From 64f993db6f70554d5dd0e3fe2db672abc4e971de Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 20 Dec 2008 07:38:46 +0000 Subject: Update modified to Kohana r3823 (svn merge -c19322 vendor/kohana/modified/kohana trunk/kohana) --- kohana/libraries/View.php | 54 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 49 insertions(+), 5 deletions(-) (limited to 'kohana/libraries/View.php') diff --git a/kohana/libraries/View.php b/kohana/libraries/View.php index 067ace9c..7a49fd84 100644 --- a/kohana/libraries/View.php +++ b/kohana/libraries/View.php @@ -56,6 +56,17 @@ class View_Core { $this->kohana_local_data = array_merge($this->kohana_local_data, $data); } } + + /** + * Magic method access to test for view property + * + * @param string View property to test for + * @return boolean + */ + public function __isset($key = NULL) + { + return $this->is_set($key); + } /** * Sets the view filename. @@ -117,6 +128,43 @@ class View_Core { return $this; } + /** + * Checks for a property existence in the view locally or globally. Unlike the built in __isset(), + * this method can take an array of properties to test simultaneously. + * + * @param string $key property name to test for + * @param array $key array of property names to test for + * @return boolean property test result + * @return array associative array of keys and boolean test result + */ + public function is_set( $key = FALSE ) + { + // Setup result; + $result = FALSE; + + // If key is an array + if (is_array($key)) + { + // Set the result to an array + $result = array(); + + // Foreach key + foreach ($key as $property) + { + // Set the result to an associative array + $result[$property] = (array_key_exists($property, $this->kohana_local_data) OR array_key_exists($property, self::$kohana_global_data)) ? TRUE : FALSE; + } + } + else + { + // Otherwise just check one property + $result = (array_key_exists($key, $this->kohana_local_data) OR array_key_exists($key, self::$kohana_global_data)) ? TRUE : FALSE; + } + + // Return the result + return $result; + } + /** * Sets a bound variable by reference. * @@ -164,10 +212,7 @@ class View_Core { */ public function __set($key, $value) { - if ( ! isset($this->$key)) - { - $this->kohana_local_data[$key] = $value; - } + $this->kohana_local_data[$key] = $value; } /** @@ -255,5 +300,4 @@ class View_Core { return $output; } - } // End View \ No newline at end of file -- cgit v1.2.3