From fd74f07aeb4727f4ede5fd5f4f60ebd55f1421c2 Mon Sep 17 00:00:00 2001 From: "Michael J. Rubinsky" Date: Fri, 31 Jul 2009 14:49:11 -0400 Subject: [PATCH] More autoload renaming / removal of require statements etc... --- ansel/browse.php | 1 - ansel/group.php | 1 - ansel/image.php | 4 -- ansel/lib/Ansel.php | 16 -------- ansel/lib/Form/Ecard.php | 1 - ansel/lib/GalleryMode/RemoteVimeo.php | 2 - ansel/lib/Report.php | 2 - ansel/lib/View/List.php | 1 - ansel/lib/View/Results.php | 50 +++++++----------------- ansel/lib/View/Slideshow.php | 73 +++++++++++------------------------ ansel/lib/XPPublisher.php | 6 +-- ansel/lib/api.php | 4 -- ansel/perms.php | 1 - ansel/protect.php | 1 - ansel/report.php | 1 - ansel/rss.php | 1 - ansel/xppublish.php | 3 +- 17 files changed, 40 insertions(+), 128 deletions(-) diff --git a/ansel/browse.php b/ansel/browse.php index 265b2dd3f..347f4d9ca 100644 --- a/ansel/browse.php +++ b/ansel/browse.php @@ -7,7 +7,6 @@ */ require_once dirname(__FILE__) . '/lib/base.php'; -require_once ANSEL_BASE . '/lib/Tags.php'; Horde::addScriptFile('prototype.js', 'horde', true); $layout = new Horde_Block_Layout_View( diff --git a/ansel/group.php b/ansel/group.php index 621f6ed07..f31c16486 100644 --- a/ansel/group.php +++ b/ansel/group.php @@ -42,7 +42,6 @@ case 'category': break; case 'owner': - require_once 'Horde/Identity.php'; $num_groups = $ansel_storage->shares->countOwners(PERMS_SHOW, null, false); if (is_a($num_groups, 'PEAR_Error')) { diff --git a/ansel/image.php b/ansel/image.php index 4121bf9c4..e9cd97e23 100644 --- a/ansel/image.php +++ b/ansel/image.php @@ -27,7 +27,6 @@ $date = Ansel::getDateParameter(); /* Are we watermarking the image? */ if ($watermark) { - require_once 'Horde/Identity.php'; $identity = Identity::singleton(); $name = $identity->getValue('fullname'); if (empty($name)) { @@ -137,7 +136,6 @@ case 'modify': $title = sprintf(_("Edit properties :: %s"), $image->filename); /* Set up the form object. */ - require_once ANSEL_BASE . '/lib/Forms/Image.php'; $vars = Horde_Variables::getDefaultVariables(); if ($ret == 'gallery') { $vars->set('actionID', 'saveclose'); @@ -180,7 +178,6 @@ case 'save': } /* Validate the form object. */ - require_once ANSEL_BASE . '/lib/Forms/Image.php'; $vars = Horde_Variables::getDefaultVariables(); $vars->set('actionID', 'save'); $renderer = new Horde_Form_Renderer(); @@ -459,7 +456,6 @@ case 'setwatermark': exit; } /* Set up the form object. */ - require_once ANSEL_BASE . '/lib/Forms/Watermark.php'; $vars = Horde_Variables::getDefaultVariables(); $vars->set('actionID', 'previewcustomwatermark'); $form = new Ansel_Form_Watermark($vars, _("Watermark")); diff --git a/ansel/lib/Ansel.php b/ansel/lib/Ansel.php index cea2ba0f5..de061d3e2 100644 --- a/ansel/lib/Ansel.php +++ b/ansel/lib/Ansel.php @@ -6,12 +6,6 @@ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html. */ -/** Horde_Share */ -require_once 'Horde/Share.php'; - -/** Need to bring this in explicitly since we extend the object class */ -require_once 'Horde/Share/sql_hierarchical.php'; - /** * Ansel Base Class. * @@ -712,7 +706,6 @@ class Ansel { $owner, '', null, false); $fullname = $uprefs->getValue('grouptitle'); if (!$fullname) { - require_once 'Horde/Identity.php'; $identity = Identity::singleton('none', $owner); $fullname = $identity->getValue('fullname'); if (!$fullname) { @@ -1154,7 +1147,6 @@ class Ansel_Gallery extends Horde_Share_Object_sql_hierarchical { { $type = basename($type); $class = 'Ansel_GalleryMode_' . $type; - require_once dirname(__FILE__) . '/GalleryMode/' . $type . '.php'; $this->_modeHelper = new $class($this); $this->_modeHelper->init(); } @@ -1485,7 +1477,6 @@ class Ansel_Gallery extends Horde_Share_Object_sql_hierarchical { */ function getOwner() { - require_once 'Horde/Identity.php'; $identity = Identity::singleton('none', $this->data['share_owner']); return $identity; } @@ -1502,8 +1493,6 @@ class Ansel_Gallery extends Horde_Share_Object_sql_hierarchical { function getTile($parent = null, $style = null, $mini = false, $params = array()) { - require_once ANSEL_BASE . '/lib/Tile/Gallery.php'; - if (!is_null($parent) && is_null($style)) { $style = $parent->getStyle(); } else { @@ -1663,7 +1652,6 @@ class Ansel_Gallery extends Horde_Share_Object_sql_hierarchical { } // Don't already have one, must generate it. - require_once dirname(__FILE__) . '/ImageView.php'; $params = array('gallery' => $this, 'style' => $gal_style); $iview = Ansel_ImageView::factory( $gal_style['default_galleryimage_type'], $params); @@ -2291,8 +2279,6 @@ class Ansel_Image { return $result; } $styleDef = Ansel::getStyleDefinition($style); - - require_once dirname(__FILE__) . '/ImageView.php'; if ($view == 'prettythumb') { $viewType = $styleDef['thumbstyle']; } else { @@ -2849,7 +2835,6 @@ class Ansel_Image { } if (empty($watermark)) { - require_once 'Horde/Identity.php'; $identity = Identity::singleton(); $name = $identity->getValue('fullname'); if (empty($name)) { @@ -3199,7 +3184,6 @@ class Ansel_Storage { } if ($perms) { - require_once 'Horde/Group.php'; $groups = Group::singleton(); $group_list = $groups->getGroupMemberships(Horde_Auth::getAuth()); if (!is_a($group_list, 'PEAR_Error') && count($group_list)) { diff --git a/ansel/lib/Form/Ecard.php b/ansel/lib/Form/Ecard.php index bf50f3f2f..ebcb47833 100644 --- a/ansel/lib/Form/Ecard.php +++ b/ansel/lib/Form/Ecard.php @@ -23,7 +23,6 @@ class Ansel_Form_Ecard extends Horde_Form { if (empty($user)) { $this->addVariable(_("Use the following return address:"), 'ecard_retaddr', 'text', true); } else { - require_once 'Horde/Identity.php'; $identity = Identity::singleton(); $from_addr = $identity->getDefaultFromAddress(); $vars->set('ecard_retaddr', $from_addr); diff --git a/ansel/lib/GalleryMode/RemoteVimeo.php b/ansel/lib/GalleryMode/RemoteVimeo.php index 94245bdf9..922283786 100644 --- a/ansel/lib/GalleryMode/RemoteVimeo.php +++ b/ansel/lib/GalleryMode/RemoteVimeo.php @@ -30,8 +30,6 @@ class Ansel_GalleryMode_RemoteVimeo { */ function Ansel_GalleryMode_RemoteVimeo($gallery) { - require_once 'Horde/Autoloader.php'; - // Build a Horde_Service_Vimeo object // It *requires* a http client object and can make use of a cache object, $params = array('http_client' => new Horde_Http_Client(), diff --git a/ansel/lib/Report.php b/ansel/lib/Report.php index f252f157e..cb6a02252 100644 --- a/ansel/lib/Report.php +++ b/ansel/lib/Report.php @@ -55,8 +55,6 @@ class Ansel_Report { */ function _getUserEmail($user = null) { - require_once 'Horde/Identity.php'; - // Get user email $identity = Identity::singleton('none', $user); return $identity->getValue('from_addr'); diff --git a/ansel/lib/View/List.php b/ansel/lib/View/List.php index b6a6c51ff..aea0364b0 100644 --- a/ansel/lib/View/List.php +++ b/ansel/lib/View/List.php @@ -133,7 +133,6 @@ class Ansel_View_List extends Ansel_View_Base 'ansel', $owner, '', null, false); $fullname = $uprefs->getValue('grouptitle'); if (!$fullname) { - require_once 'Horde/Identity.php'; $identity = &Identity::singleton('none', $owner); $fullname = $identity->getValue('fullname'); if (!$fullname) { diff --git a/ansel/lib/View/Results.php b/ansel/lib/View/Results.php index 8af8b08f7..09db9bfaf 100644 --- a/ansel/lib/View/Results.php +++ b/ansel/lib/View/Results.php @@ -1,73 +1,44 @@ * @package Ansel */ -class Ansel_View_Results extends Ansel_View_Abstract { - +class Ansel_View_Results extends Ansel_View_Base +{ /** * Instance of our tag search * * @var Ansel_Tag_Search */ - var $_search; + protected $_search; /** * Gallery owner id * * @var string */ - var $_owner; + protected $_owner; /** * Contructor - just set some instance variables. * * @return Ansel_View_Results */ - function Ansel_View_Results() + public function __construct() { $this->_owner = Horde_Util::getFormData('owner', null); $this->_search = Ansel_Tags::getSearch(null, $this->_owner); } /** - * @static - * - * @return Ansel_View_Results The view object. - * - * @TODO use exceptions from the constructor instead of static - * instance-getting. - */ - function makeView($params = array()) - { - $view = new Ansel_View_Results(); - if (count($params)) { - $view->_params = $params; - } - return $view; - } - - /** * Return the title for this view. * * @return string The title for this view. */ - function getTitle() + public function getTitle() { return (!empty($this->_owner)) ? sprintf(_("Searching %s's photos tagged: "), $this->_owner) @@ -79,7 +50,7 @@ class Ansel_View_Results extends Ansel_View_Abstract { * * @return string The HTML */ - function html() + public function html() { global $conf, $prefs, $registry, $ansel_storage; @@ -302,9 +273,14 @@ class Ansel_View_Results extends Ansel_View_Abstract { return ob_get_clean(); } - function viewType() + public function viewType() { return 'Results'; } + public function getGalleryCrumbData() + { + return array(); + } + } diff --git a/ansel/lib/View/Slideshow.php b/ansel/lib/View/Slideshow.php index 038a5f8ca..7ebd00ce6 100644 --- a/ansel/lib/View/Slideshow.php +++ b/ansel/lib/View/Slideshow.php @@ -6,19 +6,8 @@ * @author Michael J. Rubinsky * @package Ansel */ - -/** Ansel_View_Abstract */ -require_once ANSEL_BASE . '/lib/Views/Abstract.php'; - -class Ansel_View_Slideshow extends Ansel_View_Abstract { - - /** - * The Ansel_Image object representing the first image selected for view. - * - * @var Ansel_Image - */ - var $image; - +class Ansel_View_Slideshow extends Ansel_View_Base +{ /** * @static * @@ -27,37 +16,27 @@ class Ansel_View_Slideshow extends Ansel_View_Abstract { * @TODO use exceptions from the constructor instead of static * instance-getting. */ - function makeView($params = array()) + public function __construct($params = array()) { + parent::__construct($params); if (empty($params['image_id'])) { $image_id = Horde_Util::getFormData('image'); } else { $image_id = $params['image_id']; } $image = $GLOBALS['ansel_storage']->getImage($image_id); - if (is_a($image, 'PEAR_Error')) { - return $image; - } - - $view = new Ansel_View_Slideshow(); - if (count($params)) { - $view->_params = $params; - } - $view->gallery = $view->getGallery($image->gallery); - if (is_a($view->gallery, 'PEAR_Error')) { - return $view->gallery; - } - $view->image = $image; + $this->gallery = $this->getGallery($image->gallery); + $this->image = $image; // Check user age - if (!$view->gallery->isOldEnough()) { + if (!$this->gallery->isOldEnough()) { $date = Ansel::getDateParameter( - array('year' => isset($view->_params['year']) ? $view->_params['year'] : 0, - 'month' => isset($view->_params['month']) ? $view->_params['month'] : 0, - 'day' => isset($view->_params['day']) ? $view->_params['day'] : 0)); + array('year' => !empty($this->_params['year']) ? $this->_params['year'] : 0, + 'month' => !empty($this->_params['month']) ? $this->_params['month'] : 0, + 'day' => !empty($this->_params['day']) ? $this->_params['day'] : 0)); $url = Ansel::getUrlFor('view', array_merge( - array('gallery' => $view->gallery->id, + array('gallery' => $this->gallery->id, 'slug' => empty($params['slug']) ? '' : $params['slug'], 'page' => empty($params['page']) ? 0 : $params['page'], 'view' => 'Slideshow', @@ -65,21 +44,21 @@ class Ansel_View_Slideshow extends Ansel_View_Abstract { $date), true); - $params = array('gallery' => $view->gallery->id, 'url' => $url); + $params = array('gallery' => $this->gallery->id, 'url' => $url); header('Location: ' . Horde_Util::addParameter(Horde::applicationUrl('disclamer.php'), $params, null, false)); exit; } // Check password - if ($view->gallery->hasPasswd()) { + if ($this->gallery->hasPasswd()) { $date = Ansel::getDateParameter( - array('year' => isset($view->_params['year']) ? $view->_params['year'] : 0, - 'month' => isset($view->_params['month']) ? $view->_params['month'] : 0, - 'day' => isset($view->_params['day']) ? $view->_params['day'] : 0)); + array('year' => isset($this->_params['year']) ? $this->_params['year'] : 0, + 'month' => isset($this->_params['month']) ? $this->_params['month'] : 0, + 'day' => isset($this->_params['day']) ? $this->_params['day'] : 0)); $url = Ansel::getUrlFor('view', array_merge( - array('gallery' => $view->gallery->id, + array('gallery' => $this->gallery->id, 'slug' => empty($params['slug']) ? '' : $params['slug'], 'page' => empty($params['page']) ? 0 : $params['page'], 'view' => 'Slideshow', @@ -87,7 +66,7 @@ class Ansel_View_Slideshow extends Ansel_View_Abstract { $date), true); - $params = array('gallery' => $view->gallery->id, 'url' => $url); + $params = array('gallery' => $this->gallery->id, 'url' => $url); header('Location: ' . Horde_Util::addParameter(Horde::applicationUrl('protect.php'), $params, null, false)); exit; @@ -97,8 +76,6 @@ class Ansel_View_Slideshow extends Ansel_View_Abstract { Horde::addScriptFile('effects.js', 'horde', true); Horde::addScriptFile('stripe.js', 'horde', true); Horde::addScriptFile('slideshow.js', 'ansel', true); - - return $view; } /** @@ -106,9 +83,9 @@ class Ansel_View_Slideshow extends Ansel_View_Abstract { * * @return string The title. */ - function getTitle() + public function getTitle() { - return $this->image->filename; + return $this->resource->filename; } /** @@ -116,17 +93,13 @@ class Ansel_View_Slideshow extends Ansel_View_Abstract { * * @return string The HTML. */ - function html() + public function html() { global $browser, $conf, $prefs, $registry; - if (is_a($this->gallery, 'PEAR_Error')) { - echo htmlspecialchars($this->gallery->getMessage()); - return; - } $page = Horde_Util::getFormData('page', 0); $galleryId = $this->gallery->id; - $imageId = $this->image->id; + $imageId = $this->resource->id; $galleryOwner = $this->gallery->get('owner'); $style = $this->gallery->getStyle(); @@ -171,7 +144,7 @@ class Ansel_View_Slideshow extends Ansel_View_Abstract { return ob_get_clean(); } - function viewType() + public function viewType() { return 'Slideshow'; } diff --git a/ansel/lib/XPPublisher.php b/ansel/lib/XPPublisher.php index 313fde91b..7575fed5d 100644 --- a/ansel/lib/XPPublisher.php +++ b/ansel/lib/XPPublisher.php @@ -6,8 +6,8 @@ * @package Ansel * @author Chuck Hagenbuch */ -class Horde_XPPublisher { - +class Ansel_XPPublisher +{ /** * Generates a Windows Registry file that a user can double-click * to add your provider to their list of Providers for the @@ -30,7 +30,7 @@ class Horde_XPPublisher { * service. Usually displayed at 32x32, will be scaled if it's not * that size. */ - function sendRegFile($appKey, $displayName, $description, $href, $icon) + public function sendRegFile($appKey, $displayName, $description, $href, $icon) { $browser = Horde_Browser::singleton(); $browser->downloadHeaders('install_registry.reg', 'application/octet-stream'); diff --git a/ansel/lib/api.php b/ansel/lib/api.php index a76fa38ec..214ea4838 100644 --- a/ansel/lib/api.php +++ b/ansel/lib/api.php @@ -1177,7 +1177,6 @@ function _ansel_countGalleries($app = null, $perm = PERMS_SHOW, $attributes = nu function _ansel_listTagInfo($tags = null) { require_once dirname(__FILE__) . '/base.php'; - require_once ANSEL_BASE . '/lib/Tags.php'; return Ansel_Tags::listTagInfo($tags); } @@ -1210,7 +1209,6 @@ function _ansel_searchTags($names, $max = 10, $from = 0, $app = null) { require_once dirname(__FILE__) . '/base.php'; - require_once ANSEL_BASE . '/lib/Tags.php'; if (!is_null($app)) { $GLOBALS['ansel_storage'] = new Ansel_Storage($app); @@ -1314,8 +1312,6 @@ function _ansel_renderView($params = array(), $app = null, if (!is_null($app)) { $GLOBALS['ansel_storage'] = new Ansel_Storage($app); } - - require_once ANSEL_BASE . '/lib/Views/' . basename($view) . '.php'; $classname = 'Ansel_View_' . basename($view); $params['api'] = true; $params['view'] = $view; diff --git a/ansel/perms.php b/ansel/perms.php index 36a53355b..29a0a88a8 100644 --- a/ansel/perms.php +++ b/ansel/perms.php @@ -16,7 +16,6 @@ $fieldsList = array( ); require_once dirname(__FILE__) . '/lib/base.php'; -require_once 'Horde/Group.php'; $groups = Group::singleton(); $auth = Horde_Auth::singleton($conf['auth']['driver']); diff --git a/ansel/protect.php b/ansel/protect.php index db7e481f4..2f984b7c2 100644 --- a/ansel/protect.php +++ b/ansel/protect.php @@ -9,7 +9,6 @@ */ require_once dirname(__FILE__) . '/lib/base.php'; -require_once 'Horde/Form.php'; $vars = Horde_Variables::getDefaultVariables(); $gallery = $ansel_storage->getGallery($vars->get('gallery')); diff --git a/ansel/report.php b/ansel/report.php index 6c35fe0ea..6fa156880 100644 --- a/ansel/report.php +++ b/ansel/report.php @@ -12,7 +12,6 @@ */ require_once dirname(__FILE__) . '/lib/base.php'; -require_once 'Horde/Form.php'; $title = _("Do you really want to report this gallery?"); $gallery_id = (int)Horde_Util::getFormData('gallery'); diff --git a/ansel/rss.php b/ansel/rss.php index f6bbcc68c..4d7b1d6f2 100644 --- a/ansel/rss.php +++ b/ansel/rss.php @@ -140,7 +140,6 @@ if (empty($rss)) { if (isset($galleries) && count($galleries)) { $images = $ansel_storage->getRecentImages($galleries); if (!is_a($images, 'PEAR_Error') && count($images)) { - require_once('Horde/Identity.php'); $owner = Identity::singleton('none', $id); $name = $owner->getValue('fullname'); $author = $owner->getValue('from_addr'); diff --git a/ansel/xppublish.php b/ansel/xppublish.php index d23efa406..06ab476fc 100644 --- a/ansel/xppublish.php +++ b/ansel/xppublish.php @@ -10,11 +10,10 @@ $ansel_authentication = 'none'; require_once dirname(__FILE__) . '/lib/base.php'; -require_once ANSEL_BASE . '/lib/XPPublisher.php'; $cmd = Horde_Util::getFormData('cmd'); if (empty($cmd)) { - $publisher = new Horde_XPPublisher(); + $publisher = new Ansel_XPPublisher(); $publisher->sendRegFile( $registry->getApp() . '-' . $conf['server']['name'], $registry->get('name'), -- 2.11.0