Merge ../butv10/core/framework
authorRobert Sesek <rsesek@bluestatic.org>
Thu, 27 Mar 2008 04:32:33 +0000 (00:32 -0400)
committerRobert Sesek <rsesek@bluestatic.org>
Thu, 27 Mar 2008 04:32:33 +0000 (00:32 -0400)
Conflicts:

CHANGES

Api.php
CHANGES
PrinterAbstract.php
PrinterRootPage.php

diff --git a/Api.php b/Api.php
index 3f5d8603c348e5f7c1a00a0373360ea1d87034c0..89d8dd90b318640fef09c625a641551b5dd8ac34 100644 (file)
--- a/Api.php
+++ b/Api.php
@@ -174,6 +174,25 @@ abstract class BSApi
                }
        }
        
+       /**
+        * Sets an array of data into the API, ignoring things in $exclude. Keys
+        * in the array that don't exist in the API will be ignored.
+        * 
+        * @param       array   A dictionary of field names and values to set
+        * @param       array   Array of keys to exclude
+        */
+       public function setArray(Array $data, $exclude = array())
+       {
+               foreach ($data as $key => $value)
+               {
+                       if (in_array($key, $exclude) || !isset($this->fields[$key]))
+                       {
+                               continue;
+                       }
+                       $this->set($key, $value);
+               }
+       }
+       
        /**
         * Sets a value, sanitizes it, and validates it
         *
diff --git a/CHANGES b/CHANGES
index cfec3816d545e086c86a3af926e9b3efcc005594..5219aa34429609a26f6fbe1fd10e48a4b769fb3c 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,7 @@
 3.1.0
 ===================
 - Change: BSPrinterElementTable:__construct() can now take straight strings and convert them into BSPrinterElementLabel's
-- Change: Removed the text indent on .input elements in BSPrinter
\ No newline at end of file
+- Change: Removed the text indent on .input elements in BSPrinter
+- 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()
+- New: Added an ability to quick-set API information via an array with BSApi::setArray()
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;
        }
index 2724239f9e0a10d1fd052b1e60551b48950fcf2f..75ed20c1366c11a0cb74bed9365d24e734091ec1 100644 (file)
@@ -52,6 +52,12 @@ class BSPrinterRootPage extends BSPrinterRootAbstract
         */
        private $navigator;
        
+       /**
+        * The header code for the page
+        * @var string
+        */
+       private $headerCode;
+       
        /**
         * Constructor
         *
@@ -97,6 +103,16 @@ class BSPrinterRootPage extends BSPrinterRootAbstract
                return $this->navigatior;
        }
        
+       /**
+        * Sets the code to inject into the <head> element of the page
+        *
+        * @param       string  Code
+        */
+       public function setHeaderCode($code)
+       {
+               $this->headerCode = $code;
+       }
+       
        /**
         * Creates a redirect to another page; constructs the header and footer
         * (therefore execution stops)
@@ -283,6 +299,7 @@ class BSPrinterRootPage extends BSPrinterRootAbstract
                echo "\n\t<title>" . BSPrinter::get_realm() . " - " . $this->title . "</title>";
                echo "\n\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=" . $language['charset'] . "\" />";
                echo "\n\t<link rel=\"stylesheet\" href=\"" . BSPrinter::get_stylesheet() . "\" />";
+               echo "\n" . $this->headerCode;
                echo "\n</head>\n<body>\n";
                
                if ($this->navigator && (!defined('ISSO_PRINTER_NO_NAVIGATION') || !constant('ISSO_PRINTER_NO_NAVIGATION')))