aboutsummaryrefslogtreecommitdiffstats
path: root/admin
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2008-03-03 12:50:54 +0000
committerrvelices <rv-github@modusoptimus.com>2008-03-03 12:50:54 +0000
commit7688a7cbb6c4906f70d87b56cd6e90d028e99666 (patch)
treee197ac0fef76f918e100ae1e45c582309d3e99d8 /admin
parent14bfa8a3e6e5fa81fa3eba565a1b696840f351cd (diff)
- history, stats and redirect go smarty
- lang correction - small change in calling check_server_plugins (use by ref param instead of global) git-svn-id: http://piwigo.org/svn/trunk@2245 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--admin/history.php172
-rw-r--r--admin/include/functions_plugins.inc.php13
-rw-r--r--admin/plugins_new.php30
-rw-r--r--admin/plugins_update.php28
-rw-r--r--admin/stats.php18
5 files changed, 100 insertions, 161 deletions
diff --git a/admin/history.php b/admin/history.php
index 5c2264384..fe8914f5d 100644
--- a/admin/history.php
+++ b/admin/history.php
@@ -2,7 +2,7 @@
// +-----------------------------------------------------------------------+
// | PhpWebGallery - a PHP based picture gallery |
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
-// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
+// | Copyright (C) 2003-2008 PhpWebGallery Team - http://phpwebgallery.net |
// +-----------------------------------------------------------------------+
// | file : $Id$
// | last update : $Date$
@@ -107,7 +107,7 @@ if (isset($_POST['submit']))
{
$search['fields']['image_id'] = intval($_POST['image_id']);
}
-
+
if (!empty($_POST['filename']))
{
$search['fields']['filename'] = str_replace(
@@ -123,9 +123,9 @@ if (isset($_POST['submit']))
// TODO manage inconsistency of having $_POST['image_id'] and
// $_POST['filename'] simultaneously
-
+
// echo '<pre>'; print_r($search); echo '</pre>';
-
+
if (!empty($search))
{
// register search rules in database, then they will be available on
@@ -139,7 +139,7 @@ INSERT INTO '.SEARCH_TABLE.'
pwg_query($query);
$search_id = mysql_insert_id();
-
+
redirect(
PHPWG_ROOT_PATH.'admin.php?page=history&search_id='.$search_id
);
@@ -159,21 +159,10 @@ $template->set_filename('history', 'admin/history.tpl');
// TabSheet initialization
history_tabsheet();
-$base_url = PHPWG_ROOT_PATH.'admin.php?page=history';
-
-$template->assign_vars(
+$template->assign(
array(
'U_HELP' => PHPWG_ROOT_PATH.'popuphelp.php?page=history',
-
- 'F_ACTION' => PHPWG_ROOT_PATH.'admin.php?page=history'
- )
- );
-
-$template->assign_vars(
- array(
- 'TODAY_DAY' => date('d', time()),
- 'TODAY_MONTH' => date('m', time()),
- 'TODAY_YEAR' => date('Y', time()),
+ 'F_ACTION' => get_root_url().'admin.php?page=history'
)
);
@@ -212,7 +201,7 @@ INSERT INTO '.SEARCH_TABLE.'
pwg_query($query);
$search_id = mysql_insert_id();
-
+
redirect(
PHPWG_ROOT_PATH.'admin.php?page=history&search_id='.$search_id
);
@@ -286,7 +275,7 @@ SELECT id, uppercats
$uppercats_of = simple_hash_from_query($query, 'id', 'uppercats');
$name_of_category = array();
-
+
foreach ($uppercats_of as $category_id => $uppercats)
{
$name_of_category[$category_id] = get_cat_display_name_cache(
@@ -359,7 +348,7 @@ SELECT
$name_of_tag[ $row['id'] ] = $row['name'];
}
}
-
+
$i = 0;
$first_line = $page['start'] + 1;
$last_line = $page['start'] + $conf['nb_logs_page'];
@@ -374,7 +363,7 @@ SELECT
// unknown) but the non image element filesize. Proposed solution: add
// #images.representative_filesize and add 'representative' in the
// choices of #history.image_type.
-
+
if (isset($line['image_type']))
{
if ($line['image_type'] == 'high')
@@ -401,12 +390,12 @@ SELECT
{
$summary['guests_IP'][ $line['IP'] ] = 0;
}
-
+
$summary['guests_IP'][ $line['IP'] ]++;
}
-
+
$i++;
-
+
if ($i < $first_line or $i > $last_line)
{
continue;
@@ -497,9 +486,9 @@ SELECT
}
}
}
-
- $template->assign_block_vars(
- 'detail',
+
+ $template->append(
+ 'search_results',
array(
'DATE' => $line['date'],
'TIME' => $line['time'],
@@ -514,7 +503,6 @@ SELECT
: 'deleted '.$line['category_id'] )
: '',
'TAGS' => $tags_string,
- 'T_CLASS' => ($i % 2) ? 'row1' : 'row2',
)
);
}
@@ -528,23 +516,23 @@ SELECT
// avoided in next steps
unset($username_of[ $conf['guest_id'] ]);
}
-
+
$summary['nb_members'] = count($username_of);
$member_strings = array();
foreach ($username_of as $user_id => $user_name)
{
$member_string = $user_name.'&nbsp;<a href="';
- $member_string.= PHPWG_ROOT_PATH.'admin.php?page=history';
+ $member_string.= get_root_url().'admin.php?page=history';
$member_string.= '&amp;search_id='.$page['search_id'];
$member_string.= '&amp;user_id='.$user_id;
$member_string.= '">+</a>';
$member_strings[] = $member_string;
}
-
- $template->assign_block_vars(
- 'summary',
+
+ $template->assign(
+ 'search_summary',
array(
'NB_LINES' => l10n_dec(
'%d line filtered', '%d lines filtered',
@@ -577,18 +565,13 @@ SELECT
if (isset($page['search_id']))
{
$navbar = create_navigation_bar(
- PHPWG_ROOT_PATH.'admin.php'.get_query_string_diff(array('start')),
+ get_root_url().'admin.php'.get_query_string_diff(array('start')),
$page['nb_lines'],
$page['start'],
$conf['nb_logs_page']
);
- $template->assign_block_vars(
- 'navigation',
- array(
- 'NAVBAR' => $navbar
- )
- );
+ $template->assign('NAV_BAR', $navbar);
}
// +-----------------------------------------------------------------------+
@@ -602,7 +585,7 @@ if (isset($page['search']))
if (isset($page['search']['fields']['date-after']))
{
$tokens = explode('-', $page['search']['fields']['date-after']);
-
+
$form['start_year'] = (int)$tokens[0];
$form['start_month'] = (int)$tokens[1];
$form['start_day'] = (int)$tokens[2];
@@ -646,50 +629,36 @@ else
pwg_get_cookie_var('history_display_thumbnail', $display_thumbnails[2]);
}
-// start date
-get_day_list('start_day', @$form['start_day']);
-get_month_list('start_month', @$form['start_month']);
-// end date
-get_day_list('end_day', @$form['end_day']);
-get_month_list('end_month', @$form['end_month']);
-$template->assign_vars(
+$month_list = $lang['month'];
+$month_list[0]='------------';
+ksort($month_list);
+
+$template->assign(
array(
- 'START_YEAR' => @$form['start_year'],
- 'END_YEAR' => @$form['end_year'],
'IMAGE_ID' => @$form['image_id'],
'FILENAME' => @$form['filename'],
+
+ 'month_list' => $month_list,
+
+ 'START_DAY_SELECTED' => @$form['start_day'],
+ 'START_MONTH_SELECTED' => @$form['start_month'],
+ 'START_YEAR' => @$form['start_year'],
+
+ 'END_DAY_SELECTED' => @$form['end_day'],
+ 'END_MONTH_SELECTED' => @$form['end_month'],
+ 'END_YEAR' => @$form['end_year'],
)
);
-foreach ($types as $option)
-{
- $selected = '';
-
- if (in_array($option, $form['types']))
- {
- $selected = 'selected="selected"';
- }
-
- $template->assign_block_vars(
- 'types_option',
+$template->assign(
array(
- 'VALUE' => $option,
- 'CONTENT' => l10n($option),
- 'SELECTED' => $selected,
- )
- );
-}
-
-$template->assign_block_vars(
- 'user_option',
- array(
- 'VALUE'=> -1,
- 'CONTENT' => '------------',
- 'SELECTED' => ''
+ 'type_option_values' => $types,
+ 'type_option_selected' => $form['types']
)
);
+
$query = '
SELECT
'.$conf['user_fields']['id'].' AS id,
@@ -697,50 +666,23 @@ SELECT
FROM '.USERS_TABLE.'
ORDER BY username ASC
;';
-$result = pwg_query($query);
-
-while ($row = mysql_fetch_array($result))
-{
- $selected = '';
-
- if (isset($form['user'])
- and $row['id'] == $form['user'])
- {
- $selected = 'selected="selected"';
- }
-
- $template->assign_block_vars(
- 'user_option',
- array(
- 'VALUE' => $row['id'],
- 'CONTENT' => $row['username'],
- 'SELECTED' => $selected,
- )
- );
-}
+$template->assign(
+ array(
+ 'user_options' => simple_hash_from_query($query, 'id','username'),
+ 'user_options_selected' => array(@$form['user'])
+ )
+);
-foreach ($display_thumbnails as $display_thumbnail)
-{
- $selected = '';
-
- if ($display_thumbnail === $form['display_thumbnail'])
- {
- $selected = 'selected="selected"';
- }
-
- $template->assign_block_vars(
- 'display_thumbnail',
- array(
- 'VALUE' => $display_thumbnail,
- 'CONTENT' => l10n($display_thumbnail),
- 'SELECTED' => $selected,
- )
- );
-}
+$template->assign(
+ array(
+ 'display_thumbnail_values' => $display_thumbnails,
+ 'display_thumbnail_selected' => array($form['display_thumbnail']),
+ )
+ );
// +-----------------------------------------------------------------------+
// | html code display |
// +-----------------------------------------------------------------------+
$template->assign_var_from_handle('ADMIN_CONTENT', 'history');
-?>
+?> \ No newline at end of file
diff --git a/admin/include/functions_plugins.inc.php b/admin/include/functions_plugins.inc.php
index 9b59fdb0f..b51a22fd2 100644
--- a/admin/include/functions_plugins.inc.php
+++ b/admin/include/functions_plugins.inc.php
@@ -136,10 +136,8 @@ function sort_plugins_by_state($plugins, $db_plugins_by_id)
* Retrieve PEM server datas
* @param bool (true for retrieve new extensions)
*/
-function check_server_plugins($newext=false)
+function check_server_plugins(& $fs_plugins, $newext=false)
{
- global $fs_plugins;
-
foreach($fs_plugins as $plugin_id => $fs_plugin)
{
if (!empty($fs_plugin['uri']) and strpos($fs_plugin['uri'] , 'extension_view.php?eid='))
@@ -150,7 +148,7 @@ function check_server_plugins($newext=false)
$fs_plugins[$plugin_id]['extension'] = $extension;
}
}
-
+
$url = PEM_URL . '/uptodate.php?version=' . rawurlencode(PHPWG_VERSION) . '&extensions=' . implode(',', $plugins_to_check);
$url .= $newext ? '&newext=Plugin' : '';
@@ -170,7 +168,6 @@ function check_server_plugins($newext=false)
*/
function extract_plugin_files($action, $source, $dest)
{
- global $archive;
if ($archive = tempnam( PHPWG_PLUGINS_PATH, 'zip'))
{
if (@copy(PEM_URL . str_replace(' ', '%20', $source), $archive))
@@ -192,12 +189,12 @@ function extract_plugin_files($action, $source, $dest)
{
$root = dirname($main_filepath); // main.inc.php path in archive
if ($action == 'upgrade')
- {
+ {
$extract_path = PHPWG_PLUGINS_PATH.$dest;
}
else
{
- $extract_path = PHPWG_PLUGINS_PATH
+ $extract_path = PHPWG_PLUGINS_PATH
. ($root == '.' ? 'extension_' . $dest : basename($root));
}
if($result = $zip->extract(PCLZIP_OPT_PATH, $extract_path,
@@ -222,7 +219,7 @@ function extract_plugin_files($action, $source, $dest)
else $status = 'dl_archive_error';
}
else $status = 'temp_path_error';
-
+
@unlink($archive);
return $status;
}
diff --git a/admin/plugins_new.php b/admin/plugins_new.php
index e3bdf8f7d..186a1901e 100644
--- a/admin/plugins_new.php
+++ b/admin/plugins_new.php
@@ -52,66 +52,66 @@ if (isset($_GET['installstatus']))
case 'ok':
array_push($page['infos'], l10n('plugins_install_ok'), l10n('plugins_install_need_activate'));
break;
-
+
case 'temp_path_error':
- array_push($page['errors'], l10n('plugins_temp_path_error'));
+ array_push($page['errors'], l10n('plugins_temp_path_error'));
break;
-
+
case 'dl_archive_error':
- array_push($page['errors'], l10n('plugins_dl_archive_error'));
+ array_push($page['errors'], l10n('plugins_dl_archive_error'));
break;
case 'archive_error':
- array_push($page['errors'], l10n('plugins_archive_error'));
+ array_push($page['errors'], l10n('plugins_archive_error'));
break;
default:
- array_push($page['errors'], sprintf(l10n('plugins_extract_error'), $_GET['installstatus']), l10n('plugins_check_chmod'));
+ array_push($page['errors'], sprintf(l10n('plugins_extract_error'), $_GET['installstatus']), l10n('plugins_check_chmod'));
}
}
//----------------------------------------------------------------sort options
$order = isset($_GET['order']) ? $_GET['order'] : 'date';
-
-$template->assign('order',
+
+$template->assign('order',
array(htmlentities($my_base_url.'&order=date') => l10n('Post date'),
htmlentities($my_base_url.'&order=name') => l10n('Name'),
htmlentities($my_base_url.'&order=author') => l10n('Author')));
-
+
$template->assign('selected', htmlentities($my_base_url.'&order=').$order);
// +-----------------------------------------------------------------------+
// | start template output |
// +-----------------------------------------------------------------------+
-$plugins_infos = check_server_plugins(true);
+$plugins_infos = check_server_plugins($fs_plugins, true);
if ($plugins_infos !== false)
{
if ($order == 'date') krsort($plugins_infos);
else uasort($plugins_infos, 'extension_'.$order.'_compare');
-
+
foreach($plugins_infos as $plugin)
{
$ext_desc = nl2br(htmlspecialchars(strip_tags(
utf8_encode($plugin['ext_description']))));
-
+
$ver_desc = sprintf(l10n('plugins_description'),
$plugin['version'],
date('Y-m-d', $plugin['date']),
nl2br(htmlspecialchars(strip_tags(
utf8_encode($plugin['description'])))));
-
+
$url_auto_install = htmlentities($my_base_url)
. '&amp;extension=' . $plugin['id_extension']
. '&amp;install=%2Fupload%2Fextension-' . $plugin['id_extension']
. '%2Frevision-' . $plugin['id_revision'] . '%2F'
. str_replace(' ', '%20',$plugin['url']);
-
+
$url_download = PEM_URL .'/upload/extension-'.$plugin['id_extension']
. '/revision-' . $plugin['id_revision']
. '/' . $plugin['url'];
-
+
$template->append('plugins',
array('EXT_NAME' => $plugin['ext_name'],
'EXT_URL' => PEM_URL.'/extension_view.php?eid='.$plugin['id_extension'],
diff --git a/admin/plugins_update.php b/admin/plugins_update.php
index 6017c56db..43aab8d56 100644
--- a/admin/plugins_update.php
+++ b/admin/plugins_update.php
@@ -58,21 +58,21 @@ if (isset($_GET['upgradestatus']) and isset($_GET['plugin']))
break;
case 'temp_path_error':
- array_push($page['errors'], l10n('plugins_temp_path_error'));
+ array_push($page['errors'], l10n('plugins_temp_path_error'));
break;
-
+
case 'dl_archive_error':
- array_push($page['errors'], l10n('plugins_dl_archive_error'));
+ array_push($page['errors'], l10n('plugins_dl_archive_error'));
break;
case 'archive_error':
- array_push($page['errors'], l10n('plugins_archive_error'));
+ array_push($page['errors'], l10n('plugins_archive_error'));
break;
default:
array_push($page['errors'],
sprintf(l10n('plugins_extract_error'),
- $_GET['upgradestatus']));
+ $_GET['upgradestatus']));
}
}
@@ -80,7 +80,7 @@ if (isset($_GET['upgradestatus']) and isset($_GET['plugin']))
// +-----------------------------------------------------------------------+
// | start template output |
// +-----------------------------------------------------------------------+
-$plugins_infos = check_server_plugins();
+$plugins_infos = check_server_plugins($fs_plugins);
if ($plugins_infos !== false)
{
@@ -90,16 +90,16 @@ if ($plugins_infos !== false)
and isset($plugins_infos[$fs_plugin['extension']]))
{
$plugin_info = $plugins_infos[$fs_plugin['extension']];
-
+
$ext_desc = nl2br(htmlspecialchars(strip_tags(
utf8_encode($plugin_info['ext_description']))));
-
+
$ver_desc = sprintf(l10n('plugins_description'),
$plugin_info['version'],
date('Y-m-d', $plugin_info['date']),
nl2br(htmlspecialchars(strip_tags(
utf8_encode($plugin_info['description'])))));
-
+
if ($plugin_info['version'] == $fs_plugin['version'])
{
// Plugin is up to date
@@ -116,18 +116,18 @@ if ($plugins_infos !== false)
$url_auto_update = htmlentities($my_base_url)
. '&amp;plugin=' . $plugin_id
. (
- (isset($db_plugins_by_id[$plugin_id])
- and $db_plugins_by_id[$plugin_id]['state'] == 'active') ?
+ (isset($db_plugins_by_id[$plugin_id])
+ and $db_plugins_by_id[$plugin_id]['state'] == 'active') ?
'&amp;action=deactivate' : ''
)
. '&amp;upgrade=%2Fupload%2Fextension-' . $fs_plugin['extension']
. '%2Frevision-' . $plugin_info['id_revision']
. '%2F' . $plugin_info['url'];
-
+
$url_download = PEM_URL.'/upload/extension-'. $fs_plugin['extension']
. '/revision-' . $plugin_info['id_revision']
. '/' . $plugin_info['url'];
-
+
$template->append('plugins_not_uptodate',
array('EXT_NAME' => $fs_plugin['name'],
'EXT_URL' => $fs_plugin['uri'],
@@ -140,7 +140,7 @@ if ($plugins_infos !== false)
'URL_DOWNLOAD' => $url_download));
}
}
- else
+ else
{
// Can't check plugin
$template->append('plugins_cant_check',
diff --git a/admin/stats.php b/admin/stats.php
index 07a98848c..72970dc57 100644
--- a/admin/stats.php
+++ b/admin/stats.php
@@ -388,14 +388,14 @@ $template->set_filename('stats', 'admin/stats.tpl');
// TabSheet initialization
history_tabsheet();
-$base_url = PHPWG_ROOT_PATH.'admin.php?page=history';
+$base_url = get_root_url().'admin.php?page=history';
-$template->assign_vars(
+$template->assign(
array(
'L_STAT_TITLE' => implode($conf['level_separator'], $title_parts),
'PERIOD_LABEL' => $period_label,
- 'U_HELP' => PHPWG_ROOT_PATH.'popuphelp.php?page=history',
- 'F_ACTION' => PHPWG_ROOT_PATH.'admin.php?page=history',
+ 'U_HELP' => get_root_url().'popuphelp.php?page=history',
+ 'F_ACTION' => $base_url,
)
);
@@ -468,7 +468,7 @@ if (count($datas) > 0)
else if (isset($page['month']))
{
$url =
- PHPWG_ROOT_PATH.'admin.php'
+ get_root_url().'admin.php'
.'?page=stats'
.'&amp;year='.$page['year']
.'&amp;month='.$page['month']
@@ -482,7 +482,7 @@ if (count($datas) > 0)
else if (isset($page['year']))
{
$url =
- PHPWG_ROOT_PATH.'admin.php'
+ get_root_url().'admin.php'
.'?page=stats'
.'&amp;year='.$page['year']
.'&amp;month='.$i
@@ -494,7 +494,7 @@ if (count($datas) > 0)
{
// at least the year is defined
$url =
- PHPWG_ROOT_PATH.'admin.php'
+ get_root_url().'admin.php'
.'?page=stats'
.'&amp;year='.$i
;
@@ -507,8 +507,8 @@ if (count($datas) > 0)
$value = '<a href="'.$url.'">'.$value.'</a>';
}
- $template->assign_block_vars(
- 'statrow',
+ $template->append(
+ 'statrows',
array(
'VALUE' => $value,
'PAGES' => $datas[$i],