summaryrefslogtreecommitdiff
path: root/modules/gallery/libraries/MY_View.php
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2009-12-26 11:24:50 -0800
committerTim Almdal <tnalmdal@shaw.ca>2009-12-26 11:24:50 -0800
commit3060a6f662da66008d57a461bf1c9b5b4aa2b002 (patch)
tree442fd290505817efc0324f2af6e01805cb7396aa /modules/gallery/libraries/MY_View.php
parent1cd6a615bb47a33794e4a4f690c87a348ab752d7 (diff)
parent32d25dafd5b033338b6a9bb8c7c53edab462543a (diff)
Merge branch 'master' into talmdal_dev
Conflicts: modules/gallery/controllers/albums.php modules/gallery/controllers/movies.php modules/gallery/controllers/photos.php
Diffstat (limited to 'modules/gallery/libraries/MY_View.php')
-rw-r--r--modules/gallery/libraries/MY_View.php36
1 files changed, 33 insertions, 3 deletions
diff --git a/modules/gallery/libraries/MY_View.php b/modules/gallery/libraries/MY_View.php
index eb55aca6..cec59ec1 100644
--- a/modules/gallery/libraries/MY_View.php
+++ b/modules/gallery/libraries/MY_View.php
@@ -18,6 +18,35 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class View extends View_Core {
+ static $global_data = array();
+
+ /**
+ * Reimplement Kohana 2.3's View::set_global() functionality.
+ */
+ public function set_global($key, $value) {
+ View::$global_data[$key] = $value;
+ }
+
+ public function is_set($key) {
+ return parent::is_set($key) ? true : array_key_exists($key, View::$global_data);
+ }
+
+ /**
+ * Completely replace View_Core::__get() so that local data trumps global data, trumps members.
+ * This simulates the Kohana 2.3 behavior.
+ */
+ public function &__get($key) {
+ if (isset($this->kohana_local_data[$key])) {
+ return $this->kohana_local_data[$key];
+ } else if (isset(View::$global_data[$key])) {
+ return View::$global_data[$key];
+ } else if (isset($this->$key)) {
+ return $this->$key;
+ } else {
+ throw new Kohana_Exception('Undefined view variable: :var', array(':var' => $key));
+ }
+ }
+
/**
* Override View_Core::__construct so that we can set the csrf value into all views.
*
@@ -34,11 +63,12 @@ class View extends View_Core {
*
* @see View_Core::render
*/
- public function render($print=false, $renderer=false) {
+ public function render($print=false, $renderer=false, $modifier=false) {
try {
- return parent::render($print, $renderer);
+ $this->kohana_local_data = array_merge(View::$global_data, $this->kohana_local_data);
+ return parent::render($print, $renderer, $modifier);
} catch (Exception $e) {
- Kohana::Log("error", $e->getMessage() . "\n" . $e->getTraceAsString());
+ Kohana_Log::add("error", $e->getMessage() . "\n" . $e->getTraceAsString());
return "";
}
}