Changeset 774 for trunk/picture.php


Ignore:
Timestamp:
Apr 26, 2005, 4:24:08 PM (20 years ago)
Author:
gweltas
Message:

Bug 0000100: 'info_line' template code splited

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/picture.php

    r745 r774  
    460460  $url_metadata.= '&show_metadata=1';
    461461}
    462                                  
     462
     463// author
     464$author = $creation_date = $size = $filesize = $lang['unavailable'];
     465if ( !empty($picture['current']['author']) )
     466{
     467  $search_url = PHPWG_ROOT_PATH.'category.php?cat=search';
     468  $search_url.= '&search=author:'.$picture['current']['author'];
     469 
     470  $author = '<a href="';
     471  $author .= add_session_id($search_url);
     472  $author .= '">'.$picture['current']['author'].'</a>';
     473}
     474
     475// creation date
     476if ( !empty($picture['current']['date_creation']) )
     477{
     478  $creation_date = format_date($picture['current']['date_creation']);
     479}
     480
     481// date of availability
     482$availability_date = format_date($picture['current']['date_available']);
     483
     484// size in pixels
     485if ($picture['current']['is_picture'])
     486{
     487  if ($original_width != $picture_size[0]
     488      or $original_height != $picture_size[1])
     489  {
     490    $size = '[ <a href="'.$picture['current']['src'].'" ';
     491    $size .= ' title="'.$lang['true_size'].'">';
     492    $size .= $original_width.'*'.$original_height.'</a> ]';
     493  }
     494  else
     495  {
     496    $size = $original_width.'*'.$original_height;
     497  }
     498}
     499
     500// filesize
     501if (empty($picture['current']['filesize']))
     502{
     503  if (!$picture['current']['is_picture'])
     504  {
     505    $filesize = floor(filesize($picture['current']['download'])/1024);
     506  }
     507  else
     508  {
     509    $filesize = floor(filesize($picture['current']['src'])/1024);
     510  }
     511}
     512else
     513{
     514  $filesize = $picture['current']['filesize'];
     515}
     516
     517// number of visits
     518$template->assign_block_vars(
     519  'info_line',
     520  array(
     521    'INFO'=>$lang['visited'],
     522    'VALUE'=>$picture['current']['hit'].' '.$lang['times']
     523    ));
     524                         
    463525include(PHPWG_ROOT_PATH.'include/page_header.php');
    464526$template->set_filenames(array('picture'=>'picture.tpl'));
     
    472534  'WIDTH_IMG' => $picture_size[0],
    473535  'HEIGHT_IMG' => $picture_size[1],
     536  'AUTHOR' => $author,
     537  'CREATION_DATE' => $creation_date,
     538  'AVAILABILITY_DATE' => $availability_date,
     539  'SIZE' => $size,
     540  'FILE_SIZE' => $filesize,
    474541
    475542  'LEVEL_SEPARATOR' => $conf['level_separator'],
     
    494561  'L_UP_HINT' => $lang['home_hint'],
    495562  'L_UP_ALT' => $lang['home'],
     563  'L_CREATION_DATE' => $lang['creation_date'],
     564  'L_AVAILABILITY_DATE' => $lang['registration_date'],
     565  'L_SIZE' => $lang['size'],
     566  'L_FILE' => $lang['file'],
     567  'L_FILE_SIZE' => $lang['size'],
    496568 
    497569  'U_HOME' => add_session_id(PHPWG_ROOT_PATH.'category.php'),
     
    612684}
    613685
    614 // author
    615 if ( !empty($picture['current']['author']) )
    616 {
    617   $search_url = PHPWG_ROOT_PATH.'category.php?cat=search';
    618   $search_url.= '&amp;search=author:'.$picture['current']['author'];
    619  
    620   $value = '<a href="';
    621   $value.= add_session_id($search_url);
    622   $value.= '">'.$picture['current']['author'].'</a>';
    623  
    624   $template->assign_block_vars(
    625     'info_line',
    626     array(
    627       'INFO'=>$lang['author'],
    628       'VALUE'=>$value
    629       ));
    630 }
    631 // creation date
    632 if ( !empty($picture['current']['date_creation']) )
    633 {
    634   $search_url = PHPWG_ROOT_PATH.'category.php?cat=search';
    635   $search_url.= '&amp;search=';
    636   $search_url.= 'date_creation:'.$picture['current']['date_creation'];
    637  
    638   $value = '<a href="';
    639   $value.= add_session_id($search_url);
    640   $value.= '">'.format_date($picture['current']['date_creation']).'</a>';
    641  
    642   $template->assign_block_vars(
    643     'info_line',
    644     array(
    645       'INFO'=>$lang['creation_date'],
    646       'VALUE'=>$value
    647       ));
    648 }
    649 // date of availability
    650 $search_url = PHPWG_ROOT_PATH.'category.php?cat=search';
    651 $search_url.= '&amp;search=';
    652 $search_url.= 'date_available:'.$picture['current']['date_available'];
    653  
    654 $value = '<a href="';
    655 $value.= add_session_id($search_url);
    656 $value.= '">'.format_date($picture['current']['date_available']).'</a>';
    657 
    658 $template->assign_block_vars(
    659   'info_line',
    660   array(
    661     'INFO'=>$lang['registration_date'],
    662     'VALUE'=>$value
    663     ));
    664 // size in pixels
    665 if ($picture['current']['is_picture'])
    666 {
    667   if ($original_width != $picture_size[0]
    668       or $original_height != $picture_size[1])
    669   {
    670     $content = '[ <a href="'.$picture['current']['src'].'" ';
    671     $content.= ' title="'.$lang['true_size'].'">';
    672     $content.= $original_width.'*'.$original_height.'</a> ]';
    673   }
    674   else
    675   {
    676     $content = $original_width.'*'.$original_height;
    677   }
    678   $template->assign_block_vars(
    679     'info_line',
    680     array(
    681       'INFO'=>$lang['size'],
    682       'VALUE'=>$content
    683       ));
    684 }
    685 // file
    686 $template->assign_block_vars('info_line', array(
    687           'INFO'=>$lang['file'],
    688           'VALUE'=>$picture['current']['file']
    689           ));
    690 // filesize
    691 if (empty($picture['current']['filesize']))
    692 {
    693   if (!$picture['current']['is_picture'])
    694   {
    695     $filesize = floor(filesize($picture['current']['download'])/1024);
    696   }
    697   else
    698   {
    699     $filesize = floor(filesize($picture['current']['src'])/1024);
    700   }
    701 }
    702 else
    703 {
    704   $filesize = $picture['current']['filesize'];
    705 }
    706 
    707 $template->assign_block_vars('info_line', array(
    708           'INFO'=>$lang['filesize'],
    709           'VALUE'=>$filesize.' KB'
    710           ));
    711686// keywords
    712687if (!empty($picture['current']['keywords']))
     
    725700  }
    726701  $template->assign_block_vars(
    727     'info_line',
     702    'keywords',
    728703    array(
    729704      'INFO'=>$lang['keywords'],
     
    731706      ));
    732707}
    733 // number of visits
    734 $template->assign_block_vars(
    735   'info_line',
    736   array(
    737     'INFO'=>$lang['visited'],
    738     'VALUE'=>$picture['current']['hit'].' '.$lang['times']
    739     ));
    740 // rate results
    741 if ($conf['rate'])
    742 {
    743   $query = '
    744 SELECT COUNT(rate) AS count
    745      , ROUND(AVG(rate),2) AS average
    746      , ROUND(STD(rate),2) AS STD
    747   FROM '.RATE_TABLE.'
    748   WHERE element_id = '.$picture['current']['id'].'
    749 ;';
    750   $row = mysql_fetch_array(pwg_query($query));
    751   if ($row['count'] == 0)
    752   {
    753     $value = $lang['no_rate'];
    754   }
    755   else
    756   {
    757     $value = $row['average'];
    758     $value.= ' (';
    759     $value.= $row['count'].' '.$lang['rates'];
    760     $value.= ', '.$lang['standard_deviation'].' : '.$row['STD'];
    761     $value.= ')';
    762   }
    763  
    764   $template->assign_block_vars(
    765     'info_line',
    766     array(
    767       'INFO'  => $lang['element_rate'],
    768       'VALUE' => $value
    769       ));
    770 }
     708
    771709// related categories
    772710$cat_output = '';
     
    796734}
    797735$template->assign_block_vars(
    798   'info_line',
     736  'associated',
    799737  array(
    800738    'INFO'  => $lang['categories'],
    801739    'VALUE' => $cat_output
    802740    ));
    803 // metadata
     741
     742//-------------------------------------------------------------------  metadata
    804743if ($metadata_showable and isset($_GET['show_metadata']))
    805744{
     
    905844}
    906845
    907 //------------------------------------------------------------------- rate form
    908 if ($conf['rate'] and !$user['is_the_guest'])
    909 {
    910   $query = '
    911 SELECT rate
     846//------------------------------------------------------------------- rating
     847if ($conf['rate'])
     848{
     849  $query = 'SELECT COUNT(rate) AS count
     850     , ROUND(AVG(rate),2) AS average
     851     , ROUND(STD(rate),2) AS STD
    912852  FROM '.RATE_TABLE.'
    913   WHERE user_id = '.$user['id'].'
    914     AND element_id = '.$_GET['image_id'].'
     853  WHERE element_id = '.$picture['current']['id'].'
    915854;';
     855  $row = mysql_fetch_array(pwg_query($query));
     856  if ($row['count'] == 0)
     857  {
     858    $value = $lang['no_rate'];
     859  }
     860  else
     861  {
     862    $value = $row['average'];
     863    $value.= ' (';
     864    $value.= $row['count'].' '.$lang['rates'];
     865    $value.= ', '.$lang['standard_deviation'].' : '.$row['STD'];
     866    $value.= ')';
     867  }
     868 
     869  if (!$user['is_the_guest'])
     870  {
     871    $query = 'SELECT rate
     872    FROM '.RATE_TABLE.'
     873    WHERE user_id = '.$user['id'].'
     874    AND element_id = '.$_GET['image_id'].';';
    916875  $result = pwg_query($query);
    917876  if (mysql_num_rows($result) > 0)
     
    925884  {
    926885    $sentence = $lang['never_rated'].'. '.$lang['to_rate'];
    927   }
     886  } 
    928887  $template->assign_block_vars(
    929888    'rate',
    930     array('SENTENCE' => $sentence)
    931     );
    932  
     889    array(
     890      'INFO'  => $lang['element_rate'],
     891      'VALUE' => $value,
     892      'SENTENCE' => $sentence
     893      ));
    933894 
    934895  foreach ($rate_items as $num => $mark)
     
    954915        'SEPARATOR' => $separator
    955916        ));
    956   }
    957 }
     917    }
     918  }
     919}
     920
    958921//---------------------------------------------------- users's comments display
    959922if ($page['show_comments'])
Note: See TracChangeset for help on using the changeset viewer.