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 * Creates the "Sort pages" wizard
32 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
34 * @subpackage wizard_sortpages
36 class SortPagesWizardModuleFunction
extends \TYPO3\CMS\Backend\Module\AbstractFunctionModule
{
39 * 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...
43 * @todo Define visibility
45 public function modMenu() {
47 $modMenuAdd = array();
52 * Main function creating the content for the module.
54 * @return string HTML content for the module, actually a "section" made through the parent object in $this->pObj
55 * @todo Define visibility
57 public function main() {
59 $out = $this->pObj
->doc
->header($LANG->getLL('wiz_sort'));
60 if ($GLOBALS['BE_USER']->workspace
=== 0) {
62 // Check if user has modify permissions to
63 $sys_pages = \TYPO3\CMS\Core\Utility\GeneralUtility
::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
64 $sortByField = \TYPO3\CMS\Core\Utility\GeneralUtility
::_GP('sortByField');
67 if (\TYPO3\CMS\Core\Utility\GeneralUtility
::inList('title,subtitle,crdate,tstamp', $sortByField)) {
68 $menuItems = $sys_pages->getMenu($this->pObj
->id
, 'uid,pid,title', $sortByField, '', 0);
69 } elseif ($sortByField == 'REV') {
70 $menuItems = $sys_pages->getMenu($this->pObj
->id
, 'uid,pid,title', 'sorting', '', 0);
71 $menuItems = array_reverse($menuItems);
73 if (count($menuItems)) {
74 $tce = \TYPO3\CMS\Core\Utility\GeneralUtility
::makeInstance('TYPO3\\CMS\\Core\\DataHandler\\DataHandler');
75 $tce->stripslashes_values
= 0;
76 $menuItems = array_reverse($menuItems);
78 foreach ($menuItems as $r) {
79 $cmd['pages'][$r['uid']]['move'] = $this->pObj
->id
;
81 $tce->start(array(), $cmd);
82 $tce->process_cmdmap();
83 \TYPO3\CMS\Backend\Utility\BackendUtility
::setUpdateSignal('updatePageTree');
86 $menuItems = $sys_pages->getMenu($this->pObj
->id
, '*', 'sorting', '', 0);
88 $lines[] = ((((((('<tr class="t3-row-header">
89 <td>' . $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_title'), 'title')) . '</td>
90 ') . (\TYPO3\CMS\Core\Extension\ExtensionManager
::isLoaded('cms') ?
('<td> ' . $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_subtitle'), 'subtitle')) . '</td>' : '')) . '
91 <td>') . $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_tChange'), 'tstamp')) . '</td>
92 <td>') . $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_tCreate'), 'crdate')) . '</td>
94 foreach ($menuItems as $rec) {
95 $m_perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(2);
96 // edit permissions for that page!
97 $pRec = \TYPO3\CMS\Backend\Utility\BackendUtility
::getRecord('pages', $rec['uid'], 'uid', ' AND ' . $m_perms_clause);
98 $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>
99 ') . (\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>' : '')) . '
100 <td nowrap="nowrap">') . \t3lib_Befunc
::datetime($rec['tstamp'])) . ' </td>
101 <td nowrap="nowrap">') . \t3lib_Befunc
::datetime($rec['crdate'])) . ' </td>
104 $theCode .= ((('<h4>' . $LANG->getLL('wiz_currentPageOrder', TRUE)) . '</h4>
105 <table border="0" cellpadding="0" cellspacing="0" class="typo3-dblist">') . implode('', $lines)) . '</table><br />';
106 if (count($menuItems)) {
109 $lines[] = $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_title'), 'title');
110 if (\TYPO3\CMS\Core\Extension\ExtensionManager
::isLoaded('cms')) {
111 $lines[] = $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_subtitle'), 'subtitle');
113 $lines[] = $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_tChange'), 'tstamp');
114 $lines[] = $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_tCreate'), 'crdate');
116 $lines[] = $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_REVERSE'), 'REV');
117 $theCode .= (('<h4>' . $LANG->getLL('wiz_changeOrder')) . '</h4>') . implode('<br />', $lines);
120 $theCode .= \TYPO3\CMS\Backend\Utility\BackendUtility
::cshItem('_MOD_web_func', 'tx_wizardsortpages', $GLOBALS['BACK_PATH'], '<br />|');
121 $out .= $this->pObj
->doc
->section('', $theCode, 0, 1);
123 $out .= $this->pObj
->doc
->section('', 'Sorry, this function is not available in the current draft workspace!', 0, 1, 1);
129 * Creates a link for the sorting order
131 * @param string $title Title of the link
132 * @param string $order Field to sort by
133 * @return string HTML string
134 * @todo Define visibility
136 public function wiz_linkOrder($title, $order) {
137 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>';