]> src.bluestatic.org Git - isso.git/blob - PrinterElement.php
Fixing another call to BSApp::GetType() and switching to using the ::Registry()
[isso.git] / PrinterElement.php
1 <?php
2 /*=====================================================================*
3 || ###################################################################
4 || # Blue Static ISSO Framework
5 || # Copyright (c)2002-2007 Blue Static
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 2 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 Element Abstract Class (PrinterElement.php)
24 *
25 * @package ISSO
26 */
27
28 /**
29 * Printer Element
30 *
31 * This abstract class is used for all printer elements and describes
32 * the basic functionality of an element.
33 *
34 * @author Blue Static
35 * @copyright Copyright (c)2002 - 2007, Blue Static
36 * @package ISSO
37 *
38 */
39 abstract class BSPrinterElement
40 {
41 /**
42 * Style information
43 * @var array
44 */
45 protected $style = array();
46
47 /**
48 * The CSS class to use
49 * @var string
50 */
51 protected $cssClass = ':swap:';
52
53 /**
54 * Tells the element to paint itself (and any children)
55 */
56 public abstract function paint();
57
58 // ###################################################################
59 /**
60 * Sets the CSS class to use. Use ":swap:" to alternate
61 *
62 * @param string CSS class
63 */
64 public function setCssClass($class)
65 {
66 $this->cssClass = $class;
67 }
68
69 // ###################################################################
70 /**
71 * Sets the style information
72 */
73 public function setStyle(Array $attributes)
74 {
75 $this->style = $attributes;
76 }
77
78 // ###################################################################
79 /**
80 * Returns a string of CSS style attributes
81 *
82 * @return string CSS attributes
83 */
84 protected function _prepareStyle()
85 {
86 if (empty($this->style) AND empty($this->cssClass))
87 {
88 return;
89 }
90
91 if ($this->cssClass == ':swap:')
92 {
93 BSFunctions::SwapCssClasses();
94 $class = BSFunctions::$cssClass;
95 }
96 else
97 {
98 $class = $this->cssClass;
99 }
100
101 $attrs = array();
102
103 foreach ($this->style AS $prop => $value)
104 {
105 $attrs[] = $prop . ': ' . $value;
106 }
107
108 $style = implode('; ', $attrs);
109
110 $string = '';
111 if ($class)
112 {
113 $string .= ' class="' . $class . '"';
114 }
115 if ($style)
116 {
117 $string .= ' style="' . $style . '"';
118 }
119
120 return $string;
121 }
122 }
123
124 ?>