Changeset 6669 for branches/2.1/include


Ignore:
Timestamp:
Jul 6, 2010, 10:11:06 PM (14 years ago)
Author:
rvelices
Message:

merge r6668 from trunk

  • removed function get_extra_fields and its usage (unnecessary + perf issue when retrieving many image ids in a section)
  • 2 fixes recent feed.php commit
    • month names were decalated by one
    • strptime function is not implemented under Windows in php
  • added somme missing $ROOT_URL in templates
Location:
branches/2.1/include
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/2.1/include/functions.inc.php

    r6384 r6669  
    3333
    3434//----------------------------------------------------------- generic functions
    35 function get_extra_fields($order_by_fields)
    36 {
    37   $fields = str_ireplace(array(' order by ', ' desc', ' asc'),
    38                          array('', '', ''),
    39                          $order_by_fields
    40                          );
    41   if (!empty($fields))
    42   {
    43     $fields = ','.$fields;
    44   }
    45   return $fields;
    46 }
    4735
    4836// The function get_moment returns a float value coresponding to the number
     
    584572  global $user, $template, $lang_info, $conf, $lang, $t2, $page, $debug;
    585573
    586   if (!isset($lang_info))
     574  if (!isset($lang_info) || !isset($template) )
    587575  {
    588576    $user = build_user( $conf['guest_id'], true);
     
    591579    load_language('lang', PHPWG_ROOT_PATH.'local/', array('no_fallback'=>true, 'local'=>true) );
    592580    $template = new Template(PHPWG_ROOT_PATH.'themes', get_default_theme());
    593   }
    594   else
    595   {
    596     $template = new Template(PHPWG_ROOT_PATH.'themes', $user['theme']);
    597581  }
    598582
  • branches/2.1/include/functions_calendar.inc.php

    r6364 r6669  
    259259  if ($must_show_list)
    260260  {
    261     $query = 'SELECT DISTINCT id '.get_extra_fields($conf['order_by']);
     261    $query = 'SELECT DISTINCT id ';
    262262    $query .= ','.$calendar->date_field;
    263263    $query .= $calendar->inner_sql.'
  • branches/2.1/include/functions_notification.inc.php

    r6663 r6669  
    8080      if (!empty($end))
    8181      {
    82         $query .= '     
     82        $query .= '
    8383    AND c.validation_date <= \''.$end.'\'';
    8484      }
     
    9595      }
    9696      if (!empty($end))
    97       {     
     97      {
    9898        $query .= ' AND date <= \''.$end.'\'';
    9999      }
     
    620620
    621621  $title = l10n_dec('%d new image', '%d new images', $date_detail['nb_elements']);
    622   $title .= ' ('.$lang['month'][(int)$exploded_date['tm_mon']].' '.$exploded_date['tm_mday'].')';
     622  $title .= ' ('.$lang['month'][1+$exploded_date['tm_mon']].' '.$exploded_date['tm_mday'].')';
    623623
    624624  return $title;
    625625}
    626626
     627if(!function_exists("strptime"))
     628{
     629                function strptime($date, $fmt)
     630                {
     631                        if ($fmt != '%Y-%m-%d %H:%M:%S')
     632                                die('Invalid strptime format '.$fmt);
     633                        list($y,$m,$d,$H,$M,$S) = preg_split('/[-: ]/', $date);
     634                        $res = localtime( mktime($H,$M,$S,$m,$d,$y), true );
     635                        return $res;
     636                }
     637 }
    627638?>
  • branches/2.1/include/section_init.inc.php

    r6665 r6669  
    290290    // Main query
    291291    $query = '
    292 SELECT DISTINCT(image_id)'.get_extra_fields($conf['order_by']).'
     292SELECT DISTINCT(image_id)
    293293  FROM '.IMAGE_CATEGORY_TABLE.'
    294294    INNER JOIN '.IMAGES_TABLE.' ON id = image_id
     
    324324    {
    325325      $query = '
    326 SELECT DISTINCT image_id'.get_extra_fields($conf['order_by']).'
     326SELECT DISTINCT image_id
    327327  FROM '.IMAGE_CATEGORY_TABLE.' INNER JOIN '.IMAGES_TABLE.' ON image_id=id
    328328  WHERE image_id IN ('.implode(',', $items).')
     
    441441
    442442    $query = '
    443 SELECT DISTINCT(id)'.get_extra_fields($conf['order_by']).'
     443SELECT DISTINCT(id)
    444444  FROM '.IMAGES_TABLE.'
    445445    INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
     
    529529  {
    530530    $query ='
    531 SELECT DISTINCT(id)'.get_extra_fields($conf['order_by']).'
     531SELECT DISTINCT(id)
    532532  FROM '.IMAGES_TABLE.'
    533533    INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
Note: See TracChangeset for help on using the changeset viewer.