Adding base printer_css.php file
[isso.git] / printer_css.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Iris Studios Shared Object Framework [#]issoversion[#]
5 || # Copyright ©2002-[#]year[#] Iris Studios, Inc.
6 || #
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version [#]gpl[#] of the License.
10 || #
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 || # more details.
15 || #
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
21
22 /**
23 * Printer - CSS Blocks
24 * printer_css.php
25 *
26 * @package ISSO
27 */
28
29 /**
30 * Printer - CSS Blocks
31 *
32 * This framework works in conjunction with ISSO.Printer to create a unique
33 * CSS editor enviornment.
34 *
35 * @author Iris Studios, Inc.
36 * @copyright Copyright ©2002 - [#]year[#], Iris Studios, Inc.
37 * @version $Revision$
38 * @package ISSO
39 *
40 */
41 class Printer_CSS
42 {
43 /**
44 * Framework registry object
45 * @var object
46 * @access private
47 */
48 var $registry = null;
49
50 /**
51 * CSS block list
52 * @var array
53 * @access private
54 */
55 var $descriptors = array();
56
57 /**
58 * Master data set
59 * @var array
60 * @access private
61 */
62 var $masterdata = array();
63
64 /**
65 * Cutomized data set
66 * @var array
67 * @access private
68 */
69 var $customdata = array();
70
71 // ###################################################################
72 /**
73 * Constructor
74 */
75 function __construct(&$registry)
76 {
77 $this->registry =& $registry;
78 }
79
80 // ###################################################################
81 /**
82 * (PHP 4) Constructor
83 */
84 function Printer_CSS(&$registry)
85 {
86 $this->__construct($registry);
87 }
88
89 // ###################################################################
90 /**
91 * Adds a CSS information block to the array for later use
92 *
93 * @access public
94 *
95 * @param string Block title to display in thead
96 * @param string CSS class/descriptor/element name
97 * @param bool Show the link CSS information
98 */
99 function add_block($title, $descriptor, $dolink)
100 {
101 if (isset($this->descriptors["$descriptor"]))
102 {
103 trigger_error('The descriptor `' . $descriptor . '` already exists', E_USER_WARNING);
104 return;
105 }
106
107 $this->descriptors["$descriptor"] = array(
108 'title' => $title,
109 'descriptor' => $descriptor,
110 'dolink' => $dolink
111 );
112 }
113
114 // ###################################################################
115 /**
116 * Sets a master data key for a given descriptor and property
117 *
118 * @access public
119 *
120 * @param string Descriptor
121 * @param string Property
122 * @param string Value
123 */
124 function set_master_data($descriptor, $property, $value)
125 {
126 $this->masterdata["$descriptor"]["$property"] = $value;
127 }
128
129 // ###################################################################
130 /**
131 * Sets a custom data key for a given descriptor and property
132 *
133 * @access public
134 *
135 * @param string Descriptor
136 * @param string Property
137 * @param string Value
138 */
139 function set_custom_data($descriptor, $property, $value)
140 {
141 $this->customdata["$descriptor"]["$property"] = $value;
142 }
143
144 // ###################################################################
145 /**
146 * Generates the HTML needed to output the CSS editing blocks; this is
147 * done in the form of using ISSO.Printer
148 *
149 * @access public
150 */
151 function generate_blocks()
152 {
153 $print =& $this->registry->modules['printer'];
154
155 $lang = array(
156 'standard_css_attributes' => $this->registry->modules['localize']->string('Standard CSS Attributes'),
157 'extra_css_attributes' => $this->registry->modules['localize']->string('Extra CSS Attributes'),
158
159 'links_normal' => $this->registry->modules['localize']->string('Normal CSS Links'),
160 'links_visited' => $this->registry->modules['localize']->string('Visited CSS Links'),
161 'links_hover' => $this->registry->modules['localize']->string('Hover CSS Links'),
162
163 'background' => $this->registry->modules['localize']->string('Background'),
164 'font_color' => $this->registry->modules['localize']->string('Font Color'),
165 'font_style' => $this->registry->modules['localize']->string('Font Style'),
166 'font_size' => $this->registry->modules['localize']->string('Font Size'),
167 'font_family' => $this->registry->modules['localize']->string('Font Family'),
168
169 'text_decoration' => $this->registry->modules['localize']->string('Text Decoration')
170 );
171
172 foreach ($this->descriptors AS $descriptor)
173 {
174 $value = array();
175
176 $print->table_start();
177 $print->table_head($descriptor['title'] . ' (' . $descriptor['descriptor'] . ')');
178
179 $value['background'] = $this->fetch_value($descriptor['descriptor'], 'background');
180 $value['color'] = $this->fetch_value($descriptor['descriptor'], 'color');
181 $value['font_style'] = $this->fetch_value($descriptor['descriptor'], 'font-style');
182 $value['font_size'] = $this->fetch_value($descriptor['descriptor'], 'font-size');
183 $value['font_family'] = $this->fetch_value($descriptor['descriptor'], 'font-family');
184 $value['extra'] = $this->fetch_value($descriptor['descriptor'], 'extra');
185
186 $html = <<<HTML
187 <table cellspacing="0" cellpadding="4" border="0" width="100%">
188 <tr valign="top">
189 <td width="50%">
190 <fieldset>
191 <legend><strong>$lang[standard_css_attributes]</strong></legend>
192
193 <table cellspacing="0" cellpadding="2" border="0" width="100%">
194 <tr>
195 <td width="45%">$lang[background]</td>
196 <td><input name="css[$descriptor[descriptor]][background]" class="input" style="width: 100%" value="$value[background]" /></td>
197 </tr>
198 <tr>
199 <td width="45%">$lang[font_color]</td>
200 <td><input name="css[$descriptor[descriptor]][color]" class="input" style="width: 100%" value="$value[color]" /></td>
201 </tr>
202 <tr>
203 <td width="45%">$lang[font_style]</td>
204 <td><input name="css[$descriptor[descriptor]][font-style]" class="input" style="width: 100%" value="$value[font_style]" /></td>
205 </tr>
206 <tr>
207 <td width="45%">$lang[font_size]</td>
208 <td><input name="css[$descriptor[descriptor]][font-size]" class="input" style="width: 100%" value="$value[font_size]" /></td>
209 </tr>
210 <tr>
211 <td width="45%">$lang[font_family]</td>
212 <td><input name="css[$descriptor[descriptor]][font-family]" class="input" style="width: 100%" value="$value[font_family]" /></td>
213 </tr>
214 </table>
215 </fieldset>
216 </td>
217
218 <td>
219 <fieldset style="height: 115px">
220 <legend><strong>$lang[extra_css_attributes]</strong></legend>
221 <textarea name="css[$descriptor[descriptor]][extra]" style="width: 100%; height: 90%">$value[extra]</textarea>
222 </fieldset>
223 </td>
224 </tr>
225 </table>
226 HTML;
227 if ($descriptor['dolink'])
228 {
229 foreach (array('a:link' => 'a_link', 'a:visited' => 'a_visited', 'a:hover' => 'a_hover') AS $sel => $selname)
230 {
231 $value[$selname . '_background'] = $this->fetch_value($descriptor['descriptor'] . ' ' . $sel, 'background');
232 $value[$selname . '_color'] = $this->fetch_value($descriptor['descriptor'] . ' ' . $sel, 'color');
233 $value[$selname . '_text_decoration'] = $this->fetch_value($descriptor['descriptor'] . ' ' . $sel, 'text-decoration');
234 }
235
236 print_r($value);
237
238 $html .= <<<HTML
239
240 <table cellspacing="0" cellpadding="4" border="0" width="100%">
241 <tr valign="top">
242 <td width="33%">
243 <fieldset>
244 <legend><strong>$lang[links_normal]</strong></legend>
245
246 <table cellspacing="0" cellpadding="2" border="0" width="100%">
247 <tr>
248 <td width="45%">$lang[background]</td>
249 <td><input name="css[$descriptor[descriptor] a:link][background]" class="input" style="width: 100%" value="$value[a_link_background]" /></td>
250 </tr>
251 <tr>
252 <td width="45%">$lang[font_color]</td>
253 <td><input name="css[$descriptor[descriptor] a:link][color]" class="input" style="width: 100%" value="$value[a_link_color]" /></td>
254 </tr>
255 <tr>
256 <td width="45%">$lang[text_decoration]</td>
257 <td><input name="css[$descriptor[descriptor] a:link][text_decoration]" class="input" style="width: 100%" value="$value[a_link_text_decoration]" /></td>
258 </tr>
259 </table>
260 </fieldset>
261 </td>
262
263 <td width="33%">
264 <fieldset>
265 <legend><strong>$lang[links_visited]</strong></legend>
266
267 <table cellspacing="0" cellpadding="2" border="0" width="100%">
268 <tr>
269 <td width="45%">$lang[background]</td>
270 <td><input name="css[$descriptor[descriptor] a:visited][background]" class="input" style="width: 100%" value="$value[a_visited_background]" /></td>
271 </tr>
272 <tr>
273 <td width="45%">$lang[font_color]</td>
274 <td><input name="css[$descriptor[descriptor] a:visited][color]" class="input" style="width: 100%" value="$value[a_visited_color]" /></td>
275 </tr>
276 <tr>
277 <td width="45%">$lang[text_decoration]</td>
278 <td><input name="css[$descriptor[descriptor] a:visited][text_decoration]" class="input" style="width: 100%" value="$value[a_visited_text_decoration]" /></td>
279 </tr>
280 </table>
281 </fieldset>
282 </td>
283
284 <td width="33%">
285 <fieldset>
286 <legend><strong>$lang[links_hover]</strong></legend>
287
288 <table cellspacing="0" cellpadding="2" border="0" width="100%">
289 <tr>
290 <td width="45%">$lang[background]</td>
291 <td><input name="css[$descriptor[descriptor] a:hover][background]" class="input" style="width: 100%" value="$value[a_hover_background]" /></td>
292 </tr>
293 <tr>
294 <td width="45%">$lang[font_color]</td>
295 <td><input name="css[$descriptor[descriptor] a:hover][color]" class="input" style="width: 100%" value="$value[a_hover_color]" /></td>
296 </tr>
297 <tr>
298 <td width="45%">$lang[text_decoration]</td>
299 <td><input name="css[$descriptor[descriptor] a:hover][text_decoration]" class="input" style="width: 100%" value="$value[a_hover_text_decoration]" /></td>
300 </tr>
301 </table>
302 </fieldset>
303 </td>
304 </tr>
305 </table>
306 HTML;
307 }
308
309 $print->row_span($html, 'alt2', 'left', 1);
310
311 $print->table_end();
312 }
313 }
314
315 // ###################################################################
316 /**
317 * Returns the value of a given descriptor and property by comparing
318 * the mater set and custom set then returning the right one
319 *
320 * @access private
321 *
322 * @param string Descriptor
323 * @param string Property
324 *
325 * @return string Value of the given property
326 */
327 function fetch_value($descriptor, $property)
328 {
329 if ($this->customdata["$descriptor"]["$property"] == '')
330 {
331 return $this->masterdata["$descriptor"]["$property"];
332 }
333 else
334 {
335 return $this->customdata["$desciptor"]["$property"];
336 }
337 }
338 }
339
340 /*=====================================================================*\
341 || ###################################################################
342 || # $HeadURL$
343 || # $Id$
344 || ###################################################################
345 \*=====================================================================*/
346 ?>