Changeset 847 for trunk/picture.php


Ignore:
Timestamp:
Aug 21, 2005, 1:32:12 PM (19 years ago)
Author:
plg
Message:
  • new way to display picture informations (template variables instead of template generic blocks)
  • new color for A:hover and its solid border-bottom, dotted border-bottom for A (same color as link color)
  • background color and border color for form input fields (input, select, textarea) to accentuate contrast with page background.
  • clear:both on #imageHeaderBar H1 let it be center on page
  • in infoTable keys are right aligned and values are left aligned (more beautiful, isn't it?)
  • add "set as representative" button to cclear template in picture.tpl. representative.png picture taken from Gorilla theme.
  • invisible horizontal rule on picture.tpl to separate user comments from the beginning of the page
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/picture.php

    r811 r847  
    9696  FROM '.IMAGE_CATEGORY_TABLE.'
    9797    INNER JOIN '.CATEGORIES_TABLE.' ON category_id = id
    98   WHERE image_id = '.$_GET['image_id'];
    99 if ($user['forbidden_categories'] != '')
    100 {
    101   $query.= '
    102     AND category_id NOT IN ('.$user['forbidden_categories'].')';
    103 }
    104 $query.= '
     98  WHERE image_id = '.$_GET['image_id'].'
     99    AND category_id NOT IN ('.$user['forbidden_categories'].')
    105100;';
    106101$result = pwg_query($query);
     
    488483}
    489484
    490 // author
    491 $author = $creation_date = $size = $filesize = $lang['unavailable'];
    492 if ( !empty($picture['current']['author']) )
    493 {
    494   $search_url = PHPWG_ROOT_PATH.'category.php?cat=search';
    495   $search_url.= '&search=author:'.$picture['current']['author'];
    496  
    497   $author = '<a href="';
    498   $author .= add_session_id($search_url);
    499   $author .= '">'.$picture['current']['author'].'</a>';
    500 }
    501 
    502 // creation date
    503 if ( !empty($picture['current']['date_creation']) )
    504 {
    505   $creation_date = format_date($picture['current']['date_creation']);
    506 }
    507 
    508 // date of availability
    509 $availability_date = format_date($picture['current']['date_available'],
    510                                  'mysql_datetime');
    511 
    512 // size in pixels
    513 if ($picture['current']['is_picture'])
    514 {
    515   if ($original_width != $picture_size[0]
    516       or $original_height != $picture_size[1])
    517   {
    518     $size = '[ <a href="'.$picture['current']['src'].'" ';
    519     $size .= ' title="'.$lang['true_size'].'">';
    520     $size .= $original_width.'*'.$original_height.'</a> ]';
    521   }
    522   else
    523   {
    524     $size = $original_width.'*'.$original_height;
    525   }
    526 }
    527 
    528 // filesize
    529 if (empty($picture['current']['filesize']))
    530 {
    531   if (!$picture['current']['is_picture'])
    532   {
    533     $filesize = floor(filesize($picture['current']['download'])/1024);
    534   }
    535   else
    536   {
    537     $filesize = floor(filesize($picture['current']['src'])/1024);
    538   }
    539 }
    540 else
    541 {
    542   $filesize = $picture['current']['filesize'];
    543 }
    544 
    545 // number of visits
    546 $template->assign_block_vars(
    547   'info_line',
    548   array(
    549     'INFO'=>$lang['visited'],
    550     'VALUE'=>$picture['current']['hit'].' '.$lang['times']
    551     ));
    552                          
    553485include(PHPWG_ROOT_PATH.'include/page_header.php');
    554486$template->set_filenames(array('picture'=>'picture.tpl'));
     
    562494  'WIDTH_IMG' => $picture_size[0],
    563495  'HEIGHT_IMG' => $picture_size[1],
    564   'AUTHOR' => $author,
    565   'CREATION_DATE' => $creation_date,
    566   'AVAILABILITY_DATE' => $availability_date,
    567   'SIZE' => $size,
    568   'FILE_SIZE' => $filesize,
    569496
    570497  'LEVEL_SEPARATOR' => $conf['level_separator'],
     
    581508  'L_DELETE' =>$lang['delete'],
    582509  'L_SUBMIT' =>$lang['submit'],
    583   'L_AUTHOR' =>$lang['author'],
    584510  'L_COMMENT' =>$lang['comment'],
    585511  'L_DOWNLOAD' => $lang['download'],
     
    589515  'L_UP_HINT' => $lang['home_hint'],
    590516  'L_UP_ALT' => $lang['home'],
    591   'L_CREATION_DATE' => $lang['creation_date'],
    592   'L_AVAILABILITY_DATE' => $lang['registration_date'],
    593   'L_SIZE' => $lang['size'],
    594   'L_FILE' => $lang['file'],
    595   'L_FILE_SIZE' => $lang['size'],
    596517 
    597518  'U_HOME' => add_session_id(PHPWG_ROOT_PATH.'category.php'),
     
    731652}
    732653
     654$infos = array();
     655
     656// author
     657if (!empty($picture['current']['author']))
     658{
     659  $infos['INFO_AUTHOR'] =
     660    '<a href="'.
     661    add_session_id(
     662      PHPWG_ROOT_PATH.'category.php?cat=search'.
     663      '&amp;search=author:'.$picture['current']['author']
     664      ).
     665    '">'.$picture['current']['author'].'</a>';
     666}
     667else
     668{
     669  $infos['INFO_AUTHOR'] = l10n('N/A');
     670}
     671
     672// creation date
     673if (!empty($picture['current']['date_creation']))
     674{
     675  $infos['INFO_CREATION_DATE'] =
     676    '<a href="'.
     677    add_session_id(
     678      PHPWG_ROOT_PATH.'category.php?cat=search'.
     679      '&amp;search=date_creation:'.$picture['current']['date_creation']
     680      ).
     681    '">'.format_date($picture['current']['date_creation']).'</a>';
     682}
     683else
     684{
     685  $infos['INFO_CREATION_DATE'] = l10n('N/A');
     686}
     687
     688// date of availability
     689$infos['INFO_AVAILABILITY_DATE'] =
     690  '<a href="'.
     691  add_session_id(
     692    PHPWG_ROOT_PATH.'category.php?cat=search'.
     693    '&amp;search=date_available:'.
     694    substr($picture['current']['date_available'], 0, 10)
     695    ).
     696    '">'.
     697  format_date($picture['current']['date_available'], 'mysql_datetime').
     698  '</a>';
     699
     700// size in pixels
     701if ($picture['current']['is_picture'])
     702{
     703  if ($original_width != $picture_size[0]
     704      or $original_height != $picture_size[1])
     705  {
     706    $infos['INFO_DIMENSIONS'] =
     707      '<a href="'.$picture['current']['src'].'" title="'.
     708      l10n('Original dimensions').'">'.
     709      $original_width.'*'.$original_height.'</a>';
     710  }
     711  else
     712  {
     713    $infos['INFO_DIMENSIONS'] = $original_width.'*'.$original_height;
     714  }
     715}
     716else
     717{
     718  $infos['INFO_DIMENSIONS'] = l10n('N/A');
     719}
     720
     721// filesize
     722if (!empty($picture['current']['filesize']))
     723{
     724  $infos['INFO_FILESIZE'] =
     725    sprintf(l10n('%d Kb'), $picture['current']['filesize']);
     726}
     727else
     728{
     729  $infos['INFO_FILESIZE'] = l10n('N/A');
     730}
     731
     732// number of visits
     733$infos['INFO_VISITS'] = $picture['current']['hit'];
     734
     735// file
     736$infos['INFO_FILE'] = $picture['current']['file'];
     737
    733738// keywords
    734739if (!empty($picture['current']['keywords']))
    735740{
    736   $keywords = explode(',', $picture['current']['keywords']);
    737   $content = '';
    738   $url = PHPWG_ROOT_PATH.'category.php?cat=search&amp;search=keywords:';
    739   foreach ($keywords as $i => $keyword)
    740   {
    741     $local_url = add_session_id($url.$keyword);
    742     if ($i > 0)
    743     {
    744       $content.= ',';
    745     }
    746     $content.= '<a href="'.$local_url.'">'.$keyword.'</a>';
    747   }
     741  $infos['INFO_KEYWORDS'] =
     742    preg_replace(
     743      '/([^,]+)/',
     744      '<a href="'.
     745      add_session_id(
     746        PHPWG_ROOT_PATH.'category.php?cat=search&amp;search=keywords:$1'
     747        ).
     748      '">$1</a>',
     749      $picture['current']['keywords']
     750      );
     751}
     752else
     753{
     754  $infos['INFO_KEYWORDS'] = l10n('N/A');
     755}
     756
     757$template->assign_vars($infos);
     758
     759// related categories
     760foreach ($related_categories as $category)
     761{
    748762  $template->assign_block_vars(
    749     'keywords',
     763    'category',
    750764    array(
    751       'INFO'=>$lang['keywords'],
    752       'VALUE'=>$content
    753       ));
    754 }
    755 
    756 // related categories
    757 $cat_output = '';
    758 $page['show_comments'] = false;
    759 foreach ($related_categories as $category)
    760 {
    761   if ($cat_output != '')
    762   {
    763     $cat_output.= '<br />';
    764   }
    765  
    766   if (count($related_categories) > 3)
    767   {
    768     $cat_output .= get_cat_display_name_cache($category['uppercats']);
    769   }
    770   else
    771   {
    772     $cat_info = get_cat_info($category['category_id']);
    773     $cat_output .= get_cat_display_name($cat_info['name']);
    774   }
    775   // the picture is commentable if it belongs at least to one category which
    776   // is commentable
    777   if ($category['commentable'] == 'true')
    778   {
    779     $page['show_comments'] = true;
    780   }
    781 }
    782 $template->assign_block_vars(
    783   'associated',
    784   array(
    785     'INFO'  => $lang['categories'],
    786     'VALUE' => $cat_output
    787     ));
     765      'LINE' => count($related_categories) > 3
     766        ? get_cat_display_name_cache($category['uppercats'])
     767        : get_cat_display_name_from_id($category['category_id'])
     768      )
     769    );
     770}
    788771
    789772//-------------------------------------------------------------------  metadata
     
    894877if ($conf['rate'])
    895878{
    896   $query = 'SELECT COUNT(rate) AS count
     879  $query = '
     880SELECT COUNT(rate) AS count
    897881     , ROUND(AVG(rate),2) AS average
    898882     , ROUND(STD(rate),2) AS STD
     
    907891  else
    908892  {
    909     $value = $row['average'];
    910     $value.= ' (';
    911     $value.= $row['count'].' '.$lang['rates'];
    912     $value.= ', '.$lang['standard_deviation'].' : '.$row['STD'];
    913     $value.= ')';
     893    $value = sprintf(
     894      l10n('%.2f (rated %d times, standard deviation = %.2f)'),
     895      $row['average'],
     896      $row['count'],
     897      $row['STD']
     898      );
    914899  }
    915900 
     
    935920    'rate',
    936921    array(
    937       'INFO'  => $lang['element_rate'],
    938       'VALUE' => $value,
     922      'CONTENT' => $value,
    939923      'SENTENCE' => $sentence
    940924      ));
     925
     926  $template->assign_block_vars('info_rate', array('CONTENT' => $value));
     927 
     928  $template->assign_vars(
     929    array(
     930      'INFO_RATE' => $value
     931      )
     932    );
    941933 
    942934  foreach ($rate_items as $num => $mark)
     
    967959
    968960//---------------------------------------------------- users's comments display
     961
     962// the picture is commentable if it belongs at least to one category which
     963// is commentable
     964$page['show_comments'] = false;
     965foreach ($related_categories as $category)
     966{
     967  if ($category['commentable'] == 'true')
     968  {
     969    $page['show_comments'] = true;
     970  }
     971}
     972
    969973if ($page['show_comments'])
    970974{
Note: See TracChangeset for help on using the changeset viewer.