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