Class constants
authorMichael J. Rubinsky <mrubinsk@horde.org>
Sat, 2 Oct 2010 19:59:30 +0000 (15:59 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Sat, 2 Oct 2010 20:02:10 +0000 (16:02 -0400)
32 files changed:
wicked/diff.php
wicked/display.php
wicked/history.php
wicked/lib/Api.php
wicked/lib/Block/page.php
wicked/lib/Driver/sql.php
wicked/lib/Page.php
wicked/lib/Page/AddPage.php
wicked/lib/Page/AllPages.php
wicked/lib/Page/AttachedFiles.php
wicked/lib/Page/BackLinks.php
wicked/lib/Page/DeletePage.php
wicked/lib/Page/EditPage.php
wicked/lib/Page/LeastPopular.php
wicked/lib/Page/LikePages.php
wicked/lib/Page/MergeOrRename.php
wicked/lib/Page/MostPopular.php
wicked/lib/Page/NewPage.php
wicked/lib/Page/RecentChanges.php
wicked/lib/Page/RevertPage.php
wicked/lib/Page/Search.php
wicked/lib/Page/StandardPage.php
wicked/lib/Page/StandardPage/StdHistoryPage.php
wicked/lib/Page/SyncDiff.php
wicked/lib/Page/SyncPages.php
wicked/lib/Text_Wiki/Parse/Default/Attribute.php
wicked/lib/Text_Wiki/Render/Xhtml/Attribute.php
wicked/lib/Wicked.php
wicked/templates/display/standard.inc
wicked/templates/display/title.inc
wicked/templates/history/header.inc
wicked/templates/history/summary.inc

index 3144b6a..7bb87fb 100644 (file)
@@ -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';
index 0ae43e3..d4e0de7 100644 (file)
@@ -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') &&
index bc99520..7e232f1 100644 (file)
@@ -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';
index 9a70cbc..9c16c6e 100644 (file)
@@ -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."));
         }
 
index c1f4fbd..5821488 100644 (file)
@@ -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()
index 652e932..e9e80f0 100644 (file)
@@ -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/';
         }
 
index 580e379..4a15e74 100644 (file)
@@ -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:
index ad1d182..a03ac69 100644 (file)
@@ -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.
index bed4cf6..000da21 100644 (file)
@@ -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.
index 0776daf..2904603 100644 (file)
@@ -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()),
index fd8a73a..f8504eb 100644 (file)
@@ -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.
index 95bd31e..53617ce 100644 (file)
@@ -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);
index a6d6672..a2935ef 100644 (file)
@@ -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');
index 1c793ae..e402e7a 100644 (file)
@@ -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.
index c2f2a7a..3743c7b 100644 (file)
@@ -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.
index 3d2e851..0d9e508 100644 (file)
@@ -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
index 7ae4eab..b4d70a0 100644 (file)
@@ -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.
index 6fee5ac..1016f9c 100644 (file)
@@ -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');
index 885e480..c9cb9c7 100644 (file)
@@ -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.
index 240fd8b..8242950 100644 (file)
@@ -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');
index 934cf56..44c125a 100644 (file)
@@ -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.
index e48e34d..abb6978 100644 (file)
@@ -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;
             }
index 63a8ea0..4c77346 100644 (file)
@@ -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
index 2984e2f..0b7a2dd 100644 (file)
@@ -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
index 8ea4b07..51a2f45 100644 (file)
@@ -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));
         }
 
index 9655725..cff5d5f 100644 (file)
@@ -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*)+)/';
     }
 
index bd62c00..dae5d5d 100644 (file)
@@ -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' => '',
index c6a81a1..3111470 100644 (file)
@@ -1,37 +1,48 @@
 <?php
-// Modes we might be displaying a page in.
-/** Display mode. */
-define('WICKED_MODE_DISPLAY', 0);
+/**
+ * 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 <tyler@colberts.us>
+ * @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 <tyler@colberts.us>
- * @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();
     }
index 5ce8632..73adf1e 100644 (file)
@@ -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'),
index 8450251..2352967 100644 (file)
@@ -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' => '?',
index feb75e6..e2b9e16 100644 (file)
@@ -12,9 +12,9 @@
  <tr class="item">
   <th align="left" width="1%"><?php echo _("Version") ?></th>
 
-<?php if ($this->allows(WICKED_MODE_REMOVE)): ?>
+<?php if ($this->allows(Wicked::MODE_REMOVE)): ?>
   <th align="center" class="nowrap" style="width:1%"><?php echo Horde::img('delete.png', _("Delete Version")) ?></th>
-<?php endif; if ($this->allows(WICKED_MODE_EDIT)): ?>
+<?php endif; if ($this->allows(Wicked::MODE_EDIT)): ?>
   <th align="center" class="nowrap" style="width:1%"><?php echo Horde::img('edit.png', _("Edit Version")) ?></th>
 
   <th align="center" class="nowrap" style="width:1%"><?php echo Horde::img('restore.png', _("Restore Version")) ?></th>
index 4278964..8d7efe9 100644 (file)
@@ -1,6 +1,6 @@
 <tr>
  <td><?php echo Horde::link($page->pageUrl(), sprintf(_("Display Version %s"), $page->version())) . htmlspecialchars($page->version()) ?></a></td>
-<?php if ($this->allows(WICKED_MODE_REMOVE)): ?>
+<?php if ($this->allows(Wicked::MODE_REMOVE)): ?>
  <td style="text-align:center">
 <?php
 $text = sprintf(_("Delete Version %s"), $page->version());
@@ -9,7 +9,7 @@ $url = Horde_Util::addParameter(Wicked::url('DeletePage'), array('referrer' => $
 echo Horde::link($url, $text) . Horde::img('delete.png', $text) . '</a>';
 ?>
  </td>
-<?php endif; if ($this->allows(WICKED_MODE_EDIT)): ?>
+<?php endif; if ($this->allows(Wicked::MODE_EDIT)): ?>
  <td style="text-align:center">
 <?php
 if ($show_edit) {