aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--admin/configuration.php5
-rw-r--r--admin/themes/default/template/configuration.tpl7
-rw-r--r--include/picture_comment.inc.php28
-rw-r--r--install/config.sql1
-rw-r--r--install/db/115-database.php38
-rw-r--r--language/en_UK/admin.lang.php1
-rw-r--r--language/fr_CA/admin.lang.php1
-rw-r--r--language/fr_FR/admin.lang.php1
-rw-r--r--themes/default/template/picture.tpl4
9 files changed, 84 insertions, 2 deletions
diff --git a/admin/configuration.php b/admin/configuration.php
index b7a06aa74..6e4bb0311 100644
--- a/admin/configuration.php
+++ b/admin/configuration.php
@@ -419,7 +419,10 @@ switch ($page['section'])
'comments',
array(
'NB_COMMENTS_PAGE'=>$conf['nb_comment_page'],
- ));
+ 'comments_order'=>$conf['comments_order'],
+ 'comments_order_options'=> $sort_directions
+ )
+ );
foreach ($comments_checkboxes as $checkbox)
{
diff --git a/admin/themes/default/template/configuration.tpl b/admin/themes/default/template/configuration.tpl
index 521ad40c0..232b00356 100644
--- a/admin/themes/default/template/configuration.tpl
+++ b/admin/themes/default/template/configuration.tpl
@@ -203,6 +203,13 @@ jQuery(document).ready(function () {
</span>
<input type="text" size="3" maxlength="4" name="nb_comment_page" id="nb_comment_page" value="{$comments.NB_COMMENTS_PAGE}">
</li>
+
+ <li>
+ <span class="property">{'Default comments order'|@translate}</span>
+ <select name="comments_order">
+ {html_options options=$comments.comments_order_options selected=$comments.comments_order}
+ </select>
+ </li>
<li>
<label>
diff --git a/include/picture_comment.inc.php b/include/picture_comment.inc.php
index 70e2c7e95..b35bf2285 100644
--- a/include/picture_comment.inc.php
+++ b/include/picture_comment.inc.php
@@ -125,6 +125,32 @@ SELECT
if ($row['nb_comments'] > 0)
{
+ // comments order (get, session, conf)
+ if (!empty($_GET['comments_order']))
+ {
+ if (in_array(strtoupper($_GET['comments_order']), array('ASC', 'DESC')))
+ {
+ $comments_order = $_GET['comments_order'];
+ pwg_set_session_var('comments_order', $comments_order);
+ }
+ else
+ {
+ $comments_order = $conf['comments_order'];
+ }
+ }
+ else if (pwg_get_session_var('comments_order') !== null)
+ {
+ $comments_order = pwg_get_session_var('comments_order');
+ }
+ else
+ {
+ $comments_order = $conf['comments_order'];
+ }
+ $template->assign(array(
+ 'COMMENTS_ORDER_URL' => duplicate_picture_url().'&amp;comments_order='.($comments_order == 'ASC' ? 'DESC' : 'ASC'),
+ 'COMMENTS_ORDER_TITLE' => $comments_order == 'ASC' ? l10n('ascending') : l10n('descending'),
+ ));
+
$query = '
SELECT
com.id,
@@ -140,7 +166,7 @@ SELECT
ON u.'.$conf['user_fields']['id'].' = author_id
WHERE image_id = '.$page['image_id'].'
'.$validated_clause.'
- ORDER BY date ASC
+ ORDER BY date '.$comments_order.'
LIMIT '.$conf['nb_comment_page'].' OFFSET '.$page['start'].'
;';
$result = pwg_query( $query );
diff --git a/install/config.sql b/install/config.sql
index a973bb107..e121fb2cd 100644
--- a/install/config.sql
+++ b/install/config.sql
@@ -5,6 +5,7 @@ INSERT INTO piwigo_config (param,value,comment) VALUES ('nb_comment_page','10','
INSERT INTO piwigo_config (param,value,comment) VALUES ('log','true','keep an history of visits on your website');
INSERT INTO piwigo_config (param,value,comment) VALUES ('comments_validation','false','administrators validate users comments before becoming visible');
INSERT INTO piwigo_config (param,value,comment) VALUES ('comments_forall','false','even guest not registered can post comments');
+INSERT INTO piwigo_config (param,value,comment) VALUES ('comments_order','ASC','comments order on picture page and cie');
INSERT INTO piwigo_config (param,value,comment) VALUES ('user_can_delete_comment','false','administrators can allow user delete their own comments');
INSERT INTO piwigo_config (param,value,comment) VALUES ('user_can_edit_comment','false','administrators can allow user edit their own comments');
INSERT INTO piwigo_config (param,value,comment) VALUES ('email_admin_on_comment_edition','false','Send an email to the administrators when a comment is modified');
diff --git a/install/db/115-database.php b/install/db/115-database.php
new file mode 100644
index 000000000..c9d043c09
--- /dev/null
+++ b/install/db/115-database.php
@@ -0,0 +1,38 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | Piwigo - a PHP based photo gallery |
+// +-----------------------------------------------------------------------+
+// | Copyright(C) 2008-2011 Piwigo Team http://piwigo.org |
+// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
+// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
+// +-----------------------------------------------------------------------+
+// | 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 = 'New setting for comments order on picture page';
+
+conf_update_param('comments_order', 'ASC');
+
+echo
+"\n"
+. $upgrade_description
+."\n"
+;
+?> \ No newline at end of file
diff --git a/language/en_UK/admin.lang.php b/language/en_UK/admin.lang.php
index a76c27488..6797d3e18 100644
--- a/language/en_UK/admin.lang.php
+++ b/language/en_UK/admin.lang.php
@@ -223,6 +223,7 @@ $lang['Date'] = "Date";
$lang['Day'] = "Day";
$lang['Deactivate all'] = "Deactivate all";
$lang['Deactivate'] = "Deactivate";
+$lang['Default comments order'] = 'Default comments order';
$lang['Default display'] = "Default display";
$lang['Default photos order'] = "Default photos order";
$lang['Default user cannot be deleted'] = "Default user cannot be deleted";
diff --git a/language/fr_CA/admin.lang.php b/language/fr_CA/admin.lang.php
index 1e1ed3daf..8bfb8efbf 100644
--- a/language/fr_CA/admin.lang.php
+++ b/language/fr_CA/admin.lang.php
@@ -846,5 +846,6 @@ $lang['An error has occured during extract. Please check files permissions of yo
$lang['Piwigo cannot retrieve upgrade file from server'] = 'Piwigo ne peut pas récupérer le fichier de mise à jour depuis le serveur';
$lang['Send connection settings by email'] = 'Envoyer les identifiants par email';
$lang['Activate comments'] = 'Activer les commentaires';
+$lang['Default comments order'] = 'Ordre par défaut des commentaires';
?> \ No newline at end of file
diff --git a/language/fr_FR/admin.lang.php b/language/fr_FR/admin.lang.php
index 8051c1b2f..8a790f309 100644
--- a/language/fr_FR/admin.lang.php
+++ b/language/fr_FR/admin.lang.php
@@ -845,5 +845,6 @@ $lang['Photo Sizes'] = 'Tailles de photo';
$lang['Original Size'] = 'Taille originale';
$lang['Send connection settings by email'] = 'Envoyer les identifiants par email';
$lang['Activate comments'] = 'Activer les commentaires';
+$lang['Default comments order'] = 'Ordre par défaut des commentaires';
?> \ No newline at end of file
diff --git a/themes/default/template/picture.tpl b/themes/default/template/picture.tpl
index 6fb873771..430d0e3c5 100644
--- a/themes/default/template/picture.tpl
+++ b/themes/default/template/picture.tpl
@@ -274,10 +274,14 @@ y.callService(
</div>
{if isset($COMMENT_COUNT)}
+<a name="comments"></a>
<div id="comments">
{if $COMMENT_COUNT > 0}
<h3>{$pwg->l10n_dec('%d comment', '%d comments',$COMMENT_COUNT)}</h3>
{/if}
+ {if $COMMENT_COUNT > 2}
+ {'Sort order'|@translate} : <a href="{$COMMENTS_ORDER_URL}#comments">{$COMMENTS_ORDER_TITLE}</a>
+ {/if}
{if !empty($navbar)}{include file='navigation_bar.tpl'|@get_extent:'navbar'}{/if}
{if isset($comments)}