Changeset 579 for trunk/picture.php


Ignore:
Timestamp:
Oct 23, 2004, 7:56:46 PM (20 years ago)
Author:
z0rglub
Message:
  • 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)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/picture.php

    r576 r579  
    182182  }
    183183
    184   if (isset($row['tn_ext']) and $row['tn_ext'] != '')
    185   {
    186     $picture[$i]['thumbnail'] = $cat_directory.'thumbnail/';
    187     $picture[$i]['thumbnail'].= $conf['prefix_thumbnail'].$file_wo_ext;
    188     $picture[$i]['thumbnail'].= '.'.$row['tn_ext'];
    189   }
    190   else
    191   {
    192     $picture[$i]['thumbnail'] = $icon;
    193   }
     184  $picture[$i]['thumbnail'] = get_thumbnail_src($row['file'],
     185                                                $row['storage_category_id'],
     186                                                @$row['tn_ext']);
    194187 
    195188  if ( !empty( $row['name'] ) )
     
    962955  while ( $row = mysql_fetch_array( $result ) )
    963956  {
    964     $content = nl2br( $row['content'] );
    965 
    966     // replace _word_ by an underlined word
    967     $pattern = '/_([^\s]*)_/';
    968     $replacement = '<span style="text-decoration:underline;">\1</span>';
    969     $content = preg_replace( $pattern, $replacement, $content );
    970 
    971     // replace *word* by a bolded word
    972     $pattern = '/\*([^\s]*)\*/';
    973     $replacement = '<span style="font-weight:bold;">\1</span>';
    974     $content = preg_replace( $pattern, $replacement, $content );
    975 
    976     // replace /word/ by an italic word
    977     $pattern = '/\/([^\s]*)\//';
    978     $replacement = '<span style="font-style:italic;">\1</span>';
    979     $content = preg_replace( $pattern, $replacement, $content );
    980        
    981     $template->assign_block_vars('comments.comment', array(
    982     'COMMENT_AUTHOR'=>empty($row['author'])?$lang['guest']:$row['author'],
    983     'COMMENT_DATE'=>format_date( $row['date'], 'mysql_datetime', true ),
    984         'COMMENT'=>$content
     957    $template->assign_block_vars(
     958      'comments.comment',
     959      array(
     960        'COMMENT_AUTHOR'=>empty($row['author'])?$lang['guest']:$row['author'],
     961        'COMMENT_DATE'=>format_date($row['date'], 'mysql_datetime', true),
     962        'COMMENT'=>parse_comment_content($row['content'])
    985963        ));
    986964       
    987965    if ( $user['status'] == 'admin' )
    988966    {
    989           $template->assign_block_vars('comments.comment.delete', array('U_COMMENT_DELETE'=>add_session_id( $url.'&amp;del='.$row['id'] )));
    990     }
    991   }
    992 
    993   if ( !$user['is_the_guest']||( $user['is_the_guest'] and $conf['comments_forall'] ) )
     967      $template->assign_block_vars(
     968        'comments.comment.delete',
     969        array('U_COMMENT_DELETE'=>add_session_id( $url.'&amp;del='.$row['id'])
     970          ));
     971    }
     972  }
     973
     974  if (!$user['is_the_guest']
     975      or ($user['is_the_guest'] and $conf['comments_forall']))
    994976  {
    995977    $template->assign_block_vars('comments.add_comment', array());
    996978    // display author field if the user is not logged in
    997     if ( !$user['is_the_guest'] )
    998     {
    999       $template->assign_block_vars('comments.add_comment.author_known', array('KNOWN_AUTHOR'=>$user['username']));
    1000         }
     979    if (!$user['is_the_guest'])
     980    {
     981      $template->assign_block_vars(
     982        'comments.add_comment.author_known',
     983        array('KNOWN_AUTHOR'=>$user['username'])
     984        );
     985    }
    1001986    else
    1002987    {
    1003       $template->assign_block_vars('comments.add_comment.author_field', array());
     988      $template->assign_block_vars(
     989        'comments.add_comment.author_field', array()
     990        );
    1004991    }
    1005992  }
Note: See TracChangeset for help on using the changeset viewer.