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/include/functions.inc.php

    r537 r579  
    547547  return get_dirs(PHPWG_ROOT_PATH.'template');
    548548}
     549
     550/**
     551 * returns thumbnail filepath (or distant URL if thumbnail is remote) for a
     552 * given element
     553 *
     554 * this function could have taken only the element id as parameter but to
     555 * optimize database access we directly ask file, storage category
     556 * identifier and extension since when this function is called,
     557 * PhpWebGallery should have all these infos. No need to retrieve them
     558 * another time in the database.
     559 *
     560 * the returned string can represente the filepath of the thumbnail or the
     561 * filepath to the corresponding icon for non picture elements
     562 *
     563 * complete directories are cached to be used more than once during a page
     564 * generation (many thumbnails of the same category on the same page)
     565 *
     566 * @param string file
     567 * @param int storage_category_id
     568 * @param string tn_ext
     569 * @return string
     570 */
     571function get_thumbnail_src($file, $storage_category_id, $tn_ext = '')
     572{
     573  global $conf, $user, $array_cat_directories;
     574 
     575  if (!isset($array_cat_directories[$storage_category_id]))
     576  {
     577    $array_cat_directories[$storage_category_id] =
     578      get_complete_dir($storage_category_id);
     579  }
     580 
     581  if ($tn_ext != '')
     582  {
     583    $src = $array_cat_directories[$storage_category_id];
     584    $src.= 'thumbnail/'.$conf['prefix_thumbnail'];
     585    $src.= get_filename_wo_extension($file);
     586    $src.= '.'.$tn_ext;
     587  }
     588  else
     589  {
     590    $src = PHPWG_ROOT_PATH;
     591    $src.= 'template/'.$user['template'].'/mimetypes/';
     592    $src.= strtolower(get_extension($file)).'.png';
     593  }
     594
     595  return $src;
     596}
    549597?>
Note: See TracChangeset for help on using the changeset viewer.