]>
src.bluestatic.org Git - isso.git/blob - PrinterElement.php
2 /*=====================================================================*
3 || ###################################################################
4 || # Blue Static ISSO Framework
5 || # Copyright (c)2005-2008 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 (PrinterElement.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 - 2008, Blue Static
39 abstract class BSPrinterElement
45 protected $style = array();
48 * The CSS class to use
51 protected $cssClass = ':swap:';
54 * Fluent object instantiation
56 public abstract static function make();
59 * Tells the element to paint itself (and any children)
61 public abstract function paint();
63 // ###################################################################
65 * Sets the CSS class to use. Use ":swap:" to alternate
67 * @param string CSS class
69 * @return fluent interface
71 public function setCssClass($class)
73 $this->cssClass
= $class;
77 // ###################################################################
79 * Sets the style information
81 * @param array Style attributes
83 * @return fluent interface
85 public function setStyle(Array $attributes)
87 $this->style
= $attributes;
91 // ###################################################################
93 * Returns a string of CSS style attributes
95 * @return string CSS attributes
97 protected function _prepareStyle()
99 if (empty($this->style
) AND empty($this->cssClass
))
104 if ($this->cssClass
== ':swap:')
106 BSFunctions
::SwapCssClasses();
107 $class = BSFunctions
::$cssClass;
111 $class = $this->cssClass
;
116 foreach ($this->style
AS $prop => $value)
118 $attrs[] = $prop . ': ' . $value;
121 $style = implode('; ', $attrs);
126 $string .= ' class="' . $class . '"';
130 $string .= ' style="' . $style . '"';