Changeset 16688 for extensions/UserCollections
- Timestamp:
- Jul 13, 2012, 12:09:19 PM (12 years ago)
- Location:
- extensions/UserCollections
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/UserCollections/include/UserCollection.class.php
r16658 r16688 17 17 18 18 $this->data = array( 19 ' col_id' => 0,19 'id' => 0, 20 20 'user_id' => $user['id'], 21 21 'name' => null, … … 53 53 $query = ' 54 54 SELECT 55 id, 55 56 user_id, 56 57 name, … … 69 70 if (pwg_db_num_rows($result)) 70 71 { 71 $this->data['col_id'] = $col_id;72 72 $this->data = array_merge( 73 73 $this->data, … … 87 87 SELECT image_id 88 88 FROM '.COLLECTION_IMAGES_TABLE.' 89 WHERE col_id = '.$this->data[' col_id'].'89 WHERE col_id = '.$this->data['id'].' 90 90 ;'; 91 91 $this->images = array_from_query($query, 'image_id'); … … 107 107 $this->data['active'] = $active; 108 108 $this->data['public'] = $public; 109 $this->data['public_id'] = 'uc'.hash('crc32', uniqid(serialize($this->data , true)));109 $this->data['public_id'] = 'uc'.hash('crc32', uniqid(serialize($this->data), true)); 110 110 111 111 $query = ' … … 128 128 ;'; 129 129 pwg_query($query); 130 $this->data[' col_id'] = pwg_db_insert_id();130 $this->data['id'] = pwg_db_insert_id(); 131 131 132 132 $date = pwg_query('SELECT FROM_UNIXTIME(NOW());'); … … 146 146 WHERE 147 147 user_id = '.$this->data['user_id'].' 148 AND id != '.$this->data[' col_id'].'148 AND id != '.$this->data['id'].' 149 149 ;'; 150 150 pwg_query($query); … … 165 165 { 166 166 $this->data[$name] = $value; 167 pwg_query('UPDATE '.COLLECTIONS_TABLE.' SET '.$name.' = "'.$value.'" WHERE id = '.$this->data[' col_id'].';');167 pwg_query('UPDATE '.COLLECTIONS_TABLE.' SET '.$name.' = "'.$value.'" WHERE id = '.$this->data['id'].';'); 168 168 } 169 169 … … 213 213 DELETE FROM '.COLLECTION_IMAGES_TABLE.' 214 214 WHERE 215 col_id = '.$this->data[' col_id'].'215 col_id = '.$this->data['id'].' 216 216 AND image_id IN('.implode(',', $image_ids).') 217 217 ;'; … … 237 237 238 238 array_push($this->images, $image_id); 239 array_push($inserts, array('col_id'=>$this->data[' col_id'], 'image_id'=>$image_id));239 array_push($inserts, array('col_id'=>$this->data['id'], 'image_id'=>$image_id)); 240 240 } 241 241 … … 275 275 $query = ' 276 276 DELETE FROM '.COLLECTION_IMAGES_TABLE.' 277 WHERE col_id = '.$this->data[' col_id'].'277 WHERE col_id = '.$this->data['id'].' 278 278 ;'; 279 279 pwg_query($query); -
extensions/UserCollections/include/collections.inc.php
r16658 r16688 24 24 case 'new': 25 25 { 26 new UserCollection('new', array(), empty($_GET['name']) ? 'temp' : $_GET['name'], 1); 27 redirect(USER_COLLEC_PUBLIC); 28 break; 29 } 30 31 // clear 32 case 'clear': 33 { 34 $query = ' 35 DELETE ci 36 FROM '.COLLECTION_IMAGES_TABLE.' AS ci 37 INNER JOIN '.COLLECTIONS_TABLE.' AS c 38 ON ci.col_id = c.id 39 WHERE 40 c.user_id = '.$user['id'].' 41 AND c.id = '.$_GET['col_id'].' 42 ;'; 43 pwg_query($query); 26 $UserCollection = new UserCollection('new', array(), empty($_GET['name']) ? 'temp' : $_GET['name'], 1); 44 27 45 if ( !empty($_SERVER['HTTP_REFERER']))28 if (isset($_GET['redirect'])) 46 29 { 47 redirect($_SERVER['HTTP_REFERER']);30 $redirect = USER_COLLEC_PUBLIC.'edit/'.$UserCollection->getParam('id'); 48 31 } 32 else 33 { 34 $redirect = USER_COLLEC_PUBLIC; 35 } 36 redirect($redirect); 49 37 break; 50 38 } … … 194 182 } 195 183 184 // clear 185 if ( isset($_GET['action']) and $_GET['action'] == 'clear' ) 186 { 187 $UserCollection->clearImages(); 188 } 189 196 190 // remove an element 197 191 if ( isset($_GET['collection_toggle']) and preg_match('#^[0-9]+$#', $_GET['collection_toggle']) ) 198 192 { 199 193 $UserCollection->removeImages(array($_GET['collection_toggle'])); 194 unset($_GET['collection_toggle']); 200 195 } 201 196 … … 205 200 206 201 // collection content 207 $template->assign('collection', $UserCollection->getCollectionInfo()); 202 $col = $UserCollection->getCollectionInfo(); 203 $col['U_CLEAR'] = $self_url.'&action=clear'; 204 $col['U_DELETE'] = USER_COLLEC_PUBLIC.'&action=delete&col_id='.$page['col_id']; 205 $template->assign('collection', $col); 206 208 207 $page['items'] = $UserCollection->getImages(); 209 208 … … 252 251 $UserCollection = new UserCollection($page['col_id']); 253 252 254 // backlink for owner255 if ($UserCollection->getParam('user_id') == $user['id'])256 {257 $template->assign('U_LIST', USER_COLLEC_PUBLIC);258 }259 260 253 // special template 261 254 add_event_handler('loc_end_index_thumbnails', 'user_collections_thumbnails_in_collection', EVENT_HANDLER_PRIORITY_NEUTRAL+10, 2); // +10 to overload GThumb+ 262 255 263 256 // collection content 264 $template->assign('collection', $UserCollection->getCollectionInfo());265 257 $page['items'] = $UserCollection->getImages(); 266 258 -
extensions/UserCollections/include/events.inc.php
r16625 r16688 216 216 function user_collections_applymenu($menu_ref_arr) 217 217 { 218 global $template, $conf, $UserCollection; 218 $max = 6; 219 220 global $template, $conf, $user, $UserCollection; 219 221 $menu = &$menu_ref_arr[0]; 220 222 221 223 if (($block = $menu->get_block('mbUserCollection')) != null) 222 224 { 223 if (($col_id = get_current_collection_id(false)) !== false) 224 { 225 if (empty($UserCollection)) 226 { 227 $UserCollection = new UserCollection($col_id); 228 } 229 230 $data = array( 231 'current' => array( 232 'NAME' => $UserCollection->getParam('name'), 233 'NB_IMAGES' => $UserCollection->getParam('nb_images'), 234 ), 235 'links' => array(), 236 ); 237 238 if ($data['current']['NB_IMAGES'] > 0) 239 { 240 $data['links'] = array( 241 array( 242 'URL' => USER_COLLEC_PUBLIC.'edit/'.$UserCollection->getParam('col_id'), 243 'NAME' => l10n('Display collection'), 244 ), 245 array( 246 'URL' => USER_COLLEC_PUBLIC.'&action=clear&col_id='.$UserCollection->getParam('col_id'), 247 'NAME' => l10n('Clear collection'), 248 ), 249 ); 250 } 225 $query = ' 226 SELECT * 227 FROM '.COLLECTIONS_TABLE.' 228 WHERE user_id = '.$user['id'].' 229 ORDER BY 230 active DESC, 231 date_creation DESC 232 ;'; 233 $collections = array_values(hash_from_query($query, 'id')); 234 235 $data['collections'] = array(); 236 for ($i=0; $i<$max && $i<count($collections); $i++) 237 { 238 $collections[$i]['U_EDIT'] = USER_COLLEC_PUBLIC.'edit/'.$collections[$i]['id']; 239 array_push($data['collections'], $collections[$i]); 240 } 241 242 $data['NB_COL'] = count($collections); 243 if ($data['NB_COL'] > $max) 244 { 245 $data['MORE'] = count($collections)-$max; 251 246 } 252 247 253 248 $data['U_LIST'] = USER_COLLEC_PUBLIC; 249 $data['U_CREATE'] = USER_COLLEC_PUBLIC.'&action=new&col_id=0&redirect=true'; 254 250 255 251 $template->set_template_dir(USER_COLLEC_PATH . 'template/'); 256 $block->set_title( l10n('Collections'));252 $block->set_title('<a href="'.USER_COLLEC_PUBLIC.'">'.l10n('Collections').'</a>'); 257 253 $block->template = 'menublock_user_collec.tpl'; 258 254 $block->data = $data; -
extensions/UserCollections/include/functions.inc.php
r16591 r16688 26 26 { 27 27 $UserCollection = new UserCollection('new', array(), 'temp', 1); 28 return $UserCollection->getParam(' col_id');28 return $UserCollection->getParam('id'); 29 29 } 30 30 -
extensions/UserCollections/language/en_UK/plugin.lang.php
r16599 r16688 12 12 $lang['set active'] = 'set active'; 13 13 $lang['Saved collections'] = 'Saved collections'; 14 $lang['Current collection:'] = 'Current collection:';15 14 $lang['See all my collections'] = 'See all my collections'; 16 15 $lang['Please give a name'] = 'Please give a name'; … … 21 20 $lang['Remove from collection'] = 'Remove from collection'; 22 21 $lang['Add to collection'] = 'Add to collection'; 23 $lang['Display collection'] = 'Display';24 22 $lang['Clear collection'] = 'Clear'; 23 $lang['You have %d collections'] = 'You have %d collections'; 24 $lang['active'] = 'active'; 25 $lang['Save'] = 'Save'; 26 $lang['%d more...'] = '%d more...'; 25 27 26 28 ?> -
extensions/UserCollections/language/fr_FR/plugin.lang.php
r16599 r16688 12 12 $lang['set active'] = 'choisir comme collection active'; 13 13 $lang['Saved collections'] = 'Collections sauvegardées'; 14 $lang['Current collection:'] = 'Collection actuelle:';15 14 $lang['See all my collections'] = 'Voir toutes mes collections'; 16 15 $lang['Please give a name'] = 'Veuillez donner un nom'; … … 21 20 $lang['Remove from collection'] = 'Supprimer de la collection'; 22 21 $lang['Add to collection'] = 'Ajouter à la collection'; 23 $lang['Display collection'] = 'Afficher';24 22 $lang['Clear collection'] = 'Vider'; 23 $lang['You have %d collections'] = 'Vous avez %d collections'; 24 $lang['active'] = 'active'; 25 $lang['Save'] = 'Sauvegarder'; 26 $lang['%d more...'] = 'et %d autres...'; 25 27 26 28 ?> -
extensions/UserCollections/main.inc.php
r16597 r16688 23 23 24 24 add_event_handler('loc_end_section_init', 'user_collections_section_init'); 25 add_event_handler('loc_end_index', 'user_collections_page' );25 add_event_handler('loc_end_index', 'user_collections_page', EVENT_HANDLER_PRIORITY_NEUTRAL-10); 26 26 27 27 add_event_handler('loc_end_index', 'user_collections_index_actions'); -
extensions/UserCollections/template/edit.tpl
r16658 r16688 23 23 delay: 0, 24 24 defaultPosition: 'right' 25 }); 26 27 jQuery("#actions input").click(function() {ldelim} 28 if (confirm("{'Are you sure?'|@translate}")) {ldelim} 29 document.location.href = jQuery(this).data("href"); 30 } 31 return false; 25 32 }); 26 33 {if $collection.PUBLIC}bindZclip();{/if} … … 49 56 50 57 51 {if $collection and not $collection.IS_TEMP}58 {if $collection} 52 59 <form action="{$F_ACTION}" method="post"> 53 60 <fieldset id="colProperties"> … … 68 75 </fieldset> 69 76 </form> 70 {/if}71 77 72 78 73 {if !empty($THUMBNAILS)}79 {if $collection.NB_IMAGES > 0} 74 80 <ul class="thumbnails" id="thumbnails"> 75 81 {$THUMBNAILS} … … 82 88 83 89 84 <p style="text-align:center;font-weight:bold;margin:20px;"><a href="{$U_LIST}" rel="nofollow">{'Return to collections list'|@translate}</a></p> 90 <form id="actions" style="text-align:center;"> 91 <input type="submit" data-href="{$collection.U_CLEAR}" value="{'Clear collection'|@translate}"> 92 <input type="submit" data-href="{$collection.U_DELETE}" value="{'Delete'|@translate}"> 93 </form> 94 {/if} 95 85 96 86 97 </div>{* <!-- content --> *} -
extensions/UserCollections/template/list.tpl
r16658 r16688 56 56 | <a href="{$col.U_SAVE}" class="save_col" rel="nofollow">{'save'|@translate}</a> 57 57 {if $col.U_DOWNLOAD}| <a href="{$col.U_DOWNLOAD}" rel="nofollow">{'download'|@translate}</a>{/if} 58 | <a href="{$col.U_DELETE}" onClick="return confirm('{'Are you sure?'|@translate}');" rel="nofollow">{' delete'|@translate}</a>58 | <a href="{$col.U_DELETE}" onClick="return confirm('{'Are you sure?'|@translate}');" rel="nofollow">{'Delete'|@translate}</a> 59 59 {if not $col.active}| <a href="{$col.U_ACTIVE}" rel="nofollow">{'set active'|@translate}</a>{/if} 60 60 </p> … … 83 83 <a href="{$col.U_EDIT}" rel="nofollow">{'Edit'|@translate}</a> 84 84 {if $col.U_DOWNLOAD}| <a href="{$col.U_DOWNLOAD}" rel="nofollow">{'download'|@translate}</a>{/if} 85 | <a href="{$col.U_DELETE}" onClick="return confirm('{'Are you sure?'|@translate}');" rel="nofollow">{' delete'|@translate}</a>85 | <a href="{$col.U_DELETE}" onClick="return confirm('{'Are you sure?'|@translate}');" rel="nofollow">{'Delete'|@translate}</a> 86 86 {if not $col.active}| <a href="{$col.U_ACTIVE}" rel="nofollow">{'set active'|@translate}</a>{/if} 87 87 </p> -
extensions/UserCollections/template/menublock_user_collec.tpl
r16625 r16688 1 1 <dt>{$block->get_title()}</dt> 2 2 <dd> 3 {if $block->data.current} 4 {assign var="nb_images" value='<span class="nbImagesCollec">'|@cat:$block->data.current.NB_IMAGES|@cat:'</span>'} 5 <p>{'Current collection:'|@translate} <b>{$block->data.current.NAME}</b>, {'%d photos'|@translate|replace:'%d':'%s'|sprintf:$nb_images}</p> 6 <ul>{strip} 7 {foreach from=$block->data.links item=link} 8 <li><a href="{$link.URL}" title="{$link.TITLE}" rel="nofollow">{$link.NAME}</a></li> 3 <p><a href="{$block->data.U_LIST}">{'You have %d collections'|@translate|sprintf:$block->data.NB_COL}</a></p> 4 {if $block->data.collections} 5 <ul>{strip} 6 {foreach from=$block->data.collections item=col} 7 <li>{if $col.active} 8 <a href="{$col.U_EDIT}" style="font-weight:bold;" rel="nofollow">{$col.name}</a> <i class="menuInfoCat">({'active'|@translate})</i> <span class="menuInfoCat">[<span class="nbImagesCollec">{$col.nb_images}</span>]</span> 9 {else} 10 <a href="{$col.U_EDIT}" rel="nofollow">{$col.name}</a> <span class="menuInfoCat">[{$col.nb_images}]</span> 11 {/if}</li> 9 12 {/foreach} 13 {if $block->data.MORE}<li class="menuInfoCat">{'%d more...'|@translate|sprintf:$block->data.MORE}</li>{/if} 10 14 {/strip}</ul> 11 {/if}12 <p><a href="{$block->data.U_ LIST}" rel="nofollow">{'See all my collections'|@translate}</a></p>15 {/if} 16 <p><a href="{$block->data.U_CREATE}" rel="nofollow">{'Create a new collection'|@translate}</a></p> 13 17 </dd> -
extensions/UserCollections/template/thumbnails.tpl
r16658 r16688 5 5 rel: ".preview-box", 6 6 title: function() {ldelim} 7 return $(this).attr("title") +' · <a href="'+ $(this).data('url') +'" target="_blank">{'jump to photo'|@translate} →</a>'; 7 var title = $(this).attr("title"); 8 {if $F_ACTION} title+= ' · <a href="{$collection_toggle_url}&collection_toggle='+ $(this).data('id') +'" class="addCollection" data-id="'+ $(this).data('id') +'">{'Remove from collection'|@translate}</a>';{/if} 9 title+= ' · <a href="'+ $(this).data('url') +'" target="_blank">{'jump to photo'|@translate} →</a>'; 10 return title; 8 11 } 12 }); 13 jQuery(document).on("click", "#cboxTitle .addCollection", function() {ldelim} 14 jQuery.colorbox.close(); 15 jQuery("#thumbnails a.addCollection[data-id='"+ $(this).data('id')+"']").trigger("click"); 16 return false; 9 17 }); 10 18 {/footer_script} … … 42 50 <span class="wrap1"> 43 51 <span class="wrap2"> 44 <a href="{$thumbnail.FILE_SRC}" class="preview-box" title="{$thumbnail.NAME}" data-url="{$thumbnail.URL}" >52 <a href="{$thumbnail.FILE_SRC}" class="preview-box" title="{$thumbnail.NAME}" data-url="{$thumbnail.URL}" data-id="{$thumbnail.id}"> 45 53 <img class="thumbnail" {if $derivative->is_cached()}src="{$derivative->get_url()}"{else}src="{$ROOT_URL}{$themeconf.img_dir}/ajax-loader-small.gif" data-src="{$derivative->get_url()}"{/if} alt="{$thumbnail.TN_ALT}" title="{$thumbnail.TN_TITLE}"> 46 54 </a> -
extensions/UserCollections/template/thumbnails_css_js.tpl
r16658 r16688 1 1 {html_style} 2 2 .thumbnails .wrap1 {ldelim} position:relative !important; } 3 . 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;color:#eee;white-space:nowrap; }3 .wrap1 .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;color:#eee;white-space:nowrap; } 4 4 .wrap1:hover .addCollection {ldelim} display:block; } 5 5 {/html_style} -
extensions/UserCollections/template/view.tpl
r16658 r16688 32 32 33 33 34 {if $U_LIST}<p style="text-align:center;font-weight:bold;margin:20px;"><a href="{$U_LIST}" rel="nofollow">{'Return to collections list'|@translate}</a></p>{/if}35 36 34 </div>{* <!-- content --> *}
Note: See TracChangeset
for help on using the changeset viewer.