Changeset 3126 for trunk/include


Ignore:
Timestamp:
Feb 5, 2009, 4:03:30 AM (16 years ago)
Author:
rvelices
Message:
  • embellish_url compacts now ..
  • some trigger improvements (render_category_description)
  • improved perf of duplicate_xxx_url ( rewrote func params_for_duplication and remove some vars from $page )
Location:
trunk/include
Files:
5 edited

Legend:

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

    r3124 r3126  
    2828 */
    2929
    30 $page['rank_of'] = array_flip($page['items']);
    31 
    3230$pictures = array();
    3331
     
    4038if (count($selection) > 0)
    4139{
     40  $rank_of = array_flip($page['items']);
     41
    4242  $query = '
    4343SELECT *
     
    5454
    5555  usort($pictures, 'rank_compare');
     56  unset($rank_of);
    5657}
    5758
  • trunk/include/common.inc.php

    r3049 r3126  
    234234// default event handlers
    235235add_event_handler('render_category_literal_description', 'render_category_literal_description');
    236 add_event_handler('render_category_description', 'render_category_description');
     236if ( !$conf['allow_html_descriptions'] )
     237{
     238  add_event_handler('render_category_description', 'nl2br');
     239}
    237240add_event_handler('render_comment_content', 'htmlspecialchars');
    238241add_event_handler('render_comment_content', 'parse_comment_content');
  • trunk/include/functions_html.inc.php

    r3049 r3126  
    2424function get_icon($date, $is_child_date = false)
    2525{
    26   global $page, $user;
     26  global $cache, $user;
    2727
    2828  if (empty($date))
     
    3131  }
    3232
    33   if (isset($page['get_icon_cache'][$date]))
    34   {
    35     if (! $page['get_icon_cache'][$date] )
     33  if (isset($cache['get_icon'][$date]))
     34  {
     35    if (! $cache['get_icon'][$date] )
    3636      return '';
    37     return $page['get_icon_cache']['_icons_'][$is_child_date];
    38   }
    39 
    40   if (!isset($page['get_icon_cache']['sql_recent_date']))
     37    return $cache['get_icon']['_icons_'][$is_child_date];
     38  }
     39
     40  if (!isset($cache['get_icon']['sql_recent_date']))
    4141  {
    4242    // Use MySql date in order to standardize all recent "actions/queries"
    43     list($page['get_icon_cache']['sql_recent_date']) =
     43    list($cache['get_icon']['sql_recent_date']) =
    4444      mysql_fetch_array(pwg_query('select SUBDATE(
    4545      CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY)'));
    4646  }
    4747
    48   $page['get_icon_cache'][$date] = false;
    49   if ( $date > $page['get_icon_cache']['sql_recent_date'] )
    50   {
    51     if ( !isset($page['get_icon_cache']['_icons_'] ) )
     48  $cache['get_icon'][$date] = false;
     49  if ( $date > $cache['get_icon']['sql_recent_date'] )
     50  {
     51    if ( !isset($cache['get_icon']['_icons_'] ) )
    5252    {
    5353      $icons = array(false => 'recent', true => 'recent_by_child' );
     
    6363        $output = '<img title="'.$title.'" src="'.$icon_url.'" class="icon" style="border:0;';
    6464        $output.= 'height:'.$size[1].'px;width:'.$size[0].'px" alt="(!)" />';
    65         $page['get_icon_cache']['_icons_'][$key] = $output;
     65        $cache['get_icon']['_icons_'][$key] = $output;
    6666      }
    6767    }
    68     $page['get_icon_cache'][$date] = true;
    69   }
    70 
    71   if (! $page['get_icon_cache'][$date] )
     68    $cache['get_icon'][$date] = true;
     69  }
     70
     71  if (! $cache['get_icon'][$date] )
    7272    return '';
    73   return $page['get_icon_cache']['_icons_'][$is_child_date];
     73  return $cache['get_icon']['_icons_'][$is_child_date];
    7474}
    7575
     
    777777}
    778778
    779 /** returns the category comment for rendering in html.
    780  * this is an event handler. don't call directly
    781  */
    782 function render_category_description($desc)
    783 {
    784   global $conf;
    785   if ( !$conf['allow_html_descriptions'] )
    786   {
    787     $desc = nl2br($desc);
    788   }
    789   return $desc;
    790 }
    791 
    792779/** returns the category comment for rendering in html textual mode (subcatify)
    793780 * this is an event handler. don't call directly
  • trunk/include/functions_url.inc.php

    r3049 r3126  
    3939    $root_url = PHPWG_ROOT_PATH;
    4040  }
    41   if ( dirname($root_url)!='.' )
     41  if ( strncmp($root_url, './', 2) != 0 )
    4242  {
    4343    return $root_url;
     
    171171  global $page;
    172172
    173   if (count($removed) > 0)
    174   {
    175     $params = array();
    176 
    177     foreach ($page as $page_item_key => $page_item_value)
    178     {
    179       if (!in_array($page_item_key, $removed))
    180       {
    181         $params[$page_item_key] = $page_item_value;
    182       }
    183     }
    184   }
    185   else
    186   {
    187     $params = $page;
     173  $params = $page;
     174
     175  foreach ($removed as $param_key)
     176  {
     177    unset($params[$param_key]);
    188178  }
    189179
     
    723713function embellish_url($url)
    724714{
    725   return str_replace('/./', '/', $url);
     715  $url = str_replace('/./', '/', $url);
     716  while ( ($dotdot = strpos($url, '/../', 1) ) !== false )
     717  {
     718    $before = strrpos($url, '/', -(strlen($url)-$dotdot+1) );
     719    if ($before !== false)
     720    {
     721      $url = substr_replace($url, '', $before, $dotdot-$before+3);
     722    }
     723    else
     724      break;
     725  }
     726  return $url;
    726727}
    727728
  • trunk/include/functions_user.inc.php

    r3049 r3126  
    761761function get_default_user_info($convert_str = true)
    762762{
    763   global $page, $conf;
    764 
    765   if (!isset($page['cache_default_user']))
    766   {
    767     $query = 'select * from '.USER_INFOS_TABLE.
    768             ' where user_id = '.$conf['default_user_id'].';';
     763  global $cache, $conf;
     764
     765  if (!isset($cache['default_user']))
     766  {
     767    $query = 'SELECT * FROM '.USER_INFOS_TABLE.
     768            ' WHERE user_id = '.$conf['default_user_id'].';';
    769769
    770770    $result = pwg_query($query);
    771     $page['cache_default_user'] = mysql_fetch_assoc($result);
    772 
    773     if ($page['cache_default_user'] !== false)
    774     {
    775       unset($page['cache_default_user']['user_id']);
    776       unset($page['cache_default_user']['status']);
    777       unset($page['cache_default_user']['registration_date']);
    778     }
    779   }
    780 
    781   if (is_array($page['cache_default_user']) and $convert_str)
     771    $cache['default_user'] = mysql_fetch_assoc($result);
     772
     773    if ($cache['default_user'] !== false)
     774    {
     775      unset($cache['default_user']['user_id']);
     776      unset($cache['default_user']['status']);
     777      unset($cache['default_user']['registration_date']);
     778    }
     779  }
     780
     781  if (is_array($cache['default_user']) and $convert_str)
    782782  {
    783783    $default_user = array();
    784     foreach ($page['cache_default_user'] as $name => $value)
     784    foreach ($cache['default_user'] as $name => $value)
    785785    {
    786786      // If the field is true or false, the variable is transformed into a
     
    799799  else
    800800  {
    801     return $page['cache_default_user'];
     801    return $cache['default_user'];
    802802  }
    803803}
Note: See TracChangeset for help on using the changeset viewer.