Skip to content

Commit

Permalink
- removed function get_extra_fields and its usage (unnecessary + perf…
Browse files Browse the repository at this point in the history
… 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

git-svn-id: http://piwigo.org/svn/trunk@6668 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
rvelices committed Jul 6, 2010
1 parent 804d79a commit 4748adc
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 32 deletions.
18 changes: 1 addition & 17 deletions include/functions.inc.php
Expand Up @@ -32,18 +32,6 @@
include_once( PHPWG_ROOT_PATH .'include/functions_plugins.inc.php' );

//----------------------------------------------------------- generic functions
function get_extra_fields($order_by_fields)
{
$fields = str_ireplace(array(' order by ', ' desc', ' asc'),
array('', '', ''),
$order_by_fields
);
if (!empty($fields))
{
$fields = ','.$fields;
}
return $fields;
}

// The function get_moment returns a float value coresponding to the number
// of seconds since the unix epoch (1st January 1970) and the microseconds
Expand Down Expand Up @@ -583,18 +571,14 @@ function redirect_html( $url , $msg = '', $refresh_time = 0)
{
global $user, $template, $lang_info, $conf, $lang, $t2, $page, $debug;

if (!isset($lang_info))
if (!isset($lang_info) || !isset($template) )
{
$user = build_user( $conf['guest_id'], true);
load_language('common.lang');
trigger_action('loading_lang');
load_language('lang', PHPWG_ROOT_PATH.'local/', array('no_fallback'=>true, 'local'=>true) );
$template = new Template(PHPWG_ROOT_PATH.'themes', get_default_theme());
}
else
{
$template = new Template(PHPWG_ROOT_PATH.'themes', $user['theme']);
}

if (empty($msg))
{
Expand Down
2 changes: 1 addition & 1 deletion include/functions_calendar.inc.php
Expand Up @@ -258,7 +258,7 @@ function initialize_calendar()

if ($must_show_list)
{
$query = 'SELECT DISTINCT id '.get_extra_fields($conf['order_by']);
$query = 'SELECT DISTINCT id ';
$query .= ','.$calendar->date_field;
$query .= $calendar->inner_sql.'
'.$calendar->get_date_where();
Expand Down
17 changes: 14 additions & 3 deletions include/functions_notification.inc.php
Expand Up @@ -79,7 +79,7 @@ function custom_notification_query($action, $type, $start, $end)
}
if (!empty($end))
{
$query .= '
$query .= '
AND c.validation_date <= \''.$end.'\'';
}
$query .= get_std_sql_where_restrict_filter('AND').'
Expand All @@ -94,7 +94,7 @@ function custom_notification_query($action, $type, $start, $end)
$query .= ' AND date> \''.$start.'\'';
}
if (!empty($end))
{
{
$query .= ' AND date <= \''.$end.'\'';
}
$query .= ' AND validated = \'false\'
Expand Down Expand Up @@ -619,9 +619,20 @@ function get_title_recent_post_date($date_detail)
$exploded_date = strptime($date, '%Y-%m-%d %H:%M:%S');

$title = l10n_dec('%d new image', '%d new images', $date_detail['nb_elements']);
$title .= ' ('.$lang['month'][(int)$exploded_date['tm_mon']].' '.$exploded_date['tm_mday'].')';
$title .= ' ('.$lang['month'][1+$exploded_date['tm_mon']].' '.$exploded_date['tm_mday'].')';

return $title;
}

if(!function_exists("strptime"))
{
function strptime($date, $fmt)
{
if ($fmt != '%Y-%m-%d %H:%M:%S')
die('Invalid strptime format '.$fmt);
list($y,$m,$d,$H,$M,$S) = preg_split('/[-: ]/', $date);
$res = localtime( mktime($H,$M,$S,$m,$d,$y), true );
return $res;
}
}
?>
8 changes: 4 additions & 4 deletions include/section_init.inc.php
Expand Up @@ -289,7 +289,7 @@

// Main query
$query = '
SELECT DISTINCT(image_id)'.get_extra_fields($conf['order_by']).'
SELECT DISTINCT(image_id)
FROM '.IMAGE_CATEGORY_TABLE.'
INNER JOIN '.IMAGES_TABLE.' ON id = image_id
WHERE
Expand Down Expand Up @@ -323,7 +323,7 @@
if (!empty($items) )
{
$query = '
SELECT DISTINCT image_id'.get_extra_fields($conf['order_by']).'
SELECT DISTINCT image_id
FROM '.IMAGE_CATEGORY_TABLE.' INNER JOIN '.IMAGES_TABLE.' ON image_id=id
WHERE image_id IN ('.implode(',', $items).')
'.$forbidden.
Expand Down Expand Up @@ -438,7 +438,7 @@
}

$query = '
SELECT DISTINCT(id)'.get_extra_fields($conf['order_by']).'
SELECT DISTINCT(id)
FROM '.IMAGES_TABLE.'
INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
WHERE
Expand Down Expand Up @@ -526,7 +526,7 @@
else if ($page['section'] == 'list')
{
$query ='
SELECT DISTINCT(id)'.get_extra_fields($conf['order_by']).'
SELECT DISTINCT(id)
FROM '.IMAGES_TABLE.'
INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
WHERE image_id IN ('.implode(',', $page['list']).')
Expand Down
2 changes: 1 addition & 1 deletion themes/default/template/comments.tpl
Expand Up @@ -2,7 +2,7 @@

<div class="titrePage">
<ul class="categoryActions">
<li><a href="{$U_HOME}" title="{'Home'|@translate}"><img src="{$themeconf.icon_dir}/home.png" class="button" alt="{'Home'|@translate}"></a></li>
<li><a href="{$U_HOME}" title="{'Home'|@translate}"><img src="{$ROOT_URL}{$themeconf.icon_dir}/home.png" class="button" alt="{'Home'|@translate}"></a></li>
</ul>
<h2>{'User comments'|@translate}</h2>
</div>
Expand Down
2 changes: 1 addition & 1 deletion themes/default/template/notification.tpl
Expand Up @@ -6,7 +6,7 @@

<div class="titrePage">
<ul class="categoryActions">
<li><a href="{$U_HOME}" title="{'Home'|@translate}"><img src="{$themeconf.icon_dir}/home.png" class="button" alt="{'Home'|@translate}"></a></li>
<li><a href="{$U_HOME}" title="{'Home'|@translate}"><img src="{$ROOT_URL}{$themeconf.icon_dir}/home.png" class="button" alt="{'Home'|@translate}"></a></li>
</ul>
<h2>{'Notification'|@translate}</h2>
</div>
Expand Down
2 changes: 1 addition & 1 deletion themes/default/template/password.tpl
Expand Up @@ -2,7 +2,7 @@

<div class="titrePage">
<ul class="categoryActions">
<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>
<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>
</ul>
<h2>{'Password forgotten'|@translate}</h2>
</div>
Expand Down
6 changes: 3 additions & 3 deletions themes/default/template/tags.tpl
Expand Up @@ -3,14 +3,14 @@
<div class="titrePage">
<ul class="categoryActions">
{if $display_mode == 'letters'}
<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>
<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>
{/if}

{if $display_mode == 'cloud'}
<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>
<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>
{/if}

<li><a href="{$U_HOME}" title="{'Home'|@translate}"><img src="{$themeconf.icon_dir}/home.png" class="button" alt="{'Home'|@translate}"></a></li>
<li><a href="{$U_HOME}" title="{'Home'|@translate}"><img src="{$ROOT_URL}{$themeconf.icon_dir}/home.png" class="button" alt="{'Home'|@translate}"></a></li>
</ul>
<h2>{'Tags'|@translate}</h2>
</div>
Expand Down
2 changes: 1 addition & 1 deletion themes/default/template/upload.tpl
Expand Up @@ -8,7 +8,7 @@

<div class="titrePage">
<ul class="categoryActions">
<li><a href="{$U_HOME}" title="{'Home'|@translate}"><img src="{$themeconf.icon_dir}/home.png" class="button" alt="{'Home'|@translate}"></a></li>
<li><a href="{$U_HOME}" title="{'Home'|@translate}"><img src="{$ROOT_URL}{$themeconf.icon_dir}/home.png" class="button" alt="{'Home'|@translate}"></a></li>
</ul>
<h2>{'Upload a picture'|@translate}</h2>
</div>
Expand Down

0 comments on commit 4748adc

Please sign in to comment.