[CLEANUP] Tree Classes
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / Tree / View / PageTreeView.php
1 <?php
2 namespace TYPO3\CMS\Backend\Tree\View;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16 use \TYPO3\CMS\Core\Utility\GeneralUtility;
17 /**
18 * Generate a page-tree, non-browsable.
19 *
20 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
21 * @coauthor René Fritz <r.fritz@colorcube.de>
22 */
23 class PageTreeView extends AbstractTreeView {
24
25 /**
26 * @var array
27 */
28 public $fieldArray = array(
29 'uid',
30 'pid',
31 'title',
32 'doktype',
33 'nav_title',
34 'mount_pid',
35 'php_tree_stop',
36 't3ver_id',
37 't3ver_state',
38 'hidden',
39 'starttime',
40 'endtime',
41 'fe_group',
42 'module',
43 'extendToSubpages',
44 'nav_hide'
45 );
46
47 /**
48 * override to use this treeName
49 * @var string
50 */
51 public $treeName = 'pages';
52
53 /**
54 * override to use this table
55 * @var string
56 */
57 public $table = 'pages';
58
59 /**
60 * Init function
61 * REMEMBER to feed a $clause which will filter out non-readable pages!
62 *
63 * @param string $clause Part of where query which will filter out non-readable pages.
64 * @param string $orderByFields Record ORDER BY field
65 * @return void
66 */
67 public function init($clause = '', $orderByFields = '') {
68 parent::init(' AND deleted=0 ' . $clause, 'sorting');
69 }
70
71 /**
72 * Returns TRUE/FALSE if the next level for $id should be expanded - and all levels should, so we always return 1.
73 *
74 * @param int $id ID (uid) to test for (see extending classes where this is checked against session data)
75 * @return bool
76 */
77 public function expandNext($id) {
78 return 1;
79 }
80
81 /**
82 * Generate the plus/minus icon for the browsable tree.
83 * In this case, there is no plus-minus icon displayed.
84 *
85 * @param array $row Record for the entry
86 * @param int $a The current entry number
87 * @param int $c The total number of entries. If equal to $a, a 'bottom' element is returned.
88 * @param int $nextCount The number of sub-elements to the current element.
89 * @param bool $exp The element was expanded to render subelements if this flag is set.
90 * @return string Image tag with the plus/minus icon.
91 * @access private
92 * @see AbstarctTreeView::PMicon()
93 */
94 public function PMicon($row, $a, $c, $nextCount, $exp) {
95 return \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('treeline-join' . ($a == $c ? 'bottom' : ''));
96 }
97
98 /**
99 * Get stored tree structure AND updating it if needed according to incoming PM GET var.
100 * - Here we just set it to nothing since we want to just render the tree, nothing more.
101 *
102 * @return void
103 * @access private
104 */
105 public function initializePositionSaving() {
106 $this->stored = array();
107 }
108
109 /**
110 * Returns the title for the input record. If blank, a "no title" label (localized) will be returned.
111 * Do NOT htmlspecialchar the string from this function - has already been done.
112 *
113 * @param array $row The input row array (where the key "title" is used for the title)
114 * @param int $titleLen Title length (30)
115 * @return string The title.
116 */
117 public function getTitleStr($row, $titleLen = 30) {
118 if ($this->ext_showNavTitle && trim($row['nav_title']) !== '') {
119 $title = '<span title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_tca.xlf:title', TRUE) . ' ' . htmlspecialchars(trim($row['title'])) . '">' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($row['nav_title'], $titleLen)) . '</span>';
120 } else {
121 $title = htmlspecialchars(GeneralUtility::fixed_lgd_cs($row['title'], $titleLen));
122 if (trim($row['nav_title']) !== '') {
123 $title = '<span title="' . $GLOBALS['LANG']->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.nav_title', TRUE) . ' ' . htmlspecialchars(trim($row['nav_title'])) . '">' . $title . '</span>';
124 }
125 $title = trim($row['title']) === '' ? '<em>[' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.no_title', TRUE) . ']</em>' : $title;
126 }
127 return $title;
128 }
129 }