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