Passed
Push — master ( d99b2c...0c4ec8 )
by
unknown
23:31
created

PageTreeView::initializePositionSaving()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the TYPO3 CMS project.
5
 *
6
 * It is free software; you can redistribute it and/or modify it under
7
 * the terms of the GNU General Public License, either version 2
8
 * of the License, or any later version.
9
 *
10
 * For the full copyright and license information, please read the
11
 * LICENSE.txt file that was distributed with this source code.
12
 *
13
 * The TYPO3 project - inspiring people to share!
14
 */
15
16
namespace TYPO3\CMS\Backend\Tree\View;
17
18
use TYPO3\CMS\Core\Utility\GeneralUtility;
19
20
/**
21
 * Generate a page-tree, non-browsable.
22
 */
23
class PageTreeView extends AbstractTreeView
24
{
25
    /**
26
     * override to use this table
27
     * @var string
28
     */
29
    public $table = 'pages';
30
31
    /**
32
     * Init function
33
     * REMEMBER to feed a $clause which will filter out non-readable pages!
34
     *
35
     * @param string $clause Part of where query which will filter out non-readable pages.
36
     * @param string $orderByFields Record ORDER BY field
37
     */
38
    public function init($clause = '', $orderByFields = '')
39
    {
40
        parent::init(' AND deleted=0 AND sys_language_uid=0 ' . $clause, $orderByFields ?: 'sorting');
41
    }
42
43
    /**
44
     * Returns TRUE/FALSE if the next level for $id should be expanded - and all levels should, so we always return 1.
45
     *
46
     * @param int $id ID (uid) to test for (see extending classes where this is checked against session data)
47
     * @return bool
48
     */
49
    public function expandNext($id)
50
    {
51
        return true;
52
    }
53
54
    /**
55
     * Generate the plus/minus icon for the browsable tree.
56
     * In this case, there is no plus-minus icon displayed.
57
     *
58
     * @param array $row Record for the entry
59
     * @param int $a The current entry number
60
     * @param int $c The total number of entries. If equal to $a, a 'bottom' element is returned.
61
     * @param int $nextCount The number of sub-elements to the current element.
62
     * @param bool $isExpand The element was expanded to render subelements if this flag is set.
63
     * @return string Image tag with the plus/minus icon.
64
     * @internal
65
     * @see AbstractTreeView::PMicon()
66
     */
67
    public function PMicon($row, $a, $c, $nextCount, $isExpand)
68
    {
69
        return '<span class="treeline-icon treeline-icon-join' . ($a == $c ? 'bottom' : '') . '"></span>';
70
    }
71
72
    /**
73
     * Returns the title for the input record. If blank, a "no title" label (localized) will be returned.
74
     * Do NOT htmlspecialchar the string from this function - has already been done.
75
     *
76
     * @param array $row The input row array (where the key "title" is used for the title)
77
     * @param int $titleLen Title length (30)
78
     * @return string The title.
79
     */
80
    public function getTitleStr($row, $titleLen = 30)
81
    {
82
        $lang = $this->getLanguageService();
83
        $title = htmlspecialchars(GeneralUtility::fixed_lgd_cs($row['title'], $titleLen));
84
        if (isset($row['nav_title']) && trim($row['nav_title']) !== '') {
85
            $title = '<span title="'
86
                        . htmlspecialchars($lang->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.nav_title'))
87
                        . ' ' . htmlspecialchars(trim($row['nav_title'])) . '">' . $title
88
                        . '</span>';
89
        }
90
        return trim($row['title']) === ''
91
            ? '<em>[' . htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.no_title')) . ']</em>'
92
            : $title;
93
    }
94
}
95