TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
SortPagesWizardModuleFunction.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\WizardSortpages\View;
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
22 
27 {
33  public function main()
34  {
35  $assigns = [];
36  $assigns['LLPrefix'] = 'LLL:EXT:wizard_sortpages/Resources/Private/Language/locallang.xlf:';
37  $assigns['workspace'] = $this->getBackendUser()->workspace;
38  if ($this->getBackendUser()->workspace === 0) {
39  // Check if user has modify permissions to
40  $sys_pages = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\Page\PageRepository::class);
41  $sortByField = GeneralUtility::_GP('sortByField');
42  if ($sortByField) {
43  $menuItems = [];
44  if ($sortByField === 'title' || $sortByField === 'subtitle' || $sortByField === 'crdate' || $sortByField === 'tstamp') {
45  $menuItems = $sys_pages->getMenu($this->pObj->id, 'uid,pid,title', $sortByField, '', false);
46  } elseif ($sortByField === 'REV') {
47  $menuItems = $sys_pages->getMenu($this->pObj->id, 'uid,pid,title', 'sorting', '', false);
48  $menuItems = array_reverse($menuItems);
49  }
50  if (!empty($menuItems)) {
51  $tce = GeneralUtility::makeInstance(\TYPO3\CMS\Core\DataHandling\DataHandler::class);
52  $menuItems = array_reverse($menuItems);
53  $cmd = [];
54  foreach ($menuItems as $r) {
55  $cmd['pages'][$r['uid']]['move'] = $this->pObj->id;
56  }
57  $tce->start([], $cmd);
58  $tce->process_cmdmap();
59  BackendUtility::setUpdateSignal('updatePageTree');
60  }
61  }
62  $menuItems = $sys_pages->getMenu($this->pObj->id, '*', 'sorting', '', false);
63  $assigns['menuItems'] = $menuItems;
64  if (!empty($menuItems)) {
65  $dataLines = [];
66  foreach ($menuItems as $rec) {
67  $m_perms_clause = $this->getBackendUser()->getPagePermsClause(2);
68  // edit permissions for that page!
69  $pRec = BackendUtility::getRecord('pages', $rec['uid'], 'uid', ' AND ' . $m_perms_clause);
70  $line = [];
71  $line['rec'] = $rec;
72  $line['danger'] = !is_array($pRec);
73  $line['title'] = GeneralUtility::fixed_lgd_cs($rec['title'], $GLOBALS['BE_USER']->uc['titleLen']);
74  $line['subtitle'] = GeneralUtility::fixed_lgd_cs($rec['subtitle'], $this->getBackendUser()->uc['titleLen']);
75  $line['tstamp'] = BackendUtility::datetime($rec['tstamp']);
76  $line['crdate'] = BackendUtility::datetime($rec['crdate']);
77  $dataLines[] = $line;
78  }
79  $assigns['lines'] = $dataLines;
80 
81  // Menu:
82  $dataLines = [];
83  $line = [];
84  $line['title'] = 'wiz_changeOrder_title';
85  $line['href'] = BackendUtility::getModuleUrl('web_func',
86  [
87  'id' => $GLOBALS['SOBE']->id,
88  'sortByField' => 'title'
89  ]
90  );
91  $dataLines[] = $line;
92  $line['title'] = 'wiz_changeOrder_subtitle';
93  $line['href'] = BackendUtility::getModuleUrl('web_func',
94  [
95  'id' => $GLOBALS['SOBE']->id,
96  'sortByField' => 'subtitle'
97  ]
98  );
99  $dataLines[] = $line;
100  $line['title'] = 'wiz_changeOrder_tChange';
101  $line['href'] = BackendUtility::getModuleUrl('web_func',
102  [
103  'id' => $GLOBALS['SOBE']->id,
104  'sortByField' => 'tstamp'
105  ]
106  );
107  $dataLines[] = $line;
108  $line['title'] = 'wiz_changeOrder_tCreate';
109  $line['href'] = BackendUtility::getModuleUrl('web_func',
110  [
111  'id' => $GLOBALS['SOBE']->id,
112  'sortByField' => 'crdate'
113  ]
114  );
115  $dataLines[] = $line;
116  $line['title'] = 'wiz_changeOrder_REVERSE';
117  $line['href'] = BackendUtility::getModuleUrl('web_func',
118  [
119  'id' => $GLOBALS['SOBE']->id,
120  'sortByField' => 'REV'
121  ]
122  );
123  $dataLines[] = $line;
124  $assigns['buttons'] = $dataLines;
125  } else {
126  $lang = $this->getLanguageService();
127  $lang->includeLLFile('EXT:wizard_sortpages/Resources/Private/Language/locallang.xlf');
128  $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $lang->getLL('no_subpages'), '', FlashMessage::NOTICE);
130  $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
132  $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
133  $defaultFlashMessageQueue->enqueue($flashMessage);
134  }
135  // CSH:
136  $assigns['cshItem'] = BackendUtility::cshItem('_MOD_web_func', 'tx_wizardsortpages');
137  }
138  // Rendering of the output via fluid
139  $view = GeneralUtility::makeInstance(StandaloneView::class);
140  $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName(
141  'EXT:wizard_sortpages/Resources/Private/Templates/SortPagesWizard.html'
142  ));
143  $view->assignMultiple($assigns);
144  return $view->render();
145  }
146 
152  protected function getLanguageService()
153  {
154  return $GLOBALS['LANG'];
155  }
156 
162  protected function getBackendUser()
163  {
164  return $GLOBALS['BE_USER'];
165  }
166 }
static getRecord($table, $uid, $fields= '*', $where= '', $useDeleteClause=true)
if(TYPO3_MODE=== 'BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']
static makeInstance($className,...$constructorArguments)
static getFileAbsFileName($filename, $_=null, $_2=null)