[TASK] Clean up phpDoc comments 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">'.$A[0].'<strong>'.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="" />':'').'</strong><br />'.$description.$A[1].'</td>
1385 </tr>';
1386 }
1387 }
1388
1389 // Sort by keys:
1390 ksort($subcats);
1391
1392 // Add menu to content:
1393 $content .= '
1394
1395 <!--
1396 Special userdefined menu:
1397 -->
1398 <table border="0" cellpadding="1" cellspacing="1" id="typo3-linkSpecial">
1399 <tr>
1400 <td class="bgColor5" class="c-wCell" valign="top"><strong>' . $GLOBALS['LANG']->getLL('special', 1) . '</strong></td>
1401 </tr>
1402 '.implode('', $subcats).'
1403 </table>
1404 ';
1405 }
1406 break;
1407 case 'page':
1408 $pagetree = t3lib_div::makeInstance('rtePageTree');
1409 $pagetree->thisScript = $this->thisScript;
1410 $pagetree->ext_showPageId = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showPageIdWithTitle');
1411 $pagetree->ext_showNavTitle = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showNavTitle');
1412 $pagetree->addField('nav_title');
1413 $tree=$pagetree->getBrowsableTree();
1414 $cElements = $this->expandPage();
1415
1416 // Outputting Temporary DB mount notice:
1417 if (intval($GLOBALS['BE_USER']->getSessionData('pageTree_temporaryMountPoint'))) {
1418 $link = '<a href="' . htmlspecialchars(t3lib_div::linkThisScript(array('setTempDBmount' => 0))) . '">' .
1419 $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_core.xml:labels.temporaryDBmount', 1) .
1420 '</a>';
1421 $flashMessage = t3lib_div::makeInstance(
1422 't3lib_FlashMessage',
1423 $link,
1424 '',
1425 t3lib_FlashMessage::INFO
1426 );
1427 $dbmount = $flashMessage->render();
1428 }
1429
1430 $content .= '
1431
1432 <!--
1433 Wrapper table for page tree / record list:
1434 -->
1435 <table border="0" cellpadding="0" cellspacing="0" id="typo3-linkPages">
1436 <tr>
1437 <td class="c-wCell" valign="top">' . $this->barheader($GLOBALS['LANG']->getLL('pageTree') . ':') . $dbmount . $tree . '</td>
1438 <td class="c-wCell" valign="top">'.$cElements.'</td>
1439 </tr>
1440 </table>
1441 ';
1442 break;
1443 default:
1444 // Call hook
1445 foreach ($this->hookObjects as $hookObject) {
1446 $content .= $hookObject->getTab($this->act);
1447 }
1448 break;
1449 }
1450
1451 if (in_array('params', $allowedFields, TRUE)) {
1452 $content .= '
1453 <!--
1454 Selecting params for link:
1455 -->
1456 <form action="" name="lparamsform" id="lparamsform">
1457 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkParams">
1458 <tr>
1459 <td style="width: 96px;">' . $GLOBALS['LANG']->getLL('params', 1) . '</td>
1460 <td><input type="text" name="lparams" class="typo3-link-input" onchange="browse_links_setParams(this.value);" value="' . htmlspecialchars($this->setParams) . '" /></td>
1461 </tr>
1462 </table>
1463 </form>
1464 ';
1465 }
1466
1467 if (in_array('class', $allowedFields, TRUE)) {
1468 $content .= '
1469 <!--
1470 Selecting class for link:
1471 -->
1472 <form action="" name="lclassform" id="lclassform">
1473 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkClass">
1474 <tr>
1475 <td style="width: 96px;">' . $GLOBALS['LANG']->getLL('class', 1) . '</td>
1476 <td><input type="text" name="lclass" class="typo3-link-input" onchange="browse_links_setClass(this.value);" value="' . htmlspecialchars($this->setClass) . '" /></td>
1477 </tr>
1478 </table>
1479 </form>
1480 ';
1481 }
1482
1483 if (in_array('title', $allowedFields, TRUE)) {
1484 $content .= '
1485 <!--
1486 Selecting title for link:
1487 -->
1488 <form action="" name="ltitleform" id="ltitleform">
1489 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkTitle">
1490 <tr>
1491 <td style="width: 96px;">' . $GLOBALS['LANG']->getLL('title', 1) . '</td>
1492 <td><input type="text" name="ltitle" class="typo3-link-input" onchange="browse_links_setTitle(this.value);" value="' . htmlspecialchars($this->setTitle) . '" /></td>
1493 </tr>
1494 </table>
1495 </form>
1496 ';
1497 }
1498
1499 // additional fields for page links
1500 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'])) {
1501 $_params = array(
1502 'conf' => &$conf,
1503 );
1504 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['addFields_PageLink'] as $objRef) {
1505 $processor = &t3lib_div::getUserObj($objRef);
1506 $content .= $processor->addFields( $_params, $this);
1507 }
1508 }
1509
1510 // Target:
1511 if ($this->act != 'mail' && in_array('target', $allowedFields, TRUE)) {
1512 $ltarget='
1513
1514 <!--
1515 Selecting target for link:
1516 -->
1517 <form action="" name="ltargetform" id="ltargetform">
1518 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkTarget">
1519 <tr>
1520 <td>'.$GLOBALS['LANG']->getLL('target', 1).':</td>
1521 <td><input type="text" name="ltarget" onchange="browse_links_setTarget(this.value);" value="' . htmlspecialchars($this->setTarget) . '"' . $this->doc->formWidth(10) . ' /></td>
1522 <td>
1523 <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;">
1524 <option></option>
1525 <option value="_top">'.$GLOBALS['LANG']->getLL('top', 1).'</option>
1526 <option value="_blank">'.$GLOBALS['LANG']->getLL('newWindow', 1).'</option>
1527 </select>
1528 </td>
1529 <td>';
1530 if (($this->curUrlInfo['act'] == 'page' || $this->curUrlInfo['act'] == 'file' || $this->curUrlInfo['act'] == 'folder') && $this->curUrlArray['href'] && $this->curUrlInfo['act'] == $this->act) {
1531 $ltarget.='
1532 <input type="submit" value="'.$GLOBALS['LANG']->getLL('update', 1).'" onclick="return link_current();" />';
1533 }
1534
1535 $selectJS = '
1536 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) {
1537 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;
1538 browse_links_setTarget(document.ltargetform.ltarget.value);
1539 browse_links_setClass(document.lclassform.lclass.value);
1540 browse_links_setTitle(document.ltitleform.ltitle.value);
1541 browse_links_setParams(document.lparamsform.lparams.value);
1542 document.ltargetform.popup_width.selectedIndex=0;
1543 document.ltargetform.popup_height.selectedIndex=0;
1544 }
1545 ';
1546
1547 $ltarget .= ' </td>
1548 </tr>
1549 <tr>
1550 <td>'.$GLOBALS['LANG']->getLL('target_popUpWindow', 1).':</td>
1551 <td colspan="3">
1552 <select name="popup_width" onchange="'.htmlspecialchars($selectJS).'">
1553 <option value="0">'.$GLOBALS['LANG']->getLL('target_popUpWindow_width', 1).'</option>
1554 <option value="300">300</option>
1555 <option value="400">400</option>
1556 <option value="500">500</option>
1557 <option value="600">600</option>
1558 <option value="700">700</option>
1559 <option value="800">800</option>
1560 </select>
1561 x
1562 <select name="popup_height" onchange="'.htmlspecialchars($selectJS).'">
1563 <option value="0">'.$GLOBALS['LANG']->getLL('target_popUpWindow_height', 1).'</option>
1564 <option value="200">200</option>
1565 <option value="300">300</option>
1566 <option value="400">400</option>
1567 <option value="500">500</option>
1568 <option value="600">600</option>
1569 </select>
1570 </td>
1571 </tr>
1572 </table>
1573 </form>';
1574
1575 // Add "target selector" box to content:
1576 $content .= $ltarget;
1577
1578 // Add some space
1579 $content .= '<br /><br />';
1580 }
1581
1582 // End page, return content:
1583 $content .= $this->doc->endPage();
1584 $content = $this->doc->insertStylesAndJS($content);
1585 return $content;
1586 }
1587
1588 /**
1589 * TYPO3 Element Browser: Showing a page tree and allows you to browse for records
1590 *
1591 * @return string HTML content for the module
1592 */
1593 function main_db() {
1594
1595 // Starting content:
1596 $content=$this->doc->startPage('TBE record selector');
1597
1598 // Init variable:
1599 $pArr = explode('|', $this->bparams);
1600
1601 // Making the browsable pagetree:
1602 $pagetree = t3lib_div::makeInstance('TBE_PageTree');
1603 $pagetree->thisScript=$this->thisScript;
1604 $pagetree->ext_pArrPages = !strcmp($pArr[3], 'pages')?1:0;
1605 $pagetree->ext_showNavTitle = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showNavTitle');
1606 $pagetree->ext_showPageId = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showPageIdWithTitle');
1607 $pagetree->addField('nav_title');
1608 $tree=$pagetree->getBrowsableTree();
1609
1610 // Making the list of elements, if applicable:
1611 $cElements = $this->TBE_expandPage($pArr[3]);
1612
1613 // Putting the things together, side by side:
1614 $content .= '
1615
1616 <!--
1617 Wrapper table for page tree / record list:
1618 -->
1619 <table border="0" cellpadding="0" cellspacing="0" id="typo3-EBrecords">
1620 <tr>
1621 <td class="c-wCell" valign="top">'.$this->barheader($GLOBALS['LANG']->getLL('pageTree').':').$tree.'</td>
1622 <td class="c-wCell" valign="top">'.$cElements.'</td>
1623 </tr>
1624 </table>
1625 ';
1626
1627 // Add some space
1628 $content .= '<br /><br />';
1629
1630 // End page, return content:
1631 $content .= $this->doc->endPage();
1632 $content = $this->doc->insertStylesAndJS($content);
1633 return $content;
1634 }
1635
1636 /**
1637 * TYPO3 Element Browser: Showing a folder tree, allowing you to browse for files.
1638 *
1639 * @return string HTML content for the module
1640 */
1641 function main_file() {
1642 // include JS files and set prefs for foldertree
1643 $this->doc->getDragDropCode('folders');
1644 $this->doc->JScode .= $this->doc->wrapScriptTags('
1645 Tree.ajaxID = "SC_alt_file_navframe::expandCollapse";
1646 ');
1647
1648 // Starting content:
1649 $content = $this->doc->startPage('TBE file selector');
1650
1651
1652 // Init variable:
1653 $pArr = explode('|', $this->bparams);
1654
1655 // 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
1656 $allowed = $pArr[3];
1657
1658 if ($allowed !== 'sys_file') {
1659 $allowedFileExtensions = $allowed;
1660 }
1661
1662 $this->storages = $GLOBALS['BE_USER']->getFileStorages();
1663
1664 if (isset($allowedFileExtensions)) {
1665 // Create new filter object
1666 $filterObject = t3lib_div::makeInstance('t3lib_file_Utility_FileExtensionFilter');
1667 $filterObject->setAllowedFileExtensions($allowedFileExtensions);
1668
1669 // Set file extension filters on all storages
1670 /** @var $storage t3lib_file_Storage */
1671 foreach ($this->storages as $storage) {
1672 $storage->addFileAndFolderNameFilter(array($filterObject, 'filterFileList'));
1673 }
1674 }
1675
1676 // Create upload/create folder forms, if a path is given:
1677 if ($this->expandFolder) {
1678 $this->selectedFolder = t3lib_file_Factory::getInstance()->getFolderObjectFromCombinedIdentifier($this->expandFolder);
1679 }
1680
1681 // @todo implement upload stuff (default upload folder of a storaget etc)
1682 if (!$this->selectedFolder) {
1683 $fileStorages = $GLOBALS['BE_USER']->getFileStorages();
1684 $fileStorage = reset($fileStorages);
1685 $this->selectedFolder = $fileStorage->getRootLevelFolder();
1686 }
1687
1688 if ($this->selectedFolder) {
1689 $uploadForm = $this->uploadForm($this->selectedFolder);
1690 $createFolder = $this->createFolder($this->selectedFolder);
1691 } else {
1692 $uploadForm = $createFolder = '';
1693 }
1694
1695 if ($GLOBALS['BE_USER']->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
1696 $content .= $uploadForm;
1697 }
1698
1699 // Getting flag for showing/not showing thumbnails:
1700 $noThumbs = $GLOBALS['BE_USER']->getTSConfigVal('options.noThumbsInEB');
1701
1702 if (!$noThumbs) {
1703 // MENU-ITEMS, fetching the setting for thumbnails from File>List module:
1704 $_MOD_MENU = array('displayThumbs' => '');
1705 $_MCONF['name'] = 'file_list';
1706 $_MOD_SETTINGS = t3lib_BEfunc::getModuleData($_MOD_MENU, t3lib_div::_GP('SET'), $_MCONF['name']);
1707 }
1708 $noThumbs = $noThumbs ? $noThumbs : !$_MOD_SETTINGS['displayThumbs'];
1709
1710 // Create folder tree:
1711 $foldertree = t3lib_div::makeInstance('TBE_FolderTree');
1712 $foldertree->thisScript=$this->thisScript;
1713 $foldertree->ext_noTempRecyclerDirs = ($this->mode == 'filedrag');
1714 $tree=$foldertree->getBrowsableTree();
1715
1716 list(,,$specUid) = explode('_', $this->PM);
1717
1718 if ($this->mode == 'filedrag') {
1719 $files = $this->TBE_dragNDrop($this->selectedFolder, $pArr[3]);
1720 } else {
1721 $files = $this->TBE_expandFolder($this->selectedFolder, $pArr[3], $noThumbs);
1722 }
1723
1724 // Putting the parts together, side by side:
1725 $content .= '
1726
1727 <!--
1728 Wrapper table for folder tree / file list:
1729 -->
1730 <table border="0" cellpadding="0" cellspacing="0" id="typo3-EBfiles">
1731 <tr>
1732 <td class="c-wCell" valign="top">'.$this->barheader($GLOBALS['LANG']->getLL('folderTree').':').$tree.'</td>
1733 <td class="c-wCell" valign="top">'.$files.'</td>
1734 </tr>
1735 </table>
1736 ';
1737
1738 // Adding create folder + upload forms if applicable:
1739 if (!$GLOBALS['BE_USER']->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
1740 $content .= $uploadForm;
1741 }
1742 if ($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['BE_USER']->getTSConfigVal('options.createFoldersInEB')) {
1743 $content .= $createFolder;
1744 }
1745
1746 // Add some space
1747 $content .= '<br /><br />';
1748
1749 // Setup indexed elements:
1750 $this->doc->JScode .= $this->doc->wrapScriptTags('BrowseLinks.addElements(' . json_encode($this->elements) . ');');
1751 // Ending page, returning content:
1752 $content .= $this->doc->endPage();
1753 $content = $this->doc->insertStylesAndJS($content);
1754
1755 return $content;
1756 }
1757
1758 /**
1759 * TYPO3 Element Browser: Showing a folder tree, allowing you to browse for folders.
1760 *
1761 * @return string HTML content for the module
1762 */
1763 function main_folder() {
1764
1765 // include JS files
1766 $this->doc->getDragDropCode('folders');
1767
1768 // Setting prefs for foldertree
1769 $this->doc->JScode .= $this->doc->wrapScriptTags('
1770 Tree.ajaxID = "SC_alt_file_navframe::expandCollapse";
1771 ');
1772
1773 // Starting content:
1774 $content = $this->doc->startPage('TBE folder selector');
1775
1776 // Init variable:
1777 $parameters = explode('|', $this->bparams);
1778
1779 if ($this->expandFolder) {
1780 $this->selectedFolder = t3lib_file_Factory::getInstance()->getFolderObjectFromCombinedIdentifier($this->expandFolder);
1781 }
1782
1783 if ($this->selectedFolder) {
1784 $createFolder = $this->createFolder($this->selectedFolder);
1785 } else {
1786 $createFolder = '';
1787 }
1788
1789 // Create folder tree:
1790 $foldertree = t3lib_div::makeInstance('TBE_FolderTree');
1791 $foldertree->thisScript = $this->thisScript;
1792 $foldertree->ext_noTempRecyclerDirs = ($this->mode == 'filedrag');
1793 $tree = $foldertree->getBrowsableTree(FALSE);
1794
1795 list(, , $specUid) = explode('_', $this->PM);
1796
1797 if ($this->mode == 'filedrag') {
1798 $folders = $this->TBE_dragNDrop($this->selectedFolder, $parameters[3]);
1799 } else {
1800 $folders = $this->TBE_expandSubFolders($this->selectedFolder);
1801 }
1802
1803 // Putting the parts together, side by side:
1804 $content .= '
1805
1806 <!--
1807 Wrapper table for folder tree / folder list:
1808 -->
1809 <table border="0" cellpadding="0" cellspacing="0" id="typo3-EBfiles">
1810 <tr>
1811 <td class="c-wCell" valign="top">'.$this->barheader($GLOBALS['LANG']->getLL('folderTree').':').$tree.'</td>
1812 <td class="c-wCell" valign="top">'.$folders.'</td>
1813 </tr>
1814 </table>
1815 ';
1816
1817 // Adding create folder if applicable:
1818 if ($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['BE_USER']->getTSConfigVal('options.createFoldersInEB')) {
1819 $content .= $createFolder;
1820 }
1821
1822 // Add some space
1823 $content .= '<br /><br />';
1824
1825 // Ending page, returning content:
1826 $content .= $this->doc->endPage();
1827 $content = $this->doc->insertStylesAndJS($content);
1828
1829 return $content;
1830 }
1831
1832 /******************************************************************
1833 *
1834 * Record listing
1835 *
1836 ******************************************************************/
1837
1838 /**
1839 * For RTE: This displays all content elements on a page and lets you create a link to the element.
1840 *
1841 * @return string HTML output. Returns content only if the ->expandPage value is set (pointing to a page uid to show tt_content records from ...)
1842 */
1843 function expandPage() {
1844 $out = '';
1845 // Set page id (if any) to expand
1846 $expPageId = $this->expandPage;
1847
1848 // If there is an anchor value (content element reference) in the element reference, then force an ID to expand:
1849 if (!$this->expandPage && $this->curUrlInfo['cElement']) {
1850 // Set to the current link page id.
1851 $expPageId = $this->curUrlInfo['pageid'];
1852 }
1853
1854 // Draw the record list IF there is a page id to expand:
1855 if ($expPageId && t3lib_utility_Math::canBeInterpretedAsInteger($expPageId) && $GLOBALS['BE_USER']->isInWebMount($expPageId)) {
1856
1857 // Set header:
1858 $out .= $this->barheader($GLOBALS['LANG']->getLL('contentElements').':');
1859
1860 // Create header for listing, showing the page title/icon:
1861 $titleLen = intval($GLOBALS['BE_USER']->uc['titleLen']);
1862 $mainPageRec = t3lib_BEfunc::getRecordWSOL('pages', $expPageId);
1863 $picon = t3lib_iconWorks::getSpriteIconForRecord('pages', $mainPageRec);
1864 $picon .= t3lib_BEfunc::getRecordTitle('pages', $mainPageRec, TRUE);
1865 $out .= $picon.'<br />';
1866
1867 // Look up tt_content elements from the expanded page:
1868 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1869 'uid,header,hidden,starttime,endtime,fe_group,CType,colPos,bodytext',
1870 'tt_content',
1871 'pid='.intval($expPageId).
1872 t3lib_BEfunc::deleteClause('tt_content').
1873 t3lib_BEfunc::versioningPlaceholderClause('tt_content'),
1874 '',
1875 'colPos,sorting'
1876 );
1877 $cc = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
1878
1879 // Traverse list of records:
1880 $c = 0;
1881 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
1882 $c++;
1883 $icon = t3lib_iconWorks::getSpriteIconForRecord('tt_content', $row);
1884 if ($this->curUrlInfo['act'] == 'page' && $this->curUrlInfo['cElement'] == $row['uid']) {
1885 $arrCol='<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/blinkarrow_left.gif', 'width="5" height="9"').' class="c-blinkArrowL" alt="" />';
1886 } else {
1887 $arrCol = '';
1888 }
1889 // Putting list element HTML together:
1890 $out .= '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/ol/join'.($c==$cc?'bottom':'').'.gif', 'width="18" height="16"').' alt="" />'.
1891 $arrCol.
1892 '<a href="#" onclick="return link_typo3Page(\''.$expPageId.'\',\'#'.$row['uid'].'\');">'.
1893 $icon.
1894 t3lib_BEfunc::getRecordTitle('tt_content', $row, TRUE) .
1895 '</a><br />';
1896
1897 // Finding internal anchor points:
1898 if (t3lib_div::inList('text,textpic', $row['CType'])) {
1899 $split = preg_split('/(<a[^>]+name=[\'"]?([^"\'>[:space:]]+)[\'"]?[^>]*>)/i', $row['bodytext'], -1, PREG_SPLIT_DELIM_CAPTURE);
1900
1901 foreach ($split as $skey => $sval) {
1902 if (($skey%3) == 2) {
1903 // Putting list element HTML together:
1904 $sval = substr($sval, 0, 100);
1905 $out .= '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/ol/line.gif', 'width="18" height="16"').' alt="" />'.
1906 '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/ol/join'.($skey+3>count($split)?'bottom':'').'.gif', 'width="18" height="16"').' alt="" />'.
1907 '<a href="#" onclick="return link_typo3Page(\''.$expPageId.'\',\'#'.rawurlencode($sval).'\');">'.
1908 htmlspecialchars(' <A> '.$sval).
1909 '</a><br />';
1910 }
1911 }
1912 }
1913 }
1914 }
1915 return $out;
1916 }
1917
1918 /**
1919 * For TYPO3 Element Browser: This lists all content elements from the given list of tables
1920 *
1921 * @param string $tables Commalist of tables. Set to "*" if you want all tables.
1922 * @return string HTML output.
1923 */
1924 function TBE_expandPage($tables) {
1925 $out = '';
1926 if ($this->expandPage >= 0 && t3lib_utility_Math::canBeInterpretedAsInteger($this->expandPage) && $GLOBALS['BE_USER']->isInWebMount($this->expandPage)) {
1927
1928 // Set array with table names to list:
1929 if (!strcmp(trim($tables), '*')) {
1930 $tablesArr = array_keys($GLOBALS['TCA']);
1931 } else {
1932 $tablesArr = t3lib_div::trimExplode(',', $tables, 1);
1933 }
1934 reset($tablesArr);
1935
1936 // Headline for selecting records:
1937 $out .= $this->barheader($GLOBALS['LANG']->getLL('selectRecords').':');
1938
1939 // Create the header, showing the current page for which the listing is. Includes link to the page itself, if pages are amount allowed tables.
1940 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
1941 $mainPageRec = t3lib_BEfunc::getRecordWSOL('pages', $this->expandPage);
1942 $ATag = '';
1943 $ATag_e = '';
1944 $ATag2 = '';
1945 $picon = '';
1946 if (is_array($mainPageRec)) {
1947 $picon = t3lib_iconWorks::getSpriteIconForRecord('pages', $mainPageRec);
1948 if (in_array('pages', $tablesArr)) {
1949 $ATag = "<a href=\"#\" onclick=\"return insertElement('pages', '" . $mainPageRec['uid'] .
1950 "', 'db', " . t3lib_div::quoteJSvalue($mainPageRec['title']) . ", '', '', '','',1);\">";
1951 $ATag2 = "<a href=\"#\" onclick=\"return insertElement('pages', '" . $mainPageRec['uid'] .
1952 "', 'db', " . t3lib_div::quoteJSvalue($mainPageRec['title']) . ", '', '', '','',0);\">";
1953 $ATag_alt = substr($ATag, 0, -4) . ",'',1);\">";
1954 $ATag_e = '</a>';
1955 }
1956 }
1957 $pBicon = ($ATag2 ? '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/plusbullet2.gif', 'width="18" height="16"') . ' alt="" />' : '');
1958 $pText = htmlspecialchars(t3lib_div::fixed_lgd_cs($mainPageRec['title'], $titleLen));
1959 $out .= $picon.$ATag2.$pBicon.$ATag_e.$ATag.$pText.$ATag_e.'<br />';
1960
1961 // Initialize the record listing:
1962 $id = $this->expandPage;
1963 $pointer = t3lib_utility_Math::forceIntegerInRange($this->pointer, 0, 100000);
1964 $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
1965 $pageinfo = t3lib_BEfunc::readPageAccess($id, $perms_clause);
1966 $table = '';
1967
1968 // Generate the record list:
1969 /** @var $dblist TBE_browser_recordList */
1970 $dblist = t3lib_div::makeInstance('TBE_browser_recordList');
1971 $dblist->thisScript = $this->thisScript;
1972 $dblist->backPath = $GLOBALS['BACK_PATH'];
1973 $dblist->thumbs = 0;
1974 $dblist->calcPerms = $GLOBALS['BE_USER']->calcPerms($pageinfo);
1975 $dblist->noControlPanels = 1;
1976 $dblist->clickMenuEnabled = 0;
1977 $dblist->tableList = implode(',', $tablesArr);
1978
1979 $pArr = explode('|', $this->bparams);
1980 // a string like "data[pages][79][storage_pid]"
1981 $fieldPointerString = $pArr[0];
1982 // parts like: data, pages], 79], storage_pid]
1983 $fieldPointerParts = explode('[', $fieldPointerString);
1984 $relatingTableName = substr($fieldPointerParts[1], 0, -1);
1985 $relatingFieldName = substr($fieldPointerParts[3], 0, -1);
1986
1987 if ($relatingTableName && $relatingFieldName) {
1988 $dblist->setRelatingTableAndField($relatingTableName, $relatingFieldName);
1989 }
1990
1991 $dblist->start($id, t3lib_div::_GP('table'), $pointer,
1992 t3lib_div::_GP('search_field'),
1993 t3lib_div::_GP('search_levels'),
1994 t3lib_div::_GP('showLimit')
1995 );
1996 $dblist->setDispFields();
1997 $dblist->generateList();
1998 $dblist->writeBottom();
1999
2000 // Add the HTML for the record list to output variable:
2001 $out .= $dblist->HTMLcode;
2002
2003 // Add support for fieldselectbox in singleTableMode
2004 if ($dblist->table) {
2005 $out .= $dblist->fieldSelectBox($dblist->table);
2006 }
2007
2008 $out .= $dblist->getSearchBox();
2009 }
2010
2011 // Return accumulated content:
2012 return $out;
2013 }
2014
2015 /**
2016 * Render list of folders inside a folder.
2017 *
2018 * @param string $folder String of the current folder
2019 * @return string HTML output
2020 */
2021 function TBE_expandSubFolders(t3lib_file_Folder $folder) {
2022 $content = '';
2023
2024 if ($folder->checkActionPermission('browse')) {
2025 $content .= $this->folderList($folder);
2026 }
2027
2028 // Return accumulated content for folderlisting:
2029 return $content;
2030 }
2031
2032 /******************************************************************
2033 *
2034 * File listing
2035 *
2036 ******************************************************************/
2037 /**
2038 * For RTE: This displays all files from folder. No thumbnails shown
2039 *
2040 * @param string $folder The folder path to expand
2041 * @param string $extensionList List of fileextensions to show
2042 * @return string HTML output
2043 */
2044 function expandFolder(t3lib_file_Folder $folder, $extensionList = '') {
2045 $out = '';
2046 $renderFolders = ($this->act === 'folder');
2047 if ($folder->checkActionPermission('browse')) {
2048
2049 // Create header for filelisting:
2050 $out .= $this->barheader($GLOBALS['LANG']->getLL('files').':');
2051
2052 // Prepare current path value for comparison (showing red arrow)
2053 $currentIdentifier = '';
2054 if ($this->curUrlInfo['value']) {
2055 $currentIdentifier = $this->curUrlInfo['info'];
2056 }
2057
2058 // Create header element; The folder from which files are listed.
2059 $titleLen = intval($GLOBALS['BE_USER']->uc['titleLen']);
2060
2061 $folderIcon = t3lib_iconWorks::getSpriteIconForFile('folder');
2062 $folderIcon .= htmlspecialchars(t3lib_div::fixed_lgd_cs($folder->getIdentifier(), $titleLen));
2063
2064 $picon = '<a href="#" onclick="return link_folder(\'file:'.$folder->getCombinedIdentifier().'\');">' . $folderIcon . '</a>';
2065 if ($this->curUrlInfo['act'] == 'folder' && $currentIdentifier == $folder->getCombinedIdentifier()) {
2066 $out.= '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/blinkarrow_left.gif', 'width="5" height="9"') . ' class="c-blinkArrowL" alt="" />';
2067 }
2068 $out.=$picon.'<br />';
2069
2070 // Get files from the folder:
2071 if ($renderFolders) {
2072 $items = $folder->getSubfolders();
2073 } else {
2074 $items = $folder->getFiles($extensionList);
2075 }
2076
2077 $c = 0;
2078 $totalItems = count($items);
2079 foreach ($items as $fileOrFolderObject) {
2080 $c++;
2081
2082 if ($renderFolders) {
2083 $fileIdentifier = $fileOrFolderObject->getCombinedIdentifier();
2084 $icon = t3lib_iconWorks::getSpriteIconForFile('folder');
2085 $itemUid = 'file:' . $fileIdentifier;
2086 } else {
2087 $fileIdentifier = $fileOrFolderObject->getUid();
2088 // File icon:
2089 $fileExtension = $fileOrFolderObject->getExtension();
2090 // Get size and icon:
2091 $size = ' (' . t3lib_div::formatSize($fileOrFolderObject->getSize()) . 'bytes)';
2092 $icon = t3lib_iconWorks::getSpriteIconForFile($fileExtension, array('title' => $fileOrFolderObject->getName() . $size));
2093 $itemUid = 'file:' . $fileIdentifier;
2094 }
2095
2096 // If the listed file turns out to be the CURRENT file, then show blinking arrow:
2097 if (($this->curUrlInfo['act'] == 'file' || $this->curUrlInfo['act'] == 'folder') && $currentIdentifier == $fileIdentifier) {
2098 $arrCol = '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/blinkarrow_left.gif', 'width="5" height="9"').' class="c-blinkArrowL" alt="" />';
2099 } else {
2100 $arrCol = '';
2101 }
2102
2103 // Put it all together for the file element:
2104 $out.='<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/ol/join'.($c == $totalItems ?'bottom':'').'.gif','width="18" height="16"').' alt="" />'.
2105 $arrCol.
2106 '<a href="#" onclick="return link_folder(\'' . $itemUid . '\');">'.
2107 $icon.
2108 htmlspecialchars(t3lib_div::fixed_lgd_cs($fileOrFolderObject->getName(), $titleLen)).
2109 '</a><br />';
2110 }
2111 }
2112 return $out;
2113 }
2114
2115 /**
2116 * For TYPO3 Element Browser: Expand folder of files.
2117 *
2118 * @param t3lib_file_Folder $folder The folder path to expand
2119 * @param string $extensionList List of fileextensions to show
2120 * @param boolean $noThumbs Whether to show thumbnails or not. If set, no thumbnails are shown.
2121 * @return string HTML output
2122 */
2123 function TBE_expandFolder(t3lib_file_Folder $folder, $extensionList = '', $noThumbs = 0) {
2124 $extensionList = ($extensionList == '*') ? '' : $extensionList;
2125 $content = '';
2126 if ($folder->checkActionPermission('browse')) {
2127 // Listing the files:
2128 $files = $folder->getFiles($extensionList);
2129 $content = $this->fileList($files, $folder, $noThumbs);
2130 }
2131 // Return accumulated content for filelisting:
2132 return $content;
2133 }
2134
2135 /**
2136 * Render list of files.
2137 *
2138 * @param array $files List of files. See t3lib_div::getFilesInDir
2139 * @param string t3lib_file_Folder $folder If set a header with a folder icon and folder name are shown
2140 * @param boolean $noThumbs Whether to show thumbnails or not. If set, no thumbnails are shown.
2141 * @return string HTML output
2142 */
2143 function fileList(array $files, t3lib_file_Folder $folder = NULL, $noThumbs=0) {
2144 $out = '';
2145 // Listing the files:
2146 if (is_array($files)) {
2147 $lines = array();
2148
2149 // Create headline (showing number of files):
2150 $filesCount = count($files);
2151 $out .= $this->barheader(sprintf($GLOBALS['LANG']->getLL('files').' (%s):', $filesCount));
2152 $out .= '<div id="filelist">';
2153 $out .= $this->getBulkSelector($filesCount);
2154
2155 $titleLen = intval($GLOBALS['BE_USER']->uc['titleLen']);
2156
2157 // Create the header of current folder:
2158 if ($folder) {
2159 $folderIcon = t3lib_iconWorks::getSpriteIconForFile('folder');
2160 $lines[] = '<tr class="t3-row-header">
2161 <td colspan="4">' . $folderIcon . htmlspecialchars(t3lib_div::fixed_lgd_cs($folder->getIdentifier(), $titleLen)) . '</td>
2162 </tr>';
2163 }
2164
2165 if ($filesCount == 0) {
2166 $lines[]='
2167 <tr class="file_list_normal">
2168 <td colspan="4">No files found.</td>
2169 </tr>';
2170 }
2171
2172 // Init graphic object for reading file dimensions:
2173 /** @var $imgObj t3lib_stdGraphic */
2174 $imgObj = t3lib_div::makeInstance('t3lib_stdGraphic');
2175 $imgObj->init();
2176 $imgObj->mayScaleUp = 0;
2177 $imgObj->tempPath = PATH_site . $imgObj->tempPath;
2178
2179 // Traverse the file list:
2180 foreach ($files as $fileObject) {
2181 $fileExtension = $fileObject->getExtension();
2182 // Thumbnail/size generation:
2183 if (t3lib_div::inList(strtolower($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']), strtolower($fileExtension)) && !$noThumbs) {
2184 $imageUrl = $fileObject->process(
2185 t3lib_file_ProcessedFile::CONTEXT_IMAGEPREVIEW,
2186 array('width' => 64, 'height' => 64)
2187 )->getPublicUrl(TRUE);
2188
2189 $imgInfo = $imgObj->getImageDimensions($fileObject->getForLocalProcessing(FALSE));
2190 $pDim = $imgInfo[0].'x'.$imgInfo[1].' pixels';
2191 $clickIcon = '<img src="' . $imageUrl . '" hspace="5" vspace="5" border="1"';
2192 } else {
2193 $clickIcon = '';
2194 $pDim = '';
2195 }
2196
2197 // Create file icon:
2198 $size = ' ('.t3lib_div::formatSize($fileObject->getSize()) . 'bytes' . ($pDim ? ', ' . $pDim : '') . ')';
2199 $icon = t3lib_iconWorks::getSpriteIconForFile($fileExtension, array('title' => $fileObject->getName() . $size));
2200
2201 // Create links for adding the file:
2202 $filesIndex = count($this->elements);
2203 $this->elements['file_' . $filesIndex] = array(
2204 'type' => 'file',
2205 'table' => 'sys_file',
2206 'uid' => $fileObject->getUid(),
2207 'fileName' => $fileObject->getName(),
2208 'filePath' => $fileObject->getUid(),
2209 'fileExt' => $fileExtension,
2210 'fileIcon' => $icon,
2211 );
2212 $ATag = "<a href=\"#\" onclick=\"return BrowseLinks.File.insertElement('file_" . $filesIndex . "');\">";
2213 $ATag_alt = substr($ATag, 0, -4) . ',1);">';
2214 $bulkCheckBox = '<input type="checkbox" class="typo3-bulk-item" name="file_'.$filesIndex.'" value="0" /> ';
2215
2216 $ATag_e = '</a>';
2217
2218 // Create link to showing details about the file in a window:
2219 $Ahref = $GLOBALS['BACK_PATH'].'show_item.php?type=file&table=_FILE&uid='.rawurlencode($fileObject->getCombinedIdentifier()).'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
2220 $ATag2 = '<a href="'.htmlspecialchars($Ahref).'">';
2221 $ATag2_e = '</a>';
2222
2223 // Combine the stuff:
2224 $filenameAndIcon = $bulkCheckBox . $ATag_alt . $icon . htmlspecialchars(t3lib_div::fixed_lgd_cs($fileObject->getName(), $titleLen)) . $ATag_e;
2225
2226 // Show element:
2227 // Image...
2228 if ($pDim) {
2229 $lines[] = '
2230 <tr class="file_list_normal">
2231 <td nowrap="nowrap">'.$filenameAndIcon.'&nbsp;</td>
2232 <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>
2233 <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>
2234 <td nowrap="nowrap">&nbsp;'.$pDim.'</td>
2235 </tr>';
2236 $lines[] = '
2237 <tr>
2238 <td class="filelistThumbnail" colspan="4">' . $ATag_alt . $clickIcon . $ATag_e . '</td>
2239 </tr>';
2240 } else {
2241 $lines[] = '
2242 <tr class="file_list_normal">
2243 <td nowrap="nowrap">'.$filenameAndIcon.'&nbsp;</td>
2244 <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>
2245 <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>
2246 <td>&nbsp;</td>
2247 </tr>';
2248 }
2249 }
2250
2251 // Wrap all the rows in table tags:
2252 $out.='
2253
2254 <!--
2255 File listing
2256 -->
2257 <table cellpadding="0" cellspacing="0" id="typo3-filelist">
2258 '.implode('', $lines).'
2259 </table>';
2260 }
2261 // Return accumulated content for filelisting:
2262 $out .= '</div>';
2263 return $out;
2264 }
2265
2266 /**
2267 * Render list of folders.
2268 *
2269 * @param array $baseFolder List of folders. See t3lib_div::get_dirs
2270 * @param string $folders If set a header with a folder icon and folder name are shown
2271 * @return string HTML output
2272 */
2273 function folderList($baseFolder, $folders) {
2274 $content = '';
2275
2276 // Create headline (showing number of folders):
2277 $content .= $this->barheader(
2278 sprintf($GLOBALS['LANG']->getLL('folders').' (%s):',count($folders))
2279 );
2280
2281 $titleLength = intval($GLOBALS['BE_USER']->uc['titleLen']);
2282
2283 // Create the header of current folder:
2284 if ($baseFolder) {
2285 if (strstr($baseFolder, ',') || strstr($baseFolder, '|')) {
2286 // In case an invalid character is in the filepath, display error message:
2287 $errorMessage = $GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->getLL('invalidChar'), ', |'));
2288 $aTag = $aTag_alt = '<a href="#" onclick="alert(' . $errorMessage . ');return false;">';
2289 } else {
2290 // If foldername is OK, just add it:
2291 $aTag = "<a href=\"#\" onclick=\"return insertElement('','".rawurlencode($baseFolder)."', 'folder', '".rawurlencode($baseFolder)."', unescape('".rawurlencode($baseFolder)."'), '".$fI['extension']."', '".$ficon."');\">";
2292 $aTag_alt = substr($aTag, 0, -4).",'',1);\">";
2293 }
2294 $aTag_e = '</a>';
2295
2296 // Add the foder icon
2297 $folderIcon = $aTag_alt;
2298 $folderIcon .= '<img'.t3lib_iconWorks::skinImg(
2299 $GLOBALS['BACK_PATH'],
2300 'gfx/i/_icon_webfolders.gif','width="18" height="16"'
2301 ).' alt="" />';
2302 $folderIcon .= htmlspecialchars(
2303 t3lib_div::fixed_lgd_cs(basename($baseFolder), $titleLength)
2304 );
2305 $folderIcon .= $aTag_e;
2306
2307 $content .= $folderIcon.'<br />';
2308 }
2309
2310 // Listing the folders:
2311 if (is_array($folders)) {
2312 if (count($folders) > 0) {
2313 // Traverse the folder list:
2314 $lines = array();
2315 foreach ($folders as $folderPath) {
2316 $pathInfo = pathinfo($folderPath);
2317
2318 // Create folder icon:
2319 $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="" />';
2320
2321 // Create links for adding the folder:
2322 if ($this->P['itemName'] != '' && $this->P['formName'] != '') {
2323 $aTag = "<a href=\"#\" onclick=\"return set_folderpath(unescape('".rawurlencode($folderPath)."'));\">";
2324 } else {
2325 $aTag = "<a href=\"#\" onclick=\"return insertElement('','".rawurlencode($folderPath)."', 'folder', '".rawurlencode($folderPath)."', unescape('".rawurlencode($folderPath)."'), '".$pathInfo['extension']."', '".$ficon."');\">";
2326 }
2327
2328 if (strstr($folderPath, ',') || strstr($folderPath, '|')) {
2329 // In case an invalid character is in the filepath, display error message:
2330 $errorMessage = $GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->getLL('invalidChar'), ', |'));
2331 $aTag = $aTag_alt = '<a href="#" onclick="alert(' . $errorMessage . ');return false;">';
2332 } else {
2333 // If foldername is OK, just add it:
2334 $aTag_alt = substr($aTag, 0, -4).",'',1);\">";
2335 }
2336 $aTag_e = '</a>';
2337
2338 // Combine icon and folderpath:
2339 $foldernameAndIcon = $aTag_alt.$icon.htmlspecialchars(
2340 t3lib_div::fixed_lgd_cs(basename($folderPath), $titleLength)
2341 ).$aTag_e;
2342
2343 if ($this->P['itemName'] != '') {
2344 $lines[] = '
2345 <tr class="bgColor4">
2346 <td nowrap="nowrap">'.$foldernameAndIcon.'&nbsp;</td>
2347 <td>&nbsp;</td>
2348 </tr>';
2349 } else {
2350 $lines[] = '
2351 <tr class="bgColor4">
2352 <td nowrap="nowrap">'.$foldernameAndIcon.'&nbsp;</td>
2353 <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>
2354 <td>&nbsp;</td>
2355 </tr>';
2356 }
2357
2358 $lines[] = '
2359 <tr>
2360 <td colspan="3"><img src="clear.gif" width="1" height="3" alt="" /></td>
2361 </tr>';
2362 }
2363 }
2364
2365 // Wrap all the rows in table tags:
2366 $content .= '
2367
2368 <!--
2369 Folder listing
2370 -->
2371 <table border="0" cellpadding="0" cellspacing="1" id="typo3-folderList">
2372 '.implode('', $lines).'
2373 </table>';
2374 }
2375
2376 // Return accumulated content for folderlisting:
2377 return $content;
2378 }
2379
2380 /**
2381 * For RTE: This displays all IMAGES (gif,png,jpg) (from extensionList) from folder. Thumbnails are shown for images.
2382 * This listing is of images located in the web-accessible paths ONLY - the listing is for drag-n-drop use in the RTE
2383 *
2384 * @param t3lib_file_Folder $folder The folder path to expand
2385 * @param string $extensionList List of fileextensions to show
2386 * @return string HTML output
2387 */
2388 function TBE_dragNDrop(t3lib_file_Folder $folder, $extensionList = '') {
2389 $extensionList = ($extensionList == '*') ? '' : $extensionList;
2390 $out = '';
2391 if ($folder) {
2392 if ($folder->getStorage()->isPublic()) {
2393
2394 // Read files from directory:
2395 $files = $folder->getFiles($extensionList);
2396 if (is_array($files)) {
2397 $out .= $this->barheader(sprintf($GLOBALS['LANG']->getLL('files').' (%s):', count($files)));
2398
2399 $titleLen = intval($GLOBALS['BE_USER']->uc['titleLen']);
2400 $picon = '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/i/_icon_webfolders.gif', 'width="18" height="16"') . ' alt="" />';
2401 $picon .= htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($folder->getName()), $titleLen));
2402 $out .= $picon . '<br />';
2403
2404 // Init row-array:
2405 $lines = array();
2406
2407 // Add "drag-n-drop" message:
2408 $lines[] = '
2409 <tr>
2410 <td colspan="2">'.$this->getMsgBox($GLOBALS['LANG']->getLL('findDragDrop')).'</td>
2411 </tr>';
2412
2413 // Traverse files:
2414 foreach ($files as $fileObject) {
2415 $fileInfo = $fileObject->getStorage()->getFileInfo($fileObject);
2416
2417 // URL of image:
2418 $iUrl = t3lib_div::rawurlencodeFP($fileObject->getPublicUrl(TRUE));
2419
2420 // Show only web-images
2421 $fileExtension = strtolower($fileObject->getExtension());
2422 if (t3lib_div::inList('gif,jpeg,jpg,png', $fileExtension)) {
2423 $imgInfo = @getimagesize($fileObject->getForLocalProcessing(FALSE));
2424 $pDim = $imgInfo[0] . 'x' . $imgInfo[1] . ' pixels';
2425
2426 $size = ' ('.t3lib_div::formatSize($fileObject->getSize()) . 'bytes' . ($pDim ? ', ' . $pDim : '') . ')';
2427 $filenameAndIcon = t3lib_iconWorks::getSpriteIconForFile($fileExtension, array('title' => $fileObject->getName() . $size));
2428
2429 if (t3lib_div::_GP('noLimit')) {
2430 $maxW=10000;
2431 $maxH=10000;
2432 } else {
2433 $maxW=380;
2434 $maxH=500;
2435 }
2436 $IW = $imgInfo[0];
2437 $IH = $imgInfo[1];
2438 if ($IW>$maxW) {
2439 $IH=ceil($IH/$IW*$maxW);
2440 $IW=$maxW;
2441 }
2442 if ($IH>$maxH) {
2443 $IW=ceil($IW/$IH*$maxH);
2444 $IH=$maxH;
2445 }
2446
2447 // Make row:
2448 $lines[] = '
2449 <tr class="bgColor4">
2450 <td nowrap="nowrap">'.$filenameAndIcon.'&nbsp;</td>
2451 <td nowrap="nowrap">'.
2452 ($imgInfo[0]!=$IW ? '<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('noLimit'=>'1'))).'">'.
2453 '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/icon_warning2.gif', 'width="18" height="16"').' title="'.$GLOBALS['LANG']->getLL('clickToRedrawFullSize', 1).'" alt="" />'.
2454 '</a>':'').
2455 $pDim.'&nbsp;</td>
2456 </tr>';
2457
2458 $lines[] = '
2459 <tr>
2460 <td colspan="2"><img src="' . $iUrl . '" data-htmlarea-file-uid="' . $fileObject->getUid() . '" width="'.$IW.'" height="'.$IH.'" border="1" alt="" /></td>
2461 </tr>';
2462 $lines[] = '
2463 <tr>
2464 <td colspan="2"><img src="clear.gif" width="1" height="3" alt="" /></td>
2465 </tr>';
2466 }
2467 }
2468
2469 // Finally, wrap all rows in a table tag:
2470 $out .= '
2471
2472
2473 <!--
2474 File listing / Drag-n-drop
2475 -->
2476 <table border="0" cellpadding="0" cellspacing="1" id="typo3-dragBox">
2477 '.implode('', $lines).'
2478 </table>';
2479 }
2480 } else {
2481 // Print this warning if the folder is NOT a web folder:
2482 $out .= $this->barheader($GLOBALS['LANG']->getLL('files'));
2483 $out .= $this->getMsgBox($GLOBALS['LANG']->getLL('noWebFolder'), 'icon_warning2');
2484 }
2485 }
2486 return $out;
2487 }
2488
2489 /******************************************************************
2490 *
2491 * Miscellaneous functions
2492 *
2493 ******************************************************************/
2494
2495 /**
2496 * Verifies that a path is a web-folder:
2497 *
2498 * @param string $folder Absolute filepath
2499 * @return boolean If the input path is found in PATH_site then it returns TRUE.
2500 */
2501 function isWebFolder($folder) {
2502 $folder = rtrim($folder, '/').'/';
2503 return t3lib_div::isFirstPartOfStr($folder, PATH_site) ? TRUE : FALSE;
2504 }
2505
2506 /**
2507 * Checks, if a path is within the mountpoints of the backend user
2508 *
2509 * @param string $folder Absolute filepath
2510 * @return boolean If the input path is found in the backend users filemounts, then return TRUE.
2511 */
2512 function checkFolder($folder) {
2513 return $this->fileProcessor->checkPathAgainstMounts(rtrim($folder, '/') . '/') ? TRUE : FALSE;
2514 }
2515
2516 /**
2517 * Checks, if a path is within a read-only mountpoint of the backend user
2518 *
2519 * @param string $folder Absolute filepath
2520 * @return boolean If the input path is found in the backend users filemounts and if the filemount is of type readonly, then return TRUE.
2521 */
2522 function isReadOnlyFolder($folder) {
2523 return ($GLOBALS['FILEMOUNTS'][$this->fileProcessor->checkPathAgainstMounts(rtrim($folder, '/') . '/')]['type'] == 'readonly');
2524 }
2525
2526 /**
2527 * Prints a 'header' where string is in a tablecell
2528 *
2529 * @param string $str The string to print in the header. The value is htmlspecialchars()'ed before output.
2530 * @return string The header HTML (wrapped in a table)
2531 */
2532 function barheader($str) {
2533 return '
2534 <!-- Bar header: -->
2535 <h3>' . htmlspecialchars($str) . '</h3>
2536 ';
2537 }
2538
2539 /**
2540 * Displays a message box with the input message
2541 *
2542 * @param string $in_msg Input message to show (will be htmlspecialchars()'ed inside of this function)
2543 * @param string $icon Icon filename body from gfx/ (default is "icon_note") - meant to allow change to warning type icons...
2544 * @return string HTML for the message (wrapped in a table).
2545 */
2546 function getMsgBox($in_msg, $icon = 'icon_note') {
2547 $msg = '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/'.$icon.'.gif', 'width="18" height="16"').' alt="" />'.htmlspecialchars($in_msg);
2548 $msg = '
2549
2550 <!--
2551 Message box:
2552 -->
2553 <table cellspacing="0" class="bgColor4" id="typo3-msgBox">
2554 <tr>
2555 <td>'.$msg.'</td>
2556 </tr>
2557 </table>
2558 ';
2559 return $msg;
2560 }
2561
2562 /**
2563 * For RTE/link: This prints the 'currentUrl'
2564 *
2565 * @param string $str URL value. The value is htmlspecialchars()'ed before output.
2566 * @return string HTML content, wrapped in a table.
2567 */
2568 function printCurrentUrl($str) {
2569 // Output the folder or file identifier, when working with files
2570 if ($str && $this->act == 'file' || $this->act == 'folder') {
2571 try {
2572 $fileObject = t3lib_file_Factory::getInstance()->retrieveFileOrFolderObject($str);
2573 if (is_object($fileObject)) {
2574 $str = $fileObject->getIdentifier();
2575 }
2576 } catch (t3lib_file_exception_FileDoesNotExistException $e) {
2577 $str = '';
2578 }
2579 }
2580
2581 if (strlen($str)) {
2582 return '
2583 <!-- Print current URL -->
2584 <table border="0" cellpadding="0" cellspacing="0" id="typo3-curUrl">
2585 <tr>
2586 <td>' . $GLOBALS['LANG']->getLL('currentLink', 1) . ': ' .htmlspecialchars(rawurldecode($str)) . '</td>
2587 </tr>
2588 </table>';
2589 } else {
2590 return '';
2591 }
2592 }
2593
2594 /**
2595 * For RTE/link: Parses the incoming URL and determines if it's a page, file, external or mail address.
2596 *
2597 * @param string $href HREF value tp analyse
2598 * @param string $siteUrl The URL of the current website (frontend)
2599 * @return array Array with URL information stored in assoc. keys: value, act (page, file, spec, mail), pageid, cElement, info
2600 */
2601 function parseCurUrl($href, $siteUrl) {
2602 $href = trim($href);
2603 if ($href) {
2604 $info = array();
2605
2606 // Default is "url":
2607 $info['value'] = $href;
2608 $info['act'] = 'url';
2609
2610 $specialParts = explode('#_SPECIAL', $href);
2611 // Special kind (Something RTE specific: User configurable links through: "userLinks." from ->thisConfig)
2612 if (count($specialParts) == 2) {
2613 $info['value'] = '#_SPECIAL'.$specialParts[1];
2614 $info['act'] = 'spec';
2615 // is a FAL resource/identifier
2616 } elseif (strpos($href, 'file:') !== FALSE) {
2617 $rel = substr($href, strpos($href, 'file:')+5);
2618 $rel = rawurldecode($rel);
2619
2620 // resolve FAL-api "file:UID-of-sys_file-record" and "file:combined-identifier"
2621 $fileOrFolderObject = t3lib_file_Factory::getInstance()->retrieveFileOrFolderObject($rel);
2622
2623 if ($fileOrFolderObject instanceof t3lib_file_Folder) {
2624 $info['act'] = 'folder';
2625 $info['value'] = $fileOrFolderObject->getCombinedIdentifier();
2626 } elseif ($fileOrFolderObject instanceof t3lib_file_FileInterface) {
2627 $info['act'] = 'file';
2628 $info['value'] = $fileOrFolderObject->getUid();
2629 } else {
2630 $info['value'] = $rel;
2631 }
2632
2633 } elseif (t3lib_div::isFirstPartOfStr($href, $siteUrl)) { // If URL is on the current frontend website:
2634 // URL is a file, which exists:
2635 if (file_exists(PATH_site.rawurldecode($href))) {
2636 $info['value'] = rawurldecode($href);
2637 if (@is_dir(PATH_site . $info['value'])) {
2638 $info['act'] = 'folder';
2639 } else {
2640 $info['act'] = 'file';
2641 }
2642 } else { // URL is a page (id parameter)
2643 $uP = parse_url($rel);
2644 if (!trim($uP['path'])) {
2645 $pp = preg_split('/^id=/', $uP['query']);
2646 $pp[1] = preg_replace( '/&id=[^&]*/', '', $pp[1]);
2647 $parameters = explode('&', $pp[1]);
2648 $id = array_shift($parameters);
2649 if ($id) {
2650 // Checking if the id-parameter is an alias.
2651 if (!t3lib_utility_Math::canBeInterpretedAsInteger($id)) {
2652 list($idPartR) = t3lib_BEfunc::getRecordsByField('pages', 'alias', $id);
2653 $id = intval($idPartR['uid']);
2654 }
2655
2656 $pageRow = t3lib_BEfunc::getRecordWSOL('pages', $id);
2657 $titleLen = intval($GLOBALS['BE_USER']->uc['titleLen']);
2658 $info['value'] = $GLOBALS['LANG']->getLL('page', 1)." '".htmlspecialchars(t3lib_div::fixed_lgd_cs($pageRow['title'], $titleLen))."' (ID:".$id.($uP['fragment']?', #'.$uP['fragment']:'').')';
2659 $info['pageid'] = $id;
2660 $info['cElement'] = $uP['fragment'];
2661 $info['act'] = 'page';
2662 $info['query'] = $parameters[0]?'&'.implode('&', $parameters):'';
2663 }
2664 }
2665 }
2666 } else { // Email link:
2667 if (strtolower(substr($href, 0, 7)) == 'mailto:') {
2668 $info['value'] = trim(substr($href, 7));
2669 $info['act'] = 'mail';
2670 }
2671 }
2672 $info['info'] = $info['value'];
2673 } else { // NO value inputted:
2674 $info = array();
2675 $info['info'] = $GLOBALS['LANG']->getLL('none');
2676 $info['value'] = '';
2677 $info['act'] = 'page';
2678 }
2679
2680 // let the hook have a look
2681 foreach ($this->hookObjects as $hookObject) {
2682 $info = $hookObject->parseCurrentUrl($href, $siteUrl, $info);
2683 }
2684
2685 return $info;
2686 }
2687
2688 /**
2689 * For TBE: Makes an upload form for uploading files to the filemount the user is browsing.
2690 * The files are uploaded to the tce_file.php script in the core which will handle the upload.
2691 *
2692 * @param t3lib_file_Folder $folderObject Absolute filepath on server to which to upload.
2693 * @return string HTML for an upload form.
2694 */
2695 function uploadForm(t3lib_file_Folder $folderObject) {
2696 if (!$folderObject->checkActionPermission('write')) {
2697 return '';
2698 }
2699
2700 // Read configuration of upload field count
2701 $userSetting = $GLOBALS['BE_USER']->getTSConfigVal('options.folderTree.uploadFieldsInLinkBrowser');
2702 $count = isset($userSetting) ? $userSetting : 3;
2703 if ($count === '0') {
2704 return '';
2705 }
2706 $count = intval($count) == 0 ? 3 : intval($count);
2707
2708 // Create header, showing upload path:
2709 $header = $folderObject->getIdentifier();
2710 $code = '
2711 <br />
2712 <!--
2713 Form, for uploading files:
2714 -->
2715 <form action="' . $GLOBALS['BACK_PATH'] . 'tce_file.php" method="post" name="editform" id="typo3-uplFilesForm" enctype="' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'] . '">
2716 <table border="0" cellpadding="0" cellspacing="0" id="typo3-uplFiles">
2717 <tr>
2718 <td>' . $this->barheader($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_upload.php.pagetitle', 1) . ':') . '</td>
2719 </tr>
2720 <tr>
2721 <td class="c-wCell c-hCell"><strong>' . $GLOBALS['LANG']->getLL('path', 1) . ':</strong> ' . htmlspecialchars($header) . '</td>
2722 </tr>
2723 <tr>
2724 <td class="c-wCell c-hCell">';
2725
2726 // Traverse the number of upload fields (default is 3):
2727 for ($a = 1; $a <= $count; $a++) {
2728 $code .= '<input type="file" multiple="multiple" name="upload_'.$a.'"'.$this->doc->formWidth(35).' size="50" />
2729 <input type="hidden" name="file[upload]['.$a.'][target]" value="'.htmlspecialchars($folderObject->getCombinedIdentifier()).'" />
2730 <input type="hidden" name="file[upload]['.$a.'][data]" value="'.$a.'" /><br />';
2731 }
2732
2733 // Make footer of upload form, including the submit button:
2734 $redirectValue = $this->thisScript.'?act='.$this->act.'&mode='.$this->mode.'&expandFolder='.rawurlencode($folderObject->getCombinedIdentifier()).'&bparams='.rawurlencode($this->bparams);
2735 $code .= '<input type="hidden" name="redirect" value="' . htmlspecialchars($redirectValue) . '" />';
2736
2737 $code .= '
2738 <div id="c-override">
2739 <label><input type="checkbox" name="overwriteExistingFiles" id="overwriteExistingFiles" value="1" /> ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xml:overwriteExistingFiles', 1) . '</label>
2740 </div>
2741 <input type="submit" name="submit" value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_upload.php.submit', 1) . '" />
2742 ';
2743
2744 $code .= '</td>
2745 </tr>
2746 </table>
2747 </form><br />';
2748
2749 return $code;
2750 }
2751
2752 /**
2753 * For TBE: Makes a form for creating new folders in the filemount the user is browsing.
2754 * The folder creation request is sent to the tce_file.php script in the core which will handle the creation.
2755 *
2756 * @param t3lib_file_Folder $folderObject Absolute filepath on server in which to create the new folder.
2757 * @return string HTML for the create folder form.
2758 */
2759 function createFolder(t3lib_file_Folder $folderObject) {
2760 if (!$folderObject->checkActionPermission('write')) {
2761 return '';
2762 }
2763
2764 // Don't show Folder-create form if it's denied
2765 if ($GLOBALS['BE_USER']->getTSConfigVal('options.folderTree.hideCreateFolder')) {
2766 return '';
2767 }
2768 // Create header, showing upload path:
2769 $header = $folderObject->getIdentifier();
2770 $code = '
2771
2772 <!--
2773 Form, for creating new folders:
2774 -->
2775 <form action="' . $GLOBALS['BACK_PATH'] . 'tce_file.php" method="post" name="editform2" id="typo3-crFolderForm">
2776 <table border="0" cellpadding="0" cellspacing="0" id="typo3-crFolder">
2777 <tr>
2778 <td>' . $this->barheader($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.pagetitle') . ':') . '</td>
2779 </tr>
2780 <tr>
2781 <td class="c-wCell c-hCell"><strong>' . $GLOBALS['LANG']->getLL('path', 1) . ':</strong> ' . htmlspecialchars($header) . '</td>
2782 </tr>
2783 <tr>
2784 <td class="c-wCell c-hCell">';
2785
2786 // Create the new-folder name field:
2787 $a = 1;
2788 $code.='<input'.$this->doc->formWidth(20).' type="text" name="file[newfolder]['.$a.'][data]" />'.
2789 '<input type="hidden" name="file[newfolder]['.$a.'][target]" value="'.htmlspecialchars($folderObject->getCombinedIdentifier()).'" />';
2790
2791 // Make footer of upload form, including the submit button:
2792 $redirectValue = $this->thisScript.'?act='.$this->act.'&mode='.$this->mode.'&expandFolder='.rawurlencode($folderObject->getCombinedIdentifier()).'&bparams='.rawurlencode($this->bparams);
2793 $code .= '<input type="hidden" name="redirect" value="'.htmlspecialchars($redirectValue).'" />'.
2794 '<input type="submit" name="submit" value="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.submit', 1).'" />';
2795
2796 $code .= '</td>
2797 </tr>
2798 </table>
2799 </form>';
2800
2801 return $code;
2802 }
2803
2804 /**
2805 * Get the HTML data required for a bulk selection of files of the TYPO3 Element Browser.
2806 *
2807 * @param integer $filesCount Number of files currently displayed
2808 * @return string HTML data required for a bulk selection of files - if $filesCount is 0, nothing is returned
2809 */
2810 function getBulkSelector($filesCount) {
2811 if ($filesCount) {
2812 $labelToggleSelection = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_browse_links.php:toggleSelection', 1);
2813 $labelImportSelection = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_browse_links.php:importSelection', 1);
2814
2815 // Getting flag for showing/not showing thumbnails:
2816 $noThumbsInEB = $GLOBALS['BE_USER']->getTSConfigVal('options.noThumbsInEB');
2817
2818 $out = $this->doc->spacer(10).'<div>' .
2819 '<a href="#" onclick="BrowseLinks.Selector.handle()">' .
2820 '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/import.gif', 'width="12" height="12"').' title="'.$labelImportSelection.'" alt="" /> ' .
2821 $labelImportSelection.'</a>&nbsp;&nbsp;&nbsp;' .
2822 '<a href="#" onclick="BrowseLinks.Selector.toggle()">' .
2823 '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/clip_select.gif', 'width="12" height="12"').' title="'.$labelToggleSelection.'" alt="" /> ' .
2824 $labelToggleSelection.'</a>' .
2825 '</div>';
2826
2827 $thumbNailCheck = '';
2828 if (!$noThumbsInEB && $this->selectedFolder) {
2829
2830 // MENU-ITEMS, fetching the setting for thumbnails from File>List module:
2831 $_MOD_MENU = array('displayThumbs' => '');
2832 $_MCONF['name'] = 'file_list';
2833 $_MOD_SETTINGS = t3lib_BEfunc::getModuleData($_MOD_MENU, t3lib_div::_GP('SET'), $_MCONF['name']);
2834 $addParams = '&act=' . $this->act . '&mode=' . $this->mode . '&expandFolder=' . rawurlencode($this->selectedFolder->getCombinedIdentifier()) . '&bparams=' . rawurlencode($this->bparams);
2835 $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>';
2836 $out .= $this->doc->spacer(5) . $thumbNailCheck . $this->doc->spacer(15);
2837 } else {
2838 $out .= $this->doc->spacer(15);
2839 }
2840 }
2841 return $out;
2842 }
2843
2844 /**
2845 * Determines whether submitted field change functions are valid
2846 * and are coming from the system and not from an external abuse.
2847 *
2848 * @param boolean $handleFlexformSections Whether to handle flexform sections differently
2849 * @return boolean Whether the submitted field change functions are valid
2850 */
2851 protected function areFieldChangeFunctionsValid($handleFlexformSections = FALSE) {
2852 $result = FALSE;
2853
2854 if (isset($this->P['fieldChangeFunc']) && is_array($this->P['fieldChangeFunc']) && isset($this->P['fieldChangeFuncHash'])) {
2855 $matches = array();
2856 $pattern = '#\[el\]\[(([^]-]+-[^]-]+-)(idx\d+-)([^]]+))\]#i';
2857
2858 $fieldChangeFunctions = $this->P['fieldChangeFunc'];
2859
2860 // Special handling of flexform sections:
2861 // Field change functions are modified in JavaScript, thus the hash is always invalid
2862 if ($handleFlexformSections && preg_match($pattern, $this->P['itemName'], $matches)) {
2863 $originalName = $matches[1];
2864 $cleanedName = $matches[2] . $matches[4];
2865
2866 foreach ($fieldChangeFunctions as &$value) {
2867 $value = str_replace($originalName, $cleanedName, $value);
2868 }
2869 unset($value);
2870 }
2871
2872 $result = ($this->P['fieldChangeFuncHash'] === t3lib_div::hmac(serialize($fieldChangeFunctions)));
2873 }
2874
2875 return $result;
2876 }
2877 }
2878 ?>