2 namespace TYPO3\CMS\WizardSortPages\View
;
4 /***************************************************************
7 * (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
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.
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.
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.
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
30 * Contains class for "Sort pages" wizard
32 * Revised for TYPO3 3.6 July/2003 by Kasper Skårhøj
35 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
38 * Creates the "Sort pages" wizard
40 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
42 * @subpackage tx_wizardsortpages
44 class SortPagesWizardModuleFunction
extends \TYPO3\CMS\Backend\Module\AbstractFunctionModule
{
47 * Adds menu items... but I think this is not used at all. Looks very much like some testing code. If anyone cares to check it we can remove it some day...
51 * @todo Define visibility
53 public function modMenu() {
55 $modMenuAdd = array();
60 * Main function creating the content for the module.
62 * @return string HTML content for the module, actually a "section" made through the parent object in $this->pObj
63 * @todo Define visibility
65 public function main() {
67 $out = $this->pObj
->doc
->header($LANG->getLL('wiz_sort'));
68 if ($GLOBALS['BE_USER']->workspace
=== 0) {
70 // Check if user has modify permissions to
71 $sys_pages = \TYPO3\CMS\Core\Utility\GeneralUtility
::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
72 $sortByField = \TYPO3\CMS\Core\Utility\GeneralUtility
::_GP('sortByField');
75 if (\TYPO3\CMS\Core\Utility\GeneralUtility
::inList('title,subtitle,crdate,tstamp', $sortByField)) {
76 $menuItems = $sys_pages->getMenu($this->pObj
->id
, 'uid,pid,title', $sortByField, '', 0);
77 } elseif ($sortByField == 'REV') {
78 $menuItems = $sys_pages->getMenu($this->pObj
->id
, 'uid,pid,title', 'sorting', '', 0);
79 $menuItems = array_reverse($menuItems);
81 if (count($menuItems)) {
82 $tce = \TYPO3\CMS\Core\Utility\GeneralUtility
::makeInstance('TYPO3\\CMS\\Core\\DataHandler\\DataHandler');
83 $tce->stripslashes_values
= 0;
84 $menuItems = array_reverse($menuItems);
86 foreach ($menuItems as $r) {
87 $cmd['pages'][$r['uid']]['move'] = $this->pObj
->id
;
89 $tce->start(array(), $cmd);
90 $tce->process_cmdmap();
91 \TYPO3\CMS\Backend\Utility\BackendUtility
::setUpdateSignal('updatePageTree');
94 $menuItems = $sys_pages->getMenu($this->pObj
->id
, '*', 'sorting', '', 0);
96 $lines[] = ((((((('<tr class="t3-row-header">
97 <td>' . $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_title'), 'title')) . '</td>
98 ') . (\TYPO3\CMS\Core\Extension\ExtensionManager
::isLoaded('cms') ?
('<td> ' . $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_subtitle'), 'subtitle')) . '</td>' : '')) . '
99 <td>') . $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_tChange'), 'tstamp')) . '</td>
100 <td>') . $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_tCreate'), 'crdate')) . '</td>
102 foreach ($menuItems as $rec) {
103 $m_perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(2);
104 // edit permissions for that page!
105 $pRec = \TYPO3\CMS\Backend\Utility\BackendUtility
::getRecord('pages', $rec['uid'], 'uid', ' AND ' . $m_perms_clause);
106 $lines[] = ((((((((('<tr><td nowrap="nowrap">' . \TYPO3\CMS\Backend\Utility\IconUtility
::getSpriteIconForRecord('pages', $rec)) . (!is_array($pRec) ?
$GLOBALS['TBE_TEMPLATE']->rfw(('<strong>' . $LANG->getLL('wiz_W', 1)) . '</strong> ') : '')) . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility
::fixed_lgd_cs($rec['title'], $GLOBALS['BE_USER']->uc
['titleLen']))) . ' </td>
107 ') . (\TYPO3\CMS\Core\Extension\ExtensionManager
::isLoaded('cms') ?
('<td nowrap="nowrap">' . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility
::fixed_lgd_cs($rec['subtitle'], $GLOBALS['BE_USER']->uc
['titleLen']))) . ' </td>' : '')) . '
108 <td nowrap="nowrap">') . \t3lib_Befunc
::datetime($rec['tstamp'])) . ' </td>
109 <td nowrap="nowrap">') . \t3lib_Befunc
::datetime($rec['crdate'])) . ' </td>
112 $theCode .= ((('<h4>' . $LANG->getLL('wiz_currentPageOrder', TRUE)) . '</h4>
113 <table border="0" cellpadding="0" cellspacing="0" class="typo3-dblist">') . implode('', $lines)) . '</table><br />';
114 if (count($menuItems)) {
117 $lines[] = $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_title'), 'title');
118 if (\TYPO3\CMS\Core\Extension\ExtensionManager
::isLoaded('cms')) {
119 $lines[] = $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_subtitle'), 'subtitle');
121 $lines[] = $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_tChange'), 'tstamp');
122 $lines[] = $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_tCreate'), 'crdate');
124 $lines[] = $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_REVERSE'), 'REV');
125 $theCode .= (('<h4>' . $LANG->getLL('wiz_changeOrder')) . '</h4>') . implode('<br />', $lines);
128 $theCode .= \TYPO3\CMS\Backend\Utility\BackendUtility
::cshItem('_MOD_web_func', 'tx_wizardsortpages', $GLOBALS['BACK_PATH'], '<br />|');
129 $out .= $this->pObj
->doc
->section('', $theCode, 0, 1);
131 $out .= $this->pObj
->doc
->section('', 'Sorry, this function is not available in the current draft workspace!', 0, 1, 1);
137 * Creates a link for the sorting order
139 * @param string $title Title of the link
140 * @param string $order Field to sort by
141 * @return string HTML string
142 * @todo Define visibility
144 public function wiz_linkOrder($title, $order) {
145 return (((((' <a class="t3-link" href="' . htmlspecialchars(((('index.php?id=' . $GLOBALS['SOBE']->id
) . '&sortByField=') . $order))) . '" onclick="return confirm(') . $GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->getLL('wiz_changeOrder_msg1'))) . ')">') . htmlspecialchars($title)) . '</a>';