Changeset 1866
- Timestamp:
- Feb 28, 2007, 4:07:12 AM (17 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin.php
r1865 r1866 5 5 // | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net | 6 6 // +-----------------------------------------------------------------------+ 7 // | branch : BSF (Best So Far)8 7 // | file : $Id$ 9 8 // | last update : $Date$ … … 108 107 'U_USERS'=> $link_start.'user_list', 109 108 'U_GROUPS'=> $link_start.'group_list', 109 'U_PERMALINKS'=> $link_start.'permalinks', 110 110 'U_RETURN'=> make_index_url(), 111 111 'U_ADMIN'=> PHPWG_ROOT_PATH.'admin.php', 112 'L_ADMIN' => $lang['admin'],113 'L_ADMIN_HINT' => $lang['hint_admin']114 112 ) 115 113 ); -
trunk/admin/cat_list.php
r1861 r1866 139 139 140 140 // +-----------------------------------------------------------------------+ 141 // | Cache management |142 // +-----------------------------------------------------------------------+143 $query = '144 SELECT *145 FROM '.CATEGORIES_TABLE;146 if (!isset($_GET['parent_id']))147 {148 $query.= '149 WHERE id_uppercat IS NULL';150 }151 else152 {153 $query.= '154 WHERE id_uppercat = '.$_GET['parent_id'];155 }156 $query.= '157 ORDER BY rank ASC158 ;';159 $result = pwg_query($query);160 while ($row = mysql_fetch_assoc($result))161 {162 $categories[$row['rank']] = $row;163 $categories[$row['rank']]['nb_subcats'] = 0;164 }165 166 // +-----------------------------------------------------------------------+167 141 // | Navigation path | 168 142 // +-----------------------------------------------------------------------+ … … 210 184 211 185 $query = ' 212 SELECT id, name, dir, rank, nb_images, status186 SELECT id, name, permalink, dir, rank, nb_images, status 213 187 FROM '.CATEGORIES_TABLE; 214 188 if (!isset($_GET['parent_id'])) -
trunk/admin/include/functions.php
r1863 r1866 119 119 '.wordwrap(implode(', ', $ids), 80, "\n").') 120 120 ;'; 121 pwg_query($query); 122 123 $query=' 124 DELETE FROM '.OLD_PERMALINKS_TABLE.' 125 WHERE cat_id IN ('.implode(',',$cat_ids).')'; 121 126 pwg_query($query); 122 127 -
trunk/admin/plugin.php
r1731 r1866 50 50 51 51 $plugin_id = $sections[0]; 52 $check_db_plugin = get_db_plugins('active', $plugin_id ); 53 if (empty($check_db_plugin)) 52 if ( !isset($pwg_loaded_plugins[$plugin_id]) ) 54 53 { 55 54 die('Invalid URL - plugin '.$plugin_id.' not active'); -
trunk/comments.php
r1861 r1866 370 370 371 371 // retrieving category informations 372 $categories = array();373 372 $query = ' 374 SELECT id, name, uppercats373 SELECT id, name, permalink, uppercats 375 374 FROM '.CATEGORIES_TABLE.' 376 375 WHERE id IN ('.implode(',', $category_ids).') 377 376 ;'; 378 $result = pwg_query($query); 379 while ($row = mysql_fetch_assoc($result)) 380 { 381 $categories[$row['id']] = $row; 382 } 377 $categories = hash_from_query($query, 'id'); 383 378 384 379 foreach ($comments as $comment) -
trunk/include/category_cats.inc.php
r1861 r1866 36 36 $query = ' 37 37 SELECT 38 id, name, representative_picture_id, comment, nb_images, uppercats,38 id, name, permalink, representative_picture_id, comment, nb_images, uppercats, 39 39 date_last, max_date_last, count_images, count_categories, global_rank 40 40 FROM '.CATEGORIES_TABLE.' INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.' … … 58 58 $query = ' 59 59 SELECT 60 id, name, representative_picture_id, comment, nb_images,60 id, name, permalink, representative_picture_id, comment, nb_images, 61 61 date_last, max_date_last, count_images, count_categories 62 62 FROM '.CATEGORIES_TABLE.' INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.' -
trunk/include/constants.php
r1727 r1866 5 5 // | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net | 6 6 // +-----------------------------------------------------------------------+ 7 // | branch : BSF (Best So Far) 8 // | file : $RCSfile$ 7 // | file : $Id$ 9 8 // | last update : $Date$ 10 9 // | last modifier : $Author$ … … 76 75 define('PLUGINS_TABLE', $prefixeTable.'plugins'); 77 76 define('WEB_SERVICES_ACCESS_TABLE', $prefixeTable.'ws_access'); 77 define('OLD_PERMALINKS_TABLE', $prefixeTable.'old_permalinks'); 78 78 ?> -
trunk/include/functions.inc.php
r1864 r1866 1176 1176 1177 1177 /** 1178 * creates an hashed based on a query, this function is a very common 1179 * pattern used here. The key is given as parameter, the value is an associative 1180 * array. 1181 * 1182 * @param string $query 1183 * @param string $keyname 1184 * @return array 1185 */ 1186 function hash_from_query($query, $keyname) 1187 { 1188 $array = array(); 1189 $result = pwg_query($query); 1190 while ($row = mysql_fetch_assoc($result)) 1191 { 1192 $array[ $row[$keyname] ] = $row; 1193 } 1194 return $array; 1195 } 1196 1197 /** 1178 1198 * Return basename of the current script 1179 1199 * Lower case convertion is applied on return value -
trunk/include/functions_category.inc.php
r1861 r1866 60 60 // From CATEGORIES_TABLE 61 61 $query.= ' 62 name, id, nb_images, global_rank,';62 id, name, permalink, nb_images, global_rank,'; 63 63 // From USER_CACHE_CATEGORIES_TABLE 64 64 $query.= ' … … 160 160 } 161 161 162 $names = array(); 163 $query = ' 164 SELECT id, name 165 FROM '.CATEGORIES_TABLE.' 166 WHERE id IN ('.$cat['uppercats'].') 167 ;'; 168 $result = pwg_query($query); 169 while($row = mysql_fetch_assoc($result)) 170 { 171 $names[$row['id']] = $row; 172 } 173 174 // category names must be in the same order than uppercats list 175 $cat['upper_names'] = array(); 176 foreach (explode(',', $cat['uppercats']) as $cat_id) 177 { 178 $cat['upper_names'][$cat_id] = $names[$cat_id]; 179 } 180 162 $upper_ids = explode(',', $cat['uppercats']); 163 if ( count($upper_ids)==1 ) 164 {// no need to make a query for level 1 165 $cat['upper_names'] = array( 166 array( 167 'id' => $cat['id'], 168 'name' => $cat['name'], 169 'permalink' => $cat['permalink'], 170 ) 171 ); 172 } 173 else 174 { 175 $names = array(); 176 $query = ' 177 SELECT id, name, permalink 178 FROM '.CATEGORIES_TABLE.' 179 WHERE id IN ('.$cat['uppercats'].') 180 ;'; 181 $names = hash_from_query($query, 'id'); 182 183 // category names must be in the same order than uppercats list 184 $cat['upper_names'] = array(); 185 foreach ($upper_ids as $cat_id) 186 { 187 array_push( $cat['upper_names'], $names[$cat_id]); 188 } 189 } 181 190 return $cat; 182 191 } … … 309 318 if (!empty($result)) 310 319 { 311 while ($row = mysql_fetch_a rray($result))320 while ($row = mysql_fetch_assoc($result)) 312 321 { 313 322 array_push($categories, $row); … … 356 365 } 357 366 367 /** returns a category id that corresponds to the given permalink (or null) 368 * @param string permalink 369 */ 370 function get_cat_id_from_permalink( $permalink ) 371 { 372 $query =' 373 SELECT id FROM '.CATEGORIES_TABLE.' 374 WHERE permalink="'.$permalink.'"'; 375 $ids = array_from_query($query, 'id'); 376 if (!empty($ids)) 377 { 378 return $ids[0]; 379 } 380 return null; 381 } 382 383 /** returns a category id that has used before this permalink (or null) 384 * @param string permalink 385 * @param boolean is_hit if true update the usage counters on the old permalinks 386 */ 387 function get_cat_id_from_old_permalink($permalink, $is_hit) 388 { 389 $query=' 390 SELECT c.id 391 FROM '.OLD_PERMALINKS_TABLE.' op INNER JOIN '.CATEGORIES_TABLE.' c 392 ON op.cat_id=c.id 393 WHERE op.permalink="'.$permalink.'" 394 LIMIT 1'; 395 $result = pwg_query($query); 396 $cat_id = null; 397 if ( mysql_num_rows($result) ) 398 list( $cat_id ) = mysql_fetch_array($result); 399 400 if ( isset($cat_id) and $is_hit ) 401 { 402 $query=' 403 UPDATE '.OLD_PERMALINKS_TABLE.' SET last_hit=NOW(), hit=hit+1 404 WHERE permalink="'.$permalink.'" AND cat_id='.$cat_id.' 405 LIMIT 1'; 406 pwg_query($query); 407 } 408 return $cat_id; 409 } 410 358 411 function global_rank_compare($a, $b) 359 412 { -
trunk/include/functions_html.inc.php
r1861 r1866 235 235 * 236 236 * categories string returned contains categories as given in the input 237 * array $cat_informations. $cat_informations array must be an a ssociation238 * of {category_id => array( id, name) }. If url input parameter is null,237 * array $cat_informations. $cat_informations array must be an array 238 * of array( id=>?, name=>?, permalink=>?). If url input parameter is null, 239 239 * returns only the categories name without links. 240 240 * … … 252 252 $output = ''; 253 253 $is_first = true; 254 foreach ($cat_informations as $ id => $cat)254 foreach ($cat_informations as $cat) 255 255 { 256 256 is_array($cat) or trigger_error( 257 'get_cat_display_name wrong type for cat '.$id, E_USER_WARNING257 'get_cat_display_name wrong type for category ', E_USER_WARNING 258 258 ); 259 259 if ($is_first) … … 283 283 else 284 284 { 285 $output.= '<a href="'.PHPWG_ROOT_PATH.$url.$ id.'">';285 $output.= '<a href="'.PHPWG_ROOT_PATH.$url.$cat['id'].'">'; 286 286 $output.= $cat['name'].'</a>'; 287 287 } … … 319 319 { 320 320 $query = ' 321 SELECT id, name 321 SELECT id, name, permalink 322 322 FROM '.CATEGORIES_TABLE.' 323 323 ;'; 324 $result = pwg_query($query); 325 while ($row = mysql_fetch_assoc($result)) 326 { 327 $cache['cat_names'][$row['id']] = $row; 328 } 324 $cache['cat_names'] = hash_from_query($query, 'id'); 329 325 } 330 326 -
trunk/include/functions_url.inc.php
r1861 r1866 337 337 ); 338 338 339 $section_string.= '/category/'.$params['category']['id']; 340 if ( $conf['category_url_style']=='id-name' ) 339 array_key_exists('permalink', $params['category']) or trigger_error( 340 'make_section_in_url category permalink not set', E_USER_WARNING 341 ); 342 343 $section_string.= '/category/'; 344 if ( empty($params['category']['permalink']) ) 341 345 { 342 $section_string.= '-'.str2url($params['category']['name']); 346 $section_string.= $params['category']['id']; 347 if ( $conf['category_url_style']=='id-name' ) 348 { 349 $section_string.= '-'.str2url($params['category']['name']); 350 } 351 } 352 else 353 { 354 $section_string.= $params['category']['permalink']; 343 355 } 344 356 } -
trunk/include/section_init.inc.php
r1861 r1866 108 108 $page['image_file'] = $matches[2]; 109 109 } 110 111 110 } 112 111 else … … 129 128 $next_token++; 130 129 131 if (isset($tokens[$next_token]) 132 and preg_match('/^(\d+)/', $tokens[$next_token], $matches)) 133 { 134 $page['category'] = $matches[1]; 135 $next_token++; 130 if (isset($tokens[$next_token]) ) 131 { 132 if (preg_match('/^(\d+)(?:-(.+))?$/', $tokens[$next_token], $matches)) 133 { 134 if ( isset($matches[2]) ) 135 $page['hit_by']['cat_url_name'] = $matches[2]; 136 $page['category'] = $matches[1]; 137 $next_token++; 138 } 139 else 140 { 141 if ( strpos($tokens[$next_token], 'created-')!==0 142 and strpos($tokens[$next_token], 'posted-')!==0 143 and $tokens[$next_token] != 'flat') 144 {// try a permalink 145 $cat_id = get_cat_id_from_permalink($tokens[$next_token]); 146 if ( !isset($cat_id) ) 147 {//try old permalink 148 $cat_id = get_cat_id_from_old_permalink($tokens[$next_token], true); 149 } 150 if ( isset($cat_id) ) 151 { 152 $page['category'] = $cat_id; 153 $page['hit_by']['cat_permalink'] = $tokens[$next_token]; 154 } 155 else 156 { 157 page_not_found('Permalink for album not found'); 158 } 159 unset($cat_id); 160 $next_token++; 161 } 162 } 136 163 } 137 164 } … … 691 718 } 692 719 720 // see if we need a redirect because of a permalink 721 if ( 'categories'==$page['section'] and isset($page['category']) ) 722 { 723 $need_redirect=false; 724 if ( empty($page['category']['permalink']) ) 725 { 726 if ( $conf['category_url_style'] == 'id-name' and 727 @$page['hit_by']['cat_url_name'] !== str2url($page['category']['name']) ) 728 { 729 $need_redirect=true; 730 } 731 } 732 else 733 { 734 if ( $page['category']['permalink'] !== @$page['hit_by']['cat_permalink'] ) 735 { 736 $need_redirect=true; 737 } 738 } 739 740 if ($need_redirect) 741 { 742 $redirect_url = ( script_basename()=='picture' 743 ? duplicate_picture_url() 744 : duplicate_index_url() 745 ); 746 if (!headers_sent()) 747 { // this is a permanent redirection 748 set_status_header(302); 749 redirect_http( $redirect_url ); 750 } 751 redirect( $redirect_url ); 752 } 753 unset( $need_redirect, $page['hit_by'] ); 754 } 755 693 756 trigger_action('loc_end_section_init'); 694 757 ?> -
trunk/include/ws_functions.inc.php
r1861 r1866 320 320 321 321 $query = ' 322 SELECT id, name, image_order322 SELECT id, name, permalink, image_order 323 323 FROM '.CATEGORIES_TABLE.' 324 324 WHERE '. implode(' … … 466 466 467 467 $query = ' 468 SELECT id, name, uppercats, global_rank,468 SELECT id, name, permalink, uppercats, global_rank, 469 469 nb_images, count_images AS total_nb_images, 470 470 date_last, max_date_last, count_categories AS nb_categories … … 597 597 //-------------------------------------------------------- related categories 598 598 $query = ' 599 SELECT id, name, uppercats, global_rank, commentable599 SELECT id, name, permalink, uppercats, global_rank, commentable 600 600 FROM '.IMAGE_CATEGORY_TABLE.' 601 601 INNER JOIN '.CATEGORIES_TABLE.' ON category_id = id -
trunk/install/phpwebgallery_structure.sql
r1844 r1866 39 39 `global_rank` varchar(255) default NULL, 40 40 `image_order` varchar(128) default NULL, 41 PRIMARY KEY (`id`), 42 KEY `categories_i2` (`id_uppercat`) 41 `permalink` VARCHAR(64) default NULL, 42 PRIMARY KEY (`id`), 43 KEY `categories_i2` (`id_uppercat`), 44 UNIQUE KEY `categories_i3` (`permalink`) 43 45 ) TYPE=MyISAM; 44 46 … … 204 206 205 207 -- 208 -- Table structure for table `phpwebgallery_old_permalinks` 209 -- 210 211 DROP TABLE IF EXISTS `phpwebgallery_old_permalinks`; 212 CREATE TABLE `phpwebgallery_old_permalinks` ( 213 `cat_id` smallint(5) unsigned NOT NULL, 214 `permalink` VARCHAR(64) NOT NULL, 215 `date_deleted` datetime NOT NULL, 216 `last_hit` datetime default NULL, 217 `hit` int(10) unsigned NOT NULL default '0', 218 PRIMARY KEY (`permalink`) 219 ) TYPE=MyISAM; 220 221 -- 206 222 -- Table structure for table `phpwebgallery_plugins` 207 223 -- -
trunk/language/en_UK.iso-8859-1/admin.lang.php
r1853 r1866 5 5 // | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net | 6 6 // +-----------------------------------------------------------------------+ 7 // | branch : BSF (Best So Far) 8 // | file : $RCSfile$ 7 // | file : $Id$ 9 8 // | last update : $Date$ 10 9 // | last modifier : $Author$ … … 44 43 $lang['Actions'] = 'Actions'; 45 44 $lang['Activate'] = 'Activate'; 45 $lang['Add/delete a permalink'] = 'Add/delete a permalink'; 46 46 $lang['Add a tag'] = 'Add a tag'; 47 47 $lang['Add a user'] = 'Add a user'; … … 138 138 $lang['Parent category'] = 'Parent category'; 139 139 $lang['Path'] = 'Path'; 140 $lang['Permalink'] = 'Permalink'; 141 $lang['Permalink_%s_histo_used_by_%s'] = 'Permalink %s has been previously used by category %s. Delete from the permalink history first'; 142 $lang['Permalink_name_rule'] = 'The permalink name must be composed of a-z, A-Z, 0-9, "-" or "_". It must not be numeric or start with number followed by "-"'; 143 $lang['Permalink %s is already used by category %s'] = 'Permalink %s is already used by category %s'; 144 $lang['Permalink history'] = 'Permalink history'; 145 $lang['Permalinks'] = 'Permalinks'; 140 146 $lang['Permission denied'] = 'Permission denied'; 141 147 $lang['Permission granted thanks to a group'] = 'Permission granted thanks to a group'; … … 160 166 $lang['Represents'] = 'Represents'; 161 167 $lang['Save order'] = 'Save order'; 168 $lang['Save to permalink history'] = 'Save to permalink history'; 162 169 $lang['Select at least one category'] = 'Select at least one category'; 163 170 $lang['Select at least one picture'] = 'Select at least one picture'; -
trunk/language/fr_FR.iso-8859-1/admin.lang.php
r1853 r1866 5 5 // | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net | 6 6 // +-----------------------------------------------------------------------+ 7 // | branch : BSF (Best So Far) 8 // | file : $RCSfile$ 7 // | file : $Id$ 9 8 // | last update : $Date$ 10 9 // | last modifier : $Author$ … … 44 43 $lang['Actions'] = 'Actions'; 45 44 $lang['Activate'] = 'Activer'; 45 $lang['Add/delete a permalink'] = 'Ajouter/effacer un lien permanent'; 46 46 $lang['Add a tag'] = 'Ajouter un tag'; 47 47 $lang['Add a user'] = 'Ajouter un utilisateur'; … … 138 138 $lang['Parent category'] = 'Catégorie parente'; 139 139 $lang['Path'] = 'Chemin'; 140 $lang['Permalink'] = 'Lien permanent'; 141 $lang['Permalink_%s_histo_used_by_%s'] = 'Le lien permanent %s a été utilisé précédemment par la catégorie %s. Veuillez l\'effacer de l\'historique des liens permanents'; 142 $lang['Permalink_name_rule'] = 'Le lien permanent ne doit contenir des caractères que parmi "a-zA-Z0-9", "-" ou "_". Il ne doit pas être numérique ou commencer par un nombre suivi par "-"'; 143 $lang['Permalink %s is already used by category %s'] = 'Le lien permanent %s est dèja utilisé par la catégorie %s'; 144 $lang['Permalink history'] = 'Historique des liens permanents'; 145 $lang['Permalinks'] = 'Liens permanents'; 140 146 $lang['Permission denied'] = 'Accès interdit'; 141 147 $lang['Permission granted thanks to a group'] = 'Accès autorisé grâce à l\'appartenance aux groupes'; … … 160 166 $lang['Represents'] = 'Représente'; 161 167 $lang['Save order'] = 'Sauvegarder l\'ordre'; 168 $lang['Save to permalink history'] = 'Sauvegarder dans l\'historique des liens permanents'; 162 169 $lang['Select at least one category'] = 'Sélectionner au moins une catégorie'; 163 170 $lang['Select at least one picture'] = 'Sélectionner au moins une image'; -
trunk/template/yoga/admin.tpl
r1865 r1866 7 7 <li><a href="{U_RETURN}">{lang:home}</a></li> 8 8 <li><a href="{U_FAQ}">{lang:instructions}</a></li> 9 <li><a href="{U_ADMIN}" title="{ L_ADMIN_HINT}">{L_ADMIN}</a></li>9 <li><a href="{U_ADMIN}" title="{lang:hint_admin}">{lang:admin}</a></li> 10 10 </ul> 11 11 </dd> … … 35 35 <li><a href="{representative.URL}">{lang:Representative}</a></li> 36 36 <!-- END representative --> 37 <li><a href="{U_PERMALINKS}">{lang:Permalinks}</a></li> 37 38 </ul> 38 39 </dd> -
trunk/template/yoga/default-layout.css
r1776 r1866 81 81 margin-bottom: 2em; 82 82 } 83 84 FORM FIELDSET P { 85 margin-top: 1em; 86 margin-bottom: 0; 87 } 88 83 89 .small { 84 90 font-size: 80%;
Note: See TracChangeset
for help on using the changeset viewer.