diff options
author | rvelices <rv-github@modusoptimus.com> | 2006-03-22 01:01:47 +0000 |
---|---|---|
committer | rvelices <rv-github@modusoptimus.com> | 2006-03-22 01:01:47 +0000 |
commit | 0971ce48d217b7cc8081ae70c4b041ab23fdf29c (patch) | |
tree | 841bd14e9c2a19c207fb8479b1a086112795d04a /include/section_init.inc.php | |
parent | 3609c224c74f50a9049524ebedc996ddd1187108 (diff) |
URL rewriting: capable of fully working with urls without ?
URL rewriting: works with image file instead of image id (change
make_picture_url to generate urls with file name instead of image id)
URL rewriting: completely works with category/best_rated and
picture/best_rated/534 (change 'category.php?' to 'category' in make_index_url
and 'picture.php?' to 'picture' in make_picture_url to see it)
fix: picture category display in upper bar
fix: function rate_picture variables and use of the new user type
fix: caddie icon appears now on category page
fix: admin element_set sql query was using storage_category_id column
(column has moved to #image_categories)
fix: replaced some old $_GET[xxx] with $page[xxx]
fix: pictures have metadata url (use ? parameter - might change later)
git-svn-id: http://piwigo.org/svn/trunk@1092 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r-- | include/section_init.inc.php | 63 |
1 files changed, 48 insertions, 15 deletions
diff --git a/include/section_init.inc.php b/include/section_init.inc.php index d225e7871..80f853d17 100644 --- a/include/section_init.inc.php +++ b/include/section_init.inc.php @@ -6,9 +6,9 @@ // +-----------------------------------------------------------------------+ // | branch : BSF (Best So Far) // | file : $RCSfile$ -// | last update : $Date: 2006-01-27 02:11:43 +0100 (ven, 27 jan 2006) $ -// | last modifier : $Author: rvelices $ -// | revision : $Revision: 1014 $ +// | last update : $Date$ +// | last modifier : $Author$ +// | revision : $Revision$ // +-----------------------------------------------------------------------+ // | This program is free software; you can redistribute it and/or modify | // | it under the terms of the GNU General Public License as published by | @@ -84,17 +84,35 @@ $tokens = explode( $next_token = 0; if (basename($_SERVER['SCRIPT_NAME']) == 'picture.php') -{ - - // the first token must be the numeric identifier of the picture - preg_match('/(\d+)/', $tokens[$next_token], $matches); - if (!isset($matches[1])) +{ // the last token must be the identifier for the picture + $token = array_pop($tokens); + if ( is_numeric($token) ) { - die('Fatal: picture identifier is missing'); + $page['image_id'] = $token; + } + else + { + preg_match('/^(\d+-)?((.*)[_\.]html?)?$/', $token, $matches); + if ( isset($matches[1]) and is_numeric($matches[1]) ) + { + $page['image_id'] = $matches[1]; + if ( !empty($matches[3]) ) + { + $page['image_file'] = $matches[3]; + } + } + else + { + if ( !empty($matches[3]) ) + { + $page['image_file'] = $matches[3]; + } + else + { + die('Fatal: picture identifier is missing'); + } + } } - $page['image_id'] = $matches[1]; - - $next_token++; } if (0 === strpos($tokens[$next_token], 'cat')) @@ -273,11 +291,11 @@ if ('categories' == $page['section']) 'cat_id_uppercat' => $result['id_uppercat'], 'uppercats' => $result['uppercats'], - 'title' => get_cat_display_name($result['name'], '', false), + 'title' => get_cat_display_name($result['name'], null, false), ) ); - if (!isset($_GET['calendar'])) + if (!isset($page['chronology_field'])) { $query = ' SELECT image_id @@ -321,7 +339,7 @@ else SELECT DISTINCT(id) FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id - WHERE '.get_sql_search_clause($_GET['search']).' + WHERE '.get_sql_search_clause($page['search']).' AND '.$forbidden.' '.$conf['order_by'].' ;'; @@ -489,4 +507,19 @@ if (isset($page['chronology_field'])) initialize_calendar(); } +if (basename($_SERVER['SCRIPT_NAME']) == 'picture.php' + and !isset($page['image_id']) ) +{ + $query = ' +SELECT id,file + FROM '.IMAGES_TABLE .' + WHERE id IN ('.implode(',',$page['items']).') + AND file LIKE "' . $page['image_file'] . '.%" ESCAPE "|"' +; + $result = pwg_query($query); + if (mysql_num_rows($result)>0) + { + list($page['image_id'], $page['image_file']) = mysql_fetch_row($result); + } +} ?>
\ No newline at end of file |