aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--include/category_subcats.inc.php19
-rw-r--r--include/config_default.inc.php25
-rw-r--r--include/functions.inc.php6
-rw-r--r--include/functions_html.inc.php29
-rw-r--r--include/functions_url.inc.php34
-rw-r--r--include/section_init.inc.php86
6 files changed, 135 insertions, 64 deletions
diff --git a/include/category_subcats.inc.php b/include/category_subcats.inc.php
index 57fe73cec..8deef5711 100644
--- a/include/category_subcats.inc.php
+++ b/include/category_subcats.inc.php
@@ -28,7 +28,7 @@
/**
* This file is included by the main page to show thumbnails for a category
* that have only subcategories
- *
+ *
*/
$query = '
@@ -90,6 +90,12 @@ SELECT representative_picture_id
}
}
+ $comment = null;
+ if ( isset($row['comment']) )
+ {
+ $comment = strip_tags( $row['comment'] );
+ }
+
if (isset($image_id))
{
array_push(
@@ -99,7 +105,7 @@ SELECT representative_picture_id
'picture' => $image_id,
'name' => $row['name'],
'date_last' => @$row['date_last'],
- 'comment' => @$row['comment'],
+ 'comment' => $comment,
'nb_images' => $row['nb_images'],
)
);
@@ -111,7 +117,7 @@ SELECT representative_picture_id
if (count($cat_thumbnails) > 0)
{
$images = array();
-
+
foreach ($cat_thumbnails as $item)
{
$images[$item['picture']] = '';
@@ -129,7 +135,7 @@ SELECT id, path, tn_ext
}
$template->assign_block_vars('categories', array());
-
+
foreach ($cat_thumbnails as $item)
{
$template->assign_block_vars(
@@ -139,10 +145,11 @@ SELECT id, path, tn_ext
'ALT' => $item['name'],
'TITLE' => $lang['hint_category'],
'ICON' => get_icon(@$item['date_last']),
-
+
'URL' => make_index_url(
array(
'category' => $item['category'],
+ 'cat_name' => $item['name'],
)
),
'NAME' => $item['name'],
@@ -152,4 +159,4 @@ SELECT id, path, tn_ext
);
}
}
-?>
+?> \ No newline at end of file
diff --git a/include/config_default.inc.php b/include/config_default.inc.php
index 72363d85d..655b13d76 100644
--- a/include/config_default.inc.php
+++ b/include/config_default.inc.php
@@ -424,20 +424,29 @@ $conf['history_admin'] = false;
// (depends on the server AcceptPathInfo directive configuration)
$conf['question_mark_in_urls'] = true;
-// picture_url_style : one of 'id' 'id-file' or 'file'. 'id-file' or 'file'
-// mean that the file name (without extension will appear in the url).
-// Note that one aditionnal sql query will occur if 'file' is choosen.
-// Note that you might experience navigation issues if you choose 'file'
-// and your file names are not unique
-$conf['picture_url_style'] = 'id';
-
-
// php_extension_in_urls : if true, the urls generated for picture and
// category will not contain the .php extension. This will work only if
// .htaccess defines Options +MultiViews parameter or url rewriting rules
// are active.
$conf['php_extension_in_urls'] = true;
+// category_url_style : one of 'id' (default) or 'id-name'. 'id-name'
+// means that an simplified ascii represntation of the category name will
+// appear in the url
+$conf['category_url_style'] = 'id';
+
+// picture_url_style : one of 'id' (default), 'id-file' or 'file'. 'id-file'
+// or 'file' mean that the file name (without extension will appear in the
+// url). Note that one aditionnal sql query will occur if 'file' is choosen.
+// Note that you might experience navigation issues if you choose 'file'
+// and your file names are not unique
+$conf['picture_url_style'] = 'id';
+
+// tag_url_style : one of 'id-tag' (default), 'id' or 'tag'.
+// Note that if you choose 'tag' and the url (ascii) representation of your
+// tags is not unique, all tags with the same url representation will be shown
+$conf['tag_url_style'] = 'id-tag';
+
// +-----------------------------------------------------------------------+
// | tags |
// +-----------------------------------------------------------------------+
diff --git a/include/functions.inc.php b/include/functions.inc.php
index d8b86743f..5a1245c4b 100644
--- a/include/functions.inc.php
+++ b/include/functions.inc.php
@@ -290,10 +290,10 @@ function str2url($str)
$str = str_replace('¼', 'OE', $str);
$str = str_replace('½', 'oe', $str);
- $str = preg_replace('/[^a-z0-9_\s\'\:\/\[\]-]/','',strtolower($str));
- $str = preg_replace('/[\s\'\:\/\[\]-]+/',' ',trim($str));
+ $str = preg_replace('/[^a-z0-9_\s\'\:\/\[\],-]/','',strtolower($str));
+ $str = preg_replace('/[\s\'\:\/\[\],-]+/',' ',trim($str));
$res = str_replace(' ','_',$str);
-
+
return $res;
}
diff --git a/include/functions_html.inc.php b/include/functions_html.inc.php
index 13c3dc206..b217f01d9 100644
--- a/include/functions_html.inc.php
+++ b/include/functions_html.inc.php
@@ -278,7 +278,14 @@ function get_cat_display_name($cat_informations,
elseif ($url == '')
{
$output.= '<a class=""';
- $output.= ' href="'.make_index_url( array('category'=>$id) ).'">';
+ $output.= ' href="'
+ .make_index_url(
+ array(
+ 'category'=>$id,
+ 'cat_name'=>$name
+ )
+ )
+ .'">';
$output.= $name.'</a>';
}
else
@@ -353,7 +360,14 @@ SELECT id,name
{
$output.= '
<a class=""
- href="'.make_index_url( array('category'=>$category_id) ).'">'.$name.'</a>';
+ href="'
+ .make_index_url(
+ array(
+ 'category'=>$category_id,
+ 'cat_name'=>$name
+ )
+ )
+ .'">'.$name.'</a>';
}
else
{
@@ -423,7 +437,12 @@ function get_html_menu_category($categories)
}
$menu.= '>';
- $url = make_index_url(array('category' => $category['id']));
+ $url = make_index_url(
+ array(
+ 'category'=>$category['id'],
+ 'cat_name'=>$category['name']
+ )
+ );
$menu.= "\n".'<a href="'.$url.'"';
if ($page_cat != 0
@@ -509,7 +528,7 @@ function get_html_tag_selection(
)
{
global $conf;
-
+
$output = '<ul class="tagSelection">';
foreach ($tags as $tag)
{
@@ -524,7 +543,7 @@ function get_html_tag_selection(
{
$output.= ' checked="checked"';
}
-
+
$output.=
' />'
.' '.$tag['name']
diff --git a/include/functions_url.inc.php b/include/functions_url.inc.php
index a50f789c8..63316d4d5 100644
--- a/include/functions_url.inc.php
+++ b/include/functions_url.inc.php
@@ -256,6 +256,7 @@ function add_well_known_params_in_url($url, $params)
*/
function make_section_in_URL($params)
{
+ global $conf;
$section_string = '';
$section_of = array(
@@ -289,6 +290,19 @@ function make_section_in_URL($params)
else
{
$section_string.= '/category/'.$params['category'];
+ if ($conf['category_url_style']=='id-name' and isset($params['cat_name']) )
+ {
+ if ( is_string($params['cat_name']) )
+ {
+ $section_string.= '-'.str2url($params['cat_name']);
+ }
+ elseif ( is_array( $params['cat_name'] ) and
+ isset( $params['cat_name'][$params['category']] ) )
+ {
+ $section_string.= '-'
+ .str2url($params['cat_name'][$params['category']]);
+ }
+ }
}
break;
@@ -304,11 +318,23 @@ function make_section_in_URL($params)
foreach ($params['tags'] as $tag)
{
- $section_string.= '/'.$tag['id'];
-
- if (isset($tag['url_name']))
+ switch ( $conf['tag_url_style'] )
{
- $section_string.= '-'.$tag['url_name'];
+ case 'id':
+ $section_string.= '/'.$tag['id'];
+ break;
+ case 'tag':
+ if (isset($tag['url_name']) and !is_numeric($tag['url_name']) )
+ {
+ $section_string.= '/'.$tag['url_name'];
+ break;
+ }
+ default:
+ $section_string.= '/'.$tag['id'];
+ if (isset($tag['url_name']))
+ {
+ $section_string.= '-'.$tag['url_name'];
+ }
}
}
diff --git a/include/section_init.inc.php b/include/section_init.inc.php
index e22979e69..c29686e6f 100644
--- a/include/section_init.inc.php
+++ b/include/section_init.inc.php
@@ -70,7 +70,7 @@ else
}
$page['root_path'] = PHPWG_ROOT_PATH;
}
-//phpinfo();
+
// deleting first "/" if displayed
$tokens = explode(
'/',
@@ -147,33 +147,58 @@ else if (0 === strpos($tokens[$next_token], 'tag'))
$next_token++;
$i = $next_token;
+ $requested_tag_ids = array();
+ $requested_tag_url_names = array();
+
while (isset($tokens[$i]))
{
- preg_match('/^(\d+)(?:-(.*))?/', $tokens[$i], $matches);
- if (!isset($matches[1]))
+ if ( preg_match('/^(created-|posted-|start-(\d)+)/', $tokens[$i]) )
+ break;
+
+ if ( preg_match('/^(\d+)(?:-(.*))?/', $tokens[$i], $matches) )
{
- if (0 == count($page['tags']))
- {
- die('Fatal: at least one tag required');
- }
- else
- {
- break;
- }
+ array_push($requested_tag_ids, $matches[1]);
+ }
+ else
+ {
+ array_push($requested_tag_url_names, "'".$tokens[$i]."'");
}
-
- array_push(
- $page['tags'],
- array(
- 'id' => $matches[1],
- 'url_name' => isset($matches[2]) ? $matches[2] : '',
- )
- );
-
$i++;
}
-
$next_token = $i;
+
+ if ( empty($requested_tag_ids) && empty($requested_tag_url_names) )
+ {
+ die('Fatal: at least one tag required');
+ }
+ // tag infos
+ $query = '
+SELECT name, url_name, id
+ FROM '.TAGS_TABLE.'
+ WHERE ';
+ if ( !empty($requested_tag_ids) )
+ {
+ $query.= 'id IN ('.implode(',', $requested_tag_ids ).')';
+ }
+ if ( !empty($requested_tag_url_names) )
+ {
+ if ( !empty($requested_tag_ids) )
+ {
+ $query.= ' OR ';
+ }
+ $query.= 'url_name IN ('.implode(',', $requested_tag_url_names ).')';
+ }
+ $result = pwg_query($query);
+ $tag_infos = array();
+ while ($row = mysql_fetch_array($result))
+ {
+ $tag_infos[ $row['id'] ] = $row;
+ array_push($page['tags'], $row );//we loose given tag order; is it important?
+ }
+ if ( empty($page['tags']) )
+ {
+ die('Fatal: no existing tag');
+ }
}
else if (0 === strpos($tokens[$next_token], 'fav'))
{
@@ -239,7 +264,7 @@ while (isset($tokens[$i]))
$page['start'] = $matches[1];
}
- if (preg_match('/^posted|created/', $tokens[$i] ))
+ if (preg_match('/^(posted|created)/', $tokens[$i] ))
{
$chronology_tokens = explode('-', $tokens[$i] );
@@ -359,7 +384,7 @@ else
// permissions depends on category, so to only keep images that are
// reachable to the connected user, we need to check category
// associations
- if (!empty($user['forbidden_categories']) and !empty($items) )
+ if (!empty($items) )
{
$query = '
SELECT image_id
@@ -373,21 +398,6 @@ SELECT image_id
);
}
- // tag names
- $query = '
-SELECT name, url_name, id
- FROM '.TAGS_TABLE.'
- WHERE id IN ('.implode(',', $page['tag_ids']).')
-;';
- $result = pwg_query($query);
- $tag_infos = array();
-
- while ($row = mysql_fetch_array($result))
- {
- $tag_infos[ $row['id'] ]['name'] = $row['name'];
- $tag_infos[ $row['id'] ]['url_name'] = $row['url_name'];
- }
-
$title = count($page['tags']) > 1 ? l10n('Tags') : l10n('Tag');
$title.= ' ';