Fix the set_focus() setting issues
authorRobert Sesek <rsesek@bluestatic.org>
Sun, 16 Apr 2006 18:47:57 +0000 (18:47 +0000)
committerRobert Sesek <rsesek@bluestatic.org>
Sun, 16 Apr 2006 18:47:57 +0000 (18:47 +0000)
printer_navigation.php

index f50bbdc5d983e85f79c234b011fd840b0c51ff7d..0604a41a5673abc934f4776e992a7f6c0ef92a85 100644 (file)
@@ -163,30 +163,36 @@ class Printer_Navigation
        *
        * @param        string  Scope operator
        * @param        string  Unique key in scope
+       * @param        string  Parent operator (links only)
        */
-       function set_focus($scope, $key)
+       function set_focus($scope, $key, $parent)
        {
                if ($scope == 'tab')
                {
-                       $array = 'tabs';
+                       if (isset($this->tabs["$key"]))
+                       {
+                               $this->focus["$scope"] = $key;
+                       }
+                       else
+                       {
+                               trigger_error('Invalid key for scope', E_USER_WARNING);
+                       }
                }
                else if ($scope == 'link')
                {
-                       $array = 'links';
+                       if (isset($this->links["$parent"]["$key"]))
+                       {
+                               $this->focus["$scope"] = $key;
+                       }
+                       else
+                       {
+                               trigger_error('Invalid key for scope', E_USER_WARNING);
+                       }
                }
                else
                {
                        trigger_error('Printer_Navigation::set_focus() only allows setting of focus for tab and link scopes', E_USER_ERROR);
                }
-               
-               if (isset($this->{$array}["$key"]))
-               {
-                       $this->focus["$scope"] = $key;
-               }
-               else
-               {
-                       trigger_error('Invalid key for scope', E_USER_WARNING);
-               }
        }
        
        // ###################################################################
@@ -250,7 +256,7 @@ class Printer_Navigation
                        $output .= "\n\t" . '<li class="header"><span>' . $text . '</span></li>';
                        foreach ((array)$this->links["$key"] AS $key2 => $content)
                        {
-                               $output .= "\n\t" . '<li' . ($this->focus['link'] == $key ? ' class="focus"' : '') . '><a href="' . $content[1] . '"><span>' . $content[0] . '</span></a></li>';
+                               $output .= "\n\t" . '<li' . ($this->focus['link'] == $key2 ? ' class="focus"' : '') . '><a href="' . $content[1] . '"><span>' . $content[0] . '</span></a></li>';
                        }
                        $output .= "\n" . '</ul>' . "\n";
                }