Changeset 2226

Show
Ignore:
Timestamp:
02/29/08 00:41:47 (5 years ago)
Author:
rub
Message:

0000809: Use more php classes implementation

Use class for tabsheet like grum class
Change way for tabsheet

Location:
trunk
Files:
7 modified
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/admin/cat_options.php

    r2223 r2226  
    3131 
    3232include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); 
    33 include_once(PHPWG_ROOT_PATH.'admin/include/functions_tabsheet.inc.php'); 
     33include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); 
    3434 
    3535// +-----------------------------------------------------------------------+ 
     
    160160 ); 
    161161 
     162// TabSheet 
     163$tabsheet = new tabsheet(); 
    162164// TabSheet initialization 
    163165$opt_link = $link_start.'cat_options&section='; 
    164 $tabsheet = array 
    165 ( 
    166   'status' => array 
    167    ( 
    168     'caption' => l10n('cat_security'), 
    169     'url' => $opt_link.'status' 
    170    ), 
    171   'visible' => array 
    172    ( 
    173     'caption' => l10n('lock'), 
    174     'url' => $opt_link.'visible' 
    175    ), 
    176   'upload' => array 
    177    ( 
    178     'caption' => l10n('upload'), 
    179     'url' => $opt_link.'upload' 
    180    ), 
    181   'comments' => array 
    182    ( 
    183     'caption' => l10n('comments'), 
    184     'url' => $opt_link.'comments' 
    185    ), 
    186 ); 
    187  
     166$tabsheet->add('status', l10n('cat_security'), $opt_link.'status'); 
     167$tabsheet->add('visible', l10n('lock'), $opt_link.'visible'); 
     168$tabsheet->add('upload', l10n('upload'), $opt_link.'upload'); 
     169$tabsheet->add('comments', l10n('comments'), $opt_link.'comments'); 
    188170if ($conf['allow_random_representative']) 
    189171{ 
    190   $tabsheet['representative'] = 
    191     array 
    192     ( 
    193       'caption' => l10n('Representative'), 
    194       'url' => $opt_link.'representative' 
    195     ); 
    196 } 
    197 $tabsheet[$page['section']]['selected'] = true; 
    198  
     172  $tabsheet->add('representative', l10n('Representative'), $opt_link.'representative'); 
     173} 
     174// TabSheet selection 
     175$tabsheet->select($page['section']); 
    199176// Assign tabsheet to template 
    200 $template->assign( 
    201     array( 
    202       'tabsheet' => $tabsheet, 
    203       'TABSHEET_TITLE' => $tabsheet[$page['section']]['caption'] 
    204     ) 
    205   ); 
     177$tabsheet->assign(); 
    206178 
    207179// +-----------------------------------------------------------------------+ 
  • trunk/admin/configuration.php

    r2201 r2226  
    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// | branch        : BSF (Best So Far) 
     
    3232 
    3333include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); 
    34 include_once(PHPWG_ROOT_PATH.'admin/include/functions_tabsheet.inc.php'); 
     34include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); 
    3535 
    3636// +-----------------------------------------------------------------------+ 
     
    158158$template->set_filename('config', 'admin/configuration.tpl'); 
    159159 
     160// TabSheet 
     161$tabsheet = new tabsheet(); 
    160162// TabSheet initialization 
    161 $page['tabsheet'] = array 
    162 ( 
    163   'main' => array 
    164    ( 
    165     'caption' => l10n('conf_main_title'), 
    166     'url' => $conf_link.'main' 
    167    ), 
    168   'history' => array 
    169    ( 
    170     'caption' => l10n('conf_history_title'), 
    171     'url' => $conf_link.'history' 
    172    ), 
    173   'comments' => array 
    174    ( 
    175     'caption' => l10n('conf_comments_title'), 
    176     'url' => $conf_link.'comments' 
    177    ), 
    178   'default' => array 
    179    ( 
    180     'caption' => l10n('conf_display'), 
    181     'url' => $conf_link.'default' 
    182    ) 
    183 ); 
    184  
    185 $page['tabsheet'][$page['section']]['selected'] = true; 
    186  
     163$tabsheet->add('main', l10n('conf_main_title'), $conf_link.'main'); 
     164$tabsheet->add('history', l10n('conf_history_title'), $conf_link.'history'); 
     165$tabsheet->add('comments', l10n('conf_comments_title'), $conf_link.'comments'); 
     166$tabsheet->add('default', l10n('conf_display'), $conf_link.'default'); 
     167// TabSheet selection 
     168$tabsheet->select($page['section']); 
    187169// Assign tabsheet to template 
    188 template_assign_tabsheet(); 
     170$tabsheet->assign(); 
    189171 
    190172$action = PHPWG_ROOT_PATH.'admin.php?page=configuration'; 
  • trunk/admin/include/functions_history.inc.php

    r2157 r2226  
    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$ 
     
    2525// +-----------------------------------------------------------------------+ 
    2626 
    27 include_once(PHPWG_ROOT_PATH.'admin/include/functions_tabsheet.inc.php'); 
     27include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); 
    2828 
    2929function history_tabsheet() 
     
    3131  global $page, $link_start; 
    3232 
     33  // TabSheet 
     34  $tabsheet = new tabsheet(); 
    3335  // TabSheet initialization 
    34   $page['tabsheet'] = array 
    35   ( 
    36     'stats' => array 
    37      ( 
    38       'caption' => l10n('Statistics'), 
    39       'url' => $link_start.'stats' 
    40      ), 
    41     'history' => array 
    42      ( 
    43       'caption' => l10n('Search'), 
    44       'url' => $link_start.'history' 
    45      ) 
    46   ); 
    47  
    48   $page['tabsheet'][$page['page']]['selected'] = true; 
    49  
     36  $tabsheet->add('stats', l10n('Statistics'), $link_start.'stats'); 
     37  $tabsheet->add('history', l10n('Search'), $link_start.'history'); 
     38  // TabSheet selection 
     39  $tabsheet->select($page['page']); 
    5040  // Assign tabsheet to template 
    51   template_assign_tabsheet(); 
     41  $tabsheet->assign(); 
    5242} 
    5343 
  • trunk/admin/include/functions_waiting.inc.php

    r1915 r2226  
    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$ 
     
    2525// +-----------------------------------------------------------------------+ 
    2626 
    27 include_once(PHPWG_ROOT_PATH.'admin/include/functions_tabsheet.inc.php'); 
     27include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); 
    2828 
    2929function waiting_tabsheet() 
     
    3131  global $page, $link_start; 
    3232 
     33  // TabSheet 
     34  $tabsheet = new tabsheet(); 
    3335  // TabSheet initialization 
    34   $page['tabsheet'] = array 
    35   ( 
    36     'comments' => array 
    37      ( 
    38       'caption' => l10n('comments'), 
    39       'url' => $link_start.'comments' 
    40      ), 
    41     'upload' => array 
    42      ( 
    43       'caption' => l10n('upload_pictures'), 
    44       'url' => $link_start.'upload' 
    45      ) 
    46   ); 
    47  
    48   $page['tabsheet'][$page['page']]['selected'] = true; 
    49  
     36  $tabsheet->add('comments', l10n('comments'), $link_start.'comments'); 
     37  $tabsheet->add('upload', l10n('upload_pictures'), $link_start.'upload'); 
     38  // TabSheet selection 
     39  $tabsheet->select($page['page']); 
    5040  // Assign tabsheet to template 
    51   template_assign_tabsheet(); 
     41  $tabsheet->assign(); 
    5242} 
    5343 
  • trunk/admin/include/tabsheet.class.php

    r2223 r2226  
    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$ 
     
    2525// +-----------------------------------------------------------------------+ 
    2626 
    27 /* 
    28  * Build TabSheet and assign this content to current page 
    29  * 
    30  * Uses $page['tabsheet'], it's an array of array 
    31  * 
    32  * $page['tabsheet'] description: 
    33  *  $page['tabsheet']'[url'] : Tab link 
    34  *  $page['tabsheet']['Caption'] : Tab caption 
    35  *  $page['tabsheet']['selected'] : Is the selected tab (default value false) 
    36  * 
    37  * Fill {TABSHEET} with HTML code for tabshette 
    38  * Fill {U_TABSHEET_TITLE} with formated caption of the selected tab 
    39  */ 
     27class tabsheet 
     28{ 
     29  var $sheets; 
     30  var $name; 
     31  var $titlename; 
     32  var $selected; 
    4033 
    41 function template_assign_tabsheet() 
    42 { 
    43   global $page, $template; 
    44 //THIS SHOULD BE DEPRECATED ? 
    45    
    46   $template->set_filename('tabsheet', 'admin/tabsheet.tpl'); 
    47   $template->assign('tabsheet', $page['tabsheet']); 
     34  /* 
     35    $name is the tabsheet's name inside the template .tpl file 
     36    $titlename in the template is affected by $titlename value 
     37  */ 
     38  function tabsheet($name = 'TABSHEET', $titlename = 'TABSHEET_TITLE') 
     39  { 
     40    $this->sheets = array(); 
     41    $this->name = $name; 
     42    $this->titlename = $titlename; 
     43    $this->selected = ""; 
     44  } 
    4845 
    49   foreach ($page['tabsheet'] as $tab_name => $tab) 
     46  /* 
     47     add a tab 
     48  */ 
     49  function add($name, $caption, $url, $selected = false) 
    5050  { 
    51     $is_selected = isset($tab['selected']) and $tab['selected'] === true; 
    52     if ($is_selected) 
     51    if (!isset($this->sheets[$name])) 
    5352    { 
    54       $template->assign_vars( 
    55         array('TABSHEET_TITLE' => '['.$tab['caption'].']')); 
    56       break; 
     53      $this->sheets[$name] = array('caption' => $caption, 
     54                                   'url' => $url); 
     55      if($selected) 
     56      { 
     57        $this->selected=$name; 
     58      } 
     59      return true; 
     60    } 
     61    return false; 
     62  } 
     63 
     64  /* 
     65     remove a tab 
     66  */ 
     67  function delete($name) 
     68  { 
     69    if (isset($this->sheets[$name])) 
     70    { 
     71      array_splice($this->sheets, $name, 1); 
     72 
     73      if ($this->selected == $name) 
     74      { 
     75        $this->selected = ""; 
     76      } 
     77      return true; 
     78    } 
     79    return false; 
     80  } 
     81 
     82  /* 
     83     select a tab to be active 
     84  */ 
     85  function select($name) 
     86  { 
     87    $this->selected = $name; 
     88  } 
     89 
     90  /* 
     91    set $titlename value 
     92  */ 
     93  function set_titlename($titlename) 
     94  { 
     95    $this->titlename = $titlename; 
     96    return $this->titlename; 
     97  } 
     98 
     99  /* 
     100    returns $titlename value 
     101  */ 
     102  function get_titlename() 
     103  { 
     104    return $this->titlename; 
     105  } 
     106 
     107  /* 
     108    returns properties of selected tab 
     109  */ 
     110  function get_selected() 
     111  { 
     112    if (!empty($this->selected)) 
     113    { 
     114      return $this->sheets[$this->selected]; 
     115    } 
     116    else 
     117    { 
     118      return null; 
    57119    } 
    58120  } 
    59121 
    60   $template->assign_var_from_handle('TABSHEET', 'tabsheet'); 
    61   $template->clear_assign('tabsheet'); 
     122  /* 
     123   * Build TabSheet and assign this content to current page 
     124   * 
     125   * Fill $this->$name {default value = TABSHEET} with HTML code for tabsheet 
     126   * Fill $this->titlename {default value = TABSHEET_TITLE} with formated caption of the selected tab 
     127   */ 
     128  function assign() 
     129  { 
     130    global $template; 
     131 
     132    $template->set_filename('tabsheet', 'admin/tabsheet.tpl'); 
     133    $template->assign('tabsheet', $this->sheets); 
     134    $template->assign('tabsheet_selected', $this->selected); 
     135 
     136    $selected_tab = $this->get_selected(); 
     137     
     138    if (isset($selected_tab)) 
     139    { 
     140      $template->assign_vars( 
     141        array($this->titlename => '['.$selected_tab['caption'].']')); 
     142    } 
     143 
     144    $template->assign_var_from_handle($this->name, 'tabsheet'); 
     145    $template->clear_assign('tabsheet'); 
     146  } 
    62147} 
    63148 
  • trunk/admin/notification_by_mail.php

    r2140 r2226  
    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$ 
     
    3636include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); 
    3737include_once(PHPWG_ROOT_PATH.'admin/include/functions_notification_by_mail.inc.php'); 
    38 include_once(PHPWG_ROOT_PATH.'admin/include/functions_tabsheet.inc.php'); 
     38include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); 
    3939include_once(PHPWG_ROOT_PATH.'include/common.inc.php'); 
    4040include_once(PHPWG_ROOT_PATH.'include/functions_notification.inc.php'); 
     
    611611if (is_autorize_status(ACCESS_WEBMASTER)) 
    612612{ 
     613  // TabSheet 
     614  $tabsheet = new tabsheet(); 
    613615  // TabSheet initialization 
    614   $page['tabsheet'] = array 
    615   ( 
    616     'param' => array 
    617      ( 
    618       'caption' => l10n('nbm_param_mode'), 
    619       'url' => add_url_params($base_url.get_query_string_diff(array('mode', 'select')), 
    620         array('mode' => 'param')) 
    621      ), 
    622     'subscribe' => array 
    623      ( 
    624       'caption' => l10n('nbm_subscribe_mode'), 
    625       'url' => add_url_params($base_url.get_query_string_diff(array('mode', 'select')), array('mode' => 'subscribe')), 
    626      ), 
    627     'send' => array 
    628      ( 
    629       'caption' => l10n('nbm_send_mode'), 
    630       'url' => add_url_params($base_url.get_query_string_diff(array('mode', 'select')), array('mode' => 'send')) 
    631      ) 
    632   ); 
    633  
    634   $page['tabsheet'][$page['mode']]['selected'] = true; 
    635  
     616  $tabsheet->add('param', l10n('nbm_param_mode'), 
     617    add_url_params($base_url.get_query_string_diff(array('mode', 'select')), 
     618        array('mode' => 'param'))); 
     619  $tabsheet->add('subscribe', l10n('nbm_subscribe_mode'), 
     620    add_url_params($base_url.get_query_string_diff(array('mode', 'select')), 
     621      array('mode' => 'subscribe'))); 
     622  $tabsheet->add('send', l10n('nbm_send_mode'), 
     623    add_url_params($base_url.get_query_string_diff(array('mode', 'select')), 
     624      array('mode' => 'send'))); 
     625  // TabSheet selection 
     626  $tabsheet->select($page['mode']); 
    636627  // Assign tabsheet to template 
    637   template_assign_tabsheet(); 
     628  $tabsheet->assign(); 
    638629} 
    639630 
  • trunk/template/yoga/admin/cat_options.tpl

    r2223 r2226  
    55  </ul> 
    66  <h2>{'cat_options_title'|@translate} {$TABSHEET_TITLE}</h2> 
    7   {include file='admin/tabsheet.tpl'} 
     7  {$TABSHEET} 
    88</div> 
    99 
  • trunk/template/yoga/admin/tabsheet.tpl

    r2223 r2226  
    22{if isset($tabsheet) and count($tabsheet)} 
    33<ul class="tabsheet"> 
    4 {foreach from=$tabsheet item=tab} 
    5   <li class="{if isset($tab.selected) and $tab.selected}selected_tab{else}normal_tab{/if}"><a href="{$tab.url}">{$tab.caption}</a></li> 
     4{foreach from=$tabsheet key=name item=sheet} 
     5  <li class="{if ($name == $tabsheet_selected)}selected_tab{else}normal_tab{/if}"><a href="{$sheet.url}">{$sheet.caption}</a></li> 
    66{/foreach} 
    77</ul>