[TASK] Cleanup entry classes in typo3/ part2
[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 textfile 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 * Constructor
79 */
80 public function __construct() {
81 $GLOBALS['SOBE'] = $this;
82 $GLOBALS['BACK_PATH'] = '';
83 $this->init();
84 }
85
86 /**
87 * Initialiation of the script class
88 *
89 * @return void
90 */
91 protected function init() {
92 // Setting backPath
93 $this->backPath = $GLOBALS['BACK_PATH'];
94 // Setting GPvars:
95 $this->currentSubScript = GeneralUtility::_GP('currentSubScript');
96 $this->cMR = GeneralUtility::_GP('cMR');
97 // Create folder tree object:
98 /** @var $foldertree \TYPO3\CMS\Filelist\FileListFolderTree */
99 $this->foldertree = GeneralUtility::makeInstance('TYPO3\\CMS\\Filelist\\FileListFolderTree');
100 $this->foldertree->ext_IconMode = $GLOBALS['BE_USER']->getTSConfigVal('options.folderTree.disableIconLinkToContextmenu');
101 $this->foldertree->thisScript = 'alt_file_navframe.php';
102 }
103
104 /**
105 * initialization for the visual parts of the class
106 * Use template rendering only if this is a non-AJAX call
107 *
108 * @return void
109 */
110 public function initPage() {
111 // Setting highlight mode:
112 $this->doHighlight = !$GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.disableTitleHighlight');
113 // Create template object:
114 $this->doc = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
115 $this->doc->backPath = $GLOBALS['BACK_PATH'];
116 $this->doc->setModuleTemplate('EXT:backend/Resources/Private/Templates/alt_file_navframe.html');
117 $this->doc->showFlashMessages = FALSE;
118 // Adding javascript code for AJAX (prototype), drag&drop and the filetree as well as the click menu code
119 $this->doc->getDragDropCode('folders');
120 $this->doc->getContextMenuCode();
121 // Setting JavaScript for menu.
122 $this->doc->JScode .= $this->doc->wrapScriptTags(($this->currentSubScript ? 'top.currentSubScript=unescape("' . rawurlencode($this->currentSubScript) . '");' : '') . '
123
124 // setting prefs for foldertree
125 Tree.ajaxID = "SC_alt_file_navframe::expandCollapse";
126
127 // Function, loading the list frame from navigation tree:
128 function jumpTo(id, linkObj, highlightID, bank) {
129 var theUrl = top.TS.PATH_typo3 + top.currentSubScript ;
130 if (theUrl.indexOf("?") != -1) {
131 theUrl += "&id=" + id
132 } else {
133 theUrl += "?id=" + id
134 }
135 top.fsMod.currentBank = bank;
136 top.TYPO3.Backend.ContentContainer.setUrl(theUrl);
137
138 ' . ($this->doHighlight ? 'Tree.highlightActiveItem("file", highlightID + "_" + bank);' : '') . '
139 ' . (!$GLOBALS['CLIENT']['FORMSTYLE'] ? '' : 'if (linkObj) linkObj.blur(); ') . '
140 return false;
141 }
142 ' . ($this->cMR ? ' jumpTo(top.fsMod.recentIds[\'file\'],\'\');' : ''));
143 }
144
145 /**
146 * Main function, rendering the folder tree
147 *
148 * @return void
149 */
150 public function main() {
151 // Produce browse-tree:
152 $tree = $this->foldertree->getBrowsableTree();
153 // Outputting page tree:
154 $this->content .= $tree;
155 // Adding javascript for drag & drop activation and highlighting
156 $this->content .= $this->doc->wrapScriptTags('
157 ' . ($this->doHighlight ? 'Tree.highlightActiveItem("", top.fsMod.navFrameHighlightedID["file"]);' : '') . '
158 Tree.registerDragDropHandlers();');
159 // Setting up the buttons and markers for docheader
160 $docHeaderButtons = $this->getButtons();
161 $markers = array(
162 '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') . '" />',
163 'CONTENT' => $this->content
164 );
165 $subparts = array();
166 // Possible filter/search like in page tree
167 $subparts['###SECOND_ROW###'] = '';
168 // Build the <body> for the module
169 $this->content = $this->doc->startPage('TYPO3 Folder Tree');
170 $this->content .= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers, $subparts);
171 $this->content .= $this->doc->endPage();
172 $this->content = $this->doc->insertStylesAndJS($this->content);
173 }
174
175 /**
176 * Outputting the accumulated content to screen
177 *
178 * @return void
179 */
180 public function printContent() {
181 echo $this->content;
182 }
183
184 /**
185 * Create the panel of buttons for submitting the form or otherwise perform operations.
186 *
187 * @return array All available buttons as an assoc. array
188 */
189 protected function getButtons() {
190 $buttons = array(
191 'csh' => '',
192 'refresh' => ''
193 );
194 // Refresh
195 $buttons['refresh'] = '<a href="' . htmlspecialchars(GeneralUtility::getIndpEnv('REQUEST_URI')) . '">' . IconUtility::getSpriteIcon('actions-system-refresh') . '</a>';
196 // CSH
197 $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']));
198 return $buttons;
199 }
200
201 /**********************************
202 *
203 * AJAX Calls
204 *
205 **********************************/
206 /**
207 * Makes the AJAX call to expand or collapse the foldertree.
208 * Called by typo3/ajax.php
209 *
210 * @param array $params Additional parameters (not used here)
211 * @param \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj The AjaxRequestHandler object of this request
212 * @return void
213 */
214 public function ajaxExpandCollapse($params, $ajaxObj) {
215 $this->init();
216 $tree = $this->foldertree->getBrowsableTree();
217 if ($this->foldertree->getAjaxStatus() === FALSE) {
218 $ajaxObj->setError($tree);
219 } else {
220 $ajaxObj->addContent('tree', $tree);
221 }
222 }
223
224 }
225
226 ?>