mirror of
https://github.com/Piwigo/Piwigo.git
synced 2025-04-28 12:19:57 +03:00
improvement: urls for tags can contain now only the tag or the id and tag
improvement: urls for category can be now id and category names (instead of only id) improvement: added 2 indexes (#image_tag.tag_id and #tags.url_name) improvement: identification, register, search pages automatically set focus on first form input improvement: focus, nofocus css class now valid for all forms fix: category comment is tag stripped in category_subcats.inc.php (otherwise issues with html/scripts inside category comment) git-svn-id: http://piwigo.org/svn/trunk@1131 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
parent
b9a37cd6f0
commit
d700a59172
15 changed files with 246 additions and 101 deletions
|
@ -276,6 +276,7 @@ foreach ($categories as $category)
|
|||
'U_JUMPTO' => make_index_url(
|
||||
array(
|
||||
'category' => $category['id'],
|
||||
'cat_name' => $category['name'],
|
||||
)
|
||||
),
|
||||
|
||||
|
|
|
@ -244,6 +244,7 @@ $template->assign_vars(
|
|||
'U_JUMPTO' => make_index_url(
|
||||
array(
|
||||
'category' => $category['id'],
|
||||
'cat_name' => $category['name'],
|
||||
)
|
||||
),
|
||||
|
||||
|
|
|
@ -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'],
|
||||
)
|
||||
);
|
||||
|
@ -143,6 +149,7 @@ SELECT id, path, tn_ext
|
|||
'URL' => make_index_url(
|
||||
array(
|
||||
'category' => $item['category'],
|
||||
'cat_name' => $item['name'],
|
||||
)
|
||||
),
|
||||
'NAME' => $item['name'],
|
||||
|
|
|
@ -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 |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
|
|
@ -290,8 +290,8 @@ 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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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.= ' ';
|
||||
|
||||
|
|
58
install/db/22-database.php
Normal file
58
install/db/22-database.php
Normal file
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | PhpWebGallery - a PHP based picture gallery |
|
||||
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
|
||||
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | branch : BSF (Best So Far)
|
||||
// | file : $RCSfile$
|
||||
// | last update : $Date: 2005-09-21 00:04:57 +0200 (mer, 21 sep 2005) $
|
||||
// | last modifier : $Author: plg $
|
||||
// | revision : $Revision: 870 $
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | 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 |
|
||||
// | the Free Software Foundation |
|
||||
// | |
|
||||
// | This program is distributed in the hope that it will be useful, but |
|
||||
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||
// | General Public License for more details. |
|
||||
// | |
|
||||
// | You should have received a copy of the GNU General Public License |
|
||||
// | along with this program; if not, write to the Free Software |
|
||||
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||
// | USA. |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
if (!defined('PHPWG_ROOT_PATH'))
|
||||
{
|
||||
die('Hacking attempt!');
|
||||
}
|
||||
|
||||
$upgrade_description = 'add index on #tags.url_name and #image_tag.tag_id ';
|
||||
|
||||
|
||||
|
||||
$query = '
|
||||
ALTER TABLE '.PREFIX_TABLE.'tags ADD INDEX `tags_i1`(`url_name`);
|
||||
;';
|
||||
pwg_query($query);
|
||||
|
||||
|
||||
$query = '
|
||||
ALTER TABLE '.PREFIX_TABLE.'image_tag ADD INDEX `image_tag_i1`(`tag_id`);
|
||||
;';
|
||||
pwg_query($query);
|
||||
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | End notification |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
echo
|
||||
"\n"
|
||||
.'Tables '.PREFIX_TABLE.'tags and '.PREFIX_TABLE.'image_tag updated'."\n"
|
||||
;
|
||||
echo $upgrade_description;
|
||||
?>
|
|
@ -140,7 +140,8 @@ DROP TABLE IF EXISTS `phpwebgallery_image_tag`;
|
|||
CREATE TABLE `phpwebgallery_image_tag` (
|
||||
`image_id` mediumint(8) unsigned NOT NULL default '0',
|
||||
`tag_id` smallint(5) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (`image_id`,`tag_id`)
|
||||
PRIMARY KEY (`image_id`,`tag_id`),
|
||||
KEY `image_tag_i1` (`tag_id`)
|
||||
) TYPE=MyISAM;
|
||||
|
||||
--
|
||||
|
@ -233,7 +234,8 @@ CREATE TABLE `phpwebgallery_tags` (
|
|||
`id` smallint(5) unsigned NOT NULL auto_increment,
|
||||
`name` varchar(255) binary NOT NULL default '',
|
||||
`url_name` varchar(255) binary NOT NULL default '',
|
||||
PRIMARY KEY (`id`)
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `tags_i1` (`url_name`)
|
||||
) TYPE=MyISAM;
|
||||
|
||||
--
|
||||
|
|
|
@ -188,11 +188,11 @@ FORM.properties SPAN.property {
|
|||
padding: 0 0.5em 0 0;
|
||||
}
|
||||
|
||||
FORM.properties .focus {
|
||||
FORM .focus {
|
||||
background-color: whitesmoke;
|
||||
}
|
||||
|
||||
FORM.properties .nofocus {
|
||||
FORM .nofocus {
|
||||
background-color: lightgrey; /* must be the same as input background-color */
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
</div>
|
||||
<!-- END errors -->
|
||||
|
||||
<form action="{F_LOGIN_ACTION}" method="post" class="properties">
|
||||
<form action="{F_LOGIN_ACTION}" method="post" name="login_form" class="properties">
|
||||
<fieldset>
|
||||
<legend>{lang:Connection settings}</legend>
|
||||
|
||||
|
@ -55,6 +55,10 @@
|
|||
<p><input tabindex="4" type="submit" name="login" value="{L_LOGIN}"></p>
|
||||
</form>
|
||||
|
||||
<script><!--
|
||||
document.login_form.username.focus();
|
||||
//--></script>
|
||||
|
||||
<p>
|
||||
<a href="{U_REGISTER}"><img src="{themeconf:icon_dir}/register.png" class="button" alt=""> {L_REGISTER}</a>
|
||||
<a href="{U_LOST_PASSWORD}"><img src="{themeconf:icon_dir}/lost_password.png" class="button" alt=""> {lang:Forgot your password?}</a>
|
||||
|
|
|
@ -89,12 +89,12 @@
|
|||
|
||||
<label>
|
||||
{lang:Username}
|
||||
<input type="text" name="username" size="15" value="">
|
||||
<input type="text" name="username" size="15" value="" onfocus="this.className='focus';" onblur="this.className='nofocus';">
|
||||
</label>
|
||||
|
||||
<label>
|
||||
{lang:password}
|
||||
<input type="password" name="password" size="15">
|
||||
<input type="password" name="password" size="15" onfocus="this.className='focus';" onblur="this.className='nofocus';">
|
||||
</label>
|
||||
|
||||
<!-- BEGIN remember_me -->
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
</div>
|
||||
<!-- END errors -->
|
||||
|
||||
<form method="post" action="{F_ACTION}" class="properties">
|
||||
<form method="post" action="{F_ACTION}" class="properties" name="register_form">
|
||||
<fieldset>
|
||||
<legend>{lang:Enter your personnal informations}</legend>
|
||||
|
||||
|
@ -63,5 +63,9 @@
|
|||
|
||||
</form>
|
||||
|
||||
<script><!--
|
||||
document.register_form.login.focus();
|
||||
//--></script>
|
||||
|
||||
</div> <!-- content -->
|
||||
</div> <!-- registerPage -->
|
||||
|
|
|
@ -146,4 +146,8 @@
|
|||
</table>
|
||||
</form>
|
||||
|
||||
<script><!--
|
||||
document.post.search_allwords.focus();
|
||||
//--></script>
|
||||
|
||||
</div> <!-- content -->
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue