2 /***************************************************************
5 * (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
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.
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.
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.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
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!
32 * Revised for TYPO3 3.6 November/2003 by Kasper Skårhøj
35 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
38 * [CLASS/FUNCTION INDEX of SCRIPT]
42 * 155: class TBE_browser_recordList extends localRecordList
43 * 163: function TBE_browser_recordList ()
44 * 175: function listURL($altId='',$table=-1,$exclList='')
45 * 194: function ext_addP()
46 * 211: function linkWrapItems($table,$uid,$code,$row)
47 * 244: function linkWrapTable($table,$code)
50 * 261: class localPageTree extends t3lib_browseTree
51 * 268: function localPageTree()
52 * 284: function wrapTitle($title,$v,$ext_pArrPages='')
53 * 299: function printTree($treeArr='')
54 * 350: function ext_isLinkable($doktype,$uid)
55 * 364: function PM_ATagWrap($icon,$cmd,$bMark='')
56 * 381: function wrapIcon($icon,$row)
59 * 400: class rtePageTree extends localPageTree
62 * 417: class TBE_PageTree extends localPageTree
63 * 426: function ext_isLinkable($doktype,$uid)
64 * 438: function wrapTitle($title,$v,$ext_pArrPages)
67 * 464: class localFolderTree extends t3lib_folderTree
68 * 473: function localFolderTree()
69 * 485: function wrapTitle($title,$v)
70 * 500: function ext_isLinkable($v)
71 * 517: function PM_ATagWrap($icon,$cmd,$bMark='')
72 * 532: function printTree($treeArr='')
75 * 599: class rteFolderTree extends localFolderTree
78 * 615: class TBE_FolderTree extends localFolderTree
79 * 624: function ext_isLinkable($v)
80 * 637: function wrapTitle($title,$v)
83 * 658: class browse_links
84 * 764: function init()
85 * 1034: function processSessionData($data)
87 * SECTION: Main functions
88 * 1077: function main_rte($wiz=0)
89 * 1379: function main_db()
90 * 1424: function main_file()
92 * SECTION: Record listing
93 * 1534: function expandPage()
94 * 1615: function TBE_expandPage($tables)
96 * SECTION: File listing
97 * 1708: function expandFolder($expandFolder=0,$extensionList='')
98 * 1778: function TBE_expandFolder($expandFolder=0,$extensionList='',$noThumbs=0)
99 * 1801: function fileList($files, $folderName='', $noThumbs=0)
100 * 1918: function TBE_dragNDrop($expandFolder=0,$extensionList='')
102 * SECTION: Miscellaneous functions
103 * 2046: function isWebFolder($folder)
104 * 2057: function checkFolder($folder)
105 * 2070: function barheader($str)
106 * 2087: function getMsgBox($in_msg,$icon='icon_note')
107 * 2111: function printCurrentUrl($str)
108 * 2131: function parseCurUrl($href,$siteUrl)
109 * 2193: function uploadForm($path)
110 * 2247: function createFolder($path)
112 * TOTAL FUNCTIONS: 39
113 * (This index is automatically created/updated by the extension "extdeveval")
119 require_once (PATH_typo3
.'/class.db_list.inc');
120 require_once (PATH_typo3
.'/class.db_list_extra.inc');
126 * Local version of the record list.
128 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
132 class TBE_browser_recordList
extends localRecordList
{
133 var $thisScript = 'browse_links.php';
136 * Initializes the script path
140 function __construct() {
141 parent
::__construct();
142 $this->thisScript
= t3lib_div
::getIndpEnv('SCRIPT_NAME');
146 * Creates the URL for links
148 * @param mixed If not blank string, this is used instead of $this->id as the id value.
149 * @param string If this is "-1" then $this->table is used, otherwise the value of the input variable.
150 * @param string Commalist of fields NOT to pass as parameters (currently "sortField" and "sortRev")
151 * @return string Query-string for URL
153 function listURL($altId='',$table=-1,$exclList='') {
154 return $this->thisScript
.
155 '?id='.(strcmp($altId,'')?
$altId:$this->id
).
156 '&table='.rawurlencode($table==-1?
$this->table
:$table).
157 ($this->thumbs?
'&imagemode='.$this->thumbs
:'').
158 ($this->searchString?
'&search_field='.rawurlencode($this->searchString
):'').
159 ($this->searchLevels?
'&search_levels='.rawurlencode($this->searchLevels
):'').
160 ((!$exclList ||
!t3lib_div
::inList($exclList,'sortField')) && $this->sortField?
'&sortField='.rawurlencode($this->sortField
):'').
161 ((!$exclList ||
!t3lib_div
::inList($exclList,'sortRev')) && $this->sortRev?
'&sortRev='.rawurlencode($this->sortRev
):'').
168 * Returns additional, local GET parameters to include in the links of the record list.
172 function ext_addP() {
173 $str = '&act='.$GLOBALS['SOBE']->browser
->act
.
174 '&mode='.$GLOBALS['SOBE']->browser
->mode
.
175 '&expandPage='.$GLOBALS['SOBE']->browser
->expandPage
.
176 '&bparams='.rawurlencode($GLOBALS['SOBE']->browser
->bparams
);
181 * 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...)
183 * @param string Table name
184 * @param integer UID (not used here)
185 * @param string Title string
186 * @param array Records array (from table name)
189 function linkWrapItems($table,$uid,$code,$row) {
191 $code = '<i>['.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.no_title',1).']</i>';
193 $code = t3lib_BEfunc
::getRecordTitlePrep($code, $this->fixedL
);
196 $title = t3lib_BEfunc
::getRecordTitle($table,$row,FALSE
,TRUE
);
197 $ficon = t3lib_iconWorks
::getIcon($table,$row);
198 $aOnClick = "return insertElement('".$table."', '".$row['uid']."', 'db', ".t3lib_div
::quoteJSvalue($title).", '', '', '".$ficon."');";
199 $ATag = '<a href="#" onclick="'.$aOnClick.'">';
200 $ATag_alt = substr($ATag,0,-4).',\'\',1);">';
204 '<img' . t3lib_iconWorks
::skinImg($GLOBALS['BACK_PATH'], 'gfx/plusbullet2.gif', 'width="18" height="16"') .
205 ' title="' . $GLOBALS['LANG']->getLL('addToList', 1) . '" alt="" />' .
213 * Local version that sets allFields to TRUE to support userFieldSelect
216 * @see fieldSelectBox
218 function generateList() {
219 $this->allFields
= TRUE
;
220 parent
::generateList();
230 * Class which generates the page tree
232 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
236 class localPageTree
extends t3lib_browseTree
{
239 * whether the page ID should be shown next to the title, activate through userTSconfig (options.pageTree.showPageIdWithTitle)
242 public $ext_showPageId = FALSE
;
245 * Constructor. Just calling init()
249 function __construct() {
250 $this->thisScript
= t3lib_div
::getIndpEnv('SCRIPT_NAME');
254 $this->clause
= ' AND doktype!=' . t3lib_pageSelect
::DOKTYPE_RECYCLER
. $this->clause
;
258 * Wrapping the title in a link, if applicable.
260 * @param string Title, (must be ready for output, that means it must be htmlspecialchars()'ed).
261 * @param array The record
262 * @param boolean (Ignore)
263 * @return string Wrapping title string.
265 function wrapTitle($title,$v,$ext_pArrPages='') {
266 if ($this->ext_isLinkable($v['doktype'],$v['uid'])) {
267 $aOnClick = "return link_typo3Page('".$v['uid']."');";
268 return '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$title.'</a>';
270 return '<span style="color: #666666;">'.$title.'</span>';
275 * Create the page navigation tree in HTML
277 * @param array Tree array
278 * @return string HTML output.
280 function printTree($treeArr='') {
282 $titleLen=intval($GLOBALS['BE_USER']->uc
['titleLen']);
283 if (!is_array($treeArr)) $treeArr=$this->tree
;
288 foreach($treeArr as $k => $v) {
290 $bgColorClass = ($c+
1)%2 ?
'bgColor' : 'bgColor-10';
291 if ($GLOBALS['SOBE']->browser
->curUrlInfo
['act']=='page' && $GLOBALS['SOBE']->browser
->curUrlInfo
['pageid']==$v['row']['uid'] && $GLOBALS['SOBE']->browser
->curUrlInfo
['pageid']) {
292 $arrCol='<td><img'.t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/blinkarrow_right.gif','width="5" height="9"').' class="c-blinkArrowR" alt="" /></td>';
293 $bgColorClass='bgColor4';
298 $aOnClick = 'return jumpToUrl(\''.$this->thisScript
.'?act='.$GLOBALS['SOBE']->browser
->act
.'&mode='.$GLOBALS['SOBE']->browser
->mode
.'&expandPage='.$v['row']['uid'].'\');';
299 $cEbullet = $this->ext_isLinkable($v['row']['doktype'],$v['row']['uid']) ?
300 '<a href="#" onclick="'.htmlspecialchars($aOnClick).'"><img'.t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/ol/arrowbullet.gif','width="18" height="16"').' alt="" /></a>' :
303 <tr class="'.$bgColorClass.'">
304 <td nowrap="nowrap"'.($v['row']['_CSSCLASS'] ?
' class="'.$v['row']['_CSSCLASS'].'"' : '').'>'.
306 $this->wrapTitle($this->getTitleStr($v['row'],$titleLen),$v['row'],$this->ext_pArrPages
).
309 '<td>'.$cEbullet.'</td>
316 Navigation Page Tree:
318 <table border="0" cellpadding="0" cellspacing="0" id="typo3-tree">
325 * Returns TRUE if a doktype can be linked.
327 * @param integer Doktype value to test
328 * @param integer uid to test.
331 function ext_isLinkable($doktype,$uid) {
332 if ($uid && $doktype<199) {
338 * Wrap the plus/minus icon in a link
340 * @param string HTML string to wrap, probably an image tag.
341 * @param string Command for 'PM' get var
342 * @param boolean If set, the link will have a anchor point (=$bMark) and a name attribute (=$bMark)
343 * @return string Link-wrapped input string
345 function PM_ATagWrap($icon,$cmd,$bMark='') {
347 $anchor = '#'.$bMark;
348 $name=' name="'.$bMark.'"';
350 $aOnClick = "return jumpToUrl('".$this->thisScript
.'?PM='.$cmd."','".$anchor."');";
352 return '<a href="#"'.$name.' onclick="'.htmlspecialchars($aOnClick).'">'.$icon.'</a>';
356 * Wrapping the image tag, $icon, for the row, $row
358 * @param string The image tag for the icon
359 * @param array The row for the current element
360 * @return string The processed icon input value.
362 function wrapIcon($icon, $row) {
363 $content = $this->addTagAttributes($icon, ' title="id=' . $row['uid'] . '"');
364 if ($this->ext_showPageId
) {
365 $content .= '[' . $row['uid'] . '] ';
379 * Page tree for the RTE - totally the same, no changes needed. (Just for the sake of beauty - or confusion... :-)
381 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
385 class rtePageTree
extends localPageTree
{
396 * For TBE record browser
398 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
402 class TBE_PageTree
extends localPageTree
{
405 * Returns TRUE if a doktype can be linked (which is always the case here).
407 * @param integer Doktype value to test
408 * @param integer uid to test.
411 function ext_isLinkable($doktype,$uid) {
416 * Wrapping the title in a link, if applicable.
418 * @param string Title, ready for output.
419 * @param array The record
420 * @param boolean If set, pages clicked will return immediately, otherwise reload page.
421 * @return string Wrapping title string.
423 function wrapTitle($title,$v,$ext_pArrPages) {
424 if ($ext_pArrPages) {
425 $ficon=t3lib_iconWorks
::getIcon('pages',$v);
426 $onClick = "return insertElement('pages', '".$v['uid']."', 'db', ".t3lib_div
::quoteJSvalue($v['title']).", '', '', '".$ficon."','',1);";
428 $onClick = htmlspecialchars('return jumpToUrl(\''.$this->thisScript
.'?act='.$GLOBALS['SOBE']->browser
->act
.'&mode='.$GLOBALS['SOBE']->browser
->mode
.'&expandPage='.$v['uid'].'\');');
430 return '<a href="#" onclick="'.$onClick.'">'.$title.'</a>';
442 * Base extension class which generates the folder tree.
443 * Used directly by the RTE.
445 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
449 class localFolderTree
extends t3lib_folderTree
{
454 * Initializes the script path
458 function __construct() {
459 $this->thisScript
= t3lib_div
::getIndpEnv('SCRIPT_NAME');
460 parent
::__construct();
464 * Wrapping the title in a link, if applicable.
466 * @param string Title, ready for output.
467 * @param array The "record"
468 * @return string Wrapping title string.
470 function wrapTitle($title,$v) {
471 if ($this->ext_isLinkable($v)) {
472 $aOnClick = 'return jumpToUrl(\''.$this->thisScript
.'?act='.$GLOBALS['SOBE']->browser
->act
.'&mode='.$GLOBALS['SOBE']->browser
->mode
.'&expandFolder='.rawurlencode($v['path']).'\');';
473 return '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$title.'</a>';
475 return '<span class="typo3-dimmed">'.$title.'</span>';
480 * Returns TRUE if the input "record" contains a folder which can be linked.
482 * @param array Array with information about the folder element. Contains keys like title, uid, path, _title
483 * @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
485 function ext_isLinkable($v) {
486 $webpath=t3lib_BEfunc
::getPathType_web_nonweb($v['path']); // Checking, if the input path is a web-path.
487 if (strstr($v['path'],'_recycler_') ||
strstr($v['path'],'_temp_') ||
$webpath!='web') {
494 * Wrap the plus/minus icon in a link
496 * @param string HTML string to wrap, probably an image tag.
497 * @param string Command for 'PM' get var
498 * @param boolean If set, the link will have a anchor point (=$bMark) and a name attribute (=$bMark)
499 * @return string Link-wrapped input string
502 function PM_ATagWrap($icon,$cmd,$bMark='') {
504 $anchor = '#'.$bMark;
505 $name=' name="'.$bMark.'"';
507 $aOnClick = 'return jumpToUrl(\''.$this->thisScript
.'?PM='.$cmd.'\',\''.$anchor.'\');';
508 return '<a href="#"'.$name.' onclick="'.htmlspecialchars($aOnClick).'">'.$icon.'</a>';
512 * Create the folder navigation tree in HTML
514 * @param mixed Input tree array. If not array, then $this->tree is used.
515 * @return string HTML output of the tree.
517 function printTree($treeArr='') {
519 $titleLen=intval($GLOBALS['BE_USER']->uc
['titleLen']);
521 if (!is_array($treeArr)) $treeArr=$this->tree
;
526 // Preparing the current-path string (if found in the listing we will see a red blinking arrow).
527 if (!$GLOBALS['SOBE']->browser
->curUrlInfo
['value']) {
529 } elseif (substr(trim($GLOBALS['SOBE']->browser
->curUrlInfo
['info']),-1)!='/') {
530 $cmpPath=PATH_site
.dirname($GLOBALS['SOBE']->browser
->curUrlInfo
['info']).'/';
532 $cmpPath=PATH_site
.$GLOBALS['SOBE']->browser
->curUrlInfo
['info'];
535 // Traverse rows for the tree and print them into table rows:
536 foreach($treeArr as $k => $v) {
538 $bgColorClass=($c+
1)%2 ?
'bgColor' : 'bgColor-10';
540 // Creating blinking arrow, if applicable:
541 if (($GLOBALS['SOBE']->browser
->curUrlInfo
['act'] == 'file' ||
$GLOBALS['SOBE']->browser
->curUrlInfo
['act'] == 'folder') && $cmpPath == $v['row']['path']) {
542 $arrCol='<td><img'.t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/blinkarrow_right.gif','width="5" height="9"').' class="c-blinkArrowR" alt="" /></td>';
543 $bgColorClass='bgColor4';
547 // Create arrow-bullet for file listing (if folder path is linkable):
548 $aOnClick = 'return jumpToUrl(\''.$this->thisScript
.'?act='.$GLOBALS['SOBE']->browser
->act
.'&mode='.$GLOBALS['SOBE']->browser
->mode
.'&expandFolder='.rawurlencode($v['row']['path']).'\');';
549 $cEbullet = $this->ext_isLinkable($v['row']) ?
'<a href="#" onclick="'.htmlspecialchars($aOnClick).'"><img'.t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/ol/arrowbullet.gif','width="18" height="16"').' alt="" /></a>' : '';
551 // Put table row with folder together:
553 <tr class="'.$bgColorClass.'">
554 <td nowrap="nowrap">' . $v['HTML'] . $this->wrapTitle(htmlspecialchars(t3lib_div
::fixed_lgd_cs($v['row']['title'], $titleLen)), $v['row']) . '</td>
556 <td>'.$cEbullet.'</td>
565 <table border="0" cellpadding="0" cellspacing="0" id="typo3-tree">
578 * Folder tree for the RTE - totally the same, no changes needed. (Just for the sake of beauty - or confusion... :-)
580 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
584 class rteFolderTree
extends localFolderTree
{
594 * For TBE File Browser
596 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
600 class TBE_FolderTree
extends localFolderTree
{
601 var $ext_noTempRecyclerDirs=0; // If file-drag mode is set, temp and recycler folders are filtered out.
604 * Returns TRUE if the input "record" contains a folder which can be linked.
606 * @param array Array with information about the folder element. Contains keys like title, uid, path, _title
607 * @return boolean TRUE is returned if the path is NOT a recycler or temp folder AND if ->ext_noTempRecyclerDirs is not set.
609 function ext_isLinkable($v) {
610 if ($this->ext_noTempRecyclerDirs
&& (substr($v['path'],-7)=='_temp_/' ||
substr($v['path'],-11)=='_recycler_/')) {
616 * Wrapping the title in a link, if applicable.
618 * @param string Title, ready for output.
619 * @param array The 'record'
620 * @return string Wrapping title string.
622 function wrapTitle($title,$v) {
623 if ($this->ext_isLinkable($v)) {
624 $aOnClick = 'return jumpToUrl(\''.$this->thisScript
.'?act='.$GLOBALS['SOBE']->browser
->act
.'&mode='.$GLOBALS['SOBE']->browser
->mode
.'&expandFolder='.rawurlencode($v['path']).'\');';
625 return '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$title.'</a>';
627 return '<span class="typo3-dimmed">'.$title.'</span>';
637 * class for the Element Browser window.
639 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
646 var $siteURL; // Current site URL (Frontend)
647 var $thisScript; // the script to link to
648 var $thisConfig; // RTE specific TSconfig
649 var $setTarget; // Target (RTE specific)
650 var $setClass; // CSS Class (RTE specific)
651 var $setTitle; // title (RTE specific)
652 var $doc; // Backend template object
653 var $elements = array(); // Holds information about files
655 // GPvars: (Input variables from outside)
657 * The mode determines the main kind of output from the element browser.
658 * There are these options for values: rte, db, file, filedrag, wizard.
659 * "rte" will show the link selector for the Rich Text Editor (see main_rte())
660 * "db" will allow you to browse for pages or records in the page tree (for TCEforms, see main_db())
661 * "file"/"filedrag" will allow you to browse for files or folders in the folder mounts (for TCEforms, main_file())
662 * "wizard" will allow you to browse for links (like "rte") which are passed back to TCEforms (see main_rte(1))
669 * Link selector action.
670 * page,file,url,mail,spec are allowed values.
671 * These are only important with the link selector function and in that case they switch between the various menu options.
676 * 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")
681 * 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/"
688 * TYPO3 Element Browser, wizard mode parameters. There is a heap of parameters there, better debug() them out if you need something... :-)
693 * 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.
694 * Example value: "data[pages][39][bodytext]|||tt_content|" or "data[tt_content][NEW3fba56fde763d][image]|||gif,jpg,jpeg,tif,bmp,pcx,tga,png,pdf,ai|"
697 * 0: form field name reference, eg. "data[tt_content][123][image]"
698 * 1: htlmArea RTE parameters: editorNo:contentTypo3Language:contentTypo3Charset
699 * 2: RTE config parameters: RTEtsConfigParams
700 * 3: allowed types. Eg. "tt_content" or "gif,jpg,jpeg,tif,bmp,pcx,tga,png,pdf,ai"
701 * 4: IRRE uniqueness: target level object-id to perform actions/checks on, eg. "data[79][tt_address][1][<field>][<foreign_table>]"
702 * 5: IRRE uniqueness: name of function in opener window that checks if element is already used, eg. "inline.checkUniqueElement"
703 * 6: IRRE uniqueness: name of function in opener window that performs some additional(!) action, eg. "inline.setUniqueElement"
704 * 7: IRRE uniqueness: name of function in opener window that performs action instead of using addElement/insertElement, eg. "inline.importElement"
706 * $pArr = explode('|',$this->bparams);
707 * $formFieldName = $pArr[0];
708 * $allowedTablesOrFileTypes = $pArr[3];
713 * Used with the Rich Text Editor.
714 * Example value: "tt_content:NEW3fba58c969f5c:bodytext:23:text:23:"
716 var $RTEtsConfigParams;
722 * Plus/Minus icon value. Used by the tree class to open/close notes on the trees.
727 * Pointer, used when browsing a long list of records etc.
735 * 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.
740 * 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.
745 * array which holds hook objects (initialised in init() )
747 protected $hookObjects = array();
751 * object for t3lib_basicFileFunctions
753 public $fileProcessor;
758 * Initializes a lot of variables, setting JavaScript functions in header etc.
766 $this->pointer
= t3lib_div
::_GP('pointer');
767 $this->bparams
= t3lib_div
::_GP('bparams');
768 $this->P
= t3lib_div
::_GP('P');
769 $this->RTEtsConfigParams
= t3lib_div
::_GP('RTEtsConfigParams');
770 $this->expandPage
= t3lib_div
::_GP('expandPage');
771 $this->expandFolder
= t3lib_div
::_GP('expandFolder');
772 $this->PM
= t3lib_div
::_GP('PM');
775 $this->mode
= t3lib_div
::_GP('mode');
779 // Creating backend template object:
780 $this->doc
= t3lib_div
::makeInstance('template');
781 $this->doc
->backPath
= $GLOBALS['BACK_PATH'];
782 // Load the Prototype library and browse_links.js
783 $this->doc
->getPageRenderer()->loadPrototype();
784 $this->doc
->loadJavascriptLib('js/browse_links.js');
786 // init hook objects:
787 $this->hookObjects
= array();
788 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['browseLinksHook'])) {
789 foreach($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['browseLinksHook'] as $classData) {
790 $processObject = t3lib_div
::getUserObj($classData);
792 if(!($processObject instanceof t3lib_browseLinksHook
)) {
793 throw new UnexpectedValueException('$processObject must implement interface t3lib_browseLinksHook', 1195039394);
796 $parameters = array();
797 $processObject->init($this, $parameters);
798 $this->hookObjects
[] = $processObject;
803 $this->siteURL
= t3lib_div
::getIndpEnv('TYPO3_SITE_URL'); // Current site url
805 // the script to link to
806 $this->thisScript
= t3lib_div
::getIndpEnv('SCRIPT_NAME');
808 // init fileProcessor
809 $this->fileProcessor
= t3lib_div
::makeInstance('t3lib_basicFileFunctions');
810 $this->fileProcessor
->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
813 // CurrentUrl - the current link url must be passed around if it exists
814 if ($this->mode
== 'wizard') {
815 $currentValues = t3lib_div
::trimExplode(LF
, trim($this->P
['currentValue']));
816 if (count($currentValues) > 0) {
817 $currentValue = array_pop($currentValues);
821 $currentLinkParts = t3lib_div
::unQuoteFilenames($currentValue, TRUE
);
822 $initialCurUrlArray = array (
823 'href' => $currentLinkParts[0],
824 'target' => $currentLinkParts[1],
825 'class' => $currentLinkParts[2],
826 'title' => $currentLinkParts[3],
827 'params' => $currentLinkParts[4]
829 $this->curUrlArray
= (is_array(t3lib_div
::_GP('curUrl'))) ?
830 array_merge($initialCurUrlArray, t3lib_div
::_GP('curUrl')) :
832 $this->curUrlInfo
= $this->parseCurUrl($this->siteURL
.'?id='.$this->curUrlArray
['href'], $this->siteURL
);
833 if ($this->curUrlInfo
['pageid'] == 0 && $this->curUrlArray
['href']) { // pageid == 0 means that this is not an internal (page) link
834 if (file_exists(PATH_site
.rawurldecode($this->curUrlArray
['href']))) { // check if this is a link to a file
835 if (t3lib_div
::isFirstPartOfStr($this->curUrlArray
['href'], PATH_site
)) {
836 $currentLinkParts[0] = substr($this->curUrlArray
['href'], strlen(PATH_site
));
838 $this->curUrlInfo
= $this->parseCurUrl($this->siteURL
.$this->curUrlArray
['href'], $this->siteURL
);
839 } elseif (strstr($this->curUrlArray
['href'], '@')) { // check for email link
840 if (t3lib_div
::isFirstPartOfStr($this->curUrlArray
['href'], 'mailto:')) {
841 $currentLinkParts[0] = substr($this->curUrlArray
['href'], 7);
843 $this->curUrlInfo
= $this->parseCurUrl('mailto:'.$this->curUrlArray
['href'], $this->siteURL
);
844 } else { // nothing of the above. this is an external link
845 if(strpos($this->curUrlArray
['href'], '://') === FALSE
) {
846 $currentLinkParts[0] = 'http://' . $this->curUrlArray
['href'];
848 $this->curUrlInfo
= $this->parseCurUrl($currentLinkParts[0], $this->siteURL
);
850 } elseif (!$this->curUrlArray
['href']) {
851 $this->curUrlInfo
= array();
854 $this->curUrlInfo
= $this->parseCurUrl($this->siteURL
.'?id='.$this->curUrlArray
['href'], $this->siteURL
);
857 $this->curUrlArray
= t3lib_div
::_GP('curUrl');
858 if ($this->curUrlArray
['all']) {
859 $this->curUrlArray
=t3lib_div
::get_tag_attributes($this->curUrlArray
['all']);
861 $this->curUrlInfo
=$this->parseCurUrl($this->curUrlArray
['href'],$this->siteURL
);
864 // Determine nature of current url:
865 $this->act
=t3lib_div
::_GP('act');
867 $this->act
=$this->curUrlInfo
['act'];
870 // Rich Text Editor specific configuration:
872 if ((string)$this->mode
== 'rte') {
873 $RTEtsConfigParts = explode(':',$this->RTEtsConfigParams
);
874 $addPassOnParams.='&RTEtsConfigParams='.rawurlencode($this->RTEtsConfigParams
);
875 $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE',t3lib_BEfunc
::getPagesTSconfig($RTEtsConfigParts[5]));
876 $this->thisConfig
= t3lib_BEfunc
::RTEsetup($RTEsetup['properties'],$RTEtsConfigParts[0],$RTEtsConfigParts[2],$RTEtsConfigParts[4]);
879 // Initializing the target value (RTE)
880 $this->setTarget
= ($this->curUrlArray
['target'] != '-') ?
$this->curUrlArray
['target'] : '';
881 if ($this->thisConfig
['defaultLinkTarget'] && !isset($this->curUrlArray
['target'])) {
882 $this->setTarget
=$this->thisConfig
['defaultLinkTarget'];
885 // Initializing the class value (RTE)
886 $this->setClass
= ($this->curUrlArray
['class'] != '-') ?
$this->curUrlArray
['class'] : '';
888 // Initializing the title value (RTE)
889 $this->setTitle
= ($this->curUrlArray
['title'] != '-') ?
$this->curUrlArray
['title'] : '';
891 // Initializing the params value
892 $this->setParams
= ($this->curUrlArray
['params'] != '-') ?
$this->curUrlArray
['params'] : '';
894 // BEGIN accumulation of header JavaScript:
896 // This JavaScript is primarily for RTE/Link. jumpToUrl is used in the other cases as well...
897 var add_href="'.($this->curUrlArray
['href']?
'&curUrl[href]='.rawurlencode($this->curUrlArray
['href']):'').'";
898 var add_target="'.($this->setTarget?
'&curUrl[target]='.rawurlencode($this->setTarget
):'').'";
899 var add_class="'.($this->setClass ?
'&curUrl[class]='.rawurlencode($this->setClass
) : '').'";
900 var add_title="'.($this->setTitle?
'&curUrl[title]='.rawurlencode($this->setTitle
):'').'";
901 var add_params="'.($this->bparams?
'&bparams='.rawurlencode($this->bparams
):'').'";
903 var cur_href="'.($this->curUrlArray
['href']?
$this->curUrlArray
['href']:'').'";
904 var cur_target="'.($this->setTarget?
$this->setTarget
:'').'";
905 var cur_class = "' . ($this->setClass ?
$this->setClass
: '') . '";
906 var cur_title="'.($this->setTitle?
$this->setTitle
:'').'";
907 var cur_params="' . ($this->setParams ?
$this->setParams
: '') . '";
909 function browse_links_setTarget(target) { //
911 add_target="&curUrl[target]="+escape(target);
913 function browse_links_setClass(cssClass) { //
914 cur_class = cssClass;
915 add_class = "&curUrl[class]=" + escape(cssClass);
917 function browse_links_setTitle(title) { //
919 add_title="&curUrl[title]="+escape(title);
921 function browse_links_setValue(value) { //
923 add_href="&curUrl[href]="+value;
925 function browse_links_setParams(params) { //
927 add_params="&curUrl[params]="+escape(params);
931 if ($this->mode
== 'wizard') { // Functions used, if the link selector is in wizard mode (= TCEforms fields)
932 if (!$this->areFieldChangeFunctionsValid() && !$this->areFieldChangeFunctionsValid(TRUE
)) {
933 $this->P
['fieldChangeFunc'] = array();
935 unset($this->P
['fieldChangeFunc']['alert']);
937 foreach ($this->P
['fieldChangeFunc'] as $k => $v) {
943 $P2['itemName']=$this->P
['itemName'];
944 $P2['formName']=$this->P
['formName'];
945 $P2['fieldChangeFunc']=$this->P
['fieldChangeFunc'];
946 $P2['fieldChangeFuncHash'] = t3lib_div
::hmac(serialize($this->P
['fieldChangeFunc']));
947 $P2['params']['allowedExtensions']=$this->P
['params']['allowedExtensions'];
948 $P2['params']['blindLinkOptions']=$this->P
['params']['blindLinkOptions'];
949 $addPassOnParams.=t3lib_div
::implodeArrayForUrl('P',$P2);
952 function link_typo3Page(id,anchor) { //
953 updateValueInMainForm(id + (anchor ? anchor : ""));
957 function link_folder(folder) { //
958 updateValueInMainForm(folder);
962 function link_current() { //
963 if (cur_href!="http://" && cur_href!="mailto:") {
964 returnBeforeCleaned = cur_href;
965 if (returnBeforeCleaned.substr(0, 7) == "http://") {
966 returnToMainFormValue = returnBeforeCleaned.substr(7);
967 } else if (returnBeforeCleaned.substr(0, 7) == "mailto:") {
968 if (returnBeforeCleaned.substr(0, 14) == "mailto:mailto:") {
969 returnToMainFormValue = returnBeforeCleaned.substr(14);
971 returnToMainFormValue = returnBeforeCleaned.substr(7);
974 returnToMainFormValue = returnBeforeCleaned;
976 updateValueInMainForm(returnToMainFormValue);
981 function checkReference() { //
982 if (window.opener && window.opener.document && window.opener.document.'.$this->P
['formName'].' && window.opener.document.'.$this->P
['formName'].'["'.$this->P
['itemName'].'"] ) {
983 return window.opener.document.'.$this->P
['formName'].'["'.$this->P
['itemName'].'"];
988 function updateValueInMainForm(input) { //
989 var field = checkReference();
991 if (cur_target == "" && (cur_class != "" || cur_title != "" || cur_params != "")) {
994 if (cur_class == "" && (cur_title != "" || cur_params != "")) {
997 cur_class = cur_class.replace(/[\'\"]/g, "");
998 if (cur_class.indexOf(" ") != -1) {
999 cur_class = "\"" + cur_class + "\"";
1001 if (cur_title == "" && cur_params != "") {
1004 cur_title = cur_title.replace(/(^\")|(\"$)/g, "");
1005 if (cur_title.indexOf(" ") != -1) {
1006 cur_title = "\"" + cur_title + "\"";
1009 cur_params = cur_params.replace(/\bid\=.*?(\&|$)/, "");
1011 input = input + " " + cur_target + " " + cur_class + " " + cur_title + " " + cur_params;
1012 if(field.value && field.className.search(/textarea/) != -1) {
1013 field.value += "\n" + input;
1015 field.value = input;
1021 } else { // Functions used, if the link selector is in RTE mode:
1023 function link_typo3Page(id,anchor) { //
1024 var theLink = \''.$this->siteURL
.'?id=\'+id+(anchor?anchor:"");
1025 self.parent.parent.renderPopup_addLink(theLink, cur_target, cur_class, cur_title);
1028 function link_folder(folder) { //
1029 var theLink = \''.$this->siteURL
.'\'+folder;
1030 self.parent.parent.renderPopup_addLink(theLink, cur_target, cur_class, cur_title);
1033 function link_spec(theLink) { //
1034 self.parent.parent.renderPopup_addLink(theLink, cur_target, cur_class, cur_title);
1037 function link_current() { //
1038 if (cur_href!="http://" && cur_href!="mailto:") {
1039 self.parent.parent.renderPopup_addLink(cur_href, cur_target, cur_class, cur_title);
1046 // General "jumpToUrl" function:
1048 function jumpToUrl(URL,anchor) { //
1049 var add_act = URL.indexOf("act=")==-1 ? "&act='.$this->act
.'" : "";
1050 var add_mode = URL.indexOf("mode=")==-1 ? "&mode='.$this->mode
.'" : "";
1051 var theLocation = URL + add_act + add_mode + add_href + add_target + add_class + add_title + add_params'.($addPassOnParams?
'+"'.$addPassOnParams.'"':'').'+(anchor?anchor:"");
1052 window.location.href = theLocation;
1059 * Splits parts of $this->bparams
1062 $pArr = explode('|',$this->bparams
);
1064 // This is JavaScript especially for the TBE Element Browser!
1065 $formFieldName = 'data['.$pArr[0].']['.$pArr[1].']['.$pArr[2].']';
1067 // insertElement - Call check function (e.g. for uniqueness handling):
1068 if ($pArr[4] && $pArr[5]) {
1070 // Call a check function in the opener window (e.g. for uniqueness handling):
1071 if (parent.window.opener) {
1072 var res = parent.window.opener.'.$pArr[5].'("'.addslashes($pArr[4]).'",table,uid,type);
1074 if (res.message) alert(res.message);
1075 performAction = false;
1078 alert("Error - reference to main window is not set properly!");
1083 // insertElement - Call helper function:
1084 if ($pArr[4] && $pArr[6]) {
1086 // Call helper function to manage data in the opener window:
1087 if (parent.window.opener) {
1088 parent.window.opener.'.$pArr[6].'("'.addslashes($pArr[4]).'",table,uid,type,"'.addslashes($pArr[0]).'");
1090 alert("Error - reference to main window is not set properly!");
1095 // insertElement - perform action commands:
1096 if ($pArr[4] && $pArr[7]) {
1097 // Call user defined action function:
1099 if (parent.window.opener) {
1100 parent.window.opener.'.$pArr[7].'("'.addslashes($pArr[4]).'",table,uid,type);
1101 focusOpenerAndClose(close);
1103 alert("Error - reference to main window is not set properly!");
1107 } elseif ($pArr[0] && !$pArr[1] && !$pArr[2]) {
1109 addElement(filename,table+"_"+uid,fp,close);
1113 if (setReferences()) {
1114 parent.window.opener.group_change("add","'.$pArr[0].'","'.$pArr[1].'","'.$pArr[2].'",elRef,targetDoc);
1116 alert("Error - reference to main window is not set properly!");
1118 focusOpenerAndClose(close);
1126 function launchView(url) { //
1127 var thePreviewWindow="";
1128 thePreviewWindow = window.open("'.$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");
1129 if (thePreviewWindow && thePreviewWindow.focus) {
1130 thePreviewWindow.focus();
1133 function setReferences() { //
1134 if (parent.window.opener && parent.window.opener.content && parent.window.opener.content.document.editform && parent.window.opener.content.document.editform["'.$formFieldName.'"]) {
1135 targetDoc = parent.window.opener.content.document;
1136 elRef = targetDoc.editform["'.$formFieldName.'"];
1142 function insertElement(table, uid, type, filename,fp,filetype,imagefile,action, close) { //
1143 var performAction = true;
1145 // Call performing function and finish this action:
1146 if (performAction) {
1147 '.$JScodeHelper.$JScodeAction.'
1151 function addElement(elName,elValue,altElValue,close) { //
1152 if (parent.window.opener && parent.window.opener.setFormValueFromBrowseWin) {
1153 parent.window.opener.setFormValueFromBrowseWin("'.$pArr[0].'",altElValue?altElValue:elValue,elName);
1154 focusOpenerAndClose(close);
1156 alert("Error - reference to main window is not set properly!");
1160 function focusOpenerAndClose(close) { //
1161 BrowseLinks.focusOpenerAndClose(close);
1165 // Finally, add the accumulated JavaScript to the template object:
1166 $this->doc
->JScode
.= $this->doc
->wrapScriptTags($JScode);
1169 if (FALSE
) debug(array(
1170 'pointer' => $this->pointer
,
1171 'act' => $this->act
,
1172 'mode' => $this->mode
,
1173 'curUrlInfo' => $this->curUrlInfo
,
1174 'curUrlArray' => $this->curUrlArray
,
1176 'bparams' => $this->bparams
,
1177 'RTEtsConfigParams' => $this->RTEtsConfigParams
,
1178 'expandPage' => $this->expandPage
,
1179 'expandFolder' => $this->expandFolder
,
1181 ),'Internal variables of Script Class:');
1186 * Session data for this class can be set from outside with this method.
1189 * @param array Session data array
1190 * @return array Session data and boolean which indicates that data needs to be stored in session because it's changed
1192 function processSessionData($data) {
1195 switch((string)$this->mode
) {
1197 if (isset($this->expandPage
)) {
1198 $data['expandPage']=$this->expandPage
;
1201 $this->expandPage
=$data['expandPage'];
1207 if (isset($this->expandFolder
)) {
1208 $data['expandFolder']=$this->expandFolder
;
1211 $this->expandFolder
=$data['expandFolder'];
1216 return array($data, $store);
1222 /******************************************************************
1226 ******************************************************************/
1229 * Rich Text Editor (RTE) link selector (MAIN function)
1230 * Generates the link selector for the Rich Text Editor.
1231 * Can also be used to select links for the TCEforms (see $wiz)
1233 * @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
1234 * @return string Modified content variable.
1236 function main_rte($wiz=0) {
1239 // Starting content:
1240 $content=$this->doc
->startPage('RTE link');
1242 // Initializing the action value, possibly removing blinded values etc:
1243 $allowedItems = array_diff(
1244 explode(',','page,file,folder,url,mail,spec'),
1245 t3lib_div
::trimExplode(',',$this->thisConfig
['blindLinkOptions'],1)
1247 $allowedItems = array_diff(
1249 t3lib_div
::trimExplode(',',$this->P
['params']['blindLinkOptions'])
1252 //call hook for extra options
1253 foreach($this->hookObjects
as $hookObject) {
1254 $allowedItems = $hookObject->addAllowedItems($allowedItems);
1257 reset($allowedItems);
1258 if (!in_array($this->act
,$allowedItems)) $this->act
= current($allowedItems);
1260 // Making menu in top:
1263 $menuDef['removeLink']['isActive'] = $this->act
=='removeLink';
1264 $menuDef['removeLink']['label'] = $GLOBALS['LANG']->getLL('removeLink', 1);
1265 $menuDef['removeLink']['url'] = '#';
1266 $menuDef['removeLink']['addParams'] = 'onclick="self.parent.parent.renderPopup_unLink();return false;"';
1268 if (in_array('page',$allowedItems)) {
1269 $menuDef['page']['isActive'] = $this->act
=='page';
1270 $menuDef['page']['label'] = $GLOBALS['LANG']->getLL('page', 1);
1271 $menuDef['page']['url'] = '#';
1272 $menuDef['page']['addParams'] = 'onclick="jumpToUrl(\'?act=page\');return false;"';
1274 if (in_array('file',$allowedItems)){
1275 $menuDef['file']['isActive'] = $this->act
=='file';
1276 $menuDef['file']['label'] = $GLOBALS['LANG']->getLL('file', 1);
1277 $menuDef['file']['url'] = '#';
1278 $menuDef['file']['addParams'] = 'onclick="jumpToUrl(\'?act=file\');return false;"';
1280 if (in_array('folder',$allowedItems)){
1281 $menuDef['folder']['isActive'] = $this->act
== 'folder';
1282 $menuDef['folder']['label'] = $GLOBALS['LANG']->getLL('folder', 1);
1283 $menuDef['folder']['url'] = '#';
1284 $menuDef['folder']['addParams'] = 'onclick="jumpToUrl(\'?act=folder\');return false;"';
1286 if (in_array('url',$allowedItems)) {
1287 $menuDef['url']['isActive'] = $this->act
=='url';
1288 $menuDef['url']['label'] = $GLOBALS['LANG']->getLL('extUrl', 1);
1289 $menuDef['url']['url'] = '#';
1290 $menuDef['url']['addParams'] = 'onclick="jumpToUrl(\'?act=url\');return false;"';
1292 if (in_array('mail',$allowedItems)) {
1293 $menuDef['mail']['isActive'] = $this->act
=='mail';
1294 $menuDef['mail']['label'] = $GLOBALS['LANG']->getLL('email', 1);
1295 $menuDef['mail']['url'] = '#';
1296 $menuDef['mail']['addParams'] = 'onclick="jumpToUrl(\'?act=mail\');return false;"';
1298 if (is_array($this->thisConfig
['userLinks.']) && in_array('spec',$allowedItems)) {
1299 $menuDef['spec']['isActive'] = $this->act
=='spec';
1300 $menuDef['spec']['label'] = $GLOBALS['LANG']->getLL('special', 1);
1301 $menuDef['spec']['url'] = '#';
1302 $menuDef['spec']['addParams'] = 'onclick="jumpToUrl(\'?act=spec\');return false;"';
1305 // call hook for extra options
1306 foreach($this->hookObjects
as $hookObject) {
1307 $menuDef = $hookObject->modifyMenuDefinition($menuDef);
1310 $content .= $this->doc
->getTabMenuRaw($menuDef);
1312 // Adding the menu and header to the top of page:
1313 $content.=$this->printCurrentUrl($this->curUrlInfo
['info']).'<br />';
1315 // Depending on the current action we will create the actual module content for selecting a link:
1316 switch($this->act
) {
1323 <form action="" name="lurlform" id="lurlform">
1324 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkMail">
1326 <td style="width: 96px;">' . $GLOBALS['LANG']->getLL('emailAddress', 1) . ':</td>
1327 <td><input type="text" name="lemail"'.$this->doc
->formWidth(20).' value="'.htmlspecialchars($this->curUrlInfo
['act']=='mail'?
$this->curUrlInfo
['info']:'').'" /> '.
1328 '<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>
1340 <form action="" name="lurlform" id="lurlform">
1341 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkURL">
1343 <td style="width: 96px;">URL:</td>
1344 <td><input type="text" name="lurl"'.$this->doc
->formWidth(30).' value="'.htmlspecialchars($this->curUrlInfo
['act']=='url'?
$this->curUrlInfo
['info']:'http://').'" /> '.
1345 '<input type="submit" value="' . $GLOBALS['LANG']->getLL('setLink', 1) . '" onclick="browse_links_setValue(document.lurlform.lurl.value); return link_current();" /></td>
1353 $foldertree = t3lib_div
::makeInstance('rteFolderTree');
1354 $foldertree->thisScript
= $this->thisScript
;
1355 $tree = $foldertree->getBrowsableTree();
1357 if (!$this->curUrlInfo
['value'] ||
$this->curUrlInfo
['act'] != $this->act
) {
1359 } elseif (substr(trim($this->curUrlInfo
['info']), -1) != '/') {
1360 $cmpPath = PATH_site
.dirname($this->curUrlInfo
['info']).'/';
1361 if (!isset($this->expandFolder
)) {
1362 $this->expandFolder
= $cmpPath;
1365 $cmpPath = PATH_site
.$this->curUrlInfo
['info'];
1366 if (!isset($this->expandFolder
) && $this->curUrlInfo
['act'] == 'folder') {
1367 $this->expandFolder
= $cmpPath;
1371 list(, , $specUid) = explode('_', $this->PM
);
1372 $files = $this->expandFolder(
1373 $foldertree->specUIDmap
[$specUid],
1374 $this->P
['params']['allowedExtensions']
1379 Wrapper table for folder tree / file/folder list:
1381 <table border="0" cellpadding="0" cellspacing="0" id="typo3-linkFiles">
1383 <td class="c-wCell" valign="top">'.$this->barheader($GLOBALS['LANG']->getLL('folderTree').':').$tree.'</td>
1384 <td class="c-wCell" valign="top">'.$files.'</td>
1390 if (is_array($this->thisConfig
['userLinks.'])) {
1392 $v=$this->thisConfig
['userLinks.'];
1393 foreach ($v as $k2 => $value) {
1395 if (substr($k2,-1)=='.' && is_array($v[$k2i.'.'])) {
1398 $title = trim($v[$k2i]);
1400 $title=$v[$k2i.'.']['url'];
1402 $title = $GLOBALS['LANG']->sL($title);
1405 $description = ($v[$k2i . '.']['description'] ?
$GLOBALS['LANG']->sL($v[$k2i . '.']['description'], 1) . '<br />' : '');
1407 // URL + onclick event:
1409 if (isset($v[$k2i.'.']['target'])) $onClickEvent.="browse_links_setTarget('".$v[$k2i.'.']['target']."');";
1410 $v[$k2i.'.']['url'] = str_replace('###_URL###',$this->siteURL
,$v[$k2i.'.']['url']);
1411 if (substr($v[$k2i.'.']['url'],0,7)=='http://' ||
substr($v[$k2i.'.']['url'],0,7)=='mailto:') {
1412 $onClickEvent.="cur_href=unescape('".rawurlencode($v[$k2i.'.']['url'])."');link_current();";
1414 $onClickEvent.="link_spec(unescape('".$this->siteURL
.rawurlencode($v[$k2i.'.']['url'])."'));";
1418 $A=array('<a href="#" onclick="'.htmlspecialchars($onClickEvent).'return false;">','</a>');
1420 // Adding link to menu of user defined links:
1423 <td class="bgColor4">'.$A[0].'<strong>'.htmlspecialchars($title).($this->curUrlInfo
['info']==$v[$k2i.'.']['url']?
'<img'.t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/blinkarrow_right.gif','width="5" height="9"').' class="c-blinkArrowR" alt="" />':'').'</strong><br />'.$description.$A[1].'</td>
1431 // Add menu to content:
1435 Special userdefined menu:
1437 <table border="0" cellpadding="1" cellspacing="1" id="typo3-linkSpecial">
1439 <td class="bgColor5" class="c-wCell" valign="top"><strong>' . $GLOBALS['LANG']->getLL('special', 1) . '</strong></td>
1441 '.implode('',$subcats).'
1447 $pagetree = t3lib_div
::makeInstance('rtePageTree');
1448 $pagetree->thisScript
= $this->thisScript
;
1449 $pagetree->ext_showPageId
= $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showPageIdWithTitle');
1450 $pagetree->ext_showNavTitle
= $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showNavTitle');
1451 $pagetree->addField('nav_title');
1452 $tree=$pagetree->getBrowsableTree();
1453 $cElements = $this->expandPage();
1455 // Outputting Temporary DB mount notice:
1456 if (intval($GLOBALS['BE_USER']->getSessionData('pageTree_temporaryMountPoint'))) {
1457 $link = '<a href="' . htmlspecialchars(t3lib_div
::linkThisScript(array('setTempDBmount' => 0))) . '">' .
1458 $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_core.xml:labels.temporaryDBmount', 1) .
1460 $flashMessage = t3lib_div
::makeInstance(
1461 't3lib_FlashMessage',
1464 t3lib_FlashMessage
::INFO
1466 $dbmount = $flashMessage->render();
1472 Wrapper table for page tree / record list:
1474 <table border="0" cellpadding="0" cellspacing="0" id="typo3-linkPages">
1476 <td class="c-wCell" valign="top">' . $this->barheader($GLOBALS['LANG']->getLL('pageTree') . ':') . $dbmount . $tree . '</td>
1477 <td class="c-wCell" valign="top">'.$cElements.'</td>
1484 foreach($this->hookObjects
as $hookObject) {
1485 $content .= $hookObject->getTab($this->act
);
1492 Selecting params for link:
1494 <form action="" name="lparamsform" id="lparamsform">
1495 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkParams">
1497 <td style="width: 96px;">' . $GLOBALS['LANG']->getLL('params', 1) . '</td>
1498 <td><input type="text" name="lparams" class="typo3-link-input" onchange="browse_links_setParams(this.value);" value="' . htmlspecialchars($this->setParams
) . '" /></td>
1504 Selecting class for link:
1506 <form action="" name="lclassform" id="lclassform">
1507 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkClass">
1509 <td style="width: 96px;">' . $GLOBALS['LANG']->getLL('class', 1) . '</td>
1510 <td><input type="text" name="lclass" class="typo3-link-input" onchange="browse_links_setClass(this.value);" value="' . htmlspecialchars($this->setClass
) . '" /></td>
1516 Selecting title for link:
1518 <form action="" name="ltitleform" id="ltitleform">
1519 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkTitle">
1521 <td style="width: 96px;">' . $GLOBALS['LANG']->getLL('title', 1) . '</td>
1522 <td><input type="text" name="ltitle" class="typo3-link-input" onchange="browse_links_setTitle(this.value);" value="' . htmlspecialchars($this->setTitle
) . '" /></td>
1529 if ($this->act
!='mail') {
1535 Selecting target for link:
1537 <form action="" name="ltargetform" id="ltargetform">
1538 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkTarget">
1540 <td>'.$GLOBALS['LANG']->getLL('target',1).':</td>
1541 <td><input type="text" name="ltarget" onchange="browse_links_setTarget(this.value);" value="' . htmlspecialchars($this->setTarget
) . '"' . $this->doc
->formWidth(10) . ' /></td>
1543 <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;">
1545 <option value="_top">'.$GLOBALS['LANG']->getLL('top',1).'</option>
1546 <option value="_blank">'.$GLOBALS['LANG']->getLL('newWindow',1).'</option>
1550 if (($this->curUrlInfo
['act'] == 'page' ||
$this->curUrlInfo
['act'] == 'file' ||
$this->curUrlInfo
['act'] == 'folder') && $this->curUrlArray
['href'] && $this->curUrlInfo
['act'] == $this->act
) {
1552 <input type="submit" value="'.$GLOBALS['LANG']->getLL('update',1).'" onclick="return link_current();" />';
1556 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) {
1557 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;
1558 browse_links_setTarget(document.ltargetform.ltarget.value);
1559 browse_links_setClass(document.lclassform.lclass.value);
1560 browse_links_setTitle(document.ltitleform.ltitle.value);
1561 browse_links_setParams(document.lparamsform.lparams.value);
1562 document.ltargetform.popup_width.selectedIndex=0;
1563 document.ltargetform.popup_height.selectedIndex=0;
1570 <td>'.$GLOBALS['LANG']->getLL('target_popUpWindow',1).':</td>
1572 <select name="popup_width" onchange="'.htmlspecialchars($selectJS).'">
1573 <option value="0">'.$GLOBALS['LANG']->getLL('target_popUpWindow_width',1).'</option>
1574 <option value="300">300</option>
1575 <option value="400">400</option>
1576 <option value="500">500</option>
1577 <option value="600">600</option>
1578 <option value="700">700</option>
1579 <option value="800">800</option>
1582 <select name="popup_height" onchange="'.htmlspecialchars($selectJS).'">
1583 <option value="0">'.$GLOBALS['LANG']->getLL('target_popUpWindow_height',1).'</option>
1584 <option value="200">200</option>
1585 <option value="300">300</option>
1586 <option value="400">400</option>
1587 <option value="500">500</option>
1588 <option value="600">600</option>
1595 // Add "target selector" box to content:
1599 $content.='<br /><br />';
1602 // End page, return content:
1603 $content.= $this->doc
->endPage();
1604 $content = $this->doc
->insertStylesAndJS($content);
1609 * TYPO3 Element Browser: Showing a page tree and allows you to browse for records
1611 * @return string HTML content for the module
1613 function main_db() {
1615 // Starting content:
1616 $content=$this->doc
->startPage('TBE record selector');
1619 $pArr = explode('|',$this->bparams
);
1621 // Making the browsable pagetree:
1622 $pagetree = t3lib_div
::makeInstance('TBE_PageTree');
1623 $pagetree->thisScript
=$this->thisScript
;
1624 $pagetree->ext_pArrPages
= !strcmp($pArr[3],'pages')?
1:0;
1625 $pagetree->ext_showNavTitle
= $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showNavTitle');
1626 $pagetree->ext_showPageId
= $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showPageIdWithTitle');
1627 $pagetree->addField('nav_title');
1628 $tree=$pagetree->getBrowsableTree();
1630 // Making the list of elements, if applicable:
1631 $cElements = $this->TBE_expandPage($pArr[3]);
1633 // Putting the things together, side by side:
1637 Wrapper table for page tree / record list:
1639 <table border="0" cellpadding="0" cellspacing="0" id="typo3-EBrecords">
1641 <td class="c-wCell" valign="top">'.$this->barheader($GLOBALS['LANG']->getLL('pageTree').':').$tree.'</td>
1642 <td class="c-wCell" valign="top">'.$cElements.'</td>
1648 $content.='<br /><br />';
1650 // End page, return content:
1651 $content.= $this->doc
->endPage();
1652 $content = $this->doc
->insertStylesAndJS($content);
1657 * TYPO3 Element Browser: Showing a folder tree, allowing you to browse for files.
1659 * @return string HTML content for the module
1661 function main_file() {
1663 // Starting content:
1664 $content = $this->doc
->startPage('TBE file selector');
1667 $pArr = explode('|',$this->bparams
);
1669 // Create upload/create folder forms, if a path is given:
1670 $path=$this->expandFolder
;
1671 if (!$path ||
!@is_dir
($path)) {
1672 // The closest TEMP-path is found
1673 $path = $this->fileProcessor
->findTempFolder().'/';
1675 if ($path!='/' && @is_dir
($path)) {
1676 $uploadForm=$this->uploadForm($path);
1677 $createFolder=$this->createFolder($path);
1682 if ($GLOBALS['BE_USER']->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
1683 $content .= $uploadForm;
1686 // Getting flag for showing/not showing thumbnails:
1687 $noThumbs = $GLOBALS['BE_USER']->getTSConfigVal('options.noThumbsInEB');
1690 // MENU-ITEMS, fetching the setting for thumbnails from File>List module:
1691 $_MOD_MENU = array('displayThumbs' => '');
1692 $_MCONF['name']='file_list';
1693 $_MOD_SETTINGS = t3lib_BEfunc
::getModuleData($_MOD_MENU, t3lib_div
::_GP('SET'), $_MCONF['name']);
1694 $addParams = '&act='.$this->act
.'&mode='.$this->mode
.'&expandFolder='.rawurlencode($path).'&bparams='.rawurlencode($this->bparams
);
1695 $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>';
1699 $noThumbs = $noThumbs ?
$noThumbs : !$_MOD_SETTINGS['displayThumbs'];
1701 // Create folder tree:
1702 $foldertree = t3lib_div
::makeInstance('TBE_FolderTree');
1703 $foldertree->thisScript
=$this->thisScript
;
1704 $foldertree->ext_noTempRecyclerDirs
= ($this->mode
== 'filedrag');
1705 $tree=$foldertree->getBrowsableTree();
1707 list(,,$specUid) = explode('_',$this->PM
);
1709 if ($this->mode
=='filedrag') {
1710 $files = $this->TBE_dragNDrop($foldertree->specUIDmap
[$specUid],$pArr[3]);
1712 $files = $this->TBE_expandFolder($foldertree->specUIDmap
[$specUid],$pArr[3],$noThumbs);
1715 // Putting the parts together, side by side:
1719 Wrapper table for folder tree / file list:
1721 <table border="0" cellpadding="0" cellspacing="0" id="typo3-EBfiles">
1723 <td class="c-wCell" valign="top">'.$this->barheader($GLOBALS['LANG']->getLL('folderTree').':').$tree.'</td>
1724 <td class="c-wCell" valign="top">'.$files.'</td>
1728 $content.= $thumbNailCheck;
1730 // Adding create folder + upload forms if applicable:
1731 if (!$GLOBALS['BE_USER']->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
1732 $content .= $uploadForm;
1734 if ($GLOBALS['BE_USER']->isAdmin() ||
$GLOBALS['BE_USER']->getTSConfigVal('options.createFoldersInEB')) {
1735 $content .= $createFolder;
1739 $content.='<br /><br />';
1741 // Setup indexed elements:
1742 $this->doc
->JScode
.= $this->doc
->wrapScriptTags('BrowseLinks.addElements(' . json_encode($this->elements
) . ');');
1743 // Ending page, returning content:
1744 $content.= $this->doc
->endPage();
1745 $content = $this->doc
->insertStylesAndJS($content);
1751 * TYPO3 Element Browser: Showing a folder tree, allowing you to browse for folders.
1753 * @return string HTML content for the module
1755 function main_folder() {
1757 // Starting content:
1758 $content = $this->doc
->startPage('TBE folder selector');
1761 $parameters = explode('|', $this->bparams
);
1764 $path = $this->expandFolder
;
1765 if (!$path ||
!@is_dir
($path)) {
1766 // The closest TEMP-path is found
1767 $path = $this->fileProcessor
->findTempFolder().'/';
1769 if ($path != '/' && @is_dir
($path)) {
1770 $createFolder = $this->createFolder($path);
1775 // Create folder tree:
1776 $foldertree = t3lib_div
::makeInstance('TBE_FolderTree');
1777 $foldertree->thisScript
= $this->thisScript
;
1778 $foldertree->ext_noTempRecyclerDirs
= ($this->mode
== 'filedrag');
1779 $tree = $foldertree->getBrowsableTree(FALSE
);
1781 list(, , $specUid) = explode('_', $this->PM
);
1783 if($this->mode
== 'filedrag') {
1784 $folders = $this->TBE_dragNDrop(
1785 $foldertree->specUIDmap
[$specUid],
1789 $folders = $this->TBE_expandSubFolders($foldertree->specUIDmap
[$specUid]);
1792 // Putting the parts together, side by side:
1796 Wrapper table for folder tree / folder list:
1798 <table border="0" cellpadding="0" cellspacing="0" id="typo3-EBfiles">
1800 <td class="c-wCell" valign="top">'.$this->barheader($GLOBALS['LANG']->getLL('folderTree').':').$tree.'</td>
1801 <td class="c-wCell" valign="top">'.$folders.'</td>
1806 // Adding create folder if applicable:
1807 if ($GLOBALS['BE_USER']->isAdmin() ||
$GLOBALS['BE_USER']->getTSConfigVal('options.createFoldersInEB')) {
1808 $content .= $createFolder;
1812 $content .= '<br /><br />';
1814 // Ending page, returning content:
1815 $content.= $this->doc
->endPage();
1816 $content = $this->doc
->insertStylesAndJS($content);
1837 /******************************************************************
1841 ******************************************************************/
1843 * For RTE: This displays all content elements on a page and lets you create a link to the element.
1845 * @return string HTML output. Returns content only if the ->expandPage value is set (pointing to a page uid to show tt_content records from ...)
1847 function expandPage() {
1851 $expPageId = $this->expandPage
; // Set page id (if any) to expand
1853 // If there is an anchor value (content element reference) in the element reference, then force an ID to expand:
1854 if (!$this->expandPage
&& $this->curUrlInfo
['cElement']) {
1855 $expPageId = $this->curUrlInfo
['pageid']; // Set to the current link page id.
1858 // Draw the record list IF there is a page id to expand:
1859 if ($expPageId && t3lib_div
::testInt($expPageId) && $GLOBALS['BE_USER']->isInWebMount($expPageId)) {
1862 $out.=$this->barheader($GLOBALS['LANG']->getLL('contentElements').':');
1864 // Create header for listing, showing the page title/icon:
1865 $titleLen=intval($GLOBALS['BE_USER']->uc
['titleLen']);
1866 $mainPageRec = t3lib_BEfunc
::getRecordWSOL('pages',$expPageId);
1867 $picon = t3lib_iconWorks
::getSpriteIconForRecord('pages', $mainPageRec);
1868 $picon .= t3lib_BEfunc
::getRecordTitle('pages', $mainPageRec, TRUE
);
1869 $out.=$picon.'<br />';
1871 // Look up tt_content elements from the expanded page:
1872 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1873 'uid,header,hidden,starttime,endtime,fe_group,CType,colPos,bodytext',
1875 'pid='.intval($expPageId).
1876 t3lib_BEfunc
::deleteClause('tt_content').
1877 t3lib_BEfunc
::versioningPlaceholderClause('tt_content'),
1881 $cc = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
1883 // Traverse list of records:
1885 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
1887 $icon = t3lib_iconWorks
::getSpriteIconForRecord('tt_content', $row);
1888 if ($this->curUrlInfo
['act']=='page' && $this->curUrlInfo
['cElement']==$row['uid']) {
1889 $arrCol='<img'.t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/blinkarrow_left.gif','width="5" height="9"').' class="c-blinkArrowL" alt="" />';
1893 // Putting list element HTML together:
1894 $out.='<img'.t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/ol/join'.($c==$cc?
'bottom':'').'.gif','width="18" height="16"').' alt="" />'.
1896 '<a href="#" onclick="return link_typo3Page(\''.$expPageId.'\',\'#'.$row['uid'].'\');">'.
1898 t3lib_BEfunc
::getRecordTitle('tt_content', $row, TRUE
) .
1901 // Finding internal anchor points:
1902 if (t3lib_div
::inList('text,textpic', $row['CType'])) {
1903 $split = preg_split('/(<a[^>]+name=[\'"]?([^"\'>[:space:]]+)[\'"]?[^>]*>)/i', $row['bodytext'], -1, PREG_SPLIT_DELIM_CAPTURE
);
1905 foreach($split as $skey => $sval) {
1907 // Putting list element HTML together:
1908 $sval = substr($sval,0,100);
1909 $out.='<img'.t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/ol/line.gif','width="18" height="16"').' alt="" />'.
1910 '<img'.t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/ol/join'.($skey+
3>count($split)?
'bottom':'').'.gif','width="18" height="16"').' alt="" />'.
1911 '<a href="#" onclick="return link_typo3Page(\''.$expPageId.'\',\'#'.rawurlencode($sval).'\');">'.
1912 htmlspecialchars(' <A> '.$sval).
1923 * For TYPO3 Element Browser: This lists all content elements from the given list of tables
1925 * @param string Commalist of tables. Set to "*" if you want all tables.
1926 * @return string HTML output.
1928 function TBE_expandPage($tables) {
1930 if ($this->expandPage
>= 0 && t3lib_div
::testInt($this->expandPage
) && $GLOBALS['BE_USER']->isInWebMount($this->expandPage
)) {
1932 // Set array with table names to list:
1933 if (!strcmp(trim($tables),'*')) {
1934 $tablesArr = array_keys($GLOBALS['TCA']);
1936 $tablesArr = t3lib_div
::trimExplode(',',$tables,1);
1940 // Headline for selecting records:
1941 $out.=$this->barheader($GLOBALS['LANG']->getLL('selectRecords').':');
1943 // Create the header, showing the current page for which the listing is. Includes link to the page itself, if pages are amount allowed tables.
1944 $titleLen=intval($GLOBALS['BE_USER']->uc
['titleLen']);
1945 $mainPageRec = t3lib_BEfunc
::getRecordWSOL('pages',$this->expandPage
);
1950 if (is_array($mainPageRec)) {
1951 $picon = t3lib_iconWorks
::getSpriteIconForRecord('pages', $mainPageRec);
1952 if (in_array('pages', $tablesArr)) {
1953 $ATag = "<a href=\"#\" onclick=\"return insertElement('pages', '" . $mainPageRec['uid'] .
1954 "', 'db', " . t3lib_div
::quoteJSvalue($mainPageRec['title']) . ", '', '', '','',1);\">";
1955 $ATag2 = "<a href=\"#\" onclick=\"return insertElement('pages', '" . $mainPageRec['uid'] .
1956 "', 'db', " . t3lib_div
::quoteJSvalue($mainPageRec['title']) . ", '', '', '','',0);\">";
1957 $ATag_alt = substr($ATag, 0, -4) . ",'',1);\">";
1961 $pBicon = ($ATag2 ?
'<img' . t3lib_iconWorks
::skinImg($GLOBALS['BACK_PATH'], 'gfx/plusbullet2.gif', 'width="18" height="16"') . ' alt="" />' : '');
1962 $pText=htmlspecialchars(t3lib_div
::fixed_lgd_cs($mainPageRec['title'],$titleLen));
1963 $out.=$picon.$ATag2.$pBicon.$ATag_e.$ATag.$pText.$ATag_e.'<br />';
1965 // Initialize the record listing:
1966 $id = $this->expandPage
;
1967 $pointer = t3lib_div
::intInRange($this->pointer
,0,100000);
1968 $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
1969 $pageinfo = t3lib_BEfunc
::readPageAccess($id,$perms_clause);
1972 // Generate the record list:
1973 /** @var $dblist TBE_browser_recordList */
1974 $dblist = t3lib_div
::makeInstance('TBE_browser_recordList');
1975 $dblist->thisScript
=$this->thisScript
;
1976 $dblist->backPath
= $GLOBALS['BACK_PATH'];
1977 $dblist->thumbs
= 0;
1978 $dblist->calcPerms
= $GLOBALS['BE_USER']->calcPerms($pageinfo);
1979 $dblist->noControlPanels
=1;
1980 $dblist->clickMenuEnabled
=0;
1981 $dblist->tableList
=implode(',',$tablesArr);
1983 $dblist->start($id,t3lib_div
::_GP('table'),$pointer,
1984 t3lib_div
::_GP('search_field'),
1985 t3lib_div
::_GP('search_levels'),
1986 t3lib_div
::_GP('showLimit')
1988 $dblist->setDispFields();
1989 $dblist->generateList();
1990 $dblist->writeBottom();
1992 // Add the HTML for the record list to output variable:
1993 $out.=$dblist->HTMLcode
;
1995 // Add support for fieldselectbox in singleTableMode
1996 if ($dblist->table
) {
1997 $out.= $dblist->fieldSelectBox($dblist->table
);
2000 $out.=$dblist->getSearchBox();
2003 // Return accumulated content:
2009 * Render list of folders inside a folder.
2011 * @param string string of the current folder
2012 * @return string HTML output
2014 function TBE_expandSubFolders($expandFolder=0) {
2017 $expandFolder = $expandFolder ?
2019 $this->expandFolder
;
2021 if($expandFolder && $this->checkFolder($expandFolder)) {
2022 if(t3lib_div
::isFirstPartOfStr($expandFolder, PATH_site
)) {
2023 $rootFolder = substr($expandFolder, strlen(PATH_site
));
2028 // Listing the folders:
2029 $folders = t3lib_div
::get_dirs($expandFolder);
2030 if(count($folders) > 0) {
2031 foreach($folders as $index => $folder) {
2032 $folders[$index] = $rootFolder.$folder.'/';
2035 $content.= $this->folderList($rootFolder, $folders);
2038 // Return accumulated content for folderlisting:
2052 /******************************************************************
2056 ******************************************************************/
2058 * For RTE: This displays all files from folder. No thumbnails shown
2060 * @param string The folder path to expand
2061 * @param string List of fileextensions to show
2062 * @return string HTML output
2064 function expandFolder($expandFolder=0,$extensionList='') {
2067 $expandFolder = $expandFolder ?
$expandFolder : $this->expandFolder
;
2069 if ($expandFolder && $this->checkFolder($expandFolder)) {
2071 // Create header for filelisting:
2072 $out.=$this->barheader($GLOBALS['LANG']->getLL('files').':');
2074 // Prepare current path value for comparison (showing red arrow)
2075 if (!$this->curUrlInfo
['value']) {
2078 $cmpPath=PATH_site
.$this->curUrlInfo
['info'];
2082 // Create header element; The folder from which files are listed.
2083 $titleLen=intval($GLOBALS['BE_USER']->uc
['titleLen']);
2084 $picon='<img'.t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/i/_icon_webfolders.gif','width="18" height="16"').' alt="" />';
2085 $picon.=htmlspecialchars(t3lib_div
::fixed_lgd_cs(basename($expandFolder),$titleLen));
2086 $picon='<a href="#" onclick="return link_folder(\''.t3lib_div
::rawUrlEncodeFP(substr($expandFolder,strlen(PATH_site
))).'\');">'.$picon.'</a>';
2087 if ($this->curUrlInfo
['act'] == 'folder' && $cmpPath == $expandFolder) {
2088 $out.= '<img'.t3lib_iconWorks
::skinImg($BACK_PATH, 'gfx/blinkarrow_left.gif', 'width="5" height="9"') . ' class="c-blinkArrowL" alt="" />';
2090 $out.=$picon.'<br />';
2092 // Get files from the folder:
2093 if ($this->mode
== 'wizard' && $this->act
== 'folder') {
2094 $files = t3lib_div
::get_dirs($expandFolder);
2096 $files = t3lib_div
::getFilesInDir($expandFolder, $extensionList, 1, 1); // $extensionList='', $prependPath=0, $order='')
2101 if (is_array($files)) {
2102 foreach($files as $filepath) {
2104 $fI=pathinfo($filepath);
2106 if ($this->mode
== 'wizard' && $this->act
== 'folder') {
2107 $filepath = $expandFolder.$filepath.'/';
2108 $icon = '<img' . t3lib_iconWorks
::skinImg($BACK_PATH, 'gfx/i/_icon_webfolders.gif', 'width="18" height="16"') . ' alt="" />';
2111 $icon = t3lib_BEfunc
::getFileIcon(strtolower($fI['extension']));
2113 // Get size and icon:
2114 $size = ' (' . t3lib_div
::formatSize(filesize($filepath)) . 'bytes)';
2115 $icon = '<img' . t3lib_iconWorks
::skinImg($BACK_PATH, 'gfx/fileicons/' . $icon . '', 'width="18" height="16"') . ' title="' . htmlspecialchars($fI['basename'] . $size) . '" alt="" />';
2118 // If the listed file turns out to be the CURRENT file, then show blinking arrow:
2119 if (($this->curUrlInfo
['act'] == 'file' ||
$this->curUrlInfo
['act'] == 'folder') && $cmpPath == $filepath) {
2120 $arrCol='<img'.t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/blinkarrow_left.gif','width="5" height="9"').' class="c-blinkArrowL" alt="" />';
2125 // Put it all together for the file element:
2126 $out.='<img'.t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/ol/join'.($c==$cc?
'bottom':'').'.gif','width="18" height="16"').' alt="" />'.
2128 '<a href="#" onclick="return link_folder(\''.t3lib_div
::rawUrlEncodeFP(substr($filepath,strlen(PATH_site
))).'\');">'.
2130 htmlspecialchars(t3lib_div
::fixed_lgd_cs(basename($filepath),$titleLen)).
2139 * For TYPO3 Element Browser: Expand folder of files.
2141 * @param string The folder path to expand
2142 * @param string List of fileextensions to show
2143 * @param boolean Whether to show thumbnails or not. If set, no thumbnails are shown.
2144 * @return string HTML output
2146 function TBE_expandFolder($expandFolder=0,$extensionList='',$noThumbs=0) {
2147 $extensionList = ($extensionList == '*') ?
'' : $extensionList;
2148 $expandFolder = $expandFolder ?
$expandFolder : $this->expandFolder
;
2150 if ($expandFolder && $this->checkFolder($expandFolder)) {
2151 // Listing the files:
2152 $files = t3lib_div
::getFilesInDir($expandFolder,$extensionList,1,1); // $extensionList="",$prependPath=0,$order='')
2153 $out.= $this->fileList($files, $expandFolder, $noThumbs);
2156 // Return accumulated content for filelisting:
2161 * Render list of files.
2163 * @param array List of files. See t3lib_div::getFilesInDir
2164 * @param string If set a header with a folder icon and folder name are shown
2165 * @param boolean Whether to show thumbnails or not. If set, no thumbnails are shown.
2166 * @return string HTML output
2168 function fileList($files, $folderName='', $noThumbs=0) {
2173 // Listing the files:
2174 if (is_array($files)) {
2176 // Create headline (showing number of files):
2177 $filesCount = count($files);
2178 $out.=$this->barheader(sprintf($GLOBALS['LANG']->getLL('files').' (%s):', $filesCount));
2179 $out.=$this->getBulkSelector($filesCount);
2181 $titleLen=intval($GLOBALS['BE_USER']->uc
['titleLen']);
2183 // Create the header of current folder:
2185 $picon='<img'.t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/i/_icon_webfolders.gif','width="18" height="16"').' alt="" />';
2186 $picon.=htmlspecialchars(t3lib_div
::fixed_lgd_cs(basename($folderName),$titleLen));
2187 $out.=$picon.'<br />';
2190 // Init graphic object for reading file dimensions:
2191 /** @var $imgObj t3lib_stdGraphic */
2192 $imgObj = t3lib_div
::makeInstance('t3lib_stdGraphic');
2194 $imgObj->mayScaleUp
=0;
2195 $imgObj->tempPath
=PATH_site
.$imgObj->tempPath
;
2197 // Traverse the file list:
2199 foreach($files as $filepath) {
2200 $fI=pathinfo($filepath);
2202 // Thumbnail/size generation:
2203 if (t3lib_div
::inList(strtolower($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']),strtolower($fI['extension'])) && !$noThumbs) {
2204 $imgInfo = $imgObj->getImageDimensions($filepath);
2205 $pDim = $imgInfo[0].'x'.$imgInfo[1].' pixels';
2206 $clickIcon = t3lib_BEfunc
::getThumbNail($BACK_PATH.'thumbs.php',$filepath,'hspace="5" vspace="5" border="1"');
2212 // Create file icon:
2213 $ficon = t3lib_BEfunc
::getFileIcon(strtolower($fI['extension']));
2214 $size=' ('.t3lib_div
::formatSize(filesize($filepath)).'bytes'.($pDim?
', '.$pDim:'').')';
2215 $icon = '<img'.t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/fileicons/'.$ficon,'width="18" height="16"').' title="'.htmlspecialchars($fI['basename'].$size).'" class="absmiddle" alt="" />';
2217 // Create links for adding the file:
2218 if (strstr($filepath,',') ||
strstr($filepath,'|')) { // In case an invalid character is in the filepath, display error message:
2219 $eMsg = $GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->getLL('invalidChar'), ', |'));
2220 $ATag = $ATag_alt = "<a href=\"#\" onclick=\"alert(".$eMsg.");return false;\">";
2222 } else { // If filename is OK, just add it:
2223 $filesIndex = count($this->elements
);
2224 $this->elements
['file_'.$filesIndex] = array(
2225 'md5' => t3lib_div
::shortMD5($filepath),
2227 'fileName' => $fI['basename'],
2228 'filePath' => $filepath,
2229 'fileExt' => $fI['extension'],
2230 'fileIcon' => $ficon,
2232 $ATag = "<a href=\"#\" onclick=\"return BrowseLinks.File.insertElement('file_$filesIndex');\">";
2233 $ATag_alt = substr($ATag,0,-4).",1);\">";
2234 $bulkCheckBox = '<input type="checkbox" class="typo3-bulk-item" name="file_'.$filesIndex.'" value="0" /> ';
2238 // Create link to showing details about the file in a window:
2239 $Ahref = $BACK_PATH.'show_item.php?table='.rawurlencode($filepath).'&returnUrl='.rawurlencode(t3lib_div
::getIndpEnv('REQUEST_URI'));
2240 $ATag2='<a href="'.htmlspecialchars($Ahref).'">';
2243 // Combine the stuff:
2244 $filenameAndIcon=$bulkCheckBox.$ATag_alt.$icon.htmlspecialchars(t3lib_div
::fixed_lgd_cs(basename($filepath),$titleLen)).$ATag_e;
2247 if ($pDim) { // Image...
2249 <tr class="bgColor4">
2250 <td nowrap="nowrap">'.$filenameAndIcon.' </td>
2251 <td>' . $ATag . '<img' . t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/plusbullet2.gif', 'width="18" height="16"') . ' title="' . $GLOBALS['LANG']->getLL('addToList',1) . '" alt="" />' . $ATag_e . '</td>
2252 <td nowrap="nowrap">' . ($ATag2 . '<img'.t3lib_iconWorks
::skinImg($BACK_PATH, 'gfx/zoom2.gif', 'width="12" height="12"') . ' title="' . $GLOBALS['LANG']->getLL('info', 1) . '" alt="" /> ' . $GLOBALS['LANG']->getLL('info', 1) . $ATag2_e) . '</td>
2253 <td nowrap="nowrap"> '.$pDim.'</td>
2257 <td colspan="4">'.$ATag_alt.$clickIcon.$ATag_e.'</td>
2261 <tr class="bgColor4">
2262 <td nowrap="nowrap">'.$filenameAndIcon.' </td>
2263 <td>' . $ATag . '<img' . t3lib_iconWorks
::skinImg($BACK_PATH, 'gfx/plusbullet2.gif','width="18" height="16"') . ' title="' . $GLOBALS['LANG']->getLL('addToList',1) . '" alt="" />' . $ATag_e . '</td>
2264 <td nowrap="nowrap">' . ($ATag2 . '<img' . t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/zoom2.gif','width="12" height="12"') . ' title="' . $GLOBALS['LANG']->getLL('info', 1) . '" alt="" /> ' . $GLOBALS['LANG']->getLL('info', 1) . $ATag2_e) . '</td>
2270 <td colspan="3"><img src="clear.gif" width="1" height="3" alt="" /></td>
2274 // Wrap all the rows in table tags:
2282 <table cellpadding="0" cellspacing="0" id="typo3-fileList">
2283 '.implode('',$lines).'
2286 // Return accumulated content for filelisting:
2291 * Render list of folders.
2293 * @param array List of folders. See t3lib_div::get_dirs
2294 * @param string If set a header with a folder icon and folder name are shown
2295 * @return string HTML output
2297 function folderList($baseFolder, $folders) {
2302 // Create headline (showing number of folders):
2303 $content.=$this->barheader(
2304 sprintf($GLOBALS['LANG']->getLL('folders').' (%s):',count($folders))
2307 $titleLength = intval($GLOBALS['BE_USER']->uc
['titleLen']);
2309 // Create the header of current folder:
2311 if (strstr($baseFolder, ',') ||
strstr($baseFolder, '|')) {
2312 // In case an invalid character is in the filepath, display error message:
2313 $errorMessage = $GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->getLL('invalidChar'), ', |'));
2314 $aTag = $aTag_alt = "<a href=\"#\" onclick=\"alert(".$errorMessage.");return false;\">";
2316 // If foldername is OK, just add it:
2317 $aTag = "<a href=\"#\" onclick=\"return insertElement('','".rawurlencode($baseFolder)."', 'folder', '".rawurlencode($baseFolder)."', unescape('".rawurlencode($baseFolder)."'), '".$fI['extension']."', '".$ficon."');\">";
2318 $aTag_alt = substr($aTag,0,-4).",'',1);\">";
2322 // add the foder icon
2323 $folderIcon = $aTag_alt;
2324 $folderIcon.= '<img'.t3lib_iconWorks
::skinImg(
2326 'gfx/i/_icon_webfolders.gif','width="18" height="16"'
2328 $folderIcon.= htmlspecialchars(
2329 t3lib_div
::fixed_lgd_cs(basename($baseFolder),$titleLength)
2331 $folderIcon.= $aTag_e;
2333 $content.=$folderIcon.'<br />';
2336 // Listing the folders:
2337 if(is_array($folders)) {
2338 if(count($folders) > 0) {
2339 // Traverse the folder list:
2341 foreach($folders as $folderPath) {
2342 $pathInfo = pathinfo($folderPath);
2344 // Create folder icon:
2345 $icon = '<img src="clear.gif" width="16" height="16" alt="" /><img'.t3lib_iconWorks
::skinImg($BACK_PATH, 'gfx/i/_icon_webfolders.gif','width="16" height="16"').' title="'.htmlspecialchars($pathInfo['basename'].$size).'" class="absmiddle" alt="" />';
2347 // Create links for adding the folder:
2348 if($this->P
['itemName'] != '' && $this->P
['formName'] != '') {
2349 $aTag = "<a href=\"#\" onclick=\"return set_folderpath(unescape('".rawurlencode($folderPath)."'));\">";
2351 $aTag = "<a href=\"#\" onclick=\"return insertElement('','".rawurlencode($folderPath)."', 'folder', '".rawurlencode($folderPath)."', unescape('".rawurlencode($folderPath)."'), '".$pathInfo['extension']."', '".$ficon."');\">";
2354 if (strstr($folderPath,',') ||
strstr($folderPath,'|')) {
2355 // In case an invalid character is in the filepath, display error message:
2356 $errorMessage = $GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->getLL('invalidChar'), ', |'));
2357 $aTag = $aTag_alt = "<a href=\"#\" onclick=\"alert(".$errorMessage.");return false;\">";
2359 // If foldername is OK, just add it:
2360 $aTag_alt = substr($aTag,0,-4).",'',1);\">";
2364 // Combine icon and folderpath:
2365 $foldernameAndIcon = $aTag_alt.$icon.htmlspecialchars(
2366 t3lib_div
::fixed_lgd_cs(basename($folderPath),$titleLength)
2369 if($this->P
['itemName'] != '') {
2371 <tr class="bgColor4">
2372 <td nowrap="nowrap">'.$foldernameAndIcon.' </td>
2377 <tr class="bgColor4">
2378 <td nowrap="nowrap">'.$foldernameAndIcon.' </td>
2379 <td>' . $aTag . '<img' . t3lib_iconWorks
::skinImg($BACK_PATH, 'gfx/plusbullet2.gif', 'width="18" height="16"') . ' title="' . $GLOBALS['LANG']->getLL('addToList', 1) . '" alt="" />' . $aTag_e .' </td>
2386 <td colspan="3"><img src="clear.gif" width="1" height="3" alt="" /></td>
2391 // Wrap all the rows in table tags:
2397 <table border="0" cellpadding="0" cellspacing="1" id="typo3-folderList">
2398 '.implode('', $lines).'
2402 // Return accumulated content for folderlisting:
2407 * For RTE: This displays all IMAGES (gif,png,jpg) (from extensionList) from folder. Thumbnails are shown for images.
2408 * This listing is of images located in the web-accessible paths ONLY - the listing is for drag-n-drop use in the RTE
2410 * @param string The folder path to expand
2411 * @param string List of fileextensions to show
2412 * @return string HTML output
2414 function TBE_dragNDrop($expandFolder=0,$extensionList='') {
2417 $extensionList = ($extensionList == '*') ?
'' : $extensionList;
2418 $expandFolder = $expandFolder ?
$expandFolder : $this->expandFolder
;
2420 if ($expandFolder && $this->checkFolder($expandFolder)) {
2421 if ($this->isWebFolder($expandFolder)) {
2423 // Read files from directory:
2424 $files = t3lib_div
::getFilesInDir($expandFolder,$extensionList,1,1); // $extensionList="",$prependPath=0,$order='')
2425 if (is_array($files)) {
2426 $out.=$this->barheader(sprintf($GLOBALS['LANG']->getLL('files').' (%s):',count($files)));
2428 $titleLen=intval($GLOBALS['BE_USER']->uc
['titleLen']);
2429 $picon='<img'.t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/i/_icon_webfolders.gif','width="18" height="16"').' alt="" />';
2430 $picon.=htmlspecialchars(t3lib_div
::fixed_lgd_cs(basename($expandFolder),$titleLen));
2431 $out.=$picon.'<br />';
2436 // Add "drag-n-drop" message:
2439 <td colspan="2">'.$this->getMsgBox($GLOBALS['LANG']->getLL('findDragDrop')).'</td>
2443 foreach ($files as $filepath) {
2444 $fI = pathinfo($filepath);
2447 $iurl = $this->siteURL
.t3lib_div
::rawurlencodeFP(substr($filepath,strlen(PATH_site
)));
2449 // Show only web-images
2450 if (t3lib_div
::inList('gif,jpeg,jpg,png',strtolower($fI['extension']))) {
2451 $imgInfo = @getimagesize
($filepath);
2452 $pDim = $imgInfo[0].'x'.$imgInfo[1].' pixels';
2454 $ficon = t3lib_BEfunc
::getFileIcon(strtolower($fI['extension']));
2455 $size=' ('.t3lib_div
::formatSize(filesize($filepath)).'bytes'.($pDim?
', '.$pDim:'').')';
2456 $icon = '<img'.t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/fileicons/'.$ficon,'width="18" height="16"').' class="absmiddle" title="'.htmlspecialchars($fI['basename'].$size).'" alt="" />';
2457 $filenameAndIcon=$icon.htmlspecialchars(t3lib_div
::fixed_lgd_cs(basename($filepath),$titleLen));
2459 if (t3lib_div
::_GP('noLimit')) {
2469 $IH=ceil($IH/$IW*$maxW);
2473 $IW=ceil($IW/$IH*$maxH);
2479 <tr class="bgColor4">
2480 <td nowrap="nowrap">'.$filenameAndIcon.' </td>
2481 <td nowrap="nowrap">'.
2482 ($imgInfo[0]!=$IW ?
'<a href="'.htmlspecialchars(t3lib_div
::linkThisScript(array('noLimit'=>'1'))).'">'.
2483 '<img'.t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/icon_warning2.gif','width="18" height="16"').' title="'.$GLOBALS['LANG']->getLL('clickToRedrawFullSize',1).'" alt="" />'.
2490 <td colspan="2"><img src="'.$iurl.'" width="'.$IW.'" height="'.$IH.'" border="1" alt="" /></td>
2494 <td colspan="2"><img src="clear.gif" width="1" height="3" alt="" /></td>
2499 // Finally, wrap all rows in a table tag:
2504 File listing / Drag-n-drop
2506 <table border="0" cellpadding="0" cellspacing="1" id="typo3-dragBox">
2507 '.implode('',$lines).'
2511 // Print this warning if the folder is NOT a web folder:
2512 $out.=$this->barheader($GLOBALS['LANG']->getLL('files'));
2513 $out.=$this->getMsgBox($GLOBALS['LANG']->getLL('noWebFolder'),'icon_warning2');
2530 /******************************************************************
2532 * Miscellaneous functions
2534 ******************************************************************/
2538 * Verifies that a path is a web-folder:
2540 * @param string Absolute filepath
2541 * @return boolean If the input path is found in PATH_site then it returns TRUE.
2543 function isWebFolder($folder) {
2544 $folder = rtrim($folder, '/').'/';
2545 return t3lib_div
::isFirstPartOfStr($folder,PATH_site
) ? TRUE
: FALSE
;
2549 * Checks, if a path is within the mountpoints of the backend user
2551 * @param string Absolute filepath
2552 * @return boolean If the input path is found in the backend users filemounts, then return TRUE.
2554 function checkFolder($folder) {
2555 return $this->fileProcessor
->checkPathAgainstMounts(rtrim($folder, '/') . '/') ? TRUE
: FALSE
;
2559 * Checks, if a path is within a read-only mountpoint of the backend user
2561 * @param string Absolute filepath
2562 * @return boolean If the input path is found in the backend users filemounts and if the filemount is of type readonly, then return TRUE.
2564 function isReadOnlyFolder($folder) {
2565 return ($GLOBALS['FILEMOUNTS'][$this->fileProcessor
->checkPathAgainstMounts(rtrim($folder, '/') . '/')]['type'] == 'readonly');
2569 * Prints a 'header' where string is in a tablecell
2571 * @param string The string to print in the header. The value is htmlspecialchars()'ed before output.
2572 * @return string The header HTML (wrapped in a table)
2574 function barheader($str) {
2576 <!-- Bar header: -->
2577 <h3>' . htmlspecialchars($str) . '</h3>
2582 * Displays a message box with the input message
2584 * @param string Input message to show (will be htmlspecialchars()'ed inside of this function)
2585 * @param string Icon filename body from gfx/ (default is "icon_note") - meant to allow change to warning type icons...
2586 * @return string HTML for the message (wrapped in a table).
2588 function getMsgBox($in_msg,$icon='icon_note') {
2591 $msg = '<img'.t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/'.$icon.'.gif','width="18" height="16"').' alt="" />'.htmlspecialchars($in_msg);
2597 <table cellspacing="0" class="bgColor4" id="typo3-msgBox">
2607 * For RTE/link: This prints the 'currentUrl'
2609 * @param string URL value. The value is htmlspecialchars()'ed before output.
2610 * @return string HTML content, wrapped in a table.
2612 function printCurrentUrl($str) {
2615 <!-- Print current URL -->
2616 <table border="0" cellpadding="0" cellspacing="0" id="typo3-curUrl">
2618 <td>' . $GLOBALS['LANG']->getLL('currentLink',1) . ': ' .htmlspecialchars(rawurldecode($str)) . '</td>
2627 * For RTE/link: Parses the incoming URL and determines if it's a page, file, external or mail address.
2629 * @param string HREF value tp analyse
2630 * @param string The URL of the current website (frontend)
2631 * @return array Array with URL information stored in assoc. keys: value, act (page, file, spec, mail), pageid, cElement, info
2633 function parseCurUrl($href,$siteUrl) {
2634 $href = trim($href);
2638 // Default is "url":
2639 $info['value']=$href;
2642 $specialParts = explode('#_SPECIAL',$href);
2643 if (count($specialParts)==2) { // Special kind (Something RTE specific: User configurable links through: "userLinks." from ->thisConfig)
2644 $info['value']='#_SPECIAL'.$specialParts[1];
2645 $info['act']='spec';
2646 } elseif (t3lib_div
::isFirstPartOfStr($href,$siteUrl)) { // If URL is on the current frontend website:
2647 $rel = substr($href,strlen($siteUrl));
2648 if (file_exists(PATH_site
.rawurldecode($rel))) { // URL is a file, which exists:
2649 $info['value']=rawurldecode($rel);
2650 if (@is_dir
(PATH_site
. $info['value'])) {
2651 $info['act'] = 'folder';
2653 $info['act'] = 'file';
2655 } else { // URL is a page (id parameter)
2656 $uP=parse_url($rel);
2657 if (!trim($uP['path'])) {
2658 $pp = preg_split('/^id=/', $uP['query']);
2659 $pp[1] = preg_replace( '/&id=[^&]*/', '', $pp[1]);
2660 $parameters = explode('&', $pp[1]);
2661 $id = array_shift($parameters);
2663 // Checking if the id-parameter is an alias.
2664 if (!t3lib_div
::testInt($id)) {
2665 list($idPartR) = t3lib_BEfunc
::getRecordsByField('pages','alias',$id);
2666 $id=intval($idPartR['uid']);
2669 $pageRow = t3lib_BEfunc
::getRecordWSOL('pages',$id);
2670 $titleLen=intval($GLOBALS['BE_USER']->uc
['titleLen']);
2671 $info['value']=$GLOBALS['LANG']->getLL('page',1)." '".htmlspecialchars(t3lib_div
::fixed_lgd_cs($pageRow['title'],$titleLen))."' (ID:".$id.($uP['fragment']?
', #'.$uP['fragment']:'').')';
2672 $info['pageid']=$id;
2673 $info['cElement']=$uP['fragment'];
2674 $info['act']='page';
2675 $info['query'] = $parameters[0]?
'&'.implode('&', $parameters):'';
2679 } else { // Email link:
2680 if (strtolower(substr($href,0,7))=='mailto:') {
2681 $info['value']=trim(substr($href,7));
2682 $info['act']='mail';
2685 $info['info'] = $info['value'];
2686 } else { // NO value inputted:
2688 $info['info']=$GLOBALS['LANG']->getLL('none');
2690 $info['act']='page';
2693 // let the hook have a look
2694 foreach($this->hookObjects
as $hookObject) {
2695 $info = $hookObject->parseCurrentUrl($href, $siteUrl, $info);
2702 * For TBE: Makes an upload form for uploading files to the filemount the user is browsing.
2703 * The files are uploaded to the tce_file.php script in the core which will handle the upload.
2705 * @param string Absolute filepath on server to which to upload.
2706 * @return string HTML for an upload form.
2708 function uploadForm($path) {
2711 if ($this->isReadOnlyFolder($path)) return '';
2713 // Read configuration of upload field count
2714 $userSetting = $GLOBALS['BE_USER']->getTSConfigVal('options.folderTree.uploadFieldsInLinkBrowser');
2715 $count = isset($userSetting) ?
$userSetting : 3;
2716 if ($count === '0') {
2719 $count = intval($count) == 0 ?
3 : intval($count);
2721 // Create header, showing upload path:
2722 $header = t3lib_div
::isFirstPartOfStr($path,PATH_site
)?
substr($path,strlen(PATH_site
)):$path;
2723 $code=$this->barheader($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_upload.php.pagetitle',1).':');
2727 Form, for uploading files:
2729 <form action="'.$BACK_PATH.'tce_file.php" method="post" name="editform" enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'">
2730 <table border="0" cellpadding="0" cellspacing="3" id="typo3-uplFiles">
2732 <td><strong>'.$GLOBALS['LANG']->getLL('path',1).':</strong> '.htmlspecialchars($header).'</td>
2737 // Traverse the number of upload fields (default is 3):
2738 for ($a=1;$a<=$count;$a++
) {
2739 $code.='<input type="file" name="upload_'.$a.'"'.$this->doc
->formWidth(35).' size="50" />
2740 <input type="hidden" name="file[upload]['.$a.'][target]" value="'.htmlspecialchars($path).'" />
2741 <input type="hidden" name="file[upload]['.$a.'][data]" value="'.$a.'" /><br />';
2744 // Make footer of upload form, including the submit button:
2745 $redirectValue = $this->thisScript
.'?act='.$this->act
.'&mode='.$this->mode
.'&expandFolder='.rawurlencode($path).'&bparams='.rawurlencode($this->bparams
);
2746 $code.='<input type="hidden" name="redirect" value="'.htmlspecialchars($redirectValue).'" />'.
2747 '<input type="submit" name="submit" value="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_upload.php.submit',1).'" />';
2750 <div id="c-override">
2751 <input type="checkbox" name="overwriteExistingFiles" id="overwriteExistingFiles" value="1" /> <label for="overwriteExistingFiles">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xml:overwriteExistingFiles',1).'</label>
2765 * For TBE: Makes a form for creating new folders in the filemount the user is browsing.
2766 * The folder creation request is sent to the tce_file.php script in the core which will handle the creation.
2768 * @param string Absolute filepath on server in which to create the new folder.
2769 * @return string HTML for the create folder form.
2771 function createFolder($path) {
2774 if ($this->isReadOnlyFolder($path)) return '';
2776 // Don't show Folder-create form if it's denied
2777 if ($GLOBALS['BE_USER']->getTSConfigVal('options.folderTree.hideCreateFolder')) {
2780 // Create header, showing upload path:
2781 $header = t3lib_div
::isFirstPartOfStr($path,PATH_site
)?
substr($path,strlen(PATH_site
)):$path;
2782 $code=$this->barheader($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.pagetitle').':');
2786 Form, for creating new folders:
2788 <form action="'.$BACK_PATH.'tce_file.php" method="post" name="editform2">
2789 <table border="0" cellpadding="0" cellspacing="3" id="typo3-crFolder">
2791 <td><strong>'.$GLOBALS['LANG']->getLL('path',1).':</strong> '.htmlspecialchars($header).'</td>
2796 // Create the new-folder name field:
2798 $code.='<input'.$this->doc
->formWidth(20).' type="text" name="file[newfolder]['.$a.'][data]" />'.
2799 '<input type="hidden" name="file[newfolder]['.$a.'][target]" value="'.htmlspecialchars($path).'" />';
2801 // Make footer of upload form, including the submit button:
2802 $redirectValue = $this->thisScript
.'?act='.$this->act
.'&mode='.$this->mode
.'&expandFolder='.rawurlencode($path).'&bparams='.rawurlencode($this->bparams
);
2803 $code.='<input type="hidden" name="redirect" value="'.htmlspecialchars($redirectValue).'" />'.
2804 '<input type="submit" name="submit" value="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.submit',1).'" />';
2815 * Get the HTML data required for a bulk selection of files of the TYPO3 Element Browser.
2817 * @param integer $filesCount: Number of files currently displayed
2818 * @return string HTML data required for a bulk selection of files - if $filesCount is 0, nothing is returned
2820 function getBulkSelector($filesCount) {
2822 $labelToggleSelection = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_browse_links.php:toggleSelection',1);
2823 $labelImportSelection = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_browse_links.php:importSelection',1);
2825 $out = $this->doc
->spacer(15).'<div>' .
2826 '<a href="#" onclick="BrowseLinks.Selector.toggle()">' .
2827 '<img'.t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/clip_select.gif','width="12" height="12"').' title="'.$labelToggleSelection.'" alt="" /> ' .
2828 $labelToggleSelection.'</a>'.$this->doc
->spacer(5) .
2829 '<a href="#" onclick="BrowseLinks.Selector.handle()">' .
2830 '<img'.t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/import.gif','width="12" height="12"').' title="'.$labelImportSelection.'" alt="" /> ' .
2831 $labelImportSelection.'</a>' .
2832 '</div>'.$this->doc
->spacer(15);
2838 * Determines whether submitted field change functions are valid
2839 * and are coming from the system and not from an external abuse.
2841 * @param boolean $allowFlexformSections Whether to handle flexform sections differently
2842 * @return boolean Whether the submitted field change functions are valid
2844 protected function areFieldChangeFunctionsValid($handleFlexformSections = FALSE
) {
2847 if (isset($this->P
['fieldChangeFunc']) && is_array($this->P
['fieldChangeFunc']) && isset($this->P
['fieldChangeFuncHash'])) {
2849 $pattern = '#\[el\]\[(([^]-]+-[^]-]+-)(idx\d+-)([^]]+))\]#i';
2851 $fieldChangeFunctions = $this->P
['fieldChangeFunc'];
2853 // Special handling of flexform sections:
2854 // Field change functions are modified in JavaScript, thus the hash is always invalid
2855 if ($handleFlexformSections && preg_match($pattern, $this->P
['itemName'], $matches)) {
2856 $originalName = $matches[1];
2857 $cleanedName = $matches[2] . $matches[4];
2859 foreach ($fieldChangeFunctions as &$value) {
2860 $value = str_replace($originalName, $cleanedName, $value);
2864 $result = ($this->P
['fieldChangeFuncHash'] === t3lib_div
::hmac(serialize($fieldChangeFunctions)));
2872 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE
]['XCLASS']['typo3/class.browse_links.php'])) {
2873 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE
]['XCLASS']['typo3/class.browse_links.php']);