- 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 ) git-svn-id: http://piwigo.org/svn/trunk@3126 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
parent
e71d84ebfb
commit
e34c68cb89
5 changed files with 49 additions and 57 deletions
|
|
@ -27,8 +27,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
$page['rank_of'] = array_flip($page['items']);
|
||||
|
||||
$pictures = array();
|
||||
|
||||
$selection = array_slice(
|
||||
|
|
@ -39,6 +37,8 @@ $selection = array_slice(
|
|||
|
||||
if (count($selection) > 0)
|
||||
{
|
||||
$rank_of = array_flip($page['items']);
|
||||
|
||||
$query = '
|
||||
SELECT *
|
||||
FROM '.IMAGES_TABLE.'
|
||||
|
|
@ -53,6 +53,7 @@ SELECT *
|
|||
}
|
||||
|
||||
usort($pictures, 'rank_compare');
|
||||
unset($rank_of);
|
||||
}
|
||||
|
||||
if (count($pictures) > 0)
|
||||
|
|
|
|||
|
|
@ -233,7 +233,10 @@ if (isset($conf['header_notes']))
|
|||
|
||||
// default event handlers
|
||||
add_event_handler('render_category_literal_description', 'render_category_literal_description');
|
||||
add_event_handler('render_category_description', 'render_category_description');
|
||||
if ( !$conf['allow_html_descriptions'] )
|
||||
{
|
||||
add_event_handler('render_category_description', 'nl2br');
|
||||
}
|
||||
add_event_handler('render_comment_content', 'htmlspecialchars');
|
||||
add_event_handler('render_comment_content', 'parse_comment_content');
|
||||
add_event_handler('render_comment_author', 'strip_tags');
|
||||
|
|
|
|||
|
|
@ -23,32 +23,32 @@
|
|||
|
||||
function get_icon($date, $is_child_date = false)
|
||||
{
|
||||
global $page, $user;
|
||||
global $cache, $user;
|
||||
|
||||
if (empty($date))
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
if (isset($page['get_icon_cache'][$date]))
|
||||
if (isset($cache['get_icon'][$date]))
|
||||
{
|
||||
if (! $page['get_icon_cache'][$date] )
|
||||
if (! $cache['get_icon'][$date] )
|
||||
return '';
|
||||
return $page['get_icon_cache']['_icons_'][$is_child_date];
|
||||
return $cache['get_icon']['_icons_'][$is_child_date];
|
||||
}
|
||||
|
||||
if (!isset($page['get_icon_cache']['sql_recent_date']))
|
||||
if (!isset($cache['get_icon']['sql_recent_date']))
|
||||
{
|
||||
// Use MySql date in order to standardize all recent "actions/queries"
|
||||
list($page['get_icon_cache']['sql_recent_date']) =
|
||||
list($cache['get_icon']['sql_recent_date']) =
|
||||
mysql_fetch_array(pwg_query('select SUBDATE(
|
||||
CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY)'));
|
||||
}
|
||||
|
||||
$page['get_icon_cache'][$date] = false;
|
||||
if ( $date > $page['get_icon_cache']['sql_recent_date'] )
|
||||
$cache['get_icon'][$date] = false;
|
||||
if ( $date > $cache['get_icon']['sql_recent_date'] )
|
||||
{
|
||||
if ( !isset($page['get_icon_cache']['_icons_'] ) )
|
||||
if ( !isset($cache['get_icon']['_icons_'] ) )
|
||||
{
|
||||
$icons = array(false => 'recent', true => 'recent_by_child' );
|
||||
$title = sprintf(
|
||||
|
|
@ -62,15 +62,15 @@ function get_icon($date, $is_child_date = false)
|
|||
$icon_url = get_root_url().$icon_url;
|
||||
$output = '<img title="'.$title.'" src="'.$icon_url.'" class="icon" style="border:0;';
|
||||
$output.= 'height:'.$size[1].'px;width:'.$size[0].'px" alt="(!)" />';
|
||||
$page['get_icon_cache']['_icons_'][$key] = $output;
|
||||
$cache['get_icon']['_icons_'][$key] = $output;
|
||||
}
|
||||
}
|
||||
$page['get_icon_cache'][$date] = true;
|
||||
$cache['get_icon'][$date] = true;
|
||||
}
|
||||
|
||||
if (! $page['get_icon_cache'][$date] )
|
||||
if (! $cache['get_icon'][$date] )
|
||||
return '';
|
||||
return $page['get_icon_cache']['_icons_'][$is_child_date];
|
||||
return $cache['get_icon']['_icons_'][$is_child_date];
|
||||
}
|
||||
|
||||
function create_navigation_bar(
|
||||
|
|
@ -776,19 +776,6 @@ function set_status_header($code, $text='')
|
|||
trigger_action('set_status_header', $code, $text);
|
||||
}
|
||||
|
||||
/** returns the category comment for rendering in html.
|
||||
* this is an event handler. don't call directly
|
||||
*/
|
||||
function render_category_description($desc)
|
||||
{
|
||||
global $conf;
|
||||
if ( !$conf['allow_html_descriptions'] )
|
||||
{
|
||||
$desc = nl2br($desc);
|
||||
}
|
||||
return $desc;
|
||||
}
|
||||
|
||||
/** returns the category comment for rendering in html textual mode (subcatify)
|
||||
* this is an event handler. don't call directly
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ function get_root_url()
|
|||
{// TODO - add HERE the possibility to call PWG functions from external scripts
|
||||
$root_url = PHPWG_ROOT_PATH;
|
||||
}
|
||||
if ( dirname($root_url)!='.' )
|
||||
if ( strncmp($root_url, './', 2) != 0 )
|
||||
{
|
||||
return $root_url;
|
||||
}
|
||||
|
|
@ -170,21 +170,11 @@ function params_for_duplication($redefined, $removed)
|
|||
{
|
||||
global $page;
|
||||
|
||||
if (count($removed) > 0)
|
||||
{
|
||||
$params = array();
|
||||
|
||||
foreach ($page as $page_item_key => $page_item_value)
|
||||
{
|
||||
if (!in_array($page_item_key, $removed))
|
||||
{
|
||||
$params[$page_item_key] = $page_item_value;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$params = $page;
|
||||
|
||||
foreach ($removed as $param_key)
|
||||
{
|
||||
unset($params[$param_key]);
|
||||
}
|
||||
|
||||
foreach ($redefined as $redefined_param => $redefined_value)
|
||||
|
|
@ -722,7 +712,18 @@ function unset_make_full_url()
|
|||
*/
|
||||
function embellish_url($url)
|
||||
{
|
||||
return str_replace('/./', '/', $url);
|
||||
$url = str_replace('/./', '/', $url);
|
||||
while ( ($dotdot = strpos($url, '/../', 1) ) !== false )
|
||||
{
|
||||
$before = strrpos($url, '/', -(strlen($url)-$dotdot+1) );
|
||||
if ($before !== false)
|
||||
{
|
||||
$url = substr_replace($url, '', $before, $dotdot-$before+3);
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -760,28 +760,28 @@ SELECT COUNT(*)
|
|||
*/
|
||||
function get_default_user_info($convert_str = true)
|
||||
{
|
||||
global $page, $conf;
|
||||
global $cache, $conf;
|
||||
|
||||
if (!isset($page['cache_default_user']))
|
||||
if (!isset($cache['default_user']))
|
||||
{
|
||||
$query = 'select * from '.USER_INFOS_TABLE.
|
||||
' where user_id = '.$conf['default_user_id'].';';
|
||||
$query = 'SELECT * FROM '.USER_INFOS_TABLE.
|
||||
' WHERE user_id = '.$conf['default_user_id'].';';
|
||||
|
||||
$result = pwg_query($query);
|
||||
$page['cache_default_user'] = mysql_fetch_assoc($result);
|
||||
$cache['default_user'] = mysql_fetch_assoc($result);
|
||||
|
||||
if ($page['cache_default_user'] !== false)
|
||||
if ($cache['default_user'] !== false)
|
||||
{
|
||||
unset($page['cache_default_user']['user_id']);
|
||||
unset($page['cache_default_user']['status']);
|
||||
unset($page['cache_default_user']['registration_date']);
|
||||
unset($cache['default_user']['user_id']);
|
||||
unset($cache['default_user']['status']);
|
||||
unset($cache['default_user']['registration_date']);
|
||||
}
|
||||
}
|
||||
|
||||
if (is_array($page['cache_default_user']) and $convert_str)
|
||||
if (is_array($cache['default_user']) and $convert_str)
|
||||
{
|
||||
$default_user = array();
|
||||
foreach ($page['cache_default_user'] as $name => $value)
|
||||
foreach ($cache['default_user'] as $name => $value)
|
||||
{
|
||||
// If the field is true or false, the variable is transformed into a
|
||||
// boolean value.
|
||||
|
|
@ -798,7 +798,7 @@ function get_default_user_info($convert_str = true)
|
|||
}
|
||||
else
|
||||
{
|
||||
return $page['cache_default_user'];
|
||||
return $cache['default_user'];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue