aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--admin/maintenance.php10
-rw-r--r--admin/themes/default/template/maintenance.tpl4
-rw-r--r--include/functions_category.inc.php28
-rw-r--r--include/functions_user.inc.php71
-rw-r--r--include/page_header.php33
-rw-r--r--include/ws_functions.inc.php36
-rw-r--r--picture.php12
-rw-r--r--themes/default/template/index.tpl3
-rw-r--r--themes/default/template/password.tpl2
-rw-r--r--themes/default/template/picture.tpl6
-rw-r--r--themes/default/template/register.tpl2
11 files changed, 94 insertions, 113 deletions
diff --git a/admin/maintenance.php b/admin/maintenance.php
index c8547a118..78c4d0a7d 100644
--- a/admin/maintenance.php
+++ b/admin/maintenance.php
@@ -142,7 +142,7 @@ DELETE
}
case 'derivatives':
{
- clear_derivative_cache();
+ clear_derivative_cache($_GET['type']);
break;
}
default :
@@ -159,6 +159,12 @@ $template->set_filenames(array('maintenance'=>'maintenance.tpl'));
$url_format = get_root_url().'admin.php?page=maintenance&action=%s&pwg_token='.get_pwg_token();
+$purge_urls[l10n('all')] = sprintf($url_format, 'derivatives').'&type=all';
+foreach(ImageStdParams::get_defined_type_map() as $params)
+{
+ $purge_urls[ l10n($params->type) ] = sprintf($url_format, 'derivatives').'&type='.$params->type;
+}
+
$template->assign(
array(
'U_MAINT_CATEGORIES' => sprintf($url_format, 'categories'),
@@ -173,10 +179,12 @@ $template->assign(
'U_MAINT_SEARCH' => sprintf($url_format, 'search'),
'U_MAINT_COMPILED_TEMPLATES' => sprintf($url_format, 'compiled-templates'),
'U_MAINT_DERIVATIVES' => sprintf($url_format, 'derivatives'),
+ 'purge_derivatives' => $purge_urls,
'U_HELP' => get_root_url().'admin/popuphelp.php?page=maintenance',
)
);
+
if ($conf['gallery_locked'])
{
$template->assign(
diff --git a/admin/themes/default/template/maintenance.tpl b/admin/themes/default/template/maintenance.tpl
index a7e0112a9..f55d10d2e 100644
--- a/admin/themes/default/template/maintenance.tpl
+++ b/admin/themes/default/template/maintenance.tpl
@@ -34,5 +34,7 @@
<li><a href="{$U_MAINT_FEEDS}">{'Purge never used notification feeds'|@translate}</a></li>
<li><a href="{$U_MAINT_SEARCH}"onclick="return confirm('{'Purge search history'|@translate|@escape:'javascript'}');">{'Purge search history'|@translate}</a></li>
<li><a href="{$U_MAINT_COMPILED_TEMPLATES}">{'Purge compiled templates'|@translate}</a></li>
- <li><a href="{$U_MAINT_DERIVATIVES}">{'Purge derivative image cache'|@translate}</a></li>
+ <li>{'Purge derivative image cache'|@translate}:
+ {foreach from=$purge_derivatives key=name item=url name=loop}{if !$smarty.foreach.loop.first}, {/if}<a href="{$url}">{$name}</a>{/foreach}
+ </li>
</ul>
diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php
index c37a9c266..5d66e75c5 100644
--- a/include/functions_category.inc.php
+++ b/include/functions_category.inc.php
@@ -485,33 +485,5 @@ SELECT image_id
return $image_id;
}
-/**
- * create a tree from a flat list of categories, no recursivity for high speed
- */
-function categories_flatlist_to_tree($categories)
-{
- $tree = array();
- $key_of_cat = array();
-
- foreach ($categories as $key => &$node)
- {
- $key_of_cat[$node['id']] = $key;
-
- if (!isset($node['id_uppercat']))
- {
- $tree[$key] = &$node;
- }
- else
- {
- if (!isset($categories[ $key_of_cat[ $node['id_uppercat'] ] ]['sub_categories']))
- {
- $categories[ $key_of_cat[ $node['id_uppercat'] ] ]['sub_categories'] = array();
- }
- $categories[ $key_of_cat[ $node['id_uppercat'] ] ]['sub_categories'][$key] = &$node;
- }
- }
-
- return $tree;
-}
?> \ No newline at end of file
diff --git a/include/functions_user.inc.php b/include/functions_user.inc.php
index 47fa9ab8f..9c25ed1d4 100644
--- a/include/functions_user.inc.php
+++ b/include/functions_user.inc.php
@@ -73,7 +73,7 @@ where upper('.$conf['user_fields']['email'].') = upper(\''.$mail_address.'\')
function validate_login_case($login)
{
global $conf;
-
+
if (defined("PHPWG_INSTALLED"))
{
$query = "
@@ -105,7 +105,7 @@ function search_case_username($username)
$username_lo = strtolower($username);
$SCU_users = array();
-
+
$q = pwg_query("
SELECT ".$conf['user_fields']['username']." AS username
FROM `".USERS_TABLE."`;
@@ -114,7 +114,7 @@ function search_case_username($username)
$SCU_users[$r['username']] = strtolower($r['username']);
// $SCU_users is now an associative table where the key is the account as
// registered in the DB, and the value is this same account, in lower case
-
+
$users_found = array_keys($SCU_users, $username_lo);
// $users_found is now a table of which the values are all the accounts
// which can be written in lowercase the same way as $username
@@ -130,28 +130,28 @@ function register_user($login, $password, $mail_address,
if ($login == '')
{
- array_push($errors, l10n('Please, enter a login'));
+ $errors[] = l10n('Please, enter a login');
}
if (preg_match('/^.* $/', $login))
{
- array_push($errors, l10n('login mustn\'t end with a space character'));
+ $errors[] = l10n('login mustn\'t end with a space character');
}
if (preg_match('/^ .*$/', $login))
{
- array_push($errors, l10n('login mustn\'t start with a space character'));
+ $errors[] = l10n('login mustn\'t start with a space character');
}
if (get_userid($login))
{
- array_push($errors, l10n('this login is already used'));
+ $errors[] = l10n('this login is already used');
}
if ($login != strip_tags($login))
{
- array_push($errors, l10n('html tags are not allowed in login'));
+ $errors[] = l10n('html tags are not allowed in login');
}
$mail_error = validate_mail_address(null, $mail_address);
if ('' != $mail_error)
{
- array_push($errors, $mail_error);
+ $errors[] = $mail_error;
}
if ($conf['insensitive_case_logon'] == true)
@@ -159,7 +159,7 @@ function register_user($login, $password, $mail_address,
$login_error = validate_login_case($login);
if ($login_error != '')
{
- array_push($errors, $login_error);
+ $errors[] = $login_error;
}
}
@@ -205,15 +205,10 @@ SELECT id
$inserts = array();
while ($row = pwg_db_fetch_assoc($result))
{
- array_push
- (
- $inserts,
- array
- (
+ $inserts[] = array(
'user_id' => $next_id,
'group_id' => $row['id']
- )
- );
+ );
}
}
@@ -400,7 +395,7 @@ SELECT DISTINCT(id)
if ( empty($forbidden_ids) )
{
- array_push( $forbidden_ids, 0 );
+ $forbidden_ids[] = 0;
}
$userdata['image_access_type'] = 'NOT IN'; //TODO maybe later
$userdata['image_access_list'] = implode(',',$forbidden_ids);
@@ -423,7 +418,7 @@ SELECT COUNT(DISTINCT(image_id)) as total
{
if ($cat['count_images']==0)
{
- array_push($forbidden_ids, $cat['cat_id']);
+ $forbidden_ids[] = $cat['cat_id'];
unset( $user_cache_cats[$cat['cat_id']] );
}
}
@@ -518,27 +513,16 @@ SELECT DISTINCT f.image_id
'AND'
).'
;';
- $result = pwg_query($query);
- $authorizeds = array();
- while ($row = pwg_db_fetch_assoc($result))
- {
- array_push($authorizeds, $row['image_id']);
- }
+ $authorizeds = array_from_query($query, 'image_id');
$query = '
SELECT image_id
FROM '.FAVORITES_TABLE.'
WHERE user_id = '.$user['id'].'
;';
- $result = pwg_query($query);
- $favorites = array();
- while ($row = pwg_db_fetch_assoc($result))
- {
- array_push($favorites, $row['image_id']);
- }
+ $favorites = array_from_query($query, 'image_id');
$to_deletes = array_diff($favorites, $authorizeds);
-
if (count($to_deletes) > 0)
{
$query = '
@@ -564,19 +548,12 @@ DELETE FROM '.FAVORITES_TABLE.'
*/
function calculate_permissions($user_id, $user_status)
{
- $private_array = array();
- $authorized_array = array();
-
$query = '
SELECT id
FROM '.CATEGORIES_TABLE.'
WHERE status = \'private\'
;';
- $result = pwg_query($query);
- while ($row = pwg_db_fetch_assoc($result))
- {
- array_push($private_array, $row['id']);
- }
+ $private_array = array_from_query($query, 'id');
// retrieve category ids directly authorized to the user
$query = '
@@ -617,7 +594,7 @@ SELECT id
$result = pwg_query($query);
while ($row = pwg_db_fetch_assoc($result))
{
- array_push($forbidden_array, $row['id']);
+ $forbidden_array[] = $row['id'];
}
$forbidden_array = array_unique($forbidden_array);
}
@@ -626,7 +603,7 @@ SELECT id
{// at least, the list contains 0 value. This category does not exists so
// where clauses such as "WHERE category_id NOT IN(0)" will always be
// true.
- array_push($forbidden_array, 0);
+ $forbidden_array[] = 0;
}
return implode(',', $forbidden_array);
@@ -809,7 +786,7 @@ function get_userid_by_email($email)
global $conf;
$email = pwg_db_real_escape_string($email);
-
+
$query = '
SELECT
'.$conf['user_fields']['id'].'
@@ -931,7 +908,7 @@ function get_default_theme()
{
return $theme;
}
-
+
// let's find the first available theme
$active_themes = get_pwg_themes();
foreach (array_keys(get_pwg_themes()) as $theme_id)
@@ -1158,7 +1135,7 @@ function try_log_user($username, $password, $remember_me)
{
// we force the session table to be clean
pwg_session_gc();
-
+
global $conf;
// retrieving the encrypted password of the login submitted
$query = '
@@ -1351,12 +1328,12 @@ function is_adviser()
function can_manage_comment($action, $comment_author_id)
{
global $user, $conf;
-
+
if (is_a_guest())
{
return false;
}
-
+
if (!in_array($action, array('delete','edit', 'validate')))
{
return false;
diff --git a/include/page_header.php b/include/page_header.php
index 3ed10fe47..e48740a01 100644
--- a/include/page_header.php
+++ b/include/page_header.php
@@ -66,7 +66,7 @@ if ( !empty($header_notes) )
}
// No referencing is required
-if ( !$conf['meta_ref'] )
+if ( !$conf['meta_ref'] )
{
$page['meta_robots']['noindex'] = 1;
$page['meta_robots']['nofollow'] = 1;
@@ -81,8 +81,8 @@ if ( !empty($page['meta_robots']) )
);
}
if ( !isset($page['meta_robots']['noindex']) )
-{
- $template->assign('meta_ref',1);
+{
+ $template->assign('meta_ref',1);
}
// refresh
@@ -97,23 +97,22 @@ if ( isset( $refresh ) and intval($refresh) >= 0
)
));
}
-
-
-// messages
-foreach (array('errors','infos') as $mode)
-{
- if (isset($_SESSION['page_'.$mode]))
+else
+{// messages only if no redirection
+ foreach (array('errors','infos') as $mode)
{
- $page[$mode] = array_merge($page[$mode], $_SESSION['page_'.$mode]);
- unset($_SESSION['page_'.$mode]);
- }
-
- if (count($page[$mode]) != 0)
- {
- $template->assign($mode, $page[$mode]);
+ if (isset($_SESSION['page_'.$mode]))
+ {
+ $page[$mode] = array_merge($page[$mode], $_SESSION['page_'.$mode]);
+ unset($_SESSION['page_'.$mode]);
+ }
+
+ if (count($page[$mode]) != 0)
+ {
+ $template->assign($mode, $page[$mode]);
+ }
}
}
-
trigger_action('loc_end_page_header');
header('Content-Type: text/html; charset='.get_pwg_charset());
diff --git a/include/ws_functions.inc.php b/include/ws_functions.inc.php
index 908eb6118..fa4fd5fb0 100644
--- a/include/ws_functions.inc.php
+++ b/include/ws_functions.inc.php
@@ -522,6 +522,36 @@ LIMIT '.(int)$params['per_page'].' OFFSET '.(int)($params['per_page']*$params['p
/**
+ * create a tree from a flat list of categories, no recursivity for high speed
+ */
+function categories_flatlist_to_tree($categories)
+{
+ $tree = array();
+ $key_of_cat = array();
+
+ foreach ($categories as $key => &$node)
+ {
+ $key_of_cat[$node['id']] = $key;
+
+ if (!isset($node['id_uppercat']))
+ {
+ $tree[$key] = &$node;
+ }
+ else
+ {
+ if (!isset($categories[ $key_of_cat[ $node['id_uppercat'] ] ]['sub_categories']))
+ {
+ $categories[ $key_of_cat[ $node['id_uppercat'] ] ]['sub_categories'] = array();
+ }
+
+ $categories[ $key_of_cat[ $node['id_uppercat'] ] ]['sub_categories'][$key] = &$node;
+ }
+ }
+
+ return $tree;
+}
+
+/**
* returns a list of categories (web service method)
*/
function ws_categories_getList($params, &$service)
@@ -1669,9 +1699,9 @@ SELECT
if ('file' == $params['type'])
{
$do_update = false;
-
+
$infos = pwg_image_infos($file_path);
-
+
foreach (array('width', 'height', 'filesize') as $image_info)
{
if ($infos[$image_info] > $image[$image_info])
@@ -1744,7 +1774,7 @@ SELECT
// pwg.images.addChunk. If "high" is available we use it as "original"
// else we use "file".
remove_chunks($params['original_sum'], 'thumb');
-
+
if (isset($params['high_sum']))
{
$original_type = 'high';
diff --git a/picture.php b/picture.php
index ee96083e8..f78c6d085 100644
--- a/picture.php
+++ b/picture.php
@@ -170,6 +170,8 @@ function default_picture_content($content, $element_info)
$added = array();
foreach($element_info['derivatives'] as $type => $derivative)
{
+ if ($type==IMG_SQUARE || $type==IMG_THUMB)
+ continue;
$url = $derivative->get_url();
if (isset($added[$url]))
continue;
@@ -805,15 +807,7 @@ if (isset($picture['current']['comment'])
// author
if (!empty($picture['current']['author']))
{
- $infos['INFO_AUTHOR'] =
-// FIXME because of search engine partial rewrite, giving the author
-// name threw GET is not supported anymore. This feature should come
-// back later, with a better design
-// '<a href="'.
-// PHPWG_ROOT_PATH.'category.php?cat=search'.
-// '&amp;search=author:'.$picture['current']['author']
-// .'">'.$picture['current']['author'].'</a>';
- $picture['current']['author'];
+ $infos['INFO_AUTHOR'] = $picture['current']['author'];
}
// creation date
diff --git a/themes/default/template/index.tpl b/themes/default/template/index.tpl
index c0c8c8002..519e1a732 100644
--- a/themes/default/template/index.tpl
+++ b/themes/default/template/index.tpl
@@ -131,8 +131,9 @@ function toggleImageDerivativesBox() {
</div>{* <!-- titrePage --> *}
+{if isset($errors) or not empty($infos)}
{include file='infos_errors.tpl'}
-
+{/if}
{if !empty($PLUGIN_INDEX_CONTENT_BEGIN)}{$PLUGIN_INDEX_CONTENT_BEGIN}{/if}
{if !empty($category_search_results)}
diff --git a/themes/default/template/password.tpl b/themes/default/template/password.tpl
index 2546adea2..eb78122e6 100644
--- a/themes/default/template/password.tpl
+++ b/themes/default/template/password.tpl
@@ -1,5 +1,5 @@
{if isset($MENUBAR)}{$MENUBAR}{/if}
-<div id="content" class="content">
+<div id="content" class="content{if isset($MENUBAR)} contentWithMenu{/if}">
<div class="titrePage">
<ul class="categoryActions">
<li>
diff --git a/themes/default/template/picture.tpl b/themes/default/template/picture.tpl
index ff9ad2729..b679d2ebb 100644
--- a/themes/default/template/picture.tpl
+++ b/themes/default/template/picture.tpl
@@ -1,14 +1,13 @@
{* Example of resizeable
{include file='include/autosize.inc.tpl'}
*}
-
{if isset($MENUBAR)}
{$MENUBAR}
<div id="content" class="contentWithMenu">
{/if}
-
+{if isset($errors) or not empty($infos)}
{include file='infos_errors.tpl'}
-
+{/if}
{if !empty($PLUGIN_PICTURE_BEFORE)}{$PLUGIN_PICTURE_BEFORE}{/if}
<div id="imageHeaderBar">
@@ -274,7 +273,6 @@ y.callService(
</div>
{if isset($COMMENT_COUNT)}
-<a name="comments"></a>
<div id="comments">
{if $COMMENT_COUNT > 0}
<h3>{$pwg->l10n_dec('%d comment', '%d comments',$COMMENT_COUNT)}</h3>
diff --git a/themes/default/template/register.tpl b/themes/default/template/register.tpl
index 525d53342..e1d25a2ad 100644
--- a/themes/default/template/register.tpl
+++ b/themes/default/template/register.tpl
@@ -1,7 +1,7 @@
{if isset($MENUBAR)}{$MENUBAR}{/if}
<div id="registerPage">
-<div id="content" class="content">
+<div id="content" class="content{if isset($MENUBAR)} contentWithMenu{/if}">
<div class="titrePage">
<ul class="categoryActions">