1 | <?php |
---|
2 | /**************************************************************************\ |
---|
3 | * eGroupWare API - Portal Box manager * |
---|
4 | * This file written by Joseph Engo <jengo@phpgroupware.org> * |
---|
5 | * Helps manage the portal boxes for eGroupWares main page * |
---|
6 | * Copyright (C) 2000, 2001 Joseph Engo * |
---|
7 | * -------------------------------------------------------------------------* |
---|
8 | * This library is part of the eGroupWare API * |
---|
9 | * http://www.egroupware.org/api * |
---|
10 | * ------------------------------------------------------------------------ * |
---|
11 | * This library is free software; you can redistribute it and/or modify it * |
---|
12 | * under the terms of the GNU Lesser General Public License as published by * |
---|
13 | * the Free Software Foundation; either version 2.1 of the License, * |
---|
14 | * or any later version. * |
---|
15 | * This library is distributed in the hope that it will be useful, but * |
---|
16 | * WITHOUT ANY WARRANTY; without even the implied warranty of * |
---|
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * |
---|
18 | * See the GNU Lesser General Public License for more details. * |
---|
19 | * You should have received a copy of the GNU Lesser General Public License * |
---|
20 | * along with this library; if not, write to the Free Software Foundation, * |
---|
21 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * |
---|
22 | \**************************************************************************/ |
---|
23 | |
---|
24 | |
---|
25 | class portalbox |
---|
26 | { |
---|
27 | //Set up the Object, reserving memory space for variables |
---|
28 | |
---|
29 | var $outerwidth; |
---|
30 | var $outerbordercolor; |
---|
31 | var $outerborderwidth = 1; |
---|
32 | var $titlebgcolor; |
---|
33 | var $width; |
---|
34 | var $innerwidth; |
---|
35 | var $innerbgcolor; |
---|
36 | var $controls; |
---|
37 | var $header_background_image; |
---|
38 | var $classname; |
---|
39 | var $up; |
---|
40 | var $down; |
---|
41 | var $close; |
---|
42 | var $question; |
---|
43 | var $edit; |
---|
44 | |
---|
45 | var $data = Array(); |
---|
46 | |
---|
47 | // Textual variables |
---|
48 | var $title; |
---|
49 | |
---|
50 | // Template |
---|
51 | var $p; |
---|
52 | |
---|
53 | /* |
---|
54 | Use these functions to get and set the values of this |
---|
55 | object's variables. This is good OO practice, as it means |
---|
56 | that datatype checking can be completed and errors raised accordingly. |
---|
57 | */ |
---|
58 | function setvar($var,$value='') |
---|
59 | { |
---|
60 | if ($value=='') |
---|
61 | { |
---|
62 | global $$var; |
---|
63 | $value = $$var; |
---|
64 | } |
---|
65 | $this->$var = $value; |
---|
66 | // echo $var." = ".$this->$var."<br>\n"; |
---|
67 | } |
---|
68 | |
---|
69 | function getvar($var='') |
---|
70 | { |
---|
71 | if ($var=='' || !isset($this->$var)) |
---|
72 | { |
---|
73 | echo 'Programming Error: '.$this->getvar('classname').'->getvar('.$var.')!<br>'."\n"; |
---|
74 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
75 | } |
---|
76 | //echo "Var = ".$var."<br>\n"; |
---|
77 | //echo $var." = ".$this->$var."<br>\n"; |
---|
78 | return $this->$var; |
---|
79 | } |
---|
80 | |
---|
81 | /* |
---|
82 | This is the constructor for the object. |
---|
83 | */ |
---|
84 | function portalbox($title='', $primary='', $secondary='', $tertiary='') |
---|
85 | { |
---|
86 | $this->setvar('title',$title); |
---|
87 | // echo 'After SetVar Title = '.$this->getvar('title')."<br>\n"; |
---|
88 | $this->setvar('titlebgcolor',$primary); |
---|
89 | $this->setvar('innerbgcolor',$secondary); |
---|
90 | $this->setvar('outerbordercolor',$tertiary); |
---|
91 | } |
---|
92 | |
---|
93 | function start_template() |
---|
94 | { |
---|
95 | $this->p = CreateObject('phpgwapi.Template',$GLOBALS['phpgw']->common->get_tpl_dir('home')); |
---|
96 | $this->p->set_file( |
---|
97 | array( |
---|
98 | 'PORTAL' => 'portal.tpl' |
---|
99 | ) |
---|
100 | ); |
---|
101 | |
---|
102 | $this->p->set_block('PORTAL','portal_box','portal_box'); |
---|
103 | $this->p->set_block('PORTAL','portal_row','portal_row'); |
---|
104 | $this->p->set_block('PORTAL','portal_listbox_header','portal_listbox_header'); |
---|
105 | $this->p->set_block('PORTAL','portal_listbox_link','portal_listbox_link'); |
---|
106 | $this->p->set_block('PORTAL','portal_listbox_footer','portal_listbox_footer'); |
---|
107 | $this->p->set_block('PORTAL','portal_control','portal_control'); |
---|
108 | $this->p->set_block('PORTAL','link_field','link_field'); |
---|
109 | |
---|
110 | $var = Array( |
---|
111 | 'outer_border' => $this->getvar('outerborderwidth'), |
---|
112 | 'outer_width' => $this->getvar('width'), |
---|
113 | 'outer_bordercolor' => $this->getvar('outerbordercolor'), |
---|
114 | 'outer_bgcolor' => $this->getvar('titlebgcolor'), |
---|
115 | 'title' => $this->getvar('title'), |
---|
116 | 'inner_width' => $this->getvar('width'), |
---|
117 | 'inner_bgcolor' => $this->getvar('innerbgcolor'), |
---|
118 | 'header_background_image' => $this->getvar('header_background_image'), |
---|
119 | 'control_link' => '' |
---|
120 | ); |
---|
121 | $this->p->set_var($var); |
---|
122 | $this->p->set_var('row','',False); |
---|
123 | } |
---|
124 | |
---|
125 | function set_controls($control='',$control_param='') |
---|
126 | { |
---|
127 | if($control != '' && $control_param != '') |
---|
128 | { |
---|
129 | $this->setvar($control,$GLOBALS['phpgw']->link($control_param['url'],'app='.$control_param['app'].'&control='.$control)); |
---|
130 | } |
---|
131 | } |
---|
132 | |
---|
133 | function set_internal($data='') |
---|
134 | { |
---|
135 | if($data=='' && !count($this->data)) |
---|
136 | { |
---|
137 | $data = '<td> </td>'; |
---|
138 | } |
---|
139 | $this->p->set_var('output',$data); |
---|
140 | $this->p->parse('row','portal_row',true); |
---|
141 | } |
---|
142 | |
---|
143 | function draw_box() |
---|
144 | { |
---|
145 | $control = ''; |
---|
146 | if($this->up || $this->down || $this->close || $this->question || $this->edit) |
---|
147 | { |
---|
148 | $control_array = Array( |
---|
149 | 'up', |
---|
150 | 'down', |
---|
151 | /*'question', |
---|
152 | 'close', |
---|
153 | 'edit'*/ |
---|
154 | ); |
---|
155 | @reset($control_array); |
---|
156 | while(list($key,$param) = each($control_array)) |
---|
157 | { |
---|
158 | if(isset($this->$param) && $this->$param) |
---|
159 | { |
---|
160 | $image_width = 15; |
---|
161 | if($param == 'edit') |
---|
162 | { |
---|
163 | $image_width = 30; |
---|
164 | } |
---|
165 | $this->p->set_var('link_field_data','<a href="'.$this->$param.'"><img src="'.$GLOBALS['phpgw']->common->image('phpgwapi',$param.'.button').'" border="0" width="'.$image_width.'" height="15" alt="'.lang($param).'"></a>'); |
---|
166 | $this->p->parse('control_link','link_field',True); |
---|
167 | } |
---|
168 | } |
---|
169 | $this->p->parse('portal_controls','portal_control',True); |
---|
170 | } |
---|
171 | return $this->p->fp('out','portal_box'); |
---|
172 | } |
---|
173 | } |
---|