Add sanity checks to BSPrinterNavigation when setting focus or sections
authorRobert Sesek <rsesek@bluestatic.org>
Mon, 14 Jan 2008 22:04:29 +0000 (17:04 -0500)
committerRobert Sesek <rsesek@bluestatic.org>
Mon, 14 Jan 2008 22:04:29 +0000 (17:04 -0500)
* PrinterNavigation.php
(BSPrinterNavigation::addFocus): Make sure the key is unique and exists before accepting it
(BSPrinterNavigation::addSection): ditto

PrinterNavigation.php

index ba702311147c4c3337301c748c4ed3fe142f6274..7a7e33c925f65aeabc7bb79cf3446a07e2879cae 100644 (file)
@@ -75,6 +75,10 @@ class BSPrinterNavigation
         */
        public function addFocus($key)
        {
+               if (sizeof($this->structure->xpath('//*[@key="' . $key . '"]')) != 1)
+               {
+                       throw new Exception('The key passed to BSPrinterNavigation::addFocus() is either too vague or nonexistent');
+               }
                $this->focusKeys[] = $key;
        }
        
@@ -86,6 +90,10 @@ class BSPrinterNavigation
         */
        public function addSection($key)
        {
+               if (sizeof($this->structure->xpath('//*[@key="' . $key . '"]')) != 1)
+               {
+                       throw new Exception('The key passed to BSPrinterNavigation::addSection() is either too vague or nonexistent');
+               }
                $this->displaySections[] = $key;
        }