TYPO3 CMS  TYPO3_6-2
PageTreeNavigationController.php
Go to the documentation of this file.
1 <?php
3 
20 
27 
28  // Internal:
32  public $content;
33 
37  public $pagetree;
38 
45  public $doc;
46 
47  // Temporary mount point (record), if any
52 
56  public $backPath;
57 
58  // Internal, static: GPvar:
63 
67  public $cMR;
68 
69  // If not '' (blank) then it will clear (0) or set (>0) Temporary DB mount.
74 
78  public $template;
79 
80  // Depends on userTS-setting
84  public $hasFilterBox;
85 
89  public function __construct() {
90  $GLOBALS['SOBE'] = $this;
91  $GLOBALS['BACK_PATH'] = '';
92 
93  $this->init();
94  }
95 
101  protected function init() {
102  // Setting backPath
103  $this->backPath = $GLOBALS['BACK_PATH'];
104  // Setting GPvars:
105  $this->cMR = GeneralUtility::_GP('cMR');
106  $this->currentSubScript = GeneralUtility::_GP('currentSubScript');
107  $this->setTempDBmount = GeneralUtility::_GP('setTempDBmount');
108  // look for User setting
109  $this->hasFilterBox = !$GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.hideFilter');
110  // Create page tree object:
111  $this->pagetree = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\View\\PageTreeView');
112  $this->pagetree->ext_IconMode = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.disableIconLinkToContextmenu');
113  $this->pagetree->ext_showPageId = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showPageIdWithTitle');
114  $this->pagetree->ext_showNavTitle = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showNavTitle');
115  $this->pagetree->ext_separateNotinmenuPages = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.separateNotinmenuPages');
116  $this->pagetree->ext_alphasortNotinmenuPages = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.alphasortNotinmenuPages');
117  $this->pagetree->thisScript = 'alt_db_navframe.php';
118  $this->pagetree->addField('alias');
119  $this->pagetree->addField('shortcut');
120  $this->pagetree->addField('shortcut_mode');
121  $this->pagetree->addField('mount_pid');
122  $this->pagetree->addField('mount_pid_ol');
123  $this->pagetree->addField('nav_hide');
124  $this->pagetree->addField('nav_title');
125  $this->pagetree->addField('url');
126  // Temporary DB mounts:
128  }
129 
136  public function initPage() {
137  // Setting highlight mode:
138  $this->doHighlight = !$GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.disableTitleHighlight');
139  // If highlighting is active, define the CSS class for the active item depending on the workspace
140  if ($this->doHighlight) {
141  $hlClass = $GLOBALS['BE_USER']->workspace === 0 ? 'active' : 'active active-ws wsver' . $GLOBALS['BE_USER']->workspace;
142  }
143  // Create template object:
144  $this->doc = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
145  $this->doc->backPath = $GLOBALS['BACK_PATH'];
146  $this->doc->setModuleTemplate('EXT:backend/Resources/Private/Templates/alt_db_navframe.html');
147  $this->doc->showFlashMessages = FALSE;
148  // Get HTML-Template
149  // Adding javascript code for AJAX (prototype), drag&drop and the pagetree as well as the click menu code
150  $this->doc->getDragDropCode('pages');
151  $this->doc->getContextMenuCode();
153  $pageRenderer = $this->doc->getPageRenderer();
154  $pageRenderer->loadScriptaculous('effects');
155  $pageRenderer->loadExtJS();
156  if ($this->hasFilterBox) {
157  $pageRenderer->addJsFile('sysext/backend/Resources/Public/JavaScript/pagetreefiltermenu.js');
158  }
159  $this->doc->JScode .= $this->doc->wrapScriptTags(($this->currentSubScript ? 'top.currentSubScript=unescape("' . rawurlencode($this->currentSubScript) . '");' : '') . '
160  // setting prefs for pagetree and drag & drop
161  ' . ($this->doHighlight ? 'Tree.highlightClass = "' . $hlClass . '";' : '') . '
162 
163  // Function, loading the list frame from navigation tree:
164  function jumpTo(id, linkObj, highlightID, bank) { //
165  var theUrl = top.TS.PATH_typo3 + top.currentSubScript ;
166  if (theUrl.indexOf("?") != -1) {
167  theUrl += "&id=" + id
168  } else {
169  theUrl += "?id=" + id
170  }
171  top.fsMod.currentBank = bank;
172  top.TYPO3.Backend.ContentContainer.setUrl(theUrl);
173 
174  ' . ($this->doHighlight ? 'Tree.highlightActiveItem("web", highlightID + "_" + bank);' : '') . '
175  if (linkObj) { linkObj.blur(); }
176  return false;
177  }
178  ' . ($this->cMR ? 'jumpTo(top.fsMod.recentIds[\'web\'],\'\');' : '') . ($this->hasFilterBox ? 'var TYPO3PageTreeFilter = new PageTreeFilter();' : '') . '
179 
180  ');
181  $this->doc->bodyTagId = 'typo3-pagetree';
182  }
183 
189  public function main() {
190  // Produce browse-tree:
191  $tree = $this->pagetree->getBrowsableTree();
192  // Outputting Temporary DB mount notice:
193  if ($this->active_tempMountPoint) {
194  $flashText = '
195  <a href="' . htmlspecialchars(GeneralUtility::linkThisScript(array('setTempDBmount' => 0))) . '">' . $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_core.xlf:labels.temporaryDBmount', TRUE) . '</a> <br />' . $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_core.xlf:labels.path', TRUE) . ': <span title="' . htmlspecialchars($this->active_tempMountPoint['_thePathFull']) . '">' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($this->active_tempMountPoint['_thePath'], -50)) . '</span>
196  ';
197  $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $flashText, '', \TYPO3\CMS\Core\Messaging\FlashMessage::INFO);
198  $this->content .= $flashMessage->render();
199  }
200  // Outputting page tree:
201  $this->content .= '<div id="PageTreeDiv">' . $tree . '</div>';
202  // Adding javascript for drag & drop activation and highlighting
203  $this->content .= $this->doc->wrapScriptTags('
204  ' . ($this->doHighlight ? 'Tree.highlightActiveItem("",top.fsMod.navFrameHighlightedID["web"]);' : '') . '
205  Tree.registerDragDropHandlers();');
206  // Setting up the buttons and markers for docheader
207  $docHeaderButtons = $this->getButtons();
208  $markers = array(
209  'IMG_RESET' => IconUtility::getSpriteIcon('actions-document-close', array(
210  'id' => 'treeFilterReset',
211  'alt' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.resetFilter'),
212  'title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.resetFilter')
213  )),
214  'WORKSPACEINFO' => $this->getWorkspaceInfo(),
215  'CONTENT' => $this->content
216  );
217  $subparts = array();
218  if (!$this->hasFilterBox) {
219  $subparts['###SECOND_ROW###'] = '';
220  }
221  // Build the <body> for the module
222  $this->content = $this->doc->startPage('TYPO3 Page Tree');
223  $this->content .= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers, $subparts);
224  $this->content .= $this->doc->endPage();
225  $this->content = $this->doc->insertStylesAndJS($this->content);
226  }
227 
233  public function printContent() {
234  echo $this->content;
235  }
236 
242  protected function getButtons() {
243  $buttons = array(
244  'csh' => '',
245  'new_page' => '',
246  'refresh' => '',
247  'filter' => ''
248  );
249  // New Page
250  $onclickNewPageWizard = 'top.content.list_frame.location.href=top.TS.PATH_typo3+\'db_new.php?pagesOnly=1&amp;id=\'+Tree.pageID;';
251  $buttons['new_page'] = '<a href="#" onclick="' . $onclickNewPageWizard . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:cms/layout/locallang.xlf:newPage', TRUE) . '">' . IconUtility::getSpriteIcon('actions-page-new') . '</a>';
252  // Refresh
253  $buttons['refresh'] = '<a href="' . htmlspecialchars(GeneralUtility::getIndpEnv('REQUEST_URI')) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.refresh', TRUE) . '">' . IconUtility::getSpriteIcon('actions-system-refresh') . '</a>';
254  // CSH
255  $buttons['csh'] = str_replace('typo3-csh-inline', 'typo3-csh-inline show-right', BackendUtility::cshItem('xMOD_csh_corebe', 'pagetree', $GLOBALS['BACK_PATH'], '', TRUE));
256  // Filter
257  if ($this->hasFilterBox) {
258  $buttons['filter'] = '<a href="#" id="tree-toolbar-filter-item">' . IconUtility::getSpriteIcon('actions-system-tree-search-open', array('title' => $GLOBALS['LANG']->sL('LLL:EXT:cms/layout/locallang.xlf:labels.filter', TRUE))) . '</a>';
259  }
260  return $buttons;
261  }
262 
268  protected function getWorkspaceInfo() {
269  if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('workspaces') && ($GLOBALS['BE_USER']->workspace !== 0 || $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.onlineWorkspaceInfo'))) {
270  $wsTitle = htmlspecialchars(\TYPO3\CMS\Workspaces\Service\WorkspaceService::getWorkspaceTitle($GLOBALS['BE_USER']->workspace));
271  $workspaceInfo = '
272  <div class="bgColor4 workspace-info">' . IconUtility::getSpriteIcon('apps-toolbar-menu-workspace', array(
273  'title' => $wsTitle,
274  'onclick' => 'top.goToModule(\'web_WorkspacesWorkspaces\');',
275  'style' => 'cursor:pointer;'
276  )) . $wsTitle . '</div>
277  ';
278  }
279  return $workspaceInfo;
280  }
281 
282  /**********************************
283  *
284  * Temporary DB mounts
285  *
286  **********************************/
293  public function initializeTemporaryDBmount() {
294  // Set/Cancel Temporary DB Mount:
295  if (strlen($this->setTempDBmount)) {
296  $set = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->setTempDBmount, 0);
297  if ($set > 0 && $GLOBALS['BE_USER']->isInWebMount($set)) {
298  // Setting...:
299  $this->settingTemporaryMountPoint($set);
300  } else {
301  // Clear:
302  $this->settingTemporaryMountPoint(0);
303  }
304  }
305  // Getting temporary mount point ID:
306  $temporaryMountPoint = (int)$GLOBALS['BE_USER']->getSessionData('pageTree_temporaryMountPoint');
307  // If mount point ID existed and is within users real mount points, then set it temporarily:
308  if ($temporaryMountPoint > 0 && $GLOBALS['BE_USER']->isInWebMount($temporaryMountPoint)) {
309  if ($this->active_tempMountPoint = BackendUtility::readPageAccess($temporaryMountPoint, $GLOBALS['BE_USER']->getPagePermsClause(1))) {
310  $this->pagetree->MOUNTS = array($temporaryMountPoint);
311  } else {
312  // Clear temporary mount point as we have no access to it any longer
313  $this->settingTemporaryMountPoint(0);
314  }
315  }
316  }
317 
325  public function settingTemporaryMountPoint($pageId) {
326  $GLOBALS['BE_USER']->setAndSaveSessionData('pageTree_temporaryMountPoint', (int)$pageId);
327  }
328 
329  /**********************************
330  *
331  * AJAX Calls
332  *
333  **********************************/
342  public function ajaxExpandCollapse($params, $ajaxObj) {
343  $this->init();
344  $tree = $this->pagetree->getBrowsableTree();
345  if (!$this->pagetree->ajaxStatus) {
346  $ajaxObj->setError($tree);
347  } else {
348  $ajaxObj->addContent('tree', $tree);
349  }
350  }
351 
352 }
static readPageAccess($id, $perms_clause)
static forceIntegerInRange($theInt, $min, $max=2000000000, $defaultValue=0)
Definition: MathUtility.php:32
static cshItem($table, $field, $BACK_PATH, $wrap='', $onlyIconMode=FALSE, $styleAttrib='')
static linkThisScript(array $getParams=array())
static getSpriteIcon($iconName, array $options=array(), array $overlays=array())
static fixed_lgd_cs($string, $chars, $appendString='...')
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
if($ajaxRegistryEntry !==NULL) $ajaxObj
Definition: ajax.php:63