mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-07-03 16:32:22 +02:00
feature 169: each category can have its own image order
git-svn-id: http://piwigo.org/svn/trunk@1500 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
@@ -80,6 +80,39 @@ if (isset($_POST['submit']))
|
||||
);
|
||||
}
|
||||
|
||||
$image_order = '';
|
||||
if ( !isset($_POST['image_order_default']) )
|
||||
{
|
||||
for ($i=1; $i<=3; $i++)
|
||||
{
|
||||
if ( !empty($_POST['order_field_'.$i]) )
|
||||
{
|
||||
if (! empty($image_order) )
|
||||
{
|
||||
$image_order .= ',';
|
||||
}
|
||||
$image_order .= $_POST['order_field_'.$i];
|
||||
if ($_POST['order_direction_'.$i]=='DESC')
|
||||
{
|
||||
$image_order .= ' DESC';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$image_order = empty($image_order) ? 'null' : "'$image_order'";
|
||||
$query = '
|
||||
UPDATE '.CATEGORIES_TABLE.' SET image_order='.$image_order.'
|
||||
WHERE ';
|
||||
if (isset($_POST['image_order_subcats']))
|
||||
{
|
||||
$query .= 'uppercats REGEXP \'(^|,)'.$_GET['cat_id'].'(,|$)\'';
|
||||
}
|
||||
else
|
||||
{
|
||||
$query .= 'id='.$_GET['cat_id'].';';
|
||||
}
|
||||
pwg_query($query);
|
||||
|
||||
array_push($page['infos'], $lang['editcat_confirm']);
|
||||
}
|
||||
else if (isset($_POST['set_random_representant']))
|
||||
@@ -226,6 +259,9 @@ $template->assign_vars(
|
||||
$commentable => 'checked="checked"',
|
||||
$uploadable => 'checked="checked"',
|
||||
|
||||
'IMG_ORDER_DEFAULT' => empty($category['image_order']) ?
|
||||
'checked="checked"' : '',
|
||||
|
||||
'L_EDIT_NAME' => $lang['name'],
|
||||
'L_STORAGE' => $lang['storage'],
|
||||
'L_REMOTE_SITE' => $lang['remote_site'],
|
||||
@@ -277,6 +313,70 @@ if ($category['nb_images'] > 0)
|
||||
);
|
||||
}
|
||||
|
||||
// image order management
|
||||
$matches = array();
|
||||
if ( !empty( $category['image_order'] ) )
|
||||
{
|
||||
preg_match_all('/([a-z_]+) *(?:(asc|desc)(?:ending)?)? *(?:, *|$)/i',
|
||||
$category['image_order'], $matches);
|
||||
}
|
||||
|
||||
$sort_fields = array(
|
||||
'' => '',
|
||||
'date_creation' => l10n('Creation date'),
|
||||
'date_available' => l10n('Post date'),
|
||||
'average_rate' => l10n('Average rate'),
|
||||
'hit' => l10n('most_visited_cat'),
|
||||
'file' => l10n('File name'),
|
||||
'id' => 'Id',
|
||||
);
|
||||
|
||||
for ($i=0; $i<3; $i++) // 3 fields
|
||||
{
|
||||
$template->assign_block_vars('image_order', array('NUMBER'=>$i+1) );
|
||||
foreach ($sort_fields as $sort_field => $name)
|
||||
{
|
||||
$selected='';
|
||||
if ( isset($matches[1][$i]) and $matches[1][$i]==$sort_field )
|
||||
{
|
||||
$selected='selected="selected"';
|
||||
}
|
||||
elseif ( empty($sort_field) )
|
||||
{
|
||||
$selected='selected="selected"';
|
||||
}
|
||||
|
||||
$template->assign_block_vars('image_order.field',
|
||||
array(
|
||||
'SELECTED' => $selected,
|
||||
'VALUE' => $sort_field,
|
||||
'OPTION' => $name
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$template->assign_block_vars('image_order.order',
|
||||
array(
|
||||
'SELECTED' =>
|
||||
( empty($matches[2][$i]) or strcasecmp($matches[2][$i],'ASC')==0 )
|
||||
? 'selected="selected"' : '',
|
||||
'VALUE' => 'ASC',
|
||||
'OPTION' => 'Ascending'
|
||||
)
|
||||
);
|
||||
|
||||
$template->assign_block_vars('image_order.order',
|
||||
array(
|
||||
'SELECTED' =>
|
||||
( isset($matches[2][$i]) and strcasecmp($matches[2][$i],'DESC')==0 )
|
||||
? 'selected="selected"' : '',
|
||||
'VALUE' => 'DESC',
|
||||
'OPTION' => 'Descending'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// representant management
|
||||
if ($category['nb_images'] > 0
|
||||
or !empty($category['representative_picture_id']))
|
||||
|
||||
@@ -110,7 +110,8 @@ function get_cat_info( $id )
|
||||
{
|
||||
$infos = array('nb_images','id_uppercat','comment','site_id'
|
||||
,'dir','date_last','uploadable','status','visible'
|
||||
,'representative_picture_id','uppercats','commentable');
|
||||
,'representative_picture_id','uppercats','commentable'
|
||||
,'image_order');
|
||||
|
||||
$query = '
|
||||
SELECT '.implode(',', $infos).'
|
||||
|
||||
@@ -342,6 +342,11 @@ if ('categories' == $page['section'])
|
||||
|
||||
if (!isset($page['chronology_field']))
|
||||
{
|
||||
if ( !empty($result['image_order']) and !isset($page['super_order_by']) )
|
||||
{
|
||||
$conf[ 'order_by' ] = ' ORDER BY '.$result['image_order'];
|
||||
}
|
||||
|
||||
$query = '
|
||||
SELECT image_id
|
||||
FROM '.IMAGE_CATEGORY_TABLE.'
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | PhpWebGallery - a PHP based picture gallery |
|
||||
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
|
||||
// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | branch : BSF (Best So Far)
|
||||
// | file : $RCSfile$
|
||||
// | last update : $Date: 2006-07-23 14:17:00 +0200 (dim, 23 jui 2006) $
|
||||
// | last modifier : $Author: nikrou $
|
||||
// | revision : $Revision: 1492 $
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | 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 column #categories.image_order';
|
||||
|
||||
$query = '
|
||||
ALTER TABLE '.PREFIX_TABLE.'categories
|
||||
ADD COLUMN image_order VARCHAR(128) DEFAULT NULL
|
||||
;';
|
||||
pwg_query($query);
|
||||
|
||||
echo
|
||||
"\n"
|
||||
. $upgrade_description
|
||||
."\n"
|
||||
;
|
||||
?>
|
||||
@@ -37,6 +37,7 @@ CREATE TABLE `phpwebgallery_categories` (
|
||||
`uppercats` varchar(255) NOT NULL default '',
|
||||
`commentable` enum('true','false') NOT NULL default 'true',
|
||||
`global_rank` varchar(255) default NULL,
|
||||
`image_order` varchar(128) default NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `categories_i2` (`id_uppercat`)
|
||||
) TYPE=MyISAM;
|
||||
|
||||
@@ -45,6 +45,7 @@ $lang['Add a user'] = 'Add a user';
|
||||
$lang['Add group'] = 'Add group';
|
||||
$lang['Add selected elements to caddie'] = 'Add selected elements to caddie';
|
||||
$lang['Add'] = 'Add';
|
||||
$lang['Apply to subcategories'] = 'Apply to subcategories';
|
||||
$lang['Are you sure?'] = 'Are you sure?';
|
||||
$lang['Associated'] = 'Associated';
|
||||
$lang['Association to categories'] = 'Association to categories';
|
||||
@@ -165,6 +166,7 @@ $lang['Tag selection'] = 'Tag selection';
|
||||
$lang['Take selected elements out of caddie'] = 'Take selected elements out of caddie';
|
||||
$lang['The %d following tags were deleted : %s'] = 'The %d following tags were deleted : %s';
|
||||
$lang['Unable to check for upgrade since allow_url_fopen is disabled.'] = 'Unable to check for upgrade since allow_url_fopen is disabled.';
|
||||
$lang['Use default sort order']='Use the default image sort order (defined in the configuration file)';
|
||||
$lang['User comments validation'] = 'User comments validation';
|
||||
$lang['Users'] = 'Users';
|
||||
$lang['Validate All'] = 'Validate All';
|
||||
|
||||
@@ -45,6 +45,7 @@ $lang['Add a user'] = 'Ajouter un utilisateur';
|
||||
$lang['Add group'] = 'Ajouter un groupe';
|
||||
$lang['Add selected elements to caddie'] = 'Ajouter les éléments sélectionnés au panier';
|
||||
$lang['Add'] = 'Ajouter';
|
||||
$lang['Apply to subcategories'] = 'Appliquer au sous-catégories';
|
||||
$lang['Are you sure?'] = 'Etes-vous sur?';
|
||||
$lang['Associated'] = 'Associée à';
|
||||
$lang['Association to categories'] = 'Association aux catégories';
|
||||
@@ -165,6 +166,7 @@ $lang['Tag selection'] = 'S
|
||||
$lang['Take selected elements out of caddie'] = 'Sortir les éléments sélectionnés du panier';
|
||||
$lang['The %d following tags were deleted : %s'] = 'Les %d tags suivants ont été supprimés : %s';
|
||||
$lang['Unable to check for upgrade since allow_url_fopen is disabled.'] = 'Impossible de connaître la dernière version cat la fonction allow_url_fopen est désactivée.';
|
||||
$lang['Use default sort order']='Utiliser l\'ordre de tri des images par défaut (défini dans le fichier de configuration)';
|
||||
$lang['User comments validation'] = 'Validation des commentaires utilisateur';
|
||||
$lang['Users'] = 'Utilisateurs';
|
||||
$lang['Validate All'] = 'Tout valider';
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
<!-- BEGIN parent_option -->
|
||||
<option class="{move.parent_option.CLASS}" {move.parent_option.SELECTED} value="{move.parent_option.VALUE}">{move.parent_option.OPTION}</option>
|
||||
<!-- END parent_option -->
|
||||
</select>
|
||||
</select>
|
||||
</fieldset>
|
||||
<!-- END move -->
|
||||
|
||||
@@ -102,6 +102,28 @@
|
||||
</table>
|
||||
</fieldset>
|
||||
|
||||
<fieldset id="image_order">
|
||||
<legend>{lang:Sort order}</legend>
|
||||
<input type="checkbox" name="image_order_default" id="image_order_default" {IMG_ORDER_DEFAULT} />
|
||||
<label for="image_order_default">{lang:Use default sort order}</label>
|
||||
<br/>
|
||||
<input type="checkbox" name="image_order_subcats" id="image_order_subcats" />
|
||||
<label for="image_order_subcats">{lang:Apply to subcategories}</label>
|
||||
<br/>
|
||||
<!-- BEGIN image_order -->
|
||||
<select name="order_field_{image_order.NUMBER}">
|
||||
<!-- BEGIN field -->
|
||||
<option value="{image_order.field.VALUE}" {image_order.field.SELECTED}>{image_order.field.OPTION}</option>
|
||||
<!-- END field -->
|
||||
</select>
|
||||
<select name="order_direction_{image_order.NUMBER}">
|
||||
<!-- BEGIN order -->
|
||||
<option value="{image_order.order.VALUE}" {image_order.order.SELECTED}>{image_order.order.OPTION}</option>
|
||||
<!-- END order -->
|
||||
</select><br/>
|
||||
<!-- END image_order -->
|
||||
</fieldset>
|
||||
|
||||
<p style="text-align:center;">
|
||||
<input type="submit" value="{L_SUBMIT}" name="submit" {TAG_INPUT_ENABLED}/>
|
||||
<input type="reset" value="{lang:Reset}" name="reset" />
|
||||
@@ -122,7 +144,7 @@
|
||||
<!-- END random -->
|
||||
</td>
|
||||
<td>
|
||||
<!-- BEGIN set_random -->
|
||||
<!-- BEGIN set_random -->
|
||||
<p><input type="submit" name="set_random_representant" value="{L_SET_RANDOM_REPRESENTANT}" {TAG_INPUT_ENABLED}/></p>
|
||||
<!-- END set_random -->
|
||||
|
||||
@@ -138,7 +160,7 @@
|
||||
</form>
|
||||
|
||||
<form action="{F_ACTION}" method="POST" id="links">
|
||||
|
||||
|
||||
<fieldset id="linkAllNew">
|
||||
<legend>{lang:Link all category elements to a new category}</legend>
|
||||
|
||||
@@ -163,7 +185,7 @@
|
||||
<p>
|
||||
<input type="submit" value="{lang:Submit}" name="submitAdd" {TAG_INPUT_ENABLED}/>
|
||||
<input type="reset" value="{lang:Reset}" name="reset" />
|
||||
</p>
|
||||
</p>
|
||||
|
||||
</fieldset>
|
||||
|
||||
@@ -186,7 +208,7 @@
|
||||
<p>
|
||||
<input type="submit" value="{lang:Submit}" name="submitDestinations" {TAG_INPUT_ENABLED}/>
|
||||
<input type="reset" value="{lang:Reset}" name="reset" />
|
||||
</p>
|
||||
</p>
|
||||
|
||||
</fieldset>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user