Remove the text-indent from .input
[isso.git] / PrinterAbstract.php
1 <?php
2 /*=====================================================================*
3 || ###################################################################
4 || # Blue Static ISSO Framework
5 || # Copyright (c)2005-2008 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 (PrinterAbstract.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)2005 - 2008, Blue Static
36 * @package ISSO
37 *
38 */
39 abstract class BSPrinterAbstract
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 * Fluent object instantiation
55 */
56 public abstract static function make();
57
58 /**
59 * Tells the element to paint itself (and any children)
60 */
61 public abstract function paint();
62
63 /**
64 * Sets the CSS class to use. Use ":swap:" to alternate
65 *
66 * @param string CSS class
67 *
68 * @return fluent interface
69 */
70 public function setCssClass($class)
71 {
72 $this->cssClass = $class;
73 return $this;
74 }
75
76 /**
77 * Sets the style information
78 *
79 * @param array Style attributes
80 *
81 * @return fluent interface
82 */
83 public function setStyle(Array $attributes)
84 {
85 $this->style = $attributes;
86 return $this;
87 }
88
89 /**
90 * Returns a string of CSS style attributes
91 *
92 * @return string CSS attributes
93 */
94 protected function _prepareStyle()
95 {
96 if (empty($this->style) && empty($this->cssClass))
97 {
98 return;
99 }
100
101 if ($this->cssClass == ':swap:')
102 {
103 BSFunctions::swap_css_classes();
104 $class = BSFunctions::$cssClass;
105 }
106 else
107 {
108 $class = $this->cssClass;
109 }
110
111 $attrs = array();
112
113 foreach ($this->style as $prop => $value)
114 {
115 $attrs[] = $prop . ': ' . $value;
116 }
117
118 $style = implode('; ', $attrs);
119
120 $string = '';
121 if ($class)
122 {
123 $string .= ' class="' . $class . '"';
124 }
125 if ($style)
126 {
127 $string .= ' style="' . $style . '"';
128 }
129
130 return $string;
131 }
132 }
133
134 ?>