From: Michael J. Rubinsky Date: Sat, 2 Oct 2010 19:59:30 +0000 (-0400) Subject: Class constants X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=89f7955d6f286a61b8be1e5c5f13511df3734abe;p=horde.git Class constants --- diff --git a/wicked/diff.php b/wicked/diff.php index 3144b6a2f..7bb87fb04 100644 --- a/wicked/diff.php +++ b/wicked/diff.php @@ -43,7 +43,7 @@ if ($v1 == '?') { /* Kick back to the display page if we're not allowed to diff this * page. */ -if (!$page->allows(WICKED_MODE_DIFF)) { +if (!$page->allows(Wicked::MODE_DIFF)) { Wicked::url($page->pageName(), true) ->add('actionID', 'diff') ->redirect(); @@ -52,5 +52,5 @@ if (!$page->allows(WICKED_MODE_DIFF)) { $title = sprintf(_("Diff for %s between %s and %s"), $page->pageName(), $v1, $page->version()); require WICKED_TEMPLATES . '/common-header.inc'; require WICKED_TEMPLATES . '/menu.inc'; -$page->render(WICKED_MODE_DIFF, $v1); +$page->render(Wicked::MODE_DIFF, $v1); require $registry->get('templates', 'horde') . '/common-footer.inc'; diff --git a/wicked/display.php b/wicked/display.php index 0ae43e3cb..d4e0de72a 100644 --- a/wicked/display.php +++ b/wicked/display.php @@ -20,7 +20,7 @@ if (is_a($page, 'PEAR_Error')) { $actionID = Horde_Util::getFormData('actionID'); switch ($actionID) { case 'lock': - if (!$page->allows(WICKED_MODE_LOCKING)) { + if (!$page->allows(Wicked::MODE_LOCKING)) { $notification->push(_("You are not allowed to lock this page"), 'horde.error'); break; @@ -33,7 +33,7 @@ case 'lock': break; case 'unlock': - if (!$page->allows(WICKED_MODE_UNLOCKING)) { + if (!$page->allows(Wicked::MODE_UNLOCKING)) { $notification->push(_("You are not allowed to unlock this page"), 'horde.error'); } @@ -48,7 +48,7 @@ case 'unlock': break; case 'history': - if ($page->allows(WICKED_MODE_HISTORY)) { + if ($page->allows(Wicked::MODE_HISTORY)) { /* Redirect to history page. */ Horde::url('history.php') ->add('page', $page->pageName()) @@ -62,7 +62,7 @@ case 'special': break; case 'export': - if (!$page->allows(WICKED_MODE_DISPLAY)) { + if (!$page->allows(Wicked::MODE_DISPLAY)) { $notification->push(_("You don't have permission to view this page."), 'horde.error'); if ($page->pageName() == 'WikiHome') { @@ -106,7 +106,7 @@ default: $wicked->logPageView($page->pageName()); } -if (!$page->allows(WICKED_MODE_DISPLAY)) { +if (!$page->allows(Wicked::MODE_DISPLAY)) { $notification->push(_("You don't have permission to view this page."), 'horde.error'); if ($page->pageName() == 'WikiHome') { @@ -116,7 +116,7 @@ if (!$page->allows(WICKED_MODE_DISPLAY)) { } $params = Horde_Util::getFormData('params'); -$page->preDisplay(WICKED_MODE_DISPLAY, $params); +$page->preDisplay(Wicked::MODE_DISPLAY, $params); if (!isset($_SESSION['wickedSession']['history'])) { $_SESSION['wickedSession']['history'] = array(); @@ -129,7 +129,7 @@ if ($page->isLocked()) { $title = $page->pageTitle(); require WICKED_TEMPLATES . '/common-header.inc'; require WICKED_TEMPLATES . '/menu.inc'; -$page->render(WICKED_MODE_DISPLAY, $params); +$page->render(Wicked::MODE_DISPLAY, $params); require $registry->get('templates', 'horde') . '/common-footer.inc'; if (is_a($page, 'StandardPage') && diff --git a/wicked/history.php b/wicked/history.php index bc995206e..7e232f1c9 100644 --- a/wicked/history.php +++ b/wicked/history.php @@ -17,7 +17,7 @@ if (is_a($page, 'PEAR_Error')) { Wicked::url('WikiHome', true)->redirect(); } -if (!$page->allows(WICKED_MODE_HISTORY)) { +if (!$page->allows(Wicked::MODE_HISTORY)) { /* Redirect to display page and force it to display an error. */ Wicked::url($page->pageName(), true)->add('actionID', 'history')->redirect(); } @@ -25,5 +25,5 @@ if (!$page->allows(WICKED_MODE_HISTORY)) { $title = sprintf(_("History: %s"), $page->pageName()); require WICKED_TEMPLATES . '/common-header.inc'; require WICKED_TEMPLATES . '/menu.inc'; -$page->render(WICKED_MODE_HISTORY); +$page->render(Wicked::MODE_HISTORY); require $registry->get('templates', 'horde') . '/common-footer.inc'; diff --git a/wicked/lib/Api.php b/wicked/lib/Api.php index 9a70cbc46..9c16c6efb 100644 --- a/wicked/lib/Api.php +++ b/wicked/lib/Api.php @@ -199,7 +199,7 @@ class Wicked_Api extends Horde_Registry_Api if (is_a($page, 'PEAR_Error')) { return $page; } - if (!$page->allows(WICKED_MODE_EDIT)) { + 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'] && @@ -277,7 +277,7 @@ class Wicked_Api extends Horde_Registry_Api $page = Wicked_Page::getPage($pagename, $version); - if (!$page->allows(WICKED_MODE_CONTENT)) { + if (!$page->allows(Wicked::MODE_CONTENT)) { return PEAR::raiseError(_("Permission denied.")); } diff --git a/wicked/lib/Block/page.php b/wicked/lib/Block/page.php index c1f4fbd14..58214887d 100644 --- a/wicked/lib/Block/page.php +++ b/wicked/lib/Block/page.php @@ -26,7 +26,7 @@ class Horde_Block_Wicked_page extends Horde_Block protected function _content() { $page = Wicked_Page::getPage($this->_params['page']); - return $page->render(WICKED_MODE_BLOCK); + return $page->render(Wicked::MODE_BLOCK); } protected function _params() diff --git a/wicked/lib/Driver/sql.php b/wicked/lib/Driver/sql.php index 652e932cb..e9e80f038 100644 --- a/wicked/lib/Driver/sql.php +++ b/wicked/lib/Driver/sql.php @@ -207,7 +207,7 @@ class Wicked_Driver_sql extends Wicked_Driver { * actually refer to $pagename. */ $patterns = array('/\(\(' . preg_quote($pagename, '/') . '(?:\|[^)]+)?\)\)/'); - if (preg_match('/^' . WICKED_REGEXP_WIKIWORD . '$/', $pagename)) { + if (preg_match('/^' . Wicked::REGEXP_WIKIWORD . '$/', $pagename)) { $patterns[] = '/\b' . preg_quote($pagename, '/') . '\b/'; } diff --git a/wicked/lib/Page.php b/wicked/lib/Page.php index 580e3792b..4a15e7490 100644 --- a/wicked/lib/Page.php +++ b/wicked/lib/Page.php @@ -15,15 +15,15 @@ class Wicked_Page { /** * Display modes supported by this page. Possible modes: * - * WICKED_MODE_CONTENT - * WICKED_MODE_DISPLAY - * WICKED_MODE_EDIT - * WICKED_MODE_REMOVE - * WICKED_MODE_HISTORY - * WICKED_MODE_DIFF - * WICKED_MODE_LOCKING - * WICKED_MODE_UNLOCKING - * WICKED_MODE_CREATE + * Wicked::MODE_CONTENT + * Wicked::MODE_DISPLAY + * Wicked::MODE_EDIT + * Wicked::MODE_REMOVE + * Wicked::MODE_HISTORY + * Wicked::MODE_DIFF + * Wicked::MODE_LOCKING + * Wicked::MODE_UNLOCKING + * Wicked::MODE_CREATE * * @var array */ @@ -102,7 +102,7 @@ class Wicked_Page { $pagePerms = $this->getPermissions(); switch ($mode) { - case WICKED_MODE_CREATE: + case Wicked::MODE_CREATE: // Special mode for pages that don't exist yet - generic // to all pages. if ($browser->isRobot()) { @@ -123,7 +123,7 @@ class Wicked_Page { } break; - case WICKED_MODE_EDIT: + case Wicked::MODE_EDIT: if ($browser->isRobot()) { return false; } @@ -137,7 +137,7 @@ class Wicked_Page { } break; - case WICKED_MODE_REMOVE: + case Wicked::MODE_REMOVE: if ($browser->isRobot()) { return false; } @@ -225,7 +225,7 @@ class Wicked_Page { } $page = new StandardPage($pagename); - if ($page->isValid() || !$page->allows(WICKED_MODE_EDIT)) { + if ($page->isValid() || !$page->allows(Wicked::MODE_EDIT)) { return $page; } @@ -460,7 +460,7 @@ class Wicked_Page { $this->_proc->setFormatConf('Xhtml', 'charset', $GLOBALS['registry']->getCharset()); $this->_proc->setFormatConf('Xhtml', 'translate', HTML_SPECIALCHARS); - $create = $this->allows(WICKED_MODE_CREATE) ? 1 : 0; + $create = $this->allows(Wicked::MODE_CREATE) ? 1 : 0; $linkConf = array( 'pages' => $wicked->getPages(), 'view_url' => $view_url, @@ -492,22 +492,22 @@ class Wicked_Page { function render($mode, $params = null) { switch ($mode) { - case WICKED_MODE_CONTENT: + case Wicked::MODE_CONTENT: return $this->content($params); - case WICKED_MODE_DISPLAY: + case Wicked::MODE_DISPLAY: return $this->display($params); - case WICKED_MODE_BLOCK: + case Wicked::MODE_BLOCK: return $this->block($params); - case WICKED_MODE_REMOVE: + case Wicked::MODE_REMOVE: return $this->remove(); - case WICKED_MODE_HISTORY: + case Wicked::MODE_HISTORY: return $this->history(); - case WICKED_MODE_DIFF: + case Wicked::MODE_DIFF: return $this->diff($params); default: diff --git a/wicked/lib/Page/AddPage.php b/wicked/lib/Page/AddPage.php index ad1d18211..a03ac6950 100644 --- a/wicked/lib/Page/AddPage.php +++ b/wicked/lib/Page/AddPage.php @@ -21,7 +21,7 @@ class AddPage extends Wicked_Page { * @var array */ var $supportedModes = array( - WICKED_MODE_DISPLAY => true); + Wicked::MODE_DISPLAY => true); /** * The page to confirm creation of. diff --git a/wicked/lib/Page/AllPages.php b/wicked/lib/Page/AllPages.php index bed4cf61b..000da21cf 100644 --- a/wicked/lib/Page/AllPages.php +++ b/wicked/lib/Page/AllPages.php @@ -19,8 +19,8 @@ class AllPages extends Wicked_Page { * Display modes supported by this page. */ var $supportedModes = array( - WICKED_MODE_CONTENT => true, - WICKED_MODE_DISPLAY => true); + Wicked::MODE_CONTENT => true, + Wicked::MODE_DISPLAY => true); /** * Render this page in Content mode. diff --git a/wicked/lib/Page/AttachedFiles.php b/wicked/lib/Page/AttachedFiles.php index 0776dafb9..2904603cb 100644 --- a/wicked/lib/Page/AttachedFiles.php +++ b/wicked/lib/Page/AttachedFiles.php @@ -22,10 +22,10 @@ class AttachedFiles extends Wicked_Page { * @var array */ var $supportedModes = array( - WICKED_MODE_CONTENT => true, - WICKED_MODE_EDIT => true, - WICKED_MODE_REMOVE => true, - WICKED_MODE_DISPLAY => true); + Wicked::MODE_CONTENT => true, + Wicked::MODE_EDIT => true, + Wicked::MODE_REMOVE => true, + Wicked::MODE_DISPLAY => true); /** * The page for which we'd like to manipulate attachments. @@ -86,7 +86,7 @@ class AttachedFiles extends Wicked_Page { 'version' => $attach['attachment_majorversion'] . '.' . $attach['attachment_minorversion'])); - $attachments[$idx]['delete_form'] = $this->allows(WICKED_MODE_REMOVE); + $attachments[$idx]['delete_form'] = $this->allows(Wicked::MODE_REMOVE); $this->_page['change_author'] = $attachments[$idx]['change_author']; $attachments[$idx]['change_author'] = $this->author(); @@ -136,9 +136,9 @@ class AttachedFiles extends Wicked_Page { sort($files); $template->set('files', $files); $template->set('canUpdate', - $this->allows(WICKED_MODE_EDIT) && count($files), + $this->allows(Wicked::MODE_EDIT) && count($files), true); - $template->set('canAttach', $this->allows(WICKED_MODE_EDIT), true); + $template->set('canAttach', $this->allows(Wicked::MODE_EDIT), true); if ($conf['wicked']['require_change_log']) { $template->set('requireChangelog', true, true); } else { @@ -186,7 +186,7 @@ class AttachedFiles extends Wicked_Page { // See if we're supposed to delete an attachment. if ($cmd == 'delete' && $filename && $version) { - if (!$this->allows(WICKED_MODE_REMOVE)) { + if (!$this->allows(Wicked::MODE_REMOVE)) { $notification->push(_("You do not have permission to delete attachments from this page."), 'horde.error'); return; } @@ -228,7 +228,7 @@ class AttachedFiles extends Wicked_Page { return; } - if (!$this->allows(WICKED_MODE_EDIT)) { + if (!$this->allows(Wicked::MODE_EDIT)) { $notification->push( sprintf(_("You do not have permission to edit \"%s\""), $this->referrer()), diff --git a/wicked/lib/Page/BackLinks.php b/wicked/lib/Page/BackLinks.php index fd8a73a8f..f8504ebea 100644 --- a/wicked/lib/Page/BackLinks.php +++ b/wicked/lib/Page/BackLinks.php @@ -21,7 +21,7 @@ class BackLinks extends Wicked_Page { * @var array */ var $supportedModes = array( - WICKED_MODE_DISPLAY => true); + Wicked::MODE_DISPLAY => true); /** * The page that we're displaying backlinks to. diff --git a/wicked/lib/Page/DeletePage.php b/wicked/lib/Page/DeletePage.php index 95bd31e37..53617ce11 100644 --- a/wicked/lib/Page/DeletePage.php +++ b/wicked/lib/Page/DeletePage.php @@ -26,7 +26,7 @@ class DeletePage extends Wicked_Page { * * @var array */ - var $supportedModes = array(WICKED_MODE_DISPLAY => true); + var $supportedModes = array(Wicked::MODE_DISPLAY => true); /** * The page that we're confirming deletion for. @@ -57,7 +57,7 @@ class DeletePage extends Wicked_Page { function preDisplay() { $page = Wicked_Page::getPage($this->referrer()); - if (!$page->allows(WICKED_MODE_REMOVE)) { + if (!$page->allows(Wicked::MODE_REMOVE)) { Wicked::url($this->referrer(), true)->redirect(); } } @@ -125,7 +125,7 @@ class DeletePage extends Wicked_Page { { $pagename = $this->referrer(); $page = Wicked_Page::getPage($pagename); - if ($page->allows(WICKED_MODE_REMOVE)) { + if ($page->allows(Wicked::MODE_REMOVE)) { $version = Horde_Util::getFormData('version'); if (empty($version)) { $GLOBALS['wicked']->removeAllVersions($pagename); diff --git a/wicked/lib/Page/EditPage.php b/wicked/lib/Page/EditPage.php index a6d667261..a2935ef54 100644 --- a/wicked/lib/Page/EditPage.php +++ b/wicked/lib/Page/EditPage.php @@ -27,8 +27,8 @@ class EditPage extends Wicked_Page { * @var array */ var $supportedModes = array( - WICKED_MODE_DISPLAY => true, - WICKED_MODE_EDIT => true); + Wicked::MODE_DISPLAY => true, + Wicked::MODE_EDIT => true); /** * The page that we're editing. @@ -41,7 +41,7 @@ class EditPage extends Wicked_Page { { $this->_referrer = $referrer; if ($GLOBALS['conf']['lock']['driver'] != 'none') { - $this->supportedModes[WICKED_MODE_LOCKING] = $this->supportedModes[WICKED_MODE_UNLOCKING] = true; + $this->supportedModes[Wicked::MODE_LOCKING] = $this->supportedModes[Wicked::MODE_UNLOCKING] = true; } } @@ -57,7 +57,7 @@ class EditPage extends Wicked_Page { */ function allows($mode) { - if ($mode == WICKED_MODE_EDIT) { + if ($mode == Wicked::MODE_EDIT) { $page = Wicked_Page::getPage($this->referrer()); if ($page->isLocked(Wicked::lockUser())) { return false; @@ -82,10 +82,10 @@ class EditPage extends Wicked_Page { */ function preDisplay() { - if (!$this->allows(WICKED_MODE_EDIT)) { + if (!$this->allows(Wicked::MODE_EDIT)) { Wicked::url($this->referrer(), true)->redirect(); } - if ($this->allows(WICKED_MODE_LOCKING)) { + if ($this->allows(Wicked::MODE_LOCKING)) { $page = Wicked_Page::getPage($this->referrer()); if ($page->isLocked()) { $page->unlock(); @@ -152,7 +152,7 @@ class EditPage extends Wicked_Page { global $notification, $conf; $page = Wicked_Page::getPage($this->referrer()); - if (!$this->allows(WICKED_MODE_EDIT)) { + if (!$this->allows(Wicked::MODE_EDIT)) { $notification->push(sprintf(_("You don't have permission to edit \"%s\"."), $page->pageName())); } else { if (!empty($GLOBALS['conf']['wicked']['captcha']) && @@ -183,7 +183,7 @@ class EditPage extends Wicked_Page { } } - if ($page->allows(WICKED_MODE_UNLOCKING)) { + if ($page->allows(Wicked::MODE_UNLOCKING)) { $result = $page->unlock(); if (is_a($result, 'PEAR_Error')) { $GLOBALS['notification']->push(sprintf(_("Page failed to unlock: %s"), $result->getMessage()), 'horde.error'); diff --git a/wicked/lib/Page/LeastPopular.php b/wicked/lib/Page/LeastPopular.php index 1c793ae0b..e402e7ae4 100644 --- a/wicked/lib/Page/LeastPopular.php +++ b/wicked/lib/Page/LeastPopular.php @@ -21,8 +21,8 @@ class LeastPopular extends Wicked_Page { * @var array */ var $supportedModes = array( - WICKED_MODE_CONTENT => true, - WICKED_MODE_DISPLAY => true); + Wicked::MODE_CONTENT => true, + Wicked::MODE_DISPLAY => true); /** * Render this page in Content mode. diff --git a/wicked/lib/Page/LikePages.php b/wicked/lib/Page/LikePages.php index c2f2a7a55..3743c7b9c 100644 --- a/wicked/lib/Page/LikePages.php +++ b/wicked/lib/Page/LikePages.php @@ -21,7 +21,7 @@ class LikePages extends Wicked_Page { * @var array */ var $supportedModes = array( - WICKED_MODE_DISPLAY => true); + Wicked::MODE_DISPLAY => true); /** * The page that we're displaying similar pages to. diff --git a/wicked/lib/Page/MergeOrRename.php b/wicked/lib/Page/MergeOrRename.php index 3d2e851f4..0d9e508c5 100644 --- a/wicked/lib/Page/MergeOrRename.php +++ b/wicked/lib/Page/MergeOrRename.php @@ -21,8 +21,8 @@ class MergeOrRename extends Wicked_Page { * @var array */ var $supportedModes = array( - WICKED_MODE_EDIT => true, - WICKED_MODE_DISPLAY => true); + Wicked::MODE_EDIT => true, + Wicked::MODE_DISPLAY => true); /** * The page that we're displaying similar pages to. @@ -55,8 +55,8 @@ class MergeOrRename extends Wicked_Page { */ function allows($mode) { - if ($mode == WICKED_MODE_EDIT) { - if (!parent::allows(WICKED_MODE_REMOVE)) { + if ($mode == Wicked::MODE_EDIT) { + if (!parent::allows(Wicked::MODE_REMOVE)) { return false; } $page = Wicked_Page::getPage($this->referrer()); @@ -184,7 +184,7 @@ class MergeOrRename extends Wicked_Page { $referrer, $sourcePage->getMessage()), 'horde.error'); return; - } elseif (!$this->allows(WICKED_MODE_EDIT)) { + } elseif (!$this->allows(Wicked::MODE_EDIT)) { $notification->push(sprintf(_("You do not have permission to edit \"%s\""), $referrer), 'horde.error'); return; @@ -199,7 +199,7 @@ class MergeOrRename extends Wicked_Page { $new_name), 'horde.error'); return; } - if (!$destPage->allows(WICKED_MODE_EDIT)) { + if (!$destPage->allows(Wicked::MODE_EDIT)) { $notification->push(sprintf(_("You do not have permission to edit \"%s\""), $new_name), 'horde.error'); return; @@ -246,7 +246,7 @@ class MergeOrRename extends Wicked_Page { 'Subject' => '[' . $registry->get('name') . '] renamed: ' . $referrer . ', ' . $new_name)); } - $wikiWord = '/^' . WICKED_REGEXP_WIKIWORD . '$/'; + $wikiWord = '/^' . Wicked::REGEXP_WIKIWORD . '$/'; // We don't check permissions on these pages since we want references // to be fixed even if the user doing the editing couldn't fix that diff --git a/wicked/lib/Page/MostPopular.php b/wicked/lib/Page/MostPopular.php index 7ae4eab72..b4d70a082 100644 --- a/wicked/lib/Page/MostPopular.php +++ b/wicked/lib/Page/MostPopular.php @@ -21,8 +21,8 @@ class MostPopular extends Wicked_Page { * @var array */ var $supportedModes = array( - WICKED_MODE_CONTENT => true, - WICKED_MODE_DISPLAY => true); + Wicked::MODE_CONTENT => true, + Wicked::MODE_DISPLAY => true); /** * Render this page in Content mode. diff --git a/wicked/lib/Page/NewPage.php b/wicked/lib/Page/NewPage.php index 6fee5ac48..1016f9c05 100644 --- a/wicked/lib/Page/NewPage.php +++ b/wicked/lib/Page/NewPage.php @@ -27,8 +27,8 @@ class NewPage extends Wicked_Page { * @var array */ var $supportedModes = array( - WICKED_MODE_DISPLAY => true, - WICKED_MODE_EDIT => true); + Wicked::MODE_DISPLAY => true, + Wicked::MODE_EDIT => true); /** * The page that we're creating. @@ -71,7 +71,7 @@ class NewPage extends Wicked_Page { Wicked::url('', true)->redirect(); } - if (!$this->allows(WICKED_MODE_EDIT)) { + if (!$this->allows(Wicked::MODE_EDIT)) { Wicked::url($this->referrer(), true)->redirect(); } } @@ -118,7 +118,7 @@ class NewPage extends Wicked_Page { { global $notification, $wicked; - if (!$this->allows(WICKED_MODE_EDIT)) { + if (!$this->allows(Wicked::MODE_EDIT)) { $notification->push(sprintf(_("You don't have permission to create \"%s\"."), $this->referrer())); } else { $text = Horde_Util::getPost('page_text'); diff --git a/wicked/lib/Page/RecentChanges.php b/wicked/lib/Page/RecentChanges.php index 885e4804f..c9cb9c723 100644 --- a/wicked/lib/Page/RecentChanges.php +++ b/wicked/lib/Page/RecentChanges.php @@ -21,8 +21,8 @@ class RecentChanges extends Wicked_Page { * @var array */ var $supportedModes = array( - WICKED_MODE_CONTENT => true, - WICKED_MODE_DISPLAY => true); + Wicked::MODE_CONTENT => true, + Wicked::MODE_DISPLAY => true); /** * Render this page in Content mode. diff --git a/wicked/lib/Page/RevertPage.php b/wicked/lib/Page/RevertPage.php index 240fd8bf5..8242950a4 100644 --- a/wicked/lib/Page/RevertPage.php +++ b/wicked/lib/Page/RevertPage.php @@ -20,7 +20,7 @@ class RevertPage extends Wicked_Page { * * @var array */ - var $supportedModes = array(WICKED_MODE_DISPLAY => true); + var $supportedModes = array(Wicked::MODE_DISPLAY => true); /** * The page that we're confirming reversion for. @@ -51,7 +51,7 @@ class RevertPage extends Wicked_Page { function preDisplay() { $page = Wicked_Page::getPage($this->referrer()); - if (!$page->allows(WICKED_MODE_EDIT)) { + if (!$page->allows(Wicked::MODE_EDIT)) { Wicked::url($this->referrer(), true)->redirect(); } } @@ -111,7 +111,7 @@ class RevertPage extends Wicked_Page { global $notification; $page = Wicked_Page::getPage($this->referrer()); - if ($page->allows(WICKED_MODE_EDIT)) { + if ($page->allows(Wicked::MODE_EDIT)) { $version = Horde_Util::getPost('version'); if (empty($version)) { $notification->push(sprintf(_("Can't revert to an unknown version.")), 'horde.error'); diff --git a/wicked/lib/Page/Search.php b/wicked/lib/Page/Search.php index 934cf5657..44c125aa3 100644 --- a/wicked/lib/Page/Search.php +++ b/wicked/lib/Page/Search.php @@ -21,8 +21,8 @@ class Search extends Wicked_Page { * @var array */ var $supportedModes = array( - WICKED_MODE_CONTENT => true, - WICKED_MODE_DISPLAY => true); + Wicked::MODE_CONTENT => true, + Wicked::MODE_DISPLAY => true); /** * Cached search results. diff --git a/wicked/lib/Page/StandardPage.php b/wicked/lib/Page/StandardPage.php index e48e34d6d..abb6978ec 100644 --- a/wicked/lib/Page/StandardPage.php +++ b/wicked/lib/Page/StandardPage.php @@ -18,11 +18,11 @@ class StandardPage extends Wicked_Page { * @var array */ var $supportedModes = array( - WICKED_MODE_DISPLAY => true, - WICKED_MODE_EDIT => true, - WICKED_MODE_REMOVE => true, - WICKED_MODE_HISTORY => true, - WICKED_MODE_DIFF => true); + Wicked::MODE_DISPLAY => true, + Wicked::MODE_EDIT => true, + Wicked::MODE_REMOVE => true, + Wicked::MODE_HISTORY => true, + Wicked::MODE_DIFF => true); /** * A Horde_Locks instance for un-/locking this page. @@ -106,7 +106,7 @@ class StandardPage extends Wicked_Page { } if ($GLOBALS['conf']['lock']['driver'] != 'none') { - $this->supportedModes[WICKED_MODE_LOCKING] = $this->supportedModes[WICKED_MODE_UNLOCKING] = true; + $this->supportedModes[Wicked::MODE_LOCKING] = $this->supportedModes[Wicked::MODE_UNLOCKING] = true; $this->_locks = $GLOBALS['injector']->getInstance('Horde_Lock'); $locks = $this->_locks->getLocks('wicked', $pagename, Horde_Lock::TYPE_EXCLUSIVE); if ($locks) { @@ -128,13 +128,13 @@ class StandardPage extends Wicked_Page { function allows($mode) { switch ($mode) { - case WICKED_MODE_EDIT: + case Wicked::MODE_EDIT: if ($this->isLocked()) { return Wicked::lockUser() == $this->_lock['lock_owner']; } break; - case WICKED_MODE_LOCKING: + case Wicked::MODE_LOCKING: if ($GLOBALS['browser']->isRobot()) { return false; } @@ -146,7 +146,7 @@ class StandardPage extends Wicked_Page { } break; - case WICKED_MODE_UNLOCKING: + case Wicked::MODE_UNLOCKING: if ($GLOBALS['registry']->isAdmin()) { return true; } diff --git a/wicked/lib/Page/StandardPage/StdHistoryPage.php b/wicked/lib/Page/StandardPage/StdHistoryPage.php index 63a8ea0aa..4c77346cb 100644 --- a/wicked/lib/Page/StandardPage/StdHistoryPage.php +++ b/wicked/lib/Page/StandardPage/StdHistoryPage.php @@ -13,13 +13,13 @@ class StdHistoryPage extends StandardPage { * @var array */ var $supportedModes = array( - WICKED_MODE_DISPLAY => true, - WICKED_MODE_EDIT => false, - WICKED_MODE_REMOVE => true, - WICKED_MODE_HISTORY => true, - WICKED_MODE_DIFF => true, - WICKED_MODE_LOCKING => false, - WICKED_MODE_UNLOCKING => false); + Wicked::MODE_DISPLAY => true, + Wicked::MODE_EDIT => false, + Wicked::MODE_REMOVE => true, + Wicked::MODE_HISTORY => true, + Wicked::MODE_DIFF => true, + Wicked::MODE_LOCKING => false, + Wicked::MODE_UNLOCKING => false); /** * Construct a standard history page class to represent an old diff --git a/wicked/lib/Page/SyncDiff.php b/wicked/lib/Page/SyncDiff.php index 2984e2f61..0b7a2dda5 100644 --- a/wicked/lib/Page/SyncDiff.php +++ b/wicked/lib/Page/SyncDiff.php @@ -19,8 +19,8 @@ class SyncDiff extends SyncPages { * Display modes supported by this page. */ var $supportedModes = array( - WICKED_MODE_CONTENT => true, - WICKED_MODE_DISPLAY => true); + Wicked::MODE_CONTENT => true, + Wicked::MODE_DISPLAY => true); /** * Sync driver diff --git a/wicked/lib/Page/SyncPages.php b/wicked/lib/Page/SyncPages.php index 8ea4b0769..51a2f4500 100644 --- a/wicked/lib/Page/SyncPages.php +++ b/wicked/lib/Page/SyncPages.php @@ -20,7 +20,7 @@ class SyncPages extends Wicked_Page { * Display modes supported by this page. */ var $supportedModes = array( - WICKED_MODE_CONTENT => true); + Wicked::MODE_CONTENT => true); /** * Sync driver @@ -364,7 +364,7 @@ class SyncPages extends Wicked_Page { return $page; } - if (!$page->allows(WICKED_MODE_EDIT)) { + if (!$page->allows(Wicked::MODE_EDIT)) { return PEAR::RaiseError(sprintf(_("You don't have permission to edit \"%s\"."), $pageName)); } diff --git a/wicked/lib/Text_Wiki/Parse/Default/Attribute.php b/wicked/lib/Text_Wiki/Parse/Default/Attribute.php index 965572523..cff5d5f0f 100644 --- a/wicked/lib/Text_Wiki/Parse/Default/Attribute.php +++ b/wicked/lib/Text_Wiki/Parse/Default/Attribute.php @@ -19,7 +19,7 @@ class Text_Wiki_Parse_Attribute extends Text_Wiki_Parse { { parent::Text_Wiki_Parse($obj); - $this->regex = '/((?:\[\[' . WICKED_REGEXP_WIKIWORD . + $this->regex = '/((?:\[\[' . Wicked::REGEXP_WIKIWORD . ':\s+.*?\]\]\s*)+)/'; } diff --git a/wicked/lib/Text_Wiki/Render/Xhtml/Attribute.php b/wicked/lib/Text_Wiki/Render/Xhtml/Attribute.php index bd62c00ea..dae5d5d54 100644 --- a/wicked/lib/Text_Wiki/Render/Xhtml/Attribute.php +++ b/wicked/lib/Text_Wiki/Render/Xhtml/Attribute.php @@ -24,7 +24,7 @@ class Text_Wiki_Render_Xhtml_Attribute extends Text_Wiki_Render { // We should do full wiki formatting, I guess, but there isn't // a convenient way to do it. - if (preg_match('/^(' . WICKED_REGEXP_WIKIWORD . ')$/', + if (preg_match('/^(' . Wicked::REGEXP_WIKIWORD . ')$/', $attribute['value'], $matches)) { $vlink = array('page' => $matches[1], 'anchor' => '', diff --git a/wicked/lib/Wicked.php b/wicked/lib/Wicked.php index c6a81a1c8..31114702e 100644 --- a/wicked/lib/Wicked.php +++ b/wicked/lib/Wicked.php @@ -1,37 +1,48 @@ + * @package Wicked + */ +class Wicked +{ + /** Display mode. */ + const MODE_DISPLAY = 0; -/** The edit screen. */ -define('WICKED_MODE_EDIT', 1); + /** The edit screen. */ + const MODE_EDIT = 1; -/** Page can be removed. */ -define('WICKED_MODE_REMOVE', 2); + /** Page can be removed. */ + const MODE_REMOVE = 2; -/** Display the page history. */ -define('WICKED_MODE_HISTORY', 3); + /** Display the page history. */ + const MODE_HISTORY = 3; -/** Diff two versions of the page. */ -define('WICKED_MODE_DIFF', 4); + /** Diff two versions of the page. */ + const MODE_DIFF = 4; -/** Page can be locked. */ -define('WICKED_MODE_LOCKING', 7); + /** Page can be locked. */ + const MODE_LOCKING = 7; -/** Page can be unlocked. */ -define('WICKED_MODE_UNLOCKING', 8); + /** Page can be unlocked. */ + const MODE_UNLOCKING = 8; -/** The ability to add a page. */ -define('WICKED_MODE_CREATE', 9); + /** The ability to add a page. */ + const MODE_CREATE = 9; -/** Raw content mode. */ -define('WICKED_MODE_CONTENT', 10); + /** Raw content mode. */ + const MODE_CONTENT = 10; -/** Like display, but for a block. */ -define('WICKED_MODE_BLOCK', 11); + /** Like display, but for a block. */ + const MODE_BLOCK = 11; -/** Our wiki word regexp (needed many places). */ -define('WICKED_REGEXP_WIKIWORD', + /** Our wiki word regexp (needed many places). "(!?" . // START WikiPage pattern (1) "[A-Z\xc0-\xde]" . // 1 upper "[A-Za-z0-9\xc0-\xfe]*" . // 0+ alpha or digit @@ -46,22 +57,11 @@ define('WICKED_REGEXP_WIKIWORD', // colon, dot "[-_A-Za-z0-9\xc0-\xfe]" . // 1 dash, alpha, digit, or underscore ")?)?)"); // end subpatterns (/4)(/3)(/2) + */ + const REGEXP_WIKIWORD = "(!?[A-Z\xc0-\xde][A-Za-z0-9\xc0-\xfe]*[a-z0-9\xdf-\xfe]+[A-Z\xc0-\xde][A-Za-z0-9\xc0-\xfe]*)((\#[A-Za-z0-9\xc0-\xfe]([-_A-Za-z0-9\xc0-\xfe:.]*[-_A-Za-z0-9\xc0-\xfe])?)?)"; -/** Where we store our attachments in VFS. */ -define('WICKED_VFS_ATTACH_PATH', '.horde/wicked/attachments'); - -/** - * Wicked Base Class. - * - * 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. - * - * @author Tyler Colbert - * @package Wicked - */ -class Wicked { + /** Where we store our attachments in VFS. */ + const WICKED_VFS_ATTACH_PATH = '.horde/wicked/attachments'; /** * Puts together the URL to a Wicked page. Uses mod_rewrite or GET @@ -73,7 +73,7 @@ class Wicked { * * @return string The URL of $page. */ - function url($page, $full = false, $append_session = 0) + public static function url($page, $full = false, $append_session = 0) { global $conf; @@ -89,7 +89,7 @@ class Wicked { /** * Build Wicked's list of menu items. */ - function getMenu($returnType = 'object') + public static function getMenu($returnType = 'object') { global $conf, $page; @@ -134,7 +134,7 @@ class Wicked { * @param string $message The message text to send out. * @param array $headers Additional headers to add to the email. */ - function mail($message, $headers = array()) + public static function mail($message, $headers = array()) { global $conf, $registry; @@ -201,7 +201,7 @@ class Wicked { * * @return string A CAPTCHA string. */ - function getCAPTCHA($new = false) + public static function getCAPTCHA($new = false) { if ($new || empty($_SESSION['wickedSession']['CAPTCHA'])) { $_SESSION['wickedSession']['CAPTCHA'] = ''; @@ -218,7 +218,7 @@ class Wicked { * * @return string The user name used for locking. */ - function lockUser() + public static function lockUser() { return $GLOBALS['registry']->getAuth() ? $GLOBALS['registry']->getAuth() : $GLOBALS['browser']->getIPAddress(); } diff --git a/wicked/templates/display/standard.inc b/wicked/templates/display/standard.inc index 5ce86329a..73adf1e8c 100644 --- a/wicked/templates/display/standard.inc +++ b/wicked/templates/display/standard.inc @@ -17,7 +17,7 @@ if (!function_exists('separator')) { separator(true); -if ($this->allows(WICKED_MODE_EDIT) && !$this->isLocked(Wicked::lockUser())) { +if ($this->allows(Wicked::MODE_EDIT) && !$this->isLocked(Wicked::lockUser())) { separator(); $url = Horde_Util::addParameter(Wicked::url('EditPage'), 'referrer', $this->pageName()); @@ -26,7 +26,7 @@ if ($this->allows(WICKED_MODE_EDIT) && !$this->isLocked(Wicked::lockUser())) { } if ($this->isLocked()) { - if ($this->allows(WICKED_MODE_UNLOCKING)) { + if ($this->allows(Wicked::MODE_UNLOCKING)) { separator(); echo Horde::widget(Horde_Util::removeParameter( $this->pageUrl(null, 'unlock'), @@ -35,7 +35,7 @@ if ($this->isLocked()) { 'widget', '', '', _("Un_lock")); } } else { - if ($this->allows(WICKED_MODE_LOCKING)) { + if ($this->allows(Wicked::MODE_LOCKING)) { separator(); echo Horde::widget(Horde_Util::removeParameter( $this->pageUrl(null, 'lock'), @@ -45,7 +45,7 @@ if ($this->isLocked()) { } } -if ($this->allows(WICKED_MODE_REMOVE)) { +if ($this->allows(Wicked::MODE_REMOVE)) { separator(); $params = array('referrer' => $this->pageName()); if ($this->isOld()) { @@ -56,7 +56,7 @@ if ($this->allows(WICKED_MODE_REMOVE)) { 'widget', '', '', _("_Delete")); } -if ($this->allows(WICKED_MODE_REMOVE) && !$this->isLocked(Wicked::lockUser())) { +if ($this->allows(Wicked::MODE_REMOVE) && !$this->isLocked(Wicked::lockUser())) { separator(); $url = Horde_Util::addParameter(Wicked::url('MergeOrRename'), 'referrer', $this->pageName()); @@ -80,7 +80,7 @@ $url = Horde_Util::addParameter(Wicked::url('AttachedFiles'), echo Horde::widget($url, _("Attachments"), 'widget', '', '', _("Attachments")); -if ($this->allows(WICKED_MODE_HISTORY)) { +if ($this->allows(Wicked::MODE_HISTORY)) { separator(); echo Horde::widget(Horde_Util::removeParameter($this->pageUrl('history.php'), 'version'), diff --git a/wicked/templates/display/title.inc b/wicked/templates/display/title.inc index 845025195..2352967e2 100644 --- a/wicked/templates/display/title.inc +++ b/wicked/templates/display/title.inc @@ -7,7 +7,7 @@ if (!is_a($v, 'PEAR_Error')) { } $v = $this->version(); -if (!is_a($v, 'PEAR_Error') && $this->allows(WICKED_MODE_DIFF)) { +if (!is_a($v, 'PEAR_Error') && $this->allows(Wicked::MODE_DIFF)) { $diff_url = Horde_Util::addParameter(Horde::url('diff.php'), array('page' => $this->pageName(), 'v1' => '?', diff --git a/wicked/templates/history/header.inc b/wicked/templates/history/header.inc index feb75e64d..e2b9e16a8 100644 --- a/wicked/templates/history/header.inc +++ b/wicked/templates/history/header.inc @@ -12,9 +12,9 @@ -allows(WICKED_MODE_REMOVE)): ?> +allows(Wicked::MODE_REMOVE)): ?> -allows(WICKED_MODE_EDIT)): ?> +allows(Wicked::MODE_EDIT)): ?> diff --git a/wicked/templates/history/summary.inc b/wicked/templates/history/summary.inc index 4278964c5..8d7efe963 100644 --- a/wicked/templates/history/summary.inc +++ b/wicked/templates/history/summary.inc @@ -1,6 +1,6 @@ pageUrl(), sprintf(_("Display Version %s"), $page->version())) . htmlspecialchars($page->version()) ?> -allows(WICKED_MODE_REMOVE)): ?> +allows(Wicked::MODE_REMOVE)): ?> version()); @@ -9,7 +9,7 @@ $url = Horde_Util::addParameter(Wicked::url('DeletePage'), array('referrer' => $ echo Horde::link($url, $text) . Horde::img('delete.png', $text) . ''; ?> -allows(WICKED_MODE_EDIT)): ?> +allows(Wicked::MODE_EDIT)): ?>