Changeset 23361
- Timestamp:
- Jun 19, 2013, 2:43:41 PM (8 years ago)
- Location:
- extensions/UserCollections
- Files:
-
- 3 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/UserCollections/include/UserCollection.class.php
r20099 r23361 26 26 'date_creation' => '0000-00-00 00:00:00', 27 27 'nb_images' => 0, 28 'active' => false,29 'public' => false,28 'active' => 0, 29 'public' => 0, 30 30 'public_id' => null, 31 31 ); … … 56 56 { 57 57 $query = ' 58 SELECT 59 id, 60 user_id, 61 name, 62 date_creation, 63 nb_images, 64 active, 65 public, 66 public_id 58 SELECT * 67 59 FROM '.COLLECTIONS_TABLE.' 68 60 WHERE … … 107 99 { 108 100 $this->data['name'] = $name; 109 $this->data['active'] = $active;110 $this->data['public'] = $public;101 $this->data['active'] = (int)$active; 102 $this->data['public'] = (int)$public; 111 103 $this->data['public_id'] = 'uc'.hash('crc32', uniqid(serialize($this->data), true)); 112 104 … … 139 131 $this->addImages($images); 140 132 } 141 142 // only one active collection allowed143 if ($this->data['active'])144 {145 $query = '146 UPDATE '.COLLECTIONS_TABLE.'147 SET active = 0148 WHERE149 user_id = '.$this->data['user_id'].'150 AND id != '.$this->data['id'].'151 ;';152 pwg_query($query);153 }154 133 } 155 134 else … … 210 189 if (empty($image_ids) or !is_array($image_ids)) return; 211 190 212 foreach ($image_ids as $image_id) 213 { 214 unset($this->images[ array_search($image_id, $this->images) ]); 215 } 191 $this->images = array_diff($this->images, $image_ids); 216 192 217 193 $query = ' … … 241 217 if ($this->isInSet($image_id)) continue; 242 218 243 array_push($this->images, $image_id); 244 array_push($inserts, array('col_id'=>$this->data['id'], 'image_id'=>$image_id)); 219 $this->images[] = $image_id; 220 $inserts[] = array( 221 'col_id' => $this->data['id'], 222 'image_id' => $image_id, 223 ); 245 224 } 246 225 … … 302 281 { 303 282 $set = array( 283 'ID' => $this->data['id'], 304 284 'NAME' => $this->data['name'], 305 285 'NB_IMAGES' => $this->data['nb_images'], … … 308 288 'DATE_CREATION' => $this->data['date_creation'], 309 289 'U_PUBLIC' => USER_COLLEC_PUBLIC . 'view/'.$this->data['public_id'], 310 'IS_TEMP' => $this->data['name'] == 'temp',311 290 ); 312 291 … … 568 547 return $content; 569 548 } 549 550 /** 551 * delete 552 */ 553 function delete() 554 { 555 $this->clearImages(); 556 pwg_query('DELETE FROM '.COLLECTIONS_TABLE.' WHERE id = '.$this->data['id'].';'); 557 } 570 558 } 571 559 -
extensions/UserCollections/include/collections.inc.php
r23166 r23361 19 19 if (is_a_guest()) access_denied(); 20 20 21 $template->set_filename('index', dirname(__FILE__) . '/../template/list.tpl');21 $template->set_filename('index', realpath(USER_COLLEC_PATH.'template/list.tpl')); 22 22 23 23 // actions … … 29 29 case 'new': 30 30 { 31 $UserCollection = new UserCollection('new', array(), empty($_GET['name']) ? 'temp' : $_GET['name'], 1); 32 33 if (isset($_GET['redirect'])) 34 { 35 $redirect = USER_COLLEC_PUBLIC.'edit/'.$UserCollection->getParam('id'); 31 if (empty($_GET['name'])) 32 { 33 array_push($page['errors'], l10n('Please give a name')); 36 34 } 37 35 else 38 36 { 39 $redirect = USER_COLLEC_PUBLIC; 40 } 41 redirect($redirect); 37 $UserCollection = new UserCollection('new', array(), $_GET['name'], 1); 38 39 if (isset($_GET['redirect'])) 40 { 41 $redirect = USER_COLLEC_PUBLIC.'edit/'.$UserCollection->getParam('id'); 42 } 43 else 44 { 45 $redirect = USER_COLLEC_PUBLIC; 46 } 47 redirect($redirect); 48 } 42 49 break; 43 50 } … … 46 53 case 'delete': 47 54 { 48 $query = ' 49 DELETE ci, c 50 FROM '.COLLECTION_IMAGES_TABLE.' AS ci 51 RIGHT JOIN '.COLLECTIONS_TABLE.' AS c 52 ON ci.col_id = c.id 53 WHERE 54 c.user_id = '.$user['id'].' 55 AND c.id = '.$_GET['col_id'].' 56 ;'; 57 pwg_query($query); 58 59 redirect(USER_COLLEC_PUBLIC); 60 break; 61 } 62 63 // save 64 case 'save': 65 { 66 if (empty($_GET['name'])) 67 { 68 array_push($page['errors'], l10n('Please give a name')); 69 } 70 else 71 { 72 $query = ' 73 UPDATE '.COLLECTIONS_TABLE.' 74 SET 75 name = "'.pwg_db_real_escape_string($_GET['name']).'", 76 active = 0 77 WHERE 78 user_id = '.$user['id'].' 79 AND id = '.$_GET['col_id'].' 80 ;'; 81 pwg_query($query); 82 55 try { 56 $UserCollection = new UserCollection($_GET['col_id']); 57 $UserCollection->delete(); 83 58 redirect(USER_COLLEC_PUBLIC); 59 } 60 catch (Exception $e) 61 { 62 $page['errors'][] = $e->getMessage(); 84 63 } 85 64 break; … … 87 66 88 67 // set active 89 case ' set_active':68 case 'toggle_active': 90 69 { 91 70 $query = ' 92 71 UPDATE '.COLLECTIONS_TABLE.' 93 SET active = 0 94 WHERE user_id = '.$user['id'].' 95 ;'; 96 pwg_query($query); 97 98 $query = ' 99 UPDATE '.COLLECTIONS_TABLE.' 100 SET active = 1 72 SET active = IF(active=1, 0, 1) 101 73 WHERE 102 74 user_id = '.$user['id'].' … … 111 83 } 112 84 113 114 // get collections115 $query = '116 SELECT *117 FROM '.COLLECTIONS_TABLE.'118 WHERE user_id = '.$user['id'].'119 ORDER BY date_creation DESC120 ';121 $collections = hash_from_query($query, 'id');122 123 foreach ($collections as $col)124 {125 $col['date_creation'] = format_date($col['date_creation'], true);126 $col['U_EDIT'] = USER_COLLEC_PUBLIC.'edit/'.$col['id'];127 $col['U_ACTIVE'] = add_url_params(USER_COLLEC_PUBLIC, array('action'=>'set_active','col_id'=>$col['id']));128 $col['U_DELETE'] = add_url_params(USER_COLLEC_PUBLIC, array('action'=>'delete','col_id'=>$col['id']));129 130 if (isset($pwg_loaded_plugins['BatchDownloader']))131 {132 $col['U_DOWNLOAD'] = add_url_params(USER_COLLEC_PUBLIC.'edit/'.$col['id'], array('action'=>'advdown_set'));133 }134 135 // temporary collections are above save collections136 if ($col['name'] == 'temp')137 {138 $col['name'] = 'temp #'.$col['id'];139 $col['U_SAVE'] = add_url_params(USER_COLLEC_PUBLIC, array('action'=>'save','col_id'=>$col['id']));140 $template->append('temp_col', $col);141 }142 else143 {144 $template->append('collections', $col);145 }146 }147 148 85 $template->assign('U_CREATE', add_url_params(USER_COLLEC_PUBLIC, array('action'=>'new','col_id'=>'0'))); 86 87 $template->set_prefilter('index_category_thumbnails', 'user_collections_categories_list'); 88 89 include(USER_COLLEC_PATH . '/include/display_collections.inc.php'); 90 149 91 break; 150 92 } … … 160 102 } 161 103 162 $template->set_filename('index', dirname(__FILE__).'/../template/edit.tpl');104 $template->set_filename('index', realpath(USER_COLLEC_PATH.'template/edit.tpl')); 163 105 164 106 $self_url = USER_COLLEC_PUBLIC . 'edit/'.$page['col_id']; … … 169 111 'collection_toggle_url' => $self_url, 170 112 'U_LIST' => USER_COLLEC_PUBLIC, 171 'AJAX_COL_ID' => $page['col_id'],172 113 'UC_IN_EDIT' => true, 173 114 )); … … 175 116 try { 176 117 $UserCollection = new UserCollection($page['col_id']); 177 178 // security179 if ( !is_admin() and $UserCollection->getParam('user_id') != $user['id'] )180 {181 access_denied();182 }183 118 184 119 // save properties … … 244 179 } 245 180 246 // remove an element247 if ( isset($_GET['collection_toggle']) and preg_match('#^[0-9]+$#', $_GET['collection_toggle']) )248 {249 $UserCollection->removeImages(array($_GET['collection_toggle']));250 unset($_GET['collection_toggle']);251 }252 181 253 182 // add remove item links 254 $template->set_prefilter('index_thumbnails', 'user_collections_thumbnails_list_prefilter'); 183 $template->set_prefilter('index_thumbnails', 'user_collections_thumbnails_list_button'); 184 $template->set_prefilter('index', 'user_collections_thumbnails_list_cssjs'); 185 $template->set_prefilter('index_thumbnails', 'user_collections_add_colorbox'); 255 186 256 187 // thumbnails … … 273 204 add_url_params(USER_COLLEC_PUBLIC, array('action'=>'delete','col_id'=>$page['col_id'])) 274 205 ); 275 if ($conf['user_collections']['allow_public'] and $conf['user_collections']['allow_mails'] )206 if ($conf['user_collections']['allow_public'] and $conf['user_collections']['allow_mails'] and !empty($page['items'])) 276 207 { 277 208 $template->assign('U_MAIL', true); … … 308 239 $UserCollection = new UserCollection($page['col_id']); 309 240 $page['col_id'] = $UserCollection->getParam('id'); 241 242 $template->set_prefilter('index_thumbnails', 'user_collections_add_colorbox'); 310 243 311 244 // thumbnails … … 328 261 } 329 262 330 331 function user_collections_ thumbnails_in_collection($tpl_thumbnails_var, $pictures)263 // modification on mainpage_categories.tpl 264 function user_collections_categories_list($content, &$samrty) 332 265 { 333 global $template, $page; 334 335 $url = USER_COLLEC_PUBLIC . 'edit/'.$page['col_id']; 336 337 foreach ($tpl_thumbnails_var as &$thumbnail) 338 { 339 $src_image = new SrcImage($thumbnail); 340 341 $thumbnail['FILE_SRC'] = DerivativeImage::url(IMG_LARGE, $src_image); 342 $thumbnail['URL'] = duplicate_picture_url( 343 array( 344 'image_id' => $thumbnail['id'], 345 'image_file' => $thumbnail['file'], 346 'section' => 'none', 347 ), 348 array('start') 349 ); 350 351 $thumbnail['COLLECTION_SELECTED'] = true; 352 $thumbnail['COLLECTION_TOGGLE_URL'] = add_url_params($url, array('collection_toggle'=>$thumbnail['id'])); 353 } 354 355 $template->set_prefilter('index_thumbnails', 'user_collections_add_colorbox'); 356 357 return $tpl_thumbnails_var; 266 $search[0] = '<div class="thumbnailCategory">'; 267 $replace[0] = '<div class="thumbnailCategory {*if $cat.active}activeCollection{/if*}"> 268 <div class="collectionActions"> 269 <a href="{$cat.URL}" rel="nofollow">{"Edit"|@translate}</a> 270 | <a href="{$cat.U_DELETE}" onClick="return confirm(\'{"Are you sure?"|@translate}\');" rel="nofollow">{"Delete"|@translate}</a> 271 {if $cat.U_ACTIVE}| <a href="{$cat.U_ACTIVE}" rel="nofollow">{if $cat.active}{"set inactive"|@translate}{else}{"set active"|@translate}{/if}</a>{/if} 272 </div>'; 273 274 // $search[1] = '<a href="{$cat.URL}">{$cat.NAME}</a>'; 275 // $replace[1] = '<a href="{$cat.URL}">{$cat.NAME}</a> {if $cat.active}<span class="collectionActive">({"active"|@translate})</span>{/if}'; 276 277 return str_replace($search, $replace, $content); 358 278 } 359 279 280 // colorbox 360 281 function user_collections_add_colorbox($content) 361 282 { -
extensions/UserCollections/include/display_thumbnails.inc.php
r21382 r23361 113 113 ); 114 114 } 115 116 117 function user_collections_thumbnails_in_collection($tpl_thumbnails_var, $pictures) 118 { 119 global $template, $page; 120 121 $url = USER_COLLEC_PUBLIC . 'edit/'.$page['col_id']; 122 123 foreach ($tpl_thumbnails_var as &$thumbnail) 124 { 125 $src_image = new SrcImage($thumbnail); 126 127 $thumbnail['FILE_SRC'] = DerivativeImage::url(IMG_LARGE, $src_image); 128 $thumbnail['URL'] = duplicate_picture_url( 129 array( 130 'image_id' => $thumbnail['id'], 131 'image_file' => $thumbnail['file'], 132 'section' => 'none', 133 ), 134 array('start') 135 ); 136 137 $thumbnail['COLLECTION_SELECTED'] = true; 138 $thumbnail['COLLECTION_TOGGLE_URL'] = add_url_params($url, array('collection_toggle'=>$thumbnail['id'])); 139 } 140 141 return $tpl_thumbnails_var; 142 } 115 143 116 144 ?> -
extensions/UserCollections/include/events.inc.php
r21382 r23361 20 20 if (in_array(@$tokens[1], array('edit','view','list'))) 21 21 { 22 $page['sub_section'] = $tokens[1]; 22 $page['sub_section'] = $tokens[1]; 23 if ($tokens[1]=='edit' and isset($conf['GThumb']) && is_array($conf['GThumb'])) 24 { 25 $conf['GThumb']['big_thumb'] = false; // big thumb is buggy with removes 26 } 23 27 } 24 28 else … … 55 59 // | CATEGORY PAGE 56 60 // +-----------------------------------------------------------------------+ 57 /* toggle an image, in case of no javascript or first call (must create the collection) */58 function user_collections_index_actions()59 {60 if (is_a_guest()) return;61 62 global $page, $UserCollection;63 64 // add image to collection list65 if ( isset($_GET['collection_toggle']) and preg_match('#^[0-9]+$#', $_GET['collection_toggle']) )66 {67 if (empty($UserCollection))68 {69 $UserCollection = new UserCollection(get_current_collection_id(true));70 }71 $UserCollection->toggleImage($_GET['collection_toggle']);72 redirect(duplicate_index_url(array(), array('collection_toggle')));73 }74 }75 76 61 /* add buttons on thumbnails list */ 77 62 function user_collections_thumbnails_list($tpl_thumbnails_var, $pictures) … … 79 64 if (is_a_guest()) return $tpl_thumbnails_var; 80 65 81 global $page, $template, $ UserCollection;66 global $page, $template, $user; 82 67 83 68 // the content is different on collection edition page and no button on batch downloader set edition page … … 87 72 } 88 73 89 // get existing collections 90 $col_id = get_current_collection_id(false); 91 if (empty($UserCollection) and $col_id !== false) 92 { 93 $UserCollection = new UserCollection($col_id); 94 $collection = $UserCollection->getImages(); 95 } 96 else if (!empty($UserCollection)) 97 { 98 $collection = $UserCollection->getImages(); 99 } 100 else 101 { 102 $collection = array(); 103 } 104 105 // if the collection doesn't exists we don't use AJAX to force menu refresh 106 if ($col_id === false) 107 { 108 $template->assign('NO_AJAX', true); 109 } 110 else 111 { 112 $template->assign('AJAX_COL_ID', $col_id ); 113 } 114 115 // template vars 116 $url = duplicate_index_url(array(), array('collection_toggle')); 74 $image_ids = array_map(create_function('$i', 'return $i["id"];'), $pictures); 75 76 // get collections for each picture 77 $query = ' 78 SELECT 79 image_id, 80 GROUP_CONCAT(col_id) AS col_ids 81 FROM '.COLLECTION_IMAGES_TABLE.' 82 WHERE col_id IN ( 83 SELECT id 84 FROM '.COLLECTIONS_TABLE.' 85 WHERE user_id = '.$user['id'].' 86 ) 87 AND image_id IN('.implode(',', $image_ids).') 88 GROUP BY image_id 89 ;'; 90 $image_collections = simple_hash_from_query($query, 'image_id', 'col_ids'); 117 91 118 92 foreach ($tpl_thumbnails_var as &$thumbnail) 119 93 { 120 if (in_array($thumbnail['id'], $collection)) 121 { 122 $thumbnail['COLLECTION_SELECTED'] = true; 123 } 124 $thumbnail['COLLECTION_TOGGLE_URL'] = add_url_params($url, array('collection_toggle'=>$thumbnail['id'])); 94 $thumbnail['COLLECTIONS'] = @$image_collections[ $thumbnail['id'] ]; 125 95 } 126 96 unset($thumbnail); 127 97 98 // get all collections 99 $query = ' 100 SELECT id, name, nb_images, active 101 FROM '.COLLECTIONS_TABLE.' 102 WHERE user_id = '.$user['id'].' 103 ORDER BY name ASC 104 ;'; 105 $collections = hash_from_query($query, 'id'); 106 128 107 $template->assign(array( 108 'COLLECTIONS' => $collections, 129 109 'USER_COLLEC_PATH' => USER_COLLEC_PATH, 130 110 )); 131 111 132 112 // thumbnails buttons 133 $template->set_prefilter('index_thumbnails', 'user_collections_thumbnails_list_prefilter'); 113 $template->set_prefilter('index_thumbnails', 'user_collections_thumbnails_list_button'); 114 $template->set_prefilter('index', 'user_collections_thumbnails_list_cssjs'); 134 115 135 116 return $tpl_thumbnails_var; 136 117 } 137 118 138 function user_collections_thumbnails_list_prefilter($content, &$smarty) 139 { 140 // add links 119 // add links 120 function user_collections_thumbnails_list_button($content, &$smarty) 121 { 141 122 $search = '#(<li>|<li class="gthumb">)#'; 142 123 $replace = '$1 143 {strip}<a class="addCollection" href="{$thumbnail.COLLECTION_TOGGLE_URL}" data-id="{$thumbnail.id}" data-stat="{if $thumbnail.COLLECTION_SELECTED}remove{else}add{/if}" rel="nofollow"> 144 <span class="uc_remove" {if not $thumbnail.COLLECTION_SELECTED}style="display:none;"{/if}> 145 {\'Remove from collection\'|@translate} <img src="{$ROOT_URL}{$USER_COLLEC_PATH}template/resources/image_delete.png" title="{\'Remove from collection\'|@translate}"> 146 </span> 147 <span class="uc_add" {if $thumbnail.COLLECTION_SELECTED}style="display:none;"{/if}> 148 {\'Add to collection\'|@translate} <img src="{$ROOT_URL}{$USER_COLLEC_PATH}template/resources/image_add.png" title="{\'Add to collection\'|@translate}"> 149 </span> 124 {strip}<a class="addCollection" data-id="{$thumbnail.id}" data-cols="[{$thumbnail.COLLECTIONS}]" rel="nofollow"> 125 {if not $UC_IN_EDIT} 126 {\'Add to collection\'|@translate} <img src="{$ROOT_URL}{$USER_COLLEC_PATH}template/resources/image_add.png" alt="[+]"> 127 {else} 128 {\'Remove from collection\'|@translate} <img src="{$ROOT_URL}{$USER_COLLEC_PATH}template/resources/image_delete.png" alt="[+]"> 129 {/if} 150 130 </a>{/strip}'; 151 152 // custom CSS and AJAX request 131 132 return preg_replace($search, $replace, $content); 133 } 134 135 // add css & js and menu 136 function user_collections_thumbnails_list_cssjs($content, &$smarty) 137 { 153 138 $content.= file_get_contents(USER_COLLEC_PATH.'template/thumbnails_css_js.tpl'); 154 155 return preg_replace($search, $replace, $content); 139 return $content; 156 140 } 157 141 … … 165 149 if (is_a_guest()) return; 166 150 167 global $template, $picture, $UserCollection; 168 169 // add image to collection list 170 if ( isset($_GET['action']) and $_GET['action'] == 'collection_toggle' ) 171 { 172 if (empty($UserCollection)) 173 { 174 $UserCollection = new UserCollection(get_current_collection_id(true)); 175 } 176 177 $UserCollection->toggleImage($picture['current']['id']); 178 redirect(duplicate_picture_url()); 179 } 180 181 // get existing collection 182 if (empty($UserCollection) and ($col_id = get_current_collection_id(false)) !== false) 183 { 184 $UserCollection = new UserCollection($col_id); 185 $collection = $UserCollection->isInSet($picture['current']['id']); 186 } 187 else if (!empty($UserCollection)) 188 { 189 $collection = $UserCollection->isInSet($picture['current']['id']); 190 } 191 else 192 { 193 $collection = false; 194 } 195 196 $url = add_url_params(duplicate_picture_url(), array('action'=>'collection_toggle')); 197 198 $button = ' 199 <a href="'.$url.'" title="'.($collection?l10n('Remove from collection'):l10n('Add to collection')).'" class="pwg-state-default pwg-button" rel="nofollow"> 200 <span class="pwg-icon" style="background:url(\''.get_root_url().USER_COLLEC_PATH.'template/resources/image_'.($collection?'delete':'add').'.png\') center center no-repeat;"> </span> 201 <span class="pwg-button-text">'.($collection?l10n('Remove from collection'):l10n('Add to collection')).'</span> 202 </a>'; 203 // $template->add_picture_button($button, 50); 204 $template->concat('PLUGIN_PICTURE_ACTIONS', $button); 151 global $template, $picture, $user; 152 153 // get collections for this picture 154 $query = ' 155 SELECT GROUP_CONCAT(col_id) 156 FROM '.COLLECTION_IMAGES_TABLE.' 157 WHERE col_id IN ( 158 SELECT id 159 FROM '.COLLECTIONS_TABLE.' 160 WHERE user_id = '.$user['id'].' 161 ) 162 AND image_id = '.$picture['current']['id'].' 163 GROUP BY image_id 164 ;'; 165 list($image_collections) = pwg_db_fetch_row(pwg_query($query)); 166 167 // get all collections 168 $query = ' 169 SELECT id, name, nb_images, active 170 FROM '.COLLECTIONS_TABLE.' 171 WHERE user_id = '.$user['id'].' 172 ORDER BY name ASC 173 ;'; 174 $collections = hash_from_query($query, 'id'); 175 176 $template->assign(array( 177 'CURRENT_COLLECTIONS' => $image_collections, 178 'COLLECTIONS' => $collections, 179 'USER_COLLEC_PATH' => USER_COLLEC_PATH, 180 'USER_COLLEC_ABS_PATH' => realpath(USER_COLLEC_PATH).'/', 181 'IN_PICTURE' => true, 182 )); 183 184 // toolbar button 185 $template->set_filename('usercol_button', realpath(USER_COLLEC_PATH.'template/picture_button.tpl')); 186 $button = $template->parse('usercol_button', true); 187 $template->add_picture_button($button, 50); 205 188 } 206 189 … … 225 208 $max = 6; 226 209 227 global $template, $page, $conf, $user , $UserCollection;210 global $template, $page, $conf, $user; 228 211 $menu = &$menu_ref_arr[0]; 229 230 // the editable counter is for the active collection, except if we are currently editing a collection231 $col_in_edit = 0;232 if ( @$page['section'] == 'collections' and @$page['sub_section']=='edit' and !empty($page['col_id']) )233 {234 $col_in_edit = $page['col_id'];235 }236 212 237 213 if (($block = $menu->get_block('mbUserCollection')) != null) … … 250 226 for ($i=0; $i<$max && $i<count($collections); $i++) 251 227 { 252 $collections[$i]['count_handler'] = $col_in_edit!=0 ? $collections[$i]['id']==$col_in_edit : $collections[$i]['active'];253 228 $collections[$i]['U_EDIT'] = USER_COLLEC_PUBLIC.'edit/'.$collections[$i]['id']; 254 array_push($data['collections'], $collections[$i]);229 $data['collections'][] = $collections[$i]; 255 230 } 256 231 -
extensions/UserCollections/include/functions.inc.php
r20093 r23361 54 54 function get_collection_preferred_image_orders() 55 55 { 56 global $conf , $page;56 global $conf; 57 57 58 58 return trigger_event('get_category_preferred_image_orders', array( … … 72 72 } 73 73 74 function get_collections_preferred_orders() 75 { 76 return array( 77 array(l10n('Name, A → Z'), 'name ASC', true), 78 array(l10n('Name, Z → A'), 'name DESC', true), 79 array(l10n('Date created, new → old'), 'date_creation DESC', true), 80 array(l10n('Date created, old → new'), 'date_creation ASC', true), 81 array(l10n('Photos number, high → low'), 'nb_images DESC', true), 82 array(l10n('Photos number, low → high'), 'nb_images ASC', true), 83 ); 84 } 85 74 86 ?> -
extensions/UserCollections/include/ws_functions.inc.php
r20090 r23361 12 12 array( 13 13 'name' => array(), 14 'user_id' => array('default' => null ),14 'user_id' => array('default' => null, 'info'=>'Admin parameter, default is current user'), 15 15 'active' => array('default' => 0), 16 16 'public' => array('default' => 0), 17 17 ), 18 'Create a new User Collection. If "user_id" is empty, the collection is created for the current user.'18 'Create a new User Collection.' 19 19 ); 20 20 … … 23 23 'ws_collections_delete', 24 24 array( 25 'col_id' => array( ),26 ), 27 'Delete a User Collection. The current user must be admin or owner of the collection.'25 'col_id' => array('info'=>'The current user must be admin or owner of the collection'), 26 ), 27 'Delete a User Collection.' 28 28 ); 29 29 … … 33 33 array( 34 34 'col_id' => array('default' => null), 35 'user_id' => array('default' => null ),35 'user_id' => array('default' => null, 'info'=>'Admin parameter, default is current user'), 36 36 'name' => array('default' => null), 37 37 'public' => array('default' => null), … … 45 45 'ws_collections_addImages', 46 46 array( 47 'col_id' => array( ),47 'col_id' => array('info'=>'The current user must be admin or owner of the collection'), 48 48 'image_ids' => array('flags'=>WS_PARAM_FORCE_ARRAY), 49 49 ), 50 'Add images to a collection. The current user must be admin or owner of the collection.'50 'Add images to a collection.' 51 51 ); 52 52 … … 55 55 'ws_collections_removeImages', 56 56 array( 57 'col_id' => array( ),57 'col_id' => array('info'=>'The current user must be admin or owner of the collection'), 58 58 'image_ids' => array('flags'=>WS_PARAM_FORCE_ARRAY), 59 59 ), 60 'Remove images from a collection. The current user must be admin or owner of the collection.'60 'Remove images from a collection.' 61 61 ); 62 62 … … 78 78 array( 79 79 'col_id' => array(), 80 'content' => array('default'=>array('id','name','url','path'), 'flags'=>WS_PARAM_FORCE_ARRAY), 81 ), 82 'Returns a serialized version of the collection in CSV.<br>Available options for "content" are : id, file, name, url, path.<br>The return type is plain/text whatever you select as response format.' 80 'content' => array( 81 'default'=>array('id','name','url','path'), 82 'flags'=>WS_PARAM_FORCE_ARRAY, 83 'info'=>'Available options are: id, file, name, url, path' 84 ), 85 ), 86 'Returns a serialized version of the collection in CSV.<br>The return type is plain/text whatever you select as response format.' 83 87 ); 84 88 } -
extensions/UserCollections/language/en_UK/plugin.lang.php
r20150 r23361 27 27 $lang['Save'] = 'Save'; 28 28 $lang['%d more...'] = '%d more...'; 29 $lang['(remove)'] = '(remove)'; 29 30 30 31 $lang['Allow users to set their collections as public'] = 'Allow users to set their collections as public'; … … 58 59 $lang['Date added to collection, new → old'] = 'Date added to collection, new → old'; 59 60 $lang['Date added to collection, old → new'] = 'Date added to collection, old → new'; 60 61 $lang['Name, A → Z'] = 'Name, A → Z'; 62 $lang['Name, Z → A'] = 'Name, Z → A'; 63 $lang['Photos number, high → low'] = 'Photos number, high → low'; 64 $lang['Photos number, low → high'] = 'Photos number, low → high'; 61 65 62 66 ?> -
extensions/UserCollections/language/fr_FR/plugin.lang.php
r20093 r23361 19 19 $lang['Collection'] = 'Collection'; 20 20 $lang['Remove from collection'] = 'Supprimer de la collection'; 21 $lang['Add to collection'] = 'Ajouter à lacollection';21 $lang['Add to collection'] = 'Ajouter à une collection'; 22 22 $lang['Clear'] = 'Vider'; 23 23 $lang['You have %d collection'] = 'Vous avez %d collection'; … … 27 27 $lang['Save'] = 'Sauvegarder'; 28 28 $lang['%d more...'] = 'et %d autres...'; 29 $lang['(remove)'] = '(retirer)'; 29 30 30 31 $lang['Allow users to set their collections as public'] = 'Les utilisateurs peuvent rendre leurs collections publiques'; … … 58 59 $lang['Date added to collection, new → old'] = 'Date d\'ajout à la collection, récent → ancien'; 59 60 $lang['Date added to collection, old → new'] = 'Date d\'ajout à la collection, ancien → récent'; 61 $lang['Name, A → Z'] = 'Nom, A → Z'; 62 $lang['Name, Z → A'] = 'Nom, Z → A'; 63 $lang['Photos number, high → low'] = 'Nombre de photos, élévé → faible'; 64 $lang['Photos number, low → high'] = 'Nombre de photos, faible → élévé'; 60 65 61 66 ?> -
extensions/UserCollections/main.inc.php
r21382 r23361 4 4 Version: auto 5 5 Description: Registered users can select pictures from the gallery and save them into collections, like advanced favorites. 6 Plugin URI: http://piwigo.org/ext/extension_view.php?eid=6156 Plugin URI: auto 7 7 Author: Mistic 8 8 Author URI: http://www.strangeplanet.fr … … 41 41 42 42 // thumbnails actions 43 add_event_handler('loc_end_index', 'user_collections_index_actions');44 43 add_event_handler('loc_end_index_thumbnails', 'user_collections_thumbnails_list', EVENT_HANDLER_PRIORITY_NEUTRAL-10, 2); 45 44 -
extensions/UserCollections/template/list.tpl
r17519 r23361 2 2 3 3 {footer_script require='jquery'} 4 jQuery(". save_col").click(function() {ldelim}4 jQuery(".new_col").click(function() {ldelim} 5 5 var name = prompt("{'Collection name:'|@translate}"); 6 6 if (name != null) {ldelim} … … 11 11 } 12 12 }); 13 14 jQuery(".titrePage h2").append(" [{$COLLECTIONS_COUNT}]"); 13 15 {/footer_script} 14 15 {if $themeconf.name == "clear"}16 {html_head}{literal}17 <style type="text/css">.collecList a { color:#eee; }</style>18 {/literal}{/html_head}19 {/if}20 16 21 17 {* <!-- Menubar & titrePage --> *} … … 35 31 36 32 37 <p style="text-align:left;font-weight:bold;margin:20px;"><a href="{$U_CREATE}" class=" save_col">{'Create a new collection'|@translate}</a></p>33 <p style="text-align:left;font-weight:bold;margin:20px;"><a href="{$U_CREATE}" class="new_col">{'Create a new collection'|@translate}</a></p> 38 34 39 40 {if $temp_col} 41 <fieldset> 42 <legend>{'Unsaved collections'|@translate}</legend> 43 44 <ul class="collecList"> 45 {foreach from=$temp_col item=col} 46 <li {if $col.active}class="active"{/if}> 47 <p class="collecTitle"> 48 <a href="{$col.U_EDIT}" rel="nofollow"><b>{$col.name}</b></a> 49 <i>{'%d photos'|@translate|@sprintf:$col.nb_images}</i> 50 </p> 51 <p class="collecActions"> 52 <a href="{$col.U_EDIT}" rel="nofollow">{'Edit'|@translate}</a> 53 | <a href="{$col.U_SAVE}" class="save_col" rel="nofollow">{'save'|@translate}</a> 54 {if $col.U_DOWNLOAD}| <a href="{$col.U_DOWNLOAD}" rel="nofollow">{'download'|@translate}</a>{/if} 55 | <a href="{$col.U_DELETE}" onClick="return confirm('{'Are you sure?'|@translate}');" rel="nofollow">{'Delete'|@translate}</a> 56 {if not $col.active}| <a href="{$col.U_ACTIVE}" rel="nofollow">{'set active'|@translate}</a>{/if} 57 </p> 58 </li> 59 {/foreach} 60 </ul> 61 </fieldset> 62 {/if} 63 64 65 {if $collections} 66 <fieldset> 67 <legend>{'Saved collections'|@translate}</legend> 68 69 <ul class="collecList"> 70 {foreach from=$collections item=col} 71 <li {if $col.active}class="active"{/if}> 72 <p class="collecDate"> 73 {'created on %s'|@translate|@sprintf:$col.date_creation} 74 </p> 75 <p class="collecTitle"> 76 <a href="{$col.U_EDIT}" rel="nofollow"><b>{$col.name}</b></a> 77 <i>{'%d photos'|@translate|@sprintf:$col.nb_images}</i> 78 </p> 79 <p class="collecActions"> 80 <a href="{$col.U_EDIT}" rel="nofollow">{'Edit'|@translate}</a> 81 {if $col.U_DOWNLOAD}| <a href="{$col.U_DOWNLOAD}" rel="nofollow">{'download'|@translate}</a>{/if} 82 | <a href="{$col.U_DELETE}" onClick="return confirm('{'Are you sure?'|@translate}');" rel="nofollow">{'Delete'|@translate}</a> 83 {if not $col.active}| <a href="{$col.U_ACTIVE}" rel="nofollow">{'set active'|@translate}</a>{/if} 84 </p> 85 </li> 86 {/foreach} 87 </ul> 88 </fieldset> 35 {if !empty($CATEGORIES)} 36 {$CATEGORIES} 37 {else} 38 {'You have no collection'|@translate} 89 39 {/if} 90 40 -
extensions/UserCollections/template/menublock_user_collec.tpl
r20097 r23361 11 11 {foreach from=$block->data.collections item=col} 12 12 <li> 13 <a href="{$col.U_EDIT}" { if $col.active}style="font-weight:bold;"{/if} rel="nofollow">{$col.name}</a> 14 { if $col.active}<i class="menuInfoCat">({'active'|@translate})</i> {/if}15 <span class="menuInfoCat">[<span {if $col.count_handler}class="nbImagesCollec"{/if}>{$col.nb_images}</span>]</span>13 <a href="{$col.U_EDIT}" {*if $col.active}style="font-weight:bold;"{/if*} rel="nofollow">{$col.name}</a> 14 {*if $col.active}<i class="menuInfoCat">({'active'|@translate})</i> {/if*} 15 <span class="menuInfoCat">[<span class="nbImagesCollec-{$col.id}">{$col.nb_images}</span>]</span> 16 16 </li> 17 17 {/foreach} 18 {if $block->data.MORE}<li class="menuInfoCat"> {'%d more...'|@translate|sprintf:$block->data.MORE}</li>{/if}18 {if $block->data.MORE}<li class="menuInfoCat"><a href="{$block->data.U_LIST}">{'%d more...'|@translate|sprintf:$block->data.MORE}</a></li>{/if} 19 19 {/strip}</ul> 20 20 {/if} -
extensions/UserCollections/template/style.css
r21382 r23361 42 42 margin-left:5px; 43 43 } 44 45 .collecList { 46 list-style:none; 47 padding:0; 48 margin:0; 44 45 /* .thumbnailCategory.activeCollection { 46 border:1px solid #999; 47 } */ 48 .thumbnailCategory { 49 position:relative; 49 50 } 50 .collecList li { 51 height:35px; 52 padding:5px 10px; 53 margin:4px 0; 54 background:#444; 55 border-radius:4px; 56 } 57 .collecList li.active { 58 background:#555; 59 border:1px solid #999; 60 } 61 .collecList p { 62 margin:0; 63 } 64 .collecList .collecDate { 65 float:right; 66 font-size:0.9em; 67 } 68 .collecList .collecActions { 69 margin-top:2px; 70 display:none; 71 } 72 .collecList li:hover .collecActions { 73 display:block; 74 } 75 51 .thumbnailCategory .collectionActions { 52 display:none; 53 position:absolute; 54 right:5px; 55 bottom:5px; 56 } 57 .thumbnailCategory:hover .collectionActions { 58 display:block; 59 } 60 /* .thumbnailCategory .collectionActive { 61 font-weight:normal; 62 font-style:italic; 63 } */ 64 76 65 /* SEND BY MAIL */ 77 66 #mail_form { -
extensions/UserCollections/template/thumbnails_css_js.tpl
r21382 r23361 1 {html_style} 2 #thumbnails li {ldelim} position:relative !important;display:inline-block; } 3 li .addCollection {ldelim} width:100%;height:16px;display:none;position:absolute;top:0;background:rgba(0,0,0,0.8);padding:2px;border-radius:2px;font-size:10px;z-index:100 !important;color:#eee;white-space:nowrap; } 4 li:hover .addCollection {ldelim} display:block !important; } 5 {/html_style} 6 7 {if not $NO_AJAX} 1 {combine_css path=$USER_COLLEC_PATH|@cat:"template/style_thumbnails.css"} 2 3 {* <!-- all pages but collection edit page --> *} 4 {if not $UC_IN_EDIT} 8 5 {footer_script require='jquery'} 9 jQuery(".addCollection").click(function() {ldelim} 10 var $trigger = jQuery(this); 11 var toggle_id = $trigger.data("id"); 12 var method = $trigger.data("stat"); 13 14 if (method != "add" && method != "remove") {ldelim} 15 $trigger.html("{'Un unknown error occured'|@translate}"); 6 var $cdm = jQuery("#collectionsDropdown"); 7 8 {if not $IN_PICTURE} 9 $cdm.on("mouseleave", function() {ldelim} 10 $cdm.hide(); 11 }); 12 {/if} 13 14 // click on "create collection" button 15 $cdm.find("a.new").on("click", function(event) {ldelim} 16 jQuery(this).hide().next().show().focus(); 17 event.stopPropagation(); 18 return false; 19 }); 20 21 // events on "new collection" input 22 $cdm.find("input.new").on({ldelim} 23 // ENTER pressed 24 "keyup": function(event) {ldelim} 25 if (event.which != 13) return; 26 27 jQuery(this).hide().prev().show(); 28 var name = jQuery(this).val(); 29 jQuery(this).val("{'Name'|@translate}"); 30 31 if (name == "") return; 32 33 jQuery.ajax({ldelim} 34 type: "GET", 35 dataType: "json", 36 url: "{$ROOT_URL}ws.php", 37 data: {ldelim} 38 format: "json", 39 method: "pwg.collections.create", 40 name: name, 41 active: 1, 42 }, 43 success: function(data) {ldelim} 44 if (data.stat == 'ok') {ldelim} 45 var col = data.result; 46 var html = '<span>★</span> <a class="add" data-id="'+ col.id +'">'+ col.name +'</a> ' 47 +'<span class="menuInfoCat">[<span class="nbImagesCollec-'+ col.id +'">'+ col.nb_images +'</span>]</span> ' 48 +'<a class="remove" data-id="'+ col.id +'">{'(remove)'|@translate}</a>' 49 +'<br>'; 50 51 $cdm.children(".switchBoxFooter").before(html); 52 $cdm.children(".noCollecMsg").remove(); 53 } 54 else {ldelim} 55 alert(data.message); 56 } 57 }, 58 error: function() {ldelim} 59 alert("{'Un unknown error occured'|@translate}"); 60 } 61 }); 62 16 63 return false; 64 }, 65 // prevent click propagation 66 "click": function(event) {ldelim} 67 event.stopPropagation(); 68 }, 69 // remove help on focus 70 "focus": function() {ldelim} 71 if (jQuery(this).val() == "{'Name'|@translate}") jQuery(this).val(""); 72 }, 73 // restore help on blur 74 "blur" : function() {ldelim} 75 if (jQuery(this).val() == "") jQuery(this).val("{'Name'|@translate}"); 17 76 } 77 }); 78 79 // add and remove links (delegate for new collections) 80 $cdm.on("click", ".add, .remove", function() {ldelim} 81 var img_id = $cdm.data("img_id"); 82 var col_id = jQuery(this).data("id"); 83 var method = jQuery(this).hasClass("add") ? "pwg.collections.addImages" : "pwg.collections.removeImages"; 18 84 19 85 jQuery.ajax({ldelim} … … 21 87 dataType: "json", 22 88 url: "{$ROOT_URL}ws.php", 23 data: {ldelim} "format": "json", "method": "pwg.collections."+method+"Images", "col_id": {$AJAX_COL_ID}, "image_ids": toggle_id }, 89 data: {ldelim} 90 format: "json", 91 method: method, 92 col_id: col_id, 93 image_ids: img_id 94 }, 24 95 success: function(data) {ldelim} 25 if (data['stat'] == 'ok') {ldelim} 26 if (method == "add") {ldelim} 27 $trigger.children(".uc_remove").show(); 28 $trigger.children(".uc_add").hide(); 29 $trigger.data("stat", "remove"); 30 } 31 else if (method == "remove") {ldelim} 32 {if $UC_IN_EDIT} 33 $trigger.parent("li").hide("fast", function() {ldelim} $(this).remove() }); 34 if (typeof batchdown_count != 'undefined') batchdown_count-=1; 35 {else} 36 $trigger.children(".uc_remove").hide(); 37 $trigger.children(".uc_add").show(); 38 $trigger.data("stat", "add"); 39 {/if} 40 } 96 if (data.stat == 'ok') {ldelim} 97 // update col counters 98 jQuery(".nbImagesCollec-"+col_id).html(data.result.nb_images); 41 99 42 jQuery(".nbImagesCollec").html(data['result']['nb_images']); 100 // update item datas 101 var $target = jQuery(".addCollection[data-id='"+ img_id +"']"); 102 var col_ids = $target.data("cols"); 103 if (method == "pwg.collections.addImages" && col_ids.indexOf(col_id) == -1) 104 col_ids[ col_ids.length ] = col_id; 105 else 106 col_ids.splice(col_ids.indexOf(col_id), 1); 107 $target.data("col", col_ids); 43 108 } 44 109 else {ldelim} 45 $trigger.html("{'Un unknown error occured'|@translate}");110 alert(data.message); 46 111 } 47 112 }, 48 113 error: function() {ldelim} 49 $trigger.html("{'Un unknown error occured'|@translate}"); 50 } 51 }); 52 114 alert("{'Un unknown error occured'|@translate}"); 115 } 116 }); 117 118 $cdm.hide(); 119 return false; 120 }); 121 122 // main button, open the menu 123 jQuery(".addCollection").on("click", function(event) {ldelim} 124 var img_id = jQuery(this).data("id"); 125 var col_ids = jQuery(this).data("cols"); 126 127 $cdm.data("img_id", img_id); 128 129 $cdm.children(".add").each(function() {ldelim} 130 if (col_ids.indexOf($(this).data("id")) != -1) {ldelim} 131 $(this).css("font-weight", "bold").next().next().show(); 132 } 133 else {ldelim} 134 $(this).css("font-weight", "normal").next().next().hide(); 135 } 136 }); 137 138 {if not $IN_PICTURE} 139 $cdm.css({ldelim} 140 "top": event.pageY-5-$(window).scrollTop(), 141 "left": Math.min(event.pageX-jQuery(window).scrollLeft()-20, jQuery(window).width()-$cdm.outerWidth(true)-5) 142 }); 143 $cdm.show(); 144 {/if} 145 146 return false; 147 }); 148 149 // try to respect theme colors 150 $cdm.children(".switchBoxFooter").css("border-top-color", $cdm.children(".switchBoxTitle").css("border-bottom-color")); 151 {/footer_script} 152 153 <div id="collectionsDropdown" class="switchBox"> 154 <div class="switchBoxTitle">{'Collections'|@translate}</div> 155 156 {foreach from=$COLLECTIONS item=col} 157 <span>★</span> <a class="add" data-id="{$col.id}">{$col.name}</a> 158 <span class="menuInfoCat">[<span class="nbImagesCollec-{$col.id}">{$col.nb_images}</span>]</span> 159 <a class="remove" data-id="{$col.id}">{'(remove)'|@translate}</a> 160 <br> 161 {foreachelse} 162 <span class="noCollecMsg">{'You have no collection'|@translate}</span> 163 {/foreach} 164 165 <div class="switchBoxFooter"> 166 <span>✚</span> <a class="new">{'Create a new collection'|@translate}</a> 167 <input class="new" value="{'Name'|@translate}" size="25"/> 168 </div> 169 </div> 170 171 {* <!-- collection edit page --> *} 172 {else} 173 {footer_script require='jquery'} 174 jQuery(".addCollection").on("click", function(event) {ldelim} 175 var $trigger = jQuery(this); 176 var img_id = jQuery(this).data("id"); 177 var col_id = {$collection.ID}; 178 179 jQuery.ajax({ldelim} 180 type: "GET", 181 dataType: "json", 182 url: "{$ROOT_URL}ws.php", 183 data: {ldelim} 184 format: "json", 185 method: "pwg.collections.removeImages", 186 col_id: col_id, 187 image_ids: img_id 188 }, 189 success: function(data) {ldelim} 190 if (data.stat == 'ok') {ldelim} 191 $trigger.parent("li").hide("fast", function() {ldelim} 192 jQuery(this).remove(); 193 if (typeof GThumb != "undefined") GThumb.build(); 194 }); 195 196 jQuery(".nbImagesCollec-"+col_id).html(data.result.nb_images); 197 if (typeof batchdown_count != 'undefined') batchdown_count = data.result.nb_images; 198 } 199 else {ldelim} 200 alert(data.message); 201 } 202 }, 203 error: function() {ldelim} 204 alert("{'Un unknown error occured'|@translate}"); 205 } 206 }); 207 208 // not working, the event is fired twice 209 event.stopPropagation(); 210 event.preventDefault(); 53 211 return false; 54 212 });
Note: See TracChangeset
for help on using the changeset viewer.