[TASK] Move and Namespace classes
[Packages/TYPO3.CMS.git] / typo3 / sysext / wizard_sort_pages / 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 * Contains class for "Sort pages" wizard
31 *
32 * Revised for TYPO3 3.6 July/2003 by Kasper Skårhøj
33 * XHTML compliant
34 *
35 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
36 */
37 /**
38 * Creates the "Sort pages" wizard
39 *
40 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
41 * @package TYPO3
42 * @subpackage tx_wizardsortpages
43 */
44 class SortPagesWizardModuleFunction extends \TYPO3\CMS\Backend\Module\AbstractFunctionModule {
45
46 /**
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...
48 *
49 * @return array
50 * @ignore
51 * @todo Define visibility
52 */
53 public function modMenu() {
54 global $LANG;
55 $modMenuAdd = array();
56 return $modMenuAdd;
57 }
58
59 /**
60 * Main function creating the content for the module.
61 *
62 * @return string HTML content for the module, actually a "section" made through the parent object in $this->pObj
63 * @todo Define visibility
64 */
65 public function main() {
66 global $SOBE, $LANG;
67 $out = $this->pObj->doc->header($LANG->getLL('wiz_sort'));
68 if ($GLOBALS['BE_USER']->workspace === 0) {
69 $theCode = '';
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');
73 if ($sortByField) {
74 $menuItems = array();
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);
80 }
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);
85 $cmd = array();
86 foreach ($menuItems as $r) {
87 $cmd['pages'][$r['uid']]['move'] = $this->pObj->id;
88 }
89 $tce->start(array(), $cmd);
90 $tce->process_cmdmap();
91 \TYPO3\CMS\Backend\Utility\BackendUtility::setUpdateSignal('updatePageTree');
92 }
93 }
94 $menuItems = $sys_pages->getMenu($this->pObj->id, '*', 'sorting', '', 0);
95 $lines = array();
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>
101 </tr>';
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']))) . '&nbsp;</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']))) . '&nbsp;</td>' : '')) . '
108 <td nowrap="nowrap">') . \t3lib_Befunc::datetime($rec['tstamp'])) . '&nbsp;&nbsp;</td>
109 <td nowrap="nowrap">') . \t3lib_Befunc::datetime($rec['crdate'])) . '&nbsp;&nbsp;</td>
110 </tr>';
111 }
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)) {
115 // Menu:
116 $lines = array();
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');
120 }
121 $lines[] = $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_tChange'), 'tstamp');
122 $lines[] = $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_tCreate'), 'crdate');
123 $lines[] = '';
124 $lines[] = $this->wiz_linkOrder($LANG->getLL('wiz_changeOrder_REVERSE'), 'REV');
125 $theCode .= (('<h4>' . $LANG->getLL('wiz_changeOrder')) . '</h4>') . implode('<br />', $lines);
126 }
127 // CSH:
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);
130 } else {
131 $out .= $this->pObj->doc->section('', 'Sorry, this function is not available in the current draft workspace!', 0, 1, 1);
132 }
133 return $out;
134 }
135
136 /**
137 * Creates a link for the sorting order
138 *
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
143 */
144 public function wiz_linkOrder($title, $order) {
145 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>';
146 }
147
148 }
149
150
151 ?>