[CLEANUP] Remove outdated $CLIENT[FORMSTYLE]
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / Controller / FileSystemNavigationFrameController.php
1 <?php
2 namespace TYPO3\CMS\Backend\Controller;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 1999-2013 Kasper Skårhøj (kasperYYYY@typo3.com)
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the text file GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29
30 use TYPO3\CMS\Backend\Utility\IconUtility;
31 use TYPO3\CMS\Core\Utility\GeneralUtility;
32
33 /**
34 * Main script class for rendering of the folder tree
35 *
36 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
37 */
38 class FileSystemNavigationFrameController {
39
40 // Internal, dynamic:
41 // Content accumulates in this variable.
42 /**
43 * @todo Define visibility
44 */
45 public $content;
46
47 /**
48 * @var \TYPO3\CMS\Filelist\FileListFolderTree $foldertree the folder tree object
49 * @todo Define visibility
50 */
51 public $foldertree;
52
53 /**
54 * document template object
55 *
56 * @var \TYPO3\CMS\Backend\Template\DocumentTemplate
57 * @todo Define visibility
58 */
59 public $doc;
60
61 /**
62 * @todo Define visibility
63 */
64 public $backPath;
65
66 // Internal, static: GPvar:
67 /**
68 * @todo Define visibility
69 */
70 public $currentSubScript;
71
72 /**
73 * @todo Define visibility
74 */
75 public $cMR;
76
77 /**
78 * @var array
79 */
80 protected $scopeData;
81
82 /**
83 * Constructor
84 */
85 public function __construct() {
86 $GLOBALS['SOBE'] = $this;
87 $GLOBALS['BACK_PATH'] = '';
88 $this->init();
89 }
90
91 /**
92 * Initialiation of the script class
93 *
94 * @return void
95 */
96 protected function init() {
97 // Setting backPath
98 $this->backPath = $GLOBALS['BACK_PATH'];
99 // Setting GPvars:
100 $this->currentSubScript = GeneralUtility::_GP('currentSubScript');
101 $this->cMR = GeneralUtility::_GP('cMR');
102
103 $scopeData = (string) GeneralUtility::_GP('scopeData');
104 $scopeHash = (string) GeneralUtility::_GP('scopeHash');
105
106 if (!empty($scopeData) && GeneralUtility::hmac($scopeData) === $scopeHash) {
107 $this->scopeData = unserialize($scopeData);
108 }
109
110 // Create folder tree object:
111 if (!empty($this->scopeData)) {
112 $this->foldertree = GeneralUtility::makeInstance($this->scopeData['class']);
113 $this->foldertree->thisScript = $this->scopeData['script'];
114 $this->foldertree->ext_noTempRecyclerDirs = $this->scopeData['ext_noTempRecyclerDirs'];
115 $GLOBALS['SOBE']->browser = new \stdClass();
116 $GLOBALS['SOBE']->browser->mode = $this->scopeData['browser']['mode'];
117 $GLOBALS['SOBE']->browser->act = $this->scopeData['browser']['act'];
118 } else {
119 $this->foldertree = GeneralUtility::makeInstance('TYPO3\\CMS\\Filelist\\FileListFolderTree');
120 $this->foldertree->thisScript = 'alt_file_navframe.php';
121 }
122
123 $this->foldertree->ext_IconMode = $GLOBALS['BE_USER']->getTSConfigVal('options.folderTree.disableIconLinkToContextmenu');
124 }
125
126 /**
127 * initialization for the visual parts of the class
128 * Use template rendering only if this is a non-AJAX call
129 *
130 * @return void
131 */
132 public function initPage() {
133 // Setting highlight mode:
134 $this->doHighlight = !$GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.disableTitleHighlight');
135 // Create template object:
136 $this->doc = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
137 $this->doc->backPath = $GLOBALS['BACK_PATH'];
138 $this->doc->setModuleTemplate('EXT:backend/Resources/Private/Templates/alt_file_navframe.html');
139 $this->doc->showFlashMessages = FALSE;
140 // Adding javascript code for AJAX (prototype), drag&drop and the filetree as well as the click menu code
141 $this->doc->getDragDropCode('folders');
142 $this->doc->getContextMenuCode();
143 // Setting JavaScript for menu.
144 $this->doc->JScode .= $this->doc->wrapScriptTags(($this->currentSubScript ? 'top.currentSubScript=unescape("' . rawurlencode($this->currentSubScript) . '");' : '') . '
145
146 // setting prefs for foldertree
147 Tree.ajaxID = "SC_alt_file_navframe::expandCollapse";
148
149 // Function, loading the list frame from navigation tree:
150 function jumpTo(id, linkObj, highlightID, bank) {
151 var theUrl = top.TS.PATH_typo3 + top.currentSubScript ;
152 if (theUrl.indexOf("?") != -1) {
153 theUrl += "&id=" + id
154 } else {
155 theUrl += "?id=" + id
156 }
157 top.fsMod.currentBank = bank;
158 top.TYPO3.Backend.ContentContainer.setUrl(theUrl);
159
160 ' . ($this->doHighlight ? 'Tree.highlightActiveItem("file", highlightID + "_" + bank);' : '') . '
161 if (linkObj) { linkObj.blur(); }
162 return false;
163 }
164 ' . ($this->cMR ? ' jumpTo(top.fsMod.recentIds[\'file\'],\'\');' : ''));
165 }
166
167 /**
168 * Main function, rendering the folder tree
169 *
170 * @return void
171 */
172 public function main() {
173 // Produce browse-tree:
174 $tree = $this->foldertree->getBrowsableTree();
175 // Outputting page tree:
176 $this->content .= $tree;
177 // Adding javascript for drag & drop activation and highlighting
178 $this->content .= $this->doc->wrapScriptTags('
179 ' . ($this->doHighlight ? 'Tree.highlightActiveItem("", top.fsMod.navFrameHighlightedID["file"]);' : '') . '
180 Tree.registerDragDropHandlers();');
181 // Setting up the buttons and markers for docheader
182 $docHeaderButtons = $this->getButtons();
183 $markers = array(
184 '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') . '" />',
185 'CONTENT' => $this->content
186 );
187 $subparts = array();
188 // Possible filter/search like in page tree
189 $subparts['###SECOND_ROW###'] = '';
190 // Build the <body> for the module
191 $this->content = $this->doc->startPage('TYPO3 Folder Tree');
192 $this->content .= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers, $subparts);
193 $this->content .= $this->doc->endPage();
194 $this->content = $this->doc->insertStylesAndJS($this->content);
195 }
196
197 /**
198 * Outputting the accumulated content to screen
199 *
200 * @return void
201 */
202 public function printContent() {
203 echo $this->content;
204 }
205
206 /**
207 * Create the panel of buttons for submitting the form or otherwise perform operations.
208 *
209 * @return array All available buttons as an assoc. array
210 */
211 protected function getButtons() {
212 $buttons = array(
213 'csh' => '',
214 'refresh' => ''
215 );
216 // Refresh
217 $buttons['refresh'] = '<a href="' . htmlspecialchars(GeneralUtility::getIndpEnv('REQUEST_URI')) . '">' . IconUtility::getSpriteIcon('actions-system-refresh') . '</a>';
218 // CSH
219 $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']));
220 return $buttons;
221 }
222
223 /**********************************
224 *
225 * AJAX Calls
226 *
227 **********************************/
228 /**
229 * Makes the AJAX call to expand or collapse the foldertree.
230 * Called by typo3/ajax.php
231 *
232 * @param array $params Additional parameters (not used here)
233 * @param \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj The AjaxRequestHandler object of this request
234 * @return void
235 */
236 public function ajaxExpandCollapse($params, $ajaxObj) {
237 $this->init();
238 $tree = $this->foldertree->getBrowsableTree();
239 if ($this->foldertree->getAjaxStatus() === FALSE) {
240 $ajaxObj->setError($tree);
241 } else {
242 $ajaxObj->addContent('tree', $tree);
243 }
244 }
245
246 }