Changeset 2245 for trunk/admin


Ignore:
Timestamp:
Mar 3, 2008, 1:50:54 PM (17 years ago)
Author:
rvelices
Message:
  • history, stats and redirect go smarty
  • lang correction
  • small change in calling check_server_plugins (use by ref param instead of global)
Location:
trunk/admin
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/history.php

    r2201 r2245  
    33// | PhpWebGallery - a PHP based picture gallery                           |
    44// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
    5 // | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
     5// | Copyright (C) 2003-2008 PhpWebGallery Team - http://phpwebgallery.net |
    66// +-----------------------------------------------------------------------+
    77// | file          : $Id$
     
    108108    $search['fields']['image_id'] = intval($_POST['image_id']);
    109109  }
    110  
     110
    111111  if (!empty($_POST['filename']))
    112112  {
     
    124124  // TODO manage inconsistency of having $_POST['image_id'] and
    125125  // $_POST['filename'] simultaneously
    126  
     126
    127127  // echo '<pre>'; print_r($search); echo '</pre>';
    128  
     128
    129129  if (!empty($search))
    130130  {
     
    140140
    141141    $search_id = mysql_insert_id();
    142    
     142
    143143    redirect(
    144144      PHPWG_ROOT_PATH.'admin.php?page=history&search_id='.$search_id
     
    160160history_tabsheet();
    161161
    162 $base_url = PHPWG_ROOT_PATH.'admin.php?page=history';
    163 
    164 $template->assign_vars(
     162$template->assign(
    165163  array(
    166164    'U_HELP' => PHPWG_ROOT_PATH.'popuphelp.php?page=history',
    167 
    168     'F_ACTION' => PHPWG_ROOT_PATH.'admin.php?page=history'
    169     )
    170   );
    171 
    172 $template->assign_vars(
    173   array(
    174     'TODAY_DAY'   => date('d', time()),
    175     'TODAY_MONTH' => date('m', time()),
    176     'TODAY_YEAR'  => date('Y', time()),
     165    'F_ACTION' => get_root_url().'admin.php?page=history'
    177166    )
    178167  );
     
    213202
    214203    $search_id = mysql_insert_id();
    215    
     204
    216205    redirect(
    217206      PHPWG_ROOT_PATH.'admin.php?page=history&search_id='.$search_id
     
    287276
    288277    $name_of_category = array();
    289    
     278
    290279    foreach ($uppercats_of as $category_id => $uppercats)
    291280    {
     
    360349    }
    361350  }
    362  
     351
    363352  $i = 0;
    364353  $first_line = $page['start'] + 1;
     
    375364    // #images.representative_filesize and add 'representative' in the
    376365    // choices of #history.image_type.
    377    
     366
    378367    if (isset($line['image_type']))
    379368    {
     
    402391        $summary['guests_IP'][ $line['IP'] ] = 0;
    403392      }
    404      
     393
    405394      $summary['guests_IP'][ $line['IP'] ]++;
    406395    }
    407    
     396
    408397    $i++;
    409    
     398
    410399    if ($i < $first_line or $i > $last_line)
    411400    {
     
    498487      }
    499488    }
    500    
    501     $template->assign_block_vars(
    502       'detail',
     489
     490    $template->append(
     491      'search_results',
    503492      array(
    504493        'DATE'      => $line['date'],
     
    515504          : '',
    516505        'TAGS'       => $tags_string,
    517         'T_CLASS'   => ($i % 2) ? 'row1' : 'row2',
    518506        )
    519507      );
     
    529517    unset($username_of[ $conf['guest_id'] ]);
    530518  }
    531  
     519
    532520  $summary['nb_members'] = count($username_of);
    533521
     
    536524  {
    537525    $member_string = $user_name.'&nbsp;<a href="';
    538     $member_string.= PHPWG_ROOT_PATH.'admin.php?page=history';
     526    $member_string.= get_root_url().'admin.php?page=history';
    539527    $member_string.= '&amp;search_id='.$page['search_id'];
    540528    $member_string.= '&amp;user_id='.$user_id;
     
    543531    $member_strings[] = $member_string;
    544532  }
    545  
    546   $template->assign_block_vars(
    547     'summary',
     533
     534  $template->assign(
     535    'search_summary',
    548536    array(
    549537      'NB_LINES' => l10n_dec(
     
    578566{
    579567  $navbar = create_navigation_bar(
    580     PHPWG_ROOT_PATH.'admin.php'.get_query_string_diff(array('start')),
     568    get_root_url().'admin.php'.get_query_string_diff(array('start')),
    581569    $page['nb_lines'],
    582570    $page['start'],
     
    584572    );
    585573
    586   $template->assign_block_vars(
    587     'navigation',
    588     array(
    589       'NAVBAR' => $navbar
    590       )
    591     );
     574  $template->assign('NAV_BAR', $navbar);
    592575}
    593576
     
    603586  {
    604587    $tokens = explode('-', $page['search']['fields']['date-after']);
    605    
     588
    606589    $form['start_year']  = (int)$tokens[0];
    607590    $form['start_month'] = (int)$tokens[1];
     
    647630}
    648631
    649 // start date
    650 get_day_list('start_day', @$form['start_day']);
    651 get_month_list('start_month', @$form['start_month']);
    652 // end date
    653 get_day_list('end_day', @$form['end_day']);
    654 get_month_list('end_month', @$form['end_month']);
    655 
    656 $template->assign_vars(
     632
     633$month_list = $lang['month'];
     634$month_list[0]='------------';
     635ksort($month_list);
     636
     637$template->assign(
    657638  array(
    658     'START_YEAR' => @$form['start_year'],
    659     'END_YEAR'   => @$form['end_year'],
    660639    'IMAGE_ID' => @$form['image_id'],
    661640    'FILENAME' => @$form['filename'],
     641
     642    'month_list' => $month_list,
     643
     644    'START_DAY_SELECTED' => @$form['start_day'],
     645    'START_MONTH_SELECTED' => @$form['start_month'],
     646    'START_YEAR' => @$form['start_year'],
     647
     648    'END_DAY_SELECTED' => @$form['end_day'],
     649    'END_MONTH_SELECTED' => @$form['end_month'],
     650    'END_YEAR'   => @$form['end_year'],
    662651    )
    663652  );
    664653
    665 foreach ($types as $option)
    666 {
    667   $selected = '';
    668  
    669   if (in_array($option, $form['types']))
    670   {
    671     $selected = 'selected="selected"';
    672   }
    673  
    674   $template->assign_block_vars(
    675     'types_option',
     654$template->assign(
    676655    array(
    677       'VALUE' => $option,
    678       'CONTENT' => l10n($option),
    679       'SELECTED' => $selected,
    680       )
    681     );
    682 }
    683 
    684 $template->assign_block_vars(
    685   'user_option',
    686   array(
    687     'VALUE'=> -1,
    688     'CONTENT' => '------------',
    689     'SELECTED' => ''
     656      'type_option_values' => $types,
     657      'type_option_selected' => $form['types']
    690658    )
    691659  );
     660
    692661
    693662$query = '
     
    698667  ORDER BY username ASC
    699668;';
    700 $result = pwg_query($query);
    701 
    702 while ($row = mysql_fetch_array($result))
    703 {
    704   $selected = '';
    705 
    706   if (isset($form['user'])
    707       and $row['id'] == $form['user'])
    708   {
    709     $selected = 'selected="selected"';
    710   }
    711  
    712   $template->assign_block_vars(
    713     'user_option',
    714     array(
    715       'VALUE' => $row['id'],
    716       'CONTENT' => $row['username'],
    717       'SELECTED' => $selected,
    718       )
    719     );
    720 }
    721 
    722 foreach ($display_thumbnails as $display_thumbnail)
    723 {
    724   $selected = '';
    725  
    726   if ($display_thumbnail === $form['display_thumbnail'])
    727   {
    728     $selected = 'selected="selected"';
    729   }
    730  
    731   $template->assign_block_vars(
    732     'display_thumbnail',
    733     array(
    734       'VALUE' => $display_thumbnail,
    735       'CONTENT' => l10n($display_thumbnail),
    736       'SELECTED' => $selected,
    737       )
    738     );
    739 }
     669$template->assign(
     670  array(
     671    'user_options' => simple_hash_from_query($query, 'id','username'),
     672    'user_options_selected' => array(@$form['user'])
     673  )
     674);
     675
     676$template->assign(
     677  array(
     678      'display_thumbnail_values' => $display_thumbnails,
     679      'display_thumbnail_selected' => array($form['display_thumbnail']),
     680    )
     681  );
    740682
    741683// +-----------------------------------------------------------------------+
  • trunk/admin/include/functions_plugins.inc.php

    r2243 r2245  
    137137 * @param bool (true for retrieve new extensions)
    138138 */
    139 function check_server_plugins($newext=false)
    140 {
    141   global $fs_plugins;
    142  
     139function check_server_plugins(& $fs_plugins, $newext=false)
     140{
    143141  foreach($fs_plugins as $plugin_id => $fs_plugin)
    144142  {
     
    151149    }
    152150  }
    153  
     151
    154152  $url = PEM_URL . '/uptodate.php?version=' . rawurlencode(PHPWG_VERSION) . '&extensions=' . implode(',', $plugins_to_check);
    155153  $url .= $newext ? '&newext=Plugin' : '';
     
    171169function extract_plugin_files($action, $source, $dest)
    172170{
    173   global $archive;
    174171  if ($archive = tempnam( PHPWG_PLUGINS_PATH, 'zip'))
    175172  {
     
    193190          $root = dirname($main_filepath); // main.inc.php path in archive
    194191          if ($action == 'upgrade')
    195           {         
     192          {
    196193            $extract_path = PHPWG_PLUGINS_PATH.$dest;
    197194          }
    198195          else
    199196          {
    200             $extract_path = PHPWG_PLUGINS_PATH 
     197            $extract_path = PHPWG_PLUGINS_PATH
    201198                . ($root == '.' ? 'extension_' . $dest : basename($root));
    202199          }
     
    223220  }
    224221  else $status = 'temp_path_error';
    225  
     222
    226223  @unlink($archive);
    227224  return $status;
  • trunk/admin/plugins_new.php

    r2243 r2245  
    5353    array_push($page['infos'], l10n('plugins_install_ok'), l10n('plugins_install_need_activate'));
    5454    break;
    55  
     55
    5656  case 'temp_path_error':
    57     array_push($page['errors'], l10n('plugins_temp_path_error')); 
     57    array_push($page['errors'], l10n('plugins_temp_path_error'));
    5858    break;
    59  
     59
    6060  case 'dl_archive_error':
    61     array_push($page['errors'], l10n('plugins_dl_archive_error')); 
     61    array_push($page['errors'], l10n('plugins_dl_archive_error'));
    6262    break;
    6363
    6464  case 'archive_error':
    65     array_push($page['errors'], l10n('plugins_archive_error')); 
     65    array_push($page['errors'], l10n('plugins_archive_error'));
    6666    break;
    6767
    6868  default:
    69     array_push($page['errors'], sprintf(l10n('plugins_extract_error'), $_GET['installstatus']), l10n('plugins_check_chmod')); 
     69    array_push($page['errors'], sprintf(l10n('plugins_extract_error'), $_GET['installstatus']), l10n('plugins_check_chmod'));
    7070  }
    7171}
     
    7474//----------------------------------------------------------------sort options
    7575$order = isset($_GET['order']) ? $_GET['order'] : 'date';
    76        
    77 $template->assign('order', 
     76
     77$template->assign('order',
    7878    array(htmlentities($my_base_url.'&order=date') => l10n('Post date'),
    7979          htmlentities($my_base_url.'&order=name') => l10n('Name'),
    8080          htmlentities($my_base_url.'&order=author') => l10n('Author')));
    81          
     81
    8282$template->assign('selected', htmlentities($my_base_url.'&order=').$order);
    8383
     
    8686// |                     start template output                             |
    8787// +-----------------------------------------------------------------------+
    88 $plugins_infos = check_server_plugins(true);
     88$plugins_infos = check_server_plugins($fs_plugins, true);
    8989if ($plugins_infos !== false)
    9090{
    9191  if ($order == 'date') krsort($plugins_infos);
    9292  else uasort($plugins_infos, 'extension_'.$order.'_compare');
    93  
     93
    9494  foreach($plugins_infos as $plugin)
    9595  {
    9696    $ext_desc = nl2br(htmlspecialchars(strip_tags(
    9797                  utf8_encode($plugin['ext_description']))));
    98    
     98
    9999    $ver_desc = sprintf(l10n('plugins_description'),
    100100            $plugin['version'],
     
    102102            nl2br(htmlspecialchars(strip_tags(
    103103              utf8_encode($plugin['description'])))));
    104  
     104
    105105    $url_auto_install = htmlentities($my_base_url)
    106106        . '&amp;extension=' . $plugin['id_extension']
     
    108108        . '%2Frevision-' . $plugin['id_revision'] . '%2F'
    109109        .  str_replace(' ', '%20',$plugin['url']);
    110    
     110
    111111    $url_download = PEM_URL .'/upload/extension-'.$plugin['id_extension']
    112112        . '/revision-' . $plugin['id_revision']
    113113        . '/' . $plugin['url'];
    114          
     114
    115115    $template->append('plugins',
    116116        array('EXT_NAME' => $plugin['ext_name'],
  • trunk/admin/plugins_update.php

    r2244 r2245  
    5959
    6060  case 'temp_path_error':
    61     array_push($page['errors'], l10n('plugins_temp_path_error')); 
     61    array_push($page['errors'], l10n('plugins_temp_path_error'));
    6262    break;
    63  
     63
    6464  case 'dl_archive_error':
    65     array_push($page['errors'], l10n('plugins_dl_archive_error')); 
     65    array_push($page['errors'], l10n('plugins_dl_archive_error'));
    6666    break;
    6767
    6868  case 'archive_error':
    69     array_push($page['errors'], l10n('plugins_archive_error')); 
     69    array_push($page['errors'], l10n('plugins_archive_error'));
    7070    break;
    7171
     
    7373    array_push($page['errors'],
    7474               sprintf(l10n('plugins_extract_error'),
    75                $_GET['upgradestatus'])); 
     75               $_GET['upgradestatus']));
    7676  }
    7777}
     
    8181// |                     start template output                             |
    8282// +-----------------------------------------------------------------------+
    83 $plugins_infos = check_server_plugins();
     83$plugins_infos = check_server_plugins($fs_plugins);
    8484
    8585if ($plugins_infos !== false)
     
    9191    {
    9292      $plugin_info = $plugins_infos[$fs_plugin['extension']];
    93      
     93
    9494      $ext_desc = nl2br(htmlspecialchars(strip_tags(
    9595                    utf8_encode($plugin_info['ext_description']))));
    96      
     96
    9797      $ver_desc = sprintf(l10n('plugins_description'),
    9898              $plugin_info['version'],
     
    100100              nl2br(htmlspecialchars(strip_tags(
    101101                utf8_encode($plugin_info['description'])))));
    102    
     102
    103103      if ($plugin_info['version'] == $fs_plugin['version'])
    104104      {
     
    117117          . '&amp;plugin=' . $plugin_id
    118118          . (
    119               (isset($db_plugins_by_id[$plugin_id]) 
    120                 and $db_plugins_by_id[$plugin_id]['state'] == 'active') ? 
     119              (isset($db_plugins_by_id[$plugin_id])
     120                and $db_plugins_by_id[$plugin_id]['state'] == 'active') ?
    121121                  '&amp;action=deactivate' : ''
    122122            )
     
    124124          . '%2Frevision-' . $plugin_info['id_revision']
    125125          . '%2F' . $plugin_info['url'];
    126        
     126
    127127        $url_download = PEM_URL.'/upload/extension-'. $fs_plugin['extension']
    128128            . '/revision-' . $plugin_info['id_revision']
    129129            . '/' . $plugin_info['url'];
    130              
     130
    131131        $template->append('plugins_not_uptodate',
    132132          array('EXT_NAME' => $fs_plugin['name'],
     
    141141      }
    142142    }
    143     else 
     143    else
    144144    {
    145145      // Can't check plugin
  • trunk/admin/stats.php

    r2187 r2245  
    389389history_tabsheet();
    390390
    391 $base_url = PHPWG_ROOT_PATH.'admin.php?page=history';
    392 
    393 $template->assign_vars(
     391$base_url = get_root_url().'admin.php?page=history';
     392
     393$template->assign(
    394394  array(
    395395    'L_STAT_TITLE' => implode($conf['level_separator'], $title_parts),
    396396    'PERIOD_LABEL' => $period_label,
    397     'U_HELP' => PHPWG_ROOT_PATH.'popuphelp.php?page=history',
    398     'F_ACTION' => PHPWG_ROOT_PATH.'admin.php?page=history',
     397    'U_HELP' => get_root_url().'popuphelp.php?page=history',
     398    'F_ACTION' => $base_url,
    399399    )
    400400  );
     
    469469    {
    470470      $url =
    471         PHPWG_ROOT_PATH.'admin.php'
     471        get_root_url().'admin.php'
    472472        .'?page=stats'
    473473        .'&amp;year='.$page['year']
     
    483483    {
    484484      $url =
    485         PHPWG_ROOT_PATH.'admin.php'
     485        get_root_url().'admin.php'
    486486        .'?page=stats'
    487487        .'&amp;year='.$page['year']
     
    495495      // at least the year is defined
    496496      $url =
    497         PHPWG_ROOT_PATH.'admin.php'
     497        get_root_url().'admin.php'
    498498        .'?page=stats'
    499499        .'&amp;year='.$i
     
    508508    }
    509509
    510     $template->assign_block_vars(
    511       'statrow',
     510    $template->append(
     511      'statrows',
    512512      array(
    513513        'VALUE' => $value,
Note: See TracChangeset for help on using the changeset viewer.