[FEATURE] pagetree dataprovider should enable node postprocessing
authorTolleiv Nietsch <info@tolleiv.de>
Tue, 5 Jul 2011 06:57:21 +0000 (08:57 +0200)
committerSusanne Moog <typo3@susannemoog.de>
Sat, 9 Jul 2011 09:33:56 +0000 (11:33 +0200)
In order to change pagetree node properties the dataprovider should enable
postprocessing of the node-collections. Used e.g. to highlight nodes
when tt_content elements have changed on a page.

Change-Id: I128ece4f659212978b06b65d5486c1124c4bf81e
Resolves: #25255
Reviewed-on: http://review.typo3.org/1037
Reviewed-by: Georg Ringer
Tested-by: Georg Ringer
Reviewed-by: Susanne Moog
Tested-by: Susanne Moog
t3lib/core_autoload.php
t3lib/tree/pagetree/class.t3lib_tree_pagetree_dataprovider.php
t3lib/tree/pagetree/interfaces/interface.t3lib_tree_pagetree_interfaces_collectionprocessor.php [new file with mode: 0644]

index aefd876..692bfaa 100644 (file)
@@ -214,6 +214,7 @@ $t3libClasses = array(
        't3lib_contextmenu_pagetree_dataprovider' => PATH_t3lib . 'contextmenu/pagetree/class.t3lib_contextmenu_pagetree_dataprovider.php',
        't3lib_tree_pagetree_indicator' => PATH_t3lib . 'tree/pagetree/class.t3lib_tree_pagetree_indicator.php',
        't3lib_tree_pagetree_indicatorprovider' => PATH_t3lib . 'tree/pagetree/interfaces/interface.t3lib_tree_pagetree_interfaces_indicatorprovider.php',
+       't3lib_tree_pagetree_interfaces_collectionprocessor' => PATH_t3lib . 'tree/pagetree/interfaces/interface.t3lib_tree_pagetree_interfaces_collectionprocessor.php',
 );
 
 $tslibClasses = require(PATH_typo3 . 'sysext/cms/ext_autoload.php');
index 9295a59..0a59a78 100644 (file)
@@ -55,6 +55,13 @@ class t3lib_tree_pagetree_DataProvider extends t3lib_tree_AbstractDataProvider {
        protected $hiddenRecords = array();
 
        /**
+        * Process collection hook objects
+        *
+        * @var array<t3lib_tree_pagetree_interfaces_collectionprocessor>
+        */
+       protected $processCollectionHookObjects = array();
+
+       /**
         * Constructor
         *
         * @param int $nodeLimit (optional)
@@ -69,6 +76,17 @@ class t3lib_tree_pagetree_DataProvider extends t3lib_tree_AbstractDataProvider {
                        ',',
                        $GLOBALS['BE_USER']->getTSConfigVal('options.hideRecords.pages')
                );
+
+               $hookElements = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/tree/pagetree/class.t3lib_tree_pagetree_dataprovider.php']['postProcessCollections'];
+               if (is_array($hookElements)) {
+                       foreach ($hookElements as $classRef) {
+                               /** @var $hookObject t3lib_tree_pagetree_interfaces_collectionprocessor */
+                               $hookObject = t3lib_div::getUserObj($classRef);
+                               if ($hookObject instanceof t3lib_tree_pagetree_interfaces_collectionprocessor) {
+                                       $this->processCollectionHookObjects[] = $hookObject;
+                               }
+                       }
+               }
        }
 
        /**
@@ -128,6 +146,11 @@ class t3lib_tree_pagetree_DataProvider extends t3lib_tree_AbstractDataProvider {
                        $nodeCollection->append($subNode);
                }
 
+               foreach ($this->processCollectionHookObjects as $hookObject) {
+                       /** @var $hookObject t3lib_tree_pagetree_interfaces_collectionprocessor */
+                       $hookObject->postProcessGetNodes($node, $mountPoint, $level, $nodeCollection);
+               }
+
                return $nodeCollection;
        }
 
@@ -224,6 +247,11 @@ class t3lib_tree_pagetree_DataProvider extends t3lib_tree_AbstractDataProvider {
                        }
                }
 
+               foreach ($this->processCollectionHookObjects as $hookObject) {
+                       /** @var $hookObject t3lib_tree_pagetree_interfaces_collectionprocessor */
+                       $hookObject->postProcessFilteredNodes($node, $searchFilter, $mountPoint, $nodeCollection);
+               }
+
                return $nodeCollection;
        }
 
@@ -305,6 +333,11 @@ class t3lib_tree_pagetree_DataProvider extends t3lib_tree_AbstractDataProvider {
                        $nodeCollection->append($subNode);
                }
 
+               foreach ($this->processCollectionHookObjects as $hookObject) {
+                       /** @var $hookObject t3lib_tree_pagetree_interfaces_collectionprocessor */
+                       $hookObject->postProcessGetTreeMounts($searchFilter, $nodeCollection);
+               }
+
                return $nodeCollection;
        }
 
@@ -386,4 +419,4 @@ if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLA
        include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/tree/pagetree/class.t3lib_tree_pagetree_dataprovider.php']);
 }
 
-?>
\ No newline at end of file
+?>
diff --git a/t3lib/tree/pagetree/interfaces/interface.t3lib_tree_pagetree_interfaces_collectionprocessor.php b/t3lib/tree/pagetree/interfaces/interface.t3lib_tree_pagetree_interfaces_collectionprocessor.php
new file mode 100644 (file)
index 0000000..72b060f
--- /dev/null
@@ -0,0 +1,72 @@
+<?php
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2011 Tolleiv Nietsch <typo3@tolleiv.de>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *  A copy is found in the textfile GPL.txt and important notices to the license
+ *  from the author is found in LICENSE.txt distributed with these scripts.
+ *
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * Interface for classes which perform pre or post processing
+ *
+ * @author Tolleiv Nietsch <typo3@tolleiv.de>
+ * @package    TYPO3
+ * @subpackage t3lib
+ */
+interface t3lib_tree_pagetree_interfaces_CollectionProcessor {
+
+       /**
+        * Post process the subelement collection of a specific node
+        *
+        * @abstract
+        * @param t3lib_tree_pagetree_Node $node
+        * @param int $mountPoint
+        * @param int $level
+        * @param t3lib_tree_pagetree_NodeCollection $nodeCollection
+        * @return void
+        */
+       public function postProcessGetNodes($node, $mountPoint, $level, $nodeCollection);
+
+       /**
+        * Post process the subelement collection of a specific node-filter combination
+        *
+        * @abstract
+        * @param t3lib_tree_pagetree_Node $node
+        * @param string $searchFilter
+        * @param int $mountPoint
+        * @param t3lib_tree_pagetree_NodeCollection $nodeCollection
+        * @return void
+        */
+       public function postProcessFilteredNodes($node, $searchFilter, $mountPoint, $nodeCollection);
+
+       /**
+        * Post process the collection of tree mounts
+        *
+        * @abstract
+        * @param string $searchFilter
+        * @param t3lib_tree_pagetree_NodeCollection $nodeCollection
+        * @return void
+        */
+       public function postProcessGetTreeMounts($searchFilter, $nodeCollection);
+}
+
+?>
\ No newline at end of file