488a319d24101adf26b0611d5be7afc57b4eba9f
[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
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 \TYPO3\CMS\Backend\Tree\View\AbstractTreeView {
24
25 /**
26 * @var array
27 */
28 public $fieldArray = array(
29 'uid',
30 'title',
31 'doktype',
32 'nav_title',
33 'mount_pid',
34 'php_tree_stop',
35 't3ver_id',
36 't3ver_state'
37 );
38
39 /**
40 * @var string
41 */
42 public $defaultList = 'uid,pid,tstamp,sorting,deleted,perms_userid,perms_groupid,perms_user,perms_group,perms_everybody,crdate,cruser_id';
43
44 /**
45 * @var int
46 */
47 public $setRecs = 0;
48
49 /**
50 * Init function
51 * REMEMBER to feed a $clause which will filter out non-readable pages!
52 *
53 * @param string $clause Part of where query which will filter out non-readable pages.
54 * @param string $orderByFields Record ORDER BY field
55 * @return void
56 */
57 public function init($clause = '', $orderByFields = '') {
58 parent::init(' AND deleted=0 ' . $clause, 'sorting');
59 $this->fieldArray = array_merge($this->fieldArray, array(
60 'hidden',
61 'starttime',
62 'endtime',
63 'fe_group',
64 'module',
65 'extendToSubpages',
66 'nav_hide'
67 ));
68 $this->table = 'pages';
69 $this->treeName = 'pages';
70 }
71
72 /**
73 * Returns TRUE/FALSE if the next level for $id should be expanded - and all levels should, so we always return 1.
74 *
75 * @param int $id ID (uid) to test for (see extending classes where this is checked against session data)
76 * @return bool
77 */
78 public function expandNext($id) {
79 return 1;
80 }
81
82 /**
83 * Generate the plus/minus icon for the browsable tree.
84 * In this case, there is no plus-minus icon displayed.
85 *
86 * @param array $row Record for the entry
87 * @param int $a The current entry number
88 * @param int $c The total number of entries. If equal to $a, a 'bottom' element is returned.
89 * @param int $nextCount The number of sub-elements to the current element.
90 * @param bool $exp The element was expanded to render subelements if this flag is set.
91 * @return string Image tag with the plus/minus icon.
92 * @access private
93 * @see AbstarctTreeView::PMicon()
94 */
95 public function PMicon($row, $a, $c, $nextCount, $exp) {
96 $PM = 'join';
97 $BTM = $a == $c ? 'bottom' : '';
98 $icon = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('treeline-' . $PM . $BTM);
99 return $icon;
100 }
101
102 /**
103 * Get stored tree structure AND updating it if needed according to incoming PM GET var.
104 * - Here we just set it to nothing since we want to just render the tree, nothing more.
105 *
106 * @return void
107 * @access private
108 */
109 public function initializePositionSaving() {
110 $this->stored = array();
111 }
112
113 /**
114 * Returns the title for the input record. If blank, a "no title" label (localized) will be returned.
115 * Do NOT htmlspecialchar the string from this function - has already been done.
116 *
117 * @param array $row The input row array (where the key "title" is used for the title)
118 * @param int $titleLen Title length (30)
119 * @return string The title.
120 */
121 public function getTitleStr($row, $titleLen = 30) {
122 if ($this->ext_showNavTitle && trim($row['nav_title']) !== '') {
123 $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>';
124 } else {
125 $title = htmlspecialchars(GeneralUtility::fixed_lgd_cs($row['title'], $titleLen));
126 if (trim($row['nav_title']) !== '') {
127 $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>';
128 }
129 $title = trim($row['title']) === '' ? '<em>[' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.no_title', TRUE) . ']</em>' : $title;
130 }
131 return $title;
132 }
133 }