Add the ability to set the id attribute of all Printer elements
authorRobert Sesek <rsesek@bluestatic.org>
Wed, 26 Mar 2008 18:11:25 +0000 (14:11 -0400)
committerRobert Sesek <rsesek@bluestatic.org>
Wed, 26 Mar 2008 18:11:25 +0000 (14:11 -0400)
* PrinterAbstract.php: New id ivar
(BSPrinterAbstract::setId): New method
(BSPrinterAbstract::_prepareStyle): Add the id attribute if it's present

CHANGES
PrinterAbstract.php

diff --git a/CHANGES b/CHANGES
index be3b50574cbe9f17c10b72400c318f4bad133d7e..8e8553edb8e6ff1d7aad7fb9482657dde30df2d5 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,4 +2,4 @@
 ===================
 - Change: BSPrinterElementTable:__construct() can now take straight strings and convert them into BSPrinterElementLabel's
 - New: BSPrinterRootPage::setHeaderCode() allows injecting in between the <head> tag of the root page element (creates BSPrinterRootPage::$headerCode)
-
+- New: BSPrinterAbstract::setId() allows all elements to have an id attribute added in _prepareStyle()
index e8ad7d3c4d54e6b98e50f0f2951d4b32c057eaa7..08a91abe62b685b42bd161f347c62c78b68f15ae 100644 (file)
@@ -50,6 +50,12 @@ abstract class BSPrinterAbstract
         */
        protected $cssClass = ':swap:';
        
+       /**
+        * DOM ID of the element
+        * @var string
+        */
+       protected $id;
+       
        /**
         * Fluent object instantiation
         */
@@ -86,6 +92,17 @@ abstract class BSPrinterAbstract
                return $this;
        }
        
+       /**
+        * Sets the DOM/CSS ID of the element
+        *
+        * @param       string  The ID
+        */
+       public function setId($id)
+       {
+               $this->id = $id;
+               return $this;
+       }
+       
        /**
         * Returns a string of CSS style attributes
         *
@@ -93,7 +110,7 @@ abstract class BSPrinterAbstract
         */
        protected function _prepareStyle()
        {
-               if (empty($this->style) && empty($this->cssClass))
+               if (empty($this->style) && empty($this->cssClass) && empty($this->id))
                {
                        return;
                }
@@ -126,6 +143,10 @@ abstract class BSPrinterAbstract
                {
                        $string .= ' style="' . $style . '"';
                }
+               if ($this->id)
+               {
+                       $string .= ' id="' . $this->id . '"';
+               }
                
                return $string;
        }