From a4e98230bc8a69ec705dfe5fe8968b1d0e879c89 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Thu, 28 Jan 2010 11:34:09 -0700 Subject: [PATCH] Fully convert wicked to Horde_Registry_Application --- wicked/diff.php | 4 +- wicked/display.php | 3 +- wicked/history.php | 4 +- wicked/lib/Api.php | 334 ++++++++++++++++++++ wicked/lib/Application.php | 97 ++++++ wicked/lib/Block/page.php | 4 - wicked/lib/api.php | 465 ---------------------------- wicked/lib/base.load.php | 25 -- wicked/lib/base.php | 51 --- wicked/lib/version.php | 1 - wicked/preview.php | 4 +- wicked/scripts/mail-filter.php | 23 +- wicked/scripts/upgrades/convert_to_utf8.php | 21 +- wicked/scripts/wicked.php | 20 +- wicked/view.php | 3 +- 15 files changed, 452 insertions(+), 607 deletions(-) create mode 100644 wicked/lib/Api.php create mode 100644 wicked/lib/Application.php delete mode 100644 wicked/lib/api.php delete mode 100644 wicked/lib/base.load.php delete mode 100644 wicked/lib/base.php delete mode 100644 wicked/lib/version.php diff --git a/wicked/diff.php b/wicked/diff.php index 14adcaf11..233537526 100644 --- a/wicked/diff.php +++ b/wicked/diff.php @@ -8,8 +8,8 @@ * @author Chuck Hagenbuch */ -@define('WICKED_BASE', dirname(__FILE__)); -require_once WICKED_BASE . '/lib/base.php'; +require_once dirname(__FILE__) . '/lib/Application.php'; +Horde_Registry::appInit('wicked'); $v1 = Horde_Util::getFormData('v1'); $v2 = Horde_Util::getFormData('v2'); diff --git a/wicked/display.php b/wicked/display.php index 1544d96bc..f7a258c0e 100644 --- a/wicked/display.php +++ b/wicked/display.php @@ -8,7 +8,8 @@ * @author Tyler Colbert */ -require_once dirname(__FILE__) . '/lib/base.php'; +require_once dirname(__FILE__) . '/lib/Application.php'; +Horde_Registry::appInit('wicked'); $page = Page::getCurrentPage(); if (is_a($page, 'PEAR_Error')) { diff --git a/wicked/history.php b/wicked/history.php index 78f0dbe60..d84900cc1 100644 --- a/wicked/history.php +++ b/wicked/history.php @@ -8,8 +8,8 @@ * @author Tyler Colbert */ -@define('WICKED_BASE', dirname(__FILE__)); -require_once WICKED_BASE . '/lib/base.php'; +require_once dirname(__FILE__) . '/lib/Application.php'; +Horde_Registry::appInit('wicked'); $page = Page::getCurrentPage(); if (is_a($page, 'PEAR_Error')) { diff --git a/wicked/lib/Api.php b/wicked/lib/Api.php new file mode 100644 index 000000000..d92554941 --- /dev/null +++ b/wicked/lib/Api.php @@ -0,0 +1,334 @@ + '%application%/display.php?page=|page|&version=|version|#|toc|' + ); + + /** + * Returns a list of available pages. + * + * @param boolean $special Include special pages + * @param boolean $no_cache Always retreive pages from backed + * + * @return array An array of all available pages. + */ + public function list($special = true, $no_cache = false) + { + return $GLOBALS['wicked']->getPages($special, $no_cache); + } + + /** + * Return basic page information. + * + * @param string $pagename Page name + * + * @return array An array of page parameters. + */ + public function getPageInfo($pagename) + { + $page = Page::getPage($pagename); + if (is_a($page, 'PEAR_Error')) { + return $page; + } + + return array( + 'page_majorversion' => $page->_page['page_majorversion'], + 'page_minorversion' => $page->_page['page_minorversion'], + 'page_checksum' => md5($page->getText()), + 'version_created' => $page->_page['version_created'], + 'change_author' => $page->_page['change_author'], + 'change_log' => $page->_page['change_log'], + ); + } + + /** + * Return basic information for multiple pages. + * + * @param array $pagenames Page names + * + * @return array An array of arrays of page parameters. + */ + public function getMultiplePageInfo($pagenames = array()) + { + require_once dirname(__FILE__) . '/base.php'; + + if (empty($pagenames)) { + $pagenames = $GLOBALS['wicked']->getPages(false); + if (is_a($pagenames, 'PEAR_Error')) { + return $pagenames; + } + } + + $info = array(); + + foreach ($pagenames as $pagename) { + $page = Page::getPage($pagename); + if (is_a($page, 'PEAR_Error')) { + return $page; + } + $info[$pagename] = array( + 'page_majorversion' => $page->_page['page_majorversion'], + 'page_minorversion' => $page->_page['page_minorversion'], + 'page_checksum' => md5($page->getText()), + 'version_created' => $page->_page['version_created'], + 'change_author' => $page->_page['change_author'], + 'change_log' => $page->_page['change_log'] + ); + } + + return $info; + } + + /** + * Return page history. + * + * @param string $pagename Page name + * + * @return array An array of page parameters. + */ + public function getPageHistory($pagename) + { + $page = Page::getPage($pagename); + if (is_a($page, 'PEAR_Error')) { + return $page; + } + + $summaries = $GLOBALS['wicked']->getHistory($pagename); + if (is_a($summaries, 'PEAR_Error')) { + return $summaries; + } + + foreach ($summaries as $i => $summary) { + $summaries[$i]['page_checksum'] = md5($summary['page_text']); + unset($summaries[$i]['page_text']); + } + + return $summaries; + } + + /** + * Chech if a page exists + * + * @param string $pagename Page name + * + * @return boolean + */ + public function pageExists($pagename) + { + return $GLOBALS['wicked']->pageExists($pagename); + } + + /** + * Returns a rendered wiki page. + * + * @param string $pagename Page to display + * + * @return array Page without CSS link + */ + public function display($pagename) + { + $page = Page::getPage($pagename); + if (is_a($page, 'PEAR_Error')) { + return $page; + } + + $GLOBALS['wicked']->logPageView($page->pageName()); + + return $page->displayContents(false); + } + + /** + * Returns a rendered wiki page. + * + * @param string $pagename Page to display + * @param string $format Format to render page to (Plain, XHtml) + * + * @return array Rendered page + */ + public function renderPage($pagename, $format = 'Plain') + { + $page = Page::getPage($pagename); + if (is_a($page, 'PEAR_Error')) { + return $page; + } + + $wiki = &$page->getProcessor(); + $content = $wiki->transform($page->getText(), $format); + if (is_a($content, 'PEAR_Error')) { + return $content; + } + + $GLOBALS['wicked']->logPageView($page->pageName()); + return $content; + } + + /** + * Updates content of a wiki page. If the page does not exist it is + * created. + * + * @param string $pagename Page to edit + * @param string $text Page content + * @param string $changelog Description of the change + * @param boolean $minorchange True if this is a minor change + * + * @return boolean | PEAR_Error True on success, PEAR_Error on failure. + */ + public function edit($pagename, $text, $changelog = '', + $minorchange = false) + { + $page = Page::getPage($pagename); + if (is_a($page, 'PEAR_Error')) { + return $page; + } + if (!$page->allows(WICKED_MODE_EDIT)) { + return PEAR::RaiseError(sprintf(_("You don't have permission to edit \"%s\"."), $pagename)); + } + if ($GLOBALS['conf']['wicked']['require_change_log'] && + empty($changelog)) { + return PEAR::raiseError(_("You must provide a change log.")); + } + + $content = $page->getText(); + if (is_a($content, 'PEAR_Error')) { + // Maybe the page does not exists, if not create it + if ($GLOBALS['wicked']->pageExists($pagename)) { + return $content; + } else { + return $GLOBALS['wicked']->newPage($pagename, $text); + } + } + + if (trim($text) == trim($content)) { + return PEAR::raiseError(_("No changes made")); + } + + $result = $page->updateText($text, $changelog, $minorchange); + if (is_a($result, 'PEAR_Error')) { + return $result; + } else { + return true; + } + } + + /** + * Get a list of templates provided by Wicked. A template is any page + * whose name begins with "Template" + * + * @return mixed Array on success; PEAR_Error on failure + */ + public function listTemplates() + { + global $wicked; + $templates = $wicked->getMatchingPages('Template', WICKED_PAGE_MATCH_ENDS); + $list = array(array('category' => _("Wiki Templates"), + 'templates' => array())); + foreach ($templates as $page) { + $list[0]['templates'][] = array('id' => $page['page_name'], + 'name' => $page['page_name']); + } + return $list; + } + + /** + * Get a template specified by its name. This is effectively an alias for + * getPageSource() since Wicked templates are also normal pages. + * Wicked templates are pages that include "Template" at the beginning of + * the name. + * + * @param string $name The name of the template to fetch + * + * @return mixed String of template data on success; PEAR_Error on fail. + */ + public function getTemplate($name) + { + return $this->getPageSource($name); + } + + /** + * Get the wiki source of a page specified by its name. + * + * @param string $name The name of the page to fetch + * @param string $version Page version + * + * @return mixed String of page data on success; PEAR_Error on fail + */ + public function getPageSource($pagename, $version = null) + { + global $wicked; + + $page = Page::getPage($pagename, $version); + + if (!$page->allows(WICKED_MODE_CONTENT)) { + return PEAR::raiseError(_("Permission denied.")); + } + + if (!$page->isValid()) { + return PEAR::raiseError(_("Invalid page requested.")); + } + + return $page->getText(); + } + + /** + * Process a completed template to update the named Wiki page. This + * method is basically a passthrough to edit(). + * + * @param string $name Name of the new or modified page + * @param string $data Text content of the populated template + * + * @return mixed True on success; PEAR_Error on failure + */ + public function saveTemplate($name, $data) + { + return $this->edit($name, $data, 'Template Auto-fill', false); + } + + /** + * Returns the most recently changed pages. + * + * @param integer $days The number of days to look back. + * + * @return mixed An array of pages, or PEAR_Error on failure. + */ + public function getRecentChanges($days = 3) + { + $summaries = $GLOBALS['wicked']->getRecentChanges($days); + if (is_a($summaries, 'PEAR_Error')) { + return $summaries; + } + + $info = array(); + foreach ($summaries as $page) { + $info[$page['page_name']] = array( + 'page_majorversion' => $page['page_majorversion'], + 'page_minorversion' => $page['page_minorversion'], + 'page_checksum' => md5($page['page_text']), + 'version_created' => $page['version_created'], + 'change_author' => $page['change_author'], + 'change_log' => $page['change_log'], + ); + } + + return $info; + } + +} diff --git a/wicked/lib/Application.php b/wicked/lib/Application.php new file mode 100644 index 000000000..882047368 --- /dev/null +++ b/wicked/lib/Application.php @@ -0,0 +1,97 @@ +_permsCache)) { + return $this->_permsCache; + } + + $perms['tree']['wicked']['pages'] = array(); + $perms['title']['wicked:pages'] = _("Pages"); + + foreach (array('AllPages', 'LeastPopular', 'MostPopular', 'RecentChanges') as $val) { + $perms['tree']['wicked']['pages'][$val] = false; + $perms['title']['wicked:pages:' . $val] = $val; + } + + $pages = $wicked->getPages(); + if (!($pages instanceof PEAR_Error)) { + foreach ($pages as $pagename) { + $pageId = $wicked->getPageId($pagename); + $perms['tree']['wicked']['pages'][$pageId] = false; + $perms['title']['wicked:pages:' . $pageId] = $pagename; + } + ksort($perms['tree']['wicked']['pages']); + } + + $this->_permsCache = $perms; + + return $perms; + + } + +} diff --git a/wicked/lib/Block/page.php b/wicked/lib/Block/page.php index 8d9f434e5..a6d078ba2 100644 --- a/wicked/lib/Block/page.php +++ b/wicked/lib/Block/page.php @@ -19,16 +19,12 @@ class Horde_Block_Wicked_page extends Horde_Block { function _title() { - require_once dirname(__FILE__) . '/../base.php'; - $page = Page::getPage($this->_params['page']); return htmlspecialchars($page->pageName()); } function _content() { - require_once dirname(__FILE__) . '/../base.php'; - $page = Page::getPage($this->_params['page']); return $page->render(WICKED_MODE_BLOCK); } diff --git a/wicked/lib/api.php b/wicked/lib/api.php deleted file mode 100644 index b0eb60ce6..000000000 --- a/wicked/lib/api.php +++ /dev/null @@ -1,465 +0,0 @@ - array(), - 'type' => 'array', -); - -$_services['show'] = array( - 'link' => '%application%/display.php?page=|page|&version=|version|#|toc|', -); - -$_services['list'] = array( - 'args' => array('special' => 'boolean', - 'no_cache' => 'boolean'), - 'type' => 'array', -); - -$_services['getPageInfo'] = array( - 'args' => array('pagename' => 'string'), - 'type' => 'string', -); - -$_services['getMultiplePageInfo'] = array( - 'args' => array('pagenames' => '{urn:horde}stringArray'), - 'type' => 'string', -); - -$_services['getPageHistory'] = array( - 'args' => array('pagename' => 'string'), - 'type' => 'string', -); - -$_services['pageExists'] = array( - 'args' => array('pagename' => 'string'), - 'type' => 'string', -); - -$_services['display'] = array( - 'args' => array('pagename' => 'string'), - 'type' => 'string', -); - -$_services['renderPage'] = array( - 'args' => array('pagename' => 'string', - 'format' => 'string'), - 'type' => 'string', -); - -$_services['edit'] = array( - 'args' => array('pagename' => 'string', - 'text' => 'string', - 'changelog' => 'string', - 'minorchange' => 'boolean'), - 'type' => 'boolean', -); - -$_services['listTemplates'] = array( - 'args' => array(), - 'type' => 'array', -); - -$_services['getTemplate'] = array( - 'args' => array('name' => 'string'), - 'type' => 'string', -); - -$_services['saveTemplate'] = array( - 'args' => array('name' => 'string', - 'data' => 'string'), - 'type' => 'boolean', -); - -$_services['getPageSource'] = array( - 'args' => array('name' => 'string'), - 'type' => 'text', -); - -$_services['getRecentChanges'] = array( - 'args' => array('days' => 'int'), - 'type' => 'array', -); - -/** - * Returns a list of available permissions. - * - * @return array An array describing all available permissions. - */ -function _wicked_perms() -{ - static $perms = array(); - if (!empty($perms)) { - return $perms; - } - - require_once dirname(__FILE__) . '/base.php'; - global $wicked; - - $perms['tree']['wicked']['pages'] = array(); - $perms['title']['wicked:pages'] = _("Pages"); - - $perms['tree']['wicked']['pages'] = array(); - $perms['title']['wicked:pages'] = _("Pages"); - - $perms['tree']['wicked']['pages']['AllPages'] = false; - $perms['title']['wicked:pages:AllPages'] = 'AllPages'; - - $perms['tree']['wicked']['pages']['LeastPopular'] = false; - $perms['title']['wicked:pages:LeastPopular'] = 'LeastPopular'; - - $perms['tree']['wicked']['pages']['MostPopular'] = false; - $perms['title']['wicked:pages:MostPopular'] = 'MostPopular'; - - $perms['tree']['wicked']['pages']['RecentChanges'] = false; - $perms['title']['wicked:pages:RecentChanges'] = 'RecentChanges'; - - $pages = $wicked->getPages(); - if (is_a($pages, 'PEAR_Error')) { - return $pages; - } - - foreach ($pages as $pagename) { - $pageId = $wicked->getPageId($pagename); - $perms['tree']['wicked']['pages'][$pageId] = false; - $perms['title']['wicked:pages:' . $pageId] = $pagename; - } - - ksort($perms['tree']['wicked']['pages']); - return $perms; -} - -/** - * Returns a list of available pages. - * - * @param boolean $special Include special pages - * @param boolean $no_cache Always retreive pages from backed - * - * @return array An array of all available pages. - */ -function _wicked_list($special = true, $no_cache = false) -{ - require_once dirname(__FILE__) . '/base.php'; - return $GLOBALS['wicked']->getPages($special, $no_cache); -} - -/** - * Return basic page information. - * - * @param string $pagename Page name - * - * @return array An array of page parameters. - */ -function _wicked_getPageInfo($pagename) -{ - require_once dirname(__FILE__) . '/base.php'; - - $page = Page::getPage($pagename); - if (is_a($page, 'PEAR_Error')) { - return $page; - } - - return array( - 'page_majorversion' => $page->_page['page_majorversion'], - 'page_minorversion' => $page->_page['page_minorversion'], - 'page_checksum' => md5($page->getText()), - 'version_created' => $page->_page['version_created'], - 'change_author' => $page->_page['change_author'], - 'change_log' => $page->_page['change_log'], - ); -} - -/** - * Return basic information for multiple pages. - * - * @param array $pagenames Page names - * - * @return array An array of arrays of page parameters. - */ -function _wicked_getMultiplePageInfo($pagenames = array()) -{ - require_once dirname(__FILE__) . '/base.php'; - - if (empty($pagenames)) { - $pagenames = $GLOBALS['wicked']->getPages(false); - if (is_a($pagenames, 'PEAR_Error')) { - return $pagenames; - } - } - - $info = array(); - - foreach ($pagenames as $pagename) { - $page = Page::getPage($pagename); - if (is_a($page, 'PEAR_Error')) { - return $page; - } - $info[$pagename] = array( - 'page_majorversion' => $page->_page['page_majorversion'], - 'page_minorversion' => $page->_page['page_minorversion'], - 'page_checksum' => md5($page->getText()), - 'version_created' => $page->_page['version_created'], - 'change_author' => $page->_page['change_author'], - 'change_log' => $page->_page['change_log'] - ); - } - - return $info; -} - -/** - * Return page history. - * - * @param string $pagename Page name - * - * @return array An array of page parameters. - */ -function _wicked_getPageHistory($pagename) -{ - require_once dirname(__FILE__) . '/base.php'; - - $page = Page::getPage($pagename); - if (is_a($page, 'PEAR_Error')) { - return $page; - } - - $summaries = $GLOBALS['wicked']->getHistory($pagename); - if (is_a($summaries, 'PEAR_Error')) { - return $summaries; - } - - foreach ($summaries as $i => $summary) { - $summaries[$i]['page_checksum'] = md5($summary['page_text']); - unset($summaries[$i]['page_text']); - } - - return $summaries; -} - -/** - * Chech if a page exists - * - * @param string $pagename Page name - * - * @return boolean - */ -function _wicked_pageExists($pagename) -{ - require_once dirname(__FILE__) . '/base.php'; - return $GLOBALS['wicked']->pageExists($pagename); -} - -/** - * Returns a rendered wiki page. - * - * @param string $pagename Page to display - * - * @return array Page without CSS link - */ -function _wicked_display($pagename) -{ - require_once dirname(__FILE__) . '/base.php'; - - $page = Page::getPage($pagename); - if (is_a($page, 'PEAR_Error')) { - return $page; - } - - $GLOBALS['wicked']->logPageView($page->pageName()); - - return $page->displayContents(false); -} - -/** - * Returns a rendered wiki page. - * - * @param string $pagename Page to display - * @param string $format Format to render page to (Plain, XHtml) - * - * @return array Rendered page - */ -function _wicked_renderPage($pagename, $format = 'Plain') -{ - require_once dirname(__FILE__) . '/base.php'; - - $page = Page::getPage($pagename); - if (is_a($page, 'PEAR_Error')) { - return $page; - } - - $wiki = &$page->getProcessor(); - $content = $wiki->transform($page->getText(), $format); - if (is_a($content, 'PEAR_Error')) { - return $content; - } - - $GLOBALS['wicked']->logPageView($page->pageName()); - return $content; -} - -/** - * Updates content of a wiki page. If the page does not exist it is - * created. - * - * @param string $pagename Page to edit - * @param string $text Page content - * @param string $changelog Description of the change - * @param boolean $minorchange True if this is a minor change - * - * @return boolean | PEAR_Error True on success, PEAR_Error on failure. - */ -function _wicked_edit($pagename, $text, $changelog = '', $minorchange = false) -{ - require_once dirname(__FILE__) . '/base.php'; - - $page = Page::getPage($pagename); - if (is_a($page, 'PEAR_Error')) { - return $page; - } - if (!$page->allows(WICKED_MODE_EDIT)) { - return PEAR::RaiseError(sprintf(_("You don't have permission to edit \"%s\"."), $pagename)); - } - if ($GLOBALS['conf']['wicked']['require_change_log'] && - empty($changelog)) { - return PEAR::raiseError(_("You must provide a change log.")); - } - - $content = $page->getText(); - if (is_a($content, 'PEAR_Error')) { - // Maybe the page does not exists, if not create it - if ($GLOBALS['wicked']->pageExists($pagename)) { - return $content; - } else { - return $GLOBALS['wicked']->newPage($pagename, $text); - } - } - - if (trim($text) == trim($content)) { - return PEAR::raiseError(_("No changes made")); - } - - $result = $page->updateText($text, $changelog, $minorchange); - if (is_a($result, 'PEAR_Error')) { - return $result; - } else { - return true; - } -} - -/** - * Get a list of templates provided by Wicked. A template is any page whose - * name begins with "Template" - * - * @return mixed Array on success; PEAR_Error on failure - */ -function _wicked_listTemplates() -{ - require_once dirname(__FILE__) . '/base.php'; - global $wicked; - $templates = $wicked->getMatchingPages('Template', WICKED_PAGE_MATCH_ENDS); - $list = array(array('category' => _("Wiki Templates"), - 'templates' => array())); - foreach ($templates as $page) { - $list[0]['templates'][] = array('id' => $page['page_name'], - 'name' => $page['page_name']); - } - return $list; -} - -/** - * Get a template specified by its name. This is effectively an alias for - * getPageSource() since Wicked templates are also normal pages. - * Wicked templates are pages that include "Template" at the beginning of the - * name. - * - * @param string $name The name of the template to fetch - * - * @return mixed String of template data on success; PEAR_Error on fail - */ -function _wicked_getTemplate($name) -{ - return _wicked_getPageSource($name); -} - -/** - * Get the wiki source of a page specified by its name. - * - * @param string $name The name of the page to fetch - * @param string $version Page version - * - * @return mixed String of page data on success; PEAR_Error on fail - */ -function _wicked_getPageSource($pagename, $version = null) -{ - require_once dirname(__FILE__) . '/base.php'; - global $wicked; - - $page = Page::getPage($pagename, $version); - - if (!$page->allows(WICKED_MODE_CONTENT)) { - return PEAR::raiseError(_("Permission denied.")); - } - - if (!$page->isValid()) { - return PEAR::raiseError(_("Invalid page requested.")); - } - - return $page->getText(); -} - -/** - * Process a completed template to update the named Wiki page. This method is - * basically a passthrough to _wicked_edit() - * - * @param string $name Name of the new or modified page - * @param string $data Text content of the populated template - * - * @return mixed True on success; PEAR_Error on failure - */ -function _wicked_saveTemplate($name, $data) -{ - return _wicked_edit($name, $data, 'Template Auto-fill', false); -} - -/** - * Returns the most recently changed pages. - * - * @param integer $days The number of days to look back. - * - * @return mixed An array of pages, or PEAR_Error on failure. - */ -function _wicked_getRecentChanges($days = 3) -{ - require_once dirname(__FILE__) . '/base.php'; - - $summaries = $GLOBALS['wicked']->getRecentChanges($days); - if (is_a($summaries, 'PEAR_Error')) { - return $summaries; - } - - $info = array(); - foreach ($summaries as $page) { - $info[$page['page_name']] = array( - 'page_majorversion' => $page['page_majorversion'], - 'page_minorversion' => $page['page_minorversion'], - 'page_checksum' => md5($page['page_text']), - 'version_created' => $page['version_created'], - 'change_author' => $page['change_author'], - 'change_log' => $page['change_log'], - ); - } - - return $info; -} diff --git a/wicked/lib/base.load.php b/wicked/lib/base.load.php deleted file mode 100644 index 6a8259932..000000000 --- a/wicked/lib/base.load.php +++ /dev/null @@ -1,25 +0,0 @@ -pushApp('wicked', !defined('AUTH_HANDLER')); -} catch (Horde_Exception $e) { - if ($e->getCode() == 'permission_denied') { - Horde_Auth::authenticateFailure('wicked', $e); - } - Horde::fatal($e, __FILE__, __LINE__, false); -} -$conf = &$GLOBALS['conf']; -define('WICKED_TEMPLATES', $registry->get('templates')); - -// Find the base file path of Wicked. -if (!defined('WICKED_BASE')) { - define('WICKED_BASE', dirname(__FILE__) . '/..'); -} - -// Notification system. -$notification = &Horde_Notification::singleton(); -$notification->attach('status'); - -// Wicked base libraries. -require_once WICKED_BASE . '/lib/Wicked.php'; -require_once WICKED_BASE . '/lib/Driver.php'; -require_once WICKED_BASE . '/lib/Page.php'; -$GLOBALS['wicked'] = Wicked_Driver::factory(); - -// Start compression. -if (!Horde_Util::nonInputVar('no_compress')) { - Horde::compressOutput(); -} diff --git a/wicked/lib/version.php b/wicked/lib/version.php deleted file mode 100644 index 79508903c..000000000 --- a/wicked/lib/version.php +++ /dev/null @@ -1 +0,0 @@ - diff --git a/wicked/preview.php b/wicked/preview.php index 911e60b8e..598c087ea 100644 --- a/wicked/preview.php +++ b/wicked/preview.php @@ -8,8 +8,8 @@ * @author Chuck Hagenbuch */ -@define('WICKED_BASE', dirname(__FILE__)); -require_once WICKED_BASE . '/lib/base.php'; +require_once dirname(__FILE__) . '/lib/Application.php'; +Horde_Registry::appInit('wicked'); if (!($text = Horde_Util::getFormData('page_text'))) { exit; diff --git a/wicked/scripts/mail-filter.php b/wicked/scripts/mail-filter.php index 4c8351687..a2a3c49a0 100755 --- a/wicked/scripts/mail-filter.php +++ b/wicked/scripts/mail-filter.php @@ -6,27 +6,12 @@ * page. */ -@define('AUTH_HANDLER', true); -@define('HORDE_BASE', dirname(__FILE__) . '/../..'); +require_once dirname(__FILE__) . '/../lib/Application.php'; +Horde_Registry::appInit('wicked', array('authentication' => 'none', 'cli' => true)); -// Do CLI checks and environment setup first. -require_once HORDE_BASE . '/lib/core.php'; - -$keepHeaders = array('From', 'To', 'Subject', 'Cc', 'Date'); -$dateFormat = "F j, Y"; - -// Make sure no one runs this from the web. -if (!Horde_Cli::runningFromCLI()) { - exit("Must be run from the command line\n"); -} - -// Load the CLI environment - make sure there's no time limit, init -// some variables, etc. -Horde_Cli::init(); $cli = Horde_Cli::singleton(); - -@define('WICKED_BASE', HORDE_BASE . '/wicked'); -require_once WICKED_BASE . '/lib/base.php'; +$dateFormat = "F j, Y"; +$keepHeaders = array('From', 'To', 'Subject', 'Cc', 'Date'); $text = ''; while (!feof(STDIN)) { diff --git a/wicked/scripts/upgrades/convert_to_utf8.php b/wicked/scripts/upgrades/convert_to_utf8.php index c03697b2d..42ea33bcb 100755 --- a/wicked/scripts/upgrades/convert_to_utf8.php +++ b/wicked/scripts/upgrades/convert_to_utf8.php @@ -12,29 +12,16 @@ * @author Jan Schneider */ -@define('AUTH_HANDLER', true); -@define('HORDE_BASE', dirname(__FILE__) . '/../../..'); +require_once dirname(__FILE__) . '/../lib/Application.php'; +Horde_Registry::appInit('wicked', array('authentication' => 'none', 'cli' => true)); -// Do CLI checks and environment setup first. -require_once HORDE_BASE . '/lib/core.php'; - -// Make sure no one runs this from the web. -if (!Horde_Cli::runningFromCLI()) { - exit("Must be run from the command line\n"); -} - -// Load the CLI environment - make sure there's no time limit, init some -// variables, etc. -$cli = &Horde_Cli::singleton(); -$cli->init(); +$cli = Horde_Cli::singleton(); // Create driver instance. -@define('WICKED_BASE', dirname(__FILE__) . '/../..'); -require_once WICKED_BASE . '/lib/base.php'; if ($conf['storage']['driver'] != 'sql') { exit("You must have an SQL backend configured.\n"); } -$db = &$wicked->_db; +$db = $wicked->_db; // Get current charset. $charset = $cli->prompt('Please specify the current charset of the data', diff --git a/wicked/scripts/wicked.php b/wicked/scripts/wicked.php index dc55dc078..f75c9d13f 100755 --- a/wicked/scripts/wicked.php +++ b/wicked/scripts/wicked.php @@ -9,24 +9,10 @@ * @author Vijay Mahrra */ -@define('AUTH_HANDLER', true); -@define('HORDE_BASE', dirname(__FILE__) . '/../..'); -@define('WICKED_BASE', HORDE_BASE . '/wicked'); +require_once dirname(__FILE__) . '/../lib/Application.php'; +Horde_Registry::appInit('wicked', array('authentication' => 'none', 'cli' => true)); -// Do CLI checks and environment setup first. -require_once WICKED_BASE . '/lib/base.php'; - -// Make sure no one runs this from the web. -if (!Horde_Cli::runningFromCLI()) { - exit("Must be run from the command line\n"); -} - -// Load the CLI environment. -require_once 'Console/Getopt.php'; -Horde_Cli::init(); -$cli = &Horde_Cli::singleton(); -$registry = Horde_Registry::singleton(); -$registry->pushApp('wicked', false); +$cli = Horde_Cli::singleton(); $debug = false; $out = 'screen'; diff --git a/wicked/view.php b/wicked/view.php index 7e06d736e..d42781ddd 100644 --- a/wicked/view.php +++ b/wicked/view.php @@ -8,7 +8,8 @@ * @author Jason Felice */ -require_once dirname(__FILE__) . '/lib/base.php'; +require_once dirname(__FILE__) . '/lib/Application.php'; +Horde_Registry::appInit('wicked'); $page = Horde_Util::getFormData('page', 'WikiHome'); $file = Horde_Util::getFormData('file'); -- 2.11.0