[BUGFIX] Namespace: Revert extension split-up: wizard_sortpages
[Packages/TYPO3.CMS.git] / typo3 / sysext / wizard_sortpages / Classes / View / SortPagesWizardModuleFunction.php
1 <?php
2 namespace TYPO3\CMS\WizardSortpages\View;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
8 * All rights reserved
9 *
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.
15 *
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.
20 *
21 *
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.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29 /**
30 * Creates the "Sort pages" wizard
31 *
32 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
33 * @package TYPO3
34 * @subpackage wizard_sortpages
35 */
36 class SortPagesWizardModuleFunction extends \TYPO3\CMS\Backend\Module\AbstractFunctionModule {
37
38 /**
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...
40 *
41 * @return array
42 * @ignore
43 * @todo Define visibility
44 */
45 public function modMenu() {
46 global $LANG;
47 $modMenuAdd = array();
48 return $modMenuAdd;
49 }
50
51 /**
52 * Main function creating the content for the module.
53 *
54 * @return string HTML content for the module, actually a "section" made through the parent object in $this->pObj
55 * @todo Define visibility
56 */
57 public function main() {
58 global $SOBE, $LANG;
59 $out = $this->pObj->doc->header($LANG->getLL('wiz_sort'));
60 if ($GLOBALS['BE_USER']->workspace === 0) {
61 $theCode = '';
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');
65 if ($sortByField) {
66 $menuItems = array();
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);
72 }
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);
77 $cmd = array();
78 foreach ($menuItems as $r) {
79 $cmd['pages'][$r['uid']]['move'] = $this->pObj->id;
80 }
81 $tce->start(array(), $cmd);
82 $tce->process_cmdmap();
83 \TYPO3\CMS\Backend\Utility\BackendUtility::setUpdateSignal('updatePageTree');
84 }
85 }
86 $menuItems = $sys_pages->getMenu($this->pObj->id, '*', 'sorting', '', 0);
87 $lines = array();
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>
93 </tr>';
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']))) . '&nbsp;</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']))) . '&nbsp;</td>' : '')) . '
100 <td nowrap="nowrap">') . \t3lib_Befunc::datetime($rec['tstamp'])) . '&nbsp;&nbsp;</td>
101 <td nowrap="nowrap">') . \t3lib_Befunc::datetime($rec['crdate'])) . '&nbsp;&nbsp;</td>
102 </tr>';
103 }
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)) {
107 // Menu:
108 $lines = array();
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');
112 }
113 $lines[] = $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_tChange'), 'tstamp');
114 $lines[] = $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_tCreate'), 'crdate');
115 $lines[] = '';
116 $lines[] = $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_REVERSE'), 'REV');
117 $theCode .= (('<h4>' . $LANG->getLL('wiz_changeOrder')) . '</h4>') . implode('<br />', $lines);
118 }
119 // CSH:
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);
122 } else {
123 $out .= $this->pObj->doc->section('', 'Sorry, this function is not available in the current draft workspace!', 0, 1, 1);
124 }
125 return $out;
126 }
127
128 /**
129 * Creates a link for the sorting order
130 *
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
135 */
136 public function wiz_linkOrder($title, $order) {
137 return ((((('&nbsp; &nbsp;<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>';
138 }
139
140 }
141
142 ?>