From f1f444d48e814fc6ce387495d9ee4ac316b97a3d Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Thu, 11 Feb 2010 12:01:01 -0700 Subject: [PATCH] Horde_Script_Files fixes/improvements Don't use private methods (not sure how this was working anymore) Use injector to hold singleton object --- ansel/lib/View/GalleryRenderer/Gallery.php | 9 +++++---- ansel/lib/View/GalleryRenderer/GalleryLightbox.php | 8 ++++---- ansel/lib/View/Image.php | 8 ++++---- framework/Core/lib/Horde.php | 4 ++-- framework/Core/lib/Horde/Script/Files.php | 19 ------------------- 5 files changed, 15 insertions(+), 33 deletions(-) diff --git a/ansel/lib/View/GalleryRenderer/Gallery.php b/ansel/lib/View/GalleryRenderer/Gallery.php index 2a10076be..d2c1a76bb 100644 --- a/ansel/lib/View/GalleryRenderer/Gallery.php +++ b/ansel/lib/View/GalleryRenderer/Gallery.php @@ -90,12 +90,13 @@ class Ansel_View_GalleryRenderer_Gallery extends Ansel_View_GalleryRenderer_Base $pager = new Horde_Ui_Pager('page', $vars, $params); - // 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. + // 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->api)) { - $includes = new Horde_Script_Files(); - $includes->_add('prototype.js', 'horde', true, true); + $includes = $GLOBALS['injector']->createInstance('Horde_Script_Files'); + $includes->add('prototype.js', 'horde', true, true); $includes->includeFiles(); } diff --git a/ansel/lib/View/GalleryRenderer/GalleryLightbox.php b/ansel/lib/View/GalleryRenderer/GalleryLightbox.php index 6db806679..0278e43c1 100644 --- a/ansel/lib/View/GalleryRenderer/GalleryLightbox.php +++ b/ansel/lib/View/GalleryRenderer/GalleryLightbox.php @@ -134,10 +134,10 @@ class Ansel_View_GalleryRenderer_GalleryLightbox extends Ansel_View_GalleryRende /* Output js/css here if we are calling via the api */ if (!empty($this->view->api)) { Ansel::attachStylesheet('lightbox.css', true); - $includes = new Horde_Script_Files(); - $includes->_add('accesskeys.js', 'horde', true, true); - $includes->_add('effects.js', 'horde', true, true); - $includes->_add('lightbox.js', 'ansel', true, true); + $includes = $GLOBALS['injector']->createInstance('Horde_Script_Files'); + $includes->add('accesskeys.js', 'horde', true, true); + $includes->add('effects.js', 'horde', true, true); + $includes->add('lightbox.js', 'ansel', true, true); $includes->includeFiles(); } diff --git a/ansel/lib/View/Image.php b/ansel/lib/View/Image.php index 85256842d..b552f564f 100644 --- a/ansel/lib/View/Image.php +++ b/ansel/lib/View/Image.php @@ -383,10 +383,10 @@ class Ansel_View_Image extends Ansel_View_Base /* Output the js if we are calling via the api */ if (!empty($this->_params['api'])) { - $includes = new Horde_Script_Files(); - $includes->_add('prototype.js', 'horde', true, true); - $includes->_add('effects.js', 'horde',true, true); - $includes->_add('stripe.js', 'horde', true, true); + $includes = $GLOBALS['injector']->createInstance('Horde_Script_Files'); + $includes->add('prototype.js', 'horde', true, true); + $includes->add('effects.js', 'horde',true, true); + $includes->add('stripe.js', 'horde', true, true); $includes->includeFiles(); } diff --git a/framework/Core/lib/Horde.php b/framework/Core/lib/Horde.php index 7f7657fc1..cc7465be7 100644 --- a/framework/Core/lib/Horde.php +++ b/framework/Core/lib/Horde.php @@ -301,7 +301,7 @@ HTML; static public function addScriptFile($file, $app = null, $options = array()) { - $hsf = Horde_Script_Files::singleton(); + $hsf = $GLOBALS['injector']->getInstance('Horde_Script_Files'); if (empty($options['external'])) { $hsf->add($file, $app, isset($options['direct']) ? $options['direct'] : true, !empty($options['full'])); } else { @@ -322,7 +322,7 @@ HTML; $driver = empty($conf['cachejs']) ? 'none' : $conf['cachejsparams']['driver']; - $hsf = Horde_Script_Files::singleton(); + $hsf = $GLOBALS['injector']->getInstance('Horde_Script_Files'); if ($driver == 'none') { $hsf->includeFiles(); diff --git a/framework/Core/lib/Horde/Script/Files.php b/framework/Core/lib/Horde/Script/Files.php index 54a20d27d..965847eaf 100644 --- a/framework/Core/lib/Horde/Script/Files.php +++ b/framework/Core/lib/Horde/Script/Files.php @@ -15,13 +15,6 @@ class Horde_Script_Files { /** - * The singleton instance. - * - * @var Horde_Script_Files - */ - static protected $_instance; - - /** * The list of script files to add. * * @var array @@ -36,18 +29,6 @@ class Horde_Script_Files protected $_included = array(); /** - * Singleton. - */ - static public function singleton() - { - if (!self::$_instance) { - self::$_instance = new self(); - } - - return self::$_instance; - } - - /** * Adds the javascript code to the output (if output has already started) * or to the list of script files to include. * -- 2.11.0