Fixed bug #15644: Replace magic numbers for shortcut_mode with class constants
authorSteffen Gebert <steffen.gebert@typo3.org>
Wed, 13 Oct 2010 09:03:31 +0000 (09:03 +0000)
committerSteffen Gebert <steffen.gebert@typo3.org>
Wed, 13 Oct 2010 09:03:31 +0000 (09:03 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@9053 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_befunc.php
t3lib/class.t3lib_page.php

index c6d3ce5..b838439 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2010-10-13  Steffen Gebert  <steffen@steffen-gebert.de>
+
+       * Fixed bug #15644: Replace magic numbers for shortcut_mode with class constants
+
 2010-10-12  Susanne Moog  <typo3@susanne-moog.de>
 
        * Fixed bug #15168: Template auto complete is hidden beneath next text area field
index 25e794f..41a16c0 100644 (file)
@@ -1884,7 +1884,7 @@ final class t3lib_BEfunc {
                                $lRec = self::getRecordWSOL('pages', intval($row['shortcut']), 'title');
                                $label = $lRec['title'];
                        }
-                       if ($row['shortcut_mode']>0) {
+                       if ($row['shortcut_mode'] != t3lib_pageSelect::SHORTCUT_MODE_NONE) {
                                $label.=', '.$LANG->sL($TCA['pages']['columns']['shortcut_mode']['label']).' '.
                                                        $LANG->sL(self::getLabelFromItemlist('pages', 'shortcut_mode', $row['shortcut_mode']));
                        }
index ca834c1..a0555b5 100644 (file)
@@ -130,6 +130,14 @@ class t3lib_pageSelect {
        protected $cache_getMountPointInfo = array();
 
        /**
+        * Named constants for "magic numbers" of the field shortcut_mode
+        */
+       const SHORTCUT_MODE_NONE = 0;
+       const SHORTCUT_MODE_FIRST_SUBPAGE = 1;
+       const SHORTCUT_MODE_RANDOM_SUBPAGE = 2;
+       const SHORTCUT_MODE_PARENT_PAGE = 3;
+
+       /**
         * init() MUST be run directly after creating a new template-object
         * This sets the internal variable $this->where_hid_del to the correct where clause for page records taking deleted/hidden/starttime/endtime/t3ver_state into account
         *
@@ -516,16 +524,16 @@ class t3lib_pageSelect {
 
                                        // if shortcut, look up if the target exists and is currently visible
                                if ($row['doktype'] == 4 && ($row['shortcut'] || $row['shortcut_mode']) && $checkShortcuts)     {
-                                       if ($row['shortcut_mode'] == 0) {
+                                       if ($row['shortcut_mode'] == self::SHORTCUT_MODE_NONE) {
                                                        // no shortcut_mode set, so target is directly set in $row['shortcut']
                                                $searchField = 'uid';
                                                $searchUid = intval($row['shortcut']);
-                                       } elseif ($row['shortcut_mode'] == 1 || $row['shortcut_mode'] == 2) {
+                                       } elseif ($row['shortcut_mode'] == self::SHORTCUT_MODE_FIRST_SUBPAGE || $row['shortcut_mode'] == self::SHORTCUT_MODE_RANDOM_SUBPAGE) {
                                                        // check subpages - first subpage or random subpage
                                                $searchField = 'pid';
                                                        // If a shortcut mode is set and no valid page is given to select subpags from use the actual page.
                                                $searchUid = intval($row['shortcut'])?intval($row['shortcut']):$row['uid'];
-                                       } elseif ($row['shortcut_mode'] == 3) {
+                                       } elseif ($row['shortcut_mode'] == self::SHORTCUT_MODE_PARENT_PAGE) {
                                                        // shortcut to parent page
                                                $searchField = 'uid';
                                                $searchUid = $row['pid'];