From 12af0a00794d4624c4804eeef74fd207f474b002 Mon Sep 17 00:00:00 2001 From: rvelices Date: Thu, 28 Jun 2007 02:16:03 +0000 Subject: feature 713: allow permalinks to contain the slash ("/") character git-svn-id: http://piwigo.org/svn/trunk@2047 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/functions_url.inc.php | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) (limited to 'include/functions_url.inc.php') diff --git a/include/functions_url.inc.php b/include/functions_url.inc.php index 3c0138136..9e81a72cf 100644 --- a/include/functions_url.inc.php +++ b/include/functions_url.inc.php @@ -457,29 +457,44 @@ function parse_section_url( $tokens, &$next_token) $next_token++; } else - { - if ( strpos($tokens[$next_token], 'created-')!==0 - and strpos($tokens[$next_token], 'posted-')!==0 + {// try a permalink + $maybe_permalinks = array(); + $current_token = $next_token; + while ( isset($tokens[$current_token]) + and strpos($tokens[$current_token], 'created-')!==0 + and strpos($tokens[$current_token], 'posted-')!==0 and strpos($tokens[$next_token], 'start-')!==0 - and $tokens[$next_token] != 'flat') - {// try a permalink - $cat_id = get_cat_id_from_permalink($tokens[$next_token]); - if ( !isset($cat_id) ) - {//try old permalink - $cat_id = get_cat_id_from_old_permalink($tokens[$next_token], true); + and $tokens[$current_token] != 'flat') + { + if (empty($maybe_permalinks)) + { + array_push($maybe_permalinks, $tokens[$current_token]); + } + else + { + array_push($maybe_permalinks, + $maybe_permalinks[count($maybe_permalinks)-1] + . '/' . $tokens[$current_token] + ); } + $current_token++; + } + + if ( count($maybe_permalinks) ) + { + $cat_id = get_cat_id_from_permalinks($maybe_permalinks, $perma_index); if ( isset($cat_id) ) { + $next_token += $perma_index+1; $page['category'] = $cat_id; - $page['hit_by']['cat_permalink'] = $tokens[$next_token]; + $page['hit_by']['cat_permalink'] = $maybe_permalinks[$perma_index]; } else { page_not_found('Permalink for album not found'); } - $next_token++; } - } + } } if (isset($page['category'])) -- cgit v1.2.3