[BUGFIX] Wrong icon in db_new tree
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / Controller / FileSystemNavigationFrameController.php
1 <?php
2 namespace TYPO3\CMS\Backend\Controller;
3
4 /**
5 * Main script class for rendering of the folder tree
6 *
7 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
8 * @package TYPO3
9 * @subpackage core
10 */
11 class FileSystemNavigationFrameController {
12
13 // Internal, dynamic:
14 // Content accumulates in this variable.
15 /**
16 * @todo Define visibility
17 */
18 public $content;
19
20 /**
21 * @var \TYPO3\CMS\Filelist\FileListFolderTree $foldertree the folder tree object
22 * @todo Define visibility
23 */
24 public $foldertree;
25
26 /**
27 * document template object
28 *
29 * @var \TYPO3\CMS\Backend\Template\DocumentTemplate
30 * @todo Define visibility
31 */
32 public $doc;
33
34 /**
35 * @todo Define visibility
36 */
37 public $backPath;
38
39 // Internal, static: GPvar:
40 /**
41 * @todo Define visibility
42 */
43 public $currentSubScript;
44
45 /**
46 * @todo Define visibility
47 */
48 public $cMR;
49
50 /**
51 * Initialiation of the script class
52 *
53 * @return void
54 * @todo Define visibility
55 */
56 public function init() {
57 // Setting backPath
58 $this->backPath = $GLOBALS['BACK_PATH'];
59 // Setting GPvars:
60 $this->currentSubScript = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('currentSubScript');
61 $this->cMR = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('cMR');
62 // Create folder tree object:
63 /** @var $foldertree \TYPO3\CMS\Filelist\FileListFolderTree */
64 $this->foldertree = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Filelist\\FileListFolderTree');
65 $this->foldertree->ext_IconMode = $GLOBALS['BE_USER']->getTSConfigVal('options.folderTree.disableIconLinkToContextmenu');
66 $this->foldertree->thisScript = 'alt_file_navframe.php';
67 }
68
69 /**
70 * initialization for the visual parts of the class
71 * Use template rendering only if this is a non-AJAX call
72 *
73 * @return void
74 */
75 public function initPage() {
76 // Setting highlight mode:
77 $this->doHighlight = !$GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.disableTitleHighlight');
78 // Create template object:
79 $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
80 $this->doc->backPath = $GLOBALS['BACK_PATH'];
81 $this->doc->setModuleTemplate('templates/alt_file_navframe.html');
82 $this->doc->showFlashMessages = FALSE;
83 // Adding javascript code for AJAX (prototype), drag&drop and the filetree as well as the click menu code
84 $this->doc->getDragDropCode('folders');
85 $this->doc->getContextMenuCode();
86 // Setting JavaScript for menu.
87 $this->doc->JScode .= $this->doc->wrapScriptTags((((((((((((($this->currentSubScript ? ('top.currentSubScript=unescape("' . rawurlencode($this->currentSubScript)) . '");' : '') . '
88
89 function initFlashUploader(path) {
90 path = decodeURIComponent(path);
91 var flashUploadOptions = {
92 uploadURL: top.TS.PATH_typo3 + "ajax.php",
93 uploadFileSizeLimit: "') . \TYPO3\CMS\Core\Utility\GeneralUtility::getMaxUploadFileSize()) . '",
94 uploadFileTypes: {
95 allow: "') . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']['webspace']['allow']) . '",
96 deny: "') . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']['webspace']['deny']) . '"
97 },
98 uploadFilePostName: "upload_1",
99 uploadPostParams: {
100 "file[upload][1][target]": path,
101 "file[upload][1][data]": 1,
102 "file[upload][1][charset]": "utf-8",
103 "ajaxID": "TYPO3\\CMS\\Backend\\Controller\\File\\FileController::process"
104 }
105 };
106
107 // get the flashUploaderWindow instance from the parent frame
108 var flashUploader = top.TYPO3.FileUploadWindow.getInstance(flashUploadOptions);
109 // add an additional function inside the container to show the checkbox option
110 var infoComponent = new top.Ext.Panel({
111 autoEl: { tag: "div" },
112 height: "auto",
113 bodyBorder: false,
114 border: false,
115 hideBorders: true,
116 cls: "t3-upload-window-infopanel",
117 id: "t3-upload-window-infopanel-addition",
118 html: \'<label for="overrideExistingFilesCheckbox"><input id="overrideExistingFilesCheckbox" type="checkbox" onclick="setFlashPostOptionOverwriteExistingFiles(this);" />\' + top.String.format(top.TYPO3.LLL.fileUpload.infoComponentOverrideFiles) + \'</label>\'
119 });
120 flashUploader.add(infoComponent);
121
122 // do a reload of this frame once all uploads are done
123 flashUploader.on("totalcomplete", function() {
124 jumpTo (top.rawurlencode(path), "", "", "");
125 });
126
127 // this is the callback function that delivers the additional post parameter to the flash application
128 top.setFlashPostOptionOverwriteExistingFiles = function(checkbox) {
129 var uploader = top.TYPO3.getInstance("FileUploadWindow");
130 if (uploader.isVisible()) {
131 uploader.swf.addPostParam("overwriteExistingFiles", (checkbox.checked == true ? 1 : 0));
132 }
133 };
134 }
135
136
137 // setting prefs for foldertree
138 Tree.ajaxID = "SC_alt_file_navframe::expandCollapse";
139
140 // Function, loading the list frame from navigation tree:
141 function jumpTo(id, linkObj, highlightID, bank) {
142 var theUrl = top.TS.PATH_typo3 + top.currentSubScript ;
143 if (theUrl.indexOf("?") != -1) {
144 theUrl += "&id=" + id
145 } else {
146 theUrl += "?id=" + id
147 }
148 top.fsMod.currentBank = bank;
149 top.TYPO3.Backend.ContentContainer.setUrl(theUrl);
150
151 ') . ($this->doHighlight ? 'Tree.highlightActiveItem("file", highlightID + "_" + bank);' : '')) . '
152 ') . (!$GLOBALS['CLIENT']['FORMSTYLE'] ? '' : 'if (linkObj) linkObj.blur(); ')) . '
153 return false;
154 }
155 ') . ($this->cMR ? ' jumpTo(top.fsMod.recentIds[\'file\'],\'\');' : ''));
156 }
157
158 /**
159 * Main function, rendering the folder tree
160 *
161 * @return void
162 * @todo Define visibility
163 */
164 public function main() {
165 // Produce browse-tree:
166 $tree = $this->foldertree->getBrowsableTree();
167 // Outputting page tree:
168 $this->content .= $tree;
169 // Adding javascript for drag & drop activation and highlighting
170 $this->content .= $this->doc->wrapScriptTags((('
171 ' . ($this->doHighlight ? 'Tree.highlightActiveItem("", top.fsMod.navFrameHighlightedID["file"]);' : '')) . '
172 ') . (!$this->doc->isCMlayers() ? 'Tree.activateDragDrop = false;' : 'Tree.registerDragDropHandlers();'));
173 // Setting up the buttons and markers for docheader
174 $docHeaderButtons = $this->getButtons();
175 $markers = array(
176 'IMG_RESET' => (((((('<img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/close_gray.gif', ' width="16" height="16"')) . ' id="treeFilterReset" alt="') . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.resetFilter')) . '" ') . 'title="') . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.resetFilter')) . '" />',
177 'CONTENT' => $this->content
178 );
179 $subparts = array();
180 // Possible filter/search like in page tree
181 $subparts['###SECOND_ROW###'] = '';
182 // Build the <body> for the module
183 $this->content = $this->doc->startPage('TYPO3 Folder Tree');
184 $this->content .= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers, $subparts);
185 $this->content .= $this->doc->endPage();
186 $this->content = $this->doc->insertStylesAndJS($this->content);
187 }
188
189 /**
190 * Outputting the accumulated content to screen
191 *
192 * @return void
193 * @todo Define visibility
194 */
195 public function printContent() {
196 echo $this->content;
197 }
198
199 /**
200 * Create the panel of buttons for submitting the form or otherwise perform operations.
201 *
202 * @return array All available buttons as an assoc. array
203 */
204 protected function getButtons() {
205 $buttons = array(
206 'csh' => '',
207 'refresh' => ''
208 );
209 // Refresh
210 $buttons['refresh'] = ((('<a href="' . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REQUEST_URI'))) . '">') . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-system-refresh')) . '</a>';
211 // CSH
212 $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']));
213 return $buttons;
214 }
215
216 /**********************************
217 *
218 * AJAX Calls
219 *
220 **********************************/
221 /**
222 * Makes the AJAX call to expand or collapse the foldertree.
223 * Called by typo3/ajax.php
224 *
225 * @param array $params Additional parameters (not used here)
226 * @param \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj The TYPO3AJAX object of this request
227 * @return void
228 */
229 public function ajaxExpandCollapse($params, $ajaxObj) {
230 $this->init();
231 $tree = $this->foldertree->getBrowsableTree();
232 if ($this->foldertree->getAjaxStatus() === FALSE) {
233 $ajaxObj->setError($tree);
234 } else {
235 $ajaxObj->addContent('tree', $tree);
236 }
237 }
238
239 }
240
241
242 ?>