Changeset 25678 for extensions/UserCollections
- Timestamp:
- Nov 24, 2013, 6:09:57 PM (10 years ago)
- Location:
- extensions/UserCollections
- Files:
-
- 10 added
- 3 deleted
- 34 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
extensions/UserCollections/admin.php
r23551 r25678 8 8 include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); 9 9 $page['tab'] = (isset($_GET['tab'])) ? $_GET['tab'] : 'sets'; 10 10 11 11 $tabsheet = new tabsheet(); 12 12 $tabsheet->add('sets', l10n('Collections'), USER_COLLEC_ADMIN . '-sets'); … … 34 34 'USER_COLLEC_ADMIN' => USER_COLLEC_ADMIN, 35 35 )); 36 36 37 37 $template->assign_var_from_handle('ADMIN_CONTENT', 'user_collections'); 38 39 ?> -
extensions/UserCollections/admin/config.php
r24421 r25678 8 8 'allow_mails' => isset($_POST['allow_mails']) && isset($_POST['allow_public']), 9 9 ); 10 10 11 11 conf_update_param('user_collections', serialize($conf['user_collections'])); 12 12 } … … 18 18 19 19 $template->set_filename('user_collections', realpath(USER_COLLEC_PATH . 'admin/template/config.tpl')); 20 21 ?> -
extensions/UserCollections/admin/export.php
r24421 r25678 4 4 try { 5 5 $collection = new UserCollection($_GET['col_id']); 6 6 7 7 $template->assign('COL_ID', $_GET['col_id']); 8 8 } … … 19 19 pwg_set_session_var('uc_export_active_fields', $_POST['active']); 20 20 pwg_set_session_var('uc_export_inactive_fields', $_POST['inactive']); 21 21 22 22 $content = $collection->serialize($_POST['active']); 23 23 $filename = 'collection_'.$_GET['col_id'].'_'.date('Ymd-Hi').'.csv'; 24 24 25 25 header('Content-Type: application/force-download; name="'.$filename.'"'); 26 26 header('Content-Disposition: attachment; filename="'.$filename.'"'); … … 32 32 header('Pragma: no-cache'); 33 33 header('Expires: 0'); 34 34 35 35 echo $content; 36 36 exit; … … 55 55 $template->assign('inactive_fields', pwg_get_session_var('uc_export_inactive_fields', $default_inactive_fields)); 56 56 57 57 58 $template->set_filename('user_collections', realpath(USER_COLLEC_PATH . 'admin/template/export.tpl')); 58 59 ?> -
extensions/UserCollections/admin/index.php
r20090 r25678 1 1 <?php 2 // +-----------------------------------------------------------------------+3 // | Piwigo - a PHP based photo gallery |4 // +-----------------------------------------------------------------------+5 // | Copyright(C) 2008-2012 Piwigo Team http://piwigo.org |6 // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |7 // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |8 // +-----------------------------------------------------------------------+9 // | This program is free software; you can redistribute it and/or modify |10 // | it under the terms of the GNU General Public License as published by |11 // | the Free Software Foundation |12 // | |13 // | This program is distributed in the hope that it will be useful, but |14 // | WITHOUT ANY WARRANTY; without even the implied warranty of |15 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |16 // | General Public License for more details. |17 // | |18 // | You should have received a copy of the GNU General Public License |19 // | along with this program; if not, write to the Free Software |20 // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |21 // | USA. |22 // +-----------------------------------------------------------------------+23 24 // Recursive call25 2 $url = '../'; 26 3 header( 'Request-URI: '.$url ); … … 28 5 header( 'Location: '.$url ); 29 6 exit(); 30 ?> -
extensions/UserCollections/admin/sets.php
r24421 r25678 19 19 array_push($where_clauses, 'username LIKE "%'.$_POST['username'].'%"'); 20 20 } 21 21 22 22 if (!empty($_POST['name'])) 23 23 { 24 24 array_push($where_clauses, 'name LIKE "%'.$_POST['name'].'%"'); 25 25 } 26 26 27 27 $order_by = $_POST['order_by'].' '.$_POST['direction']; 28 28 } … … 31 31 // get sets 32 32 $query = ' 33 SELECT 33 SELECT 34 34 c.*, 35 35 u.'.$conf['user_fields']['username'].' AS username … … 46 46 { 47 47 $template->append('sets', array( 48 'NAME' => trigger_ event('render_category_name', $row['name']),48 'NAME' => trigger_change('render_category_name', $row['name']), 49 49 'NB_IMAGES' => $row['nb_images'], 50 50 'DATE_CREATION' => format_date($row['date_creation'], true), … … 74 74 'direction_options' => $page['direction_items'], 75 75 'direction_selected' => isset($_POST['direction']) ? $_POST['direction'] : '', 76 76 77 77 'F_USERNAME' => @htmlentities($_POST['username'], ENT_COMPAT, 'UTF-8'), 78 78 'F_NAME' => @htmlentities($_POST['name'], ENT_COMPAT, 'UTF-8'), … … 82 82 83 83 $template->set_filename('user_collections', realpath(USER_COLLEC_PATH . 'admin/template/sets.tpl')); 84 85 ?> -
extensions/UserCollections/admin/template/config.tpl
r24421 r25678 1 {combine_css path=$USER_COLLEC_PATH| @cat:"admin/template/style.css"}1 {combine_css path=$USER_COLLEC_PATH|cat:'admin/template/style.css'} 2 2 3 {footer_script} {literal}4 $( "input[name='allow_public']").on("change", function() {5 $( "#allow_mails").toggle($(this).is(":checked"));3 {footer_script} 4 $('input[name="allow_public"]').on('change', function() { 5 $('#allow_mails').toggle($(this).is(':checked')); 6 6 }); 7 {/ literal}{/footer_script}7 {/footer_script} 8 8 9 9 <div class="titrePage"> … … 17 17 <label> 18 18 <input type="checkbox" name="allow_public" {if $user_collections.allow_public}checked="checked"{/if}> 19 <b>{'Allow users to set their collections as public'| @translate}</b>19 <b>{'Allow users to set their collections as public'|translate}</b> 20 20 </label> 21 21 </li> … … 23 23 <label> 24 24 <input type="checkbox" name="allow_mails" {if $user_collections.allow_mails}checked="checked"{/if}> 25 <b>{'Allow users to send their public collections by mail'| @translate}</b>25 <b>{'Allow users to send their public collections by mail'|translate}</b> 26 26 </label> 27 27 </li> … … 29 29 </fieldset> 30 30 31 <p class="formButtons"><input type="submit" name="save_config" value="{'Save Settings'| @translate}"></p>31 <p class="formButtons"><input type="submit" name="save_config" value="{'Save Settings'|translate}"></p> 32 32 </form> -
extensions/UserCollections/admin/template/export.tpl
r20099 r25678 1 {combine_css path=$USER_COLLEC_PATH| @cat:"admin/template/style.css"}1 {combine_css path=$USER_COLLEC_PATH|cat:'admin/template/style.css'} 2 2 3 {footer_script require='jquery.ui.sortable'} {literal}4 $( "#fields_active, #fields_inactive").sortable({5 connectWith: ".connectedSortable",6 items: "> li",7 placeholder: "sortable-moving"3 {footer_script require='jquery.ui.sortable'} 4 $('#fields_active, #fields_inactive').sortable({ 5 connectWith: '.connectedSortable', 6 items: '> li', 7 placeholder: 'sortable-moving' 8 8 }).disableSelection(); 9 9 10 $( "input[name='generate']").click(function() {11 query = "ws.php?format=rest&method=pwg.collections.getSerialized&col_id={/literal}{$COL_ID}{literal}";12 $( "#fields_active li").each(function() {10 $('input[name="generate"]').click(function() { 11 query = 'ws.php?format=rest&method=pwg.collections.getSerialized&col_id={$COL_ID}'; 12 $('#fields_active li').each(function() { 13 13 query+= '&content[]='+ $(this).data('name'); 14 14 }); 15 16 $( "#iframeWrapper").show();17 $( "#invokeFrame").attr('src', query);18 15 16 $('#iframeWrapper').show(); 17 $('#invokeFrame').attr('src', query); 18 19 19 return false; 20 20 }); 21 21 22 $( "#invokeFrame").load(function() {22 $('#invokeFrame').load(function() { 23 23 $(this).css('height', $(this).contents().find('body').outerHeight(true)+10); 24 24 }); 25 25 26 $( "input[name='download']").click(function() {27 $( "#fields_active li").each(function() {28 $( "#export_form").append('<input type="hidden" name="active[]" value="'+ $(this).data('name') +'"/>');26 $('input[name="download"]').click(function() { 27 $('#fields_active li').each(function() { 28 $('#export_form').append('<input type="hidden" name="active[]" value="'+ $(this).data('name') +'"/>'); 29 29 }); 30 $( "#fields_inactive li").each(function() {31 $( "#export_form").append('<input type="hidden" name="inactive[]" value="'+ $(this).data('name') +'"/>');30 $('#fields_inactive li').each(function() { 31 $('#export_form').append('<input type="hidden" name="inactive[]" value="'+ $(this).data('name') +'"/>'); 32 32 }); 33 33 }); 34 {/ literal}{/footer_script}34 {/footer_script} 35 35 36 36 <div class="titrePage"> … … 41 41 <form method="post" action="" class="properties" id="export_form"> 42 42 <fieldset> 43 <legend>{'Fields'| @translate}</legend>43 <legend>{'Fields'|translate}</legend> 44 44 <ul id="fields_active" class="connectedSortable"> 45 <h4>{'Active'| @translate}</h4>45 <h4>{'Active'|translate}</h4> 46 46 {foreach from=$active_fields item=field} 47 47 <li data-name="{$field}"><img src="{$themeconf.admin_icon_dir}/cat_move.png"> {$field}</li> … … 49 49 </ul> 50 50 <ul id="fields_inactive" class="connectedSortable"> 51 <h4>{'Inactive'| @translate}</h4>51 <h4>{'Inactive'|translate}</h4> 52 52 {foreach from=$inactive_fields item=field} 53 53 <li data-name="{$field}"><img src="{$themeconf.admin_icon_dir}/cat_move.png"> {$field}</li> 54 54 {/foreach} 55 55 </ul> 56 56 57 57 <p class="formButtons"> 58 <input type="submit" name="generate" value="{'Preview'| @translate}">59 <input type="submit" name="download" value="{'Download CSV file'| @translate}">60 </p> 58 <input type="submit" name="generate" value="{'Preview'|translate}"> 59 <input type="submit" name="download" value="{'Download CSV file'|translate}"> 60 </p> 61 61 </fieldset> 62 62 63 63 <fieldset id="iframeWrapper" style="display:none;"> 64 <legend>{'Preview'| @translate}</legend>64 <legend>{'Preview'|translate}</legend> 65 65 <iframe src="" id="invokeFrame" name="invokeFrame"></iframe> 66 66 </fieldset> -
extensions/UserCollections/admin/template/index.php
r20090 r25678 1 1 <?php 2 // +-----------------------------------------------------------------------+3 // | Piwigo - a PHP based photo gallery |4 // +-----------------------------------------------------------------------+5 // | Copyright(C) 2008-2012 Piwigo Team http://piwigo.org |6 // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |7 // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |8 // +-----------------------------------------------------------------------+9 // | This program is free software; you can redistribute it and/or modify |10 // | it under the terms of the GNU General Public License as published by |11 // | the Free Software Foundation |12 // | |13 // | This program is distributed in the hope that it will be useful, but |14 // | WITHOUT ANY WARRANTY; without even the implied warranty of |15 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |16 // | General Public License for more details. |17 // | |18 // | You should have received a copy of the GNU General Public License |19 // | along with this program; if not, write to the Free Software |20 // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |21 // | USA. |22 // +-----------------------------------------------------------------------+23 24 // Recursive call25 2 $url = '../'; 26 3 header( 'Request-URI: '.$url ); … … 28 5 header( 'Location: '.$url ); 29 6 exit(); 30 ?> -
extensions/UserCollections/admin/template/sets.tpl
r24421 r25678 1 {combine_css path=$USER_COLLEC_PATH| @cat:"admin/template/style.css"}1 {combine_css path=$USER_COLLEC_PATH|cat:'admin/template/style.css'} 2 2 3 3 <div class="titrePage"> … … 7 7 <form class="filter" method="post" name="filter" action="{$F_FILTER_ACTION}"> 8 8 <fieldset> 9 <legend>{'Filter'| @translate}</legend>9 <legend>{'Filter'|translate}</legend> 10 10 <input type="hidden" name="page" value="user_list"> 11 11 12 <label>{'Name'| @translate} <input type="text" name="name" value="{$F_NAME}"></label>13 14 <label>{'Username'| @translate} <input type="text" name="username" value="{$F_USERNAME}"></label>12 <label>{'Name'|translate} <input type="text" name="name" value="{$F_NAME}"></label> 13 14 <label>{'Username'|translate} <input type="text" name="username" value="{$F_USERNAME}"></label> 15 15 16 16 <label> 17 {'Sort by'| @translate}17 {'Sort by'|translate} 18 18 {html_options name=order_by options=$order_options selected=$order_selected} 19 19 </label> 20 20 21 21 <label> 22 {'Sort order'| @translate}22 {'Sort order'|translate} 23 23 {html_options name=direction options=$direction_options selected=$direction_selected} 24 24 </label> … … 26 26 <label> 27 27 28 <span><input class="submit" type="submit" name="filter" value="{'Submit'| @translate}"> <a href="{$F_FILTER_ACTION}">{'Reset'|@translate}</a></span>28 <span><input class="submit" type="submit" name="filter" value="{'Submit'|translate}"> <a href="{$F_FILTER_ACTION}">{'Reset'|translate}</a></span> 29 29 </label> 30 30 … … 36 36 <thead> 37 37 <tr class="throw"> 38 <td class="name">{'Name'| @translate}</td>39 <td class="user">{'Username'| @translate}</td>40 <td class="date">{'Creation date'| @translate}</td>41 <td class="images">{'Number of images'| @translate}</td>42 <td class="action">{'Actions'| @translate}</td>38 <td class="name">{'Name'|translate}</td> 39 <td class="user">{'Username'|translate}</td> 40 <td class="date">{'Creation date'|translate}</td> 41 <td class="images">{'Number of images'|translate}</td> 42 <td class="action">{'Actions'|translate}</td> 43 43 </tr> 44 44 </thead> … … 53 53 <td>{$set.NB_IMAGES}</td> 54 54 <td style="padding-left:25px;"> 55 <a href="{$set.U_EDIT}" title="{'Edit this collection'| @translate}"><img src="{$themeconf.admin_icon_dir}/edit_s.png"></a>56 <a href="{$set.U_EXPORT}" title="{'Export image list'| @translate}"><img src="{$themeconf.admin_icon_dir}/plug_install.png"><span class="icon-upload"></span></a> <!-- temp 2.5/2.6 -->57 <a href="{$set.U_DELETE}" title="{'Delete this collection'| @translate}" onClick="return confirm('{'Are you sure?'|@translate}');"><img src="{$themeconf.admin_icon_dir}/delete.png"></a>55 <a href="{$set.U_EDIT}" title="{'Edit this collection'|translate}"><img src="{$themeconf.admin_icon_dir}/edit_s.png"></a> 56 <a href="{$set.U_EXPORT}" title="{'Export image list'|translate}"><img src="{$themeconf.admin_icon_dir}/plug_install.png"><span class="icon-upload"></span></a> <!-- temp 2.5/2.6 --> 57 <a href="{$set.U_DELETE}" title="{'Delete this collection'|translate}" onClick="return confirm('{'Are you sure?'|translate}');"><img src="{$themeconf.admin_icon_dir}/delete.png"></a> 58 58 </td> 59 59 </tr> 60 60 {/foreach} 61 61 62 62 {if not $sets} 63 63 <tr class="row2"> 64 <td colspan="8" style="text-align:center;font-style:italic;">{'No results'| @translate}</td>64 <td colspan="8" style="text-align:center;font-style:italic;">{'No results'|translate}</td> 65 65 </tr> 66 66 {/if} -
extensions/UserCollections/admin/template/style.css
r20099 r25678 93 93 opacity:0.5; 94 94 } 95 95 96 96 #invokeFrame { 97 97 width:100%; -
extensions/UserCollections/include/UserCollection.class.php
r25676 r25678 6 6 private $data; 7 7 private $images; 8 8 9 9 /** 10 10 * __construct 11 * @param: mixed col id (##|'new') 12 * @param: array images 11 * @throws Exception 12 * 13 * @param int|string $col_id or 'new' 14 * @param string $name 15 * @param string $comment 16 * @param int $user_id 13 17 */ 14 18 function __construct($col_id, $name=null, $comment=null, $user_id=null) 15 19 { 16 20 global $user; 17 21 18 22 if (empty($user_id)) 19 23 { 20 24 $user_id = $user['id']; 21 25 } 22 26 23 27 $this->data = array( 24 28 'id' => 0, … … 30 34 ); 31 35 $this->images = array(); 32 36 33 37 // load specific collection 34 38 if (preg_match('#^[0-9]+$#', $col_id)) … … 40 44 ;'; 41 45 $result = pwg_query($query); 42 46 43 47 if (pwg_db_num_rows($result)) 44 48 { … … 47 51 pwg_db_fetch_assoc($result) 48 52 ); 49 53 50 54 // make sure all pictures of the collection exist 51 55 $query = ' … … 56 60 ;'; 57 61 pwg_query($query); 58 62 59 63 // select images of the collection 60 64 $query = ' … … 64 68 ;'; 65 69 $this->images = array_from_query($query, 'image_id'); 66 70 67 71 $this->updateParam('nb_images', count($this->images)); 68 72 } … … 77 81 $this->data['name'] = $name; 78 82 $this->data['comment'] = $comment; 79 83 80 84 $query = ' 81 85 INSERT INTO '.COLLECTIONS_TABLE.'( … … 84 88 date_creation, 85 89 comment 86 ) 90 ) 87 91 VALUES( 88 92 '.$this->data['user_id'].', … … 94 98 pwg_query($query); 95 99 $this->data['id'] = pwg_db_insert_id(); 96 100 97 101 $date = pwg_query('SELECT NOW();'); 98 102 list($this->data['date_creation']) = pwg_db_fetch_row($date); … … 103 107 } 104 108 } 105 106 /** 107 * check if current user is owner of the collection or admin 109 110 /** 111 * Check if current user is owner of the collection or admin 112 * @throws Exception 108 113 */ 109 114 function checkUser() 110 115 { 111 116 global $user; 112 117 113 118 if (!is_admin() && $user['id'] != $this->data['user_id']) 114 119 { … … 116 121 } 117 122 } 118 123 119 124 /** 120 125 * updateParam 121 * @param: string param name 122 * @param: mixed param value 126 * 127 * @param string $name 128 * @param mixed $value 123 129 */ 124 130 function updateParam($name, $value) … … 130 136 } 131 137 } 132 138 133 139 /** 134 140 * getParam 135 * @param: string param name 136 * @return: mixed param value 141 * 142 * @param string $name 143 * @return mixed 137 144 */ 138 145 function getParam($name) … … 140 147 return $this->data[$name]; 141 148 } 142 149 143 150 /** 144 151 * getImages 145 * @return: array 152 * 153 * @return int[] 146 154 */ 147 155 function getImages() … … 149 157 return $this->images; 150 158 } 151 152 /** 153 * isInSet 154 * @param: int image id 155 * @return: bool 159 160 /** 161 * Check if an image is in the collection. 162 * 163 * @param int $image_id 164 * @return bool 156 165 */ 157 166 function isInSet($image_id) … … 159 168 return in_array($image_id, $this->images); 160 169 } 161 170 162 171 /** 163 172 * removeImages 164 * @param: array image ids 173 * 174 * @param int|int[] $image_ids 165 175 */ 166 176 function removeImages($image_ids) 167 177 { 168 if (empty($image_ids) or !is_array($image_ids)) return; 169 178 if (empty($image_ids)) return; 179 if (!is_array($image_ids)) $image_ids = array($image_ids); 180 170 181 $this->images = array_diff($this->images, $image_ids); 171 182 172 183 $query = ' 173 184 DELETE FROM '.COLLECTION_IMAGES_TABLE.' 174 WHERE 185 WHERE 175 186 col_id = '.$this->data['id'].' 176 187 AND image_id IN('.implode(',', $image_ids).') 177 188 ;'; 178 189 pwg_query($query); 179 190 180 191 $this->updateParam('nb_images', count($this->images)); 181 192 } 182 193 183 194 /** 184 195 * addImages 185 * @param: array image ids 196 * 197 * @param int|int[] $image_ids 186 198 */ 187 199 function addImages($image_ids) 188 200 { 189 if (empty($image_ids) or !is_array($image_ids)) return; 190 201 if (empty($image_ids)) return; 202 if (!is_array($image_ids)) $image_ids = array($image_ids); 203 191 204 $image_ids = array_unique($image_ids); 192 205 $inserts = array(); 193 206 194 207 foreach ($image_ids as $image_id) 195 208 { 196 209 if ($this->isInSet($image_id)) continue; 197 210 198 211 $this->images[] = $image_id; 199 212 $inserts[] = array( … … 202 215 ); 203 216 } 204 217 205 218 mass_inserts( 206 219 COLLECTION_IMAGES_TABLE, … … 208 221 $inserts 209 222 ); 210 223 211 224 $query = ' 212 225 UPDATE '.COLLECTION_IMAGES_TABLE.' … … 218 231 '; 219 232 pwg_query($query); 220 233 221 234 $this->updateParam('nb_images', count($this->images)); 222 235 } 223 236 224 237 /** 225 238 * toggleImage 226 * @param: int image id 239 * 240 * @param int $image_id 227 241 */ 228 242 function toggleImage($image_id) … … 237 251 } 238 252 } 239 253 240 254 /** 241 255 * clearImages … … 245 259 $this->images = array(); 246 260 $this->updateParam('nb_images', 0); 247 261 248 262 $query = ' 249 263 DELETE FROM '.COLLECTION_IMAGES_TABLE.' … … 252 266 pwg_query($query); 253 267 } 254 268 255 269 /** 256 270 * getCollectionInfo 257 * @return: array 271 * 272 * @return array 258 273 */ 259 274 function getCollectionInfo() … … 266 281 'DATE_CREATION' => $this->data['date_creation'], 267 282 ); 268 283 269 284 return $set; 270 285 } 271 272 /** 273 * get share links 286 287 /** 288 * Returns share links 289 * 290 * @return array 274 291 */ 275 292 function getShares() … … 281 298 ;'; 282 299 $result = pwg_query($query); 283 300 284 301 $shares = array(); 285 302 while ($row = pwg_db_fetch_assoc($result)) 286 303 { 287 304 $row['expired'] = false; 288 305 289 306 $row['params'] = unserialize($row['params']); 290 307 if (!empty($row['params']['deadline'])) … … 293 310 $row['params']['deadline_readable'] = format_date($row['params']['deadline'], true, false); 294 311 } 295 312 296 313 $row['url'] = USER_COLLEC_PUBLIC . 'view/' . $row['share_key']; 297 314 $row['u_delete'] = USER_COLLEC_PUBLIC . 'edit/' . $this->data['id'] . '&delete_share=' . $row['id']; 298 315 $row['add_date_readable'] = format_date($row['add_date'], true, false); 299 316 300 317 $shares[] = $row; 301 318 } 302 319 303 320 return $shares; 304 321 } 305 306 /** 307 * delete a share 322 323 /** 324 * Delete a share 325 * 326 * @param int $id 327 * @return bool 308 328 */ 309 329 function deleteShare($id) … … 315 335 ;'; 316 336 pwg_query($query); 317 337 318 338 return pwg_db_changes() != 0; 319 339 } 320 321 /** 322 * Add a share URL 323 * @param: array 324 * - share_key 325 * - password 326 * - deadline 327 * @return: array errors 340 341 /** 342 * Add a share link 343 * 344 * @param array &$share 345 * - share_key (will be slugified) 346 * - password (optional) 347 * - deadline (optional) 348 * @param bool $abord_on_duplicate 349 * @return array|string errors or full share link 328 350 */ 329 351 function addShare(&$share, $abord_on_duplicate=true) 330 352 { 331 353 global $conf, $page; 332 354 333 355 $errors = array(); 334 356 335 357 $share = array_map('stripslashes', $share); 336 358 337 359 // check key 338 360 if (empty($share['share_key']) || strlen($share['share_key']) < 8) … … 344 366 $share['share_key'] = str2url($share['share_key']); 345 367 $share_key = $this->data['id'].'-'.$share['share_key']; 346 368 347 369 $query = ' 348 370 SELECT id FROM '.COLLECTION_SHARES_TABLE.' … … 363 385 } 364 386 } 365 387 366 388 // filter date 367 389 if (!empty($share['deadline'])) 368 390 { 369 $date = DateTime::createFromFormat('Y-m-d H:i', $share['deadline']); 370 $share['deadline'] = $date->format('Y-m-d H:i'); 371 } 372 391 $share['deadline'] = transform_date($share['deadline'], 'Y-m-d H:i', 'Y-m-d H:i'); 392 } 393 373 394 // hash password 374 395 if (!empty($share['password'])) … … 376 397 $share['password'] = sha1($conf['secret_key'].$share['password'].$share_key); 377 398 } 378 399 379 400 if (empty($errors)) 380 401 { … … 383 404 'deadline' => @$share['deadline'], 384 405 )); 385 406 386 407 $query = ' 387 408 INSERT INTO '.COLLECTION_SHARES_TABLE.'( … … 399 420 ;'; 400 421 pwg_query($query); 401 422 402 423 return USER_COLLEC_PUBLIC . 'view/' . $share_key; 403 424 } 404 425 405 426 return $errors; 406 427 } 407 428 408 429 /** 409 430 * Send the collection by email 410 * @param: array 431 * 432 * @param array $comm 411 433 * - sender_name 412 434 * - sender_email … … 415 437 * - nb_images 416 438 * - message 417 * @return : array errors439 * @return array|true array errors or true 418 440 */ 419 441 function sendEmail($comm) 420 442 { 421 global $conf ;422 443 global $conf, $user; 444 423 445 $errors = array(); 424 446 425 447 $comm = array_map('stripslashes', $comm); 426 448 427 $comment_action ='validate';449 $comment_action = 'validate'; 428 450 429 451 // check author 430 452 if (empty($comm['sender_name'])) 431 453 { 432 array_push($errors, l10n('Please enter your name'));433 $comment_action ='reject';434 } 454 $errors[] = l10n('Please enter your name'); 455 $comment_action = 'reject'; 456 } 435 457 if (empty($comm['recipient_name'])) 436 458 { 437 array_push($errors, l10n('Please enter the recipient name'));438 $comment_action ='reject';439 } 440 459 $errors[] = l10n('Please enter the recipient name'); 460 $comment_action = 'reject'; 461 } 462 441 463 // check email 442 464 if (empty($comm['sender_email'])) 443 465 { 444 array_push($errors, l10n('Please enter your e-mail'));445 $comment_action ='reject';446 } 447 else if ( !empty($comm['sender_email']) and !uc_check_email_validity($comm['sender_email']))448 { 449 array_push($errors, l10n('mail address must be like xxx@yyy.eee (example : jack@altern.org)'));450 $comment_action ='reject';466 $errors[] = l10n('Please enter your e-mail'); 467 $comment_action = 'reject'; 468 } 469 else if (!empty($comm['sender_email']) and !email_check_format($comm['sender_email'])) 470 { 471 $errors[] = l10n('mail address must be like xxx@yyy.eee (example : jack@altern.org)'); 472 $comment_action = 'reject'; 451 473 } 452 474 if (empty($comm['recipient_email'])) 453 475 { 454 array_push($errors, l10n('Please enter the recipient e-mail'));455 $comment_action ='reject';456 } 457 else if ( !empty($comm['recipient_email']) and !uc_check_email_validity($comm['recipient_email']))458 { 459 array_push($errors, l10n('mail address must be like xxx@yyy.eee (example : jack@altern.org)'));460 $comment_action ='reject';461 } 462 476 $errors[] = l10n('Please enter the recipient e-mail'); 477 $comment_action = 'reject'; 478 } 479 else if (!empty($comm['recipient_email']) and !email_check_format($comm['recipient_email'])) 480 { 481 $errors[] = l10n('mail address must be like xxx@yyy.eee (example : jack@altern.org)'); 482 $comment_action = 'reject'; 483 } 484 463 485 // check content 464 486 if (!empty($comm['message'])) … … 466 488 $comm['message'] = nl2br($comm['message']); 467 489 } 468 490 469 491 include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); 470 492 471 493 if ($comment_action == 'validate') 472 494 { 473 // format subject 474 $subject = '['.$conf['gallery_title'].'] '.sprintf(l10n('A photo collection by %s'), $comm['sender_name']); 475 $subject = encode_mime_header($subject); 476 477 // format expeditor 478 $args['from'] = format_email($comm['sender_name'], $comm['sender_email']); 479 $args['to'] = format_email($comm['recipient_name'], $comm['recipient_email']); 480 481 // hearders 482 $headers = 'From: '.$args['from']."\n"; 483 $headers.= 'MIME-Version: 1.0'."\n"; 484 $headers.= 'X-Mailer: Piwigo Mailer'."\n"; 485 $headers.= 'Content-Transfer-Encoding: 8bit'."\n"; 486 $headers.= 'Content-Type: text/html; charset="'.get_pwg_charset().'";'."\n"; 487 488 // mail content 489 $content = $this->getMailContent($comm); 490 $content = wordwrap($content, 70, "\n", true); 491 492 // send mail 493 $result = 494 trigger_event('send_mail', 495 false, /* Result */ 496 trigger_event('send_mail_to', $args['to']), 497 trigger_event('send_mail_subject', $subject), 498 trigger_event('send_mail_content', $content), 499 trigger_event('send_mail_headers', $headers), 500 $args 501 ); 502 503 if ($result == false) 504 { 505 array_push($errors, l10n('Error while sending e-mail')); 506 } 507 else 508 { 509 return true; 510 } 511 } 512 513 return $errors; 514 } 515 516 /** 517 * get mail content for sendMail() 518 */ 519 function getMailContent($params) 520 { 521 global $user, $conf, $template; 522 523 // switch to guest user 524 $user_save = $user; 525 $user = build_user($conf['guest_id'], true); 526 527 // get pictures 528 $query = ' 495 // switch to guest user for get_sql_condition_FandF 496 $user_save = $user; 497 $user = build_user($conf['guest_id'], true); 498 499 // get pictures 500 $query = ' 529 501 SELECT 530 id, 531 file, 532 name, 533 path 502 id, file, name, path 534 503 FROM '.IMAGES_TABLE.' AS i 535 504 JOIN '.IMAGE_CATEGORY_TABLE.' AS ci ON ci.image_id = i.id 536 WHERE id IN ('.implode(',', $this->images).') 537 '.get_sql_condition_FandF(array( 538 'forbidden_categories' => 'category_id', 539 'forbidden_images' => 'id' 540 ), 541 'AND' 542 ).' 505 WHERE id IN ('. implode(',', $this->images) .') 506 '.get_sql_condition_FandF( 507 array( 508 'forbidden_categories' => 'category_id', 509 'forbidden_images' => 'id' 510 ), 511 'AND' 512 ).' 543 513 GROUP BY i.id 544 ORDER BY '.DB_RANDOM_FUNCTION.'() 545 LIMIT '.$params['nb_images'].' 546 ;'; 547 $pictures = hash_from_query($query, 'id'); 548 549 // switch back to current user 550 $user = $user_save; 551 unset($user_save); 552 553 // picture sinfos 554 set_make_full_url(); 555 $tpl_vars = array(); 556 foreach ($pictures as $row) 557 { 558 $name = render_element_name($row); 559 560 $tpl_vars[] = array( 561 'TN_ALT' => htmlspecialchars(strip_tags($name)), 562 'NAME' => $name, 563 'URL' => make_picture_url(array('image_id' => $row['id'])), 564 'THUMB' => DerivativeImage::url(IMG_SQUARE, $row), 514 ORDER BY '. DB_RANDOM_FUNCTION .'() 515 LIMIT '. $comm['nb_images'] .' 516 ;'; 517 $pictures = hash_from_query($query, 'id'); 518 519 // switch back to current user 520 $user = $user_save; 521 unset($user_save); 522 523 $share_key = array('share_key'=>'mail-' . substr(sha1($this->data['id'].$conf['secret_key']), 0, 11)); 524 525 $tpl_vars = array( 526 'COL_URL' => $this->addShare($share_key, false), 527 'PARAMS' => $comm, 528 'derivative_params' => ImageStdParams::get_by_type(IMG_SQUARE), 565 529 ); 566 } 567 568 // template 569 $mail_css = file_get_contents(dirname(__FILE__).'/../template/mail.css'); 570 571 $share_key = array('share_key'=>'mail-' . substr(sha1($this->data['id'].$conf['secret_key']), 0, 11)); 572 573 $template->assign(array( 574 'GALLERY_URL' => get_gallery_home_url(), 575 'PHPWG_URL' => PHPWG_URL, 576 'UC_MAIL_CSS' => str_replace("\n", null, $mail_css), 577 'MAIL_TITLE' => $this->getParam('name').' ('.sprintf(l10n('by %s'), $params['sender_name']).')', 578 'COL_URL' => $this->addShare($share_key, false), 579 'PARAMS' => $params, 580 'derivative_params' => ImageStdParams::get_by_type(IMG_SQUARE), 581 'thumbnails' => $tpl_vars, 582 )); 583 584 $template->set_filename('uc_mail', dirname(__FILE__).'/../template/mail.tpl'); 585 $content = $template->parse('uc_mail', true); 586 587 unset_make_full_url(); 588 589 return $content; 590 } 591 592 /** 593 * generate a listing of the collection 530 531 // pictures infos 532 set_make_full_url(); 533 534 foreach ($pictures as $row) 535 { 536 $name = render_element_name($row); 537 538 $tpl_vars['THUMBNAILS'][] = array( 539 'TN_ALT' => htmlspecialchars(strip_tags($name)), 540 'NAME' => $name, 541 'URL' => make_picture_url(array('image_id' => $row['id'])), 542 'THUMB' => DerivativeImage::url(IMG_SQUARE, $row), 543 ); 544 } 545 546 unset_make_full_url(); 547 548 $result = pwg_mail( 549 array( 550 'name' => $comm['recipient_name'], 551 'email' => $comm['recipient_email'], 552 ), 553 array( 554 'subject' => '['.$conf['gallery_title'].'] '.l10n('A photo collection by %s', $comm['sender_name']), 555 'mail_title' => $this->getParam('name'), 556 'mail_subtitle' => l10n('by %s', $comm['sender_name']), 557 'content_format' => 'text/html', 558 'from' => array( 559 'name' => $comm['sender_name'], 560 'email' => $comm['sender_email'], 561 ) 562 ), 563 array( 564 'filename' => 'mail', 565 'dirname' => realpath(USER_COLLEC_PATH . 'template'), 566 'assign' => $tpl_vars, 567 ) 568 ); 569 570 if ($result == false) 571 { 572 $errors[] = l10n('Error while sending e-mail'); 573 } 574 else 575 { 576 return true; 577 } 578 } 579 580 return $errors; 581 } 582 583 /** 584 * Generate a listing of the collection 585 * 586 * @param string[] $fields 587 * @return string 594 588 */ 595 589 function serialize($params) 596 590 { 597 $ params = array_intersect($params, array('id','file','name','url','path','date_creation','collection_add_date','filesize','width','height'));598 591 $fields = array_intersect($fields, array('id','file','name','url','path','date_creation','collection_add_date','filesize','width','height')); 592 599 593 $content = null; 600 594 601 595 // get images infos 602 596 $query = ' … … 617 611 ;'; 618 612 $pictures = hash_from_query($query, 'id'); 619 613 620 614 if (count($pictures)) 621 615 { … … 623 617 set_make_full_url(); 624 618 $root_url = get_root_url(); 625 619 626 620 $fp = fopen('php://temp', 'r+'); 627 fputcsv($fp, $ params);628 621 fputcsv($fp, $fields); 622 629 623 foreach ($pictures as $row) 630 624 { 631 625 $element = array(); 632 foreach ($ params as $field)626 foreach ($fields as $field) 633 627 { 634 628 switch ($field) … … 653 647 } 654 648 } 655 649 656 650 rewind($fp); 657 651 $content = stream_get_contents($fp); 658 652 fclose($fp); 659 653 660 654 unset_make_full_url(); 661 655 } 662 656 663 657 return $content; 664 658 } 665 666 /** 667 * delete659 660 /** 661 * Delete the collection 668 662 */ 669 663 function delete() … … 673 667 } 674 668 } 675 676 ?> -
extensions/UserCollections/include/collections.inc.php
r25674 r25678 21 21 access_denied(); 22 22 } 23 24 $template->set_filename(' index', realpath(USER_COLLEC_PATH.'template/collections_list.tpl'));25 23 24 $template->set_filename('uc_page', realpath(USER_COLLEC_PATH.'template/collections_list.tpl')); 25 26 26 // actions 27 if ( isset($_GET['action']) and preg_match('#^([0-9]+)$#', $_GET['col_id']))27 if (isset($_GET['action']) and preg_match('#^([0-9]+)$#', $_GET['col_id'])) 28 28 { 29 29 switch ($_GET['action']) … … 39 39 { 40 40 $collection = new UserCollection('new', $_GET['name']); 41 41 42 42 if (isset($_GET['redirect'])) 43 43 { … … 52 52 break; 53 53 } 54 54 55 55 ## delete collection ## 56 56 case 'delete': … … 69 69 } 70 70 } 71 71 72 72 $template->assign('U_CREATE', 73 73 add_url_params(USER_COLLEC_PUBLIC, array('action'=>'new','col_id'=>'0')) 74 74 ); 75 75 76 76 $template->set_prefilter('index_category_thumbnails', 'user_collections_categories_list'); 77 77 78 78 include(USER_COLLEC_PATH . '/include/display_collections.inc.php'); 79 79 80 80 break; 81 81 } … … 92 92 redirect(USER_COLLEC_PUBLIC); 93 93 } 94 95 $template->set_filename(' index', realpath(USER_COLLEC_PATH.'template/collection_edit.tpl'));96 94 95 $template->set_filename('uc_page', realpath(USER_COLLEC_PATH.'template/collection_edit.tpl')); 96 97 97 $self_url = USER_COLLEC_PUBLIC . 'edit/' . $page['col_id']; 98 98 99 99 $template->assign(array( 100 100 'F_ACTION' => $self_url, … … 102 102 'UC_IN_EDIT' => true, 103 103 )); 104 104 105 105 try { 106 106 $collection = new UserCollection($page['col_id']); 107 107 $collection->checkUser(); 108 108 109 109 // save properties 110 110 if (isset($_POST['save_col'])) … … 118 118 $collection->updateParam('name', stripslashes($_POST['name'])); 119 119 } 120 $collection->updateParam('comment', stripslashes( $_POST['comment']));121 } 122 120 $collection->updateParam('comment', stripslashes(@$_POST['comment'])); 121 } 122 123 123 // add key 124 124 if ($conf['user_collections']['allow_public']) … … 127 127 { 128 128 $share = array( 129 'share_key' => 130 'password' => 131 'deadline' => 129 'share_key' => trim($_POST['share_key']), 130 'password' => isset($_POST['use_share_password']) ? trim($_POST['share_password']) : '', 131 'deadline' => isset($_POST['use_share_deadline']) ? trim($_POST['share_deadline']) : '', 132 132 ); 133 133 134 134 if (!verify_ephemeral_key(@$_POST['key'])) 135 135 { … … 147 147 { 148 148 $share = array(); 149 $share['infos'][] = sprintf(l10n('New share added: <a href="%s">%s</a>'), $result, $result);149 $share['infos'][] = l10n('New share added: <a href="%s">%s</a>', $result, $result); 150 150 } 151 151 $share['open'] = true; … … 163 163 { 164 164 $share['share_key'] = get_random_key(16); 165 $share['password'] = null;166 $share['deadline'] = null;165 $share['password'] = null; 166 $share['deadline'] = null; 167 167 } 168 168 169 169 $template->assign('share', $share); 170 170 } 171 171 172 172 // send mail 173 if ( $conf['user_collections']['allow_mails'] && $conf['user_collections']['allow_public'] ) 174 { 175 $contact = array( 176 'sender_name' => $user['username'], 177 'sender_email' => $user['email'], 178 'recipient_name' => null, 179 'recipient_email' => null, 180 'nb_images' => 4, 181 'message' => null, 182 ); 183 173 if ($conf['user_collections']['allow_mails'] && $conf['user_collections']['allow_public']) 174 { 184 175 if (isset($_POST['send_mail'])) 185 176 { … … 192 183 'message' => $_POST['message'], 193 184 ); 194 185 195 186 if (!verify_ephemeral_key(@$_POST['key'])) 196 187 { … … 212 203 } 213 204 } 214 205 206 if (!isset($contact['sender_email'])) 207 { 208 $contact['sender_name'] = $user['username']; 209 $contact['sender_email'] = $user['email']; 210 $contact['recipient_name'] = null; 211 $contact['recipient_email'] = null; 212 $contact['nb_images'] = 4; 213 $contact['message'] = null; 214 } 215 215 216 $template->assign('contact', $contact); 216 217 } 217 218 218 219 // clear 219 if ( isset($_GET['action']) and $_GET['action'] == 'clear')220 if (isset($_GET['action']) && $_GET['action'] == 'clear') 220 221 { 221 222 $collection->clearImages(); 222 223 } 223 224 224 225 225 226 // add remove item links 226 227 $template->set_prefilter('index_thumbnails', 'user_collections_thumbnails_list_button'); 227 228 $template->set_prefilter('index_thumbnails', 'user_collections_add_colorbox'); 228 229 229 230 // thumbnails 230 231 include(USER_COLLEC_PATH . '/include/display_thumbnails.inc.php'); 231 232 232 233 233 234 // collection properties 234 235 $infos = $collection->getCollectionInfo(); 235 236 $infos['DATE_CREATION'] = format_date($infos['DATE_CREATION'], true); 236 237 $infos['SHARES'] = $collection->getShares(); 237 $template->assign('collection', $infos); 238 238 $template->assign('collection', $infos); 239 240 239 241 // toolbar buttons 240 242 if (!empty($page['items'])) 241 243 { 242 $template->assign('U_CLEAR', 244 if ($conf['user_collections']['allow_public']) 245 { 246 user_collections_add_button('share', 'U_SHARE', 247 USER_COLLEC_PUBLIC . 'view/' . $page['col_id'] .'-' 248 ); 249 250 if ($conf['user_collections']['allow_mails']) 251 { 252 user_collections_add_button('mail', 'U_MAIL', true); 253 } 254 } 255 256 user_collections_add_button('clear', 'U_CLEAR', 243 257 add_url_params($self_url, array('action'=>'clear')) 244 258 ); 245 259 } 246 $template->assign('U_DELETE', 260 261 user_collections_add_button('delete', 'U_DELETE', 247 262 add_url_params(USER_COLLEC_PUBLIC, array('action'=>'delete','col_id'=>$page['col_id'])) 248 263 ); 249 250 if ( $conf['user_collections']['allow_public'] && !empty($page['items']) ) 251 { 252 $template->assign('U_SHARE', USER_COLLEC_PUBLIC . 'view/' . $page['col_id'] .'-'); 253 } 254 if ( $conf['user_collections']['allow_mails'] && $conf['user_collections']['allow_public'] && !empty($page['items']) ) 255 { 256 $template->assign('U_MAIL', true); 257 } 264 258 265 $template->assign('UC_TKEY', get_ephemeral_key(3)); 259 266 260 267 // modify page title 261 $template->concat('TITLE', 262 $conf['level_separator'] . trigger_ event('render_category_name', $infos['NAME'])268 $template->concat('TITLE', 269 $conf['level_separator'] . trigger_change('render_category_name', $infos['NAME']) 263 270 ); 264 271 265 272 // render description 266 273 $template->assign('CONTENT_DESCRIPTION', 267 trigger_ event('render_category_description', nl2br($infos['COMMENT']))274 trigger_change('render_category_description', nl2br($infos['COMMENT'])) 268 275 ); 269 276 } … … 272 279 $page['errors'][] = $e->getMessage(); 273 280 } 274 281 275 282 break; 276 283 } … … 282 289 { 283 290 $page['col_key'] = $page['col_id']; 284 291 285 292 if (!$conf['user_collections']['allow_public']) 286 293 { … … 291 298 bad_request(''); 292 299 } 293 300 294 301 $query = ' 295 302 SELECT col_id, params … … 298 305 ;'; 299 306 $result = pwg_query($query); 307 300 308 if (!pwg_db_num_rows($result)) 301 309 { 302 310 page_not_found(l10n('Collection not found')); 303 311 } 304 312 305 313 list($page['col_id'], $share_params) = pwg_db_fetch_row($result); 306 314 $share_params = unserialize($share_params); 307 315 308 316 // deadline check 309 if ( !empty($share_params['deadline']) && strtotime($share_params['deadline'])<time())317 if (!empty($share_params['deadline']) && strtotime($share_params['deadline'])<time()) 310 318 { 311 319 page_not_found(l10n('This link expired')); 312 320 } 313 321 314 322 $self_url = USER_COLLEC_PUBLIC . 'view/' . $page['col_key']; 315 316 $template->set_filename(' index', realpath(USER_COLLEC_PATH.'template/collection_view.tpl'));317 323 324 $template->set_filename('uc_page', realpath(USER_COLLEC_PATH.'template/collection_view.tpl')); 325 318 326 try { 319 327 $collection = new UserCollection($page['col_id']); 320 328 $col = $collection->getCollectionInfo(); 321 329 322 330 $mode = 'view'; 323 331 324 332 // password check 325 333 if (!empty($share_params['password'])) … … 351 359 } 352 360 } 353 361 354 362 if ($mode == 'view') 355 363 { 356 364 $template->set_prefilter('index_thumbnails', 'user_collections_add_colorbox'); 357 365 358 366 // thumbnails 359 367 include(USER_COLLEC_PATH . '/include/display_thumbnails.inc.php'); 360 368 361 369 // render description 362 370 $template->assign('CONTENT_DESCRIPTION', 363 trigger_ event('render_category_description', nl2br($col['COMMENT']))371 trigger_change('render_category_description', nl2br($col['COMMENT'])) 364 372 ); 365 373 } 366 374 367 375 // add username in title 368 376 include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); 369 $template->concat('TITLE', 370 $conf['level_separator'] . trigger_event('render_category_name', $col['NAME']) . 371 ' (' . sprintf(l10n('by %s'), get_username($collection->getParam('user_id'))) . ')' 377 378 $template->concat('TITLE', 379 $conf['level_separator'] . trigger_change('render_category_name', $col['NAME']) . 380 ' (' . l10n('by %s', get_username($collection->getParam('user_id'))) . ')' 372 381 ); 373 382 374 383 $template->assign('UC_MODE', $mode); 375 384 } … … 378 387 access_denied(); 379 388 } 380 389 381 390 break; 382 391 } 383 392 } 393 394 $template->assign_var_from_handle('CONTENT', 'uc_page'); 384 395 385 396 … … 393 404 | <a href="{$cat.U_DELETE}" onClick="return confirm(\'{"Are you sure?"|@translate}\');" rel="nofollow">{"Delete"|@translate}</a> 394 405 </div>'; 395 406 396 407 return str_replace($search, $replace, $content); 397 408 } … … 402 413 $search = '<a href="{$thumbnail.URL}"'; 403 414 $replace = $search.' class="preview-box" data-src="{$thumbnail.FILE_SRC}" data-id="{$thumbnail.id}"'; 404 415 405 416 return str_replace($search, $replace, $content); 406 417 } 407 418 408 ?> 419 // add special buttons 420 function user_collections_add_button($tpl_file, $tpl_var, $value) 421 { 422 global $template; 423 424 $template->assign($tpl_var, $value); 425 $template->set_filename('uc_button_'.$tpl_file, realpath(USER_COLLEC_PATH.'template/buttons/'. $tpl_file .'.tpl')); 426 $template->add_index_button($template->parse('uc_button_'.$tpl_file, true)); 427 } -
extensions/UserCollections/include/display_collections.inc.php
r23551 r25678 1 1 <?php 2 2 defined('USER_COLLEC_PATH') or die('Hacking attempt!'); 3 4 3 5 4 // collections orders … … 20 19 $orders = get_collections_preferred_orders(); 21 20 21 22 22 // get sorted collections 23 23 $query = ' 24 SELECT * 24 SELECT * 25 25 FROM '.COLLECTIONS_TABLE.' 26 26 WHERE user_id = '.$user['id'].' … … 31 31 $template->assign('COLLECTIONS_COUNT', count($categories)); 32 32 33 33 34 // order menu 34 35 if (count($categories)) 35 36 { 36 37 $url = add_url_params(USER_COLLEC_PUBLIC, array('uc_collection_order' => '')); 37 38 38 39 foreach ($orders as $order_id => $order) 39 40 { … … 53 54 54 55 56 // collections details 55 57 if (count($categories)) 56 58 { … … 69 71 ;'; 70 72 $thumbnails = hash_from_query($query, 'col_id'); 71 73 72 74 $thumbnails[0] = array( 73 75 'id' => 0, … … 78 80 'rotation' => 0, 79 81 ); 80 82 81 83 foreach ($thumbnails as &$info) 82 84 { … … 84 86 } 85 87 unset($info); 86 88 87 89 $tpl_thumbnails_var = array(); 88 90 … … 91 93 $thumb = empty($thumbnails[ $category['id'] ]) ? $thumbnails[0] : $thumbnails[ $category['id'] ]; 92 94 $counter = get_display_images_count($category['nb_images'], $category['nb_images'], 0); 93 94 $tpl_var = array_merge( 95 'representative' =>$thumb,96 'TN_ALT' =>strip_tags($category['name']),97 'URL' =>USER_COLLEC_PUBLIC.'edit/'.$category['id'],98 'CAPTION_NB_IMAGES' => empty($counter) ? sprintf(l10n('%d photo'), 0) : $counter,99 'NAME' => trigger_event('render_category_name', $category['name']),100 'DESCRIPTION' => trigger_event('render_category_description', $category['comment'], 'subcatify_category_description'),101 'INFO_DATES' => format_date($category['date_creation'], true),102 'U_DELETE' => add_url_params(USER_COLLEC_PUBLIC, array('action'=>'delete','col_id'=>$category['id'])),95 96 $tpl_var = array_merge($category, array( 97 'representative' => $thumb, 98 'TN_ALT' => strip_tags($category['name']), 99 'URL' => USER_COLLEC_PUBLIC.'edit/'.$category['id'], 100 'CAPTION_NB_IMAGES' => empty($counter) ? l10n('%d photo', 0) : $counter, 101 'NAME' => trigger_change('render_category_name', $category['name']), 102 'DESCRIPTION' => trigger_change('render_category_description', $category['comment'], 'subcatify_category_description'), 103 'INFO_DATES' => format_date($category['date_creation'], true), 104 'U_DELETE' => add_url_params(USER_COLLEC_PUBLIC, array('action'=>'delete','col_id'=>$category['id'])), 103 105 )); 104 106 105 107 $tpl_thumbnails_var[] = $tpl_var; 106 108 } 107 108 $derivative_params = trigger_ event('get_index_album_derivative_params', ImageStdParams::get_by_type(IMG_THUMB) );109 110 $derivative_params = trigger_change('get_index_album_derivative_params', ImageStdParams::get_by_type(IMG_THUMB) ); 109 111 $template->assign(array( 110 'maxRequests' => $conf['max_requests'],112 'maxRequests' => $conf['max_requests'], 111 113 'category_thumbnails' => $tpl_thumbnails_var, 112 114 'derivative_params' => $derivative_params, 113 115 )); 114 116 115 117 $template->set_filename('index_category_thumbnails', 'mainpage_categories.tpl'); 116 118 $template->assign_var_from_handle('CATEGORIES', 'index_category_thumbnails'); 117 119 } 118 119 ?> -
extensions/UserCollections/include/display_thumbnails.inc.php
r23551 r25678 1 1 <?php 2 2 defined('USER_COLLEC_PATH') or die('Hacking attempt!'); 3 4 3 5 4 // image order … … 17 16 } 18 17 19 // get sorted elements20 18 $image_order_id = pwg_get_session_var('uc_image_order', 0); 21 19 $orders = get_collection_preferred_image_orders(); 22 20 21 22 // get sorted elements 23 23 $query = ' 24 24 SELECT i.id … … 31 31 $page['items'] = array_from_query($query, 'id'); 32 32 33 33 34 // caddie 34 35 if (isset($_GET['uc_caddie'])) … … 38 39 } 39 40 41 40 42 // image order menu 41 43 if ( $conf['index_sort_order_input'] … … 43 45 { 44 46 $url = add_url_params($self_url, array('uc_image_order' => '')); 45 47 46 48 foreach ($orders as $order_id => $order) 47 49 { … … 75 77 } 76 78 79 77 80 // add links for colorbox 78 81 add_event_handler('loc_end_index_thumbnails', 'user_collections_thumbnails_in_collection', EVENT_HANDLER_PRIORITY_NEUTRAL, 2); 79 82 83 // photos details 80 84 global $selection, $pictures; 81 85 include(PHPWG_ROOT_PATH . 'include/category_default.inc.php'); … … 83 87 84 88 // multisize menu 85 if ( !empty($page['items']))89 if (!empty($page['items'])) 86 90 { 87 91 $url = add_url_params($self_url, array('display' => '')); 88 92 89 93 $selected_type = $template->get_template_vars('derivative_params')->type; 90 $template->clear_assign( 'derivative_params');94 $template->clear_assign('derivative_params'); 91 95 $type_map = ImageStdParams::get_defined_type_map(); 92 96 unset($type_map[IMG_XXLARGE], $type_map[IMG_XLARGE]); … … 118 122 { 119 123 global $template, $page; 120 124 121 125 $url = USER_COLLEC_PUBLIC . 'edit/'.$page['col_id']; 122 126 123 127 foreach ($tpl_thumbnails_var as &$thumbnail) 124 128 { 125 129 $src_image = new SrcImage($thumbnail); 126 130 127 131 $thumbnail['FILE_SRC'] = DerivativeImage::url(IMG_LARGE, $src_image); 128 132 $thumbnail['URL'] = duplicate_picture_url( … … 135 139 ); 136 140 } 137 141 138 142 return $tpl_thumbnails_var; 139 143 } 140 141 ?> -
extensions/UserCollections/include/events.inc.php
r24421 r25678 12 12 if ($tokens[0] == 'collections') 13 13 { 14 add_event_handler('loc_begin_page_header', 'user_collections_page_header');15 16 14 $page['section'] = 'collections'; 17 15 $page['title'] = l10n('Collections'); 18 16 $page['body_id'] = 'theCollectionPage'; 17 $page['is_external'] = true; 18 $page['is_homepage'] = false; 19 19 20 $page['section_title'] = '<a href="'.get_absolute_root_url().'">'.l10n('Home').'</a>'.$conf['level_separator']; 20 if (is_a_guest()) $page['section_title'].= l10n('Collections'); 21 else $page['section_title'].= '<a href="'.USER_COLLEC_PUBLIC.'">'.l10n('Collections').'</a>'; 22 21 if (is_a_guest()) 22 { 23 $page['section_title'].= l10n('Collections'); 24 } 25 else 26 { 27 $page['section_title'].= '<a href="'.USER_COLLEC_PUBLIC.'">'.l10n('Collections').'</a>'; 28 } 29 30 $page['sub_section'] = 'list'; 23 31 if (in_array(@$tokens[1], array('edit','view','list'))) 24 32 { 25 33 $page['sub_section'] = $tokens[1]; 26 if ($tokens[1]=='edit' && isset($conf['GThumb']) && is_array($conf['GThumb'])) 27 { 28 $conf['GThumb']['big_thumb'] = false; // big thumb is buggy with removes 29 } 30 } 31 else 32 { 33 $page['sub_section'] = 'list'; 34 } 35 34 } 35 36 if ($page['sub_section']=='edit' && isset($conf['GThumb']) && is_array($conf['GThumb'])) 37 { 38 $conf['GThumb']['big_thumb'] = false; // big thumb is buggy with removes 39 } 40 36 41 if (!empty($tokens[2])) 37 42 { … … 39 44 } 40 45 } 41 }42 43 function user_collections_page_header()44 {45 global $page;46 $page['body_id'] = 'theCollectionPage';47 }48 49 function uc_anti_lightbox($tpl_thumbnails_var)50 {51 global $template, $page;52 53 if ($page['section'] == 'collections' && !empty($template->css_by_priority[0]))54 {55 foreach ($template->css_by_priority[0] as $file)56 {57 if (strpos($file[0], 'colorbox.css') !== false)58 {59 $template->assign('UC_NO_LIGHTBOX', true);60 break;61 }62 }63 }64 65 return $tpl_thumbnails_var;66 46 } 67 47 … … 73 53 if (isset($page['section']) and $page['section'] == 'collections') 74 54 { 75 include(USER_COLLEC_PATH . ' /include/collections.inc.php');76 } 77 55 include(USER_COLLEC_PATH . 'include/collections.inc.php'); 56 } 57 78 58 if (!is_a_guest() && count($page['items'])) 79 59 { … … 91 71 { 92 72 if (is_a_guest()) return $tpl_thumbnails_var; 93 73 94 74 global $page, $template, $user; 95 75 96 76 // the content is different on collection edition page and no button on batch downloader set edition page 97 if ( 77 if (empty($pictures) or (@$page['section'] == 'collections' and @$page['sub_section']=='edit') or @$page['section'] == 'download') 98 78 { 99 79 return $tpl_thumbnails_var; 100 80 } 101 81 102 82 $image_ids = array_map(create_function('$i', 'return $i["id"];'), $pictures); 103 83 104 84 // get collections for each picture 105 85 $query = ' … … 117 97 ;'; 118 98 $image_collections = simple_hash_from_query($query, 'image_id', 'col_ids'); 119 99 120 100 foreach ($tpl_thumbnails_var as &$thumbnail) 121 101 { … … 123 103 } 124 104 unset($thumbnail); 125 105 126 106 // get all collections 127 107 $query = ' … … 132 112 ;'; 133 113 $collections = hash_from_query($query, 'id'); 134 114 135 115 foreach ($collections as &$col) 136 116 { 137 $col["name"] = trigger_ event("render_category_name", $col["name"]);117 $col["name"] = trigger_change('render_category_name', $col["name"]); 138 118 } 139 119 unset($col); 140 120 141 121 $template->assign(array( 142 122 'COLLECTIONS' => $collections, 143 123 'USER_COLLEC_PATH' => USER_COLLEC_PATH, 144 124 )); 145 125 146 126 // thumbnails buttons 147 127 $template->set_prefilter('index_thumbnails', 'user_collections_thumbnails_list_button'); 148 128 149 129 return $tpl_thumbnails_var; 150 130 } … … 162 142 {/if} 163 143 </a>{/strip}'; 164 144 165 145 return preg_replace($search, $replace, $content); 166 146 } … … 173 153 function user_collections_picture_page() 174 154 { 175 if (is_a_guest()) return; 176 155 if (is_a_guest()) 156 { 157 return; 158 } 159 177 160 global $template, $picture, $user; 178 161 179 162 // get collections for this picture 180 163 $query = ' … … 190 173 ;'; 191 174 list($image_collections) = pwg_db_fetch_row(pwg_query($query)); 192 175 193 176 // get all collections 194 177 $query = ' … … 199 182 ;'; 200 183 $collections = hash_from_query($query, 'id'); 201 184 202 185 foreach ($collections as &$col) 203 186 { 204 $col["name"] = trigger_ event("render_category_name", $col["name"]);187 $col["name"] = trigger_change('render_category_name', $col["name"]); 205 188 } 206 189 unset($col); 207 190 208 191 $template->assign(array( 209 192 'CURRENT_COLLECTIONS' => $image_collections, … … 213 196 'IN_PICTURE' => true, 214 197 )); 215 198 216 199 // toolbar button 217 200 $template->set_filename('usercol_button', realpath(USER_COLLEC_PATH.'template/picture_button.tpl')); … … 227 210 function user_collections_add_menublock($menu_ref_arr) 228 211 { 229 if (is_a_guest()) return;230 231 212 $menu = &$menu_ref_arr[0]; 232 if ($menu->get_id() != 'menubar') return; 233 213 if (is_a_guest() || $menu->get_id() != 'menubar') 214 { 215 return; 216 } 217 234 218 $menu->register_block(new RegisteredBlock('mbUserCollection', l10n('Collections'), 'UserCollection')); 235 219 } … … 239 223 { 240 224 $max = 6; 241 225 242 226 global $template, $page, $conf, $user; 243 227 $menu = &$menu_ref_arr[0]; 244 228 245 229 if (($block = $menu->get_block('mbUserCollection')) != null) 246 230 { … … 252 236 ;'; 253 237 $collections = array_values(hash_from_query($query, 'id')); 254 238 255 239 $data['collections'] = array(); 256 240 for ($i=0; $i<$max && $i<count($collections); $i++) 257 241 { 258 $collections[$i]['name'] = trigger_ event('render_category_name', $collections[$i]['name']);242 $collections[$i]['name'] = trigger_change('render_category_name', $collections[$i]['name']); 259 243 $collections[$i]['u_edit'] = USER_COLLEC_PUBLIC.'edit/'.$collections[$i]['id']; 260 244 $data['collections'][] = $collections[$i]; 261 245 } 262 246 263 247 $data['NB_COL'] = count($collections); 264 248 if ($data['NB_COL'] > $max) … … 266 250 $data['MORE'] = count($collections)-$max; 267 251 } 268 252 269 253 $data['U_LIST'] = USER_COLLEC_PUBLIC; 270 254 271 255 $block->set_title('<a href="'.USER_COLLEC_PUBLIC.'">'.l10n('Collections').'</a>'); 272 256 $block->template = realpath(USER_COLLEC_PATH . 'template/menublock.tpl'); … … 274 258 } 275 259 } 276 277 ?> -
extensions/UserCollections/include/functions.inc.php
r24421 r25678 1 1 <?php 2 2 defined('USER_COLLEC_PATH') or die('Hacking attempt!'); 3 4 function uc_check_email_validity($mail_address)5 {6 if (function_exists('email_check_format'))7 {8 return email_check_format($mail_address); // Piwigo 2.59 }10 else if (version_compare(PHP_VERSION, '5.2.0') >= 0)11 {12 return filter_var($mail_address, FILTER_VALIDATE_EMAIL)!==false;13 }14 else15 {16 $atom = '[-a-z0-9!#$%&\'*+\\/=?^_`{|}~]'; // before arobase17 $domain = '([a-z0-9]([-a-z0-9]*[a-z0-9]+)?)'; // domain name18 $regex = '/^' . $atom . '+' . '(\.' . $atom . '+)*' . '@' . '(' . $domain . '{1,63}\.)+' . $domain . '{2,63}$/i';19 20 return (bool)preg_match($regex, $mail_address);21 }22 }23 3 24 4 function get_random_key($length=32) … … 35 15 { 36 16 global $conf; 37 38 return trigger_ event('get_category_preferred_image_orders', array(17 18 return trigger_change('get_category_preferred_image_orders', array( 39 19 array(l10n('Date added to collection, new → old'), 'add_date DESC', true), 40 20 array(l10n('Date added to collection, old → new'), 'add_date ASC', true), … … 42 22 array(l10n('Photo title, Z → A'), 'name DESC', true), 43 23 array(l10n('Date created, new → old'), 'date_creation DESC', true), 44 array(l10n('Date created, old → new'), 'date_creation ASC', true), 24 array(l10n('Date created, old → new'), 'date_creation ASC', true), 45 25 array(l10n('Date posted, new → old'), 'date_available DESC', true), 46 26 array(l10n('Date posted, old → new'), 'date_available ASC', true), … … 58 38 array(l10n('Name, Z → A'), 'name DESC', true), 59 39 array(l10n('Date created, new → old'), 'date_creation DESC', true), 60 array(l10n('Date created, old → new'), 'date_creation ASC', true), 40 array(l10n('Date created, old → new'), 'date_creation ASC', true), 61 41 array(l10n('Photos number, high → low'), 'nb_images DESC', true), 62 42 array(l10n('Photos number, low → high'), 'nb_images ASC', true), 63 43 ); 64 44 } 65 66 ?> -
extensions/UserCollections/include/index.php
r16591 r25678 1 1 <?php 2 // +-----------------------------------------------------------------------+3 // | Piwigo - a PHP based photo gallery |4 // +-----------------------------------------------------------------------+5 // | Copyright(C) 2008-2012 Piwigo Team http://piwigo.org |6 // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |7 // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |8 // +-----------------------------------------------------------------------+9 // | This program is free software; you can redistribute it and/or modify |10 // | it under the terms of the GNU General Public License as published by |11 // | the Free Software Foundation |12 // | |13 // | This program is distributed in the hope that it will be useful, but |14 // | WITHOUT ANY WARRANTY; without even the implied warranty of |15 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |16 // | General Public License for more details. |17 // | |18 // | You should have received a copy of the GNU General Public License |19 // | along with this program; if not, write to the Free Software |20 // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |21 // | USA. |22 // +-----------------------------------------------------------------------+23 24 // Recursive call25 2 $url = '../'; 26 3 header( 'Request-URI: '.$url ); … … 28 5 header( 'Location: '.$url ); 29 6 exit(); 30 ?> -
extensions/UserCollections/include/plain_encoder.php
r20090 r25678 40 40 } 41 41 } 42 43 ?> -
extensions/UserCollections/include/ws_functions.inc.php
r24421 r25678 6 6 $service = &$arr[0]; 7 7 global $conf; 8 8 9 9 $service->addMethod( 10 10 'pwg.collections.create', … … 17 17 'Create a new User Collection.' 18 18 ); 19 19 20 20 $service->addMethod( 21 21 'pwg.collections.delete', … … 26 26 'Delete a User Collection.' 27 27 ); 28 28 29 29 $service->addMethod( 30 30 'pwg.collections.getList', … … 42 42 'Returns a list of collections.' 43 43 ); 44 44 45 45 $service->addMethod( 46 46 'pwg.collections.addImages', … … 52 52 'Add images to a collection.' 53 53 ); 54 54 55 55 $service->addMethod( 56 56 'pwg.collections.removeImages', … … 62 62 'Remove images from a collection.' 63 63 ); 64 64 65 65 $service->addMethod( 66 66 'pwg.collections.getImages', … … 74 74 'Returns elements for the corresponding collection.' 75 75 ); 76 76 77 77 $service->addMethod( 78 78 'pwg.collections.getSerialized', … … 88 88 'Returns a serialized version of the collection in CSV.<br>The return type is plain/text whatever you select as response format.' 89 89 ); 90 90 91 91 $service->addMethod( 92 92 'pwg.collections.getInfo', … … 105 105 { 106 106 global $conf, $user; 107 108 // check status 109 if (is_a_guest()) 110 { 111 return new PwgError(403, 'Forbidden'); 112 } 113 107 108 // check status 109 if (is_a_guest()) 110 { 111 return new PwgError(403, 'Forbidden'); 112 } 113 114 114 // check name 115 115 if (empty($params['name'])) … … 117 117 return new PwgError(WS_ERR_MISSING_PARAM, 'Empty collection name'); 118 118 } 119 119 120 120 // check user id 121 121 if (!empty($params['user_id'])) … … 135 135 $params['user_id'] = $user['id']; 136 136 } 137 137 138 138 $collection = new UserCollection('new', $params['name'], $params['comment'], $params['user_id']); 139 139 140 140 return array_change_key_case($collection->getCollectionInfo(), CASE_LOWER); 141 141 } … … 147 147 { 148 148 global $user; 149 150 // check status 151 if (is_a_guest()) 152 { 153 return new PwgError(403, 'Forbidden'); 154 } 155 156 try { 157 $collection = new UserCollection($params['col_id']); 158 $collection->checkUser(); 159 149 150 // check status 151 if (is_a_guest()) 152 { 153 return new PwgError(403, 'Forbidden'); 154 } 155 156 try { 157 $collection = new UserCollection($params['col_id']); 158 $collection->checkUser(); 159 160 160 $collection->delete(); 161 161 } … … 172 172 { 173 173 global $user, $conf; 174 175 // check status 176 if (is_a_guest()) 177 { 178 return new PwgError(403, 'Forbidden'); 179 } 180 174 175 // check status 176 if (is_a_guest()) 177 { 178 return new PwgError(403, 'Forbidden'); 179 } 180 181 181 // check user_id 182 182 if (!empty($params['user_id'])) … … 196 196 $params['user_id'] = $user['id']; 197 197 } 198 198 199 199 // search 200 200 $where_clauses = array('1=1'); … … 207 207 $where_clauses[] = 'name LIKE("%'.pwg_db_real_escape_string($params['name']).'%")'; 208 208 } 209 209 210 210 $order_by = !empty($params['order']) ? $params['order'] : 'username ASC, name ASC'; 211 211 212 212 $query = ' 213 SELECT 213 SELECT 214 214 c.*, 215 215 u.'.$conf['user_fields']['username'].' AS username … … 223 223 ;'; 224 224 $sets = hash_from_query($query, 'id'); 225 225 226 226 $data = array(); 227 227 foreach ($sets as $row) … … 238 238 ); 239 239 } 240 240 241 241 return array( 242 242 'paging' => new PwgNamedStruct(array( … … 250 250 ) 251 251 ); 252 252 253 253 return $ret; 254 254 } … … 260 260 { 261 261 global $conf, $user; 262 263 // check status 264 if (is_a_guest()) 265 { 266 return new PwgError(403, 'Forbidden'); 267 } 268 269 try { 270 $collection = new UserCollection($params['col_id']); 271 $collection->checkUser(); 272 262 263 // check status 264 if (is_a_guest()) 265 { 266 return new PwgError(403, 'Forbidden'); 267 } 268 269 try { 270 $collection = new UserCollection($params['col_id']); 271 $collection->checkUser(); 272 273 273 $collection->addImages($params['image_ids']); 274 274 275 275 return array('nb_images' => $collection->getParam('nb_images')); 276 276 } … … 287 287 { 288 288 global $conf, $user; 289 290 // check status 291 if (is_a_guest()) 292 { 293 return new PwgError(403, 'Forbidden'); 294 } 295 296 try { 297 $collection = new UserCollection($params['col_id']); 298 $collection->checkUser(); 299 289 290 // check status 291 if (is_a_guest()) 292 { 293 return new PwgError(403, 'Forbidden'); 294 } 295 296 try { 297 $collection = new UserCollection($params['col_id']); 298 $collection->checkUser(); 299 300 300 $collection->removeImages($params['image_ids']); 301 301 302 302 return array('nb_images' => $collection->getParam('nb_images')); 303 303 } … … 314 314 { 315 315 global $conf, $user; 316 317 // check status 318 if (is_a_guest()) 319 { 320 return new PwgError(403, 'Forbidden'); 321 } 322 323 try { 324 $collection = new UserCollection($params['col_id']); 325 $collection->checkUser(); 326 316 317 // check status 318 if (is_a_guest()) 319 { 320 return new PwgError(403, 'Forbidden'); 321 } 322 323 try { 324 $collection = new UserCollection($params['col_id']); 325 $collection->checkUser(); 326 327 327 $image_ids = $collection->getImages(); 328 328 $images = array(); 329 329 330 330 if (!empty($image_ids)) 331 331 { … … 343 343 SELECT i.* 344 344 FROM '.IMAGES_TABLE.' i 345 WHERE 345 WHERE 346 346 '. implode("\n AND ", $where_clauses).' 347 347 GROUP BY i.id … … 366 366 } 367 367 $image = array_merge($image, ws_std_get_urls($row)); 368 368 369 369 array_push($images, $image); 370 370 } 371 371 } 372 372 373 373 return array( 374 374 'paging' => new PwgNamedStruct(array( … … 396 396 { 397 397 global $conf, $user; 398 399 // check status 400 if (is_a_guest()) 401 { 402 return new PwgError(403, 'Forbidden'); 403 } 404 405 try { 406 $collection = new UserCollection($params['col_id']); 407 $collection->checkUser(); 408 398 399 // check status 400 if (is_a_guest()) 401 { 402 return new PwgError(403, 'Forbidden'); 403 } 404 405 try { 406 $collection = new UserCollection($params['col_id']); 407 $collection->checkUser(); 408 409 409 // change encoder to plain text 410 410 include_once(USER_COLLEC_PATH.'include/plain_encoder.php'); 411 411 $encoder = new PwgPlainEncoder(); 412 412 $service->setEncoder('plain', $encoder); 413 413 414 414 return $collection->serialize($params['content']); 415 415 } … … 426 426 { 427 427 global $conf, $user; 428 429 // check status 430 if (is_a_guest()) 431 { 432 return new PwgError(403, 'Forbidden'); 433 } 434 435 try { 436 $collection = new UserCollection($params['col_id']); 437 $collection->checkUser(); 438 428 429 // check status 430 if (is_a_guest()) 431 { 432 return new PwgError(403, 'Forbidden'); 433 } 434 435 try { 436 $collection = new UserCollection($params['col_id']); 437 $collection->checkUser(); 438 439 439 return array_change_key_case($collection->getCollectionInfo(), CASE_LOWER); 440 440 } … … 444 444 } 445 445 } 446 447 ?> -
extensions/UserCollections/index.php
r16591 r25678 1 1 <?php 2 // +-----------------------------------------------------------------------+3 // | Piwigo - a PHP based photo gallery |4 // +-----------------------------------------------------------------------+5 // | Copyright(C) 2008-2012 Piwigo Team http://piwigo.org |6 // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |7 // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |8 // +-----------------------------------------------------------------------+9 // | This program is free software; you can redistribute it and/or modify |10 // | it under the terms of the GNU General Public License as published by |11 // | the Free Software Foundation |12 // | |13 // | This program is distributed in the hope that it will be useful, but |14 // | WITHOUT ANY WARRANTY; without even the implied warranty of |15 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |16 // | General Public License for more details. |17 // | |18 // | You should have received a copy of the GNU General Public License |19 // | along with this program; if not, write to the Free Software |20 // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |21 // | USA. |22 // +-----------------------------------------------------------------------+23 24 // Recursive call25 2 $url = '../'; 26 3 header( 'Request-URI: '.$url ); … … 28 5 header( 'Location: '.$url ); 29 6 exit(); 30 ?> -
extensions/UserCollections/language/en_UK/plugin.lang.php
r24421 r25678 55 55 $lang['Message (optional)'] = 'Message (optional)'; 56 56 $lang['Hello <b>%s</b>, %s sent you a photos collection from <a href="%s">%s</a>'] = 'Hello <b>%s</b>, %s sent you a photo collection from <a href="%s">%s</a>'; 57 $lang['Hello %s, %s sent you a photos collection from "%s"'] = 'Hello %s, %s sent you a photos collection from "%s"'; 57 58 $lang['Click here to view the complete collection'] = 'Click here to view the complete collection'; 58 59 $lang['Date added to collection, new → old'] = 'Date added to collection, new → old'; … … 62 63 $lang['Photos number, high → low'] = 'Photos number, high → low'; 63 64 $lang['Photos number, low → high'] = 'Photos number, low → high'; 65 $lang['Add'] = 'Add'; 66 $lang['Cancel'] = 'Cancel'; 67 $lang['Description'] = 'Description'; 68 $lang['jump to photo'] = 'jump to photo'; 69 $lang['Name'] = 'Name'; 70 $lang['Send'] = 'Send'; 64 71 65 72 ?> -
extensions/UserCollections/language/fr_FR/plugin.lang.php
r24421 r25678 55 55 $lang['Message (optional)'] = 'Message (optionel)'; 56 56 $lang['Hello <b>%s</b>, %s sent you a photos collection from <a href="%s">%s</a>'] = 'Bonjour <b>%s</b>, %s vous a envoyé une collection de photos depuis <a href="%s">%s</a>'; 57 $lang['Hello %s, %s sent you a photos collection from "%s"'] = 'Bonjour %s, %s vous a envoyé une collection de photos depuis "%s"'; 57 58 $lang['Click here to view the complete collection'] = 'Cliquez ici pour voir la collection complète'; 58 59 $lang['Date added to collection, new → old'] = 'Date d\'ajout à la collection, récent → ancien'; … … 62 63 $lang['Photos number, high → low'] = 'Nombre de photos, élévé → faible'; 63 64 $lang['Photos number, low → high'] = 'Nombre de photos, faible → élévé'; 65 $lang['Add'] = 'Ajouter'; 66 $lang['Cancel'] = 'Annuler'; 67 $lang['Description'] = 'Description'; 68 $lang['jump to photo'] = 'Voir la photo'; 69 $lang['Name'] = 'Nom'; 70 $lang['Send'] = 'Envoyer'; 64 71 65 72 ?> -
extensions/UserCollections/main.inc.php
r24421 r25678 1 <?php 1 <?php 2 2 /* 3 3 Plugin Name: User Collections … … 18 18 global $conf, $prefixeTable; 19 19 20 define d('USER_COLLEC_ID') or define('USER_COLLEC_ID',basename(dirname(__FILE__)));20 define('USER_COLLEC_ID', basename(dirname(__FILE__))); 21 21 define('USER_COLLEC_PATH', PHPWG_PLUGINS_PATH . USER_COLLEC_ID . '/'); 22 22 define('COLLECTIONS_TABLE', $prefixeTable.'collections'); … … 43 43 // thumbnails actions 44 44 add_event_handler('loc_end_index_thumbnails', 'user_collections_thumbnails_list', EVENT_HANDLER_PRIORITY_NEUTRAL-10, 2); 45 add_event_handler('loc_end_index_thumbnails', 'uc_anti_lightbox', 41);46 45 47 46 // picture action … … 64 63 function user_collections_init() 65 64 { 66 global $pwg_loaded_plugins, $conf; 67 68 if ( 69 USER_COLLEC_VERSION == 'auto' or 70 $pwg_loaded_plugins[USER_COLLEC_ID]['version'] == 'auto' or 71 version_compare($pwg_loaded_plugins[USER_COLLEC_ID]['version'], USER_COLLEC_VERSION, '<') 72 ) 73 { 74 include_once(USER_COLLEC_PATH . 'include/install.inc.php'); 75 user_collections_install(); 76 77 if ( $pwg_loaded_plugins[USER_COLLEC_ID]['version'] != 'auto' and USER_COLLEC_VERSION != 'auto' ) 78 { 79 $query = ' 80 UPDATE '. PLUGINS_TABLE .' 81 SET version = "'. USER_COLLEC_VERSION .'" 82 WHERE id = "'. USER_COLLEC_ID .'"'; 83 pwg_query($query); 84 85 $pwg_loaded_plugins[USER_COLLEC_ID]['version'] = USER_COLLEC_VERSION; 86 87 if (defined('IN_ADMIN')) 88 { 89 $_SESSION['page_infos'][] = 'UserCollections updated to version '. USER_COLLEC_VERSION; 90 } 91 } 92 } 93 65 global $conf; 66 67 include_once(USER_COLLEC_PATH . 'maintain.inc.php'); 68 $maintain = new UserCollections_maintain(USER_COLLEC_ID); 69 $maintain->autoUpdate(USER_COLLEC_VERSION, 'install'); 70 94 71 load_language('plugin.lang', USER_COLLEC_PATH); 95 72 96 73 $conf['user_collections'] = unserialize($conf['user_collections']); 97 74 } … … 100 77 * admin plugins menu 101 78 */ 102 function user_collections_admin_menu($menu) 79 function user_collections_admin_menu($menu) 103 80 { 104 array_push($menu,array(81 $menu[] = array( 105 82 'NAME' => 'User Collections', 106 83 'URL' => USER_COLLEC_ADMIN, 107 )); 84 ); 85 108 86 return $menu; 109 87 } 110 111 ?> -
extensions/UserCollections/maintain.inc.php
r24421 r25678 2 2 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 3 3 4 defined('USER_COLLEC_ID') or define('USER_COLLEC_ID', basename(dirname(__FILE__))); 5 include_once(PHPWG_PLUGINS_PATH . USER_COLLEC_ID . '/include/install.inc.php'); 4 class UserCollections_maintain extends PluginMaintain 5 { 6 private $installed = false; 6 7 7 function plugin_install() 8 { 9 user_collections_install(); 10 11 define('user_collections_installed', true); 12 } 8 function install($plugin_version, &$errors=array()) 9 { 10 global $conf, $prefixeTable; 13 11 14 function plugin_activate() 15 { 16 if (!defined('user_collections_intalled')) 12 if (empty($conf['user_collections'])) 13 { 14 $conf['user_collections'] = serialize(array( 15 'allow_mails' => true, 16 'allow_public' => true, 17 )); 18 19 conf_update_param('user_collections', $conf['user_collections']); 20 } 21 22 // create tables 23 $query = ' 24 CREATE TABLE IF NOT EXISTS `'.$prefixeTable.'collections` ( 25 `id` mediumint(8) NOT NULL AUTO_INCREMENT, 26 `user_id` smallint(5) DEFAULT NULL, 27 `name` varchar(255) NOT NULL, 28 `date_creation` datetime NOT NULL, 29 `comment` text NULL, 30 `nb_images` mediumint(8) NOT NULL DEFAULT 0, 31 PRIMARY KEY (`id`) 32 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 33 ;'; 34 pwg_query($query); 35 36 $query = ' 37 CREATE TABLE IF NOT EXISTS `'.$prefixeTable.'collection_images` ( 38 `col_id` mediumint(8) NOT NULL, 39 `image_id` mediumint(8) NOT NULL, 40 `add_date` datetime NULL, 41 UNIQUE KEY `UNIQUE` (`col_id`,`image_id`) 42 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 43 ;'; 44 pwg_query($query); 45 46 $query = ' 47 CREATE TABLE IF NOT EXISTS `'.$prefixeTable.'collection_shares` ( 48 `id` mediumint(8) NOT NULL AUTO_INCREMENT, 49 `col_id` mediumint(8) NOT NULL, 50 `share_key` varchar(64) NOT NULL, 51 `params` text NULL, 52 `add_date` datetime NOT NULL, 53 PRIMARY KEY (`id`), 54 UNIQUE KEY `share_key` (`share_key`) 55 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 56 ;'; 57 pwg_query($query); 58 59 60 // version 2.0.0 61 $result = pwg_query('SHOW COLUMNS FROM `'.$prefixeTable.'collection_images` LIKE "add_date";'); 62 if (!pwg_db_num_rows($result)) 63 { 64 pwg_query('ALTER TABLE `'.$prefixeTable.'collection_images` ADD `add_date` datetime NULL;'); 65 } 66 67 $result = pwg_query('SHOW COLUMNS FROM `'.$prefixeTable.'collections` LIKE "comment";'); 68 if (!pwg_db_num_rows($result)) 69 { 70 pwg_query('ALTER TABLE `'.$prefixeTable.'collections` ADD `comment` text NULL;'); 71 pwg_query('ALTER TABLE `'.$prefixeTable.'collections` DROP `active`;'); 72 } 73 74 // version 2.1.0 75 $result = pwg_query('SHOW COLUMNS FROM `'.$prefixeTable.'collections` LIKE "public";'); 76 if (pwg_db_num_rows($result)) 77 { 78 $now = date('Y-m-d H:i:s'); 79 80 $query = ' 81 SELECT id, public_id 82 FROM `'.$prefixeTable.'collections` 83 WHERE public = 1 84 ;'; 85 $result = pwg_query($query); 86 87 $inserts = array(); 88 while ($row = pwg_db_fetch_assoc($result)) 89 { 90 $inserts[] = array( 91 'col_id' => $row['id'], 92 'share_key' => $row['public_id'], 93 'params' => serialize(array('password'=>'','deadline'=>'')), 94 'add_date' => $now, 95 ); 96 } 97 98 mass_inserts($prefixeTable.'collection_shares', 99 array('col_id','share_key','params','add_date'), 100 $inserts 101 ); 102 103 pwg_query('ALTER TABLE `'.$prefixeTable.'collections` DROP `public`, DROP `public_id`;'); 104 } 105 } 106 107 function activate($plugin_version, &$errors=array()) 17 108 { 18 user_collections_install(); 109 if (!$this->installed) 110 { 111 $this->install($plugin_version, $errors); 112 } 113 } 114 115 function deactivate(){} 116 117 function uninstall() 118 { 119 global $prefixeTable; 120 121 conf_delete_param('user_collections'); 122 123 pwg_query('DROP TABLE IF EXISTS `'.$prefixeTable.'collections`;'); 124 pwg_query('DROP TABLE IF EXISTS `'.$prefixeTable.'collection_images`;'); 125 pwg_query('DROP TABLE IF EXISTS `'.$prefixeTable.'collection_shares`;'); 19 126 } 20 127 } 21 22 function plugin_uninstall()23 {24 global $prefixeTable, $conf;25 26 pwg_query('DELETE FROM `'. CONFIG_TABLE .'` WHERE param = "user_collections";');27 pwg_query('DROP TABLE IF EXISTS `'.$prefixeTable.'collections`;');28 pwg_query('DROP TABLE IF EXISTS `'.$prefixeTable.'collection_images`;');29 pwg_query('DROP TABLE IF EXISTS `'.$prefixeTable.'collection_shares`;');30 31 unset($conf['user_collections']);32 }33 34 ?> -
extensions/UserCollections/template/collection_edit.tpl
r25674 r25678 1 {strip} 1 2 {combine_css path=$USER_COLLEC_PATH|cat:'template/style_collections.css'} 2 3 … … 4 5 5 6 {*<!-- datepicker and timepicker -->*} 6 {include file='include/datepicker.inc.tpl'} 7 {combine_script id='jquery.ui.timepicker' load='footer' require='jquery.ui.datepicker,jquery.ui.slider' path=$USER_COLLEC_PATH|cat:'template/resources/jquery-timepicker/jquery-ui-timepicker-addon.js'} 8 9 {assign var="timepicker_language" value=$USER_COLLEC_PATH|cat:'template/resources/jquery-timepicker/i18n/jquery-ui-timepicker-'|cat:$lang_info.code|cat:'.js'} 10 {if "PHPWG_ROOT_PATH"|@constant|@cat:$timepicker_language|@file_exists} 11 {combine_script id="jquery.ui.timepicker-$lang_info.code" load='footer' require='jquery.ui.timepicker' path=$timepicker_language} 7 {combine_script id='jquery.ui.datepicker' load='footer' path='themes/default/js/ui/jquery.ui.datepicker.js'} 8 {combine_script id='jquery.ui.timepicker' load='footer' require='jquery.ui.slider' path=$USER_COLLEC_PATH|cat:'template/resources/jquery-timepicker/jquery-ui-timepicker-addon.js'} 9 10 {assign var=datepicker_language value='themes/default/js/ui/i18n/jquery.ui.datepicker-'|cat:$lang_info.code|cat:'.js'} 11 {if 'PHPWG_ROOT_PATH'|constant|cat:$datepicker_language|file_exists} 12 {combine_script id='jquery.ui.datepicker-'|cat:$lang_info.code load='footer' require='jquery.ui.datepicker' path=$datepicker_language} 13 {/if} 14 15 {assign var=timepicker_language value=$USER_COLLEC_PATH|cat:'template/resources/jquery-timepicker/i18n/jquery-ui-timepicker-'|cat:$lang_info.code|cat:'.js'} 16 {if 'PHPWG_ROOT_PATH'|constant|cat:$timepicker_language|file_exists} 17 {combine_script id='jquery.ui.timepicker-'|cat:$lang_info.code load='footer' require='jquery.ui.timepicker' path=$timepicker_language} 12 18 {/if} 13 19 14 20 {combine_css path='themes/default/js/ui/theme/jquery.ui.core.css'} 15 21 {combine_css path='themes/default/js/ui/theme/jquery.ui.theme.css'} 22 {combine_css path='themes/default/js/ui/theme/jquery.ui.datepicker.css'} 16 23 {combine_css path='themes/default/js/ui/theme/jquery.ui.slider.css'} 17 24 {combine_css path=$USER_COLLEC_PATH|cat:'template/resources/jquery-timepicker/jquery-ui-timepicker-addon.css'} 18 19 20 {footer_script require='jquery ,jquery.ui.timepicker'}21 var bg_color = $('#the_page #content').css('background-color');22 if (!bg_color || bg_color=='transparent') { ldelim}23 bg_color = $('body').css('background-color');25 {/strip} 26 27 {footer_script require='jquery'} 28 var bg_color = jQuery('#the_page #content').css('background-color'); 29 if (!bg_color || bg_color=='transparent') { 30 bg_color = jQuery('body').css('background-color'); 24 31 } 25 32 26 33 {if isset($U_SHARE)} 27 {literal}28 34 var $share_form = jQuery('#share_form'); 29 35 30 36 // functions 31 37 jQuery.fn.extend({ 32 38 hideVis: function() { 33 $(this).css('visibility', 'hidden');39 jQuery(this).css('visibility', 'hidden'); 34 40 return this; 35 41 }, 36 42 showVis: function() { 37 $(this).css('visibility', 'visible');43 jQuery(this).css('visibility', 'visible'); 38 44 return this; 39 45 }, 40 46 toggleVis: function(toggle) { 41 if ( $(this).css('visibility')=='hidden' || toggle === true){42 return $(this).showVis();47 if (jQuery(this).css('visibility')=='hidden' || toggle === true){ 48 return jQuery(this).showVis(); 43 49 } else { 44 return $(this).hideVis();50 return jQuery(this).hideVis(); 45 51 } 46 52 } 47 53 }); 48 54 49 55 function enterShareKeyEdit() { 50 56 $share_form.find('.url-edit').show(); 51 57 $share_form.find('.url-normal').hide(); 52 jQuery( ".share_colorbox_open").colorbox.resize({speed:0});58 jQuery('.share_colorbox_open').colorbox.resize({ldelim}speed:0}); 53 59 } 54 60 function exitShareKeyEdit() { 55 61 $share_form.find('.url-edit').hide(); 56 62 $share_form.find('.url-normal').show(); 57 jQuery( ".share_colorbox_open").colorbox.resize({speed:0});63 jQuery('.share_colorbox_open').colorbox.resize({ldelim}speed:0}); 58 64 } 59 65 60 66 // hide some inputs 61 67 exitShareKeyEdit(); 62 68 63 69 // display key 64 70 $share_form.find('.url-more').text($share_form.find('input[name="share_key"]').val()); 65 71 66 72 // url edition 67 $share_form.find('.edit_share_key').on('click', function( ) {73 $share_form.find('.edit_share_key').on('click', function(e) { 68 74 enterShareKeyEdit(); 69 return false;70 }); 71 $share_form.find('.set_share_key').on('click', function( ) {75 e.preventDefault(); 76 }); 77 $share_form.find('.set_share_key').on('click', function(e) { 72 78 if ($share_form.find('input[name="share_key"]').val().length < 8) { 73 alert( "{/literal}{'The key must be at least 8 characters long'|@translate|escape:javascript}{literal}");79 alert('{'The key must be at least 8 characters long'|translate|escape:javascript}'); 74 80 } 75 81 else { … … 77 83 exitShareKeyEdit(); 78 84 } 79 return false;80 }); 81 $share_form.find('.cancel_share_key').on('click', function( ) {85 e.preventDefault(); 86 }); 87 $share_form.find('.cancel_share_key').on('click', function(e) { 82 88 $share_form.find('input[name="share_key"]').val($share_form.find('.url-more').text()); 83 89 exitShareKeyEdit(); 84 return false;90 e.preventDefault(); 85 91 }); 86 92 $share_form.find('.url-more').on('dblclick', function() { 87 93 enterShareKeyEdit(); 88 94 }); 89 95 90 96 // optional inputs 91 97 $share_form.find('.share-option').each(function() { 92 $share_form.find('input[name="'+ $(this).data('for') +'"]').hideVis();98 $share_form.find('input[name="'+ jQuery(this).data('for') +'"]').hideVis(); 93 99 }).on('change', function() { 94 $share_form.find('input[name="'+ $(this).data('for') +'"]').toggleVis($(this).is(':checked'));95 }); 96 100 $share_form.find('input[name="'+ jQuery(this).data('for') +'"]').toggleVis($(this).is(':checked')); 101 }); 102 97 103 // datetime picker 98 104 $share_form.find('input[name="share_deadline"]').datetimepicker({ … … 100 106 minDate: new Date() 101 107 }); 102 103 108 109 104 110 // popup 105 jQuery( ".share_colorbox_open").colorbox({106 { /literal}{if isset($share.open)}open: true, transition:"none",{/if}{literal}111 jQuery('.share_colorbox_open').colorbox({ 112 {if isset($share.open)}open: true, transition:"none",{/if} 107 113 inline:true 108 114 }); 109 jQuery(".share_colorbox_close").click(function() { 110 jQuery(".share_colorbox_open").colorbox.close(); 111 return false; 112 }); 113 jQuery("#share_form").css('background-color', bg_color); 114 {/literal} 115 jQuery('.share_colorbox_close').click(function(e) { 116 jQuery('.share_colorbox_open').colorbox.close(); 117 e.preventDefault(); 118 }); 119 jQuery('#share_form').css('background-color', bg_color); 115 120 {/if} 116 121 117 122 {if isset($U_MAIL)} 118 {literal} 119 jQuery(".mail_colorbox_open").colorbox({ 120 {/literal}{if isset($contact.open)}open: true, transition:"none",{/if}{literal} 123 jQuery('.mail_colorbox_open').colorbox({ 124 {if isset($contact.open)}open: true, transition:"none",{/if} 121 125 inline:true 122 126 }); 123 jQuery(".mail_colorbox_close").click(function() { 124 jQuery(".mail_colorbox_open").colorbox.close(); 125 return false; 126 }); 127 128 129 jQuery("#mail_form").css('background-color', bg_color); 130 {/literal} 131 {/if} 132 133 {literal} 134 jQuery("#edit_form_show").click(function() { 135 jQuery("#edit_form_show").hide(); 136 jQuery(".additional_info").hide(); 137 jQuery("#edit_form").show(); 127 jQuery('.mail_colorbox_close').click(function(e) { 128 jQuery('.mail_colorbox_open').colorbox.close(); 129 e.preventDefault(); 130 }); 131 132 133 jQuery('#mail_form').css('background-color', bg_color); 134 {/if} 135 136 jQuery('#edit_form_show').click(function() { 137 jQuery('#edit_form_show').hide(); 138 jQuery('.additional_info').hide(); 139 jQuery('#edit_form').show(); 138 140 }); 139 jQuery( "#edit_form_hide").click(function() {140 jQuery( "#edit_form_show").show();141 jQuery( ".additional_info").show();142 jQuery( "#edit_form").hide();141 jQuery('#edit_form_hide').click(function() { 142 jQuery('#edit_form_show').show(); 143 jQuery('.additional_info').show(); 144 jQuery('#edit_form').hide(); 143 145 }); 144 {/literal}145 146 {/footer_script} 146 147 147 148 148 {* <!-- Menubar & titrePage --> *}149 {if $themeconf.name == "stripped" or $themeconf.parent == "stripped"}150 {include file=$USER_COLLEC_ABS_PATH|@cat:'template/themes/stripped.tpl'}151 {assign var="clear" value="true"}152 {elseif $themeconf.name == "simple-grey" or $themeconf.parent == "simple"}153 {include file=$USER_COLLEC_ABS_PATH|@cat:'template/themes/simple.tpl'}154 {assign var="clear" value="true"}155 {else}156 {include file=$USER_COLLEC_ABS_PATH|@cat:'template/themes/default.tpl'}157 {/if}158 159 {if isset($errors) or not empty($infos)}160 {include file='infos_errors.tpl'}161 {/if}162 163 164 149 {if isset($collection)} 165 150 166 {if !empty($CONTENT_DESCRIPTION)} 167 <div class="additional_info"> 168 {$CONTENT_DESCRIPTION} 169 </div> 170 {/if} 171 172 <p style="text-align:center;"><input type="submit" id="edit_form_show" value="{'Edit'|@translate}"></p> 151 <p style="text-align:center;"><input type="submit" id="edit_form_show" value="{'Edit'|translate}"></p> 173 152 174 153 {* <!-- edit collection -->*} 175 154 <form action="{$F_ACTION}" method="post" id="edit_form" style="display:none;"> 176 155 <fieldset id="colProperties"> 177 <legend>{' Properties'|@translate}</legend>178 179 <p class="title"><label for="name">{'Name'| @translate}</label></p>156 <legend>{'Edit'|translate}</legend> 157 158 <p class="title"><label for="name">{'Name'|translate}</label></p> 180 159 <p><input type="text" name="name" id="name" value="{$collection.NAME|escape:html}" size="60"></p> 181 182 <p class="title"><label for="comment">{'Description'| @translate}</label></p>160 161 <p class="title"><label for="comment">{'Description'|translate}</label></p> 183 162 <p><textarea name="comment" id="comment" style="width:400px;height:100px;">{$collection.COMMENT}</textarea></p> 184 163 185 164 <p> 186 <input type="submit" name="save_col" value="{'Save'| @translate}">187 <a id="edit_form_hide">{'Cancel'| @translate}</a>165 <input type="submit" name="save_col" value="{'Save'|translate}"> 166 <a id="edit_form_hide">{'Cancel'|translate}</a> 188 167 </p> 189 168 </fieldset> … … 195 174 <form id="share_form" class="uc_form" action="{$F_ACTION}" method="post"> 196 175 {include file='infos_errors.tpl' errors=$share.errors infos=$share.infos} 197 176 198 177 <table> 199 178 <tr> … … 201 180 <span class="url-base">{$U_SHARE}</span><span class="url-more url-normal"></span> 202 181 <input type="text" name="share_key" class="url-edit" size="20" value="{$share.share_key}"> 203 <button class="url-normal edit_share_key">{'Edit'| @translate}</button>204 <button class="url-edit set_share_key">{'OK'| @translate}</button>205 <a href="#" class="url-edit cancel_share_key">{'Cancel'| @translate}</button>182 <button class="url-normal edit_share_key">{'Edit'|translate}</button> 183 <button class="url-edit set_share_key">{'OK'|translate}</button> 184 <a href="#" class="url-edit cancel_share_key">{'Cancel'|translate}</button> 206 185 </td> 207 186 </tr> 208 187 <tr> 209 188 <td class="title"><label> 210 {'Password'| @translate}189 {'Password'|translate} 211 190 <input type="checkbox" name="use_share_password" data-for="share_password" class="share-option"> 212 191 </label></td> 213 192 <td> 214 <input type="text" name="share_password" size="25" maxlength="25" value="{$share.password}" placeholder="{'Password'| @translate}">193 <input type="text" name="share_password" size="25" maxlength="25" value="{$share.password}" placeholder="{'Password'|translate}"> 215 194 </td> 216 195 </tr> 217 196 <tr> 218 197 <td class="title"><label> 219 {'Expiration date'| @translate}198 {'Expiration date'|translate} 220 199 <input type="checkbox" name="use_share_deadline" data-for="share_deadline" class="share-option"> 221 200 </label></td> 222 201 <td> 223 <input type="text" name="share_deadline" size="25" value="{$share.deadline}" placeholder="{'Date'| @translate}">202 <input type="text" name="share_deadline" size="25" value="{$share.deadline}" placeholder="{'Date'|translate}"> 224 203 </td> 225 204 </tr> … … 227 206 <td class="title"> </td> 228 207 <td> 229 <input class="submit" type="submit" name="add_share" value="{'Add'| @translate}">230 <a class="share_colorbox_close" href="#">{'Cancel'| @translate}</a>208 <input class="submit" type="submit" name="add_share" value="{'Add'|translate}"> 209 <a class="share_colorbox_close" href="#">{'Cancel'|translate}</a> 231 210 <input type="hidden" name="key" value="{$UC_TKEY}"> 232 211 </td> 233 212 </tr> 234 213 </table> 235 214 236 215 {if not empty($collection.SHARES)} 237 216 <table class="shares_list"> 238 217 <tr class="header"> 239 <th>{'Share key'| @translate}</th>240 <th>{'Creation date'| @translate}</th>241 <th>{'Password'| @translate}</th>242 <th>{'Expiration date'| @translate}</th>218 <th>{'Share key'|translate}</th> 219 <th>{'Creation date'|translate}</th> 220 <th>{'Password'|translate}</th> 221 <th>{'Expiration date'|translate}</th> 243 222 <th></th> 244 223 </tr> … … 247 226 <td><a href="{$share.url}">{$share.share_key}</a></td> 248 227 <td>{$share.add_date_readable}</td> 249 <td>{if $share.params.password}{'Yes'| @translate}{else}{'No'|@translate}{/if}</td>250 <td>{if $share.params.deadline}{$share.params.deadline_readable}{else}{'No'| @translate}{/if}</td>251 <td><a href="{$share.u_delete}" onClick="return confirm('{'Are you sure?'| @translate}');">228 <td>{if $share.params.password}{'Yes'|translate}{else}{'No'|translate}{/if}</td> 229 <td>{if $share.params.deadline}{$share.params.deadline_readable}{else}{'No'|translate}{/if}</td> 230 <td><a href="{$share.u_delete}" onClick="return confirm('{'Are you sure?'|translate}');"> 252 231 <img src="{$ROOT_URL}{$USER_COLLEC_PATH}template/resources/delete.png" width=16 height=16></a> 253 232 </td> … … 268 247 <table> 269 248 <tr> 270 <td class="title"><label for="sender_name">{'Your name'| @translate}</label></td>249 <td class="title"><label for="sender_name">{'Your name'|translate}</label></td> 271 250 <td> 272 251 <input type="text" name="sender_name" id="sender_name" size="40" value="{$contact.sender_name}"> … … 274 253 </tr> 275 254 <tr> 276 <td class="title"><label for="sender_email">{'Your e-mail'| @translate}</label></td>255 <td class="title"><label for="sender_email">{'Your e-mail'|translate}</label></td> 277 256 <td> 278 257 <input type="text" name="sender_email" id="sender_email" size="40" value="{$contact.sender_email}"> … … 280 259 </tr> 281 260 <tr> 282 <td class="title"><label for="recipient_name">{'Recipient name'| @translate}</label></td>261 <td class="title"><label for="recipient_name">{'Recipient name'|translate}</label></td> 283 262 <td> 284 263 <input type="text" name="recipient_name" id="recipient_name" size="40" value="{$contact.recipient_name}"> … … 286 265 </tr> 287 266 <tr> 288 <td class="title"><label for="recipient_email">{'Recipient e-mail'| @translate}</label></td>267 <td class="title"><label for="recipient_email">{'Recipient e-mail'|translate}</label></td> 289 268 <td> 290 269 <input type="text" name="recipient_email" id="recipient_email" size="40" value="{$contact.recipient_email}"> … … 292 271 </tr> 293 272 <tr> 294 <td class="title"><label for="nb_images">{'Number of images'| @translate}</label></td>273 <td class="title"><label for="nb_images">{'Number of images'|translate}</label></td> 295 274 <td> 296 275 <select name="nb_images"> … … 302 281 </tr> 303 282 <tr> 304 <td class="title"><label for="message">{'Message (optional)'| @translate}</label></td>283 <td class="title"><label for="message">{'Message (optional)'|translate}</label></td> 305 284 <td><textarea name="message" id="message" rows="6" style="width:350px;">{$contact.message}</textarea></td> 306 285 </tr> … … 308 287 <td class="title"> </td> 309 288 <td> 310 <input class="submit" type="submit" name="send_mail" value="{'Send'| @translate}">311 <a class="mail_colorbox_close" href="#">{'Cancel'| @translate}</a>289 <input class="submit" type="submit" name="send_mail" value="{'Send'|translate}"> 290 <a class="mail_colorbox_close" href="#">{'Cancel'|translate}</a> 312 291 <input type="hidden" name="key" value="{$UC_TKEY}"> 313 292 </td> … … 318 297 {/if} 319 298 320 321 {* <!-- collection content -->*} 322 {if $collection.NB_IMAGES > 0} 323 <ul class="thumbnails" id="thumbnails"> 324 {$THUMBNAILS} 325 </ul> 326 {else} 327 <p><i>{'This collection is empty'|@translate}</i></p> 328 {/if} 329 330 {if !empty($navbar)}{include file='navigation_bar.tpl'|@get_extent:'navbar'}{/if} 331 332 {/if} 333 334 {if isset($clear)}<div style="clear: both;"></div> 335 </div>{/if} 336 </div>{* <!-- content --> *} 299 {if empty($THUMBNAILS)} 300 <p><i>{'This collection is empty'|translate}</i></p> 301 {/if} 302 303 {/if} -
extensions/UserCollections/template/collection_view.tpl
r24421 r25678 1 1 {combine_css path=$USER_COLLEC_PATH|cat:'template/style_collections.css'} 2 2 {include file=$USER_COLLEC_ABS_PATH|cat:'template/thumbnails_colorbox.tpl'} 3 4 5 {* <!-- Menubar & titrePage --> *}6 {if $themeconf.name == "stripped" or $themeconf.parent == "stripped"}7 {include file=$USER_COLLEC_ABS_PATH|@cat:'template/themes/stripped.tpl'}8 {assign var="clear" value="true"}9 {elseif $themeconf.name == "simple-grey" or $themeconf.parent == "simple"}10 {include file=$USER_COLLEC_ABS_PATH|@cat:'template/themes/simple.tpl'}11 {assign var="clear" value="true"}12 {else}13 {include file=$USER_COLLEC_ABS_PATH|@cat:'template/themes/default.tpl'}14 {/if}15 16 {if isset($errors) or not empty($infos)}17 {include file='infos_errors.tpl'}18 {/if}19 3 20 4 {if $UC_MODE == 'password'} 21 5 <form action="{$F_LOGIN_ACTION}" method="post" name="login_form" class="properties"> 22 6 <fieldset> 23 <legend>{'Restricted access'| @translate}</legend>7 <legend>{'Restricted access'|translate}</legend> 24 8 25 9 <ul> 26 10 <li> 27 11 <span class="property"> 28 <label for="uc_password">{'Password'| @translate}</label>12 <label for="uc_password">{'Password'|translate}</label> 29 13 </span> 30 14 <input tabindex="1" class="login" type="password" name="uc_password" id="uc_password" size="25" maxlength="25"> … … 34 18 35 19 <p> 36 <input tabindex="2" type="submit" value="{'Submit'| @translate}">20 <input tabindex="2" type="submit" value="{'Submit'|translate}"> 37 21 </p> 38 22 </form> 39 23 40 <script type="text/javascript"><!-- 41 document.login_form.username.focus(); 42 //--></script> 43 44 {else} 45 {if !empty($CONTENT_DESCRIPTION)} 46 <div class="additional_info"> 47 {$CONTENT_DESCRIPTION} 48 </div> 24 <script>document.login_form.username.focus();</script> 49 25 {/if} 50 51 {if !empty($THUMBNAILS)}52 <ul class="thumbnails" id="thumbnails">53 {$THUMBNAILS}54 </ul>55 {/if}56 57 {if !empty($navbar)}{include file='navigation_bar.tpl'|@get_extent:'navbar'}{/if}58 {/if}59 60 {if isset($clear)}<div style="clear: both;"></div>61 </div>{/if}62 </div>{* <!-- content --> *} -
extensions/UserCollections/template/collections_list.tpl
r23551 r25678 2 2 3 3 {footer_script require='jquery'} 4 jQuery( ".new_col").click(function() {ldelim}5 var name = prompt( "{'Collection name:'|@translate}");6 if (name != null) { ldelim}7 $(this).attr("href", $(this).attr("href") +"&name="+ name);4 jQuery('.new_col').click(function() { 5 var name = prompt('{'Collection name:'|translate|escape:javascript}'); 6 if (name != null) { 7 jQuery(this).attr('href', jQuery(this).attr('href') +'&name='+ name); 8 8 return true; 9 } else {ldelim} 9 } 10 else { 10 11 return false; 11 12 } 12 13 }); 13 14 14 jQuery( ".titrePage h2").append(" [{$COLLECTIONS_COUNT}]");15 jQuery('.titrePage h2').append(' [{$COLLECTIONS_COUNT}]'); 15 16 {/footer_script} 16 17 17 {* <!-- Menubar & titrePage --> *} 18 {if $themeconf.name == "stripped" or $themeconf.parent == "stripped"} 19 {include file=$USER_COLLEC_ABS_PATH|@cat:'template/themes/stripped.tpl'} 20 {assign var="clear" value="true"} 21 {elseif $themeconf.name == "simple-grey" or $themeconf.parent == "simple"} 22 {include file=$USER_COLLEC_ABS_PATH|@cat:'template/themes/simple.tpl'} 23 {assign var="clear" value="true"} 24 {else} 25 {include file=$USER_COLLEC_ABS_PATH|@cat:'template/themes/default.tpl'} 18 19 <p style="text-align:left;font-weight:bold;margin:20px;"><a href="{$U_CREATE}" class="new_col">{'Create a new collection'|translate}</a></p> 20 21 {if empty($CATEGORIES)} 22 {'You have no collection'|translate} 26 23 {/if} 27 28 {if isset($errors) or not empty($infos)}29 {include file='infos_errors.tpl'}30 {/if}31 32 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>34 35 {if !empty($CATEGORIES)}36 {$CATEGORIES}37 {else}38 {'You have no collection'|@translate}39 {/if}40 41 {if isset($clear)}<div style="clear: both;"></div>42 </div>{/if}43 </div>{* <!-- content --> *} -
extensions/UserCollections/template/index.php
r20090 r25678 1 1 <?php 2 // +-----------------------------------------------------------------------+3 // | Piwigo - a PHP based photo gallery |4 // +-----------------------------------------------------------------------+5 // | Copyright(C) 2008-2012 Piwigo Team http://piwigo.org |6 // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |7 // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |8 // +-----------------------------------------------------------------------+9 // | This program is free software; you can redistribute it and/or modify |10 // | it under the terms of the GNU General Public License as published by |11 // | the Free Software Foundation |12 // | |13 // | This program is distributed in the hope that it will be useful, but |14 // | WITHOUT ANY WARRANTY; without even the implied warranty of |15 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |16 // | General Public License for more details. |17 // | |18 // | You should have received a copy of the GNU General Public License |19 // | along with this program; if not, write to the Free Software |20 // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |21 // | USA. |22 // +-----------------------------------------------------------------------+23 24 // Recursive call25 2 $url = '../'; 26 3 header( 'Request-URI: '.$url ); … … 28 5 header( 'Location: '.$url ); 29 6 exit(); 30 ?> -
extensions/UserCollections/template/menublock.tpl
r23719 r25678 3 3 <p>{strip} 4 4 {if $block->data.NB_COL == 0} 5 {'You have no collection'| @translate}5 {'You have no collection'|translate} 6 6 {else} 7 7 <a href="{$block->data.U_LIST}">{$pwg->l10n_dec('You have %d collection', 'You have %d collections', $block->data.NB_COL)}</a> … … 12 12 {foreach from=$block->data.collections item=col}{strip} 13 13 <li> 14 <a href="{$col.u_edit}">{$col.name}</a> 14 <a href="{$col.u_edit}">{$col.name}</a> 15 15 <span class="menuInfoCat">[<span class="nbImagesCollec-{$col.id}">{$col.nb_images}</span>]</span> 16 16 </li> 17 17 {/strip}{/foreach} 18 {if isset($block->data.MORE)}<li class="menuInfoCat"><a href="{$block->data.U_LIST}">{'%d more...'| @translate|sprintf:$block->data.MORE}</a></li>{/if}18 {if isset($block->data.MORE)}<li class="menuInfoCat"><a href="{$block->data.U_LIST}">{'%d more...'|translate:$block->data.MORE}</a></li>{/if} 19 19 </ul> 20 20 {/if} -
extensions/UserCollections/template/picture_button.tpl
r23361 r25678 1 1 {include file=$USER_COLLEC_ABS_PATH|cat:'template/thumbnails_css_js.tpl'} 2 2 3 {footer_script require='jquery'} {literal}4 jQuery( ).ready(function() {3 {footer_script require='jquery'} 4 jQuery(function() { 5 5 jQuery("#collectionsLink").click(function() { 6 6 var elt = jQuery("#collectionsDropdown"); … … 17 17 }); 18 18 }); 19 {/ literal}{/footer_script}19 {/footer_script} 20 20 21 <a id="collectionsLink" title="{'Add to collection'| @translate}" class="pwg-state-default pwg-button addCollection" rel="nofollow" data-id="{$current.id}" data-cols="[{$CURRENT_COLLECTIONS}]">21 <a id="collectionsLink" title="{'Add to collection'|translate}" class="pwg-state-default pwg-button addCollection" rel="nofollow" data-id="{$current.id}" data-cols="[{$CURRENT_COLLECTIONS}]"> 22 22 <span class="pwg-icon" style="background:url('{$ROOT_URL}{$USER_COLLEC_PATH}template/resources/image_add.png') center center no-repeat;"></span> 23 <span class="pwg-button-text">{'Add to collection'| @translate}</span>23 <span class="pwg-button-text">{'Add to collection'|translate}</span> 24 24 </a> -
extensions/UserCollections/template/resources/index.php
r20090 r25678 1 1 <?php 2 // +-----------------------------------------------------------------------+3 // | Piwigo - a PHP based photo gallery |4 // +-----------------------------------------------------------------------+5 // | Copyright(C) 2008-2012 Piwigo Team http://piwigo.org |6 // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |7 // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |8 // +-----------------------------------------------------------------------+9 // | This program is free software; you can redistribute it and/or modify |10 // | it under the terms of the GNU General Public License as published by |11 // | the Free Software Foundation |12 // | |13 // | This program is distributed in the hope that it will be useful, but |14 // | WITHOUT ANY WARRANTY; without even the implied warranty of |15 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |16 // | General Public License for more details. |17 // | |18 // | You should have received a copy of the GNU General Public License |19 // | along with this program; if not, write to the Free Software |20 // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |21 // | USA. |22 // +-----------------------------------------------------------------------+23 24 // Recursive call25 2 $url = '../'; 26 3 header( 'Request-URI: '.$url ); … … 28 5 header( 'Location: '.$url ); 29 6 exit(); 30 ?> -
extensions/UserCollections/template/style_collections.css
r24421 r25678 10 10 margin-bottom:10px; 11 11 } 12 12 13 13 #publicURL { 14 14 display:inline-block; … … 77 77 padding:3px; 78 78 } 79 79 80 80 #share_form .url-base { 81 81 font-size:0.9em; … … 104 104 border-bottom:1px solid #111; 105 105 } 106 106 107 107 .shares_list tr.row2 td { background-color:#222; } 108 108 .shares_list tr.row1 td { background-color:#333; } -
extensions/UserCollections/template/text/html/mail.tpl
r25674 r25678 1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 2 <html> 3 <head> 4 <title>Piwigo Mail</title> 5 <meta http-equiv="Content-Type" content="text/html; charset={$CONTENT_ENCODING}"> 6 7 {math assign=tn_width equation="min(x,150)" x=$derivative_params->max_width()} 8 <style type="text/css">{strip}<!-- 9 {$UC_MAIL_CSS} 10 #the_image a {ldelim} 1 {math assign=tn_width equation="min(x,150)" x=$derivative_params->max_width()} 2 <style type="text/css">{strip} 3 #contentTable { 4 width:{math equation="x*4+200" x=$tn_width}px; 5 } 6 7 #the_image { 8 text-align:center; 9 margin:1em 0; 10 } 11 #the_image a { 12 border:none; 13 } 14 #the_image img { 11 15 width:{$tn_width}px; 12 16 height:{$tn_width}px; 13 17 } 14 #the_page {ldelim}15 width:{math equation="x*4+120" x=$tn_width}px;16 }17 -->{/strip}</style>18 </head>19 18 20 <body> 21 <div id="the_page"> 19 #button { 20 margin-top:2em; 21 text-align:center; 22 } 22 23 23 <div id="the_header"> 24 <b>{$MAIL_TITLE}</b> 25 </div> 26 27 <div id="the_content"> 24 #button a { 25 padding:8px 15px; 26 background:#A80D24; 27 color:#fff; 28 border:1px solid #CE2E5A; 29 text-decoration:none; 30 font-size:14px; 31 font-weight:bold; 32 } 33 {/strip}</style> 28 34 29 35 <p> 30 {'Hello <b>%s</b>, %s sent you a photos collection from <a href="%s">%s</a>'| @translate|sprintf:$PARAMS.recipient_name:$PARAMS.sender_name:$GALLERY_URL:$GALLERY_TITLE}36 {'Hello <b>%s</b>, %s sent you a photos collection from <a href="%s">%s</a>'|translate:$PARAMS.recipient_name:$PARAMS.sender_name:$GALLERY_URL:$GALLERY_TITLE} 31 37 </p> 32 38 39 {if isset($THUMBNAILS)} 33 40 <p id="the_image"> 34 {foreach from=$thumbnails item=element} 35 <a href="{$element.URL}"> 36 <span>{$element.NAME|truncate:25:"..."}</span> 37 <img src="{$element.THUMB}" alt="{$element.TN_ALT}"> 41 {foreach from=$THUMBNAILS item=element} 42 <a href="{$element.URL}" title="{$element.NAME|escape:html}"> 43 <img src="{$element.THUMB}" alt="{$element.TN_ALT|escape:html}" class="photo"> 38 44 </a> 39 45 {/foreach} 40 46 </p> 47 {/if} 41 48 42 49 {if $PARAMS.message} 43 <p> 44 <blockquote>{$PARAMS.message}</blockquote> 45 </p> 50 <blockquote>{$PARAMS.message}</blockquote> 46 51 {/if} 47 52 48 <p class="button">49 <a href="{$COL_URL}">{'Click here to view the complete collection'| @translate}</a>53 <p id="button"> 54 <a href="{$COL_URL}">{'Click here to view the complete collection'|translate}</a> 50 55 </p> 51 52 </div>53 54 <div id="the_footer">55 {'Sent by'|@translate} <a href="{$GALLERY_URL}">{$GALLERY_TITLE}</a>56 - {'Powered by'|@translate} <a href="{$PHPWG_URL}" class="Piwigo">Piwigo</a> {$VERSION}57 - User Collections58 </div>59 60 </div>61 </body>62 </html> -
extensions/UserCollections/template/thumbnails_colorbox.tpl
r25674 r25678 1 {if not isset($UC_NO_LIGHTBOX)}2 1 {combine_script id='jquery.colorbox' load='footer' require='jquery' path='themes/default/js/plugins/jquery.colorbox.min.js'} 3 {combine_css path='themes/default/js/plugins/colorbox/style2/colorbox.css'} 4 {/if} 2 {combine_css id='colorbox' path='themes/default/js/plugins/colorbox/style2/colorbox.css'} 5 3 6 {footer_script} 7 jQuery("a.preview-box").colorbox({ldelim} 8 rel: ".preview-box", 9 href: function() {ldelim} return $(this).data('src'); }, 10 title: function() {ldelim} 11 var title = $(this).children("img.thumbnail").attr("alt"); 12 {if $F_ACTION} title+= ' · <a class="addCollection" data-id="'+ $(this).data('id') +'" rel="nofollow">{'Remove from collection'|@translate|escape:javascript}</a>';{/if} 13 title+= ' · <a href="'+ $(this).attr('href') +'" target="_blank">{'jump to photo'|@translate|escape:javascript} →</a>'; 4 {footer_script require='jquery'} 5 jQuery('a.preview-box').colorbox({ 6 rel: '.preview-box', 7 href: function() { 8 return jQuery(this).data('src'); 9 }, 10 title: function() { 11 var title = jQuery(this).children('img.thumbnail').attr("alt"); 12 {if $F_ACTION} title+= ' · <a class="addCollection" data-id="'+ jQuery(this).data('id') +'" rel="nofollow">{'Remove from collection'|translate|escape:javascript}</a>';{/if} 13 title+= ' · <a href="'+ jQuery(this).attr('href') +'" target="_blank">{'jump to photo'|translate|escape:javascript} →</a>'; 14 14 return title; 15 15 } 16 16 }); 17 jQuery(document).on( "click", "#cboxTitle .addCollection", function() {ldelim}17 jQuery(document).on('click', '#cboxTitle .addCollection', function() { 18 18 jQuery.colorbox.close(); 19 jQuery( "#thumbnails a.addCollection[data-id='"+ $(this).data('id')+"']").trigger("click");19 jQuery('#thumbnails a.addCollection[data-id="'+ jQuery(this).data('id') +'"]').trigger('click'); 20 20 return false; 21 21 }); -
extensions/UserCollections/template/thumbnails_css_js.tpl
r25674 r25678 4 4 {if not $UC_IN_EDIT} 5 5 {footer_script require='jquery'} 6 var $cdm = jQuery( "#collectionsDropdown");6 var $cdm = jQuery('#collectionsDropdown'); 7 7 8 8 {if not $IN_PICTURE} 9 $cdm.on( "mouseleave", function() {ldelim}9 $cdm.on('mouseleave', function() { 10 10 $cdm.hide(); 11 11 }); … … 13 13 14 14 // click on "create collection" button 15 $cdm.find( "a.new").on("click", function(event) {ldelim}15 $cdm.find('a.new').on('click', function(e) { 16 16 jQuery(this).hide().next().show().focus(); 17 e vent.stopPropagation();18 return false;17 e.stopPropagation(); 18 e.preventDefault(); 19 19 }); 20 20 21 21 // events on "new collection" input 22 $cdm.find( "input.new").on({ldelim}22 $cdm.find('input.new').on({ 23 23 // ENTER or ESC pressed 24 "keyup": function(event) {ldelim}25 if (e vent.which == 27) {ldelim}24 keyup: function(e) { 25 if (e.which == 27) { 26 26 jQuery(this).val('').hide().prev().show(); 27 27 return; 28 28 } 29 30 if (event.which != 13) return; 31 29 30 if (e.which != 13) { 31 return; 32 } 33 32 34 jQuery(this).hide().prev().show(); 33 35 var name = jQuery(this).val(); 34 36 jQuery(this).val(''); 35 36 if (name == "" || name == null) return; 37 38 jQuery.ajax({ldelim} 39 type: "GET", 40 dataType: "json", 41 url: "{$ROOT_URL}ws.php", 42 data: {ldelim} 43 format: "json", 44 method: "pwg.collections.create", 37 38 if (name == '' || name == null) { 39 return; 40 } 41 42 jQuery.ajax({ 43 type: 'GET', 44 dataType: 'json', 45 url: '{$ROOT_URL}ws.php', 46 data: { 47 format: 'json', 48 method: 'pwg.collections.create', 45 49 name: name, 46 50 }, 47 success: function(data) { ldelim}48 if (data.stat == 'ok') { ldelim}51 success: function(data) { 52 if (data.stat == 'ok') { 49 53 var col = data.result; 50 54 var html = '<span>★</span> <a class="add" data-id="'+ col.id +'">'+ col.name +'</a> ' 51 55 +'<span class="menuInfoCat">[<span class="nbImagesCollec-'+ col.id +'">'+ col.nb_images +'</span>]</span> ' 52 +'<a class="remove" data-id="'+ col.id +'">{'(remove)'| @translate}</a>'56 +'<a class="remove" data-id="'+ col.id +'">{'(remove)'|translate|escape:javscript}</a>' 53 57 +'<br>'; 54 55 $cdm.children( ".switchBoxFooter").before(html);56 $cdm.children( ".noCollecMsg").remove();57 } 58 else { ldelim}58 59 $cdm.children('.switchBoxFooter').before(html); 60 $cdm.children('.noCollecMsg').remove(); 61 } 62 else { 59 63 alert(data.message); 60 64 } 61 65 }, 62 error: function() { ldelim}63 alert( "{'An unknown error occured'|@translate}");66 error: function() { 67 alert('{'An unknown error occured'|translate|escape:javascript}'); 64 68 } 65 69 }); 66 67 return false;68 70 }, 69 71 // prevent click propagation 70 "click": function(event) {ldelim}71 e vent.stopPropagation();72 click: function(e) { 73 e.stopPropagation(); 72 74 } 73 75 }); 74 76 75 77 // add and remove links (delegate for new collections) 76 $cdm.on( "click", ".add, .remove", function() {ldelim}77 var img_id = $cdm.data( "img_id");78 var col_id = jQuery(this).data( "id");79 var method = jQuery(this).hasClass( "add") ? "pwg.collections.addImages" : "pwg.collections.removeImages";80 81 jQuery.ajax({ ldelim}82 type: "GET",83 dataType: "json",84 url: "{$ROOT_URL}ws.php",85 data: { ldelim}86 format: "json",78 $cdm.on('click', '.add, .remove', function(e) { 79 var img_id = $cdm.data('img_id'); 80 var col_id = jQuery(this).data('id'); 81 var method = jQuery(this).hasClass('add') ? 'pwg.collections.addImages' : 'pwg.collections.removeImages'; 82 83 jQuery.ajax({ 84 type: 'GET', 85 dataType: 'json', 86 url: '{$ROOT_URL}ws.php', 87 data: { 88 format: 'json', 87 89 method: method, 88 90 col_id: col_id, 89 91 image_ids: img_id 90 92 }, 91 success: function(data) { ldelim}92 if (data.stat == 'ok') { ldelim}93 success: function(data) { 94 if (data.stat == 'ok') { 93 95 // update col counters 94 jQuery( ".nbImagesCollec-"+col_id).html(data.result.nb_images);95 96 jQuery('.nbImagesCollec-'+ col_id).html(data.result.nb_images); 97 96 98 // update item datas 97 var $target = jQuery( ".addCollection[data-id='"+ img_id +"']");98 var col_ids = $target.data( "cols");99 if (method == "pwg.collections.addImages" && col_ids.indexOf(col_id) == -1)99 var $target = jQuery('.addCollection[data-id="'+ img_id +'"]'); 100 var col_ids = $target.data('cols'); 101 if (method == 'pwg.collections.addImages' && col_ids.indexOf(col_id) == -1) { 100 102 col_ids[ col_ids.length ] = col_id; 101 else if (method == "pwg.collections.removeImages") 103 } 104 else if (method == 'pwg.collections.removeImages') { 102 105 col_ids.splice(col_ids.indexOf(col_id), 1); 103 $target.data("col", col_ids); 104 } 105 else {ldelim} 106 } 107 $target.data('col', col_ids); 108 } 109 else { 106 110 alert(data.message); 107 111 } 108 112 }, 109 error: function() { ldelim}110 alert( "{'An unknown error occured'|@translate}");111 } 112 }); 113 113 error: function() { 114 alert('{'An unknown error occured'|translate|escape:javascript}'); 115 } 116 }); 117 114 118 $cdm.hide(); 115 return false;119 e.preventDefault(); 116 120 }); 117 121 118 122 // main button, open the menu 119 jQuery( ".addCollection").on("click", function(event) {ldelim}120 var img_id = jQuery(this).data( "id");121 var col_ids = jQuery(this).data( "cols");122 123 $cdm.data( "img_id", img_id);124 125 $cdm.children( ".add").each(function() {ldelim}126 if (col_ids.indexOf($(this).data( "id")) != -1) {ldelim}127 $(this).css( "font-weight", "bold").next().next().show();128 } 129 else { ldelim}130 $(this).css( "font-weight", "normal").next().next().hide();131 } 132 }); 133 123 jQuery('.addCollection').on('click', function(e) { 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() { 130 if (col_ids.indexOf($(this).data('id')) != -1) { 131 $(this).css('font-weight', 'bold').next().next().show(); 132 } 133 else { 134 $(this).css('font-weight', 'normal').next().next().hide(); 135 } 136 }); 137 134 138 {if not $IN_PICTURE} 135 $cdm.css({ ldelim}136 "top": event.pageY-5-$(window).scrollTop(),137 "left": Math.min(event.pageX-jQuery(window).scrollLeft()-20, jQuery(window).width()-$cdm.outerWidth(true)-5)139 $cdm.css({ 140 'top': e.pageY-5-$(window).scrollTop(), 141 'left': Math.min(e.pageX-jQuery(window).scrollLeft()-20, jQuery(window).width()-$cdm.outerWidth(true)-5) 138 142 }); 139 143 $cdm.show(); 140 144 {/if} 141 142 return false;145 146 e.preventDefault(); 143 147 }); 144 148 145 149 // try to respect theme colors 146 $cdm.children( ".switchBoxFooter").css("border-top-color", $cdm.children(".switchBoxTitle").css("border-bottom-color"));150 $cdm.children('.switchBoxFooter').css('border-top-color', $cdm.children('.switchBoxTitle').css('border-bottom-color')); 147 151 {/footer_script} 148 152 149 153 <div id="collectionsDropdown" class="switchBox"> 150 <div class="switchBoxTitle">{'Collections'| @translate}</div>151 154 <div class="switchBoxTitle">{'Collections'|translate}</div> 155 152 156 {foreach from=$COLLECTIONS item=col} 153 157 <span>★</span> <a class="add" data-id="{$col.id}">{$col.name}</a> 154 158 <span class="menuInfoCat">[<span class="nbImagesCollec-{$col.id}">{$col.nb_images}</span>]</span> 155 <a class="remove" data-id="{$col.id}">{'(remove)'| @translate}</a>159 <a class="remove" data-id="{$col.id}">{'(remove)'|translate}</a> 156 160 <br> 157 161 {foreachelse} 158 <span class="noCollecMsg">{'You have no collection'| @translate}</span>162 <span class="noCollecMsg">{'You have no collection'|translate}</span> 159 163 {/foreach} 160 164 161 165 <div class="switchBoxFooter"> 162 <span>✚</span> <a class="new">{'Create a new collection'| @translate}</a>163 <input type="text" class="new" placeholder="{'Name'| @translate}" size="25"/>166 <span>✚</span> <a class="new">{'Create a new collection'|translate}</a> 167 <input type="text" class="new" placeholder="{'Name'|translate}" size="25"/> 164 168 </div> 165 169 </div> … … 168 172 {else} 169 173 {footer_script require='jquery'} 170 jQuery( ".addCollection").on("click", function(event) {ldelim}174 jQuery('.addCollection').on('click', function(e) { 171 175 var $trigger = jQuery(this); 172 var img_id = jQuery(this).data( "id");176 var img_id = jQuery(this).data('id'); 173 177 var col_id = {$collection.ID}; 174 175 jQuery.ajax({ ldelim}176 type: "GET",177 dataType: "json",178 url: "{$ROOT_URL}ws.php",179 data: { ldelim}180 format: "json",181 method: "pwg.collections.removeImages",178 179 jQuery.ajax({ 180 type: 'GET', 181 dataType: 'json', 182 url: '{$ROOT_URL}ws.php', 183 data: { 184 format: 'json', 185 method: 'pwg.collections.removeImages', 182 186 col_id: col_id, 183 187 image_ids: img_id 184 188 }, 185 success: function(data) { ldelim}186 if (data.stat == 'ok') { ldelim}187 $trigger.parent( "li").hide("fast", function() {ldelim}189 success: function(data) { 190 if (data.stat == 'ok') { 191 $trigger.parent('li').hide('fast', function() { 188 192 jQuery(this).remove(); 189 if (typeof GThumb != "undefined") GThumb.build(); 193 if (typeof GThumb != 'undefined') { 194 GThumb.build(); 195 } 190 196 }); 191 192 jQuery(".nbImagesCollec-"+col_id).html(data.result.nb_images); 193 if (typeof batchdown_count != 'undefined') batchdown_count = data.result.nb_images; 194 } 195 else {ldelim} 197 198 jQuery('.nbImagesCollec-'+ col_id).html(data.result.nb_images); 199 if (typeof batchdown_count != 'undefined') { 200 batchdown_count = data.result.nb_images; 201 } 202 } 203 else { 196 204 alert(data.message); 197 205 } 198 206 }, 199 error: function() {ldelim} 200 alert("{'An unknown error occured'|@translate}"); 201 } 202 }); 203 204 event.stopPropagation(); 205 event.preventDefault(); 206 return false; 207 error: function() { 208 alert('{'An unknown error occured'|translate|escape:javascript}'); 209 } 210 }); 211 212 e.stopPropagation(); 213 e.preventDefault(); 207 214 }); 208 215 {/footer_script}
Note: See TracChangeset
for help on using the changeset viewer.