1 | <?php |
---|
2 | /**************************************************************************\ |
---|
3 | * eGroupWare API - Link box generator * |
---|
4 | * http://www.egroupware.org/api * |
---|
5 | * This file written by Mark Peters <skeeter@phpgroupware.org> * |
---|
6 | * Creates listboxes using templates * |
---|
7 | * Copyright (C) 2000, 2001 Mark Peters * |
---|
8 | * -------------------------------------------------------------------------* |
---|
9 | * This library is part of the eGroupWare API * |
---|
10 | * http://www.egroupware.org/api * |
---|
11 | * ------------------------------------------------------------------------ * |
---|
12 | * This library is free software; you can redistribute it and/or modify it * |
---|
13 | * under the terms of the GNU Lesser General Public License as published by * |
---|
14 | * the Free Software Foundation; either version 2.1 of the License, * |
---|
15 | * or any later version. * |
---|
16 | * This library 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. * |
---|
19 | * See the GNU Lesser General Public License for more details. * |
---|
20 | * You should have received a copy of the GNU Lesser General Public License * |
---|
21 | * along with this library; if not, write to the Free Software Foundation, * |
---|
22 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * |
---|
23 | \**************************************************************************/ |
---|
24 | |
---|
25 | |
---|
26 | CreateObject('phpgwapi.portalbox'); |
---|
27 | |
---|
28 | class listbox extends portalbox |
---|
29 | { |
---|
30 | /* |
---|
31 | Set up the Object. You will notice, we have not reserved |
---|
32 | memory space for variables. In this circumstance it is not necessary. |
---|
33 | */ |
---|
34 | |
---|
35 | /* |
---|
36 | This is the constructor for the listbox. The only thing this does |
---|
37 | is to call the constructor of the parent class. Why? Well, whilst |
---|
38 | PHP manages a certain part of OO, one of the bits it falls down on |
---|
39 | (at the moment) is constructors within sub-classes. So, to |
---|
40 | be sure that the sub-class is instantiated with the constructor of |
---|
41 | the parent class, I simply call the parent constructor. Of course, |
---|
42 | if I then wanted to override any of the values, I could easily do so. |
---|
43 | */ |
---|
44 | function listbox($param) |
---|
45 | { |
---|
46 | $this->setvar('classname','listbox'); |
---|
47 | $this->setvar('outerwidth',300); |
---|
48 | $this->setvar('innerwidth',300); |
---|
49 | $this->setvar('width',300); |
---|
50 | |
---|
51 | @reset($param); |
---|
52 | while(list($key,$value) = each($param)) |
---|
53 | { |
---|
54 | if($key != 'title' && $key != 'primary' && $key != 'secondary' && $key != 'tertiary') |
---|
55 | { |
---|
56 | //echo 'Setting '.$key.':'.$value."<br>\n"; |
---|
57 | $this->setvar($key,$value); |
---|
58 | } |
---|
59 | } |
---|
60 | $this->portalbox($param['title'], $param['primary'], $param['secondary'], $param['tertiary']); |
---|
61 | $this->start_template(); |
---|
62 | } |
---|
63 | |
---|
64 | /* |
---|
65 | This is the only method within the class. Quite simply, as you can see |
---|
66 | it draws the table(s), placing the required data in the appropriate place. |
---|
67 | */ |
---|
68 | function draw($extra_data='') |
---|
69 | { |
---|
70 | if(count($this->data)) |
---|
71 | { |
---|
72 | $this->p->parse('row','portal_listbox_header',True); |
---|
73 | |
---|
74 | $data_count = count($this->data); |
---|
75 | for ($x = 0; $x < $data_count; ++$x) |
---|
76 | { |
---|
77 | $var = Array( |
---|
78 | 'text' => $this->data[$x]['text'], |
---|
79 | 'link' => $this->data[$x]['link'] |
---|
80 | ); |
---|
81 | $this->p->set_var($var); |
---|
82 | $this->p->parse('row','portal_listbox_link',True); |
---|
83 | } |
---|
84 | $this->p->parse('row','portal_listbox_footer',True); |
---|
85 | } |
---|
86 | $this->set_internal($extra_data); |
---|
87 | return $this->draw_box(); |
---|
88 | } |
---|
89 | } |
---|