[TASK] Re-work/simplify copyright header in PHP files - Part 6
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / Controller / FileSystemNavigationFrameController.php
1 <?php
2 namespace TYPO3\CMS\Backend\Controller;
3
4 /**
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Backend\Utility\IconUtility;
18 use TYPO3\CMS\Core\Utility\GeneralUtility;
19
20 /**
21 * Main script class for rendering of the folder tree
22 *
23 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
24 */
25 class FileSystemNavigationFrameController {
26
27 // Internal, dynamic:
28 // Content accumulates in this variable.
29 /**
30 * @todo Define visibility
31 */
32 public $content;
33
34 /**
35 * @var \TYPO3\CMS\Filelist\FileListFolderTree $foldertree the folder tree object
36 * @todo Define visibility
37 */
38 public $foldertree;
39
40 /**
41 * document template object
42 *
43 * @var \TYPO3\CMS\Backend\Template\DocumentTemplate
44 * @todo Define visibility
45 */
46 public $doc;
47
48 /**
49 * @todo Define visibility
50 */
51 public $backPath;
52
53 // Internal, static: GPvar:
54 /**
55 * @todo Define visibility
56 */
57 public $currentSubScript;
58
59 /**
60 * @todo Define visibility
61 */
62 public $cMR;
63
64 /**
65 * @var array
66 */
67 protected $scopeData;
68
69 /**
70 * Constructor
71 */
72 public function __construct() {
73 $GLOBALS['SOBE'] = $this;
74 $GLOBALS['BACK_PATH'] = '';
75 $this->init();
76 }
77
78 /**
79 * Initialiation of the script class
80 *
81 * @return void
82 */
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
113 /**
114 * initialization for the visual parts of the class
115 * Use template rendering only if this is a non-AJAX call
116 *
117 * @return void
118 */
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
154 /**
155 * Main function, rendering the folder tree
156 *
157 * @return void
158 */
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
184 /**
185 * Outputting the accumulated content to screen
186 *
187 * @return void
188 */
189 public function printContent() {
190 echo $this->content;
191 }
192
193 /**
194 * Create the panel of buttons for submitting the form or otherwise perform operations.
195 *
196 * @return array All available buttons as an assoc. array
197 */
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 **********************************/
215 /**
216 * Makes the AJAX call to expand or collapse the foldertree.
217 * Called by typo3/ajax.php
218 *
219 * @param array $params Additional parameters (not used here)
220 * @param \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj The AjaxRequestHandler object of this request
221 * @return void
222 */
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 }