Ignore:
Timestamp:
Sep 3, 2004, 5:01:05 PM (20 years ago)
Author:
z0rglub
Message:
  • in admin/configuration, add new step with "sections" (general, comments, default, upload, metadata, sessions)
  • admin/configuration.php and its template have been higly simplificated by making things more generic : for example, for each configuration parameter, its name must correspond to the name we find in the config table and belongs to a section, in the lang array we find :
  • more described message when connection to database server is impossible
  • redefinitions of get_languages and get_templates functions
  • deletion of configuration parameters : webmaster, session_keyword
  • rename of configuration parameters :
  • default_lang => default_language
  • default_style => default_template
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/configuration.php

    r493 r512  
    2626// +-----------------------------------------------------------------------+
    2727
    28 if( !defined("PHPWG_ROOT_PATH") )
    29 {
    30         die ("Hacking attempt!");
    31 }
    32 
    33 include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php' );
    34        
    35 $Caracs = array("¥" => "Y", "µ" => "u", "À" => "A", "Á" => "A",
    36                 "Â" => "A", "Ã" => "A", "Ä" => "A", "Å" => "A",
    37                 "Æ" => "A", "Ç" => "C", "È" => "E", "É" => "E",
    38                 "Ê" => "E", "Ë" => "E", "Ì" => "I", "Í" => "I",
    39                 "Î" => "I", "Ï" => "I", "Ð" => "D", "Ñ" => "N",
    40                 "Ò" => "O", "Ó" => "O", "Ô" => "O", "Õ" => "O",
    41                 "Ö" => "O", "Ø" => "O", "Ù" => "U", "Ú" => "U",
    42                 "Û" => "U", "Ü" => "U", "Ý" => "Y", "ß" => "s",
    43                 "à" => "a", "á" => "a", "â" => "a", "ã" => "a",
    44                 "ä" => "a", "å" => "a", "æ" => "a", "ç" => "c",
    45                 "è" => "e", "é" => "e", "ê" => "e", "ë" => "e",
    46                 "ì" => "i", "í" => "i", "î" => "i", "ï" => "i",
    47                 "ð" => "o", "ñ" => "n", "ò" => "o", "ó" => "o",
    48                 "ô" => "o", "õ" => "o", "ö" => "o", "ø" => "o",
    49                 "ù" => "u", "ú" => "u", "û" => "u", "ü" => "u",
    50                 "ý" => "y", "ÿ" => "y");
     28if (!defined('PHPWG_ROOT_PATH'))
     29{
     30  die ("Hacking attempt!");
     31}
     32include_once(PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php');
     33//-------------------------------------------------------- sections definitions
     34if (!isset($_GET['section']))
     35{
     36  $page['section'] = 'general';
     37}
     38else
     39{
     40  $page['section'] = $_GET['section'];
     41}
     42
     43// templates for fields definitions
     44$true_false = array('type' => 'radio',
     45                    'options' => array('true' => $lang['yes'],
     46                                       'false' => $lang['no']));
     47$textfield = array('type' => 'textfield');
     48
     49$sections = array(
     50  'general' => array(
     51    'mail_webmaster' => $textfield,
     52    'prefix_thumbnail' => $textfield,
     53    'access' => array('type' => 'radio',
     54                      'options' => array(
     55                        'free' => $lang['conf_general_access_1'],
     56                        'restricted' => $lang['conf_general_access_2'])),
     57    'log' => $true_false,
     58    'mail_notification' => $true_false,
     59   ),
     60  'comments' => array(
     61    'show_comments' => $true_false,
     62    'comments_forall' => $true_false,
     63    'nb_comment_page' => $textfield,
     64    'comments_validation' => $true_false
     65   ),
     66  'default' => array(
     67    'default_language' => array('type' => 'select',
     68                                'options' => get_languages()),
     69    'nb_image_line' => $textfield,
     70    'nb_line_page' => $textfield,
     71    'default_template' => array('type' => 'select',
     72                                'options' => get_templates()),
     73    'recent_period' => $textfield,
     74    'auto_expand' => $true_false,
     75    'show_nb_comments' => $true_false
     76   ),
     77  'upload' => array(
     78    'upload_available' => $true_false,
     79    'upload_maxfilesize' => $textfield,
     80    'upload_maxwidth' => $textfield,
     81    'upload_maxheight' => $textfield,
     82    'upload_maxwidth_thumbnail' => $textfield,
     83    'upload_maxheight_thumbnail' => $textfield
     84   ),
     85  'session' => array(
     86    'authorize_cookies' => $true_false,
     87    'session_time' => $textfield,
     88    'session_id_size' => $textfield
     89   ),
     90  'metadata' => array(
     91    'use_exif' => $true_false,
     92    'use_iptc' => $true_false,
     93    'show_exif' => $true_false,
     94    'show_iptc' => $true_false
     95   )
     96 );
     97//------------------------------------------------------ $conf reinitialization
     98$result = mysql_query('SELECT param,value FROM '.CONFIG_TABLE);
     99while ($row = mysql_fetch_array($result))
     100{
     101  $conf[$row['param']] = $row['value'];
     102
     103  if (isset($_POST[$row['param']]))
     104  {
     105    $conf[$row['param']] = $_POST[$row['param']];
     106  }
     107}
    51108//------------------------------ verification and registration of modifications
    52 $error = array();
    53 if ( isset( $_POST['submit'] ) )
    54 {
     109$errors = array();
     110if (isset($_POST['submit']))
     111{
     112//   echo '<pre>';
     113//   print_r($_POST);
     114//   echo '</pre>';
     115 
    55116  $int_pattern = '/^\d+$/';
    56   // deletion of site as asked
    57   $site_deleted = false;
    58   $query = 'SELECT id';
    59   $query.= ' FROM '.SITES_TABLE;
    60   $query.= " WHERE galleries_url <> './galleries/';";
    61   $result = mysql_query( $query );
    62   while ( $row = mysql_fetch_array( $result ) )
    63   {
    64     $site = 'delete_site_'.$row['id'];
    65     if ( $_POST[$site] == 1 )
    66     {
    67       delete_site( $row['id'] );
    68       $site_deleted = true;
    69     }
    70   }
    71   // if any picture of this site were linked to another categories, we have
    72   // to update the informations of those categories. To make it simple, we
    73   // just update all the categories
    74   if ( $site_deleted )
    75   {
    76     update_category( 'all' );
    77     synchronize_all_users();
    78   }
    79   // thumbnail prefix must not contain accentuated characters
    80   $old_prefix = $_POST['prefix_thumbnail'];
    81   $prefix = strtr( $_POST['prefix_thumbnail'], $Caracs );
    82   if ( $old_prefix != $prefix )
    83   {
    84     array_push( $error, $lang['conf_err_prefixe'] );
    85   }
    86   // mail must be formatted as follows : name@server.com
    87   $pattern = '/^[\w-]+(\.[\w-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$/';
    88   if ( !preg_match( $pattern, $_POST['mail_webmaster'] ) )
    89   {
    90     array_push( $error, $lang['conf_err_mail'] );
    91   }
    92   // periods must be integer values, they represents number of days
    93   if (!preg_match($int_pattern, $_POST['recent_period'])
    94       or $_POST['recent_period'] <= 0)
    95   {
    96     array_push( $error, $lang['err_periods'] );
    97   }
    98   // session_id size must be an integer between 4 and 50
    99   if ( !preg_match( $int_pattern, $_POST['session_id_size'] )
    100        or $_POST['session_id_size'] < 4
    101        or $_POST['session_id_size'] > 50 )
    102   {
    103     array_push( $error, $lang['conf_err_sid_size'] );
    104   }
    105   // session_time must be an integer between 5 and 60, in minutes
    106   if ( !preg_match( $int_pattern, $_POST['session_time'] )
    107        or $_POST['session_time'] < 5
    108        or $_POST['session_time'] > 60 )
    109   {
    110     array_push( $error, $lang['conf_err_sid_time'] );
    111   }
    112   // the number of comments per page must be an integer between 5 and 50
    113   // included
    114   if ( !preg_match( $int_pattern, $_POST['nb_comment_page'] )
    115        or $_POST['nb_comment_page'] < 5
    116        or $_POST['nb_comment_page'] > 50 )
    117   {
    118     array_push( $error, $lang['conf_err_comment_number'] );
    119   }
    120   // the maximum upload filesize must be an integer between 10 and 1000
    121   if ( !preg_match( $int_pattern, $_POST['upload_maxfilesize'] )
    122        or $_POST['upload_maxfilesize'] < 10
    123        or $_POST['upload_maxfilesize'] > 1000 )
    124   {
    125     array_push( $error, $lang['conf_err_upload_maxfilesize'] );
    126   }
    127   // the maximum width of uploaded pictures must be an integer superior to
    128   // 10
    129   if ( !preg_match( $int_pattern, $_POST['upload_maxwidth'] )
    130        or $_POST['upload_maxwidth'] < 10 )
    131   {
    132     array_push( $error, $lang['conf_err_upload_maxwidth'] );
    133   }
    134   // the maximum height  of uploaded pictures must be an integer superior to
    135   // 10
    136   if ( !preg_match( $int_pattern, $_POST['upload_maxheight'] )
    137        or $_POST['upload_maxheight'] < 10 )
    138   {
    139     array_push( $error, $lang['conf_err_upload_maxheight'] );
    140   }
    141   // the maximum width of uploaded thumbnails must be an integer superior to
    142   // 10
    143   if ( !preg_match( $int_pattern, $_POST['upload_maxwidth_thumbnail'] )
    144        or $_POST['upload_maxwidth_thumbnail'] < 10 )
    145   {
    146     array_push( $error, $lang['conf_err_upload_maxwidth_thumbnail'] );
    147   }
    148   // the maximum width of uploaded thumbnails must be an integer superior to
    149   // 10
    150   if ( !preg_match( $int_pattern, $_POST['upload_maxheight_thumbnail'] )
    151        or $_POST['upload_maxheight_thumbnail'] < 10 )
    152   {
    153     array_push( $error, $lang['conf_err_upload_maxheight_thumbnail'] );
    154   }
    155 
    156 /*  if ( $_POST['maxwidth'] != ''
    157        and ( !preg_match( $int_pattern, $_POST['maxwidth'] )
    158              or $_POST['maxwidth'] < 50 ) )
    159   {
    160     array_push( $error, $lang['err_maxwidth'] );
    161   }
    162   if ( $_POST['maxheight']
    163        and ( !preg_match( $int_pattern, $_POST['maxheight'] )
    164              or $_POST['maxheight'] < 50 ) )
    165   {
    166     array_push( $error, $lang['err_maxheight'] );
    167   }*/
     117  switch ($page['section'])
     118  {
     119    case 'general' :
     120    {
     121      // thumbnail prefix must only contain simple ASCII characters
     122      if (!preg_match('/^[\w-]*$/', $_POST['prefix_thumbnail']))
     123      {
     124        array_push($errors, $lang['conf_general_prefix_thumbnail_error']);
     125      }
     126      // mail must be formatted as follows : name@server.com
     127      $pattern = '/^[\w-]+(\.[\w-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$/';
     128      if (!preg_match($pattern, $_POST['mail_webmaster']))
     129      {
     130        array_push($errors, $lang['conf_general_mail_webmaster_error']);
     131      }
     132      break;
     133    }
     134    case 'comments' :
     135    {
     136      // the number of comments per page must be an integer between 5 and 50
     137      // included
     138      if (!preg_match($int_pattern, $_POST['nb_comment_page'])
     139           or $_POST['nb_comment_page'] < 5
     140           or $_POST['nb_comment_page'] > 50)
     141      {
     142        array_push($errors, $lang['conf_comments_nb_comment_page_error']);
     143      }
     144      break;
     145    }
     146    case 'default' :
     147    {
     148      // periods must be integer values, they represents number of days
     149      if (!preg_match($int_pattern, $_POST['recent_period'])
     150          or $_POST['recent_period'] <= 0)
     151      {
     152        array_push($errors, $lang['conf_default_recent_period_error']);
     153      }
     154      break;
     155    }
     156    case 'upload' :
     157    {
     158      // the maximum upload filesize must be an integer between 10 and 1000
     159      if (!preg_match($int_pattern, $_POST['upload_maxfilesize'])
     160          or $_POST['upload_maxfilesize'] < 10
     161          or $_POST['upload_maxfilesize'] > 1000)
     162      {
     163        array_push($errors, $lang['conf_upload_upload_maxfilesize_error']);
     164      }
     165     
     166      foreach (array('upload_maxwidth',
     167                     'upload_maxheight',
     168                     'upload_maxwidth_thumbnail',
     169                     'upload_maxheight_thumbnail')
     170               as $field)
     171      {
     172        if (!preg_match($int_pattern, $_POST[$field])
     173          or $_POST[$field] < 10)
     174        {
     175          array_push($errors, $lang['conf_upload_'.$field.'_error']);
     176        }
     177      }
     178      break;
     179    }
     180    case 'session' :
     181    {
     182      // session_id size must be an integer between 4 and 50
     183      if (!preg_match($int_pattern, $_POST['session_id_size'])
     184          or $_POST['session_id_size'] < 4
     185          or $_POST['session_id_size'] > 50)
     186      {
     187        array_push($errors, $lang['conf_session_session_id_size_error']);
     188      }
     189      // session_time must be an integer between 5 and 60, in minutes
     190      if (!preg_match($int_pattern, $_POST['session_time'])
     191          or $_POST['session_time'] < 5
     192          or $_POST['session_time'] > 60)
     193      {
     194        array_push($errors, $lang['conf_session_session_time_error']);
     195      }
     196      break;
     197    }
     198  }
     199 
    168200  // updating configuraiton if no error found
    169   if (count($error) == 0)
     201  if (count($errors) == 0)
    170202  {
    171203    $result = mysql_query('SELECT * FROM '.CONFIG_TABLE);
    172204    while ($row = mysql_fetch_array($result))
    173205    {
    174       $config_name = $row['param'];
    175       if (isset($_POST[$config_name]))
    176       {
    177         $conf[$config_name] = $_POST[$config_name];
    178       }
    179       else
    180       {
    181         $conf[$config_name] = $row['value'];
    182       }
    183 
    184       if (isset($_POST[$config_name]))
     206      if (isset($_POST[$row['param']]))
    185207      {
    186208        $query = '
    187209UPDATE '.CONFIG_TABLE.'
    188   SET value = \''. str_replace("\'", "''", $conf[$config_name]).'\'
    189   WHERE param = \''.$config_name.'\'
     210  SET value = \''. str_replace("\'", "''", $_POST[$row['param']]).'\'
     211  WHERE param = \''.$row['param'].'\'
    190212;';
    191213        mysql_query($query);
     
    194216  }
    195217}
    196 
    197 // echo '<pre>';
    198 // print_r($conf);
    199 // echo '</pre>';
    200 
    201 $access = ($conf['access']=='free')?'ACCESS_FREE':'ACCESS_RESTRICTED';
    202 $log = ($conf['log']=='true')?'HISTORY_YES':'HISTORY_NO';
    203 $mail_notif = ($conf['mail_notification']=='true')?'MAIL_NOTIFICATION_YES':'MAIL_NOTIFICATION_NO';
    204 $show_comments = ($conf['show_comments']=='true')?'SHOW_COMMENTS_YES':'SHOW_COMMENTS_NO';
    205 $comments_all = ($conf['comments_forall']=='true')?'COMMENTS_ALL_YES':'COMMENTS_ALL_NO';
    206 $comments_validation = ($conf['comments_validation']=='true')?'VALIDATE_COMMENTS_YES':'VALIDATE_COMMENTS_NO';
    207 $expand = ($conf['auto_expand']=='true')?'EXPAND_TREE_YES':'EXPAND_TREE_NO';
    208 $nb_comments = ($conf['show_nb_comments']=='true')?'NB_COMMENTS_YES':'NB_COMMENTS_NO';
    209 $upload = ($conf['upload_available']=='true')?'UPLOAD_YES':'UPLOAD_NO';
    210 $cookie = ($conf['authorize_cookies']=='true')?'COOKIE_YES':'COOKIE_NO';
    211 $use_exif = ($conf['use_exif']=='true')?'USE_EXIF_YES':'USE_EXIF_NO';
    212 $use_iptc = ($conf['use_iptc']=='true')?'USE_IPTC_YES':'USE_IPTC_NO';
    213 $show_exif = ($conf['show_exif']=='true')?'SHOW_EXIF_YES':'SHOW_EXIF_NO';
    214 $show_iptc = ($conf['show_iptc']=='true')?'SHOW_IPTC_YES':'SHOW_IPTC_NO';
    215 
    216218//----------------------------------------------------- template initialization
    217 $template->set_filenames( array('config'=>'admin/configuration.tpl') );
    218 
    219 $template->assign_vars(array(
    220   'ADMIN_NAME'=>$conf['webmaster'],
    221   'ADMIN_MAIL'=>$conf['mail_webmaster'],
    222   'THUMBNAIL_PREFIX'=>$conf['prefix_thumbnail'],
    223   'NB_COMMENTS_PAGE'=>$conf['nb_comment_page'],
    224   'LANG_SELECT'=>language_select($conf['default_lang'], 'default_lang'),
    225   'NB_IMAGE_LINE'=>$conf['nb_image_line'],
    226   'NB_ROW_PAGE'=>$conf['nb_line_page'],
    227   'STYLE_SELECT'=>style_select($conf['default_style'], 'default_style'),
    228   'RECENT_PERIOD'=>$conf['recent_period'],
    229   'UPLOAD_MAXSIZE'=>$conf['upload_maxfilesize'],
    230   'UPLOAD_MAXWIDTH'=>$conf['upload_maxwidth'],
    231   'UPLOAD_MAXHEIGHT'=>$conf['upload_maxheight'],
    232   'TN_UPLOAD_MAXWIDTH'=>$conf['upload_maxwidth_thumbnail'],
    233   'TN_UPLOAD_MAXHEIGHT'=>$conf['upload_maxheight_thumbnail'],
    234   'SESSION_LENGTH'=>$conf['session_time'],
    235   'SESSION_ID_SIZE'=>$conf['session_id_size'],
     219$template->set_filenames(array('config'=>'admin/configuration.tpl'));
     220
     221$action = PHPWG_ROOT_PATH.'admin.php?page=configuration';
     222$action.= '&amp;section='.$page['section'];
     223
     224$template->assign_vars(
     225  array(
     226    'L_CONFIRM'=>$lang['conf_confirmation'],
     227    'L_SUBMIT'=>$lang['submit'],
     228    'F_ACTION'=>add_session_id($action)
     229   )
     230 );
     231
     232$base_url = PHPWG_ROOT_PATH.'admin.php?page=configuration&amp;section=';
     233foreach (array_keys($sections) as $section)
     234{
     235  if (isset($_GET['section']) and $_GET['section'] == $section)
     236  {
     237    $class = 'opened';
     238  }
     239  else
     240  {
     241    $class = '';
     242  }
    236243 
    237   $access=>'checked="checked"',
    238   $log=>'checked="checked"',
    239   $mail_notif=>'checked="checked"',
    240   $show_comments=>'checked="checked"',
    241   $comments_all=>'checked="checked"',
    242   $comments_validation=>'checked="checked"',
    243   $expand=>'checked="checked"',
    244   $nb_comments=>'checked="checked"',
    245   $upload=>'checked="checked"',
    246   $cookie=>'checked="checked"',
    247   $use_exif=>'checked="checked"',
    248   $use_iptc=>'checked="checked"',
    249   $show_exif=>'checked="checked"',
    250   $show_iptc=>'checked="checked"',
    251  
    252   'L_CONFIRM'=>$lang['conf_confirmation'],
    253   'L_CONF_GENERAL'=>$lang['conf_general_title'],
    254   'L_ADMIN_NAME'=>$lang['conf_general_webmaster'],
    255   'L_ADMIN_NAME_INFO'=>$lang['conf_general_webmaster_info'],
    256   'L_ADMIN_MAIL'=>$lang['conf_general_mail'],
    257   'L_ADMIN_MAIL_INFO'=>$lang['conf_general_mail_info'],
    258   'L_THUMBNAIL_PREFIX'=>$lang['conf_general_prefix'],
    259   'L_THUMBNAIL_PREFIX_INFO'=>$lang['conf_general_prefix_info'],
    260   'L_ACCESS'=>$lang['conf_general_access'],
    261   'L_ACCESS_INFO'=>$lang['conf_general_access_info'],
    262   'L_ACCESS_FREE'=>$lang['conf_general_access_1'],
    263   'L_ACCESS_RESTRICTED'=>$lang['conf_general_access_2'],
    264   'L_CONF_HISTORY'=>$lang['history'],
    265   'L_CONF_HISTORY_INFO'=>$lang['conf_general_log_info'],
    266   'L_MAIL_NOTIFICATION'=>$lang['conf_general_mail_notification'],
    267   'L_MAIL_NOTIFICATION_INFO'=>$lang['conf_general_mail_notification_info'],
    268   'L_CONF_COMMENTS'=>$lang['conf_comments_title'],
    269   'L_SHOW_COMMENTS'=>$lang['conf_comments_show_comments'],
    270   'L_SHOW_COMMENTS_INFO'=>$lang['conf_comments_show_comments_info'],
    271   'L_COMMENTS_ALL'=>$lang['conf_comments_forall'],
    272   'L_COMMENTS_ALL_INFO'=>$lang['conf_comments_forall_info'],
    273   'L_NB_COMMENTS_PAGE'=>$lang['conf_comments_comments_number'],
    274   'L_NB_COMMENTS_PAGE_INFO'=>$lang['conf_comments_comments_number_info'],
    275   'L_VALIDATE_COMMENTS'=>$lang['conf_comments_validation'],
    276   'L_VALIDATE_COMMENTS_INFO'=>$lang['conf_comments_validation_info'],
    277   'L_ABILITIES_SETTINGS'=>$lang['conf_default_title'],
    278   'L_LANG_SELECT'=>$lang['customize_language'],
    279   'L_LANG_SELECT_INFO'=>$lang['conf_default_language_info'],
    280   'L_NB_IMAGE_LINE'=>$lang['customize_nb_image_per_row'],
    281   'L_NB_IMAGE_LINE_INFO'=>$lang['conf_default_nb_image_per_row_info'],
    282   'L_NB_ROW_PAGE'=>$lang['customize_nb_row_per_page'],
    283   'L_NB_ROW_PAGE_INFO'=>$lang['conf_default_nb_row_per_page_info'],
    284   'L_STYLE_SELECT'=>$lang['customize_theme'],
    285   'L_STYLE_SELECT_INFO'=>$lang['conf_default_theme_info'],
    286   'L_RECENT_PERIOD'=>$lang['customize_recent_period'],
    287   'L_RECENT_PERIOD_INFO'=>$lang['conf_default_recent_period_info'],
    288   'L_EXPAND_TREE'=>$lang['customize_expand'],
    289   'L_EXPAND_TREE_INFO'=>$lang['conf_default_expand_info'],
    290   'L_NB_COMMENTS'=>$lang['customize_show_nb_comments'],
    291   'L_NB_COMMENTS_INFO'=>$lang['conf_default_show_nb_comments_info'],
    292   'L_AUTH_UPLOAD'=>$lang['conf_upload_available'],
    293   'L_AUTH_UPLOAD_INFO'=>$lang['conf_upload_available_info'],
    294   'L_CONF_UPLOAD'=>$lang['conf_upload_title'],
    295   'L_UPLOAD_MAXSIZE'=>$lang['conf_upload_maxfilesize'],
    296   'L_UPLOAD_MAXSIZE_INFO'=>$lang['conf_upload_maxfilesize_info'],
    297   'L_UPLOAD_MAXWIDTH'=>$lang['conf_upload_maxwidth'],
    298   'L_UPLOAD_MAXWIDTH_INFO'=>$lang['conf_upload_maxwidth_info'],
    299   'L_UPLOAD_MAXHEIGHT'=>$lang['conf_upload_maxheight'],
    300   'L_UPLOAD_MAXHEIGHT_INFO'=>$lang['conf_upload_maxheight_info'],
    301   'L_TN_UPLOAD_MAXWIDTH'=>$lang['conf_upload_maxwidth_thumbnail'],
    302   'L_TN_UPLOAD_MAXWIDTH_INFO'=>$lang['conf_upload_maxwidth_thumbnail_info'],
    303   'L_TN_UPLOAD_MAXHEIGHT'=>$lang['conf_upload_maxheight_thumbnail'],
    304   'L_TN_UPLOAD_MAXHEIGHT_INFO'=>$lang['conf_upload_maxheight_thumbnail'],
    305   'L_CONF_SESSION'=>$lang['conf_session_title'],
    306   'L_COOKIE'=>$lang['conf_session_cookie'],
    307   'L_COOKIE_INFO'=>$lang['conf_session_cookie_info'],
    308   'L_SESSION_LENGTH'=>$lang['conf_session_time'],
    309   'L_SESSION_LENGTH_INFO'=>$lang['conf_session_time_info'],
    310   'L_SESSION_ID_SIZE'=>$lang['conf_session_size'],
    311   'L_SESSION_ID_SIZE_INFO'=>$lang['conf_session_size_info'],
    312   'L_YES'=>$lang['yes'],
    313   'L_NO'=>$lang['no'],
    314   'L_SUBMIT'=>$lang['submit'],
    315   'L_CONF_METADATA'=>$lang['conf_metadata_title'],
    316   'L_USE_EXIF'=>$lang['conf_use_exif'],
    317   'L_USE_EXIF_INFO'=>$lang['conf_use_exif_info'],
    318   'L_USE_IPTC'=>$lang['conf_use_iptc'],
    319   'L_USE_IPTC_INFO'=>$lang['conf_use_iptc_info'],
    320   'L_SHOW_EXIF'=>$lang['conf_show_exif'],
    321   'L_SHOW_EXIF_INFO'=>$lang['conf_show_exif_info'],
    322   'L_SHOW_IPTC'=>$lang['conf_show_iptc'],
    323   'L_SHOW_IPTC_INFO'=>$lang['conf_show_iptc_info'],
    324  
    325   'F_ACTION'=>add_session_id(PHPWG_ROOT_PATH.'admin.php?page=configuration')
    326                          ));
    327 
     244  $template->assign_block_vars(
     245    'confmenu_item',
     246    array(
     247      'CLASS' => $class,
     248      'URL' => add_session_id($base_url.$section),
     249      'NAME' => $lang['conf_'.$section.'_title']
     250     ));
     251}
     252
     253$fields = $sections[$page['section']];
     254foreach ($fields as $field_name => $field)
     255{
     256  $template->assign_block_vars(
     257    'line',
     258    array(
     259      'NAME' => $lang['conf_'.$page['section'].'_'.$field_name],
     260      'INFO' => $lang['conf_'.$page['section'].'_'.$field_name.'_info']
     261     ));
     262  if ($field['type'] == 'textfield')
     263  {
     264    $template->assign_block_vars(
     265      'line.textfield',
     266      array(
     267        'NAME' => $field_name,
     268        'VALUE' => $conf[$field_name]
     269       ));
     270  }
     271  else if ($field['type'] == 'radio')
     272  {
     273    foreach ($field['options'] as $option_value => $option)
     274    {
     275      if ($conf[$field_name] == $option_value)
     276      {
     277        $checked = 'checked="checked"';
     278      }
     279      else
     280      {
     281        $checked = '';
     282      }
     283     
     284      $template->assign_block_vars(
     285        'line.radio',
     286        array(
     287          'NAME' => $field_name,
     288          'VALUE' => $option_value,
     289          'CHECKED' => $checked,
     290          'OPTION' => $option
     291         ));
     292    }
     293  }
     294  else if ($field['type'] == 'select')
     295  {
     296    $template->assign_block_vars(
     297      'line.select',
     298      array(
     299        'NAME' => $field_name
     300       ));
     301    foreach ($field['options'] as $option_value => $option)
     302    {
     303      if ($conf[$field_name] == $option_value)
     304      {
     305        $selected = 'selected="selected"';
     306      }
     307      else
     308      {
     309        $selected = '';
     310      }
     311     
     312      $template->assign_block_vars(
     313        'line.select.select_option',
     314        array(
     315          'VALUE' => $option_value,
     316          'SELECTED' => $selected,
     317          'OPTION' => $option
     318         ));
     319    }
     320  }
     321}
    328322//-------------------------------------------------------------- errors display
    329 if ( sizeof( $error ) != 0 )
     323if (count($errors) != 0)
    330324{
    331325  $template->assign_block_vars('errors',array());
    332   for ( $i = 0; $i < sizeof( $error ); $i++ )
    333   {
    334     $template->assign_block_vars('errors.error',array('ERROR'=>$error[$i]));
    335   }
    336 }
    337 elseif ( isset( $_POST['submit'] ) )
     326  foreach ($errors as $error)
     327  {
     328    $template->assign_block_vars('errors.error',array('ERROR'=>$error));
     329  }
     330}
     331else if (isset($_POST['submit']))
    338332{
    339333  $template->assign_block_vars('confirmation' ,array());
    340 }
    341 //------------------------------------------------ remote sites administration
    342 $query = 'select id,galleries_url';
    343 $query.= ' from '.SITES_TABLE;
    344 $query.= " where galleries_url <> './galleries/';";
    345 $result = mysql_query( $query );
    346 if ( mysql_num_rows( $result ) > 0 )
    347 {
    348   $vtp->addSession( $sub, 'remote_sites' );
    349   $i = 0;
    350   while ( $row = mysql_fetch_array( $result ) )
    351   {
    352     $vtp->addSession( $sub, 'site' );
    353     $vtp->setVar( $sub, 'site.url', $row['galleries_url'] );
    354     $vtp->setVar( $sub, 'site.id', $row['id'] );
    355     if ( $i == 0 )
    356     {
    357       $vtp->addSession( $sub, 'rowspan' );
    358       $vtp->setVar( $sub, 'rowspan.nb_sites', mysql_num_rows( $result ) );
    359       $vtp->closeSession( $sub, 'rowspan' );
    360     }
    361     $vtp->closeSession( $sub, 'site' );
    362     $i++;
    363   }
    364   $vtp->closeSession( $sub, 'remote_sites' );
    365334}
    366335//----------------------------------------------------------- sending html code
Note: See TracChangeset for help on using the changeset viewer.