523c2527dfd84dcbb6a9199ca6e8a474fb493c3c
[Packages/TYPO3.CMS.git] / typo3 / sysext / workspaces / Classes / ExtDirect / PagetreeCollectionsProcessor.php
1 <?php
2 namespace TYPO3\CMS\Workspaces\ExtDirect;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2011-2013 Tolleiv Nietsch <typo3@tolleiv.de>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the textfile GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29 /**
30 * Interface for classes which perform pre or post processing
31 *
32 * @author Tolleiv Nietsch <typo3@tolleiv.de>
33 */
34 class PagetreeCollectionsProcessor implements \TYPO3\CMS\Backend\Tree\Pagetree\CollectionProcessorInterface {
35
36 /**
37 * @abstract
38 * @param \TYPO3\CMS\Backend\Tree\Pagetree\PagetreeNode $node
39 * @param int $mountPoint
40 * @param int $level
41 * @param \TYPO3\CMS\Backend\Tree\Pagetree\PagetreeNodeCollection $nodeCollection
42 * @return void
43 */
44 public function postProcessGetNodes($node, $mountPoint, $level, $nodeCollection) {
45 foreach ($nodeCollection as $node) {
46 /** @var $node \TYPO3\CMS\Backend\Tree\TreeNode */
47 $this->highlightVersionizedElements($node);
48 }
49 }
50
51 /**
52 * @abstract
53 * @param \TYPO3\CMS\Backend\Tree\Pagetree\PagetreeNode $node
54 * @param string $searchFilter
55 * @param int $mountPoint
56 * @param \TYPO3\CMS\Backend\Tree\Pagetree\PagetreeNodeCollection $nodeCollection
57 * @return void
58 */
59 public function postProcessFilteredNodes($node, $searchFilter, $mountPoint, $nodeCollection) {
60 foreach ($nodeCollection as $node) {
61 /** @var $node \TYPO3\CMS\Backend\Tree\TreeNode */
62 $this->highlightVersionizedElements($node);
63 }
64 }
65
66 /**
67 * @abstract
68 * @param string $searchFilter
69 * @param \TYPO3\CMS\Backend\Tree\Pagetree\PagetreeNodeCollection $nodeCollection
70 * @return void
71 */
72 public function postProcessGetTreeMounts($searchFilter, $nodeCollection) {
73 foreach ($nodeCollection as $node) {
74 /** @var $node \TYPO3\CMS\Backend\Tree\TreeNode */
75 $this->highlightVersionizedElements($node);
76 }
77 }
78
79 /**
80 * Sets the CSS Class on all pages which have versioned records
81 * in the current workspace
82 *
83 * @param \TYPO3\CMS\Backend\Tree\TreeNode $node
84 * @return void
85 */
86 protected function highlightVersionizedElements(\TYPO3\CMS\Backend\Tree\TreeNode $node) {
87 if (!$node->getCls() && count(\TYPO3\CMS\Backend\Utility\BackendUtility::countVersionsOfRecordsOnPage($GLOBALS['BE_USER']->workspace, $node->getId(), TRUE))) {
88 $node->setCls('ver-versions');
89 }
90 }
91
92 }
93
94
95 ?>