TYPO3 CMS  TYPO3_6-2
FileSystemNavigationFrameController.php
Go to the documentation of this file.
1 <?php
3 
19 
26 
27  // Internal, dynamic:
28  // Content accumulates in this variable.
32  public $content;
33 
38  public $foldertree;
39 
46  public $doc;
47 
51  public $backPath;
52 
53  // Internal, static: GPvar:
58 
62  public $cMR;
63 
67  protected $scopeData;
68 
72  public function __construct() {
73  $GLOBALS['SOBE'] = $this;
74  $GLOBALS['BACK_PATH'] = '';
75  $this->init();
76  }
77 
83  protected function init() {
84  // Setting backPath
85  $this->backPath = $GLOBALS['BACK_PATH'];
86  // Setting GPvars:
87  $this->currentSubScript = GeneralUtility::_GP('currentSubScript');
88  $this->cMR = GeneralUtility::_GP('cMR');
89 
90  $scopeData = (string) GeneralUtility::_GP('scopeData');
91  $scopeHash = (string) GeneralUtility::_GP('scopeHash');
92 
93  if (!empty($scopeData) && GeneralUtility::hmac($scopeData) === $scopeHash) {
94  $this->scopeData = unserialize($scopeData);
95  }
96 
97  // Create folder tree object:
98  if (!empty($this->scopeData)) {
99  $this->foldertree = GeneralUtility::makeInstance($this->scopeData['class']);
100  $this->foldertree->thisScript = $this->scopeData['script'];
101  $this->foldertree->ext_noTempRecyclerDirs = $this->scopeData['ext_noTempRecyclerDirs'];
102  $GLOBALS['SOBE']->browser = new \stdClass();
103  $GLOBALS['SOBE']->browser->mode = $this->scopeData['browser']['mode'];
104  $GLOBALS['SOBE']->browser->act = $this->scopeData['browser']['act'];
105  } else {
106  $this->foldertree = GeneralUtility::makeInstance('TYPO3\\CMS\\Filelist\\FileListFolderTree');
107  $this->foldertree->thisScript = 'alt_file_navframe.php';
108  }
109 
110  $this->foldertree->ext_IconMode = $GLOBALS['BE_USER']->getTSConfigVal('options.folderTree.disableIconLinkToContextmenu');
111  }
112 
119  public function initPage() {
120  // Setting highlight mode:
121  $this->doHighlight = !$GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.disableTitleHighlight');
122  // Create template object:
123  $this->doc = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
124  $this->doc->backPath = $GLOBALS['BACK_PATH'];
125  $this->doc->setModuleTemplate('EXT:backend/Resources/Private/Templates/alt_file_navframe.html');
126  $this->doc->showFlashMessages = FALSE;
127  // Adding javascript code for AJAX (prototype), drag&drop and the filetree as well as the click menu code
128  $this->doc->getDragDropCode('folders');
129  $this->doc->getContextMenuCode();
130  // Setting JavaScript for menu.
131  $this->doc->JScode .= $this->doc->wrapScriptTags(($this->currentSubScript ? 'top.currentSubScript=unescape("' . rawurlencode($this->currentSubScript) . '");' : '') . '
132 
133  // setting prefs for foldertree
134  Tree.ajaxID = "SC_alt_file_navframe::expandCollapse";
135 
136  // Function, loading the list frame from navigation tree:
137  function jumpTo(id, linkObj, highlightID, bank) {
138  var theUrl = top.TS.PATH_typo3 + top.currentSubScript ;
139  if (theUrl.indexOf("?") != -1) {
140  theUrl += "&id=" + id
141  } else {
142  theUrl += "?id=" + id
143  }
144  top.fsMod.currentBank = bank;
145  top.TYPO3.Backend.ContentContainer.setUrl(theUrl);
146 
147  ' . ($this->doHighlight ? 'Tree.highlightActiveItem("file", highlightID + "_" + bank);' : '') . '
148  if (linkObj) { linkObj.blur(); }
149  return false;
150  }
151  ' . ($this->cMR ? ' jumpTo(top.fsMod.recentIds[\'file\'],\'\');' : ''));
152  }
153 
159  public function main() {
160  // Produce browse-tree:
161  $tree = $this->foldertree->getBrowsableTree();
162  // Outputting page tree:
163  $this->content .= $tree;
164  // Adding javascript for drag & drop activation and highlighting
165  $this->content .= $this->doc->wrapScriptTags('
166  ' . ($this->doHighlight ? 'Tree.highlightActiveItem("", top.fsMod.navFrameHighlightedID["file"]);' : '') . '
167  Tree.registerDragDropHandlers();');
168  // Setting up the buttons and markers for docheader
169  $docHeaderButtons = $this->getButtons();
170  $markers = array(
171  'IMG_RESET' => '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/close_gray.gif', ' width="16" height="16"') . ' id="treeFilterReset" alt="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.resetFilter') . '" ' . 'title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.resetFilter') . '" />',
172  'CONTENT' => $this->content
173  );
174  $subparts = array();
175  // Possible filter/search like in page tree
176  $subparts['###SECOND_ROW###'] = '';
177  // Build the <body> for the module
178  $this->content = $this->doc->startPage('TYPO3 Folder Tree');
179  $this->content .= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers, $subparts);
180  $this->content .= $this->doc->endPage();
181  $this->content = $this->doc->insertStylesAndJS($this->content);
182  }
183 
189  public function printContent() {
190  echo $this->content;
191  }
192 
198  protected function getButtons() {
199  $buttons = array(
200  'csh' => '',
201  'refresh' => ''
202  );
203  // Refresh
204  $buttons['refresh'] = '<a href="' . htmlspecialchars(GeneralUtility::getIndpEnv('REQUEST_URI')) . '">' . IconUtility::getSpriteIcon('actions-system-refresh') . '</a>';
205  // CSH
206  $buttons['csh'] = str_replace('typo3-csh-inline', 'typo3-csh-inline show-right', \TYPO3\CMS\Backend\Utility\BackendUtility::cshItem('xMOD_csh_corebe', 'filetree', $GLOBALS['BACK_PATH']));
207  return $buttons;
208  }
209 
210  /**********************************
211  *
212  * AJAX Calls
213  *
214  **********************************/
223  public function ajaxExpandCollapse($params, $ajaxObj) {
224  $this->init();
225  $tree = $this->foldertree->getBrowsableTree();
226  if ($this->foldertree->getAjaxStatus() === FALSE) {
227  $ajaxObj->setError($tree);
228  } else {
229  $ajaxObj->addContent('tree', $tree);
230  }
231  }
232 
233 }
static skinImg($backPath, $src, $wHattribs='', $outputMode=0)
static cshItem($table, $field, $BACK_PATH, $wrap='', $onlyIconMode=FALSE, $styleAttrib='')
static hmac($input, $additionalSecret='')
static getSpriteIcon($iconName, array $options=array(), array $overlays=array())
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