Changeset 3188 for trunk/include


Ignore:
Timestamp:
Mar 11, 2009, 6:25:26 PM (15 years ago)
Author:
patdenice
Message:

Move get_icon function.

Location:
trunk/include
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/category_cats.inc.php

    r3185 r3188  
    245245          'TN_SRC'   => $thumbnail_src_of[$category['representative_picture_id']],
    246246          'TN_ALT'   => strip_tags($category['name']),
    247           'ICON_TS'  => get_icon($category['max_date_last'], $category['is_child_date_last']),
     247          'icon_ts'  => get_icon($category['max_date_last'], $category['is_child_date_last']),
    248248
    249249          'URL'   => make_index_url(
  • trunk/include/category_default.inc.php

    r3136 r3188  
    111111      'TN_ALT'    => $row['file'],
    112112      'TN_TITLE'  => get_thumbnail_title($row),
    113       'ICON_TS'   => get_icon($row['date_available']),
     113      'icon_ts'   => get_icon($row['date_available']),
    114114      'URL'       => $url,
    115115
  • trunk/include/functions.inc.php

    r3173 r3188  
    15491549  return $navbar;
    15501550}
     1551
     1552/**
     1553 * return an array which will be sent to template to display recent icon
     1554 */
     1555function get_icon($date, $is_child_date = false)
     1556{
     1557  global $cache, $user;
     1558
     1559  if (empty($date))
     1560  {
     1561    return false;
     1562  }
     1563
     1564  if (!isset($cache['get_icon']['title']))
     1565  {
     1566    $cache['get_icon']['title'] = sprintf(
     1567      l10n('elements posted during the last %d days'),
     1568      $user['recent_period']
     1569      );
     1570  }
     1571
     1572  $icon = array(
     1573    'TITLE' => $cache['get_icon']['title'],
     1574    'IS_CHILD_DATE' => $is_child_date,
     1575    );
     1576
     1577  if (isset($cache['get_icon'][$date]))
     1578  {
     1579    return $cache['get_icon'][$date] ? $icon : array();
     1580  }
     1581
     1582  if (!isset($cache['get_icon']['sql_recent_date']))
     1583  {
     1584    // Use MySql date in order to standardize all recent "actions/queries"
     1585    list($cache['get_icon']['sql_recent_date']) =
     1586      mysql_fetch_array(pwg_query('select SUBDATE(
     1587      CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY)'));
     1588  }
     1589
     1590  $cache['get_icon'][$date] = $date > $cache['get_icon']['sql_recent_date'];
     1591
     1592  return $cache['get_icon'][$date] ? $icon : array();
     1593}
    15511594?>
  • trunk/include/functions_category.inc.php

    r3171 r3188  
    121121        'URL' => make_index_url(array('category' => $row)),
    122122        'LEVEL' => substr_count($row['global_rank'], '.') + 1,
    123         'ICON_TS' => get_icon($row['max_date_last'], $child_date_last),
     123        'icon_ts' => get_icon($row['max_date_last'], $child_date_last),
    124124        'SELECTED' => $selected_category['id'] == $row['id'] ? true : false,
    125125        'IS_UPPERCAT' => $selected_category['id_uppercat'] == $row['id'] ? true : false,
  • trunk/include/functions_html.inc.php

    r3185 r3188  
    2222// +-----------------------------------------------------------------------+
    2323
    24 function get_icon($date, $is_child_date = false)
    25 {
    26   global $cache, $user;
    27 
    28   if (empty($date))
    29   {
    30     return '';
    31   }
    32 
    33   if (isset($cache['get_icon'][$date]))
    34   {
    35     if (! $cache['get_icon'][$date] )
    36       return '';
    37     return $cache['get_icon']['_icons_'][$is_child_date];
    38   }
    39 
    40   if (!isset($cache['get_icon']['sql_recent_date']))
    41   {
    42     // Use MySql date in order to standardize all recent "actions/queries"
    43     list($cache['get_icon']['sql_recent_date']) =
    44       mysql_fetch_array(pwg_query('select SUBDATE(
    45       CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY)'));
    46   }
    47 
    48   $cache['get_icon'][$date] = false;
    49   if ( $date > $cache['get_icon']['sql_recent_date'] )
    50   {
    51     if ( !isset($cache['get_icon']['_icons_'] ) )
    52     {
    53       $icons = array(false => 'recent', true => 'recent_by_child' );
    54       $title = sprintf(
    55         l10n('elements posted during the last %d days'),
    56         $user['recent_period']
    57         );
    58       foreach ($icons as $key => $icon)
    59       {
    60         $icon_url = get_themeconf('icon_dir').'/'.$icon.'.png';
    61         $size = getimagesize( PHPWG_ROOT_PATH.$icon_url );
    62         $icon_url = get_root_url().$icon_url;
    63         $output = '<img title="'.$title.'" src="'.$icon_url.'" class="icon" style="border:0;';
    64         $output.= 'height:'.$size[1].'px;width:'.$size[0].'px" alt="(!)">';
    65         $cache['get_icon']['_icons_'][$key] = $output;
    66       }
    67     }
    68     $cache['get_icon'][$date] = true;
    69   }
    70 
    71   if (! $cache['get_icon'][$date] )
    72     return '';
    73   return $cache['get_icon']['_icons_'][$is_child_date];
    74 }
    75 
    7624/**
    7725 * returns the list of categories as a HTML string
Note: See TracChangeset for help on using the changeset viewer.