diff options
author | plegall <plg@piwigo.org> | 2005-06-11 14:10:04 +0000 |
---|---|---|
committer | plegall <plg@piwigo.org> | 2005-06-11 14:10:04 +0000 |
commit | e851f504acebc9422b79f58da25420666da6e296 (patch) | |
tree | f90d0104a9799caa29bcd47d0bd2c6edabcefe79 /admin | |
parent | 4fedaac43ac404dc50193d6032307697412bb2c9 (diff) |
- errors and informations boxes : management centralized in admin.php,
$errors and $infos arrays replaced by $page['errors'] and $page['infos'],
special management for admin/update.php (more complex management)
git-svn-id: http://piwigo.org/svn/trunk@792 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'admin')
-rw-r--r-- | admin/cat_list.php | 29 | ||||
-rw-r--r-- | admin/cat_modify.php | 3 | ||||
-rw-r--r-- | admin/configuration.php | 33 | ||||
-rw-r--r-- | admin/element_set_global.php | 1 | ||||
-rw-r--r-- | admin/element_set_unit.php | 1 | ||||
-rw-r--r-- | admin/group_list.php | 22 | ||||
-rw-r--r-- | admin/picture_modify.php | 17 | ||||
-rw-r--r-- | admin/remote_site.php | 50 | ||||
-rw-r--r-- | admin/thumbnail.php | 26 | ||||
-rw-r--r-- | admin/update.php | 8 | ||||
-rw-r--r-- | admin/user_list.php | 12 | ||||
-rw-r--r-- | admin/waiting.php | 7 |
12 files changed, 56 insertions, 153 deletions
diff --git a/admin/cat_list.php b/admin/cat_list.php index 1706eaff8..a4fa4b5ce 100644 --- a/admin/cat_list.php +++ b/admin/cat_list.php @@ -33,8 +33,6 @@ include_once(PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php'); // +-----------------------------------------------------------------------+ // | initialization | // +-----------------------------------------------------------------------+ -$errors = array(); -$infos = array(); $categories = array(); $navigation = $lang['home']; // +-----------------------------------------------------------------------+ @@ -44,7 +42,7 @@ $navigation = $lang['home']; if (isset($_GET['delete']) and is_numeric($_GET['delete'])) { delete_categories(array($_GET['delete'])); - array_push($infos, $lang['cat_virtual_deleted']); + array_push($page['infos'], $lang['cat_virtual_deleted']); ordering(); update_global_rank(); } @@ -54,10 +52,10 @@ else if (isset($_POST['submit'])) // is the given category name only containing blank spaces ? if (preg_match('/^\s*$/', $_POST['virtual_name'])) { - array_push($errors, $lang['cat_error_name']); + array_push($page['errors'], $lang['cat_error_name']); } - if (!count($errors)) + if (!count($page['errors'])) { $parent_id = !empty($_GET['parent_id'])?$_GET['parent_id']:'NULL'; @@ -136,7 +134,7 @@ SELECT IF(MAX(id)+1 IS NULL, 1, MAX(id)+1) 'uppercats','global_rank'); mass_inserts(CATEGORIES_TABLE, $dbfields, $inserts); - array_push($infos, $lang['cat_virtual_added']); + array_push($page['infos'], $lang['cat_virtual_added']); } } // +-----------------------------------------------------------------------+ @@ -344,25 +342,6 @@ $template->assign_vars(array( $tpl = array('cat_first','cat_last'); // +-----------------------------------------------------------------------+ -// | errors & infos | -// +-----------------------------------------------------------------------+ -if (count($errors) != 0) -{ - $template->assign_block_vars('errors',array()); - foreach ($errors as $error) - { - $template->assign_block_vars('errors.error',array('ERROR'=>$error)); - } -} -if (count($infos) != 0) -{ - $template->assign_block_vars('infos',array()); - foreach ($infos as $info) - { - $template->assign_block_vars('infos.info',array('INFO'=>$info)); - } -} -// +-----------------------------------------------------------------------+ // | Categories display | // +-----------------------------------------------------------------------+ $ranks = array(); diff --git a/admin/cat_modify.php b/admin/cat_modify.php index 97217ab99..44c07ad85 100644 --- a/admin/cat_modify.php +++ b/admin/cat_modify.php @@ -81,7 +81,7 @@ if ( isset( $_POST['submit'] ) ) set_cat_visible(array($_GET['cat_id']), $_POST['visible']); set_cat_status(array($_GET['cat_id']), $_POST['status']); - $template->assign_block_vars('confirmation' ,array()); + array_push($infos, $lang['editcat_confirm']); } else if (isset($_POST['set_random_representant'])) { @@ -144,7 +144,6 @@ $template->assign_vars(array( $commentable=>'checked="checked"', $uploadable=>'checked="checked"', - 'L_EDIT_CONFIRM'=>$lang['editcat_confirm'], 'L_EDIT_NAME'=>$lang['name'], 'L_STORAGE'=>$lang['storage'], 'L_REMOTE_SITE'=>$lang['remote_site'], diff --git a/admin/configuration.php b/admin/configuration.php index 9b3ca801a..5d3864937 100644 --- a/admin/configuration.php +++ b/admin/configuration.php @@ -53,7 +53,6 @@ while ($row = mysql_fetch_array($result)) } } //------------------------------ verification and registration of modifications -$errors = array(); if (isset($_POST['submit'])) { $int_pattern = '/^\d+$/'; @@ -64,13 +63,13 @@ if (isset($_POST['submit'])) // thumbnail prefix must only contain simple ASCII characters if (!preg_match('/^[\w-]*$/', $_POST['prefix_thumbnail'])) { - array_push($errors, $lang['conf_prefix_thumbnail_error']); + array_push($page['errors'], $lang['conf_prefix_thumbnail_error']); } // mail must be formatted as follows : name@server.com $pattern = '/^[\w-]+(\.[\w-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$/'; if (!preg_match($pattern, $_POST['mail_webmaster'])) { - array_push($errors, $lang['conf_mail_webmaster_error']); + array_push($page['errors'], $lang['conf_mail_webmaster_error']); } break; } @@ -82,7 +81,7 @@ if (isset($_POST['submit'])) or $_POST['nb_comment_page'] < 5 or $_POST['nb_comment_page'] > 50) { - array_push($errors, $lang['conf_nb_comment_page_error']); + array_push($page['errors'], $lang['conf_nb_comment_page_error']); } break; } @@ -92,7 +91,7 @@ if (isset($_POST['submit'])) if (!preg_match($int_pattern, $_POST['recent_period']) or $_POST['recent_period'] <= 0) { - array_push($errors, $lang['periods_error']); + array_push($page['errors'], $lang['periods_error']); } break; } @@ -103,7 +102,7 @@ if (isset($_POST['submit'])) or $_POST['upload_maxfilesize'] < 10 or $_POST['upload_maxfilesize'] > 1000) { - array_push($errors, $lang['conf_upload_maxfilesize_error']); + array_push($page['errors'], $lang['conf_upload_maxfilesize_error']); } foreach (array('upload_maxwidth', @@ -113,9 +112,9 @@ if (isset($_POST['submit'])) as $field) { if (!preg_match($int_pattern, $_POST[$field]) - or $_POST[$field] < 10) + or $_POST[$field] < 10) { - array_push($errors, $lang['conf_'.$field.'_error']); + array_push($page['errors'], $lang['conf_'.$field.'_error']); } } break; @@ -123,8 +122,9 @@ if (isset($_POST['submit'])) } // updating configuration if no error found - if (count($errors) == 0) + if (count($page['errors']) == 0) { + echo '<pre>'; print_r($_POST); echo '</pre>'; $result = pwg_query('SELECT * FROM '.CONFIG_TABLE); while ($row = mysql_fetch_array($result)) { @@ -138,6 +138,7 @@ UPDATE '.CONFIG_TABLE.' pwg_query($query); } } + array_push($page['infos'], $lang['conf_confirmation']); } } @@ -149,7 +150,6 @@ $action.= '&section='.$page['section']; $template->assign_vars( array( - 'L_CONFIRM'=>$lang['conf_confirmation'], 'L_YES'=>$lang['yes'], 'L_NO'=>$lang['no'], 'L_SUBMIT'=>$lang['submit'], @@ -343,19 +343,6 @@ switch ($page['section']) break; } } -//-------------------------------------------------------------- errors display -if ( sizeof( $errors ) != 0 ) -{ - $template->assign_block_vars('errors',array()); - for ( $i = 0; $i < sizeof( $errors ); $i++ ) - { - $template->assign_block_vars('errors.error',array('ERROR'=>$errors[$i])); - } -} -elseif ( isset( $_POST['submit'] ) ) -{ - $template->assign_block_vars('confirmation' ,array()); -} //----------------------------------------------------------- sending html code $template->assign_var_from_handle('ADMIN_CONTENT', 'config'); ?> diff --git a/admin/element_set_global.php b/admin/element_set_global.php index 1c1315a0b..33ede7dfc 100644 --- a/admin/element_set_global.php +++ b/admin/element_set_global.php @@ -74,7 +74,6 @@ SELECT keywords // +-----------------------------------------------------------------------+ // | global mode form submission | // +-----------------------------------------------------------------------+ -$errors = array(); if (isset($_POST['submit'])) { diff --git a/admin/element_set_unit.php b/admin/element_set_unit.php index b72c370fe..74aaf1eb0 100644 --- a/admin/element_set_unit.php +++ b/admin/element_set_unit.php @@ -40,7 +40,6 @@ include_once(PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php'); // +-----------------------------------------------------------------------+ // | unit mode form submission | // +-----------------------------------------------------------------------+ -$errors = array(); if (isset($_POST['submit'])) { diff --git a/admin/group_list.php b/admin/group_list.php index cdf123f4e..f789a6b27 100644 --- a/admin/group_list.php +++ b/admin/group_list.php @@ -31,7 +31,6 @@ if( !defined("PHPWG_ROOT_PATH") ) include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php' ); //-------------------------------------------------------------- delete a group -$error = array(); if ( isset( $_POST['delete'] ) && isset( $_POST['confirm_delete'] ) ) { // destruction of the access linked to the group @@ -57,9 +56,9 @@ elseif ( isset( $_POST['new'] ) ) if ( empty($_POST['newgroup']) || preg_match( "/'/", $_POST['newgroup'] ) or preg_match( '/"/', $_POST['newgroup'] ) ) { - array_push( $error, $lang['group_add_error1'] ); + array_push( $page['errors'], $lang['group_add_error1'] ); } - if ( count( $error ) == 0 ) + if ( count( $page['errors'] ) == 0 ) { // is the group not already existing ? $query = 'SELECT id FROM '.GROUPS_TABLE; @@ -68,10 +67,10 @@ elseif ( isset( $_POST['new'] ) ) $result = pwg_query( $query ); if ( mysql_num_rows( $result ) > 0 ) { - array_push( $error, $lang['group_add_error2'] ); + array_push( $page['errors'], $lang['group_add_error2'] ); } } - if ( count( $error ) == 0 ) + if ( count( $page['errors'] ) == 0 ) { // creating the group $query = ' INSERT INTO '.GROUPS_TABLE; @@ -80,13 +79,13 @@ elseif ( isset( $_POST['new'] ) ) pwg_query( $query ); } } -//--------------------------------------------------------------- user management +//------------------------------------------------------------- user management elseif ( isset( $_POST['add'] ) ) { $userdata = getuserdata($_POST['username']); if (!$userdata) { - array_push($error, $lang['user_err_unknown']); + array_push($page['errors'], $lang['user_err_unknown']); } else { @@ -113,15 +112,6 @@ elseif (isset( $_POST['deny_user'] )) $query.= ') AND group_id = '.$_POST['edit_group_id']; pwg_query( $query ); } -//-------------------------------------------------------------- errors display -if ( sizeof( $error ) != 0 ) -{ - $template->assign_block_vars('errors',array()); - for ( $i = 0; $i < sizeof( $error ); $i++ ) - { - $template->assign_block_vars('errors.error',array('ERROR'=>$error[$i])); - } -} //----------------------------------------------------------------- groups list $query = 'SELECT id,name FROM '.GROUPS_TABLE; diff --git a/admin/picture_modify.php b/admin/picture_modify.php index fc2e2eb51..64d6cf04b 100644 --- a/admin/picture_modify.php +++ b/admin/picture_modify.php @@ -31,16 +31,15 @@ if(!defined("PHPWG_ROOT_PATH")) } include_once(PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php'); //--------------------------------------------------------- update informations -$errors = array(); // first, we verify whether there is a mistake on the given creation date if (isset($_POST['date_creation']) and !empty($_POST['date_creation'])) { if (!check_date_format($_POST['date_creation'])) { - array_push($errors, $lang['err_date']); + array_push($page['errors'], $lang['err_date']); } } -if (isset($_POST['submit']) and count($errors) == 0) +if (isset($_POST['submit']) and count($page['errors']) == 0) { $query = 'UPDATE '.IMAGES_TABLE.' SET name = '; if ($_POST['name'] == '') @@ -160,7 +159,7 @@ $thumbnail_url = get_thumbnail_src($row['path'], @$row['tn_ext']); $url_img = PHPWG_ROOT_PATH.'picture.php?image_id='.$_GET['image_id']; $url_img .= '&cat='.$row['storage_category_id']; -$date = isset($_POST['date_creation']) && empty($errors) +$date = isset($_POST['date_creation']) && empty($page['errors']) ?$_POST['date_creation']:date_convert_back(@$row['date_creation']); $url = PHPWG_ROOT_PATH.'admin.php?page=cat_modify&cat_id='; @@ -212,16 +211,6 @@ $template->assign_vars(array( 'F_ACTION'=>add_session_id(PHPWG_ROOT_PATH.'admin.php?'.$_SERVER['QUERY_STRING']) )); -//-------------------------------------------------------------- errors display -if (count($errors) != 0) -{ - $template->assign_block_vars('errors',array()); - foreach ($errors as $error) - { - $template->assign_block_vars('errors.error',array('ERROR'=>$error)); - } -} - // associate to another category ? $query = ' SELECT id,name,uppercats,global_rank diff --git a/admin/remote_site.php b/admin/remote_site.php index 37f9458fc..ba8dc67ce 100644 --- a/admin/remote_site.php +++ b/admin/remote_site.php @@ -45,7 +45,7 @@ define('CURRENT_DATE', date('Y-m-d')); */ function remote_output($url) { - global $template, $errors, $lang; + global $template, $page, $lang; if($lines = @file($url)) { @@ -68,7 +68,7 @@ function remote_output($url) } else { - array_push($errors, $lang['remote_site_file_not_found']); + array_push($page['errors'], $lang['remote_site_file_not_found']); } } @@ -120,7 +120,7 @@ SELECT id,dir */ function update_remote_site($listing_file, $site_id) { - global $lang, $counts, $template, $removes, $errors; + global $lang, $counts, $template, $removes, $page; if (@fopen($listing_file, 'r')) { @@ -159,7 +159,7 @@ function update_remote_site($listing_file, $site_id) } else { - array_push($errors, $lang['remote_site_listing_not_found']); + array_push($page['errors'], $lang['remote_site_listing_not_found']); } } @@ -518,14 +518,12 @@ $template->assign_vars( // +-----------------------------------------------------------------------+ // | new site creation form | // +-----------------------------------------------------------------------+ -$errors = array(); - if (isset($_POST['submit'])) { // site must start by http:// or https:// if (!preg_match('/^https?:\/\/[~\/\.\w-]+$/', $_POST['galleries_url'])) { - array_push($errors, $lang['remote_site_uncorrect_url']); + array_push($page['errors'], $lang['remote_site_uncorrect_url']); } else { @@ -542,11 +540,11 @@ SELECT COUNT(id) AS count $row = mysql_fetch_array(pwg_query($query)); if ($row['count'] > 0) { - array_push($errors, $lang['remote_site_already_exists']); + array_push($page['errors'], $lang['remote_site_already_exists']); } } - if (count($errors) == 0) + if (count($page['errors']) == 0) { $url = $page['galleries_url'].'create_listing_file.php'; $url.= '?action=test'; @@ -556,16 +554,17 @@ SELECT COUNT(id) AS count $first_line = strip_tags($lines[0]); if (!preg_match('/^PWG-INFO-2:/', $first_line)) { - array_push($errors, $lang['remote_site_error'].' : '.$first_line); + array_push($page['errors'], + $lang['remote_site_error'].' : '.$first_line); } } else { - array_push($errors, $lang['remote_site_file_not_found']); + array_push($page['errors'], $lang['remote_site_file_not_found']); } } - if (count($errors) == 0) + if (count($page['errors']) == 0) { $query = ' INSERT INTO '.SITES_TABLE.' @@ -575,11 +574,8 @@ INSERT INTO '.SITES_TABLE.' ;'; pwg_query($query); - $template->assign_block_vars( - 'confirmation', - array( - 'CONTENT'=>$page['galleries_url'].' '.$lang['remote_site_created'] - )); + array_push($page['infos'], + $page['galleries_url'].' '.$lang['remote_site_created']); } } // +-----------------------------------------------------------------------+ @@ -607,13 +603,8 @@ SELECT galleries_url case 'delete' : { delete_site($page['site']); - - $template->assign_block_vars( - 'confirmation', - array( - 'CONTENT'=>$galleries_url.' '.$lang['remote_site_deleted'] - )); - + array_push($page['infos'], + $galleries_url.' '.$lang['remote_site_deleted']); break; } case 'generate' : @@ -738,17 +729,6 @@ while ($row = mysql_fetch_array($result)) ); } // +-----------------------------------------------------------------------+ -// | errors display | -// +-----------------------------------------------------------------------+ -if (count($errors) != 0) -{ - $template->assign_block_vars('errors',array()); - foreach ($errors as $error) - { - $template->assign_block_vars('errors.error',array('ERROR'=>$error)); - } -} -// +-----------------------------------------------------------------------+ // | sending html code | // +-----------------------------------------------------------------------+ $template->assign_var_from_handle('ADMIN_CONTENT', 'remote_site'); diff --git a/admin/thumbnail.php b/admin/thumbnail.php index 7cdb1711a..64a6797e3 100644 --- a/admin/thumbnail.php +++ b/admin/thumbnail.php @@ -31,7 +31,7 @@ include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php' ); // "thumbnail". function RatioResizeImg($path, $newWidth, $newHeight, $tn_ext) { - global $conf, $lang, $errors; + global $conf, $lang, $page; $filename = basename($path); $dirname = dirname($path); @@ -100,7 +100,8 @@ function RatioResizeImg($path, $newWidth, $newHeight, $tn_ext) { if (!is_writable($dirname)) { - array_push($errors, '['.$dirname.'] : '.$lang['no_write_access']); + array_push($page['errors'], + '['.$dirname.'] : '.$lang['no_write_access']); return false; } umask(0000); @@ -114,7 +115,7 @@ function RatioResizeImg($path, $newWidth, $newHeight, $tn_ext) // creation and backup of final picture if (!is_writable($tndir)) { - array_push($errors, '['.$tndir.'] : '.$lang['no_write_access']); + array_push($page['errors'], '['.$tndir.'] : '.$lang['no_write_access']); return false; } imagejpeg($destImage, $dest_file); @@ -148,7 +149,6 @@ function RatioResizeImg($path, $newWidth, $newHeight, $tn_ext) } } -$errors = array(); $pictures = array(); $stats = array(); // +-----------------------------------------------------------------------+ @@ -247,22 +247,21 @@ foreach ($fs['elements'] as $path) // +-----------------------------------------------------------------------+ if (isset($_POST['submit'])) { - $errors = array(); $times = array(); $infos = array(); // checking criteria if (!ereg('^[0-9]{2,3}$', $_POST['width']) or $_POST['width'] < 10) { - array_push($errors, $lang['tn_err_width'].' 10'); + array_push($page['errors'], $lang['tn_err_width'].' 10'); } if (!ereg('^[0-9]{2,3}$', $_POST['height']) or $_POST['height'] < 10) { - array_push($errors, $lang['tn_err_height'].' 10'); + array_push($page['errors'], $lang['tn_err_height'].' 10'); } // picture miniaturization - if (count($errors) == 0) + if (count($page['errors']) == 0) { $num = 1; foreach ($wo_thumbnails as $path) @@ -345,17 +344,6 @@ if (isset($_POST['submit'])) } } // +-----------------------------------------------------------------------+ -// | errors display | -// +-----------------------------------------------------------------------+ -if (count($errors) != 0) -{ - $template->assign_block_vars('errors',array()); - foreach ($errors as $error) - { - $template->assign_block_vars('errors.error',array('ERROR'=>$error)); - } -} -// +-----------------------------------------------------------------------+ // | form & pictures without thumbnails display | // +-----------------------------------------------------------------------+ $remainings = array_diff($wo_thumbnails, $thumbnalized); diff --git a/admin/update.php b/admin/update.php index 59e748198..bfc3236fc 100644 --- a/admin/update.php +++ b/admin/update.php @@ -654,11 +654,11 @@ if (isset($_POST['submit']) if (count($errors) > 0) { - $template->assign_block_vars('update.errors', array()); + $template->assign_block_vars('update.update_errors', array()); foreach ($errors as $error) { $template->assign_block_vars( - 'update.errors.error', + 'update.update_errors.update_error', array( 'ELEMENT' => $error['path'], 'LABEL' => $error['type'].' ('.$error_labels[$error['type']].')' @@ -669,11 +669,11 @@ if (isset($_POST['submit']) and isset($_POST['display_info']) and $_POST['display_info'] == 1) { - $template->assign_block_vars('update.infos', array()); + $template->assign_block_vars('update.update_infos', array()); foreach ($infos as $info) { $template->assign_block_vars( - 'update.infos.info', + 'update.update_infos.update_info', array( 'ELEMENT' => $info['path'], 'LABEL' => $info['info'] diff --git a/admin/user_list.php b/admin/user_list.php index 23c467eb4..26a98ebaf 100644 --- a/admin/user_list.php +++ b/admin/user_list.php @@ -45,18 +45,16 @@ include_once(PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php'); if (isset($_POST['submit_add'])) { - $errors = register_user($_POST['login'], - $_POST['password'], - $_POST['password'], - ''); + $page['errors'] = register_user($_POST['login'], + $_POST['password'], + $_POST['password'], + ''); } // +-----------------------------------------------------------------------+ // | preferences form submission | // +-----------------------------------------------------------------------+ -$errors = array(); - if (isset($_POST['pref_submit'])) { $collection = array(); @@ -193,7 +191,7 @@ $template->set_filenames(array('user_list'=>'admin/user_list.tpl')); $base_url = add_session_id(PHPWG_ROOT_PATH.'admin.php?page=user_list'); -$conf['users_page'] = 20; +$conf['users_page'] = 10; if (isset($_GET['start']) and is_numeric($_GET['start'])) { diff --git a/admin/waiting.php b/admin/waiting.php index b0b69cd2e..3be00dd5c 100644 --- a/admin/waiting.php +++ b/admin/waiting.php @@ -72,12 +72,12 @@ if ( isset( $_POST['submit'] ) ) } } } + array_push($infos, $lang['waiting_update']); } //----------------------------------------------------- template initialization $template->set_filenames(array('waiting'=>'admin/waiting.tpl')); $template->assign_vars(array( - 'L_WAITING_CONFIRMATION'=>$lang['waiting_update'], 'L_AUTHOR'=>$lang['author'], 'L_THUMBNAIL'=>$lang['thumbnail'], 'L_DATE'=>$lang['date'], @@ -90,11 +90,6 @@ $template->assign_vars(array( 'F_ACTION'=>add_session_id(str_replace( '&', '&', $_SERVER['REQUEST_URI'] )) )); -//-------------------------------------------------------- confirmation message -if (isset($_POST['submit'])) -{ - $template->assign_block_vars('confirmation' ,array()); -} //---------------------------------------------------------------- form display $cat_names = array(); $query = 'SELECT * FROM '.WAITING_TABLE; |