From: Michael J. Rubinsky Date: Fri, 31 Jul 2009 17:17:33 +0000 (-0400) Subject: Use __get() method for obtaining protected _param[] values X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=790fa3a57be84bb02ba6d0b69d20200f36c5656c;p=horde.git Use __get() method for obtaining protected _param[] values --- diff --git a/ansel/lib/View/Base.php b/ansel/lib/View/Base.php index 6c39d22fe..92d0c5545 100644 --- a/ansel/lib/View/Base.php +++ b/ansel/lib/View/Base.php @@ -37,6 +37,18 @@ abstract class Ansel_View_Base $this->_params = $params; } + public function __get($property) + { + if (isset($this->_params[$property])) { + return $this->_params[$property]; + } + + // @TODO: For now return null until we can ensure we have default values for + // properties requested from other classes. + return null; + //throw new Horde_Exception(sprintf("The property %s of Ansel_View not found.", $property)); + } + public function &getGallery($galleryId = null, $slug = '') { if (is_null($galleryId) && empty($slug)) { diff --git a/ansel/lib/View/GalleryRenderer/Base.php b/ansel/lib/View/GalleryRenderer/Base.php index 1b3a66dd5..ee55e2c73 100644 --- a/ansel/lib/View/GalleryRenderer/Base.php +++ b/ansel/lib/View/GalleryRenderer/Base.php @@ -124,9 +124,7 @@ abstract class Ansel_View_GalleryRenderer_Base $this->galleryId = $this->view->gallery->id; $this->gallerySlug = $this->view->gallery->get('slug'); - if (isset($this->view->_params['page'])) { - $this->page = $this->view->_params['page']; - } + $this->page = $this->view->page; /* Number perpage from prefs or config */ $this->perpage = min($prefs->getValue('tilesperpage'), @@ -136,11 +134,11 @@ abstract class Ansel_View_GalleryRenderer_Base $this->pagestart = ($this->page * $this->perpage) + 1; /* Fetch the children */ - $this->fetchChildren($this->view->_params['force_grouping']); + $this->fetchChildren($this->view->force_grouping); /* Do we have an explicit style set? If not, use the gallery's */ - if (!empty($this->view->_params['style'])) { - $this->style = Ansel::getStyleDefinition($this->view->_params['style']); + if (!empty($this->view->style)) { + $this->style = Ansel::getStyleDefinition($this->view->style); } else { $this->style = $this->view->gallery->getStyle(); } @@ -196,7 +194,7 @@ abstract class Ansel_View_GalleryRenderer_Base PERMS_SHOW, $this->page * $this->perpage, $this->perpage, - !empty($this->view->_params['force_grouping'])); + !empty($this->view->force_grouping)); /* The last tile number to display on the current page */ $this->pageend = min($this->numTiles, $this->pagestart + $this->perpage - 1); diff --git a/ansel/lib/View/GalleryRenderer/Gallery.php b/ansel/lib/View/GalleryRenderer/Gallery.php index b901ca2ea..a8193680b 100644 --- a/ansel/lib/View/GalleryRenderer/Gallery.php +++ b/ansel/lib/View/GalleryRenderer/Gallery.php @@ -39,7 +39,7 @@ class Ansel_View_GalleryRenderer_Gallery extends Ansel_View_GalleryRenderer_Base } /* Only need these if not being called via the api */ - if (empty($this->view->_params['api'])) { + if (empty($this->view->api)) { $option_edit = $this->view->gallery->hasPermission(Horde_Auth::getAuth(), PERMS_EDIT); $option_select = $option_delete = $this->view->gallery->hasPermission(Horde_Auth::getAuth(), PERMS_DELETE); $option_move = ($option_delete && $GLOBALS['ansel_storage']->countGalleries(PERMS_EDIT)); @@ -52,16 +52,16 @@ class Ansel_View_GalleryRenderer_Gallery extends Ansel_View_GalleryRenderer_Base /* Set up the pager */ $date_params = Ansel::getDateParameter( - array('year' => isset($this->view->_params['year']) ? $this->view->_params['year'] : 0, - 'month' => isset($this->view->_params['month']) ? $this->view->_params['month'] : 0, - 'day' => isset($this->view->_params['day']) ? $this->view->_params['day'] : 0)); + array('year' => !empty($this->view->year) ? $this->view->year : 0, + 'month' => !empty($this->view->month) ? $this->view->month : 0, + 'day' => !empty($this->view->day) ? $this->view->day : 0)); $vars = Horde_Variables::getDefaultVariables(); - if (!empty($this->view->_params['page'])) { - $vars->add('page', $this->view->_params['page']); + if (!empty($this->view->page)) { + $vars->add('page', $this->view->page); } - if (!empty($this->view->_params['gallery_view_url'])) { - $pagerurl = str_replace(array('%g', '%s'), array($this->galleryId, $this->gallerySlug), urldecode($this->view->_params['gallery_view_url'])); + if (!empty($this->view->gallery_view_url)) { + $pagerurl = str_replace(array('%g', '%s'), array($this->galleryId, $this->gallerySlug), urldecode($this->view->gallery_view_url)); $pagerurl = Horde_Util::addParameter($pagerurl, $date_params); } else { /* @@ -78,8 +78,8 @@ class Ansel_View_GalleryRenderer_Gallery extends Ansel_View_GalleryRenderer_Base } /* See what callback to use to tweak the pager urls */ - if (!empty($this->view->_params['urlCallback'])) { - $callback = $this->view->_params['urlCallback']; + if (!empty($this->view->urlCallback)) { + $callback = $this->view->urlCallback; } else { $callback = null; } @@ -93,7 +93,7 @@ class Ansel_View_GalleryRenderer_Gallery extends Ansel_View_GalleryRenderer_Base // Note that we can't use Horde_Util::bufferOutput() here since the include // file would be included inside that method's scope, and not this one. ob_start(); - if (!empty($this->view->_params['api'])) { + if (!empty($this->view->api)) { $includes = new Horde_Script_Files(); $includes->disableAutoloadHordeJS(); $includes->_add('prototype.js', 'horde', true, true); diff --git a/ansel/lib/View/GalleryRenderer/GalleryLightbox.php b/ansel/lib/View/GalleryRenderer/GalleryLightbox.php index f4f062d82..b504e93fa 100644 --- a/ansel/lib/View/GalleryRenderer/GalleryLightbox.php +++ b/ansel/lib/View/GalleryRenderer/GalleryLightbox.php @@ -19,12 +19,12 @@ class Ansel_View_GalleryRenderer_GalleryLightbox extends Ansel_View_GalleryRende */ protected function _init() { - if (empty($this->view->_params['image_onclick'])) { - $this->view->_params['image_onclick'] = 'return lb.start(%i);'; + if (empty($this->view->image_onclick)) { + $this->view->image_onclick = 'return lb.start(%i);'; } // Attach the script and CSS files here if we aren't being called via the api - if (empty($this->view->_params['api'])) { + if (empty($this->view->api)) { Ansel::attachStylesheet('lightbox.css'); Horde::addScriptFile('effects.js', 'horde', true); Horde::addScriptFile('lightbox.js', 'ansel', true); @@ -50,17 +50,17 @@ class Ansel_View_GalleryRenderer_GalleryLightbox extends Ansel_View_GalleryRende /* Get JSON data for view */ // 0 == normal, 1 == by date if ($this->mode == 0) { - $json = $this->view->json(null, !empty($this->view->_params['api'])); + $json = $this->view->json(null, !empty($this->view->api)); } else { if (!empty($this->date['day']) && $this->numTiles) { - $json = $this->view->json(null, !empty($this->view->_params['api'])); + $json = $this->view->json(null, !empty($this->view->api)); } else { $json = '[]'; } } /* Don't bother if we are being called from the api */ - if (empty($this->view->_params['api'])) { + if (empty($this->view->api)) { $option_edit = $this->view->gallery->hasPermission(Horde_Auth::getAuth(), PERMS_EDIT); $option_select = $option_delete = $this->view->gallery->hasPermission( @@ -75,19 +75,19 @@ class Ansel_View_GalleryRenderer_GalleryLightbox extends Ansel_View_GalleryRende /* Set up the pager */ $date_params = Ansel::getDateParameter( - array('year' => isset($this->view->_params['year']) ? $this->view->_params['year'] : 0, - 'month' => isset($this->view->_params['month']) ? $this->view->_params['month'] : 0, - 'day' => isset($this->view->_params['day']) ? $this->view->_params['day'] : 0)); + array('year' => !empty($this->view->year) ? $this->view->year : 0, + 'month' => !empty($this->view->month) ? $this->view->month : 0, + 'day' => !empty($this->view->day) ? $this->view->day : 0)); $vars = Horde_Variables::getDefaultVariables(); - if (!empty($this->view->_params['page'])) { - $vars->add('page', $this->view->_params['page']); - $page = $this->view->_params['page']; + if (!empty($this->view->page)) { + $vars->add('page', $this->view->page); + $page = $this->view->page; } else { $page = 0; } - if (!empty($this->view->_params['gallery_view_url'])) { - $pagerurl = str_replace(array('%g', '%s'), array($this->galleryId, $this->gallerySlug), urldecode($this->view->_params['gallery_view_url'])); + if (!empty($this->view->gallery_view_url)) { + $pagerurl = str_replace(array('%g', '%s'), array($this->galleryId, $this->gallerySlug), urldecode($this->view->gallery_view_url)); $pagerurl = Horde_Util::addParameter($pagerurl, $date_params, null, false); } else { /* @@ -103,8 +103,8 @@ class Ansel_View_GalleryRenderer_GalleryLightbox extends Ansel_View_GalleryRende $pagerurl = Ansel::getUrlfor('view', $pager_params, true); } - if (!empty($this->view->_params['urlCallback'])) { - $callback = $this->view->_params['urlCallback']; + if (!empty($this->view->urlCallback)) { + $callback = $this->view->urlCallback; } else { $callback = null; } @@ -131,7 +131,7 @@ class Ansel_View_GalleryRenderer_GalleryLightbox extends Ansel_View_GalleryRende $jsvars['gallery_url'] = $pagerurl . '&'; } /* Output js/css here if we are calling via the api */ - if (!empty($this->view->_params['api'])) { + if (!empty($this->view->api)) { Ansel::attachStylesheet('lightbox.css', true); $includes = new Horde_Script_Files(); $includes->disableAutoloadHordeJS();