[CLEANUP] Tree Classes 36/41036/8
authorThomas Schlumberger <thomas@b13.de>
Thu, 9 Jul 2015 12:02:15 +0000 (14:02 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Thu, 9 Jul 2015 13:55:08 +0000 (15:55 +0200)
This patch is cleaning up the tree classes where properties
were set via the init() function and are now handled
by class properties, overriding the parent properties, itself.
A function not needed in the AbstractTreeView has been removed.

Resolves: #68005
Releases: master
Change-Id: I6fad1ade76c015a60ccdef77c5a8b4251f3f12da
Reviewed-on: http://review.typo3.org/41036
Reviewed-by: Benjamin Mack <benni@typo3.org>
Tested-by: Benjamin Mack <benni@typo3.org>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/backend/Classes/Tree/View/AbstractTreeView.php
typo3/sysext/backend/Classes/Tree/View/BrowseTreeView.php
typo3/sysext/backend/Classes/Tree/View/FolderTreeView.php
typo3/sysext/backend/Classes/Tree/View/PageTreeView.php
typo3/sysext/impexp/Classes/LocalPageTree.php

index 5d51abb..7904437 100644 (file)
@@ -184,20 +184,6 @@ abstract class AbstractTreeView {
        public $backPath;
 
        /**
-        * Icon file path.
-        *
-        * @var string
-        */
-       public $iconPath = '';
-
-       /**
-        * Icon file name for item icons.
-        *
-        * @var string
-        */
-       public $iconName = 'default.gif';
-
-       /**
         * If TRUE, HTML code is also accumulated in ->tree array during rendering of the tree.
         * If 2, then also the icon prefix code (depthData) is stored
         *
@@ -322,8 +308,6 @@ abstract class AbstractTreeView {
        public function init($clause = '', $orderByFields = '') {
                // Setting BE_USER by default
                $this->BE_USER = $GLOBALS['BE_USER'];
-               // Setting title attribute to use.
-               $this->titleAttrib = 'title';
                // Setting backpath.
                $this->backPath = $GLOBALS['BACK_PATH'];
                // Setting clause
@@ -337,26 +321,14 @@ abstract class AbstractTreeView {
                        // Dummy
                        $this->MOUNTS = array(0 => 0);
                }
-               $this->setTreeName();
+               // Sets the tree name which is used to identify the tree, used for JavaScript and other things
+               $this->treeName = str_replace('_', '', $this->treeName ?: $this->table);
                // Setting this to FALSE disables the use of array-trees by default
                $this->data = FALSE;
                $this->dataLookup = FALSE;
        }
 
        /**
-        * Sets the tree name which is used to identify the tree
-        * Used for JavaScript and other things
-        *
-        * @param string $treeName Default is the table name. Underscores are stripped.
-        * @return void
-        */
-       public function setTreeName($treeName = '') {
-               $this->treeName = $treeName ?: $this->treeName;
-               $this->treeName = $this->treeName ?: $this->table;
-               $this->treeName = str_replace('_', '', $this->treeName);
-       }
-
-       /**
         * Adds a fieldname to the internal array ->fieldArray
         *
         * @param string $field Field name to
@@ -657,20 +629,15 @@ abstract class AbstractTreeView {
 
        /**
         * Get icon for the row.
-        * If $this->iconPath and $this->iconName is set, try to get icon based on those values.
         *
         * @param array $row Item row.
         * @return string Image tag.
         */
        public function getIcon($row) {
-               if ($this->iconPath && $this->iconName) {
-                       $icon = '<img' . IconUtility::skinImg('', ($this->iconPath . $this->iconName), 'width="18" height="16"') . ' alt=""' . ($this->showDefaultTitleAttribute ? ' title="UID: ' . $row['uid'] . '"' : '') . ' />';
-               } else {
-                       $icon = IconUtility::getSpriteIconForRecord($this->table, $row, array(
-                               'title' => $this->showDefaultTitleAttribute ? 'UID: ' . $row['uid'] : $this->getTitleAttrib($row),
-                               'class' => 'c-recIcon'
-                       ));
-               }
+               $icon = IconUtility::getSpriteIconForRecord($this->table, $row, array(
+                       'title' => $this->showDefaultTitleAttribute ? 'UID: ' . $row['uid'] : $this->getTitleAttrib($row),
+                       'class' => 'c-recIcon'
+               ));
                return $this->wrapIcon($icon, $row);
        }
 
index f2c61ee..51854a8 100644 (file)
@@ -22,7 +22,50 @@ use TYPO3\CMS\Backend\Utility\BackendUtility;
  * @author Kasper Skårhøj <kasperYYYY@typo3.com>
  * @coauthor René Fritz <r.fritz@colorcube.de>
  */
-class BrowseTreeView extends \TYPO3\CMS\Backend\Tree\View\AbstractTreeView {
+class BrowseTreeView extends AbstractTreeView {
+
+       /**
+        * @var array
+        */
+       public $fieldArray = array(
+               'uid',
+               'pid',
+               'title',
+               'doktype',
+               'nav_title',
+               'mount_pid',
+               'php_tree_stop',
+               't3ver_id',
+               't3ver_state',
+               'hidden',
+               'starttime',
+               'endtime',
+               'fe_group',
+               'module',
+               'extendToSubpages',
+               'nav_hide',
+               't3ver_wsid',
+               't3ver_move_id',
+               'is_siteroot'
+       );
+
+       /**
+        * override to use this treeName
+        * @var string
+        */
+       public $treeName = 'browsePages';
+
+       /**
+        * override to use this table
+        * @var string
+        */
+       public $table = 'pages';
+
+       /**
+        * override to use this domIdPrefix
+        * @var string
+        */
+       public $domIdPrefix = 'pages';
 
        /**
         * Initialize, setting what is necessary for browsing pages.
@@ -42,10 +85,6 @@ class BrowseTreeView extends \TYPO3\CMS\Backend\Tree\View\AbstractTreeView {
                }
                // This is very important for making trees of pages: Filtering out deleted pages, pages with no access to and sorting them correctly:
                parent::init(' AND ' . $GLOBALS['BE_USER']->getPagePermsClause(1) . ' ' . $clause . $clauseExcludePidList, 'sorting');
-               $this->table = 'pages';
-               $this->setTreeName('browsePages');
-               $this->domIdPrefix = 'pages';
-               $this->iconName = '';
                $this->title = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
                $this->MOUNTS = $GLOBALS['BE_USER']->returnWebmounts();
                if ($pidList) {
@@ -53,8 +92,6 @@ class BrowseTreeView extends \TYPO3\CMS\Backend\Tree\View\AbstractTreeView {
                        $hideList = explode(',', $pidList);
                        $this->MOUNTS = array_diff($this->MOUNTS, $hideList);
                }
-               $this->fieldArray = array_merge($this->fieldArray, array('doktype', 'php_tree_stop', 't3ver_id', 't3ver_state', 't3ver_wsid', 't3ver_move_id'));
-               $this->fieldArray = array_merge($this->fieldArray, array('hidden', 'starttime', 'endtime', 'fe_group', 'module', 'extendToSubpages', 'is_siteroot', 'nav_hide'));
        }
 
        /**
index 499514e..8f22411 100644 (file)
@@ -27,7 +27,7 @@ use TYPO3\CMS\Lang\LanguageService;
  * @author Kasper Skårhøj <kasperYYYY@typo3.com>
  * @coauthor René Fritz <r.fritz@colorcube.de>
  */
-class FolderTreeView extends \TYPO3\CMS\Backend\Tree\View\AbstractTreeView {
+class FolderTreeView extends AbstractTreeView {
 
        /**
         * The users' file Storages
@@ -60,15 +60,30 @@ class FolderTreeView extends \TYPO3\CMS\Backend\Tree\View\AbstractTreeView {
        public $ext_noTempRecyclerDirs;
 
        /**
+        * override to not use a title attribute
+        * @var string
+        */
+       public $titleAttrib = '';
+
+       /**
+        * override to use this treeName
+        * does not need to be set in __construct()
+        * @var string
+        */
+       public $treeName = 'folder';
+
+       /**
+        * override to use this domIdPrefix
+        * @var string
+        */
+       public $domIdPrefix = 'folder';
+
+       /**
         * Constructor function of the class
         */
        public function __construct() {
                parent::init();
                $this->storages = $this->BE_USER->getFileStorages();
-               $this->treeName = 'folder';
-               // Don't apply any title
-               $this->titleAttrib = '';
-               $this->domIdPrefix = 'folder';
        }
 
        /**
index 488a319..21de639 100644 (file)
@@ -13,38 +13,48 @@ namespace TYPO3\CMS\Backend\Tree\View;
  *
  * The TYPO3 project - inspiring people to share!
  */
-
+use \TYPO3\CMS\Core\Utility\GeneralUtility;
 /**
  * Generate a page-tree, non-browsable.
  *
  * @author Kasper Skårhøj <kasperYYYY@typo3.com>
  * @coauthor René Fritz <r.fritz@colorcube.de>
  */
-class PageTreeView extends \TYPO3\CMS\Backend\Tree\View\AbstractTreeView {
+class PageTreeView extends AbstractTreeView {
 
        /**
         * @var array
         */
        public $fieldArray = array(
                'uid',
+               'pid',
                'title',
                'doktype',
                'nav_title',
                'mount_pid',
                'php_tree_stop',
                't3ver_id',
-               't3ver_state'
+               't3ver_state',
+               'hidden',
+               'starttime',
+               'endtime',
+               'fe_group',
+               'module',
+               'extendToSubpages',
+               'nav_hide'
        );
 
        /**
+        * override to use this treeName
         * @var string
         */
-       public $defaultList = 'uid,pid,tstamp,sorting,deleted,perms_userid,perms_groupid,perms_user,perms_group,perms_everybody,crdate,cruser_id';
+       public $treeName = 'pages';
 
        /**
-        * @var int
+        * override to use this table
+        * @var string
         */
-       public $setRecs = 0;
+       public $table = 'pages';
 
        /**
         * Init function
@@ -56,17 +66,6 @@ class PageTreeView extends \TYPO3\CMS\Backend\Tree\View\AbstractTreeView {
         */
        public function init($clause = '', $orderByFields = '') {
                parent::init(' AND deleted=0 ' . $clause, 'sorting');
-               $this->fieldArray = array_merge($this->fieldArray, array(
-                       'hidden',
-                       'starttime',
-                       'endtime',
-                       'fe_group',
-                       'module',
-                       'extendToSubpages',
-                       'nav_hide'
-               ));
-               $this->table = 'pages';
-               $this->treeName = 'pages';
        }
 
        /**
@@ -93,10 +92,7 @@ class PageTreeView extends \TYPO3\CMS\Backend\Tree\View\AbstractTreeView {
         * @see AbstarctTreeView::PMicon()
         */
        public function PMicon($row, $a, $c, $nextCount, $exp) {
-               $PM = 'join';
-               $BTM = $a == $c ? 'bottom' : '';
-               $icon = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('treeline-' . $PM . $BTM);
-               return $icon;
+               return \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('treeline-join' . ($a == $c ? 'bottom' : ''));
        }
 
        /**
index 89de2da..aa66022 100644 (file)
@@ -13,6 +13,7 @@ namespace TYPO3\CMS\Impexp;
  *
  * The TYPO3 project - inspiring people to share!
  */
+use TYPO3\CMS\Backend\Utility\IconUtility;
 
 /**
  * Extension of the page tree class. Used to get the tree of pages to export.
@@ -36,8 +37,7 @@ class LocalPageTree extends \TYPO3\CMS\Backend\Tree\View\BrowseTreeView {
         * @return string Wrapped title
         */
        public function wrapTitle($title, $v) {
-               $title = trim($title) === '' ? '<em>[' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.no_title', TRUE) . ']</em>' : htmlspecialchars($title);
-               return $title;
+               return trim($title) === '' ? '<em>[' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.no_title', TRUE) . ']</em>' : htmlspecialchars($title);
        }
 
        /**
@@ -64,15 +64,6 @@ class LocalPageTree extends \TYPO3\CMS\Backend\Tree\View\BrowseTreeView {
        }
 
        /**
-        * Select permissions
-        *
-        * @return string SQL where clause
-        */
-       public function permsC() {
-               return $this->BE_USER->getPagePermsClause(1);
-       }
-
-       /**
         * Tree rendering
         *
         * @param int $pid PID value
@@ -81,13 +72,9 @@ class LocalPageTree extends \TYPO3\CMS\Backend\Tree\View\BrowseTreeView {
         */
        public function ext_tree($pid, $clause = '') {
                // Initialize:
-               $this->init(' AND ' . $this->permsC() . $clause);
+               $this->init(' AND ' . $this->BE_USER->getPagePermsClause(1) . $clause);
                // Get stored tree structure:
                $this->stored = unserialize($this->BE_USER->uc['browseTrees']['browsePages']);
-               // PM action:
-               $PM = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode('_', \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('PM'));
-               // traverse mounts:
-               $titleLen = (int)$this->BE_USER->uc['titleLen'];
                $treeArr = array();
                $idx = 0;
                // Set first:
@@ -97,24 +84,21 @@ class LocalPageTree extends \TYPO3\CMS\Backend\Tree\View\BrowseTreeView {
                $curIds = $this->ids;
                $this->reset();
                $this->ids = $curIds;
-               // Set PM icon:
-               $cmd = $this->bank . '_' . ($isOpen ? '0_' : '1_') . $pid;
-               $icon = '<img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($this->backPath, ('gfx/ol/' . ($isOpen ? 'minus' : 'plus') . 'only.gif'), 'width="18" height="16"') . ' align="top" alt="" />';
-               $firstHtml = $this->PM_ATagWrap($icon, $cmd);
+               $firstHtml = '<img' . IconUtility::skinImg($this->backPath, ('gfx/ol/' . ($isOpen ? 'minus' : 'plus') . 'only.gif'), 'width="18" height="16"') . ' align="top" alt="" />';
                if ($pid > 0) {
                        $rootRec = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordWSOL('pages', $pid);
-                       $firstHtml .= $this->wrapIcon(\TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord('pages', $rootRec), $rootRec);
+                       $firstHtml .= IconUtility::getSpriteIconForRecord('pages', $rootRec);
                } else {
                        $rootRec = array(
                                'title' => $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'],
                                'uid' => 0
                        );
-                       $firstHtml .= $this->wrapIcon(\TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('apps-pagetree-page-domain'), $rootRec);
+                       $firstHtml .= $this->getRootIcon($rootRec);
                }
                $this->tree[] = array('HTML' => $firstHtml, 'row' => $rootRec);
                if ($isOpen) {
                        // Set depth:
-                       $depthD = '<img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($this->backPath, 'gfx/ol/blank.gif', 'width="18" height="16"') . ' align="top" alt="" />';
+                       $depthD = '<img' . IconUtility::skinImg($this->backPath, 'gfx/ol/blank.gif', 'width="18" height="16"') . ' align="top" alt="" />';
                        if ($this->addSelfId) {
                                $this->ids[] = $pid;
                        }