aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2006-11-08 04:28:30 +0000
committerrvelices <rv-github@modusoptimus.com>2006-11-08 04:28:30 +0000
commite5e776a263ba63407893a28df379f2ac8152680c (patch)
treecddbdfa05f6c58740161778d78f80112dac1a414
parente44f0b01549d3a52c5b261767c6531044d09a1a1 (diff)
- comments.php improvements:
- unvalidated comments are shown only for administrators - added delete/validate icons for admins - removed some unused code - display of comment content performed through an event - replace some get_thumbnail_src with get_thumbnail_url git-svn-id: http://piwigo.org/svn/trunk@1598 68402e56-0260-453c-a942-63ccdbb3a9ee
-rw-r--r--admin/comments.php15
-rw-r--r--comments.php125
-rw-r--r--include/common.inc.php6
-rw-r--r--include/picture_comment.inc.php2
-rw-r--r--template/yoga/comments.tpl17
-rw-r--r--template/yoga/icon/validate_s.pngbin0 -> 315 bytes
6 files changed, 100 insertions, 65 deletions
diff --git a/admin/comments.php b/admin/comments.php
index 3debab9d0..1371f72f2 100644
--- a/admin/comments.php
+++ b/admin/comments.php
@@ -47,7 +47,7 @@ if (isset($_POST))
$to_reject = array();
if (isset($_POST['submit']) and !is_adviser())
- {
+ {
foreach (explode(',', $_POST['list']) as $comment_id)
{
if (isset($_POST['action-'.$comment_id]))
@@ -141,8 +141,15 @@ SELECT c.id, c.image_id, c.date, c.author, c.content, i.path, i.tn_ext
WHERE validated = \'false\'
;';
$result = pwg_query($query);
-while ($row = mysql_fetch_array($result))
+while ($row = mysql_fetch_assoc($result))
{
+ $thumb = get_thumbnail_url(
+ array(
+ 'id'=>$row['image_id'],
+ 'path'=>$row['path'],
+ 'tn_ext'=>@$row['tn_ext']
+ )
+ );
$template->assign_block_vars(
'comment',
array(
@@ -150,10 +157,10 @@ while ($row = mysql_fetch_array($result))
PHPWG_ROOT_PATH.'admin.php?page=picture_modify'.
'&amp;image_id='.$row['image_id'],
'ID' => $row['id'],
- 'TN_SRC' => get_thumbnail_src($row['path'], @$row['tn_ext']),
+ 'TN_SRC' => $thumb,
'AUTHOR' => $row['author'],
'DATE' => format_date($row['date'],'mysql_datetime',true),
- 'CONTENT' => parse_comment_content($row['content'])
+ 'CONTENT' => trigger_event('render_comment_content',$row['content'])
)
);
diff --git a/comments.php b/comments.php
index 28f4bf410..8786605ef 100644
--- a/comments.php
+++ b/comments.php
@@ -5,7 +5,7 @@
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
// +-----------------------------------------------------------------------+
// | branch : BSF (Best So Far)
-// | file : $RCSfile$
+// | file : $Id$
// | last update : $Date$
// | last modifier : $Author$
// | revision : $Revision$
@@ -28,11 +28,8 @@
// +-----------------------------------------------------------------------+
// | initialization |
// +-----------------------------------------------------------------------+
-if (!defined('IN_ADMIN'))
-{
- define('PHPWG_ROOT_PATH','./');
- include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
-}
+define('PHPWG_ROOT_PATH','./');
+include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
// +-----------------------------------------------------------------------+
// | Check Access and exit when user status is not ok |
@@ -144,31 +141,41 @@ if (isset($_GET['keyword']) and !empty($_GET['keyword']))
')';
}
+// which status to filter on ?
+if ( is_admin() )
+{
+ $page['status_clause'] = '1=1';
+}
+else
+{
+ $page['status_clause'] = 'validated="true"';
+}
+
+
// +-----------------------------------------------------------------------+
// | comments management |
// +-----------------------------------------------------------------------+
-// comments deletion
-if (isset($_POST['delete']) and count($_POST['comment_id']) > 0 and is_admin())
+if (is_admin() and !is_adviser() )
{
- $_POST['comment_id'] = array_map('intval', $_POST['comment_id']);
- $query = '
+ if (isset($_GET['delete']) and is_numeric($_GET['delete']) )
+ {// comments deletion
+ $query = '
DELETE FROM '.COMMENTS_TABLE.'
- WHERE id IN ('.implode(',', $_POST['comment_id']).')
+ WHERE id='.$_GET['delete'].'
;';
- pwg_query($query);
-}
-// comments validation
-if (isset($_POST['validate']) and count($_POST['comment_id']) > 0
- and is_admin())
-{
- $_POST['comment_id'] = array_map('intval', $_POST['comment_id']);
- $query = '
+ pwg_query($query);
+ }
+
+ if (isset($_GET['validate']) and is_numeric($_GET['validate']) )
+ { // comments validation
+ $query = '
UPDATE '.COMMENTS_TABLE.'
SET validated = \'true\'
, validation_date = NOW()
- WHERE id IN ('.implode(',', $_POST['comment_id']).')
+ WHERE id='.$_GET['validate'].'
;';
- pwg_query($query);
+ pwg_query($query);
+ }
}
// +-----------------------------------------------------------------------+
// | page header and options |
@@ -298,7 +305,8 @@ SELECT COUNT(DISTINCT(id))
WHERE '.$since_options[$page['since']]['clause'].'
AND '.$page['cat_clause'].'
AND '.$page['author_clause'].'
- AND '.$page['keyword_clause'];
+ AND '.$page['keyword_clause'].'
+ AND '.$page['status_clause'];
if ($user['forbidden_categories'] != '')
{
$query.= '
@@ -308,7 +316,9 @@ $query.= '
;';
list($counter) = mysql_fetch_row(pwg_query($query));
-$url = PHPWG_ROOT_PATH.'comments.php'.get_query_string_diff(array('start'));
+$url = PHPWG_ROOT_PATH
+ .'comments.php'
+ .get_query_string_diff(array('start','delete','validate'));
$navbar = create_navigation_bar($url,
$counter,
@@ -334,13 +344,15 @@ SELECT com.id AS comment_id
, com.date
, com.content
, com.id AS comment_id
+ , com.validated
FROM '.IMAGE_CATEGORY_TABLE.' AS ic
INNER JOIN '.COMMENTS_TABLE.' AS com
ON ic.image_id = com.image_id
WHERE '.$since_options[$page['since']]['clause'].'
AND '.$page['cat_clause'].'
AND '.$page['author_clause'].'
- AND '.$page['keyword_clause'];
+ AND '.$page['keyword_clause'].'
+ AND '.$page['status_clause'];
if ($user['forbidden_categories'] != '')
{
$query.= '
@@ -357,7 +369,7 @@ if ('all' != $page['items_number'])
$query.= '
;';
$result = pwg_query($query);
-while ($row = mysql_fetch_array($result))
+while ($row = mysql_fetch_assoc($result))
{
array_push($comments, $row);
array_push($element_ids, $row['image_id']);
@@ -374,7 +386,7 @@ SELECT id, name, file, path, tn_ext
WHERE id IN ('.implode(',', $element_ids).')
;';
$result = pwg_query($query);
- while ($row = mysql_fetch_array($result))
+ while ($row = mysql_fetch_assoc($result))
{
$elements[$row['id']] = $row;
}
@@ -387,31 +399,24 @@ SELECT id, name, uppercats
WHERE id IN ('.implode(',', $category_ids).')
;';
$result = pwg_query($query);
- while ($row = mysql_fetch_array($result))
+ while ($row = mysql_fetch_assoc($result))
{
$categories[$row['id']] = $row;
}
foreach ($comments as $comment)
{
- // name of the picture
- $name = get_cat_display_name_cache(
- $categories[$comment['category_id']]['uppercats'], null, false);
- $name.= $conf['level_separator'];
if (!empty($elements[$comment['image_id']]['name']))
{
- $name.= $elements[$comment['image_id']]['name'];
+ $name=$elements[$comment['image_id']]['name'];
}
else
{
- $name.= get_name_from_file($elements[$comment['image_id']]['file']);
+ $name=get_name_from_file($elements[$comment['image_id']]['file']);
}
// source of the thumbnail picture
- $thumbnail_src = get_thumbnail_src(
- $elements[$comment['image_id']]['path'],
- @$elements[$comment['image_id']]['tn_ext']
- );
+ $thumbnail_src = get_thumbnail_url( $elements[$comment['image_id']] );
// link to the full size picture
$url = make_picture_url(
@@ -423,14 +428,6 @@ SELECT id, name, uppercats
)
);
- $template->assign_block_vars(
- 'picture',
- array(
- 'TITLE_IMG'=>$name,
- 'I_THUMB'=>$thumbnail_src,
- 'U_THUMB'=>$url
- ));
-
$author = $comment['author'];
if (empty($comment['author']))
{
@@ -442,23 +439,39 @@ SELECT id, name, uppercats
array(
'U_PICTURE' => $url,
'TN_SRC' => $thumbnail_src,
+ 'ALT' => $name,
'AUTHOR' => $author,
'DATE'=>format_date($comment['date'],'mysql_datetime',true),
- 'CONTENT'=>parse_comment_content($comment['content']),
+ 'CONTENT'=>trigger_event('render_comment_content',$comment['content']),
));
+
+ if ( is_admin() )
+ {
+ $url = get_root_url().'comments.php'.get_query_string_diff(array('delete','validate'));
+ $template->assign_block_vars(
+ 'comment.action_delete',
+ array(
+ 'U_DELETE' => add_url_params($url,
+ array('delete'=>$comment['comment_id'])
+ ),
+ ));
+ if ($comment['validated'] != 'true')
+ {
+ $template->assign_block_vars(
+ 'comment.action_validate',
+ array(
+ 'U_VALIDATE' => add_url_params($url,
+ array('validate'=>$comment['comment_id'])
+ ),
+ ));
+ }
+ }
}
}
// +-----------------------------------------------------------------------+
// | html code display |
// +-----------------------------------------------------------------------+
-if (defined('IN_ADMIN'))
-{
- $template->assign_var_from_handle('ADMIN_CONTENT', 'comments');
-}
-else
-{
- $template->assign_block_vars('title',array());
- $template->parse('comments');
- include(PHPWG_ROOT_PATH.'include/page_tail.php');
-}
+$template->assign_block_vars('title',array());
+$template->parse('comments');
+include(PHPWG_ROOT_PATH.'include/page_tail.php');
?>
diff --git a/include/common.inc.php b/include/common.inc.php
index e77d41f89..2b02e0cf8 100644
--- a/include/common.inc.php
+++ b/include/common.inc.php
@@ -5,7 +5,7 @@
// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
// +-----------------------------------------------------------------------+
// | branch : BSF (Best So Far)
-// | file : $RCSfile$
+// | file : $Id$
// | last update : $Date$
// | last modifier : $Author$
// | revision : $Revision$
@@ -228,4 +228,8 @@ if (count($header_msgs) > 0)
array('HEADER_MSG'=>$header_msg));
}
}
+
+// default event handlers
+add_event_handler('render_comment_content', 'parse_comment_content');
+trigger_action('init');
?> \ No newline at end of file
diff --git a/include/picture_comment.inc.php b/include/picture_comment.inc.php
index ad2878fcb..679f6287f 100644
--- a/include/picture_comment.inc.php
+++ b/include/picture_comment.inc.php
@@ -176,7 +176,7 @@ SELECT id,author,date,image_id,content
'mysql_datetime',
true),
- 'COMMENT' => parse_comment_content($row['content']),
+ 'COMMENT' => trigger_event('render_comment_content',$row['content']),
)
);
diff --git a/template/yoga/comments.tpl b/template/yoga/comments.tpl
index 6bf28d33b..8ba52d5ef 100644
--- a/template/yoga/comments.tpl
+++ b/template/yoga/comments.tpl
@@ -70,7 +70,7 @@
</fieldset>
- <p><input type="submit" name="submit" value="{lang:Filter and display}"></p>
+ <p><input type="submit" value="{lang:Filter and display}"></p>
</form>
@@ -80,8 +80,19 @@
<!-- BEGIN comment -->
<div class="comment">
- <a class="illustration" href="{comment.U_PICTURE}"><img src="{comment.TN_SRC}" /></a>
- <p class="commentHeader"><span class="author">{comment.AUTHOR}</span> - <span class="date">{comment.DATE}</span></p>
+ <a class="illustration" href="{comment.U_PICTURE}"><img src="{comment.TN_SRC}" alt="{comment.ALT}" /></a>
+ <p class="commentHeader"><span class="author">{comment.AUTHOR}</span> - <span class="date">{comment.DATE}</span>
+ <!-- BEGIN action_delete -->
+ <a href="{comment.action_delete.U_DELETE}" title="{lang:comments_del}">
+ <img src="{pwg_root}{themeconf:icon_dir}/delete.png" class="button" style="border:none;vertical-align:middle; margin-left:5px;" alt="[{lang:delete}]"/>
+ </a>
+ <!-- END action_delete -->
+ <!-- BEGIN action_validate -->
+ <a href="{comment.action_validate.U_VALIDATE}" title="validate this comment">
+ <img src="{pwg_root}{themeconf:icon_dir}/validate_s.png" class="button" style="border:none;vertical-align:middle; margin-left:5px;" alt="[validate]"/>
+ </a>
+ <!-- END action_validate -->
+ </p>
<blockquote>{comment.CONTENT}</blockquote>
<hr class="separation">
</div>
diff --git a/template/yoga/icon/validate_s.png b/template/yoga/icon/validate_s.png
new file mode 100644
index 000000000..400bf8a24
--- /dev/null
+++ b/template/yoga/icon/validate_s.png
Binary files differ