source: trunk/admin/include/tabsheet.class.php @ 3049

Last change on this file since 3049 was 3049, checked in by plg, 15 years ago

Administration: happy new year 2009, all PHP headers updated.

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 3.9 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based picture gallery                                  |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008-2009 Piwigo Team                  http://piwigo.org |
6// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
7// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
8// +-----------------------------------------------------------------------+
9// | This program is free software; you can redistribute it and/or modify  |
10// | it under the terms of the GNU General Public License as published by  |
11// | the Free Software Foundation                                          |
12// |                                                                       |
13// | This program is distributed in the hope that it will be useful, but   |
14// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
15// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
16// | General Public License for more details.                              |
17// |                                                                       |
18// | You should have received a copy of the GNU General Public License     |
19// | along with this program; if not, write to the Free Software           |
20// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
21// | USA.                                                                  |
22// +-----------------------------------------------------------------------+
23
24class tabsheet
25{
26  var $sheets;
27  var $name;
28  var $titlename;
29  var $selected;
30
31  /*
32    $name is the tabsheet's name inside the template .tpl file
33    $titlename in the template is affected by $titlename value
34  */
35  function tabsheet($name = 'TABSHEET', $titlename = 'TABSHEET_TITLE')
36  {
37    $this->sheets = array();
38    $this->name = $name;
39    $this->titlename = $titlename;
40    $this->selected = "";
41  }
42
43  /*
44     add a tab
45  */
46  function add($name, $caption, $url, $selected = false)
47  {
48    if (!isset($this->sheets[$name]))
49    {
50      $this->sheets[$name] = array('caption' => $caption,
51                                   'url' => $url);
52      if($selected)
53      {
54        $this->selected=$name;
55      }
56      return true;
57    }
58    return false;
59  }
60
61  /*
62     remove a tab
63  */
64  function delete($name)
65  {
66    if (isset($this->sheets[$name]))
67    {
68      array_splice($this->sheets, $name, 1);
69
70      if ($this->selected == $name)
71      {
72        $this->selected = "";
73      }
74      return true;
75    }
76    return false;
77  }
78
79  /*
80     select a tab to be active
81  */
82  function select($name)
83  {
84    $this->selected = $name;
85  }
86
87  /*
88    set $titlename value
89  */
90  function set_titlename($titlename)
91  {
92    $this->titlename = $titlename;
93    return $this->titlename;
94  }
95
96  /*
97    returns $titlename value
98  */
99  function get_titlename()
100  {
101    return $this->titlename;
102  }
103
104  /*
105    returns properties of selected tab
106  */
107  function get_selected()
108  {
109    if (!empty($this->selected))
110    {
111      return $this->sheets[$this->selected];
112    }
113    else
114    {
115      return null;
116    }
117  }
118
119  /*
120   * Build TabSheet and assign this content to current page
121   *
122   * Fill $this->$name {default value = TABSHEET} with HTML code for tabsheet
123   * Fill $this->titlename {default value = TABSHEET_TITLE} with formated caption of the selected tab
124   */
125  function assign()
126  {
127    global $template;
128
129    $template->set_filename('tabsheet', 'tabsheet.tpl');
130    $template->assign('tabsheet', $this->sheets);
131    $template->assign('tabsheet_selected', $this->selected);
132
133    $selected_tab = $this->get_selected();
134
135    if (isset($selected_tab))
136    {
137      $template->assign(
138        array($this->titlename => '['.$selected_tab['caption'].']'));
139    }
140
141    $template->assign_var_from_handle($this->name, 'tabsheet');
142    $template->clear_assign('tabsheet');
143  }
144}
145
146?>
Note: See TracBrowser for help on using the repository browser.