TYPO3 CMS  TYPO3_6-2
SortPagesWizardModuleFunction.php
Go to the documentation of this file.
1 <?php
3 
18 
25 
33  public function modMenu() {
34  global $LANG;
35  $modMenuAdd = array();
36  return $modMenuAdd;
37  }
38 
45  public function main() {
46  $GLOBALS['LANG']->includeLLFile('EXT:wizard_sortpages/locallang.xlf');
47  $out = $this->pObj->doc->header($GLOBALS['LANG']->getLL('wiz_sort'));
48  if ($GLOBALS['BE_USER']->workspace === 0) {
49  $theCode = '';
50  // Check if user has modify permissions to
51  $sys_pages = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
52  $sortByField = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('sortByField');
53  if ($sortByField) {
54  $menuItems = array();
55  if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList('title,subtitle,crdate,tstamp', $sortByField)) {
56  $menuItems = $sys_pages->getMenu($this->pObj->id, 'uid,pid,title', $sortByField, '', FALSE);
57  } elseif ($sortByField == 'REV') {
58  $menuItems = $sys_pages->getMenu($this->pObj->id, 'uid,pid,title', 'sorting', '', FALSE);
59  $menuItems = array_reverse($menuItems);
60  }
61  if (count($menuItems)) {
62  $tce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
63  $tce->stripslashes_values = 0;
64  $menuItems = array_reverse($menuItems);
65  $cmd = array();
66  foreach ($menuItems as $r) {
67  $cmd['pages'][$r['uid']]['move'] = $this->pObj->id;
68  }
69  $tce->start(array(), $cmd);
70  $tce->process_cmdmap();
71  BackendUtility::setUpdateSignal('updatePageTree');
72  }
73  }
74  $menuItems = $sys_pages->getMenu($this->pObj->id, '*', 'sorting', '', FALSE);
75 
76  if (count($menuItems)) {
77  $lines = array();
78  $lines[] = '<thead><tr>';
79  $lines[] = '<th>' . $this->wiz_linkOrder($GLOBALS['LANG']->getLL('wiz_changeOrder_title'), 'title') . '</th>';
80  $lines[] = '<th> ' . $this->wiz_linkOrder($GLOBALS['LANG']->getLL('wiz_changeOrder_subtitle'), 'subtitle') . '</th>';
81  $lines[] = '<th>' . $this->wiz_linkOrder($GLOBALS['LANG']->getLL('wiz_changeOrder_tChange'), 'tstamp') . '</th>';
82  $lines[] = '<th>' . $this->wiz_linkOrder($GLOBALS['LANG']->getLL('wiz_changeOrder_tCreate'), 'crdate') . '</th>';
83  $lines[] = '</tr></thead>';
84 
85  foreach ($menuItems as $rec) {
86  $m_perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(2);
87  // edit permissions for that page!
88  $pRec = BackendUtility::getRecord('pages', $rec['uid'], 'uid', ' AND ' . $m_perms_clause);
89  $lines[] = '<tr class="db_list_normal"><td nowrap="nowrap">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord('pages', $rec) . (!is_array($pRec) ? $GLOBALS['TBE_TEMPLATE']->rfw('<strong>' . $GLOBALS['LANG']->getLL('wiz_W', TRUE) . '</strong> ') : '') . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($rec['title'], $GLOBALS['BE_USER']->uc['titleLen'])) . '</td>
90  <td nowrap="nowrap">' . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($rec['subtitle'], $GLOBALS['BE_USER']->uc['titleLen'])) . '</td>
91  <td nowrap="nowrap">' . BackendUtility::datetime($rec['tstamp']) . '</td>
92  <td nowrap="nowrap">' . BackendUtility::datetime($rec['crdate']) . '</td>
93  </tr>';
94  }
95  $theCode .= '<h2>' . $GLOBALS['LANG']->getLL('wiz_currentPageOrder', TRUE) . '</h2>';
96  $theCode .= '<table class="t3-table">' . implode('', $lines) . '</table>';
97 
98  // Menu:
99  $lines = array();
100  $lines[] = $this->wiz_linkOrder($GLOBALS['LANG']->getLL('wiz_changeOrder_title'), 'title');
101  $lines[] = $this->wiz_linkOrder($GLOBALS['LANG']->getLL('wiz_changeOrder_subtitle'), 'subtitle');
102  $lines[] = $this->wiz_linkOrder($GLOBALS['LANG']->getLL('wiz_changeOrder_tChange'), 'tstamp');
103  $lines[] = $this->wiz_linkOrder($GLOBALS['LANG']->getLL('wiz_changeOrder_tCreate'), 'crdate');
104  $lines[] = '';
105  $lines[] = $this->wiz_linkOrder($GLOBALS['LANG']->getLL('wiz_changeOrder_REVERSE'), 'REV');
106  $theCode .= '<h4>' . $GLOBALS['LANG']->getLL('wiz_changeOrder') . '</h4>' . implode('<br />', $lines);
107  } else {
108  $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $GLOBALS['LANG']->getLL('no_subpages'), '', \TYPO3\CMS\Core\Messaging\FlashMessage::NOTICE);
109  $theCode .= $flashMessage->render();
110  }
111  // CSH:
112  $theCode .= BackendUtility::cshItem('_MOD_web_func', 'tx_wizardsortpages', $GLOBALS['BACK_PATH'], '<br />|');
113  $out .= $this->pObj->doc->section('', $theCode, 0, 1);
114  } else {
115  $out .= $this->pObj->doc->section('', 'Sorry, this function is not available in the current draft workspace!', 0, 1, 1);
116  }
117  return $out;
118  }
119 
128  public function wiz_linkOrder($title, $order) {
129  return '<a class="t3-link" href="' . htmlspecialchars(
130  BackendUtility::getModuleUrl('web_func',
131  array(
132  'id' => $GLOBALS['SOBE']->id,
133  'sortByField' => $order
134  )
135  )
136  ) . '" onclick="return confirm(' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($GLOBALS['LANG']->getLL('wiz_changeOrder_msg1')) . ')">' . htmlspecialchars($title) . '</a>';
137  }
138 
139 }
static cshItem($table, $field, $BACK_PATH, $wrap='', $onlyIconMode=FALSE, $styleAttrib='')
static getSpriteIconForRecord($table, array $row, array $options=array())
static getModuleUrl($moduleName, $urlParameters=array(), $backPathOverride=FALSE, $returnAbsoluteUrl=FALSE)
static setUpdateSignal($set='', $params='')
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]