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

Last change on this file since 2290 was 2290, checked in by rvelices, 16 years ago
  • remove compatibility with old template ...
  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 4.0 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | PhpWebGallery - a PHP based picture gallery                           |
4// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
5// | Copyright (C) 2003-2008 PhpWebGallery Team - http://phpwebgallery.net |
6// +-----------------------------------------------------------------------+
7// | file          : $Id: tabsheet.class.php 2290 2008-03-23 00:04:46Z rvelices $
8// | last update   : $Date: 2008-03-23 00:04:46 +0000 (Sun, 23 Mar 2008) $
9// | last modifier : $Author: rvelices $
10// | revision      : $Revision: 2290 $
11// +-----------------------------------------------------------------------+
12// | This program is free software; you can redistribute it and/or modify  |
13// | it under the terms of the GNU General Public License as published by  |
14// | the Free Software Foundation                                          |
15// |                                                                       |
16// | This program is distributed in the hope that it will be useful, but   |
17// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
18// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
19// | General Public License for more details.                              |
20// |                                                                       |
21// | You should have received a copy of the GNU General Public License     |
22// | along with this program; if not, write to the Free Software           |
23// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
24// | USA.                                                                  |
25// +-----------------------------------------------------------------------+
26
27class tabsheet
28{
29  var $sheets;
30  var $name;
31  var $titlename;
32  var $selected;
33
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  }
45
46  /*
47     add a tab
48  */
49  function add($name, $caption, $url, $selected = false)
50  {
51    if (!isset($this->sheets[$name]))
52    {
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;
119    }
120  }
121
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(
141        array($this->titlename => '['.$selected_tab['caption'].']'));
142    }
143
144    $template->assign_var_from_handle($this->name, 'tabsheet');
145    $template->clear_assign('tabsheet');
146  }
147}
148
149?>
Note: See TracBrowser for help on using the repository browser.