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