Changeset 6668


Ignore:
Timestamp:
Jul 6, 2010, 10:10:03 PM (10 years ago)
Author:
rvelices
Message:
  • 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:
trunk
Files:
9 edited

Legend:

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

    r6385 r6668  
    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
  • trunk/include/functions_calendar.inc.php

    r6363 r6668  
    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.'
  • trunk/include/functions_notification.inc.php

    r6662 r6668  
    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?>
  • trunk/include/section_init.inc.php

    r6664 r6668  
    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).')
     
    439439
    440440    $query = '
    441 SELECT DISTINCT(id)'.get_extra_fields($conf['order_by']).'
     441SELECT DISTINCT(id)
    442442  FROM '.IMAGES_TABLE.'
    443443    INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
     
    527527  {
    528528    $query ='
    529 SELECT DISTINCT(id)'.get_extra_fields($conf['order_by']).'
     529SELECT DISTINCT(id)
    530530  FROM '.IMAGES_TABLE.'
    531531    INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
  • trunk/themes/default/template/comments.tpl

    r5164 r6668  
    33  <div class="titrePage">
    44    <ul class="categoryActions">
    5       <li><a href="{$U_HOME}" title="{'Home'|@translate}"><img src="{$themeconf.icon_dir}/home.png" class="button" alt="{'Home'|@translate}"></a></li>
     5      <li><a href="{$U_HOME}" title="{'Home'|@translate}"><img src="{$ROOT_URL}{$themeconf.icon_dir}/home.png" class="button" alt="{'Home'|@translate}"></a></li>
    66    </ul>
    77    <h2>{'User comments'|@translate}</h2>
  • trunk/themes/default/template/notification.tpl

    r5164 r6668  
    77  <div class="titrePage">
    88    <ul class="categoryActions">
    9       <li><a href="{$U_HOME}" title="{'Home'|@translate}"><img src="{$themeconf.icon_dir}/home.png" class="button" alt="{'Home'|@translate}"></a></li>
     9      <li><a href="{$U_HOME}" title="{'Home'|@translate}"><img src="{$ROOT_URL}{$themeconf.icon_dir}/home.png" class="button" alt="{'Home'|@translate}"></a></li>
    1010    </ul>
    1111    <h2>{'Notification'|@translate}</h2>
  • trunk/themes/default/template/password.tpl

    r5559 r6668  
    33  <div class="titrePage">
    44    <ul class="categoryActions">
    5       <li><a href="{$U_HOME}" title="{'Go through the gallery as a visitor'|@translate}"><img src="{$themeconf.icon_dir}/home.png" class="button" alt="{'Home'|@translate}"></a></li>
     5      <li><a href="{$U_HOME}" title="{'Go through the gallery as a visitor'|@translate}"><img src="{$ROOT_URL}{$themeconf.icon_dir}/home.png" class="button" alt="{'Home'|@translate}"></a></li>
    66    </ul>
    77    <h2>{'Password forgotten'|@translate}</h2>
  • trunk/themes/default/template/tags.tpl

    r5709 r6668  
    44                <ul class="categoryActions">
    55                {if $display_mode == 'letters'}
    6                         <li><a href="{$U_CLOUD}" title="{'show tag cloud'|@translate}" rel="nofollow"><img src="{$themeconf.icon_dir}/tag_cloud.png" class="button" alt="{'cloud'|@translate}"></a></li>
     6                        <li><a href="{$U_CLOUD}" title="{'show tag cloud'|@translate}" rel="nofollow"><img src="{$ROOT_URL}{$themeconf.icon_dir}/tag_cloud.png" class="button" alt="{'cloud'|@translate}"></a></li>
    77                {/if}
    88
    99                {if $display_mode == 'cloud'}
    10                         <li><a href="{$U_LETTERS}" title="{'group by letters'|@translate}" rel="nofollow"><img src="{$themeconf.icon_dir}/tag_letters.png" class="button" alt="{'letters'|@translate}"></a></li>
     10                        <li><a href="{$U_LETTERS}" title="{'group by letters'|@translate}" rel="nofollow"><img src="{$ROOT_URL}{$themeconf.icon_dir}/tag_letters.png" class="button" alt="{'letters'|@translate}"></a></li>
    1111                {/if}
    1212
    13                         <li><a href="{$U_HOME}" title="{'Home'|@translate}"><img src="{$themeconf.icon_dir}/home.png" class="button" alt="{'Home'|@translate}"></a></li>
     13                        <li><a href="{$U_HOME}" title="{'Home'|@translate}"><img src="{$ROOT_URL}{$themeconf.icon_dir}/home.png" class="button" alt="{'Home'|@translate}"></a></li>
    1414                </ul>
    1515                <h2>{'Tags'|@translate}</h2>
  • trunk/themes/default/template/upload.tpl

    r5164 r6668  
    99  <div class="titrePage">
    1010    <ul class="categoryActions">
    11       <li><a href="{$U_HOME}" title="{'Home'|@translate}"><img src="{$themeconf.icon_dir}/home.png" class="button" alt="{'Home'|@translate}"></a></li>
     11      <li><a href="{$U_HOME}" title="{'Home'|@translate}"><img src="{$ROOT_URL}{$themeconf.icon_dir}/home.png" class="button" alt="{'Home'|@translate}"></a></li>
    1212    </ul>
    1313    <h2>{'Upload a picture'|@translate}</h2>
Note: See TracChangeset for help on using the changeset viewer.