TYPO3 CMS  TYPO3_6-2
ElementBrowserController.php
Go to the documentation of this file.
1 <?php
3 
23 
35  public $mode;
36 
45  public $browser;
46 
53  public $doc;
54 
58  public function __construct() {
59  $GLOBALS['SOBE'] = $this;
60  $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_browse_links.xlf');
61  $GLOBALS['BACK_PATH'] = '';
62 
63  $this->init();
64  }
65 
71  protected function init() {
72  // Find "mode"
73  $this->mode = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('mode');
74  if (!$this->mode) {
75  $this->mode = 'rte';
76  }
77  // Creating backend template object:
78  // this might not be needed but some classes refer to $GLOBALS['SOBE']->doc, so ...
79  $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
80  $this->doc->backPath = $GLOBALS['BACK_PATH'];
81  // Apply the same styles as those of the base script
82  $this->doc->bodyTagId = 'typo3-browse-links-php';
83 
84  }
85 
91  public function main() {
92  // Clear temporary DB mounts
93  $tmpMount = \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('setTempDBmount');
94  if (isset($tmpMount)) {
95  $GLOBALS['BE_USER']->setAndSaveSessionData('pageTree_temporaryMountPoint', (int)$tmpMount);
96  }
97  // Set temporary DB mounts
98  $tempDBmount = (int)$GLOBALS['BE_USER']->getSessionData('pageTree_temporaryMountPoint');
99  if ($tempDBmount) {
100  $altMountPoints = $tempDBmount;
101  }
102  if ($altMountPoints) {
103  $GLOBALS['BE_USER']->groupData['webmounts'] = implode(',', array_unique(\TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $altMountPoints)));
104  $GLOBALS['WEBMOUNTS'] = $GLOBALS['BE_USER']->returnWebmounts();
105  }
106  $this->content = '';
107  // Look for alternative mountpoints
108  switch ((string) $this->mode) {
109  case 'rte':
110  case 'db':
111  case 'wizard':
112  // Setting alternative browsing mounts (ONLY local to browse_links.php this script so they stay "read-only")
113  $altMountPoints = trim($GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.altElementBrowserMountPoints'));
114  if ($altMountPoints) {
115  $GLOBALS['BE_USER']->groupData['webmounts'] = implode(',', array_unique(\TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $altMountPoints)));
116  $GLOBALS['WEBMOUNTS'] = $GLOBALS['BE_USER']->returnWebmounts();
117  }
118  }
119  // Render type by user func
120  $browserRendered = FALSE;
121  if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/browse_links.php']['browserRendering'])) {
122  foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/browse_links.php']['browserRendering'] as $classRef) {
123  $browserRenderObj = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classRef);
124  if (is_object($browserRenderObj) && method_exists($browserRenderObj, 'isValid') && method_exists($browserRenderObj, 'render')) {
125  if ($browserRenderObj->isValid($this->mode, $this)) {
126  $this->content .= $browserRenderObj->render($this->mode, $this);
127  $browserRendered = TRUE;
128  break;
129  }
130  }
131  }
132  }
133  // if type was not rendered use default rendering functions
134  if (!$browserRendered) {
135  $this->browser = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Recordlist\\Browser\\ElementBrowser');
136  $this->browser->init();
137  $modData = $GLOBALS['BE_USER']->getModuleData('browse_links.php', 'ses');
138  list($modData, $store) = $this->browser->processSessionData($modData);
139  $GLOBALS['BE_USER']->pushModuleData('browse_links.php', $modData);
140  // Output the correct content according to $this->mode
141  switch ((string) $this->mode) {
142  case 'rte':
143  $this->content = $this->browser->main_rte();
144  break;
145  case 'db':
146  $this->content = $this->browser->main_db();
147  break;
148  case 'file':
149  case 'filedrag':
150  $this->content = $this->browser->main_file();
151  break;
152  case 'folder':
153  $this->content = $this->browser->main_folder();
154  break;
155  case 'wizard':
156  $this->content = $this->browser->main_rte(1);
157  break;
158  }
159  }
160  }
161 
167  public function printContent() {
168  echo $this->content;
169  }
170 
171 }
static intExplode($delimiter, $string, $removeEmptyValues=FALSE, $limit=0)
static getUserObj($classRef, $checkPrefix='', $silent=FALSE)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]