summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe7 <jozsef.rnagy@site.hu>2011-01-02 18:59:23 +0100
committerBharat Mediratta <bharat@menalto.com>2011-01-03 11:38:13 -0800
commitcfaa62370ecbdb3badf4ab68bbefa7cfedaea154 (patch)
tree7cc8dbb5c6c21ca6e693be391c18cc3116bb64b3
parente6a5f39b9113fa9cfc526b873947e365793d4e3e (diff)
Reimplemented Kohana 2.3's View::set_global() with array support.
Allows for cleaner code and fewer function calls.
-rw-r--r--modules/gallery/controllers/albums.php17
-rw-r--r--modules/gallery/controllers/movies.php17
-rw-r--r--modules/gallery/controllers/photos.php17
-rw-r--r--modules/gallery/libraries/MY_View.php10
4 files changed, 35 insertions, 26 deletions
diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php
index c0368488..e69f6b6d 100644
--- a/modules/gallery/controllers/albums.php
+++ b/modules/gallery/controllers/albums.php
@@ -61,14 +61,15 @@ class Albums_Controller extends Items_Controller {
}
$template = new Theme_View("page.html", "collection", "album");
- $template->set_global("page", $page);
- $template->set_global("page_title", null);
- $template->set_global("max_pages", $max_pages);
- $template->set_global("page_size", $page_size);
- $template->set_global("item", $album);
- $template->set_global("children", $album->viewable()->children($page_size, $offset));
- $template->set_global("children_count", $children_count);
- $template->set_global("parents", $album->parents()->as_array()); // view calls empty() on this
+ $template->set_global(array("page" => $page,
+ "page_title" => null,
+ "max_pages" => $max_pages,
+ "page_size" => $page_size,
+ "item" => $album,
+ "children" => $album->viewable()->children($page_size, $offset),
+ "children_count" => $children_count,
+ "parents" => $album->parents()->as_array()));
+ // view calls empty() on this
$template->content = new View("album.html");
$album->increment_view_count();
diff --git a/modules/gallery/controllers/movies.php b/modules/gallery/controllers/movies.php
index 15d4f950..1ae969c7 100644
--- a/modules/gallery/controllers/movies.php
+++ b/modules/gallery/controllers/movies.php
@@ -38,14 +38,15 @@ class Movies_Controller extends Items_Controller {
}
$template = new Theme_View("page.html", "item", "movie");
- $template->set_global("item", $movie);
- $template->set_global("children", array());
- $template->set_global("children_count", 0);
- $template->set_global("parents", $movie->parents()->as_array());
- $template->set_global("next_item", $next_item);
- $template->set_global("previous_item", $previous_item);
- $template->set_global("sibling_count", $movie->parent()->viewable()->children_count($where));
- $template->set_global("position", $position);
+ $template->set_global(array("item" => $movie,
+ "children" => array(),
+ "children_count" => 0,
+ "parents" => $movie->parents()->as_array(),
+ "next_item" => $next_item,
+ "previous_item" => $previous_item,
+ "sibling_count"
+ => $movie->parent()->viewable()->children_count($where),
+ "position" => $position));
$template->content = new View("movie.html");
diff --git a/modules/gallery/controllers/photos.php b/modules/gallery/controllers/photos.php
index 2dc22ca4..e795f336 100644
--- a/modules/gallery/controllers/photos.php
+++ b/modules/gallery/controllers/photos.php
@@ -38,14 +38,15 @@ class Photos_Controller extends Items_Controller {
}
$template = new Theme_View("page.html", "item", "photo");
- $template->set_global("item", $photo);
- $template->set_global("children", array());
- $template->set_global("children_count", 0);
- $template->set_global("parents", $photo->parents()->as_array());
- $template->set_global("next_item", $next_item);
- $template->set_global("previous_item", $previous_item);
- $template->set_global("sibling_count", $photo->parent()->viewable()->children_count($where));
- $template->set_global("position", $position);
+ $template->set_global(array("item" => $photo,
+ "children" => array(),
+ "children_count" => 0,
+ "parents" => $photo->parents()->as_array(),
+ "next_item" => $next_item,
+ "previous_item" => $previous_item,
+ "sibling_count"
+ => $photo->parent()->viewable()->children_count($where),
+ "position" => $position));
$template->content = new View("photo.html");
diff --git a/modules/gallery/libraries/MY_View.php b/modules/gallery/libraries/MY_View.php
index ded77792..2230203a 100644
--- a/modules/gallery/libraries/MY_View.php
+++ b/modules/gallery/libraries/MY_View.php
@@ -23,8 +23,14 @@ class View extends View_Core {
/**
* Reimplement Kohana 2.3's View::set_global() functionality.
*/
- public function set_global($key, $value) {
- View::$global_data[$key] = $value;
+ public function set_global($key, $value = NULL) {
+ if (is_array($key)) {
+ foreach ($key as $key2 => $value) {
+ View::$global_data[$key2] = $value;
+ }
+ } else {
+ View::$global_data[$key] = $value;
+ }
}
public function is_set($key=null) {