source: extensions/GrumPluginClasses/classes/GPCTabSheet.class.inc.php @ 6702

Last change on this file since 6702 was 6702, checked in by grum, 14 years ago

Version 3.2.0
Enhance GPCTabSheet functionnalities and add the simpleTip methods

File size: 4.5 KB
Line 
1<?php
2/* -----------------------------------------------------------------------------
3  class name     : GPCTabSheet
4  class version  : 1.1.0
5  plugin version : 3.2.0
6  date           : 2010-06-20
7  ------------------------------------------------------------------------------
8  author: grum at piwigo.org
9  << May the Little SpaceFrog be with you >>
10  ------------------------------------------------------------------------------
11
12  :: HISTORY
13
14| release | date       |
15| 1.0.0   | 2010/04/18 | * create class
16|         |            |
17| 1.1.0   | 2010/06/20 | * add possibility to manage the class names for tabs
18|         |            |
19|         |            |
20|         |            |
21|         |            |
22|         |            |
23
24  ------------------------------------------------------------------------------
25
26   this class provides base functions to manage tabsheet navigation
27
28   this class extends the Piwigo tabsheet class
29
30   ---------------------------------------------------------------------- */
31
32include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
33
34class GPCTabSheet extends tabsheet
35{
36  protected $classes;
37  protected $id;
38  protected $tplFile;
39  protected $selectedTabClasses='selected_tab';
40  protected $unselectedTabClasses='normal_tab';
41  protected $normalTabClasses='';
42
43
44  /*
45    $name is the tabsheet's name inside the template .tpl file
46    $titlename in the template is affected by $titlename value
47  */
48  public function __construct($name = 'TABSHEET', $titlename = 'TABSHEET_TITLE', $classes="", $id="", $tplFile="")
49  {
50    parent::tabsheet($name, $titlename);
51    $this->classes=$classes;
52    $this->id=$id;
53    $this->setTplFile($tplFile);
54  }
55
56
57  function add($name, $caption, $url, $selected = false, $onClick='')
58  {
59    if(parent::add($name,$caption,$url,$selected))
60    {
61      $this->sheets[$name]['onClick'] = $onClick;
62      return(true);
63    }
64    return(false);
65  }
66
67  public function setClasses($classes)
68  {
69    $this->classes=$classes;
70    return($this->classes);
71  }
72
73  public function getClasses()
74  {
75    return($this->classes);
76  }
77
78  public function setTabsClasses($state, $classes)
79  {
80    if($state=='unselected')
81    {
82      $this->unselectedTabClasses=$classes;
83      return($this->unselectedTabClasses);
84    }
85    elseif($state=='selected')
86    {
87      $this->selectedTabClasses=$classes;
88      return($this->selectedTabClasses);
89    }
90    elseif($state=='normal')
91    {
92      $this->normalTabClasses=$classes;
93      return($this->normalTabClasses);
94    }
95    return("");
96  }
97
98  public function getTabsClasses($state)
99  {
100    if($state=='unselected')
101    {
102      return($this->unselectedTabClasses);
103    }
104    elseif($state=='selected')
105    {
106      return($this->selectedTabClasses);
107    }
108    elseif($state=='normal')
109    {
110      return($this->normalTabClasses);
111    }
112    return("");
113  }
114
115  public function setId($id)
116  {
117    $this->id=$id;
118    return($this->id);
119  }
120
121  public function getId()
122  {
123    return($this->id);
124  }
125
126  public function setTplFile($fileName)
127  {
128    if(file_exists($fileName) or $fileName=="")
129    {
130      $this->tplFile=$fileName;
131    }
132    return($this->tplFile);
133  }
134
135  public function getTplFile()
136  {
137    return($this->tplFile);
138  }
139
140
141  /*
142   * Build TabSheet and assign this content to current page
143   *
144   * Fill $this->$name {default value = TABSHEET} with HTML code for tabsheet
145   * Fill $this->titlename {default value = TABSHEET_TITLE} with formated caption of the selected tab
146   */
147  function assign()
148  {
149    global $template;
150
151    if($this->tplFile=="")
152    {
153      $tplFile=dirname(dirname(__FILE__)).'/templates/GPCTabSheet.tpl';
154    }
155    else
156    {
157      $tplFile=$this->tplFile;
158    }
159
160    $template->set_filename('tabsheet', $tplFile);
161    $template->assign('tabsheet', $this->sheets);
162    $template->assign('tabsheet_selected', $this->selected);
163
164    $selected_tab = $this->get_selected();
165
166    if (isset($selected_tab))
167    {
168      $template->assign(
169        array($this->titlename => '['.$selected_tab['caption'].']'));
170    }
171
172    if($this->classes!="") $template->assign('tabsheet_classes', $this->classes);
173    if($this->id!="") $template->assign('tabsheet_id', $this->id);
174
175    $template->assign('tab_classes',
176      array(
177        'unselected' => $this->getTabsClasses('unselected'),
178        'selected' => $this->getTabsClasses('selected'),
179        'normal' => $this->getTabsClasses('normal')
180      )
181    );
182
183    $template->assign_var_from_handle($this->name, 'tabsheet');
184    $template->clear_assign('tabsheet');
185  }
186}
187
188?>
Note: See TracBrowser for help on using the repository browser.