[CLEANUP] main_rte function of the ElementBrowser
[Packages/TYPO3.CMS.git] / typo3 / sysext / recordlist / Classes / Browser / ElementBrowser.php
1 <?php
2 namespace TYPO3\CMS\Recordlist\Browser;
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\Core\Resource\File;
18 use TYPO3\CMS\Core\Resource\Folder;
19 use TYPO3\CMS\Core\Utility\GeneralUtility;
20 use TYPO3\CMS\Backend\Utility\BackendUtility;
21 use TYPO3\CMS\Backend\Utility\IconUtility;
22
23 /**
24 * class for the Element Browser window.
25 *
26 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
27 */
28 class ElementBrowser {
29
30 /**
31 * Optional instance of a record list that TBE_expandPage() should
32 * use to render the records in a page
33 *
34 * @var \TYPO3\CMS\Backend\RecordList\ElementBrowserRecordList
35 */
36 protected $recordList = NULL;
37
38 /**
39 * Current site URL (Frontend)
40 *
41 * @var string
42 * @internal
43 */
44 public $siteURL;
45
46 /**
47 * the script to link to
48 *
49 * @todo Define visibility
50 */
51 public $thisScript;
52
53 /**
54 * RTE specific TSconfig
55 *
56 * @todo Define visibility
57 */
58 public $thisConfig;
59
60 /**
61 * Target (RTE specific)
62 *
63 * @todo Define visibility
64 */
65 public $setTarget;
66
67 /**
68 * CSS Class (RTE specific)
69 *
70 * @todo Define visibility
71 */
72 public $setClass;
73
74 /**
75 * title (RTE specific)
76 *
77 * @todo Define visibility
78 */
79 public $setTitle;
80
81 /**
82 * @todo Define visibility
83 */
84 public $setParams;
85
86 /**
87 * Backend template object
88 *
89 * @todo Define visibility
90 * @var \TYPO3\CMS\Backend\Template\DocumentTemplate
91 */
92 public $doc;
93
94 /**
95 * Holds information about files
96 *
97 * @todo Define visibility
98 */
99 public $elements = array();
100
101 /**
102 * The mode determines the main kind of output from the element browser.
103 * There are these options for values: rte, db, file, filedrag, wizard.
104 * "rte" will show the link selector for the Rich Text Editor (see main_rte())
105 * "db" will allow you to browse for pages or records in the page tree (for TCEforms, see main_db())
106 * "file"/"filedrag" will allow you to browse for files or folders in the folder mounts (for TCEforms, main_file())
107 * "wizard" will allow you to browse for links (like "rte") which are passed back to TCEforms (see main_rte(1))
108 *
109 * @see main()
110 * @todo Define visibility
111 * @var string
112 */
113 public $mode;
114
115 /**
116 * Link selector action.
117 * page,file,url,mail,spec are allowed values.
118 * These are only important with the link selector function and in that case they switch
119 * between the various menu options.
120 *
121 * @todo Define visibility
122 */
123 public $act;
124
125 /**
126 * When you click a page title/expand icon to see the content of a certain page, this
127 * value will contain that value (the ID of the expanded page). If the value is NOT set,
128 * then it will be restored from the module session data (see main(), mode="db")
129 *
130 * @todo Define visibility
131 */
132 public $expandPage;
133
134 /**
135 * When you click a folder name/expand icon to see the content of a certain file folder,
136 * this value will contain that value (the path of the expanded file folder). If the
137 * value is NOT set, then it will be restored from the module session data (see main(),
138 * mode="file"/"filedrag"). Example value: "/www/htdocs/typo3/32/3dsplm/fileadmin/css/"
139 *
140 * @todo Define visibility
141 * @var string
142 */
143 public $expandFolder;
144
145 /**
146 * the folder object of a parent folder that was selected
147 *
148 * @var Folder
149 */
150 protected $selectedFolder;
151
152 /**
153 * TYPO3 Element Browser, wizard mode parameters. There is a heap of parameters there,
154 * better debug() them out if you need something... :-)
155 *
156 * @todo Define visibility
157 * @var array
158 */
159 public $P;
160
161 /**
162 * Active with TYPO3 Element Browser: Contains the name of the form field for which this window
163 * opens - thus allows us to make references back to the main window in which the form is.
164 * Example value: "data[pages][39][bodytext]|||tt_content|"
165 * or "data[tt_content][NEW3fba56fde763d][image]|||gif,jpg,jpeg,tif,bmp,pcx,tga,png,pdf,ai|"
166 *
167 * Values:
168 * 0: form field name reference, eg. "data[tt_content][123][image]"
169 * 1: htmlArea RTE parameters: editorNo:contentTypo3Language:contentTypo3Charset
170 * 2: RTE config parameters: RTEtsConfigParams
171 * 3: allowed types. Eg. "tt_content" or "gif,jpg,jpeg,tif,bmp,pcx,tga,png,pdf,ai"
172 * 4: IRRE uniqueness: target level object-id to perform actions/checks on, eg. "data[79][tt_address][1][<field>][<foreign_table>]"
173 * 5: IRRE uniqueness: name of function in opener window that checks if element is already used, eg. "inline.checkUniqueElement"
174 * 6: IRRE uniqueness: name of function in opener window that performs some additional(!) action, eg. "inline.setUniqueElement"
175 * 7: IRRE uniqueness: name of function in opener window that performs action instead of using addElement/insertElement, eg. "inline.importElement"
176 *
177 * $pArr = explode('|', $this->bparams);
178 * $formFieldName = $pArr[0];
179 * $allowedTablesOrFileTypes = $pArr[3];
180 *
181 * @todo Define visibility
182 * @var string
183 */
184 public $bparams;
185
186 /**
187 * Used with the Rich Text Editor.
188 * Example value: "tt_content:NEW3fba58c969f5c:bodytext:23:text:23:"
189 *
190 * @todo Define visibility
191 * @var string
192 */
193 public $RTEtsConfigParams;
194
195 /**
196 * Plus/Minus icon value. Used by the tree class to open/close notes on the trees.
197 *
198 * @todo Define visibility
199 */
200 public $PM;
201
202 /**
203 * Pointer, used when browsing a long list of records etc.
204 *
205 * @todo Define visibility
206 */
207 public $pointer;
208
209 /**
210 * Used with the link selector: Contains the GET input information about the CURRENT link
211 * in the RTE/TCEform field. This consists of "href", "target" and "title" keys.
212 * This information is passed around in links.
213 *
214 * @todo Define visibility
215 * @var array
216 */
217 public $curUrlArray;
218
219 /**
220 * Used with the link selector: Contains a processed version of the input values from curUrlInfo.
221 * This is splitted into pageid, content element id, label value etc.
222 * This is used for the internal processing of that information.
223 *
224 * @todo Define visibility
225 * @var array
226 */
227 public $curUrlInfo;
228
229 /**
230 * array which holds hook objects (initialised in init())
231 * @var \TYPO3\CMS\Core\ElementBrowser\ElementBrowserHookInterface[]
232 */
233 protected $hookObjects = array();
234
235 /**
236 * @var \TYPO3\CMS\Core\Utility\File\BasicFileUtility
237 */
238 public $fileProcessor;
239
240 /**
241 * Sets the script url depending on being a module or script request
242 */
243 protected function determineScriptUrl() {
244 if ($moduleName = GeneralUtility::_GP('M')) {
245 $this->thisScript = BackendUtility::getModuleUrl($moduleName);
246 } else {
247 $this->thisScript = GeneralUtility::getIndpEnv('SCRIPT_NAME');
248 }
249 }
250
251 /**
252 * Calculate path to this script.
253 * This method is public, to be used in hooks of this class only.
254 *
255 * @return string
256 */
257 public function getThisScript() {
258 return strpos($this->thisScript, '?') === FALSE ? $this->thisScript . '?' : $this->thisScript . '&';
259 }
260
261 /**
262 * Constructor:
263 * Initializes a lot of variables, setting JavaScript functions in header etc.
264 *
265 * @return void
266 * @todo Define visibility
267 * @throws \UnexpectedValueException
268 */
269 public function init() {
270 $this->initVariables();
271
272 $this->RTEtsConfigParams = GeneralUtility::_GP('RTEtsConfigParams');
273 $this->initConfiguration();
274 $this->initDocumentTemplate();
275 // init hook objects:
276 $this->initHookObjects('typo3/class.browse_links.php');
277
278 $this->initCurrentUrl();
279
280 // Determine nature of current url:
281 $this->act = GeneralUtility::_GP('act');
282 if (!$this->act) {
283 $this->act = $this->curUrlInfo['act'];
284 }
285
286 // Initializing the target value (RTE)
287 $this->setTarget = $this->curUrlArray['target'] != '-' ? $this->curUrlArray['target'] : '';
288 if ($this->thisConfig['defaultLinkTarget'] && !isset($this->curUrlArray['target'])) {
289 $this->setTarget = $this->thisConfig['defaultLinkTarget'];
290 }
291 // Initializing the class value (RTE)
292 $this->setClass = $this->curUrlArray['class'] != '-' ? $this->curUrlArray['class'] : '';
293 // Initializing the title value (RTE)
294 $this->setTitle = $this->curUrlArray['title'] != '-' ? $this->curUrlArray['title'] : '';
295 // Initializing the params value
296 $this->setParams = $this->curUrlArray['params'] != '-' ? $this->curUrlArray['params'] : '';
297
298 // Finally, add the accumulated JavaScript to the template object:
299 // also unset the default jumpToUrl() function before
300 unset($this->doc->JScodeArray['jumpToUrl']);
301 $this->doc->JScode .= $this->doc->wrapScriptTags($this->getJSCode());
302 }
303
304 /**
305 * Initialize class variables
306 *
307 * @return void
308 */
309 public function initVariables() {
310 // Main GPvars:
311 $this->pointer = GeneralUtility::_GP('pointer');
312 $this->bparams = GeneralUtility::_GP('bparams');
313 $this->P = GeneralUtility::_GP('P');
314 $this->expandPage = GeneralUtility::_GP('expandPage');
315 $this->expandFolder = GeneralUtility::_GP('expandFolder');
316 $this->PM = GeneralUtility::_GP('PM');
317
318 // Site URL
319 // Current site url
320 $this->siteURL = GeneralUtility::getIndpEnv('TYPO3_SITE_URL');
321 $this->determineScriptUrl();
322
323 // Find "mode"
324 $this->mode = GeneralUtility::_GP('mode');
325 if (!$this->mode) {
326 $this->mode = 'rte';
327 }
328
329 // Init fileProcessor
330 $this->fileProcessor = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Utility\\File\\BasicFileUtility');
331 $this->fileProcessor->init(array(), $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
332 }
333
334 /**
335 * Initializes the configuration variables
336 *
337 * @return void
338 */
339 public function initConfiguration() {
340 // Rich Text Editor specific configuration:
341 if ((string) $this->mode === 'rte') {
342 $this->thisConfig = $this->getRTEConfig();
343 }
344 }
345
346 /**
347 * Initialize document template object
348 *
349 * @return void
350 */
351 protected function initDocumentTemplate() {
352 // Creating backend template object:
353 $this->doc = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
354 $this->doc->bodyTagId = 'typo3-browse-links-php';
355 $this->doc->backPath = $GLOBALS['BACK_PATH'];
356 // Load the Prototype library and browse_links.js
357 $this->doc->getPageRenderer()->loadPrototype();
358 $this->doc->loadJavascriptLib('js/browse_links.js');
359 $this->doc->loadJavascriptLib('js/tree.js');
360 }
361
362 /**
363 * Initialize hook objects implementing the interface
364 *
365 * @param string $hookKey the hook key
366 * @throws \UnexpectedValueException
367 * @return void
368 */
369 protected function initHookObjects($hookKey) {
370 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][$hookKey]['browseLinksHook'])) {
371 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][$hookKey]['browseLinksHook'] as $classData) {
372 $processObject = GeneralUtility::getUserObj($classData);
373 if (!$processObject instanceof \TYPO3\CMS\Core\ElementBrowser\ElementBrowserHookInterface) {
374 throw new \UnexpectedValueException('$processObject must implement interface TYPO3\\CMS\\Core\\ElementBrowser\\ElementBrowserHookInterface', 1195039394);
375 }
376 $parameters = array();
377 $processObject->init($this, $parameters);
378 $this->hookObjects[] = $processObject;
379 }
380 }
381 }
382
383 /**
384 * Initialize $this->curUrlArray and $this->curUrlInfo based on script parameters
385 *
386 * @return void
387 */
388 protected function initCurrentUrl() {
389 // CurrentUrl - the current link url must be passed around if it exists
390 if ($this->mode == 'wizard') {
391 $currentValues = GeneralUtility::trimExplode(LF, trim($this->P['currentValue']));
392 if (count($currentValues) > 0) {
393 $currentValue = array_pop($currentValues);
394 } else {
395 $currentValue = '';
396 }
397 $currentLinkParts = GeneralUtility::unQuoteFilenames($currentValue, TRUE);
398 $initialCurUrlArray = array(
399 'href' => $currentLinkParts[0],
400 'target' => $currentLinkParts[1],
401 'class' => $currentLinkParts[2],
402 'title' => $currentLinkParts[3],
403 'params' => $currentLinkParts[4]
404 );
405 $this->curUrlArray = is_array(GeneralUtility::_GP('curUrl'))
406 ? array_merge($initialCurUrlArray, GeneralUtility::_GP('curUrl'))
407 : $initialCurUrlArray;
408 // Additional fields for page links
409 if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['extendUrlArray'])
410 && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['extendUrlArray'])
411 ) {
412 $conf = array();
413 $_params = array(
414 'conf' => &$conf,
415 'linkParts' => $currentLinkParts
416 );
417 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['extendUrlArray'] as $objRef) {
418 $processor =& GeneralUtility::getUserObj($objRef);
419 $processor->extendUrlArray($_params, $this);
420 }
421 }
422 $this->curUrlInfo = $this->parseCurUrl($this->siteURL . '?id=' . $this->curUrlArray['href'], $this->siteURL);
423 // pageid == 0 means that this is not an internal (page) link
424 if ($this->curUrlInfo['pageid'] == 0 && $this->curUrlArray['href']) {
425 // Check if there is the FAL API
426 if (GeneralUtility::isFirstPartOfStr($this->curUrlArray['href'], 'file:')) {
427 $this->curUrlInfo = $this->parseCurUrl($this->curUrlArray['href'], $this->siteURL);
428 // Remove the "file:" prefix
429 $currentLinkParts[0] = rawurldecode(substr($this->curUrlArray['href'], 5));
430 } elseif (file_exists(PATH_site . rawurldecode($this->curUrlArray['href']))) {
431 if (GeneralUtility::isFirstPartOfStr($this->curUrlArray['href'], PATH_site)) {
432 $currentLinkParts[0] = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($this->curUrlArray['href']);
433 }
434 $this->curUrlInfo = $this->parseCurUrl($this->siteURL . $this->curUrlArray['href'], $this->siteURL);
435 } elseif (strstr($this->curUrlArray['href'], '@')) {
436 // check for email link
437 if (GeneralUtility::isFirstPartOfStr($this->curUrlArray['href'], 'mailto:')) {
438 $currentLinkParts[0] = substr($this->curUrlArray['href'], 7);
439 }
440 $this->curUrlInfo = $this->parseCurUrl('mailto:' . $this->curUrlArray['href'], $this->siteURL);
441 } else {
442 // nothing of the above. this is an external link
443 if (strpos($this->curUrlArray['href'], '://') === FALSE) {
444 $currentLinkParts[0] = 'http://' . $this->curUrlArray['href'];
445 }
446 $this->curUrlInfo = $this->parseCurUrl($currentLinkParts[0], $this->siteURL);
447 }
448 } elseif (!$this->curUrlArray['href']) {
449 $this->curUrlInfo = array();
450 $this->act = 'page';
451 } else {
452 $this->curUrlInfo = $this->parseCurUrl($this->siteURL . '?id=' . $this->curUrlArray['href'], $this->siteURL);
453 }
454 } else {
455 $this->curUrlArray = GeneralUtility::_GP('curUrl');
456 if ($this->curUrlArray['all']) {
457 $this->curUrlArray = GeneralUtility::get_tag_attributes($this->curUrlArray['all']);
458 }
459 $this->curUrlInfo = $this->parseCurUrl($this->curUrlArray['href'], $this->siteURL);
460 }
461 }
462
463 /**
464 * Get the RTE configuration from Page TSConfig
465 *
466 * @return array RTE configuration array
467 */
468 protected function getRTEConfig() {
469 $RTEtsConfigParts = explode(':', $this->RTEtsConfigParams);
470 $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE', BackendUtility::getPagesTSconfig($RTEtsConfigParts[5]));
471 return BackendUtility::RTEsetup($RTEsetup['properties'], $RTEtsConfigParts[0], $RTEtsConfigParts[2], $RTEtsConfigParts[4]);
472 }
473
474 /**
475 * Generate JS code to be used on the link insert/modify dialogue
476 *
477 * @return string the generated JS code
478 * @todo Define visibility
479 */
480 public function getJsCode() {
481 // Rich Text Editor specific configuration:
482 $addPassOnParams = '';
483 if ((string)$this->mode == 'rte') {
484 $addPassOnParams .= '&RTEtsConfigParams=' . rawurlencode($this->RTEtsConfigParams);
485 }
486 // BEGIN accumulation of header JavaScript:
487 $JScode = '
488 // This JavaScript is primarily for RTE/Link. jumpToUrl is used in the other cases as well...
489 var add_href=' . GeneralUtility::quoteJSvalue($this->curUrlArray['href'] ? '&curUrl[href]=' . rawurlencode($this->curUrlArray['href']) : '') . ';
490 var add_target=' . GeneralUtility::quoteJSvalue($this->setTarget ? '&curUrl[target]=' . rawurlencode($this->setTarget) : '') . ';
491 var add_class=' . GeneralUtility::quoteJSvalue($this->setClass ? '&curUrl[class]=' . rawurlencode($this->setClass) : '') . ';
492 var add_title=' . GeneralUtility::quoteJSvalue($this->setTitle ? '&curUrl[title]=' . rawurlencode($this->setTitle) : '') . ';
493 var add_params=' . GeneralUtility::quoteJSvalue($this->bparams ? '&bparams=' . rawurlencode($this->bparams) : '') . ';
494
495 var cur_href=' . GeneralUtility::quoteJSvalue($this->curUrlArray['href'] ?: '') . ';
496 var cur_target=' . GeneralUtility::quoteJSvalue($this->setTarget ?: '') . ';
497 var cur_class=' . GeneralUtility::quoteJSvalue($this->setClass ?: '') . ';
498 var cur_title=' . GeneralUtility::quoteJSvalue($this->setTitle ?: '') . ';
499 var cur_params=' . GeneralUtility::quoteJSvalue($this->setParams ?: '') . ';
500
501 function browse_links_setTarget(target) { //
502 cur_target=target;
503 add_target="&curUrl[target]="+escape(target);
504 }
505 function browse_links_setClass(cssClass) { //
506 cur_class = cssClass;
507 add_class = "&curUrl[class]=" + escape(cssClass);
508 }
509 function browse_links_setTitle(title) { //
510 cur_title=title;
511 add_title="&curUrl[title]="+escape(title);
512 }
513 function browse_links_setValue(value) { //
514 cur_href=value;
515 add_href="&curUrl[href]="+value;
516 }
517 function browse_links_setParams(params) { //
518 cur_params=params;
519 add_params="&curUrl[params]="+escape(params);
520 }
521 ';
522 // Functions used, if the link selector is in wizard mode (= TCEforms fields)
523 if ($this->mode == 'wizard') {
524 if (!$this->areFieldChangeFunctionsValid() && !$this->areFieldChangeFunctionsValid(TRUE)) {
525 $this->P['fieldChangeFunc'] = array();
526 }
527 unset($this->P['fieldChangeFunc']['alert']);
528 $update = '';
529 foreach ($this->P['fieldChangeFunc'] as $v) {
530 $update .= '
531 window.opener.' . $v;
532 }
533 $P2 = array();
534 $P2['uid'] = $this->P['uid'];
535 $P2['pid'] = $this->P['pid'];
536 $P2['itemName'] = $this->P['itemName'];
537 $P2['formName'] = $this->P['formName'];
538 $P2['fieldChangeFunc'] = $this->P['fieldChangeFunc'];
539 $P2['fieldChangeFuncHash'] = GeneralUtility::hmac(serialize($this->P['fieldChangeFunc']));
540 $P2['params']['allowedExtensions'] = isset($this->P['params']['allowedExtensions']) ? $this->P['params']['allowedExtensions'] : '';
541 $P2['params']['blindLinkOptions'] = isset($this->P['params']['blindLinkOptions']) ? $this->P['params']['blindLinkOptions'] : '';
542 $P2['params']['blindLinkFields'] = isset($this->P['params']['blindLinkFields']) ? $this->P['params']['blindLinkFields']: '';
543 $addPassOnParams .= GeneralUtility::implodeArrayForUrl('P', $P2);
544 $JScode .= '
545 function link_typo3Page(id,anchor) { //
546 updateValueInMainForm(id + (anchor ? anchor : ""));
547 close();
548 return false;
549 }
550 function link_folder(folder) { //
551 updateValueInMainForm(folder);
552 close();
553 return false;
554 }
555 function link_current() { //
556 if (cur_href!="http://" && cur_href!="mailto:") {
557 returnBeforeCleaned = cur_href;
558 if (returnBeforeCleaned.substr(0, 7) == "http://") {
559 returnToMainFormValue = returnBeforeCleaned.substr(7);
560 } else if (returnBeforeCleaned.substr(0, 7) == "mailto:") {
561 if (returnBeforeCleaned.substr(0, 14) == "mailto:mailto:") {
562 returnToMainFormValue = returnBeforeCleaned.substr(14);
563 } else {
564 returnToMainFormValue = returnBeforeCleaned.substr(7);
565 }
566 } else {
567 returnToMainFormValue = returnBeforeCleaned;
568 }
569 updateValueInMainForm(returnToMainFormValue);
570 close();
571 }
572 return false;
573 }
574 function checkReference() { //
575 if (window.opener && window.opener.document && window.opener.document.' . $this->P['formName']
576 . ' && window.opener.document.' . $this->P['formName'] . '["' . $this->P['itemName'] . '"] ) {
577 return window.opener.document.' . $this->P['formName'] . '["' . $this->P['itemName'] . '"];
578 } else {
579 close();
580 }
581 }
582 function updateValueInMainForm(input) { //
583 var field = checkReference();
584 if (field) {
585 if (cur_target == "" && (cur_class != "" || cur_title != "" || cur_params != "")) {
586 cur_target = "-";
587 }
588 if (cur_class == "" && (cur_title != "" || cur_params != "")) {
589 cur_class = "-";
590 }
591 cur_class = cur_class.replace(/[\'\\"]/g, "");
592 if (cur_class.indexOf(" ") != -1) {
593 cur_class = "\\"" + cur_class + "\\"";
594 }
595 if (cur_title == "" && cur_params != "") {
596 cur_title = "-";
597 }
598 cur_title = cur_title.replace(/(^\\")|(\\"$)/g, "");
599 if (cur_title.indexOf(" ") != -1) {
600 cur_title = "\\"" + cur_title + "\\"";
601 }
602 if (cur_params) {
603 cur_params = cur_params.replace(/\\bid\\=.*?(\\&|$)/, "");
604 }
605 input = input + " " + cur_target + " " + cur_class + " " + cur_title + " " + cur_params;
606 if(field.value && field.className.search(/textarea/) != -1) {
607 field.value += "\\n" + input;
608 } else {
609 field.value = input;
610 }
611 ' . $update . '
612 }
613 }
614 ';
615 } else {
616 // Functions used, if the link selector is in RTE mode:
617 $JScode .= '
618 function link_typo3Page(id,anchor) { //
619 var theLink = \'' . $this->siteURL . '?id=\'+id+(anchor?anchor:"");
620 self.parent.parent.renderPopup_addLink(theLink, cur_target, cur_class, cur_title);
621 return false;
622 }
623 function link_folder(folder) { //
624 var theLink = \'' . $this->siteURL . '\'+folder;
625 self.parent.parent.renderPopup_addLink(theLink, cur_target, cur_class, cur_title);
626 return false;
627 }
628 function link_spec(theLink) { //
629 self.parent.parent.renderPopup_addLink(theLink, cur_target, cur_class, cur_title);
630 return false;
631 }
632 function link_current() { //
633 if (cur_href!="http://" && cur_href!="mailto:") {
634 self.parent.parent.renderPopup_addLink(cur_href, cur_target, cur_class, cur_title);
635 }
636 return false;
637 }
638 ';
639 }
640 // General "jumpToUrl" function:
641 $JScode .= '
642 function jumpToUrl(URL,anchor) { //
643 if (URL.charAt(0) === \'?\') {
644 URL = ' . GeneralUtility::quoteJSvalue($this->getThisScript()) . ' + URL.substring(1);
645 }
646 var add_act = URL.indexOf("act=")==-1 ? "&act=' . $this->act . '" : "";
647 var add_mode = URL.indexOf("mode=")==-1 ? "&mode=' . $this->mode . '" : "";
648 var theLocation = URL + add_act + add_mode + add_href + add_target + add_class + add_title + add_params'
649 . ($addPassOnParams ? '+' . GeneralUtility::quoteJSvalue($addPassOnParams) : '')
650 . '+(typeof(anchor)=="string"?anchor:"");
651 window.location.href = theLocation;
652 return false;
653 }
654 ';
655 /**
656 * Splits parts of $this->bparams
657 *
658 * @see $bparams
659 */
660 $pArr = explode('|', $this->bparams);
661 // This is JavaScript especially for the TBE Element Browser!
662 $formFieldName = 'data[' . $pArr[0] . '][' . $pArr[1] . '][' . $pArr[2] . ']';
663 // insertElement - Call check function (e.g. for uniqueness handling):
664 $JScodeCheck = '';
665 if ($pArr[4] && $pArr[5]) {
666 $JScodeCheck = '
667 // Call a check function in the opener window (e.g. for uniqueness handling):
668 if (parent.window.opener) {
669 var res = parent.window.opener.' . $pArr[5] . '("' . addslashes($pArr[4]) . '",table,uid,type);
670 if (!res.passed) {
671 if (res.message) alert(res.message);
672 performAction = false;
673 }
674 } else {
675 alert("Error - reference to main window is not set properly!");
676 parent.close();
677 }
678 ';
679 }
680 // insertElement - Call helper function:
681 $JScodeHelper = '';
682 if ($pArr[4] && $pArr[6]) {
683 $JScodeHelper = '
684 // Call helper function to manage data in the opener window:
685 if (parent.window.opener) {
686 parent.window.opener.' . $pArr[6] . '("' . addslashes($pArr[4]) . '",table,uid,type,"' . addslashes($pArr[0]) . '");
687 } else {
688 alert("Error - reference to main window is not set properly!");
689 parent.close();
690 }
691 ';
692 }
693 // insertElement - perform action commands:
694 $JScodeActionMultiple = '';
695 if ($pArr[4] && $pArr[7]) {
696 // Call user defined action function:
697 $JScodeAction = '
698 if (parent.window.opener) {
699 parent.window.opener.' . $pArr[7] . '("' . addslashes($pArr[4]) . '",table,uid,type);
700 if (close) { focusOpenerAndClose(close); }
701 } else {
702 alert("Error - reference to main window is not set properly!");
703 if (close) { parent.close(); }
704 }
705 ';
706 $JScodeActionMultiple = '
707 // Call helper function to manage data in the opener window:
708 if (parent.window.opener) {
709 parent.window.opener.' . $pArr[7] . 'Multiple("' . addslashes($pArr[4]) . '",table,uid,type,"'
710 . addslashes($pArr[0]) . '");
711 } else {
712 alert("Error - reference to main window is not set properly!");
713 parent.close();
714 }
715 ';
716 } elseif ($pArr[0] && !$pArr[1] && !$pArr[2]) {
717 $JScodeAction = '
718 addElement(filename,table+"_"+uid,fp,close);
719 ';
720 } else {
721 $JScodeAction = '
722 if (setReferences()) {
723 parent.window.opener.group_change("add","' . $pArr[0] . '","' . $pArr[1] . '","' . $pArr[2]
724 . '",elRef,targetDoc);
725 } else {
726 alert("Error - reference to main window is not set properly!");
727 }
728 focusOpenerAndClose(close);
729 ';
730 }
731 $JScode .= '
732 var elRef="";
733 var targetDoc="";
734
735 function launchView(url) { //
736 var thePreviewWindow="";
737 thePreviewWindow = window.open("' . $GLOBALS['BACK_PATH'] . 'show_item.php?table="+url,"ShowItem",'
738 . '"height=300,width=410,status=0,menubar=0,resizable=0,location=0,directories=0,scrollbars=1,toolbar=0");
739 if (thePreviewWindow && thePreviewWindow.focus) {
740 thePreviewWindow.focus();
741 }
742 }
743 function setReferences() { //
744 if (parent.window.opener && parent.window.opener.content && parent.window.opener.content.document.editform'
745 . '&& parent.window.opener.content.document.editform["' . $formFieldName . '"]) {
746 targetDoc = parent.window.opener.content.document;
747 elRef = targetDoc.editform["' . $formFieldName . '"];
748 return true;
749 } else {
750 return false;
751 }
752 }
753 function insertElement(table, uid, type, filename, fp, filetype, imagefile, action, close) { //
754 var performAction = true;
755 ' . $JScodeCheck . '
756 // Call performing function and finish this action:
757 if (performAction) {
758 ' . $JScodeHelper . $JScodeAction . '
759 }
760 return false;
761 }
762 function insertMultiple(table, uid) {
763 var type = "";
764 ' . $JScodeActionMultiple . '
765 return false;
766 }
767 function addElement(elName, elValue, altElValue, close) { //
768 if (parent.window.opener && parent.window.opener.setFormValueFromBrowseWin) {
769 parent.window.opener.setFormValueFromBrowseWin("' . $pArr[0] . '",altElValue?altElValue:elValue,elName);
770 focusOpenerAndClose(close);
771 } else {
772 alert("Error - reference to main window is not set properly!");
773 parent.close();
774 }
775 }
776 function focusOpenerAndClose(close) { //
777 BrowseLinks.focusOpenerAndClose(close);
778 }
779 ';
780 // extends JavaScript code
781 if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['extendJScode'])
782 && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['extendJScode'])
783 ) {
784 $conf = array();
785 $update = '';
786 $_params = array(
787 'conf' => &$conf,
788 'wizardUpdate' => $update,
789 'addPassOnParams' => $addPassOnParams
790 );
791 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['extendJScode'] as $objRef) {
792 $processor =& GeneralUtility::getUserObj($objRef);
793 $JScode .= $processor->extendJScode($_params, $this);
794 }
795 }
796 return $JScode;
797 }
798
799 /**
800 * Session data for this class can be set from outside with this method.
801 * Call after init()
802 *
803 * @param array $data Session data array
804 * @return array Session data and boolean which indicates that data needs to be stored in session because it's changed
805 * @todo Define visibility
806 */
807 public function processSessionData($data) {
808 $store = FALSE;
809 switch ((string) $this->mode) {
810 case 'db':
811 if (isset($this->expandPage)) {
812 $data['expandPage'] = $this->expandPage;
813 $store = TRUE;
814 } else {
815 $this->expandPage = $data['expandPage'];
816 }
817 break;
818 case 'file':
819
820 case 'filedrag':
821
822 case 'folder':
823 if (isset($this->expandFolder)) {
824 $data['expandFolder'] = $this->expandFolder;
825 $store = TRUE;
826 } else {
827 $this->expandFolder = $data['expandFolder'];
828 }
829 break;
830 }
831 return array($data, $store);
832 }
833
834 /******************************************************************
835 *
836 * Main functions
837 *
838 ******************************************************************/
839 /**
840 * Rich Text Editor (RTE) link selector (MAIN function)
841 * Generates the link selector for the Rich Text Editor.
842 * Can also be used to select links for the TCEforms (see $wiz)
843 *
844 * @param bool $wiz If set, the "remove link" is not shown in the menu: Used for the "Select link" wizard which is used by the TCEforms
845 * @return string Modified content variable.
846 */
847 public function main_rte($wiz = FALSE) {
848 // Starting content:
849 $content = $this->doc->startPage('RTE link');
850
851 $allowedItems = $this->getAllowedItems('page,file,folder,url,mail,spec');
852
853 // Removing link fields if configured
854 $blindLinkFields = isset($this->thisConfig['blindLinkFields'])
855 ? GeneralUtility::trimExplode(',', $this->thisConfig['blindLinkFields'], TRUE)
856 : array();
857 $pBlindLinkFields = isset($this->P['params']['blindLinkFields'])
858 ? GeneralUtility::trimExplode(',', $this->P['params']['blindLinkFields'], TRUE)
859 : array();
860 $allowedFields = array_diff(array('target', 'title', 'class', 'params'), $blindLinkFields, $pBlindLinkFields);
861
862 $content .= $this->doc->getTabMenuRaw($this->buildMenuArray($wiz, $allowedItems));
863 // Adding the menu and header to the top of page:
864 $content .= $this->printCurrentUrl($this->curUrlInfo['info']) . '<br />';
865 // Depending on the current action we will create the actual module content for selecting a link:
866 switch ($this->act) {
867 case 'mail':
868 $content .= $this->getEmailSelectorHtml();
869 break;
870 case 'url':
871 $content .= $this->getExternalUrlSelectorHtml();
872 break;
873 case 'file':
874 case 'folder':
875 $content .= $this->getFileSelectorHtml();
876 break;
877 case 'spec':
878 $content .= $this->getUserLinkSelectorHtml();
879 break;
880 case 'page':
881 $content .= $this->getPageSelectorHtml();
882 break;
883 default:
884 // Call hook
885 foreach ($this->hookObjects as $hookObject) {
886 $content .= $hookObject->getTab($this->act);
887 }
888 }
889 if (in_array('params', $allowedFields, TRUE)) {
890 $content .= '
891 <!--
892 Selecting params for link:
893 -->
894 <form action="" name="lparamsform" id="lparamsform">
895 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkParams">
896 <tr>
897 <td style="width: 96px;">' . $GLOBALS['LANG']->getLL('params', TRUE) . '</td>
898 <td><input type="text" name="lparams" class="typo3-link-input" onchange="'
899 . 'browse_links_setParams(this.value);" value="' . htmlspecialchars($this->setParams)
900 . '" /></td>
901 </tr>
902 </table>
903 </form>
904 ';
905 }
906 if (in_array('class', $allowedFields, TRUE)) {
907 $content .= '
908 <!--
909 Selecting class for link:
910 -->
911 <form action="" name="lclassform" id="lclassform">
912 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkClass">
913 <tr>
914 <td style="width: 96px;">' . $GLOBALS['LANG']->getLL('class', TRUE) . '</td>
915 <td><input type="text" name="lclass" class="typo3-link-input" onchange="'
916 . 'browse_links_setClass(this.value);" value="' . htmlspecialchars($this->setClass)
917 . '" /></td>
918 </tr>
919 </table>
920 </form>
921 ';
922 }
923 if (in_array('title', $allowedFields, TRUE)) {
924 $content .= '
925 <!--
926 Selecting title for link:
927 -->
928 <form action="" name="ltitleform" id="ltitleform">
929 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkTitle">
930 <tr>
931 <td style="width: 96px;">' . $GLOBALS['LANG']->getLL('title', TRUE) . '</td>
932 <td><input type="text" name="ltitle" class="typo3-link-input" onchange="'
933 . 'browse_links_setTitle(this.value);" value="' . htmlspecialchars($this->setTitle)
934 . '" /></td>
935 </tr>
936 </table>
937 </form>
938 ';
939 }
940 // additional fields for page links
941 if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['addFields_PageLink'])
942 && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['addFields_PageLink'])
943 ) {
944 $conf = array();
945 $_params = array(
946 'conf' => &$conf
947 );
948 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['addFields_PageLink'] as $objRef) {
949 $processor =& GeneralUtility::getUserObj($objRef);
950 $content .= $processor->addFields($_params, $this);
951 }
952 }
953 // Target:
954 if ($this->act != 'mail' && in_array('target', $allowedFields, TRUE)) {
955 $ltarget = '
956
957 <!--
958 Selecting target for link:
959 -->
960 <form action="" name="ltargetform" id="ltargetform">
961 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkTarget">
962 <tr>
963 <td>' . $GLOBALS['LANG']->getLL('target', TRUE) . ':</td>
964 <td><input type="text" name="ltarget" onchange="browse_links_setTarget(this.value);" value="'
965 . htmlspecialchars($this->setTarget) . '"' . $this->doc->formWidth(10) . ' /></td>
966 <td>
967 <select name="ltarget_type" onchange="browse_links_setTarget('
968 . 'this.options[this.selectedIndex].value);document.ltargetform.ltarget.value='
969 . 'this.options[this.selectedIndex].value;this.selectedIndex=0;">
970 <option></option>
971 <option value="_top">' . $GLOBALS['LANG']->getLL('top', TRUE) . '</option>
972 <option value="_blank">' . $GLOBALS['LANG']->getLL('newWindow', TRUE) . '</option>
973 </select>
974 </td>
975 <td>';
976 if (($this->curUrlInfo['act'] == 'page' || $this->curUrlInfo['act'] == 'file' || $this->curUrlInfo['act'] == 'folder')
977 && $this->curUrlArray['href'] && $this->curUrlInfo['act'] == $this->act
978 ) {
979 $ltarget .= '
980 <input type="submit" value="' . $GLOBALS['LANG']->getLL('update', TRUE)
981 . '" onclick="return link_current();" />';
982 }
983 $selectJS = '
984 if (document.ltargetform.popup_width.options[document.ltargetform.popup_width.selectedIndex].value>0'
985 . ' && document.ltargetform.popup_height.options[document.ltargetform.popup_height.selectedIndex].value>0) {
986 document.ltargetform.ltarget.value = document.ltargetform.popup_width.options['
987 . 'document.ltargetform.popup_width.selectedIndex].value+"x"'
988 . '+document.ltargetformbrowse_links_setTarget.popup_height.options['
989 . 'document.ltargetform.popup_height.selectedIndex].value;
990 browse_links_setTarget(document.ltargetform.ltarget.value);
991 browse_links_setClass(document.lclassform.lclass.value);
992 browse_links_setTitle(document.ltitleform.ltitle.value);
993 browse_links_setParams(document.lparamsform.lparams.value);
994 document.ltargetform.popup_width.selectedIndex=0;
995 document.ltargetform.popup_height.selectedIndex=0;
996 }
997 ';
998 $ltarget .= ' </td>
999 </tr>
1000 <tr>
1001 <td>' . $GLOBALS['LANG']->getLL('target_popUpWindow', TRUE) . ':</td>
1002 <td colspan="3">
1003 <select name="popup_width" onchange="' . htmlspecialchars($selectJS) . '">
1004 <option value="0">' . $GLOBALS['LANG']->getLL('target_popUpWindow_width', TRUE) . '</option>
1005 <option value="300">300</option>
1006 <option value="400">400</option>
1007 <option value="500">500</option>
1008 <option value="600">600</option>
1009 <option value="700">700</option>
1010 <option value="800">800</option>
1011 </select>
1012 x
1013 <select name="popup_height" onchange="' . htmlspecialchars($selectJS) . '">
1014 <option value="0">' . $GLOBALS['LANG']->getLL('target_popUpWindow_height', TRUE) . '</option>
1015 <option value="200">200</option>
1016 <option value="300">300</option>
1017 <option value="400">400</option>
1018 <option value="500">500</option>
1019 <option value="600">600</option>
1020 </select>
1021 </td>
1022 </tr>
1023 </table>
1024 </form>';
1025 // Add "target selector" box to content:
1026 $content .= $ltarget;
1027 // Add some space
1028 $content .= '<br /><br />';
1029 }
1030 // End page, return content:
1031 $content .= $this->doc->endPage();
1032 $content = $this->doc->insertStylesAndJS($content);
1033 return $content;
1034 }
1035
1036 /**
1037 * Get the allowed items or tabs
1038 *
1039 * @param string $items: initial list of possible items
1040 * @return array the allowed items
1041 */
1042 public function getAllowedItems($items) {
1043 // Initializing the action value, possibly removing blinded values etc:
1044 $blindLinkOptions = isset($this->thisConfig['blindLinkOptions'])
1045 ? GeneralUtility::trimExplode(',', $this->thisConfig['blindLinkOptions'], TRUE)
1046 : array();
1047 $pBlindLinkOptions = isset($this->P['params']['blindLinkOptions'])
1048 ? GeneralUtility::trimExplode(',', $this->P['params']['blindLinkOptions'])
1049 : array();
1050 $allowedItems = array_diff(explode(',', $items), $blindLinkOptions, $pBlindLinkOptions);
1051
1052 // Call hook for extra options
1053 foreach ($this->hookObjects as $hookObject) {
1054 $allowedItems = $hookObject->addAllowedItems($allowedItems);
1055 }
1056 return $allowedItems;
1057 }
1058
1059 /**
1060 * Returns an array definition of the top menu
1061 *
1062 * @param $wiz
1063 * @param $allowedItems
1064 * @return array
1065 */
1066 protected function buildMenuArray($wiz, $allowedItems) {
1067 // Making menu in top:
1068 $menuDef = array();
1069 if (!$wiz) {
1070 $menuDef['removeLink']['isActive'] = $this->act === 'removeLink';
1071 $menuDef['removeLink']['label'] = $GLOBALS['LANG']->getLL('removeLink', TRUE);
1072 $menuDef['removeLink']['url'] = '#';
1073 $menuDef['removeLink']['addParams'] = 'onclick="self.parent.parent.renderPopup_unLink();return false;"';
1074 }
1075 if (in_array('page', $allowedItems)) {
1076 $menuDef['page']['isActive'] = $this->act === 'page';
1077 $menuDef['page']['label'] = $GLOBALS['LANG']->getLL('page', TRUE);
1078 $menuDef['page']['url'] = '#';
1079 $menuDef['page']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue('?act=page') . ');return false;"';
1080 }
1081 if (in_array('file', $allowedItems)) {
1082 $menuDef['file']['isActive'] = $this->act === 'file';
1083 $menuDef['file']['label'] = $GLOBALS['LANG']->getLL('file', TRUE);
1084 $menuDef['file']['url'] = '#';
1085 $menuDef['file']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue('?act=file') . ');return false;"';
1086 }
1087 if (in_array('folder', $allowedItems)) {
1088 $menuDef['folder']['isActive'] = $this->act === 'folder';
1089 $menuDef['folder']['label'] = $GLOBALS['LANG']->getLL('folder', TRUE);
1090 $menuDef['folder']['url'] = '#';
1091 $menuDef['folder']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue('?act=folder') . ');return false;"';
1092 }
1093 if (in_array('url', $allowedItems)) {
1094 $menuDef['url']['isActive'] = $this->act === 'url';
1095 $menuDef['url']['label'] = $GLOBALS['LANG']->getLL('extUrl', TRUE);
1096 $menuDef['url']['url'] = '#';
1097 $menuDef['url']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue('?act=url') . ');return false;"';
1098 }
1099 if (in_array('mail', $allowedItems)) {
1100 $menuDef['mail']['isActive'] = $this->act === 'mail';
1101 $menuDef['mail']['label'] = $GLOBALS['LANG']->getLL('email', TRUE);
1102 $menuDef['mail']['url'] = '#';
1103 $menuDef['mail']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue('?act=mail') . ');return false;"';
1104 }
1105 if (is_array($this->thisConfig['userLinks.']) && in_array('spec', $allowedItems)) {
1106 $menuDef['spec']['isActive'] = $this->act === 'spec';
1107 $menuDef['spec']['label'] = $GLOBALS['LANG']->getLL('special', TRUE);
1108 $menuDef['spec']['url'] = '#';
1109 $menuDef['spec']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue('?act=spec') . ');return false;"';
1110 }
1111 // Call hook for extra options
1112 foreach ($this->hookObjects as $hookObject) {
1113 $menuDef = $hookObject->modifyMenuDefinition($menuDef);
1114 }
1115 return $menuDef;
1116 }
1117
1118 /**
1119 * Returns HTML of the email link from
1120 *
1121 * @return string
1122 */
1123 protected function getEmailSelectorHtml() {
1124 $extUrl = '
1125
1126 <!--
1127 Enter mail address:
1128 -->
1129 <form action="" name="lurlform" id="lurlform">
1130 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkMail">
1131 <tr>
1132 <td style="width: 96px;">' . $GLOBALS['LANG']->getLL('emailAddress', TRUE) . ':</td>
1133 <td><input type="text" name="lemail"' . $this->doc->formWidth(20) . ' value="'
1134 . htmlspecialchars(($this->curUrlInfo['act'] === 'mail' ? $this->curUrlInfo['info'] : ''))
1135 . '" /> ' . '<input type="submit" value="' . $GLOBALS['LANG']->getLL('setLink', TRUE)
1136 . '" onclick="browse_links_setTarget(\'\');browse_links_setValue(\'mailto:\'+'
1137 . 'document.lurlform.lemail.value); return link_current();" /></td>
1138 </tr>
1139 </table>
1140 </form>';
1141 return $extUrl;
1142 }
1143
1144 /**
1145 * Returns HTML of the external url link from
1146 *
1147 * @return string
1148 */
1149 protected function getExternalUrlSelectorHtml() {
1150 $extUrl = '
1151
1152 <!--
1153 Enter External URL:
1154 -->
1155 <form action="" name="lurlform" id="lurlform">
1156 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkURL">
1157 <tr>
1158 <td style="width: 96px;">URL:</td>
1159 <td><input type="text" name="lurl"' . $this->doc->formWidth(30) . ' value="'
1160 . htmlspecialchars(($this->curUrlInfo['act'] === 'url' ? $this->curUrlInfo['info'] : 'http://'))
1161 . '" /> ' . '<input type="submit" value="' . $GLOBALS['LANG']->getLL('setLink', TRUE)
1162 . '" onclick="browse_links_setValue(document.lurlform.lurl.value); return link_current();" /></td>
1163 </tr>
1164 </table>
1165 </form>';
1166 return $extUrl;
1167 }
1168
1169 /**
1170 * Returns HTML of the file/folder link selector
1171 *
1172 * @param string $treeClassName
1173 * @return string
1174 */
1175 protected function getFileSelectorHtml($treeClassName = 'localFolderTree') {
1176 $folderTree = GeneralUtility::makeInstance($treeClassName);
1177 $folderTree->thisScript = $this->thisScript;
1178 $tree = $folderTree->getBrowsableTree();
1179 if (!$this->curUrlInfo['value'] || $this->curUrlInfo['act'] != $this->act) {
1180 $cmpPath = '';
1181 } else {
1182 $cmpPath = $this->curUrlInfo['value'];
1183 if (!isset($this->expandFolder)) {
1184 $this->expandFolder = $cmpPath;
1185 }
1186 }
1187 // Create upload/create folder forms, if a path is given
1188 $selectedFolder = FALSE;
1189 if ($this->expandFolder) {
1190 $fileOrFolderObject = NULL;
1191 try {
1192 $fileOrFolderObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->retrieveFileOrFolderObject($this->expandFolder);
1193 } catch (\Exception $e) {
1194 // No path is selected
1195 }
1196
1197 if ($fileOrFolderObject instanceof Folder) {
1198 // It's a folder
1199 $selectedFolder = $fileOrFolderObject;
1200 } elseif ($fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\FileInterface) {
1201 // It's a file
1202 $selectedFolder = $fileOrFolderObject->getParentFolder();
1203 }
1204 }
1205 // If no folder is selected, get the user's default upload folder
1206 if (!$selectedFolder) {
1207 try {
1208 $selectedFolder = $GLOBALS['BE_USER']->getDefaultUploadFolder();
1209 } catch (\Exception $e) {
1210 // The configured default user folder does not exist
1211 }
1212 }
1213 // Build the file upload and folder creation form
1214 $uploadForm = '';
1215 $createFolder = '';
1216 $content = '';
1217 if ($selectedFolder) {
1218 $uploadForm = ($this->act === 'file') ? $this->uploadForm($selectedFolder) : '';
1219 $createFolder = $this->createFolder($selectedFolder);
1220 }
1221 // Insert the upload form on top, if so configured
1222 if ($GLOBALS['BE_USER']->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
1223 $content .= $uploadForm;
1224 }
1225
1226 // Render the filelist if there is a folder selected
1227 $files = '';
1228 if ($selectedFolder) {
1229 $allowedExtensions = isset($this->P['params']['allowedExtensions']) ? $this->P['params']['allowedExtensions'] : '';
1230 $files = $this->expandFolder($selectedFolder, $allowedExtensions);
1231 }
1232 // Create folder tree:
1233 $this->doc->JScode .= $this->doc->wrapScriptTags('
1234 Tree.ajaxID = "SC_alt_file_navframe::expandCollapse";
1235 ');
1236 $content .= '
1237 <!--
1238 Wrapper table for folder tree / file/folder list:
1239 -->
1240 <table border="0" cellpadding="0" cellspacing="0" id="typo3-linkFiles">
1241 <tr>
1242 <td class="c-wCell" valign="top">'
1243 . $this->barheader(($GLOBALS['LANG']->getLL('folderTree') . ':')) . $tree . '</td>
1244 <td class="c-wCell" valign="top">' . $files . '</td>
1245 </tr>
1246 </table>
1247 ';
1248 // Adding create folder + upload form if applicable
1249 if (!$GLOBALS['BE_USER']->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
1250 $content .= $uploadForm;
1251 }
1252 $content .= '<br />' . $createFolder . '<br />';
1253 return $content;
1254 }
1255
1256 /**
1257 * Returns HTML of the user defined link selector
1258 *
1259 * @return string
1260 */
1261 protected function getUserLinkSelectorHtml() {
1262 if (!is_array($this->thisConfig['userLinks.'])) {
1263 return '';
1264 }
1265 $subcats = array();
1266 $v = $this->thisConfig['userLinks.'];
1267 foreach ($v as $k2 => $value) {
1268 $k2i = (int)$k2;
1269 if (substr($k2, -1) === '.' && is_array($v[$k2i . '.'])) {
1270 // Title:
1271 $title = trim($v[$k2i]);
1272 if (!$title) {
1273 $title = $v[$k2i . '.']['url'];
1274 } else {
1275 $title = $GLOBALS['LANG']->sL($title);
1276 }
1277 // Description:
1278 $description = $v[$k2i . '.']['description']
1279 ? $GLOBALS['LANG']->sL($v[($k2i . '.')]['description'], TRUE) . '<br />'
1280 : '';
1281 // URL + onclick event:
1282 $onClickEvent = '';
1283 if (isset($v[$k2i . '.']['target'])) {
1284 $onClickEvent .= 'browse_links_setTarget(' . GeneralUtility::quoteJSvalue($v[($k2i . '.')]['target']) . ');';
1285 }
1286 $v[$k2i . '.']['url'] = str_replace('###_URL###', $this->siteURL, $v[$k2i . '.']['url']);
1287 if (substr($v[$k2i . '.']['url'], 0, 7) === 'http://' || substr($v[$k2i . '.']['url'], 0, 7) === 'mailto:') {
1288 $onClickEvent .= 'cur_href=' . GeneralUtility::quoteJSvalue($v[($k2i . '.')]['url']) . ';link_current();';
1289 } else {
1290 $onClickEvent .= 'link_spec(' . GeneralUtility::quoteJSvalue($this->siteURL . $v[($k2i . '.')]['url']) . ');';
1291 }
1292 // Link:
1293 $A = array('<a href="#" onclick="' . htmlspecialchars($onClickEvent) . 'return false;">', '</a>');
1294 // Adding link to menu of user defined links:
1295 $subcats[$k2i] = '
1296 <tr>
1297 <td class="bgColor4">' . $A[0] . '<strong>' . htmlspecialchars($title)
1298 . ($this->curUrlInfo['info'] == $v[$k2i . '.']['url']
1299 ? '<img' . IconUtility::skinImg(
1300 $GLOBALS['BACK_PATH'],
1301 'gfx/blinkarrow_right.gif',
1302 'width="5" height="9"'
1303 ) . ' class="c-blinkArrowR" alt="" />'
1304 : '')
1305 . '</strong><br />' . $description . $A[1] . '</td>
1306 </tr>';
1307 }
1308 }
1309 // Sort by keys:
1310 ksort($subcats);
1311 // Add menu to content:
1312 $content = '
1313
1314 <!--
1315 Special userdefined menu:
1316 -->
1317 <table border="0" cellpadding="1" cellspacing="1" id="typo3-linkSpecial">
1318 <tr>
1319 <td class="bgColor5" class="c-wCell" valign="top"><strong>'
1320 . $GLOBALS['LANG']->getLL('special', TRUE) . '</strong></td>
1321 </tr>
1322 ' . implode('', $subcats) . '
1323 </table>
1324 ';
1325 return $content;
1326 }
1327
1328 /**
1329 * Returns HTML of the page link selector
1330 *
1331 * @param string $treeClassName name of the class used for page tree rendering
1332 * @return string
1333 */
1334 protected function getPageSelectorHtml($treeClassName = 'localPageTree') {
1335 $pageTree = GeneralUtility::makeInstance($treeClassName);
1336 $pageTree->thisScript = $this->thisScript;
1337 $pageTree->ext_showPageId = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showPageIdWithTitle');
1338 $pageTree->ext_showNavTitle = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showNavTitle');
1339 $pageTree->addField('nav_title');
1340 $tree = $pageTree->getBrowsableTree();
1341 $cElements = $this->expandPage();
1342 $dbmount = $this->getTemporaryTreeMountCancelNotice();
1343 $content = '
1344
1345 <!--
1346 Wrapper table for page tree / record list:
1347 -->
1348 <table border="0" cellpadding="0" cellspacing="0" id="typo3-linkPages">
1349 <tr>
1350 <td class="c-wCell" valign="top">'
1351 . $this->barheader(($GLOBALS['LANG']->getLL('pageTree') . ':'))
1352 . $dbmount
1353 . $tree . '</td>
1354 <td class="c-wCell" valign="top">' . $cElements . '</td>
1355 </tr>
1356 </table>
1357 ';
1358 return $content;
1359 }
1360
1361 /**
1362 * TYPO3 Element Browser: Showing a page tree and allows you to browse for records
1363 *
1364 * @return string HTML content for the module
1365 */
1366 public function main_db() {
1367 // Starting content:
1368 $content = $this->doc->startPage('TBE record selector');
1369 // Init variable:
1370 $pArr = explode('|', $this->bparams);
1371 $tables = $pArr[3];
1372
1373 // Making the browsable pagetree:
1374 /** @var \TBE_PageTree $pageTree */
1375 $pageTree = GeneralUtility::makeInstance('TBE_PageTree');
1376 $pageTree->thisScript = $this->thisScript;
1377 $pageTree->ext_pArrPages = $tables === 'pages' ? 1 : 0;
1378 $pageTree->ext_showNavTitle = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showNavTitle');
1379 $pageTree->ext_showPageId = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showPageIdWithTitle');
1380 $pageTree->addField('nav_title');
1381
1382 $withTree = TRUE;
1383 if (($tables !== '') && ($tables !== '*')) {
1384 $tablesArr = GeneralUtility::trimExplode(',', $tables, TRUE);
1385 $onlyRootLevel = TRUE;
1386 foreach ($tablesArr as $currentTable) {
1387 $tableTca = $GLOBALS['TCA'][$currentTable];
1388 if (isset($tableTca)) {
1389 if (!isset($tableTca['ctrl']['rootLevel']) || ((int)$tableTca['ctrl']['rootLevel']) != 1) {
1390 $onlyRootLevel = FALSE;
1391 }
1392 }
1393 }
1394 if ($onlyRootLevel) {
1395 $withTree = FALSE;
1396 // page to work on will be root
1397 $this->expandPage = 0;
1398 }
1399 }
1400
1401 $tree = $pageTree->getBrowsableTree();
1402 // Making the list of elements, if applicable:
1403 $cElements = $this->TBE_expandPage($tables);
1404 // Putting the things together, side by side:
1405 $content .= '
1406
1407 <!--
1408 Wrapper table for page tree / record list:
1409 -->
1410 <table border="0" cellpadding="0" cellspacing="0" id="typo3-EBrecords">
1411 <tr>';
1412 if ($withTree) {
1413 $content .= '<td class="c-wCell" valign="top">'
1414 . $this->barheader(($GLOBALS['LANG']->getLL('pageTree') . ':'))
1415 . $this->getTemporaryTreeMountCancelNotice()
1416 . $tree . '</td>';
1417 }
1418 $content .= '<td class="c-wCell" valign="top">' . $cElements . '</td>
1419 </tr>
1420 </table>
1421 ';
1422 // Add some space
1423 $content .= '<br /><br />';
1424 // End page, return content:
1425 $content .= $this->doc->endPage();
1426 $content = $this->doc->insertStylesAndJS($content);
1427 return $content;
1428 }
1429
1430 /**
1431 * TYPO3 Element Browser: Showing a folder tree, allowing you to browse for files.
1432 *
1433 * @return string HTML content for the module
1434 * @todo Define visibility
1435 */
1436 public function main_file() {
1437 // include JS files and set prefs for foldertree
1438 $this->doc->getDragDropCode('folders');
1439 $this->doc->JScode .= $this->doc->wrapScriptTags('
1440 Tree.ajaxID = "SC_alt_file_navframe::expandCollapse";
1441 ');
1442 // Starting content:
1443 $content = $this->doc->startPage('TBE file selector');
1444 // Init variable:
1445 $pArr = explode('|', $this->bparams);
1446 // The key number 3 of the pArr contains the "allowed" string. Disallowed is not passed to
1447 // the element browser at all but only filtered out in TCEMain afterwards
1448 $allowed = $pArr[3];
1449 if ($allowed !== 'sys_file') {
1450 $allowedFileExtensions = $allowed;
1451 }
1452
1453 if (isset($allowedFileExtensions)) {
1454 // Create new filter object
1455 $filterObject = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\Filter\\FileExtensionFilter');
1456 $filterObject->setAllowedFileExtensions($allowedFileExtensions);
1457 // Set file extension filters on all storages
1458 $storages = $GLOBALS['BE_USER']->getFileStorages();
1459 /** @var $storage \TYPO3\CMS\Core\Resource\ResourceStorage */
1460 foreach ($storages as $storage) {
1461 $storage->addFileAndFolderNameFilter(array($filterObject, 'filterFileList'));
1462 }
1463 }
1464 // Create upload/create folder forms, if a path is given
1465 $this->selectedFolder = FALSE;
1466 if ($this->expandFolder) {
1467 $fileOrFolderObject = NULL;
1468
1469 // Try to fetch the folder the user had open the last time he browsed files
1470 // Fallback to the default folder in case the last used folder is not existing
1471 try {
1472 $fileOrFolderObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->retrieveFileOrFolderObject($this->expandFolder);
1473 } catch (\TYPO3\CMS\Core\Resource\Exception $accessException) {
1474 // We're just catching the exception here, nothing to be done if folder does not exist or is not accessible.
1475 }
1476
1477 if ($fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\Folder) {
1478 // It's a folder
1479 $this->selectedFolder = $fileOrFolderObject;
1480 } elseif ($fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\FileInterface) {
1481 // It's a file
1482 $this->selectedFolder = $fileOrFolderObject->getParentFolder();
1483 }
1484 }
1485 // Or get the user's default upload folder
1486 if (!$this->selectedFolder) {
1487 try {
1488 $this->selectedFolder = $GLOBALS['BE_USER']->getDefaultUploadFolder();
1489 } catch (\Exception $e) {
1490 // The configured default user folder does not exist
1491 }
1492 }
1493 // Build the file upload and folder creation form
1494 $uploadForm = '';
1495 $createFolder = '';
1496 if ($this->selectedFolder) {
1497 $uploadForm = $this->uploadForm($this->selectedFolder);
1498 $createFolder = $this->createFolder($this->selectedFolder);
1499 }
1500 // Insert the upload form on top, if so configured
1501 if ($GLOBALS['BE_USER']->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
1502 $content .= $uploadForm;
1503 }
1504 // Getting flag for showing/not showing thumbnails:
1505 $noThumbs = $GLOBALS['BE_USER']->getTSConfigVal('options.noThumbsInEB');
1506 $_MOD_SETTINGS = array();
1507 if (!$noThumbs) {
1508 // MENU-ITEMS, fetching the setting for thumbnails from File>List module:
1509 $_MOD_MENU = array('displayThumbs' => '');
1510 $_MCONF['name'] = 'file_list';
1511 $_MOD_SETTINGS = BackendUtility::getModuleData($_MOD_MENU, GeneralUtility::_GP('SET'), $_MCONF['name']);
1512 }
1513 $noThumbs = $noThumbs ?: !$_MOD_SETTINGS['displayThumbs'];
1514 // Create folder tree:
1515 $folderTree = GeneralUtility::makeInstance('TBE_FolderTree');
1516 $folderTree->thisScript = $this->thisScript;
1517 $folderTree->ext_noTempRecyclerDirs = $this->mode == 'filedrag';
1518 $tree = $folderTree->getBrowsableTree();
1519 list(, , $specUid) = explode('_', $this->PM);
1520 if ($this->selectedFolder) {
1521 if ($this->mode == 'filedrag') {
1522 $files = $this->TBE_dragNDrop($this->selectedFolder, $pArr[3]);
1523 } else {
1524 $files = $this->TBE_expandFolder($this->selectedFolder, $pArr[3], $noThumbs);
1525 }
1526 } else {
1527 $files = '';
1528 }
1529 // Add the FlashMessages if any
1530 $content .= $this->doc->getFlashMessages();
1531
1532 // Putting the parts together, side by side:
1533 $content .= '
1534
1535 <!--
1536 Wrapper table for folder tree / file list:
1537 -->
1538 <table border="0" cellpadding="0" cellspacing="0" id="typo3-EBfiles">
1539 <tr>
1540 <td class="c-wCell" valign="top">' . $this->barheader(($GLOBALS['LANG']->getLL('folderTree') . ':'))
1541 . $tree . '</td>
1542 <td class="c-wCell" valign="top">' . $files . '</td>
1543 </tr>
1544 </table>
1545 ';
1546 // Adding create folder + upload forms if applicable:
1547 if (!$GLOBALS['BE_USER']->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
1548 $content .= $uploadForm;
1549 }
1550 $content .= $createFolder;
1551 // Add some space
1552 $content .= '<br /><br />';
1553 // Setup indexed elements:
1554 $this->doc->JScode .= $this->doc->wrapScriptTags('BrowseLinks.addElements(' . json_encode($this->elements) . ');');
1555 // Ending page, returning content:
1556 $content .= $this->doc->endPage();
1557 $content = $this->doc->insertStylesAndJS($content);
1558 return $content;
1559 }
1560
1561 /**
1562 * TYPO3 Element Browser: Showing a folder tree, allowing you to browse for folders.
1563 *
1564 * @return string HTML content for the module
1565 * @todo Define visibility
1566 */
1567 public function main_folder() {
1568 // include JS files
1569 $this->doc->getDragDropCode('folders');
1570 // Setting prefs for foldertree
1571 $this->doc->JScode .= $this->doc->wrapScriptTags('
1572 Tree.ajaxID = "SC_alt_file_navframe::expandCollapse";
1573 ');
1574 // Starting content:
1575 $content = $this->doc->startPage('TBE folder selector');
1576 // Init variable:
1577 $parameters = explode('|', $this->bparams);
1578 if ($this->expandFolder) {
1579 $this->selectedFolder = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->getFolderObjectFromCombinedIdentifier($this->expandFolder);
1580 }
1581 if ($this->selectedFolder) {
1582 $createFolder = $this->createFolder($this->selectedFolder);
1583 } else {
1584 $createFolder = '';
1585 }
1586 // Create folder tree:
1587 $folderTree = GeneralUtility::makeInstance('TBE_FolderTree');
1588 $folderTree->thisScript = $this->thisScript;
1589 $folderTree->ext_noTempRecyclerDirs = $this->mode == 'filedrag';
1590 $tree = $folderTree->getBrowsableTree(FALSE);
1591 list(, , $specUid) = explode('_', $this->PM);
1592 if ($this->mode == 'filedrag') {
1593 $folders = $this->TBE_dragNDrop($this->selectedFolder, $parameters[3]);
1594 } else {
1595 $folders = $this->TBE_expandSubFolders($this->selectedFolder);
1596 }
1597 // Putting the parts together, side by side:
1598 $content .= '
1599
1600 <!--
1601 Wrapper table for folder tree / folder list:
1602 -->
1603 <table border="0" cellpadding="0" cellspacing="0" id="typo3-EBfiles">
1604 <tr>
1605 <td class="c-wCell" valign="top">' . $this->barheader(($GLOBALS['LANG']->getLL('folderTree') . ':'))
1606 . $tree . '</td>
1607 <td class="c-wCell" valign="top">' . $folders . '</td>
1608 </tr>
1609 </table>
1610 ';
1611 // Adding create folder if applicable:
1612 $content .= $createFolder;
1613 // Add some space
1614 $content .= '<br /><br />';
1615 // Ending page, returning content:
1616 $content .= $this->doc->endPage();
1617 $content = $this->doc->insertStylesAndJS($content);
1618 return $content;
1619 }
1620
1621 /******************************************************************
1622 *
1623 * Record listing
1624 *
1625 ******************************************************************/
1626 /**
1627 * For RTE: This displays all content elements on a page and lets you create a link to the element.
1628 *
1629 * @return string HTML output. Returns content only if the ->expandPage value is set (pointing to a page uid to show tt_content records from ...)
1630 * @todo Define visibility
1631 */
1632 public function expandPage() {
1633 $out = '';
1634 // Set page id (if any) to expand
1635 $expPageId = $this->expandPage;
1636 // If there is an anchor value (content element reference) in the element reference, then force an ID to expand:
1637 if (!$this->expandPage && $this->curUrlInfo['cElement']) {
1638 // Set to the current link page id.
1639 $expPageId = $this->curUrlInfo['pageid'];
1640 }
1641 // Draw the record list IF there is a page id to expand:
1642 if ($expPageId
1643 && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($expPageId)
1644 && $GLOBALS['BE_USER']->isInWebMount($expPageId)
1645 ) {
1646 // Set header:
1647 $out .= $this->barheader($GLOBALS['LANG']->getLL('contentElements') . ':');
1648 // Create header for listing, showing the page title/icon:
1649 $mainPageRec = BackendUtility::getRecordWSOL('pages', $expPageId);
1650 $picon = IconUtility::getSpriteIconForRecord('pages', $mainPageRec);
1651 $picon .= BackendUtility::getRecordTitle('pages', $mainPageRec, TRUE);
1652 $out .= $picon . '<br />';
1653 // Look up tt_content elements from the expanded page:
1654 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1655 'uid,header,hidden,starttime,endtime,fe_group,CType,colPos,bodytext',
1656 'tt_content',
1657 'pid=' . (int)$expPageId . BackendUtility::deleteClause('tt_content')
1658 . BackendUtility::versioningPlaceholderClause('tt_content'),
1659 '',
1660 'colPos,sorting'
1661 );
1662 $cc = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
1663 // Traverse list of records:
1664 $c = 0;
1665 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
1666 $c++;
1667 $icon = IconUtility::getSpriteIconForRecord('tt_content', $row);
1668 if ($this->curUrlInfo['act'] == 'page' && $this->curUrlInfo['cElement'] == $row['uid']) {
1669 $arrCol = '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/blinkarrow_left.gif', 'width="5" height="9"')
1670 . ' class="c-blinkArrowL" alt="" />';
1671 } else {
1672 $arrCol = '';
1673 }
1674 // Putting list element HTML together:
1675 $out .= '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], ('gfx/ol/join' . ($c == $cc ? 'bottom' : '')
1676 . '.gif'), 'width="18" height="16"') . ' alt="" />' . $arrCol
1677 . '<a href="#" onclick="return link_typo3Page(\'' . $expPageId . '\',\'#' . $row['uid'] . '\');">'
1678 . $icon . BackendUtility::getRecordTitle('tt_content', $row, TRUE) . '</a><br />';
1679 // Finding internal anchor points:
1680 if (GeneralUtility::inList('text,textpic', $row['CType'])) {
1681 $split = preg_split('/(<a[^>]+name=[\'"]?([^"\'>[:space:]]+)[\'"]?[^>]*>)/i', $row['bodytext'], -1, PREG_SPLIT_DELIM_CAPTURE);
1682 foreach ($split as $skey => $sval) {
1683 if ($skey % 3 == 2) {
1684 // Putting list element HTML together:
1685 $sval = substr($sval, 0, 100);
1686 $out .= '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/ol/line.gif',
1687 'width="18" height="16"') . ' alt="" />'
1688 . '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], ('gfx/ol/join'
1689 . ($skey + 3 > count($split) ? 'bottom' : '') . '.gif'), 'width="18" height="16"')
1690 . ' alt="" />' . '<a href="#" onclick="return link_typo3Page(' . GeneralUtility::quoteJSvalue($expPageId)
1691 . ',' . GeneralUtility::quoteJSvalue('#' . $sval) . ';">' . htmlspecialchars((' <A> ' . $sval))
1692 . '</a><br />';
1693 }
1694 }
1695 }
1696 }
1697 }
1698 return $out;
1699 }
1700
1701 /**
1702 * For TYPO3 Element Browser: This lists all content elements from the given list of tables
1703 *
1704 * @param string $tables Comma separated list of tables. Set to "*" if you want all tables.
1705 * @return string HTML output.
1706 * @todo Define visibility
1707 */
1708 public function TBE_expandPage($tables) {
1709 if (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->expandPage)
1710 || $this->expandPage < 0
1711 || !$GLOBALS['BE_USER']->isInWebMount($this->expandPage)
1712 ) {
1713 return '';
1714 }
1715 // Set array with table names to list:
1716 if (trim($tables) === '*') {
1717 $tablesArr = array_keys($GLOBALS['TCA']);
1718 } else {
1719 $tablesArr = GeneralUtility::trimExplode(',', $tables, TRUE);
1720 }
1721 reset($tablesArr);
1722 // Headline for selecting records:
1723 $out = $this->barheader($GLOBALS['LANG']->getLL('selectRecords') . ':');
1724 // Create the header, showing the current page for which the listing is.
1725 // Includes link to the page itself, if pages are amount allowed tables.
1726 $titleLen = (int)$GLOBALS['BE_USER']->uc['titleLen'];
1727 $mainPageRec = BackendUtility::getRecordWSOL('pages', $this->expandPage);
1728 $ATag = '';
1729 $ATag_e = '';
1730 $ATag2 = '';
1731 $picon = '';
1732 if (is_array($mainPageRec)) {
1733 $picon = IconUtility::getSpriteIconForRecord('pages', $mainPageRec);
1734 if (in_array('pages', $tablesArr)) {
1735 $ATag = '<a href="#" onclick="return insertElement(\'pages\', \'' . $mainPageRec['uid'] . '\', \'db\', '
1736 . GeneralUtility::quoteJSvalue($mainPageRec['title']) . ', \'\', \'\', \'\',\'\',1);">';
1737 $ATag2 = '<a href="#" onclick="return insertElement(\'pages\', \'' . $mainPageRec['uid'] . '\', \'db\', '
1738 . GeneralUtility::quoteJSvalue($mainPageRec['title']) . ', \'\', \'\', \'\',\'\',0);">';
1739 $ATag_e = '</a>';
1740 }
1741 }
1742 $pBicon = $ATag2 ? '<img'
1743 . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/plusbullet2.gif', 'width="18" height="16"')
1744 . ' alt="" />' : '';
1745 $pText = htmlspecialchars(GeneralUtility::fixed_lgd_cs($mainPageRec['title'], $titleLen));
1746 $out .= $picon . $ATag2 . $pBicon . $ATag_e . $ATag . $pText . $ATag_e . '<br />';
1747 // Initialize the record listing:
1748 $id = $this->expandPage;
1749 $pointer = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->pointer, 0, 100000);
1750 $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
1751 $pageInfo = BackendUtility::readPageAccess($id, $perms_clause);
1752 // Generate the record list:
1753 /** @var $dbList \TYPO3\CMS\Backend\RecordList\ElementBrowserRecordList */
1754 if (is_object($this->recordList)) {
1755 $dbList = $this->recordList;
1756 } else {
1757 $dbList = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\RecordList\\ElementBrowserRecordList');
1758 }
1759 $dbList->thisScript = $this->thisScript;
1760 $dbList->backPath = $GLOBALS['BACK_PATH'];
1761 $dbList->thumbs = 0;
1762 $dbList->calcPerms = $GLOBALS['BE_USER']->calcPerms($pageInfo);
1763 $dbList->noControlPanels = 1;
1764 $dbList->clickMenuEnabled = 0;
1765 $dbList->tableList = implode(',', $tablesArr);
1766 $pArr = explode('|', $this->bparams);
1767 // a string like "data[pages][79][storage_pid]"
1768 $fieldPointerString = $pArr[0];
1769 // parts like: data, pages], 79], storage_pid]
1770 $fieldPointerParts = explode('[', $fieldPointerString);
1771 $relatingTableName = substr($fieldPointerParts[1], 0, -1);
1772 $relatingFieldName = substr($fieldPointerParts[3], 0, -1);
1773 if ($relatingTableName && $relatingFieldName) {
1774 $dbList->setRelatingTableAndField($relatingTableName, $relatingFieldName);
1775 }
1776 $dbList->start($id, GeneralUtility::_GP('table'), $pointer, GeneralUtility::_GP('search_field'),
1777 GeneralUtility::_GP('search_levels'), GeneralUtility::_GP('showLimit')
1778 );
1779 $dbList->setDispFields();
1780 $dbList->generateList();
1781 // Add the HTML for the record list to output variable:
1782 $out .= $dbList->HTMLcode;
1783 // Add support for fieldselectbox in singleTableMode
1784 if ($dbList->table) {
1785 $out .= $dbList->fieldSelectBox($dbList->table);
1786 }
1787 $out .= $dbList->getSearchBox();
1788
1789 // Return accumulated content:
1790 return $out;
1791 }
1792
1793 /**
1794 * Render list of folders inside a folder.
1795 *
1796 * @param Folder $folder Folder
1797 * @return string HTML output
1798 * @todo Define visibility
1799 */
1800 public function TBE_expandSubFolders(Folder $folder) {
1801 $content = '';
1802 if ($folder->checkActionPermission('read')) {
1803 $content .= $this->folderList($folder);
1804 }
1805 // Return accumulated content for folderlisting:
1806 return $content;
1807 }
1808
1809 /******************************************************************
1810 *
1811 * File listing
1812 *
1813 ******************************************************************/
1814 /**
1815 * For RTE: This displays all files from folder. No thumbnails shown
1816 *
1817 * @param Folder $folder The folder path to expand
1818 * @param string $extensionList List of file extensions to show
1819 * @return string HTML output
1820 * @todo Define visibility
1821 */
1822 public function expandFolder(Folder $folder, $extensionList = '') {
1823 if (!$folder->checkActionPermission('read')) {
1824 return '';
1825 }
1826 $renderFolders = $this->act === 'folder';
1827 // Create header for file listing:
1828 $out = $this->barheader($GLOBALS['LANG']->getLL('files') . ':');
1829 // Prepare current path value for comparison (showing red arrow)
1830 $currentIdentifier = '';
1831 if ($this->curUrlInfo['value']) {
1832 $currentIdentifier = $this->curUrlInfo['info'];
1833 }
1834 // Create header element; The folder from which files are listed.
1835 $titleLen = (int)$GLOBALS['BE_USER']->uc['titleLen'];
1836 $folderIcon = IconUtility::getSpriteIconForResource($folder);
1837 $folderIcon .= htmlspecialchars(GeneralUtility::fixed_lgd_cs($folder->getIdentifier(), $titleLen));
1838 $picon = '<a href="#" onclick="return link_folder(\'file:' . $folder->getCombinedIdentifier() . '\');">'
1839 . $folderIcon . '</a>';
1840 if ($this->curUrlInfo['act'] == 'folder' && $currentIdentifier == $folder->getCombinedIdentifier()) {
1841 $out .= '<img'
1842 . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/blinkarrow_left.gif', 'width="5" height="9"')
1843 . ' class="c-blinkArrowL" alt="" />';
1844 }
1845 $out .= $picon . '<br />';
1846 // Get files from the folder:
1847 if ($renderFolders) {
1848 $items = $folder->getSubfolders();
1849 } else {
1850 $items = $this->getFilesInFolder($folder, $extensionList);
1851 }
1852 $c = 0;
1853 $totalItems = count($items);
1854 foreach ($items as $fileOrFolderObject) {
1855 $c++;
1856 if ($renderFolders) {
1857 $fileIdentifier = $fileOrFolderObject->getCombinedIdentifier();
1858 $overlays = array();
1859 if ($fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\InaccessibleFolder) {
1860 $overlays = array('status-overlay-locked' => array());
1861 }
1862 $icon = IconUtility::getSpriteIcon(
1863 IconUtility::mapFileExtensionToSpriteIconName('folder'),
1864 array('title' => $fileOrFolderObject->getName()),
1865 $overlays);
1866 $itemUid = 'file:' . $fileIdentifier;
1867 } else {
1868 $fileIdentifier = $fileOrFolderObject->getUid();
1869 // File icon:
1870 $fileExtension = $fileOrFolderObject->getExtension();
1871 // Get size and icon:
1872 $size = ' (' . GeneralUtility::formatSize($fileOrFolderObject->getSize()) . 'bytes)';
1873 $icon = IconUtility::getSpriteIconForResource($fileOrFolderObject, array('title' => $fileOrFolderObject->getName() . $size));
1874 $itemUid = 'file:' . $fileIdentifier;
1875 }
1876 // If the listed file turns out to be the CURRENT file, then show blinking arrow:
1877 if (($this->curUrlInfo['act'] == 'file' || $this->curUrlInfo['act'] == 'folder')
1878 && $currentIdentifier == $fileIdentifier
1879 ) {
1880 $arrCol = '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/blinkarrow_left.gif',
1881 'width="5" height="9"') . ' class="c-blinkArrowL" alt="" />';
1882 } else {
1883 $arrCol = '';
1884 }
1885 // Put it all together for the file element:
1886 $out .=
1887 '<img' .
1888 IconUtility::skinImg(
1889 $GLOBALS['BACK_PATH'],
1890 ('gfx/ol/join' . ($c == $totalItems ? 'bottom' : '') . '.gif'),
1891 'width="18" height="16"'
1892 ) . ' alt="" />' . $arrCol .
1893 '<a href="#" onclick="return link_folder(\'' . $itemUid . '\');">' .
1894 $icon .
1895 htmlspecialchars(GeneralUtility::fixed_lgd_cs($fileOrFolderObject->getName(), $titleLen)) .
1896 '</a><br />';
1897 }
1898 return $out;
1899 }
1900
1901 /**
1902 * For TYPO3 Element Browser: Expand folder of files.
1903 *
1904 * @param Folder $folder The folder path to expand
1905 * @param string $extensionList List of fileextensions to show
1906 * @param boolean $noThumbs Whether to show thumbnails or not. If set, no thumbnails are shown.
1907 * @return string HTML output
1908 * @todo Define visibility
1909 */
1910 public function TBE_expandFolder(Folder $folder, $extensionList = '', $noThumbs = FALSE) {
1911 if (!$folder->checkActionPermission('read')) {
1912 return '';
1913 }
1914 $extensionList = $extensionList == '*' ? '' : $extensionList;
1915 $files = $this->getFilesInFolder($folder, $extensionList);
1916 return $this->fileList($files, $folder, $noThumbs);
1917 }
1918
1919 /**
1920 * Render list of files.
1921 *
1922 * @param File[] $files List of files
1923 * @param Folder $folder If set a header with a folder icon and folder name are shown
1924 * @param boolean $noThumbs Whether to show thumbnails or not. If set, no thumbnails are shown.
1925 * @return string HTML output
1926 */
1927 protected function fileList(array $files, Folder $folder = NULL, $noThumbs = FALSE) {
1928 $out = '';
1929
1930 $lines = array();
1931 // Create headline (showing number of files):
1932 $filesCount = count($files);
1933 $out .= $this->barheader(sprintf($GLOBALS['LANG']->getLL('files') . ' (%s):', $filesCount));
1934 $out .= '<div id="filelist">';
1935 $out .= $this->getBulkSelector($filesCount);
1936 $titleLen = (int)$GLOBALS['BE_USER']->uc['titleLen'];
1937 // Create the header of current folder:
1938 if ($folder) {
1939 $folderIcon = IconUtility::getSpriteIconForResource($folder);
1940 $lines[] = '<tr class="t3-row-header">
1941 <td colspan="4">' . $folderIcon
1942 . htmlspecialchars(GeneralUtility::fixed_lgd_cs($folder->getIdentifier(), $titleLen)) . '</td>
1943 </tr>';
1944 }
1945 if ($filesCount == 0) {
1946 $lines[] = '
1947 <tr class="file_list_normal">
1948 <td colspan="4">No files found.</td>
1949 </tr>';
1950 }
1951 // Traverse the file list:
1952 /** @var $fileObject \TYPO3\CMS\Core\Resource\File */
1953 foreach ($files as $fileObject) {
1954 $fileExtension = $fileObject->getExtension();
1955 // Thumbnail/size generation:
1956 $imgInfo = array();
1957 if (GeneralUtility::inList(strtolower($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']), strtolower($fileExtension)) && !$noThumbs) {
1958 $imageUrl = $fileObject->process(
1959 \TYPO3\CMS\Core\Resource\ProcessedFile::CONTEXT_IMAGEPREVIEW,
1960 array('width' => 64, 'height' => 64)
1961 )->getPublicUrl(TRUE);
1962 $imgInfo = array(
1963 $fileObject->getProperty('width'),
1964 $fileObject->getProperty('height')
1965 );
1966 $pDim = $imgInfo[0] . 'x' . $imgInfo[1] . ' pixels';
1967 $clickIcon = '<img src="' . $imageUrl . '" hspace="5" vspace="5" border="1" />';
1968 } else {
1969 $clickIcon = '';
1970 $pDim = '';
1971 }
1972 // Create file icon:
1973 $size = ' (' . GeneralUtility::formatSize($fileObject->getSize()) . 'bytes' . ($pDim ? ', ' . $pDim : '') . ')';
1974 $icon = IconUtility::getSpriteIconForResource($fileObject, array('title' => $fileObject->getName() . $size));
1975 // Create links for adding the file:
1976 $filesIndex = count($this->elements);
1977 $this->elements['file_' . $filesIndex] = array(
1978 'type' => 'file',
1979 'table' => 'sys_file',
1980 'uid' => $fileObject->getUid(),
1981 'fileName' => $fileObject->getName(),
1982 'filePath' => $fileObject->getUid(),
1983 'fileExt' => $fileExtension,
1984 'fileIcon' => $icon
1985 );
1986 if ($this->fileIsSelectableInFileList($fileObject, $imgInfo)) {
1987 $ATag = '<a href="#" onclick="return BrowseLinks.File.insertElement(\'file_' . $filesIndex . '\');">';
1988 $ATag_alt = substr($ATag, 0, -4) . ',1);">';
1989 $bulkCheckBox = '<input type="checkbox" class="typo3-bulk-item" name="file_' . $filesIndex . '" value="0" /> ';
1990 $ATag_e = '</a>';
1991 } else {
1992 $ATag = '';
1993 $ATag_alt = '';
1994 $ATag_e = '';
1995 $bulkCheckBox = '';
1996 }
1997 // Create link to showing details about the file in a window:
1998 $Ahref = $GLOBALS['BACK_PATH'] . 'show_item.php?type=file&table=_FILE&uid='
1999 . rawurlencode($fileObject->getCombinedIdentifier())
2000 . '&returnUrl=' . rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI'));
2001 $ATag2 = '<a href="' . htmlspecialchars($Ahref) . '">';
2002 $ATag2_e = '</a>';
2003 // Combine the stuff:
2004 $filenameAndIcon = $bulkCheckBox . $ATag_alt . $icon
2005 . htmlspecialchars(GeneralUtility::fixed_lgd_cs($fileObject->getName(), $titleLen)) . $ATag_e;
2006 // Show element:
2007 if ($pDim) {
2008 // Image...
2009 $lines[] = '
2010 <tr class="file_list_normal">
2011 <td nowrap="nowrap">' . $filenameAndIcon . '&nbsp;</td>
2012 <td>' . ($ATag . '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/plusbullet2.gif',
2013 'width="18" height="16"') . ' title="' . $GLOBALS['LANG']->getLL('addToList', TRUE)
2014 . '" alt="" />' . $ATag_e) . '</td>
2015 <td nowrap="nowrap">' . ($ATag2 . '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'],
2016 'gfx/zoom2.gif', 'width="12" height="12"') . ' title="'
2017 . $GLOBALS['LANG']->getLL('info', TRUE) . '" alt="" /> '
2018 . $GLOBALS['LANG']->getLL('info', TRUE) . $ATag2_e) . '</td>
2019 <td nowrap="nowrap">&nbsp;' . $pDim . '</td>
2020 </tr>';
2021 $lines[] = '
2022 <tr>
2023 <td class="filelistThumbnail" colspan="4">' . $ATag_alt . $clickIcon . $ATag_e . '</td>
2024 </tr>';
2025 } else {
2026 $lines[] = '
2027 <tr class="file_list_normal">
2028 <td nowrap="nowrap">' . $filenameAndIcon . '&nbsp;</td>
2029 <td>' . ($ATag . '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/plusbullet2.gif',
2030 'width="18" height="16"') . ' title="' . $GLOBALS['LANG']->getLL('addToList', TRUE)
2031 . '" alt="" />' . $ATag_e) . '</td>
2032 <td nowrap="nowrap">' . ($ATag2 . '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'],
2033 'gfx/zoom2.gif', 'width="12" height="12"') . ' title="'
2034 . $GLOBALS['LANG']->getLL('info', TRUE) . '" alt="" /> '
2035 . $GLOBALS['LANG']->getLL('info', TRUE) . $ATag2_e) . '</td>
2036 <td>&nbsp;</td>
2037 </tr>';
2038 }
2039 }
2040 // Wrap all the rows in table tags:
2041 $out .= '
2042
2043 <!--
2044 File listing
2045 -->
2046 <table cellpadding="0" cellspacing="0" id="typo3-filelist">
2047 ' . implode('', $lines) . '
2048 </table>';
2049 // Return accumulated content for file listing:
2050 $out .= '</div>';
2051 return $out;
2052 }
2053
2054 /**
2055 * Checks if the given file is selectable in the file list.
2056 *
2057 * By default all files are selectable. This method may be overwritten in child classes.
2058 *
2059 * @param \TYPO3\CMS\Core\Resource\FileInterface $file
2060 * @param array $imgInfo Image dimensions from \TYPO3\CMS\Core\Imaging\GraphicalFunctions::getImageDimensions()
2061 * @return bool TRUE if file is selectable.
2062 */
2063 protected function fileIsSelectableInFileList(\TYPO3\CMS\Core\Resource\FileInterface $file, array $imgInfo) {
2064 return TRUE;
2065 }
2066
2067 /**
2068 * Render list of folders.
2069 *
2070 * @param Folder $baseFolder
2071 * @return string HTML output
2072 * @todo Define visibility
2073 */
2074 public function folderList(Folder $baseFolder) {
2075 $content = '';
2076 $folders = $baseFolder->getSubfolders();
2077 $baseFolderPath = $baseFolder->getPublicUrl();
2078 // Create headline (showing number of folders):
2079 $content .= $this->barheader(sprintf($GLOBALS['LANG']->getLL('folders') . ' (%s):', count($folders)));
2080 $titleLength = (int)$GLOBALS['BE_USER']->uc['titleLen'];
2081 // Create the header of current folder:
2082 $aTag = '<a href="#" onclick="return insertElement(\'\',' . GeneralUtility::quoteJSvalue($baseFolderPath)
2083 . ', \'folder\', ' . GeneralUtility::quoteJSvalue($baseFolderPath) . ', ' . GeneralUtility::quoteJSvalue($baseFolderPath)
2084 . ', \'\', \'\',\'\',1);">';
2085 // Add the foder icon
2086 $folderIcon = $aTag;
2087 $folderIcon .= '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/i/_icon_webfolders.gif',
2088 'width="18" height="16"') . ' alt="" />';
2089 $folderIcon .= htmlspecialchars(GeneralUtility::fixed_lgd_cs(basename($baseFolder), $titleLength));
2090 $folderIcon .= '</a>';
2091 $content .= $folderIcon . '<br />';
2092
2093 $lines = array();
2094 // Traverse the folder list:
2095 foreach ($folders as $folderPath) {
2096 $pathInfo = pathinfo($folderPath);
2097 // Create folder icon:
2098 $icon = '<img src="clear.gif" width="16" height="16" alt="" /><img'
2099 . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/i/_icon_webfolders.gif',
2100 'width="16" height="16"') . ' title="' . htmlspecialchars(($pathInfo['basename']))
2101 . '" class="absmiddle" alt="" />';
2102 // Create links for adding the folder:
2103 if ($this->P['itemName'] != '' && $this->P['formName'] != '') {
2104 $aTag = '<a href="#" onclick="return set_folderpath(' . GeneralUtility::quoteJSvalue($folderPath)
2105 . ');">';
2106 } else {
2107 $aTag = '<a href="#" onclick="return insertElement(\'\',' . GeneralUtility::quoteJSvalue($folderPath)
2108 . ', \'folder\', ' . GeneralUtility::quoteJSvalue($folderPath) . ', '
2109 . GeneralUtility::quoteJSvalue($folderPath) . ', \'' . $pathInfo['extension'] . '\', \'\');">';
2110 }
2111 if (strstr($folderPath, ',') || strstr($folderPath, '|')) {
2112 // In case an invalid character is in the filepath, display error message:
2113 $errorMessage = GeneralUtility::quoteJSvalue(sprintf($GLOBALS['LANG']->getLL('invalidChar'), ', |'));
2114 $aTag = ($aTag_alt = '<a href="#" onclick="alert(' . $errorMessage . ');return false;">');
2115 } else {
2116 // If foldername is OK, just add it:
2117 $aTag_alt = substr($aTag, 0, -4) . ',\'\',1);">';
2118 }
2119 $aTag_e = '</a>';
2120 // Combine icon and folderpath:
2121 $foldernameAndIcon = $aTag_alt . $icon
2122 . htmlspecialchars(GeneralUtility::fixed_lgd_cs(basename($folderPath), $titleLength)) . $aTag_e;
2123 if ($this->P['itemName'] != '') {
2124 $lines[] = '
2125 <tr class="bgColor4">
2126 <td nowrap="nowrap">' . $foldernameAndIcon . '&nbsp;</td>
2127 <td>&nbsp;</td>
2128 </tr>';
2129 } else {
2130 $lines[] = '
2131 <tr class="bgColor4">
2132 <td nowrap="nowrap">' . $foldernameAndIcon . '&nbsp;</td>
2133 <td>' . $aTag . '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/plusbullet2.gif',
2134 'width="18" height="16"') . ' title="' . $GLOBALS['LANG']->getLL('addToList', TRUE)
2135 . '" alt="" />' . $aTag_e . ' </td>
2136 <td>&nbsp;</td>
2137 </tr>';
2138 }
2139 $lines[] = '
2140 <tr>
2141 <td colspan="3"><img src="clear.gif" width="1" height="3" alt="" /></td>
2142 </tr>';
2143 }
2144 // Wrap all the rows in table tags:
2145 $content .= '
2146
2147 <!--
2148 Folder listing
2149 -->
2150 <table border="0" cellpadding="0" cellspacing="1" id="typo3-folderList">
2151 ' . implode('', $lines) . '
2152 </table>';
2153 // Return accumulated content for folderlisting:
2154 return $content;
2155 }
2156
2157 /**
2158 * For RTE: This displays all IMAGES (gif,png,jpg) (from extensionList) from folder. Thumbnails are shown for images.
2159 * This listing is of images located in the web-accessible paths ONLY - the listing is for drag-n-drop use in the RTE
2160 *
2161 * @param Folder $folder The folder path to expand
2162 * @param string $extensionList List of file extensions to show
2163 * @return string HTML output
2164 * @todo Define visibility
2165 */
2166 public function TBE_dragNDrop(Folder $folder, $extensionList = '') {
2167 if (!$folder) {
2168 return '';
2169 }
2170 if (!$folder->getStorage()->isPublic()) {
2171 // Print this warning if the folder is NOT a web folder
2172 return $this->barheader($GLOBALS['LANG']->getLL('files'))
2173 . $this->getMsgBox($GLOBALS['LANG']->getLL('noWebFolder'), 'icon_warning2');
2174 }
2175 $out = '';
2176
2177 // Read files from directory:
2178 $extensionList = $extensionList == '*' ? '' : $extensionList;
2179 $files = $this->getFilesInFolder($folder, $extensionList);
2180
2181 $out .= $this->barheader(sprintf($GLOBALS['LANG']->getLL('files') . ' (%s):', count($files)));
2182 $titleLen = (int)$GLOBALS['BE_USER']->uc['titleLen'];
2183 $picon = '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/i/_icon_webfolders.gif', 'width="18" height="16"') . ' alt="" />';
2184 $picon .= htmlspecialchars(GeneralUtility::fixed_lgd_cs(basename($folder->getName()), $titleLen));
2185 $out .= $picon . '<br />';
2186 // Init row-array:
2187 $lines = array();
2188 // Add "drag-n-drop" message:
2189 $lines[] = '
2190 <tr>
2191 <td colspan="2">' . $this->getMsgBox($GLOBALS['LANG']->getLL('findDragDrop')) . '</td>
2192 </tr>';
2193 // Traverse files:
2194 foreach ($files as $fileObject) {
2195 $fileInfo = $fileObject->getStorage()->getFileInfo($fileObject);
2196 // URL of image:
2197 $iUrl = GeneralUtility::rawurlencodeFP($fileObject->getPublicUrl(TRUE));
2198 // Show only web-images
2199 $fileExtension = strtolower($fileObject->getExtension());
2200 if (GeneralUtility::inList('gif,jpeg,jpg,png', $fileExtension)) {
2201 $imgInfo = array(
2202 $fileObject->getProperty('width'),
2203 $fileObject->getProperty('height')
2204 );
2205 $pDim = $imgInfo[0] . 'x' . $imgInfo[1] . ' pixels';
2206 $size = ' (' . GeneralUtility::formatSize($fileObject->getSize()) . 'bytes' . ($pDim ? ', ' . $pDim : '') . ')';
2207 $filenameAndIcon = IconUtility::getSpriteIconForResource($fileObject, array('title' => $fileObject->getName() . $size));
2208 if (GeneralUtility::_GP('noLimit')) {
2209 $maxW = 10000;
2210 $maxH = 10000;
2211 } else {
2212 $maxW = 380;
2213 $maxH = 500;
2214 }
2215 $IW = $imgInfo[0];
2216 $IH = $imgInfo[1];
2217 if ($IW > $maxW) {
2218 $IH = ceil($IH / $IW * $maxW);
2219 $IW = $maxW;
2220 }
2221 if ($IH > $maxH) {
2222 $IW = ceil($IW / $IH * $maxH);
2223 $IH = $maxH;
2224 }
2225 // Make row:
2226 $lines[] = '
2227 <tr class="bgColor4">
2228 <td nowrap="nowrap">' . $filenameAndIcon . '&nbsp;</td>
2229 <td nowrap="nowrap">' . ($imgInfo[0] != $IW
2230 ? '<a href="' . htmlspecialchars(GeneralUtility::linkThisScript(array('noLimit' => '1')))
2231 . '">' . '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/icon_warning2.gif',
2232 'width="18" height="16"') . ' title="'
2233 . $GLOBALS['LANG']->getLL('clickToRedrawFullSize', TRUE) . '" alt="" />' . '</a>'
2234 : '')
2235 . $pDim . '&nbsp;</td>
2236 </tr>';
2237 $lines[] = '
2238 <tr>
2239 <td colspan="2"><img src="' . htmlspecialchars($iUrl) . '" data-htmlarea-file-uid="' . $fileObject->getUid()
2240 . '" width="' . htmlspecialchars($IW) . '" height="' . htmlspecialchars($IH) . '" border="1" alt="" /></td>
2241 </tr>';
2242 $lines[] = '
2243 <tr>
2244 <td colspan="2"><img src="clear.gif" width="1" height="3" alt="" /></td>
2245 </tr>';
2246 }
2247 }
2248 // Finally, wrap all rows in a table tag:
2249 $out .= '
2250
2251
2252 <!--
2253 File listing / Drag-n-drop
2254 -->
2255 <table border="0" cellpadding="0" cellspacing="1" id="typo3-dragBox">
2256 ' . implode('', $lines) . '
2257 </table>';
2258
2259 return $out;
2260 }
2261
2262 /******************************************************************
2263 *
2264 * Miscellaneous functions
2265 *
2266 ******************************************************************/
2267 /**
2268 * Verifies that a path is a web-folder:
2269 *
2270 * @param string $folder Absolute filepath
2271 * @return boolean If the input path is found in PATH_site then it returns TRUE.
2272 * @deprecated since 6.2 - will be removed two versions later without replacement
2273 */
2274 public function isWebFolder($folder) {
2275 GeneralUtility::logDeprecatedFunction();
2276 $folder = rtrim($folder, '/') . '/';
2277 return GeneralUtility::isFirstPartOfStr($folder, PATH_site) ? TRUE : FALSE;
2278 }
2279
2280 /**
2281 * Checks, if a path is within the mountpoints of the backend user
2282 *
2283 * @param string $folder Absolute filepath
2284 * @return boolean If the input path is found in the backend users filemounts, then return TRUE.
2285 * @deprecated since 6.2 - will be removed two versions later without replacement
2286 */
2287 public function checkFolder($folder) {
2288 GeneralUtility::logDeprecatedFunction();
2289 return $this->fileProcessor->checkPathAgainstMounts(rtrim($folder, '/') . '/') ? TRUE : FALSE;
2290 }
2291
2292 /**
2293 * Prints a 'header' where string is in a tablecell
2294 *
2295 * @param string $str The string to print in the header. The value is htmlspecialchars()'ed before output.
2296 * @return string The header HTML (wrapped in a table)
2297 * @todo Define visibility
2298 */
2299 public function barheader($str) {
2300 return '
2301 <!-- Bar header: -->
2302 <h3>' . htmlspecialchars($str) . '</h3>
2303 ';
2304 }
2305
2306 /**
2307 * Displays a message box with the input message
2308 *
2309 * @param string $in_msg Input message to show (will be htmlspecialchars()'ed inside of this function)
2310 * @param string $icon Icon filename body from gfx/ (default is "icon_note") - meant to allow change to warning type icons...
2311 * @return string HTML for the message (wrapped in a table).
2312 * @todo Define visibility
2313 */
2314 public function getMsgBox($in_msg, $icon = 'icon_note') {
2315 $msg = '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], ('gfx/' . $icon . '.gif'), 'width="18" height="16"')
2316 . ' alt="" />' . htmlspecialchars($in_msg);
2317 $msg = '
2318
2319 <!--
2320 Message box:
2321 -->
2322 <table cellspacing="0" class="bgColor4" id="typo3-msgBox">
2323 <tr>
2324 <td>' . $msg . '</td>
2325 </tr>
2326 </table>
2327 ';
2328 return $msg;
2329 }
2330
2331 /**
2332 * For RTE/link: This prints the 'currentUrl'
2333 *
2334 * @param string $str URL value. The value is htmlspecialchars()'ed before output.
2335 * @return string HTML content, wrapped in a table.
2336 * @todo Define visibility
2337 */
2338 public function printCurrentUrl($str) {
2339 // Output the folder or file identifier, when working with files
2340 if (isset($str) && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($str)
2341 && ($this->act === 'file' || $this->act === 'folder')
2342 ) {
2343 try {
2344 $fileObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->retrieveFileOrFolderObject($str);
2345 } catch (\TYPO3\CMS\Core\Resource\Exception\FileDoesNotExistException $e) {
2346 $fileObject = NULL;
2347 }
2348 $str = is_object($fileObject) ? $fileObject->getIdentifier() : '';
2349 }
2350 if (strlen($str)) {
2351 return '
2352 <!-- Print current URL -->
2353 <table border="0" cellpadding="0" cellspacing="0" id="typo3-curUrl">
2354 <tr>
2355 <td>' . $GLOBALS['LANG']->getLL('currentLink', TRUE) . ': '
2356 . htmlspecialchars(rawurldecode($str)) . '</td>
2357 </tr>
2358 </table>';
2359 } else {
2360 return '';
2361 }
2362 }
2363
2364 /**
2365 * For RTE/link: Parses the incoming URL and determines if it's a page, file, external or mail address.
2366 *
2367 * @param string $href HREF value tp analyse
2368 * @param string $siteUrl The URL of the current website (frontend)
2369 * @return array Array with URL information stored in assoc. keys: value, act (page, file, spec, mail), pageid, cElement, info
2370 * @todo Define visibility
2371 */
2372 public function parseCurUrl($href, $siteUrl) {
2373 $href = trim($href);
2374 if ($href) {
2375 $info = array();
2376 // Default is "url":
2377 $info['value'] = $href;
2378 $info['act'] = 'url';
2379 $specialParts = explode('#_SPECIAL', $href);
2380 // Special kind (Something RTE specific: User configurable links through: "userLinks." from ->thisConfig)
2381 if (count($specialParts) == 2) {
2382 $info['value'] = '#_SPECIAL' . $specialParts[1];
2383 $info['act'] = 'spec';
2384 } elseif (strpos($href, 'file:') !== FALSE) {
2385 $rel = substr($href, strpos($href, 'file:') + 5);
2386 $rel = rawurldecode($rel);
2387 // resolve FAL-api "file:UID-of-sys_file-record" and "file:combined-identifier"
2388 $fileOrFolderObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->retrieveFileOrFolderObject($rel);
2389 if ($fileOrFolderObject instanceof Folder) {
2390 $info['act'] = 'folder';
2391 $info['value'] = $fileOrFolderObject->getCombinedIdentifier();
2392 } elseif ($fileOrFolderObject instanceof File) {
2393 $info['act'] = 'file';
2394 $info['value'] = $fileOrFolderObject->getUid();
2395 } else {
2396 $info['value'] = $rel;
2397 }
2398 } elseif (GeneralUtility::isFirstPartOfStr($href, $siteUrl)) {
2399 // If URL is on the current frontend website:
2400 // URL is a file, which exists:
2401 if (file_exists(PATH_site . rawurldecode($href))) {
2402 $info['value'] = rawurldecode($href);
2403 if (@is_dir((PATH_site . $info['value']))) {
2404 $info['act'] = 'folder';
2405 } else {
2406 $info['act'] = 'file';
2407 }
2408 } else {
2409 // URL is a page (id parameter)
2410 $uP = parse_url($href);
2411
2412 $pp = preg_split('/^id=/', $uP['query']);
2413 $pp[1] = preg_replace('/&id=[^&]*/', '', $pp[1]);
2414 $parameters = explode('&', $pp[1]);
2415 $id = array_shift($parameters);
2416 if ($id) {
2417 // Checking if the id-parameter is an alias.
2418 if (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($id)) {
2419 list($idPartR) = BackendUtility::getRecordsByField('pages', 'alias', $id);
2420 $id = (int)$idPartR['uid'];
2421 }
2422 $pageRow = BackendUtility::getRecordWSOL('pages', $id);
2423 $titleLen = (int)$GLOBALS['BE_USER']->uc['titleLen'];
2424 $info['value'] = ((((($GLOBALS['LANG']->getLL('page', TRUE) . ' \'')
2425 . htmlspecialchars(GeneralUtility::fixed_lgd_cs($pageRow['title'], $titleLen)))
2426 . '\' (ID:') . $id) . ($uP['fragment'] ? ', #' . $uP['fragment'] : '')) . ')';
2427 $info['pageid'] = $id;
2428 $info['cElement'] = $uP['fragment'];
2429 $info['act'] = 'page';
2430 $info['query'] = $parameters[0] ? '&' . implode('&', $parameters) : '';
2431 }
2432 }
2433 } else {
2434 // Email link:
2435 if (strtolower(substr($href, 0, 7)) == 'mailto:') {
2436 $info['value'] = trim(substr($href, 7));
2437 $info['act'] = 'mail';
2438 }
2439 }
2440 $info['info'] = $info['value'];
2441 } else {
2442 // NO value input:
2443 $info = array();
2444 $info['info'] = $GLOBALS['LANG']->getLL('none');
2445 $info['value'] = '';
2446 $info['act'] = 'page';
2447 }
2448 // let the hook have a look
2449 foreach ($this->hookObjects as $hookObject) {
2450 $info = $hookObject->parseCurrentUrl($href, $siteUrl, $info);
2451 }
2452 return $info;
2453 }
2454
2455 /**
2456 * Setter for the class that should be used by TBE_expandPage() to generate the record list.
2457 * This method is intended to be used by Extensions that implement their own browsing functionality.
2458 *
2459 * @param \TYPO3\CMS\Backend\RecordList\ElementBrowserRecordList $recordList
2460 * @throws \InvalidArgumentException
2461 * @return void
2462 * @api
2463 */
2464 public function setRecordList($recordList) {
2465 if (!$recordList instanceof \TYPO3\CMS\Backend\RecordList\ElementBrowserRecordList) {
2466 throw new \InvalidArgumentException('$recordList needs to be an instance of \\TYPO3\\CMS\\Backend\\RecordList\\ElementBrowserRecordList', 1370878522);
2467 }
2468 $this->recordList = $recordList;
2469 }
2470
2471 /**
2472 * For TBE: Makes an upload form for uploading files to the filemount the user is browsing.
2473 * The files are uploaded to the tce_file.php script in the core which will handle the upload.
2474 *
2475 * @param Folder $folderObject Absolute filepath on server to which to upload.
2476 * @return string HTML for an upload form.
2477 * @todo Define visibility
2478 */
2479 public function uploadForm(Folder $folderObject) {
2480 if (!$folderObject->checkActionPermission('write')) {
2481 return '';
2482 }
2483 // Read configuration of upload field count
2484 $userSetting = $GLOBALS['BE_USER']->getTSConfigVal('options.folderTree.uploadFieldsInLinkBrowser');
2485 $count = isset($userSetting) ? $userSetting : 1;
2486 if ($count === '0') {
2487 return '';
2488 }
2489 $count = (int)$count === 0 ? 1 : (int)$count;
2490 // Create header, showing upload path:
2491 $header = $folderObject->getIdentifier();
2492 $code = '
2493 <br />
2494 <!--
2495 Form, for uploading files:
2496 -->
2497 <form action="' . $GLOBALS['BACK_PATH'] . 'tce_file.php" method="post" name="editform"'
2498 . 'id="typo3-uplFilesForm" enctype="' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'] . '">
2499 <table border="0" cellpadding="0" cellspacing="0" id="typo3-uplFiles">
2500 <tr>
2501 <td>' . $this->barheader($GLOBALS['LANG']->sL(
2502 'LLL:EXT:lang/locallang_core.xlf:file_upload.php.pagetitle', TRUE) . ':') . '</td>
2503 </tr>
2504 <tr>
2505 <td class="c-wCell c-hCell"><strong>' . $GLOBALS['LANG']->getLL('path', TRUE) . ':</strong> '
2506 . htmlspecialchars($header) . '</td>
2507 </tr>
2508 <tr>
2509 <td class="c-wCell c-hCell">';
2510 // Traverse the number of upload fields (default is 3):
2511 for ($a = 1; $a <= $count; $a++) {
2512 $code .= '<input type="file" multiple="multiple" name="upload_' . $a . '[]"' . $this->doc->formWidth(35)
2513 . ' size="50" />
2514 <input type="hidden" name="file[upload][' . $a . '][target]" value="'
2515 . htmlspecialchars($folderObject->getCombinedIdentifier()) . '" />
2516 <input type="hidden" name="file[upload][' . $a . '][data]" value="' . $a . '" /><br />';
2517 }
2518 // Make footer of upload form, including the submit button:
2519 $redirectValue = $this->getThisScript() . 'act=' . $this->act . '&mode=' . $this->mode
2520 . '&expandFolder=' . rawurlencode($folderObject->getCombinedIdentifier())
2521 . '&bparams=' . rawurlencode($this->bparams);
2522 $code .= '<input type="hidden" name="redirect" value="' . htmlspecialchars($redirectValue) . '" />';
2523 $code .= \TYPO3\CMS\Backend\Form\FormEngine::getHiddenTokenField('tceAction');
2524 $code .= '
2525 <div id="c-override">
2526 <label><input type="checkbox" name="overwriteExistingFiles" id="overwriteExistingFiles" value="1" /> '
2527 . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xlf:overwriteExistingFiles', TRUE) . '</label>
2528 </div>
2529 <input type="submit" name="submit" value="'
2530 . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:file_upload.php.submit', TRUE) . '" />
2531 ';
2532 $code .= '</td>
2533 </tr>
2534 </table>
2535 </form><br />';
2536 return $code;
2537 }
2538
2539 /**
2540 * For TBE: Makes a form for creating new folders in the filemount the user is browsing.
2541 * The folder creation request is sent to the tce_file.php script in the core which will handle the creation.
2542 *
2543 * @param Folder $folderObject Absolute filepath on server in which to create the new folder.
2544 * @return string HTML for the create folder form.
2545 * @todo Define visibility
2546 */
2547 public function createFolder(Folder $folderObject) {
2548 if (!$folderObject->checkActionPermission('write')) {
2549 return '';
2550 }
2551 if (!($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['BE_USER']->getTSConfigVal('options.createFoldersInEB'))) {
2552 return '';
2553 }
2554 // Don't show Folder-create form if it's denied
2555 if ($GLOBALS['BE_USER']->getTSConfigVal('options.folderTree.hideCreateFolder')) {
2556 return '';
2557 }
2558 // Create header, showing upload path:
2559 $header = $folderObject->getIdentifier();
2560 $code = '
2561
2562 <!--
2563 Form, for creating new folders:
2564 -->
2565 <form action="' . $GLOBALS['BACK_PATH'] . 'tce_file.php" method="post" name="editform2" id="typo3-crFolderForm">
2566 <table border="0" cellpadding="0" cellspacing="0" id="typo3-crFolder">
2567 <tr>
2568 <td>' . $this->barheader($GLOBALS['LANG']->sL(
2569 'LLL:EXT:lang/locallang_core.xlf:file_newfolder.php.pagetitle') . ':') . '</td>
2570 </tr>
2571 <tr>
2572 <td class="c-wCell c-hCell"><strong>'
2573 . $GLOBALS['LANG']->getLL('path', TRUE) . ':</strong> ' . htmlspecialchars($header) . '</td>
2574 </tr>
2575 <tr>
2576 <td class="c-wCell c-hCell">';
2577 // Create the new-folder name field:
2578 $a = 1;
2579 $code .= '<input' . $this->doc->formWidth(20) . ' type="text" name="file[newfolder][' . $a . '][data]" />'
2580 . '<input type="hidden" name="file[newfolder][' . $a . '][target]" value="'
2581 . htmlspecialchars($folderObject->getCombinedIdentifier()) . '" />';
2582 // Make footer of upload form, including the submit button:
2583 $redirectValue = $this->getThisScript() . 'act=' . $this->act . '&mode=' . $this->mode
2584 . '&expandFolder=' . rawurlencode($folderObject->getCombinedIdentifier())
2585 . '&bparams=' . rawurlencode($this->bparams);
2586 $code .= '<input type="hidden" name="redirect" value="' . htmlspecialchars($redirectValue) . '" />'
2587 . \TYPO3\CMS\Backend\Form\FormEngine::getHiddenTokenField('tceAction')
2588 . '<input type="submit" name="submit" value="'
2589 . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:file_newfolder.php.submit', TRUE) . '" />';
2590 $code .= '</td>
2591 </tr>
2592 </table>
2593 </form>';
2594 return $code;
2595 }
2596
2597 /**
2598 * Get the HTML data required for a bulk selection of files of the TYPO3 Element Browser.
2599 *
2600 * @param integer $filesCount Number of files currently displayed
2601 * @return string HTML data required for a bulk selection of files - if $filesCount is 0, nothing is returned
2602 * @todo Define visibility
2603 */
2604 public function getBulkSelector($filesCount) {
2605 if (!$filesCount) {
2606 return '';
2607 }
2608
2609 $labelToggleSelection = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_browse_links.xlf:toggleSelection', TRUE);
2610 $labelImportSelection = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_browse_links.xlf:importSelection', TRUE);
2611 // Getting flag for showing/not showing thumbnails:
2612 $noThumbsInEB = $GLOBALS['BE_USER']->getTSConfigVal('options.noThumbsInEB');
2613 $out = $this->doc->spacer(10) . '<div>' . '<a href="#" onclick="BrowseLinks.Selector.handle()">'
2614 . '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/import.gif', 'width="12" height="12"')
2615 . ' title="' . $labelImportSelection . '" alt="" /> ' . $labelImportSelection . '</a>&nbsp;&nbsp;&nbsp;'
2616 . '<a href="#" onclick="BrowseLinks.Selector.toggle()">' . '<img'
2617 . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/clip_select.gif', 'width="12" height="12"')
2618 . ' title="' . $labelToggleSelection . '" alt="" /> ' . $labelToggleSelection . '</a>' . '</div>';
2619 $thumbNailCheck = '';
2620 if (!$noThumbsInEB && $this->selectedFolder) {
2621 // MENU-ITEMS, fetching the setting for thumbnails from File>List module:
2622 $_MOD_MENU = array('displayThumbs' => '');
2623 $_MCONF['name'] = 'file_list';
2624 $_MOD_SETTINGS = BackendUtility::getModuleData($_MOD_MENU, GeneralUtility::_GP('SET'), $_MCONF['name']);
2625 $addParams = '&act=' . $this->act . '&mode=' . $this->mode
2626 . '&expandFolder=' . rawurlencode($this->selectedFolder->getCombinedIdentifier())
2627 . '&bparams=' . rawurlencode($this->bparams);
2628 $thumbNailCheck = BackendUtility::getFuncCheck('', 'SET[displayThumbs]', $_MOD_SETTINGS['displayThumbs'],
2629 GeneralUtility::_GP('M') ? '' : $this->thisScript, $addParams, 'id="checkDisplayThumbs"')
2630 . ' <label for="checkDisplayThumbs">'
2631 . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xlf:displayThumbs', TRUE) . '</label>';
2632 $out .= $this->doc->spacer(5) . $thumbNailCheck . $this->doc->spacer(15);
2633 } else {
2634 $out .= $this->doc->spacer(15);
2635 }
2636 return $out;
2637 }
2638
2639 /**
2640 * Determines whether submitted field change functions are valid
2641 * and are coming from the system and not from an external abuse.
2642 *
2643 * @param boolean $handleFlexformSections Whether to handle flexform sections differently
2644 * @return boolean Whether the submitted field change functions are valid
2645 */
2646 protected function areFieldChangeFunctionsValid($handleFlexformSections = FALSE) {
2647 $result = FALSE;
2648 if (isset($this->P['fieldChangeFunc']) && is_array($this->P['fieldChangeFunc']) && isset($this->P['fieldChangeFuncHash'])) {
2649 $matches = array();
2650 $pattern = '#\\[el\\]\\[(([^]-]+-[^]-]+-)(idx\\d+-)([^]]+))\\]#i';
2651 $fieldChangeFunctions = $this->P['fieldChangeFunc'];
2652 // Special handling of flexform sections:
2653 // Field change functions are modified in JavaScript, thus the hash is always invalid
2654 if ($handleFlexformSections && preg_match($pattern, $this->P['itemName'], $matches)) {
2655 $originalName = $matches[1];
2656 $cleanedName = $matches[2] . $matches[4];
2657 foreach ($fieldChangeFunctions as &$value) {
2658 $value = str_replace($originalName, $cleanedName, $value);
2659 }
2660 unset($value);
2661 }
2662 $result = $this->P['fieldChangeFuncHash'] === GeneralUtility::hmac(serialize($fieldChangeFunctions));
2663 }
2664 return $result;
2665 }
2666
2667 /**
2668 * Check if a temporary tree mount is set and return a cancel button
2669 *
2670 * @return string
2671 */
2672 protected function getTemporaryTreeMountCancelNotice() {
2673 if ((int)$GLOBALS['BE_USER']->getSessionData('pageTree_temporaryMountPoint') === 0) {
2674 return '';
2675 }
2676 $link = '<a href="' . htmlspecialchars(GeneralUtility::linkThisScript(array('setTempDBmount' => 0))) . '">'
2677 . $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_core.xlf:labels.temporaryDBmount', TRUE) . '</a>';
2678 /** @var \TYPO3\CMS\Core\Messaging\FlashMessage $flashMessage */
2679 $flashMessage = GeneralUtility::makeInstance(
2680 'TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
2681 $link,
2682 '',
2683 \TYPO3\CMS\Core\Messaging\FlashMessage::INFO
2684 );
2685 return $flashMessage->render();
2686 }
2687
2688 /**
2689 * Get a list of Files in a folder filtered by extension
2690 *
2691 * @param \TYPO3\CMS\Core\Resource\Folder $folder
2692 * @param string $extensionList
2693 * @return \TYPO3\CMS\Core\Resource\File[]
2694 */
2695 protected function getFilesInFolder(\TYPO3\CMS\Core\Resource\Folder $folder, $extensionList) {
2696 if ($extensionList !== '') {
2697 /** @var \TYPO3\CMS\Core\Resource\Filter\FileExtensionFilter $filter */
2698 $filter = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\Filter\\FileExtensionFilter');
2699 $filter->setAllowedFileExtensions($extensionList);
2700 $folder->setFileAndFolderNameFilters(array(array($filter, 'filterFileList')));
2701 }
2702 return $folder->getFiles();
2703 }
2704 }