* @author Chuck Hagenbuch <chuck@horde.org>
*/
-@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');
* @author Tyler Colbert <tyler@colberts.us>
*/
-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')) {
* @author Tyler Colbert <tyler@colberts.us>
*/
-@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')) {
--- /dev/null
+<?php
+/**
+ * Wicked external API interface.
+ *
+ * This file defines Wicked's external API interface. Other applications
+ * can interact with Wicked through this API.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @package Wicked
+ */
+class Wicked_Api extends Horde_Registry_Api
+{
+ /**
+ * Links.
+ *
+ * @var array
+ */
+ public $links = array(
+ 'show' => '%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;
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * Wicked application API.
+ *
+ * This file defines Horde's core API interface. Other core Horde libraries
+ * can interact with Wicked through this API.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @package Wicked
+ */
+
+/* Determine the base directories. */
+if (!defined('WICKED_BASE')) {
+ define('WICKED_BASE', dirname(__FILE__) . '/..');
+}
+
+if (!defined('HORDE_BASE')) {
+ /* If Horde does not live directly under the app directory, the HORDE_BASE
+ * constant should be defined in config/horde.local.php. */
+ if (file_exists(WICKED_BASE . '/config/horde.local.php')) {
+ include WICKED_BASE . '/config/horde.local.php';
+ } else {
+ define('HORDE_BASE', WICKED_BASE . '/..');
+ }
+}
+
+/* Load the Horde Framework core (needed to autoload
+ * Horde_Registry_Application::). */
+require_once HORDE_BASE . '/lib/core.php';
+
+class Wicked_Application extends Horde_Registry_Application
+{
+ /**
+ * The application's version.
+ *
+ * @var string
+ */
+ public $version = 'H4 (2.0-git)';
+
+ /**
+ * Perms cache.
+ *
+ * @var array
+ */
+ protected $_permsCache = array();
+
+ /**
+ * Wicked initialization.
+ *
+ * Global variables defined:
+ * $wicked - The Wicked_Driver object.
+ */
+ protected function _init()
+ {
+ $GLOBALS['wicked'] = Wicked_Driver::factory();
+ }
+
+ /**
+ * Returns a list of available permissions.
+ *
+ * @return array An array describing all available permissions.
+ */
+ public function perms()
+ {
+ if (!empty($this->_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;
+
+ }
+
+}
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);
}
+++ /dev/null
-<?php
-/**
- * Wicked external API interface.
- *
- * This file defines Wicked's external API interface. Other applications
- * can interact with Wicked through this API.
- *
- * Copyright 2003-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @package Wicked
- */
-
-$_services['perms'] = array(
- 'args' => 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;
-}
+++ /dev/null
-<?php
-/**
- * Script to determine the correct *_BASE values.
- *
- * Copyright 2009-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @package Ansel
- */
-
-if (!defined('WICKED_BASE')) {
- define('WICKED_BASE', dirname(__FILE__) . '/..');
-}
-
-if (!defined('HORDE_BASE')) {
- /* If horde does not live directly under the app directory, the HORDE_BASE
- * constant should be defined in config/horde.local.php. */
- if (file_exists(WICKED_BASE . '/config/horde.local.php')) {
- include WICKED_BASE . '/config/horde.local.php';
- } else {
- define('HORDE_BASE', WHUPS_BASE . '/..');
- }
-}
+++ /dev/null
-<?php
-/**
- * Wicked base inclusion file.
- *
- * This file brings in all of the dependencies that every Wicked
- * script will need and sets up objects that all scripts use.
- *
- * Copyright 2003-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- */
-
-// Determine BASE directories.
-require_once dirname(__FILE__) . '/base.load.php';
-
-// Load the Horde Framework core, and set up inclusion paths.
-require_once HORDE_BASE . '/lib/core.php';
-
-// Registry.
-$registry = Horde_Registry::singleton();
-try {
- $registry->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();
-}
+++ /dev/null
-<?php define('WICKED_VERSION', 'H4 (1.0-cvs)') ?>
* @author Chuck Hagenbuch <chuck@horde.org>
*/
-@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;
* 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)) {
* @author Jan Schneider <jan@horde.org>
*/
-@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',
* @author Vijay Mahrra <vijay.mahrra@es.easynet.net>
*/
-@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';
* @author Jason Felice <jason.m.felice@gmail.com>
*/
-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');