aboutsummaryrefslogtreecommitdiffstats
path: root/picture.php
diff options
context:
space:
mode:
authorz0rglub <z0rglub@piwigo.org>2004-10-23 17:56:46 +0000
committerz0rglub <z0rglub@piwigo.org>2004-10-23 17:56:46 +0000
commit98b65edb831e95695cc840692ab8ad294478f80d (patch)
tree2b1ffe5ba3c8bc1fcdb209e8f8d793bd18e9dd1d /picture.php
parent60ac6f180e9500c6fea0c872277f107f05d7d26d (diff)
- refactoring of comments.php
- creation of function get_thumbnail_src used everywhere a thumbnail must be displayed - creation of function parse_comment_content (used in comments.php and picture.php) - concerning undefined index on arrays retrieved in database, instead of testing possibly unset values, use of @ operator (smarter...) - add pre tag in default.css stylesheet for debugging purpose (need to have left aligned text) git-svn-id: http://piwigo.org/svn/trunk@579 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'picture.php')
-rw-r--r--picture.php61
1 files changed, 24 insertions, 37 deletions
diff --git a/picture.php b/picture.php
index 1816aaffc..1ef71bea5 100644
--- a/picture.php
+++ b/picture.php
@@ -181,16 +181,9 @@ foreach (array('prev', 'current', 'next') as $i)
$picture[$i]['download'] = $cat_directory.$row['file'];
}
- if (isset($row['tn_ext']) and $row['tn_ext'] != '')
- {
- $picture[$i]['thumbnail'] = $cat_directory.'thumbnail/';
- $picture[$i]['thumbnail'].= $conf['prefix_thumbnail'].$file_wo_ext;
- $picture[$i]['thumbnail'].= '.'.$row['tn_ext'];
- }
- else
- {
- $picture[$i]['thumbnail'] = $icon;
- }
+ $picture[$i]['thumbnail'] = get_thumbnail_src($row['file'],
+ $row['storage_category_id'],
+ @$row['tn_ext']);
if ( !empty( $row['name'] ) )
{
@@ -961,46 +954,40 @@ if ( $conf['show_comments'] )
while ( $row = mysql_fetch_array( $result ) )
{
- $content = nl2br( $row['content'] );
-
- // replace _word_ by an underlined word
- $pattern = '/_([^\s]*)_/';
- $replacement = '<span style="text-decoration:underline;">\1</span>';
- $content = preg_replace( $pattern, $replacement, $content );
-
- // replace *word* by a bolded word
- $pattern = '/\*([^\s]*)\*/';
- $replacement = '<span style="font-weight:bold;">\1</span>';
- $content = preg_replace( $pattern, $replacement, $content );
-
- // replace /word/ by an italic word
- $pattern = '/\/([^\s]*)\//';
- $replacement = '<span style="font-style:italic;">\1</span>';
- $content = preg_replace( $pattern, $replacement, $content );
-
- $template->assign_block_vars('comments.comment', array(
- 'COMMENT_AUTHOR'=>empty($row['author'])?$lang['guest']:$row['author'],
- 'COMMENT_DATE'=>format_date( $row['date'], 'mysql_datetime', true ),
- 'COMMENT'=>$content
+ $template->assign_block_vars(
+ 'comments.comment',
+ array(
+ 'COMMENT_AUTHOR'=>empty($row['author'])?$lang['guest']:$row['author'],
+ 'COMMENT_DATE'=>format_date($row['date'], 'mysql_datetime', true),
+ 'COMMENT'=>parse_comment_content($row['content'])
));
if ( $user['status'] == 'admin' )
{
- $template->assign_block_vars('comments.comment.delete', array('U_COMMENT_DELETE'=>add_session_id( $url.'&amp;del='.$row['id'] )));
+ $template->assign_block_vars(
+ 'comments.comment.delete',
+ array('U_COMMENT_DELETE'=>add_session_id( $url.'&amp;del='.$row['id'])
+ ));
}
}
- if ( !$user['is_the_guest']||( $user['is_the_guest'] and $conf['comments_forall'] ) )
+ if (!$user['is_the_guest']
+ or ($user['is_the_guest'] and $conf['comments_forall']))
{
$template->assign_block_vars('comments.add_comment', array());
// display author field if the user is not logged in
- if ( !$user['is_the_guest'] )
+ if (!$user['is_the_guest'])
{
- $template->assign_block_vars('comments.add_comment.author_known', array('KNOWN_AUTHOR'=>$user['username']));
- }
+ $template->assign_block_vars(
+ 'comments.add_comment.author_known',
+ array('KNOWN_AUTHOR'=>$user['username'])
+ );
+ }
else
{
- $template->assign_block_vars('comments.add_comment.author_field', array());
+ $template->assign_block_vars(
+ 'comments.add_comment.author_field', array()
+ );
}
}
}