Changeset 792 for trunk/admin


Ignore:
Timestamp:
Jun 11, 2005, 4:10:04 PM (19 years ago)
Author:
plg
Message:
  • errors and informations boxes : management centralized in admin.php, $errors and $infos arrays replaced by $pageerrors and $pageinfos, special management for admin/update.php (more complex management)
Location:
trunk/admin
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/cat_list.php

    r764 r792  
    3434// |                            initialization                             |
    3535// +-----------------------------------------------------------------------+
    36 $errors = array();
    37 $infos = array();
    3836$categories = array();
    3937$navigation = $lang['home'];
     
    4543{
    4644  delete_categories(array($_GET['delete']));
    47   array_push($infos, $lang['cat_virtual_deleted']);
     45  array_push($page['infos'], $lang['cat_virtual_deleted']);
    4846  ordering();
    4947  update_global_rank();
     
    5553  if (preg_match('/^\s*$/', $_POST['virtual_name']))
    5654  {
    57     array_push($errors, $lang['cat_error_name']);
     55    array_push($page['errors'], $lang['cat_error_name']);
    5856  }
    5957       
    60   if (!count($errors))
     58  if (!count($page['errors']))
    6159  {
    6260    $parent_id = !empty($_GET['parent_id'])?$_GET['parent_id']:'NULL';
     
    137135    mass_inserts(CATEGORIES_TABLE, $dbfields, $inserts);
    138136
    139     array_push($infos, $lang['cat_virtual_added']);
     137    array_push($page['infos'], $lang['cat_virtual_added']);
    140138  }
    141139}
     
    345343$tpl = array('cat_first','cat_last');
    346344// +-----------------------------------------------------------------------+
    347 // |                            errors & infos                             |
    348 // +-----------------------------------------------------------------------+
    349 if (count($errors) != 0)
    350 {
    351   $template->assign_block_vars('errors',array());
    352   foreach ($errors as $error)
    353   {
    354     $template->assign_block_vars('errors.error',array('ERROR'=>$error));
    355   }
    356 }
    357 if (count($infos) != 0)
    358 {
    359   $template->assign_block_vars('infos',array());
    360   foreach ($infos as $info)
    361   {
    362     $template->assign_block_vars('infos.info',array('INFO'=>$info));
    363   }
    364 }
    365 // +-----------------------------------------------------------------------+
    366345// |                          Categories display                           |
    367346// +-----------------------------------------------------------------------+
  • trunk/admin/cat_modify.php

    r675 r792  
    8282  set_cat_status(array($_GET['cat_id']), $_POST['status']);
    8383
    84   $template->assign_block_vars('confirmation' ,array());
     84  array_push($infos, $lang['editcat_confirm']);
    8585}
    8686else if (isset($_POST['set_random_representant']))
     
    145145  $uploadable=>'checked="checked"',
    146146 
    147   'L_EDIT_CONFIRM'=>$lang['editcat_confirm'],
    148147  'L_EDIT_NAME'=>$lang['name'],
    149148  'L_STORAGE'=>$lang['storage'],
  • trunk/admin/configuration.php

    r700 r792  
    5454}                                         
    5555//------------------------------ verification and registration of modifications
    56 $errors = array();
    5756if (isset($_POST['submit']))
    5857{
     
    6564      if (!preg_match('/^[\w-]*$/', $_POST['prefix_thumbnail']))
    6665      {
    67         array_push($errors, $lang['conf_prefix_thumbnail_error']);
     66        array_push($page['errors'], $lang['conf_prefix_thumbnail_error']);
    6867      }
    6968      // mail must be formatted as follows : name@server.com
     
    7170      if (!preg_match($pattern, $_POST['mail_webmaster']))
    7271      {
    73         array_push($errors, $lang['conf_mail_webmaster_error']);
     72        array_push($page['errors'], $lang['conf_mail_webmaster_error']);
    7473      }
    7574      break;
     
    8382           or $_POST['nb_comment_page'] > 50)
    8483      {
    85         array_push($errors, $lang['conf_nb_comment_page_error']);
     84        array_push($page['errors'], $lang['conf_nb_comment_page_error']);
    8685      }
    8786      break;
     
    9392          or $_POST['recent_period'] <= 0)
    9493      {
    95         array_push($errors, $lang['periods_error']);
     94        array_push($page['errors'], $lang['periods_error']);
    9695      }
    9796      break;
     
    104103          or $_POST['upload_maxfilesize'] > 1000)
    105104      {
    106         array_push($errors, $lang['conf_upload_maxfilesize_error']);
     105        array_push($page['errors'], $lang['conf_upload_maxfilesize_error']);
    107106      }
    108107     
     
    114113      {
    115114        if (!preg_match($int_pattern, $_POST[$field])
    116           or $_POST[$field] < 10)
     115            or $_POST[$field] < 10)
    117116        {
    118           array_push($errors, $lang['conf_'.$field.'_error']);
     117          array_push($page['errors'], $lang['conf_'.$field.'_error']);
    119118        }
    120119      }
     
    124123 
    125124  // updating configuration if no error found
    126   if (count($errors) == 0)
    127   {
     125  if (count($page['errors']) == 0)
     126  {
     127    echo '<pre>'; print_r($_POST); echo '</pre>';
    128128    $result = pwg_query('SELECT * FROM '.CONFIG_TABLE);
    129129    while ($row = mysql_fetch_array($result))
     
    139139      }
    140140    }
     141    array_push($page['infos'], $lang['conf_confirmation']);
    141142  }
    142143}
     
    150151$template->assign_vars(
    151152  array(
    152     'L_CONFIRM'=>$lang['conf_confirmation'],
    153153    'L_YES'=>$lang['yes'],
    154154    'L_NO'=>$lang['no'],
     
    344344  }
    345345}
    346 //-------------------------------------------------------------- errors display
    347 if ( sizeof( $errors ) != 0 )
    348 {
    349   $template->assign_block_vars('errors',array());
    350   for ( $i = 0; $i < sizeof( $errors ); $i++ )
    351   {
    352     $template->assign_block_vars('errors.error',array('ERROR'=>$errors[$i]));
    353   }
    354 }
    355 elseif ( isset( $_POST['submit'] ) )
    356 {
    357   $template->assign_block_vars('confirmation' ,array());
    358 }
    359346//----------------------------------------------------------- sending html code
    360347$template->assign_var_from_handle('ADMIN_CONTENT', 'config');
  • trunk/admin/element_set_global.php

    r764 r792  
    7575// |                       global mode form submission                     |
    7676// +-----------------------------------------------------------------------+
    77 $errors = array();
    7877
    7978if (isset($_POST['submit']))
  • trunk/admin/element_set_unit.php

    r764 r792  
    4141// |                        unit mode form submission                      |
    4242// +-----------------------------------------------------------------------+
    43 $errors = array();
    4443
    4544if (isset($_POST['submit']))
  • trunk/admin/group_list.php

    r704 r792  
    3232
    3333//-------------------------------------------------------------- delete a group
    34 $error = array();
    3534if ( isset( $_POST['delete'] ) && isset( $_POST['confirm_delete'] )  )
    3635{
     
    5857       or preg_match( '/"/', $_POST['newgroup'] ) )
    5958  {
    60     array_push( $error, $lang['group_add_error1'] );
     59    array_push( $page['errors'], $lang['group_add_error1'] );
    6160  }
    62   if ( count( $error ) == 0 )
     61  if ( count( $page['errors'] ) == 0 )
    6362  {
    6463    // is the group not already existing ?
     
    6968    if ( mysql_num_rows( $result ) > 0 )
    7069    {
    71       array_push( $error, $lang['group_add_error2'] );
     70      array_push( $page['errors'], $lang['group_add_error2'] );
    7271    }
    7372  }
    74   if ( count( $error ) == 0 )
     73  if ( count( $page['errors'] ) == 0 )
    7574  {
    7675    // creating the group
     
    8180  }
    8281}
    83 //--------------------------------------------------------------- user management
     82//------------------------------------------------------------- user management
    8483elseif ( isset( $_POST['add'] ) )
    8584{
     
    8786  if (!$userdata)
    8887  {
    89     array_push($error, $lang['user_err_unknown']);
     88    array_push($page['errors'], $lang['user_err_unknown']);
    9089  }
    9190  else
     
    113112        $query.= ') AND group_id = '.$_POST['edit_group_id'];
    114113        pwg_query( $query );
    115 }
    116 //-------------------------------------------------------------- errors display
    117 if ( sizeof( $error ) != 0 )
    118 {
    119   $template->assign_block_vars('errors',array());
    120   for ( $i = 0; $i < sizeof( $error ); $i++ )
    121   {
    122     $template->assign_block_vars('errors.error',array('ERROR'=>$error[$i]));
    123   }
    124114}
    125115//----------------------------------------------------------------- groups list
  • trunk/admin/picture_modify.php

    r732 r792  
    3232include_once(PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php');
    3333//--------------------------------------------------------- update informations
    34 $errors = array();
    3534// first, we verify whether there is a mistake on the given creation date
    3635if (isset($_POST['date_creation']) and !empty($_POST['date_creation']))
     
    3837  if (!check_date_format($_POST['date_creation']))
    3938  {
    40     array_push($errors, $lang['err_date']);
    41   }
    42 }
    43 if (isset($_POST['submit']) and count($errors) == 0)
     39    array_push($page['errors'], $lang['err_date']);
     40  }
     41}
     42if (isset($_POST['submit']) and count($page['errors']) == 0)
    4443{
    4544  $query = 'UPDATE '.IMAGES_TABLE.' SET name = ';
     
    161160$url_img = PHPWG_ROOT_PATH.'picture.php?image_id='.$_GET['image_id'];
    162161$url_img .= '&amp;cat='.$row['storage_category_id'];
    163 $date = isset($_POST['date_creation']) && empty($errors)
     162$date = isset($_POST['date_creation']) && empty($page['errors'])
    164163?$_POST['date_creation']:date_convert_back(@$row['date_creation']);
    165164
     
    213212 ));
    214213 
    215 //-------------------------------------------------------------- errors display
    216 if (count($errors) != 0)
    217 {
    218   $template->assign_block_vars('errors',array());
    219   foreach ($errors as $error)
    220   {
    221     $template->assign_block_vars('errors.error',array('ERROR'=>$error));
    222   }
    223 }
    224 
    225214// associate to another category ?
    226215$query = '
  • trunk/admin/remote_site.php

    r675 r792  
    4646function remote_output($url)
    4747{
    48   global $template, $errors, $lang;
     48  global $template, $page, $lang;
    4949 
    5050  if($lines = @file($url))
     
    6969  else
    7070  {
    71     array_push($errors, $lang['remote_site_file_not_found']);
     71    array_push($page['errors'], $lang['remote_site_file_not_found']);
    7272  }
    7373}
     
    121121function update_remote_site($listing_file, $site_id)
    122122{
    123   global $lang, $counts, $template, $removes, $errors;
     123  global $lang, $counts, $template, $removes, $page;
    124124 
    125125  if (@fopen($listing_file, 'r'))
     
    160160  else
    161161  {
    162     array_push($errors, $lang['remote_site_listing_not_found']);
     162    array_push($page['errors'], $lang['remote_site_listing_not_found']);
    163163  }
    164164}
     
    519519// |                        new site creation form                         |
    520520// +-----------------------------------------------------------------------+
    521 $errors = array();
    522 
    523521if (isset($_POST['submit']))
    524522{
     
    526524  if (!preg_match('/^https?:\/\/[~\/\.\w-]+$/', $_POST['galleries_url']))
    527525  {
    528     array_push($errors, $lang['remote_site_uncorrect_url']);
     526    array_push($page['errors'], $lang['remote_site_uncorrect_url']);
    529527  }
    530528  else
     
    543541    if ($row['count'] > 0)
    544542    {
    545       array_push($errors, $lang['remote_site_already_exists']);
    546     }
    547   }
    548 
    549   if (count($errors) == 0)
     543      array_push($page['errors'], $lang['remote_site_already_exists']);
     544    }
     545  }
     546
     547  if (count($page['errors']) == 0)
    550548  {
    551549    $url = $page['galleries_url'].'create_listing_file.php';
     
    557555      if (!preg_match('/^PWG-INFO-2:/', $first_line))
    558556      {
    559         array_push($errors, $lang['remote_site_error'].' : '.$first_line);
     557        array_push($page['errors'],
     558                   $lang['remote_site_error'].' : '.$first_line);
    560559      }
    561560    }
    562561    else
    563562    {
    564       array_push($errors, $lang['remote_site_file_not_found']);
    565     }
    566   }
    567  
    568   if (count($errors) == 0)
     563      array_push($page['errors'], $lang['remote_site_file_not_found']);
     564    }
     565  }
     566 
     567  if (count($page['errors']) == 0)
    569568  {
    570569    $query = '
     
    576575    pwg_query($query);
    577576
    578     $template->assign_block_vars(
    579       'confirmation',
    580       array(
    581         'CONTENT'=>$page['galleries_url'].' '.$lang['remote_site_created']
    582         ));
     577    array_push($page['infos'],
     578               $page['galleries_url'].' '.$lang['remote_site_created']);
    583579  }
    584580}
     
    608604    {
    609605      delete_site($page['site']);
    610 
    611       $template->assign_block_vars(
    612         'confirmation',
    613         array(
    614           'CONTENT'=>$galleries_url.' '.$lang['remote_site_deleted']
    615           ));
    616      
     606      array_push($page['infos'],
     607                 $galleries_url.' '.$lang['remote_site_deleted']);
    617608      break;
    618609    }
     
    739730}
    740731// +-----------------------------------------------------------------------+
    741 // |                             errors display                            |
    742 // +-----------------------------------------------------------------------+
    743 if (count($errors) != 0)
    744 {
    745   $template->assign_block_vars('errors',array());
    746   foreach ($errors as $error)
    747   {
    748     $template->assign_block_vars('errors.error',array('ERROR'=>$error));
    749   }
    750 }
    751 // +-----------------------------------------------------------------------+
    752732// |                           sending html code                           |
    753733// +-----------------------------------------------------------------------+
  • trunk/admin/thumbnail.php

    r716 r792  
    3232function RatioResizeImg($path, $newWidth, $newHeight, $tn_ext)
    3333{
    34   global $conf, $lang, $errors;
     34  global $conf, $lang, $page;
    3535
    3636  $filename = basename($path);
     
    101101      if (!is_writable($dirname))
    102102      {
    103         array_push($errors, '['.$dirname.'] : '.$lang['no_write_access']);
     103        array_push($page['errors'],
     104                   '['.$dirname.'] : '.$lang['no_write_access']);
    104105        return false;
    105106      }
     
    115116    if (!is_writable($tndir))
    116117    {
    117       array_push($errors, '['.$tndir.'] : '.$lang['no_write_access']);
     118      array_push($page['errors'], '['.$tndir.'] : '.$lang['no_write_access']);
    118119      return false;
    119120    }
     
    149150}
    150151
    151 $errors = array();
    152152$pictures = array();
    153153$stats = array();
     
    248248if (isset($_POST['submit']))
    249249{
    250   $errors = array();
    251250  $times = array();
    252251  $infos = array();
     
    255254  if (!ereg('^[0-9]{2,3}$', $_POST['width']) or $_POST['width'] < 10)
    256255  {
    257     array_push($errors, $lang['tn_err_width'].' 10');
     256    array_push($page['errors'], $lang['tn_err_width'].' 10');
    258257  }
    259258  if (!ereg('^[0-9]{2,3}$', $_POST['height']) or $_POST['height'] < 10)
    260259  {
    261     array_push($errors, $lang['tn_err_height'].' 10');
     260    array_push($page['errors'], $lang['tn_err_height'].' 10');
    262261  }
    263262 
    264263  // picture miniaturization
    265   if (count($errors) == 0)
     264  if (count($page['errors']) == 0)
    266265  {
    267266    $num = 1;
     
    346345}
    347346// +-----------------------------------------------------------------------+
    348 // |                            errors display                             |
    349 // +-----------------------------------------------------------------------+
    350 if (count($errors) != 0)
    351 {
    352   $template->assign_block_vars('errors',array());
    353   foreach ($errors as $error)
    354   {
    355     $template->assign_block_vars('errors.error',array('ERROR'=>$error));
    356   }
    357 }
    358 // +-----------------------------------------------------------------------+
    359347// |             form & pictures without thumbnails display                |
    360348// +-----------------------------------------------------------------------+
  • trunk/admin/update.php

    r791 r792  
    655655  if (count($errors) > 0)
    656656  {
    657     $template->assign_block_vars('update.errors', array());
     657    $template->assign_block_vars('update.update_errors', array());
    658658    foreach ($errors as $error)
    659659    {
    660660      $template->assign_block_vars(
    661         'update.errors.error',
     661        'update.update_errors.update_error',
    662662        array(
    663663          'ELEMENT' => $error['path'],
     
    670670      and $_POST['display_info'] == 1)
    671671  {
    672     $template->assign_block_vars('update.infos', array());
     672    $template->assign_block_vars('update.update_infos', array());
    673673    foreach ($infos as $info)
    674674    {
    675675      $template->assign_block_vars(
    676         'update.infos.info',
     676        'update.update_infos.update_info',
    677677        array(
    678678          'ELEMENT' => $info['path'],
  • trunk/admin/user_list.php

    r787 r792  
    4646if (isset($_POST['submit_add']))
    4747{
    48   $errors = register_user($_POST['login'],
    49                           $_POST['password'],
    50                           $_POST['password'],
    51                           '');
     48  $page['errors'] = register_user($_POST['login'],
     49                                  $_POST['password'],
     50                                  $_POST['password'],
     51                                  '');
    5252}
    5353
     
    5555// |                       preferences form submission                     |
    5656// +-----------------------------------------------------------------------+
    57 
    58 $errors = array();
    5957
    6058if (isset($_POST['pref_submit']))
     
    194192$base_url = add_session_id(PHPWG_ROOT_PATH.'admin.php?page=user_list');
    195193
    196 $conf['users_page'] = 20;
     194$conf['users_page'] = 10;
    197195
    198196if (isset($_GET['start']) and is_numeric($_GET['start']))
  • trunk/admin/waiting.php

    r699 r792  
    7373    }
    7474  }
     75  array_push($infos, $lang['waiting_update']);
    7576}
    7677
     
    7879$template->set_filenames(array('waiting'=>'admin/waiting.tpl'));
    7980$template->assign_vars(array(
    80   'L_WAITING_CONFIRMATION'=>$lang['waiting_update'],
    8181  'L_AUTHOR'=>$lang['author'],
    8282  'L_THUMBNAIL'=>$lang['thumbnail'],
     
    9191  ));
    9292 
    93 //-------------------------------------------------------- confirmation message
    94 if (isset($_POST['submit']))
    95 {
    96   $template->assign_block_vars('confirmation' ,array());
    97 }
    9893//---------------------------------------------------------------- form display
    9994$cat_names = array();
Note: See TracChangeset for help on using the changeset viewer.