2 /*=====================================================================*
3 || ###################################################################
4 || # Blue Static ISSO Framework
5 || # Copyright (c)2005-2009 Blue Static
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.
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
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 \*=====================================================================*/
23 * Printer Element Abstract Class (PrinterAbstract.php)
31 * This abstract class is used for all printer elements and describes
32 * the basic functionality of an element.
35 * @copyright Copyright (c)2005 - 2009, Blue Static
39 abstract class BSPrinterAbstract
45 protected $style = array();
48 * The CSS class to use
51 protected $cssClass = ':swap:';
54 * DOM ID of the element
60 * Fluent object instantiation
62 public abstract static function make();
65 * Tells the element to paint itself (and any children)
67 public abstract function paint();
70 * To-string method which invokes paint()
72 public function __toString()
74 return $this->paint();
78 * Sets the CSS class to use. Use ":swap:" to alternate
80 * @param string CSS class
82 * @return fluent interface
84 public function setCssClass($class)
86 $this->cssClass
= $class;
91 * Sets the style information
93 * @param array Style attributes
95 * @return fluent interface
97 public function setStyle(Array $attributes)
99 $this->style
= $attributes;
104 * Sets the DOM/CSS ID of the element
106 * @param string The ID
108 * @return fluent interface
110 public function setId($id)
117 * Returns a string of style attributes, that include id, style, and class
119 * @return string Style attributes
121 protected function _prepareStyle()
123 if (empty($this->style
) && empty($this->cssClass
) && empty($this->id
))
128 if ($this->cssClass
== ':swap:')
130 BSFunctions
::swap_css_classes();
131 $class = BSFunctions
::$cssClass;
135 $class = $this->cssClass
;
140 foreach ($this->style
as $prop => $value)
142 $attrs[] = $prop . ': ' . $value;
145 $style = implode('; ', $attrs);
150 $string .= ' class="' . $class . '"';
154 $string .= ' style="' . $style . '"';
158 $string .= ' id="' . $this->id
. '"';