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