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