Changeset 16658
- Timestamp:
- Jul 12, 2012, 8:28:27 PM (12 years ago)
- Location:
- extensions/UserCollections
- Files:
-
- 1 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/UserCollections/include/UserCollection.class.php
r16625 r16658 24 24 'active' => false, 25 25 'public' => false, 26 'public_id' => null, 26 27 ); 27 28 $this->images = array(); 29 30 // access from public id 31 if ( strlen($col_id) == 10 and strpos($col_id, 'uc') === 0 ) 32 { 33 $query = ' 34 SELECT id 35 FROM '.COLLECTIONS_TABLE.' 36 WHERE public_id = "'.$col_id.'" 37 ;'; 38 $result = pwg_query($query); 39 40 if (!pwg_db_num_rows($result)) 41 { 42 $col_id = 0; 43 } 44 else 45 { 46 list($col_id) = pwg_db_fetch_row($result); 47 } 48 } 28 49 29 50 // load specific collection … … 37 58 nb_images, 38 59 active, 39 public 60 public, 61 public_id 40 62 FROM '.COLLECTIONS_TABLE.' 41 63 WHERE … … 48 70 { 49 71 $this->data['col_id'] = $col_id; 50 list( 51 $this->data['user_id'], 52 $this->data['name'], 53 $this->data['date_creation'], 54 $this->data['nb_images'], 55 $this->data['active'], 56 $this->data['public'] 57 ) = pwg_db_fetch_row($result); 72 $this->data = array_merge( 73 $this->data, 74 pwg_db_fetch_assoc($result) 75 ); 58 76 59 77 // make sur all pictures of the collection exist … … 89 107 $this->data['active'] = $active; 90 108 $this->data['public'] = $public; 109 $this->data['public_id'] = 'uc'.hash('crc32', uniqid(serialize($this->data, true))); 91 110 92 111 $query = ' … … 96 115 date_creation, 97 116 active, 98 public 117 public, 118 public_id 99 119 ) 100 120 VALUES( … … 103 123 NOW(), 104 124 '.(int)$this->data['active'].', 105 '.(int)$this->data['public'].' 125 '.(int)$this->data['public'].', 126 "'.$this->data['public_id'].'" 106 127 ) 107 128 ;'; … … 271 292 'PUBLIC' => (bool)$this->data['public'], 272 293 'DATE_CREATION' => format_date($this->data['date_creation'], true), 273 'U_PUBLIC' => get_absolute_root_url().USER_COLLEC_PUBLIC . 'view/'.$this->data[' col_id'],294 'U_PUBLIC' => get_absolute_root_url().USER_COLLEC_PUBLIC . 'view/'.$this->data['public_id'], 274 295 'IS_TEMP' => $this->data['name'] == 'temp', 275 296 ); -
extensions/UserCollections/include/collections.inc.php
r16625 r16658 11 11 case 'list': 12 12 { 13 // security 13 14 if (is_a_guest()) access_denied(); 14 15 15 16 $template->set_filename('index', dirname(__FILE__) . '/../template/list.tpl'); 16 17 18 // actions 17 19 if ( isset($_GET['action']) and filter_var($_GET['col_id'], FILTER_VALIDATE_INT) !== false ) 18 20 { … … 115 117 } 116 118 } 117 119 120 118 121 // get collections 119 122 $query = ' … … 134 137 if (isset($pwg_loaded_plugins['BatchDownloader'])) 135 138 { 136 $col['U_DOWNLOAD'] = USER_COLLEC_PUBLIC.'view/'.$col['id'].'&action=advdown_set'; 137 } 138 139 $col['U_DOWNLOAD'] = USER_COLLEC_PUBLIC.'view/'.$col['public_id'].'&action=advdown_set'; 140 } 141 142 // temporary collections are above save collections 139 143 if ($col['name'] == 'temp') 140 144 { … … 156 160 case 'edit': 157 161 { 162 // security 158 163 if (empty($page['col_id'])) 159 164 { … … 162 167 } 163 168 169 $template->set_filename('index', dirname(__FILE__).'/../template/edit.tpl'); 170 164 171 $self_url = USER_COLLEC_PUBLIC . 'edit/'.$page['col_id']; 165 166 $template->set_filename('index', dirname(__FILE__).'/../template/edit.tpl');167 172 $template->assign(array( 168 173 'USER_COLLEC_PATH' => USER_COLLEC_PATH, 169 ' U_VIEW' => $self_url,174 'F_ACTION' => $self_url, 170 175 'collection_toggle_url' => $self_url, 171 176 'U_LIST' => USER_COLLEC_PUBLIC, … … 176 181 $UserCollection = new UserCollection($page['col_id']); 177 182 178 if (!is_admin() and $UserCollection->getParam('user_id') != $user['id']) 183 // security 184 if ( !is_admin() and $UserCollection->getParam('user_id') != $user['id'] ) 179 185 { 180 186 access_denied(); … … 194 200 } 195 201 202 // special template 203 add_event_handler('loc_end_index_thumbnails', 'user_collections_thumbnails_in_collection', EVENT_HANDLER_PRIORITY_NEUTRAL+10, 2); // +10 to overload GThumb+ 204 $template->set_prefilter('index_thumbnails', 'user_collections_thumbnails_list_prefilter'); 205 206 // collection content 196 207 $template->assign('collection', $UserCollection->getCollectionInfo()); 197 198 // add_event_handler('loc_end_index_thumbnails', 'user_collections_thumbnails_in_collection', EVENT_HANDLER_PRIORITY_NEUTRAL, 2); 199 $template->set_prefilter('index_thumbnails', 'user_collections_thumbnails_list_prefilter'); 200 208 $page['items'] = $UserCollection->getImages(); 209 210 // navigation bar 201 211 $page['start'] = isset($_GET['start']) ? $_GET['start'] : 0; 202 $page['items'] = $UserCollection->getImages();203 204 212 if (count($page['items']) > $page['nb_image_page']) 205 213 { … … 214 222 } 215 223 224 // display 216 225 include(PHPWG_ROOT_PATH . 'include/category_default.inc.php'); 217 226 … … 229 238 case 'view': 230 239 { 231 if (empty($page['col_id'])) 240 // security 241 if ( empty($page['col_id']) or strlen($page['col_id']) != 10 or strpos($page['col_id'], 'uc') === false ) 232 242 { 233 243 $_SESSION['page_errors'][] = l10n('Invalid collection'); 234 redirect(get_home_url()); 235 } 244 redirect('index.php'); 245 } 246 247 $template->set_filename('index', dirname(__FILE__).'/../template/view.tpl'); 236 248 237 249 $self_url = USER_COLLEC_PUBLIC . 'view/'.$page['col_id']; 238 250 239 $template->set_filename('index', dirname(__FILE__).'/../template/view.tpl'); 240 $template->assign(array( 241 'USER_COLLEC_PATH' => USER_COLLEC_PATH, 242 'U_VIEW' => $self_url, 243 )); 244 245 try 246 { 251 try { 247 252 $UserCollection = new UserCollection($page['col_id']); 248 253 254 // backlink for owner 249 255 if ($UserCollection->getParam('user_id') == $user['id']) 250 256 { … … 252 258 } 253 259 260 // special template 261 add_event_handler('loc_end_index_thumbnails', 'user_collections_thumbnails_in_collection', EVENT_HANDLER_PRIORITY_NEUTRAL+10, 2); // +10 to overload GThumb+ 262 263 // collection content 254 264 $template->assign('collection', $UserCollection->getCollectionInfo()); 255 265 $page['items'] = $UserCollection->getImages(); 266 267 // navigation bar 256 268 $page['start'] = isset($_GET['start']) ? $_GET['start'] : 0; 257 $page['items'] = $UserCollection->getImages();258 259 269 if (count($page['items']) > $page['nb_image_page']) 260 270 { … … 269 279 } 270 280 281 // display 271 282 include(PHPWG_ROOT_PATH . 'include/category_default.inc.php'); 272 283 … … 289 300 290 301 291 // function user_collections_thumbnails_in_collection($tpl_thumbnails_var, $pictures) 292 // { 293 // global $page; 294 295 // foreach ($tpl_thumbnails_var as &$thumbnail) 296 // { 297 // $thumbnail['URL'] = duplicate_picture_url( 298 // array( 299 // 'image_id' => $thumbnail['id'], 300 // 'image_file' => $thumbnail['file'], 301 // 'section' => 'collections', 302 // ), 303 // array('start') 304 // ).'/'.$page['col_id']; 305 // } 306 307 // return $tpl_thumbnails_var; 308 // } 302 function user_collections_thumbnails_in_collection($tpl_thumbnails_var, $pictures) 303 { 304 global $template, $page; 305 306 $template->set_filename('index_thumbnails', dirname(__FILE__).'/../template/thumbnails.tpl'); 307 308 foreach ($tpl_thumbnails_var as &$thumbnail) 309 { 310 $src_image = new SrcImage($thumbnail); 311 312 $thumbnail['FILE_SRC'] = DerivativeImage::url(IMG_LARGE, $src_image); 313 $thumbnail['URL'] = duplicate_picture_url( 314 array( 315 'image_id' => $thumbnail['id'], 316 'image_file' => $thumbnail['file'], 317 'section' => 'none', 318 ), 319 array('start') 320 ); 321 } 322 323 return $tpl_thumbnails_var; 324 } 309 325 310 326 ?> -
extensions/UserCollections/maintain.inc.php
r16591 r16658 15 15 `active` tinyint(1) DEFAULT 0, 16 16 `public` tinyint(1) DEFAULT 0, 17 `public_id` varchar(10) NULL, 17 18 PRIMARY KEY (`id`) 18 19 ) DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 … … 31 32 32 33 function plugin_activate() 33 {} 34 { 35 global $prefixeTable; 36 37 // new collumn in beta2 38 $query = 'SHOW COLUMNS FROM `'.$prefixeTable.'collections`;'; 39 $columns = array_from_query($query, 'Field'); 40 if (!in_array('public_id', $columns)) 41 { 42 pwg_query('ALTER TABLE `'.$prefixeTable.'collections` ADD `public_id` varchar(10) NULL;'); 43 } 44 } 34 45 35 46 function plugin_uninstall() -
extensions/UserCollections/template/edit.tpl
r16625 r16658 27 27 {/footer_script} 28 28 29 29 30 {if $themeconf.name != "stripped" and $themeconf.parent != "stripped" and $themeconf.name != "simple-grey" and $themeconf.parent != "simple"} 30 31 {$MENUBAR} … … 34 35 <div id="content" class="content{if isset($MENUBAR)} contentWithMenu{/if}"> 35 36 {if $intern_menu}{$MENUBAR}{/if} 37 36 38 37 39 <div class="titrePage"> … … 46 48 {/if} 47 49 50 48 51 {if $collection and not $collection.IS_TEMP} 49 <form action="{$ U_VIEW}" method="post">52 <form action="{$F_ACTION}" method="post"> 50 53 <fieldset id="colProperties"> 51 54 <legend>{'Properties'|@translate}</legend> … … 67 70 {/if} 68 71 69 70 72 71 73 {if !empty($THUMBNAILS)} … … 79 81 {if !empty($navbar)}{include file='navigation_bar.tpl'|@get_extent:'navbar'}{/if} 80 82 83 81 84 <p style="text-align:center;font-weight:bold;margin:20px;"><a href="{$U_LIST}" rel="nofollow">{'Return to collections list'|@translate}</a></p> 82 85 -
extensions/UserCollections/template/list.tpl
r16625 r16658 13 13 {/footer_script} 14 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 15 21 {if $themeconf.name != "stripped" and $themeconf.parent != "stripped" and $themeconf.name != "simple-grey" and $themeconf.parent != "simple"} 16 22 {$MENUBAR} … … 20 26 <div id="content" class="content{if isset($MENUBAR)} contentWithMenu{/if}"> 21 27 {if $intern_menu}{$MENUBAR}{/if} 28 22 29 23 30 <div class="titrePage"> … … 30 37 {/if} 31 38 39 32 40 <p style="text-align:left;font-weight:bold;margin:20px;"><a href="{$U_CREATE}" class="save_col">{'Create a new collection'|@translate}</a></p> 41 33 42 34 43 {if $temp_col} … … 55 64 </fieldset> 56 65 {/if} 66 57 67 58 68 {if $collections} … … 82 92 {/if} 83 93 94 84 95 </div>{* <!-- content --> *} -
extensions/UserCollections/template/style.css
r16591 r16658 11 11 } 12 12 13 #publicURL {} 13 #publicURL { 14 display:inline-block; 15 height:22px; 16 } 14 17 #publicURL .url { 15 18 display:inline-block; 16 position:relative; 19 height:14px; 20 vertical-align:bottom; 21 padding:3px 10px; 22 background:#fff; 17 23 font-family:monospace; 18 24 font-size:12px; 19 background:#fff;20 25 color:#666; 21 padding:3px 10px;22 26 border:1px solid #999; 23 27 border-radius:0 3px 3px 0; … … 28 32 width:25px; 29 33 height:20px; 30 color:#666;34 vertical-align:bottom; 31 35 border:1px solid #999; 32 36 border-right:none; -
extensions/UserCollections/template/thumbnails_css_js.tpl
r16625 r16658 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: 0.8em;z-index:100;color:#eee;white-space:nowrap; }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; } 4 4 .wrap1:hover .addCollection {ldelim} display:block; } 5 5 {/html_style} -
extensions/UserCollections/template/view.tpl
r16625 r16658 1 1 {combine_css path=$USER_COLLEC_PATH|@cat:"template/style.css"} 2 2 3 3 4 {if $themeconf.name != "stripped" and $themeconf.parent != "stripped" and $themeconf.name != "simple-grey" and $themeconf.parent != "simple"} … … 8 9 <div id="content" class="content{if isset($MENUBAR)} contentWithMenu{/if}"> 9 10 {if $intern_menu}{$MENUBAR}{/if} 11 10 12 11 13 <div class="titrePage"> … … 20 22 {/if} 21 23 24 22 25 {if !empty($THUMBNAILS)} 23 26 <ul class="thumbnails" id="thumbnails"> … … 28 31 {if !empty($navbar)}{include file='navigation_bar.tpl'|@get_extent:'navbar'}{/if} 29 32 33 30 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} 31 35
Note: See TracChangeset
for help on using the changeset viewer.