Added feature #15696: Implement TypoScript conditions for the current page record...
authorSteffen Gebert <steffen.gebert@typo3.org>
Sat, 16 Oct 2010 18:58:13 +0000 (18:58 +0000)
committerSteffen Gebert <steffen.gebert@typo3.org>
Sat, 16 Oct 2010 18:58:13 +0000 (18:58 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@9107 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/matchcondition/class.t3lib_matchcondition_abstract.php
t3lib/matchcondition/class.t3lib_matchcondition_backend.php
t3lib/matchcondition/class.t3lib_matchcondition_frontend.php

index d67b8c0..5691855 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2010-10-16  Steffen Gebert  <steffen@steffen-gebert.de>
+
+       * Added feature #15696: Implement TypoScript conditions for the current page record (Thanks to Stefan Neufeind)
+
 2010-10-16  Susanne Moog  <typo3@susanne-moog.de>
 
        * Fixed bug #15868: Provide function to open debug messages in a popup (Thanks to Stefan Galinski)
index 3610999..8bacaa8 100644 (file)
@@ -210,8 +210,9 @@ abstract class t3lib_matchCondition_abstract {
                if (t3lib_div::inList('browser,version,system,useragent', strtolower($key))) {
                        $browserInfo = $this->getBrowserInfo(t3lib_div::getIndpEnv('HTTP_USER_AGENT'));
                }
+               $keyParts = t3lib_div::trimExplode('|', $key);
 
-               switch ($key) {
+               switch ($keyParts[0]) {
                        case 'browser':
                                $values = t3lib_div::trimExplode(',', $value, true);
                                        // take all identified browsers into account, eg chrome deliver
@@ -351,6 +352,17 @@ abstract class t3lib_matchCondition_abstract {
                                        }
                                }
                        break;
+                       case 'page':
+                               if ($keyParts[1]) {
+                                       $page = $this->getPage();
+                                       $property = $keyParts[1];
+                                       if (!empty($page) && isset($page[$property])) {
+                                               if (strcmp($page[$property], $value) === 0) {
+                                                       return TRUE;
+                                               }
+                                       }
+                               }
+                       break;
                        case 'globalVar':
                                $values = t3lib_div::trimExplode(',', $value, true);
                                foreach ($values as $test) {
@@ -596,6 +608,13 @@ abstract class t3lib_matchCondition_abstract {
         */
        abstract protected function determinePageId();
 
+       /**
+        * Gets the properties for the current page.
+        *
+        * @return      array           The properties for the current page.
+        */
+       abstract protected function getPage();
+
        /**
         * Determines the rootline for the current page.
         *
index e6e8f52..fcbc68d 100644 (file)
@@ -175,6 +175,16 @@ class t3lib_matchCondition_backend extends t3lib_matchCondition_abstract {
                return $pageId;
        }
 
+       /**
+        * Gets the properties for the current page.
+        *
+        * @return      array           The properties for the current page.
+        */
+       protected function getPage() {
+               $pageId = (isset($this->pageId) ? $this->pageId : $this->determinePageId());
+               return t3lib_BEfunc::getRecord('pages', $pageId);
+       }
+
        /**
         * Gets the page id by a record.
         *
index f6e27ba..cd6dbdf 100644 (file)
@@ -221,6 +221,15 @@ class t3lib_matchCondition_frontend extends t3lib_matchCondition_abstract {
                return (int)$GLOBALS['TSFE']->id;
        }
 
+       /**
+        * Gets the properties for the current page.
+        *
+        * @return      array           The properties for the current page.
+        */
+       protected function getPage() {
+               return $GLOBALS['TSFE']->page;
+       }
+
        /**
         * Determines the rootline for the current page.
         *