From 2b3d36c42edacd545c295b739f2091b97af9f056 Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Mon, 18 Oct 2010 13:45:26 +0200 Subject: [PATCH] Make class names autoloadable. --- wicked/display.php | 2 +- wicked/lib/Api.php | 2 +- wicked/lib/Driver.php | 25 +++++------------ wicked/lib/Driver/{sql.php => Sql.php} | 20 ++++---------- wicked/lib/Page.php | 31 +++++++++++----------- wicked/lib/Page/AddPage.php | 13 ++++----- wicked/lib/Page/AllPages.php | 7 ++--- wicked/lib/Page/AttachedFiles.php | 8 ++---- wicked/lib/Page/BackLinks.php | 11 +++----- wicked/lib/Page/DeletePage.php | 9 ++----- wicked/lib/Page/EditPage.php | 10 ++----- wicked/lib/Page/LeastPopular.php | 7 ++--- wicked/lib/Page/LikePages.php | 11 +++----- wicked/lib/Page/MergeOrRename.php | 7 ++--- wicked/lib/Page/MostPopular.php | 7 ++--- wicked/lib/Page/NewPage.php | 9 ++----- wicked/lib/Page/RecentChanges.php | 7 ++--- wicked/lib/Page/RevertPage.php | 7 ++--- wicked/lib/Page/Search.php | 16 +++++------ .../StdHistoryPage.php => StandardHistoryPage.php} | 2 +- wicked/lib/Page/StandardPage.php | 6 ++--- wicked/lib/Page/SyncDiff.php | 10 +++---- wicked/lib/Page/SyncPages.php | 8 ++---- wicked/lib/Sync.php | 16 +++++------ wicked/lib/Sync/{wicked.php => Wicked.php} | 7 ++--- wicked/lib/tests/Driver.php | 3 --- 26 files changed, 83 insertions(+), 178 deletions(-) rename wicked/lib/Driver/{sql.php => Sql.php} (98%) rename wicked/lib/Page/{StandardPage/StdHistoryPage.php => StandardHistoryPage.php} (95%) rename wicked/lib/Sync/{wicked.php => Wicked.php} (95%) diff --git a/wicked/display.php b/wicked/display.php index 46d894bf5..6dbc1182b 100644 --- a/wicked/display.php +++ b/wicked/display.php @@ -137,7 +137,7 @@ require WICKED_TEMPLATES . '/menu.inc'; $page->render(Wicked::MODE_DISPLAY, $params); require $registry->get('templates', 'horde') . '/common-footer.inc'; -if (is_a($page, 'StandardPage') && +if ($page instanceof Wicked_Page_StandardPage && (!isset($_SESSION['wickedSession']['history'][0]) || $_SESSION['wickedSession']['history'][0] != $page->pageName())) { array_unshift($_SESSION['wickedSession']['history'], $page->pageName()); diff --git a/wicked/lib/Api.php b/wicked/lib/Api.php index 02ca8c1aa..49166a921 100644 --- a/wicked/lib/Api.php +++ b/wicked/lib/Api.php @@ -205,7 +205,7 @@ class Wicked_Api extends Horde_Registry_Api public function listTemplates() { global $wicked; - $templates = $wicked->getMatchingPages('Template', WICKED_PAGE_MATCH_ENDS); + $templates = $wicked->getMatchingPages('Template', Wicked_Page::MATCH_ENDS); $list = array(array('category' => _("Wiki Templates"), 'templates' => array())); foreach ($templates as $page) { diff --git a/wicked/lib/Driver.php b/wicked/lib/Driver.php index 5916edf00..fad267d98 100644 --- a/wicked/lib/Driver.php +++ b/wicked/lib/Driver.php @@ -4,16 +4,6 @@ */ /** - * VFS - */ -require_once 'VFS.php'; - -define('WICKED_PAGE_MATCH_LEFT', 1); -define('WICKED_PAGE_MATCH_RIGHT', 2); -define('WICKED_PAGE_MATCH_ENDS', 3); -define('WICKED_PAGE_MATCH_ANY', 4); - -/** * Wicked_Driver:: defines an API for implementing storage backends for * Wicked. * @@ -46,7 +36,7 @@ abstract class Wicked_Driver { * * @param array $params A hash containing connection parameters. */ - function Wicked_Driver($params = array()) + function __construct($params = array()) { $this->_params = $params; } @@ -391,7 +381,7 @@ abstract class Wicked_Driver { if ($driver === null) { $driver = $GLOBALS['conf']['storage']['driver']; } - $driver = basename($driver); + $driver = Horde_String::ucfirst(basename($driver)); if ($params === null) { $params = Horde::getDriverConfig('storage', $driver); @@ -399,15 +389,12 @@ abstract class Wicked_Driver { $class = 'Wicked_Driver_' . $driver; if (!class_exists($class)) { - include_once dirname(__FILE__) . '/Driver/' . $driver . '.php'; - } - if (class_exists($class)) { - $wicked = new $class($params); - $result = $wicked->connect(); - return $wicked; + throw new Wicked_Exception('Definition of ' . $class . ' not found.'); } - throw new Wicked_Exception('Definition of ' . $class . ' not found.'); + $wicked = new $class($params); + $result = $wicked->connect(); + return $wicked; } } diff --git a/wicked/lib/Driver/sql.php b/wicked/lib/Driver/Sql.php similarity index 98% rename from wicked/lib/Driver/sql.php rename to wicked/lib/Driver/Sql.php index 8878b0049..ae17109b5 100644 --- a/wicked/lib/Driver/sql.php +++ b/wicked/lib/Driver/Sql.php @@ -14,7 +14,7 @@ * @author Chuck Hagenbuch * @package Wicked */ -class Wicked_Driver_sql extends Wicked_Driver { +class Wicked_Driver_Sql extends Wicked_Driver { /** * Handle for the current database connection. @@ -24,16 +24,6 @@ class Wicked_Driver_sql extends Wicked_Driver { var $_db; /** - * Constructs a new Wicked SQL driver object. - * - * @param array $params A hash containing connection parameters. - */ - function Wicked_Driver_sql($params = array()) - { - parent::Wicked_Driver($params); - } - - /** * Retrieves the page of a particular name from the database. * * @param string $pagename The name of the page to retrieve. @@ -219,21 +209,21 @@ class Wicked_Driver_sql extends Wicked_Driver { return $pages; } - function getMatchingPages($searchtext, $matchType = WICKED_PAGE_MATCH_ANY) + function getMatchingPages($searchtext, $matchType = Wicked_Page::MATCH_ANY) { $searchtext = Horde_String::lower($searchtext); /* Short circuit the simple case. */ - if ($matchType == WICKED_PAGE_MATCH_ANY) { + if ($matchType == Wicked_Page::MATCH_ANY) { return $this->_retrieve($this->_params['table'], 'LOWER(page_name) LIKE ' . $this->_db->quoteString('%' . $searchtext . '%')); } $clauses = array(); - if ($matchType & WICKED_PAGE_MATCH_LEFT) { + if ($matchType & Wicked_Page::MATCH_LEFT) { $clauses[] = 'LOWER(page_name) LIKE ' . $this->_db->quoteString($searchtext . '%'); } - if ($matchType & WICKED_PAGE_MATCH_RIGHT) { + if ($matchType & Wicked_Page::MATCH_RIGHT) { $clauses[] = 'LOWER(page_name) LIKE ' . $this->_db->quoteString('%' . $searchtext); } diff --git a/wicked/lib/Page.php b/wicked/lib/Page.php index 6c5bc3852..b6936a174 100644 --- a/wicked/lib/Page.php +++ b/wicked/lib/Page.php @@ -10,7 +10,12 @@ * @author Tyler Colbert * @package Wicked */ -class Wicked_Page { +class Wicked_Page +{ + const MATCH_LEFT = 1; + const MATCH_RIGHT = 2; + const MATCH_ENDS = 3; + const MATCH_ANY = 4; /** * Display modes supported by this page. Possible modes: @@ -188,8 +193,8 @@ class Wicked_Page { function getCurrentPage() { return Wicked_Page::getPage(rtrim(Horde_Util::getFormData('page'), '/'), - Horde_Util::getFormData('version'), - Horde_Util::getFormData('referrer')); + Horde_Util::getFormData('version'), + Horde_Util::getFormData('referrer')); } /** @@ -206,33 +211,27 @@ class Wicked_Page { $pagename = 'WikiHome'; } - $file = WICKED_BASE . '/lib/Page/' . basename($pagename) . '.php'; - if ($pagename == basename($pagename) && - file_exists($file)) { - require_once $file; - return new $pagename($referrer); + $classname = 'Wicked_Page_' . $pagename; + if ($pagename == basename($pagename) && class_exists($classname)) { + return new $classname($referrer); } - require_once WICKED_BASE . '/lib/Page/StandardPage.php'; - /* If we have a version, but it is actually the most recent version, * ignore it. */ if (!empty($pagever)) { - $page = new StandardPage($pagename, false, null); + $page = new Wicked_Page_StandardPage($pagename, false, null); if ($page->isValid() && $page->version() == $pagever) { return $page; } - require_once WICKED_BASE . '/lib/Page/StandardPage/StdHistoryPage.php'; - return new StdHistoryPage($pagename, $pagever); + return new Wicked_Page_StandardHistoryPage($pagename, $pagever); } - $page = new StandardPage($pagename); + $page = new Wicked_Page_StandardPage($pagename); if ($page->isValid() || !$page->allows(Wicked::MODE_EDIT)) { return $page; } - require_once WICKED_BASE . '/lib/Page/AddPage.php'; - return new AddPage($pagename); + return new Wicked_Page_AddPage($pagename); } function versionCreated() diff --git a/wicked/lib/Page/AddPage.php b/wicked/lib/Page/AddPage.php index 27cba550e..0f398c973 100644 --- a/wicked/lib/Page/AddPage.php +++ b/wicked/lib/Page/AddPage.php @@ -1,7 +1,4 @@ * @package Wicked */ -class AddPage extends Wicked_Page { +class Wicked_Page_AddPage extends Wicked_Page { /** * Display modes supported by this page. @@ -36,7 +33,7 @@ class AddPage extends Wicked_Page { */ var $_results; - function AddPage($newpage) + function __construct($newpage) { $this->_newpage = $newpage; $this->_results = $GLOBALS['wicked']->searchTitles($newpage); @@ -61,7 +58,7 @@ class AddPage extends Wicked_Page { function display() { try { - $templates = $GLOBALS['wicked']->getMatchingPages('Template', WICKED_PAGE_MATCH_ENDS); + $templates = $GLOBALS['wicked']->getMatchingPages('Template', Wicked_Page::MATCH_ENDS); } catch (Wicked_Exception $e) { $GLOBALS['notification']->push(sprintf(_("Error retrieving templates: %s"), $e->getMessage()), 'horde.error'); @@ -74,9 +71,9 @@ class AddPage extends Wicked_Page { $pages = array(); foreach ($this->_results as $page) { if (!empty($page['page_history'])) { - $page = new StdHistoryPage($page); + $page = new Wicked_Page_StandardHistoryPage($page); } else { - $page = new StandardPage($page); + $page = new Wicked_Page_StandardPage($page); } $pages[] = array('author' => $page->author(), diff --git a/wicked/lib/Page/AllPages.php b/wicked/lib/Page/AllPages.php index cd8d8306d..d92081761 100644 --- a/wicked/lib/Page/AllPages.php +++ b/wicked/lib/Page/AllPages.php @@ -1,7 +1,4 @@ * @package Wicked */ -class AllPages extends Wicked_Page { +class Wicked_Page_AllPages extends Wicked_Page { /** * Display modes supported by this page. @@ -43,7 +40,7 @@ class AllPages extends Wicked_Page { $template = $GLOBALS['injector']->createInstance('Horde_Template'); $pages = array(); foreach ($this->content() as $page) { - $page = new StandardPage($page); + $page = new Wicked_Page_StandardPage($page); $pages[] = array('author' => $page->author(), 'created' => $page->formatVersionCreated(), 'name' => $page->pageName(), diff --git a/wicked/lib/Page/AttachedFiles.php b/wicked/lib/Page/AttachedFiles.php index c61eda3a1..0846dfbcc 100644 --- a/wicked/lib/Page/AttachedFiles.php +++ b/wicked/lib/Page/AttachedFiles.php @@ -1,8 +1,4 @@ * @package Wicked */ -class AttachedFiles extends Wicked_Page { +class Wicked_Page_AttachedFiles extends Wicked_Page { /** * Display modes supported by this page. @@ -37,7 +33,7 @@ class AttachedFiles extends Wicked_Page { /** * Constructor. */ - function AttachedFiles($referrer) + function __construct($referrer) { $this->_referrer = $referrer; } diff --git a/wicked/lib/Page/BackLinks.php b/wicked/lib/Page/BackLinks.php index 07dbda836..5722bafc5 100644 --- a/wicked/lib/Page/BackLinks.php +++ b/wicked/lib/Page/BackLinks.php @@ -1,7 +1,4 @@ * @package Wicked */ -class BackLinks extends Wicked_Page { +class Wicked_Page_BackLinks extends Wicked_Page { /** * Display modes supported by this page. @@ -30,7 +27,7 @@ class BackLinks extends Wicked_Page { */ var $_referrer = null; - function BackLinks($referrer) + function __construct($referrer) { $this->_referrer = $referrer; } @@ -49,9 +46,9 @@ class BackLinks extends Wicked_Page { require WICKED_TEMPLATES . '/pagelist/header.inc'; foreach ($summaries as $page) { if (!empty($page['page_history'])) { - $page = new StdHistoryPage($page); + $page = new Wicked_Page_StandardHistoryPage($page); } else { - $page = new StandardPage($page); + $page = new Wicked_Page_StandardPage($page); } require WICKED_TEMPLATES . '/pagelist/summary.inc'; } diff --git a/wicked/lib/Page/DeletePage.php b/wicked/lib/Page/DeletePage.php index 0490787cf..efbfe8133 100644 --- a/wicked/lib/Page/DeletePage.php +++ b/wicked/lib/Page/DeletePage.php @@ -9,17 +9,12 @@ */ /** - * Page - */ -require_once WICKED_BASE . '/lib/Page.php'; - -/** * Wicked DeletePage class (for confirming deletion). * * @author Chuck Hagenbuch * @package Wicked */ -class DeletePage extends Wicked_Page { +class Wicked_Page_DeletePage extends Wicked_Page { /** * Display modes supported by this page. @@ -35,7 +30,7 @@ class DeletePage extends Wicked_Page { */ var $_referrer = null; - function DeletePage($referrer) + function __construct($referrer) { $this->_referrer = $referrer; } diff --git a/wicked/lib/Page/EditPage.php b/wicked/lib/Page/EditPage.php index 55dc5ee27..b5531d9a2 100644 --- a/wicked/lib/Page/EditPage.php +++ b/wicked/lib/Page/EditPage.php @@ -6,12 +6,6 @@ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html. * * @package Wicked - */ - -/** - * Page - */ -require_once WICKED_BASE . '/lib/Page.php'; /** * Wicked EditPage class. @@ -19,7 +13,7 @@ require_once WICKED_BASE . '/lib/Page.php'; * @author Jason M. Felice * @package Wicked */ -class EditPage extends Wicked_Page { +class Wicked_Page_EditPage extends Wicked_Page { /** * Display modes supported by this page. @@ -37,7 +31,7 @@ class EditPage extends Wicked_Page { */ var $_referrer = null; - function EditPage($referrer) + function __construct($referrer) { $this->_referrer = $referrer; if ($GLOBALS['conf']['lock']['driver'] != 'none') { diff --git a/wicked/lib/Page/LeastPopular.php b/wicked/lib/Page/LeastPopular.php index 45afea1a7..c2596fe1f 100644 --- a/wicked/lib/Page/LeastPopular.php +++ b/wicked/lib/Page/LeastPopular.php @@ -1,7 +1,4 @@ * @package Wicked */ -class LeastPopular extends Wicked_Page { +class Wicked_Page_LeastPopular extends Wicked_Page { /** * Display modes supported by this page. @@ -47,7 +44,7 @@ class LeastPopular extends Wicked_Page { $template = $GLOBALS['injector']->createInstance('Horde_Template'); $pages = array(); foreach ($this->content(10) as $page) { - $page = new StandardPage($page); + $page = new Wicked_Page_StandardPage($page); $pages[] = array('author' => $page->author(), 'created' => $page->formatVersionCreated(), 'name' => $page->pageName(), diff --git a/wicked/lib/Page/LikePages.php b/wicked/lib/Page/LikePages.php index 9a66c5587..4ccb80c9c 100644 --- a/wicked/lib/Page/LikePages.php +++ b/wicked/lib/Page/LikePages.php @@ -1,7 +1,4 @@ * @package Wicked */ -class LikePages extends Wicked_Page { +class Wicked_Page_LikePages extends Wicked_Page { /** * Display modes supported by this page. @@ -30,7 +27,7 @@ class LikePages extends Wicked_Page { */ var $_referrer = null; - function LikePages($referrer) + function __construct($referrer) { $this->_referrer = $referrer; } @@ -50,9 +47,9 @@ class LikePages extends Wicked_Page { require WICKED_TEMPLATES . '/pagelist/header.inc'; foreach ($summaries as $page) { if (!empty($page['page_history'])) { - $page = new StdHistoryPage($page); + $page = new Wicked_Page_StandardHistoryPage($page); } else { - $page = new StandardPage($page); + $page = new Wicked_Page_StandardPage($page); } require WICKED_TEMPLATES . '/pagelist/summary.inc'; } diff --git a/wicked/lib/Page/MergeOrRename.php b/wicked/lib/Page/MergeOrRename.php index e6d84f780..f2f200970 100644 --- a/wicked/lib/Page/MergeOrRename.php +++ b/wicked/lib/Page/MergeOrRename.php @@ -1,7 +1,4 @@ * @package Wicked */ -class MergeOrRename extends Wicked_Page { +class Wicked_Page_MergeOrRename extends Wicked_Page { /** * Display modes supported by this page. @@ -38,7 +35,7 @@ class MergeOrRename extends Wicked_Page { */ var $_errors = array(); - function MergeOrRename($referrer) + function __construct($referrer) { $this->_referrer = $referrer; } diff --git a/wicked/lib/Page/MostPopular.php b/wicked/lib/Page/MostPopular.php index d36beb899..ed9a3cf06 100644 --- a/wicked/lib/Page/MostPopular.php +++ b/wicked/lib/Page/MostPopular.php @@ -1,7 +1,4 @@ * @package Wicked */ -class MostPopular extends Wicked_Page { +class Wicked_Page_MostPopular extends Wicked_Page { /** * Display modes supported by this page. @@ -47,7 +44,7 @@ class MostPopular extends Wicked_Page { $template = $GLOBALS['injector']->createInstance('Horde_Template'); $pages = array(); foreach ($this->content(10) as $page) { - $page = new StandardPage($page); + $page = new Wicked_Page_StandardPage($page); $pages[] = array('author' => $page->author(), 'created' => $page->formatVersionCreated(), 'name' => $page->pageName(), diff --git a/wicked/lib/Page/NewPage.php b/wicked/lib/Page/NewPage.php index 101e5b9af..427f9d396 100644 --- a/wicked/lib/Page/NewPage.php +++ b/wicked/lib/Page/NewPage.php @@ -9,17 +9,12 @@ */ /** - * StandardPage - */ -require_once WICKED_BASE . '/lib/Page/StandardPage.php'; - -/** * Wicked NewPage class. * * @author Chuck Hagenbuch * @package Wicked */ -class NewPage extends Wicked_Page { +class Wicked_Page_NewPage extends Wicked_Page { /** * Display modes supported by this page. @@ -44,7 +39,7 @@ class NewPage extends Wicked_Page { */ var $_template = null; - function NewPage($referrer) + function __construct($referrer) { $this->_referrer = $referrer; $this->_template = Horde_Util::getFormData('template'); diff --git a/wicked/lib/Page/RecentChanges.php b/wicked/lib/Page/RecentChanges.php index 28c4f5df8..4d380ecec 100644 --- a/wicked/lib/Page/RecentChanges.php +++ b/wicked/lib/Page/RecentChanges.php @@ -1,7 +1,4 @@ * @package Wicked */ -class RecentChanges extends Wicked_Page { +class Wicked_Page_RecentChanges extends Wicked_Page { /** * Display modes supported by this page. @@ -40,7 +37,7 @@ class RecentChanges extends Wicked_Page { $bydate = array(); $changes = array(); foreach ($summaries as $page) { - $page = new StandardPage($page); + $page = new Wicked_Page_StandardPage($page); $createDate = $page->versionCreated(); $tm = localtime($createDate, true); diff --git a/wicked/lib/Page/RevertPage.php b/wicked/lib/Page/RevertPage.php index b3a3fa927..2b8bb2096 100644 --- a/wicked/lib/Page/RevertPage.php +++ b/wicked/lib/Page/RevertPage.php @@ -1,7 +1,4 @@ * @package Wicked */ -class RevertPage extends Wicked_Page { +class Wicked_Page_RevertPage extends Wicked_Page { /** * Display modes supported by this page. @@ -29,7 +26,7 @@ class RevertPage extends Wicked_Page { */ var $_referrer = null; - function RevertPage($referrer) + function __construct($referrer) { $this->_referrer = $referrer; } diff --git a/wicked/lib/Page/Search.php b/wicked/lib/Page/Search.php index ad2eaf868..7d6bd9aa0 100644 --- a/wicked/lib/Page/Search.php +++ b/wicked/lib/Page/Search.php @@ -1,8 +1,4 @@ * @package Wicked */ -class Search extends Wicked_Page { +class Wicked_Page_Search extends Wicked_Page { /** * Display modes supported by this page. @@ -86,7 +82,7 @@ class Search extends Wicked_Page { /* Prepare exact match section */ $exact = array(); - $page = new StandardPage($searchtext); + $page = new Wicked_Page_StandardPage($searchtext); if ($GLOBALS['wicked']->pageExists($searchtext)) { $exact[] = array('author' => htmlspecialchars($page->author()), 'created' => $page->formatVersionCreated(), @@ -109,9 +105,9 @@ class Search extends Wicked_Page { $titles = array(); foreach ($this->_results['titles'] as $page) { if (!empty($page['page_history'])) { - $page = new StdHistoryPage($page); + $page = new Wicked_Page_StandardHistoryPage($page); } else { - $page = new StandardPage($page); + $page = new Wicked_Page_StandardPage($page); } $titles[] = array('author' => $page->author(), @@ -127,9 +123,9 @@ class Search extends Wicked_Page { $pages = array(); foreach ($this->_results['pages'] as $page) { if (!empty($page['page_history'])) { - $page = new StdHistoryPage($page); + $page = new Wicked_Page_StandardHistoryPage($page); } else { - $page = new StandardPage($page); + $page = new Wicked_Page_StandardPage($page); } $pages[] = array('author' => $page->author(), diff --git a/wicked/lib/Page/StandardPage/StdHistoryPage.php b/wicked/lib/Page/StandardHistoryPage.php similarity index 95% rename from wicked/lib/Page/StandardPage/StdHistoryPage.php rename to wicked/lib/Page/StandardHistoryPage.php index f97643289..24388a441 100644 --- a/wicked/lib/Page/StandardPage/StdHistoryPage.php +++ b/wicked/lib/Page/StandardHistoryPage.php @@ -5,7 +5,7 @@ * @author Tyler Colbert * @package Wicked */ -class StdHistoryPage extends StandardPage { +class Wicked_Page_StandardHistoryPage extends Wicked_Page_StandardPage { /** * Display modes supported by this page. diff --git a/wicked/lib/Page/StandardPage.php b/wicked/lib/Page/StandardPage.php index 4bf143d0c..acf459e5f 100644 --- a/wicked/lib/Page/StandardPage.php +++ b/wicked/lib/Page/StandardPage.php @@ -10,7 +10,7 @@ * @author Tyler Colbert * @package Wicked */ -class StandardPage extends Wicked_Page { +class Wicked_Page_StandardPage extends Wicked_Page { /** * Display modes supported by this page. @@ -192,8 +192,6 @@ class StandardPage extends Wicked_Page { */ function history() { - require_once WICKED_BASE . '/lib/Page/StandardPage/StdHistoryPage.php'; - try { $summaries = $GLOBALS['wicked']->getHistory($this->pageName()); } catch (Wicked_Exception $e) { @@ -219,7 +217,7 @@ class StandardPage extends Wicked_Page { $show_edit = false; foreach ($summaries as $page) { $i++; - $page = new StdHistoryPage($page); + $page = new Wicked_Page_StandardHistoryPage($page); require WICKED_TEMPLATES . '/history/summary.inc'; } diff --git a/wicked/lib/Page/SyncDiff.php b/wicked/lib/Page/SyncDiff.php index 0fe86dbe5..cf7ddc502 100644 --- a/wicked/lib/Page/SyncDiff.php +++ b/wicked/lib/Page/SyncDiff.php @@ -1,7 +1,4 @@ * @package Wicked */ -class SyncDiff extends SyncPages { +class Wicked_Page_SyncDiff extends Wicked_Page_SyncPages { /** * Display modes supported by this page. @@ -32,10 +29,9 @@ class SyncDiff extends SyncPages { */ var $_pageName; - function SyncDiff() + function __construct() { - parent::SyncPages(); - + parent::__construct(); $this->_pageName = Horde_Util::getGet('sync_page'); } diff --git a/wicked/lib/Page/SyncPages.php b/wicked/lib/Page/SyncPages.php index 0f56a9b76..7761bb803 100644 --- a/wicked/lib/Page/SyncPages.php +++ b/wicked/lib/Page/SyncPages.php @@ -1,8 +1,4 @@ * @package Wicked */ -class SyncPages extends Wicked_Page { +class Wicked_Page_SyncPages extends Wicked_Page { /** * Display modes supported by this page. @@ -32,7 +28,7 @@ class SyncPages extends Wicked_Page { * * @throws Wicked_Exception */ - function SyncPages() + function __construct() { $this->_loadSyncDriver(); diff --git a/wicked/lib/Sync.php b/wicked/lib/Sync.php index 900899900..e25909cc0 100644 --- a/wicked/lib/Sync.php +++ b/wicked/lib/Sync.php @@ -34,26 +34,22 @@ abstract class Wicked_Sync { * @return Wicked_Sync The newly created concrete Wicked_Sync * instance, or false on an error. */ - function factory($driver = 'wicked', $params = array()) + function factory($driver = 'Wicked', $params = array()) { + $driver = Horde_String::ucfirst(basename($driver)); $class = 'Wicked_Sync_' . $driver; + if (!class_exists($class)) { - include dirname(__FILE__) . '/Sync/' . $driver . '.php'; + return false; } if (empty($params['user'])) { $params['user'] = $GLOBALS['registry']->getAuth(); } - if (empty($params['password'])) { $params['password'] = $GLOBALS['registry']->getAuthCredential('password'); } - - if (class_exists($class)) { - return new $class($params); - } else { - return false; - } + return new $class($params); } /** @@ -61,7 +57,7 @@ abstract class Wicked_Sync { * * @param array $params A hash containing connection parameters. */ - function Wicked_Sync($params = array()) + function __construct($params = array()) { $this->_params = $params; } diff --git a/wicked/lib/Sync/wicked.php b/wicked/lib/Sync/Wicked.php similarity index 95% rename from wicked/lib/Sync/wicked.php rename to wicked/lib/Sync/Wicked.php index 60eb392b8..02bd9af87 100644 --- a/wicked/lib/Sync/wicked.php +++ b/wicked/lib/Sync/Wicked.php @@ -8,9 +8,6 @@ * @package Wicked */ -/** Horde_RPC */ -require_once 'Horde/RPC.php'; - /** * Wicked_Driver:: defines an API for implementing storage backends for * Wicked. @@ -18,7 +15,7 @@ require_once 'Horde/RPC.php'; * @author Duck * @package Wicked */ -class Wicked_Sync_wicked extends Wicked_Sync { +class Wicked_Sync_Wicked extends Wicked_Sync { /** * Returns a list of available pages. @@ -116,7 +113,7 @@ class Wicked_Sync_wicked extends Wicked_Sync { function _getData($method, $params = array()) { try { - return Horde_RPC::request( + return Horde_Rpc::request( 'xmlrpc', $this->_params['url'], $this->_params['prefix'] . '.' . $method, diff --git a/wicked/lib/tests/Driver.php b/wicked/lib/tests/Driver.php index c921d2eca..7e2fe4065 100644 --- a/wicked/lib/tests/Driver.php +++ b/wicked/lib/tests/Driver.php @@ -14,9 +14,6 @@ class Wicked_Driver_TC extends HordeUnitTestCase { @define('TEST_PAGE_1', 'driver-pages.phpt Test Page One'); @define('TEST_PAGE_2', 'Renamed driver-pages.phpt Test Page (Called "Two")'); - require_once WICKED_BASE . '/lib/Driver.php'; - require_once WICKED_BASE . '/lib/Wicked.php'; - $this->wicked = Wicked_Driver::factory('sql', $this->getTestDatabaseSQLDriverConfig()); } -- 2.11.0