class.browse_links.php

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2010 Kasper Skaarhoj (kasperYYYY@typo3.com)
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00027 /**
00028  * Displays the page/file tree for browsing database records or files.
00029  * Used from TCEFORMS an other elements
00030  * In other words: This is the ELEMENT BROWSER!
00031  *
00032  * $Id: class.browse_links.php 8175 2010-07-13 17:56:02Z jsegars $
00033  * Revised for TYPO3 3.6 November/2003 by Kasper Skaarhoj
00034  * XHTML compliant
00035  *
00036  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00037  */
00038 /**
00039  * [CLASS/FUNCTION INDEX of SCRIPT]
00040  *
00041  *
00042  *
00043  *  155: class TBE_browser_recordList extends localRecordList
00044  *  163:     function TBE_browser_recordList ()
00045  *  175:     function listURL($altId='',$table=-1,$exclList='')
00046  *  194:     function ext_addP()
00047  *  211:     function linkWrapItems($table,$uid,$code,$row)
00048  *  244:     function linkWrapTable($table,$code)
00049  *
00050  *
00051  *  261: class localPageTree extends t3lib_browseTree
00052  *  268:     function localPageTree()
00053  *  284:     function wrapTitle($title,$v,$ext_pArrPages='')
00054  *  299:     function printTree($treeArr='')
00055  *  350:     function ext_isLinkable($doktype,$uid)
00056  *  364:     function PM_ATagWrap($icon,$cmd,$bMark='')
00057  *  381:     function wrapIcon($icon,$row)
00058  *
00059  *
00060  *  400: class rtePageTree extends localPageTree
00061  *
00062  *
00063  *  417: class TBE_PageTree extends localPageTree
00064  *  426:     function ext_isLinkable($doktype,$uid)
00065  *  438:     function wrapTitle($title,$v,$ext_pArrPages)
00066  *
00067  *
00068  *  464: class localFolderTree extends t3lib_folderTree
00069  *  473:     function localFolderTree()
00070  *  485:     function wrapTitle($title,$v)
00071  *  500:     function ext_isLinkable($v)
00072  *  517:     function PM_ATagWrap($icon,$cmd,$bMark='')
00073  *  532:     function printTree($treeArr='')
00074  *
00075  *
00076  *  599: class rteFolderTree extends localFolderTree
00077  *
00078  *
00079  *  615: class TBE_FolderTree extends localFolderTree
00080  *  624:     function ext_isLinkable($v)
00081  *  637:     function wrapTitle($title,$v)
00082  *
00083  *
00084  *  658: class browse_links
00085  *  764:     function init()
00086  * 1034:     function processSessionData($data)
00087  *
00088  *              SECTION: Main functions
00089  * 1077:     function main_rte($wiz=0)
00090  * 1379:     function main_db()
00091  * 1424:     function main_file()
00092  *
00093  *              SECTION: Record listing
00094  * 1534:     function expandPage()
00095  * 1615:     function TBE_expandPage($tables)
00096  *
00097  *              SECTION: File listing
00098  * 1708:     function expandFolder($expandFolder=0,$extensionList='')
00099  * 1778:     function TBE_expandFolder($expandFolder=0,$extensionList='',$noThumbs=0)
00100  * 1801:     function fileList($files, $folderName='', $noThumbs=0)
00101  * 1918:     function TBE_dragNDrop($expandFolder=0,$extensionList='')
00102  *
00103  *              SECTION: Miscellaneous functions
00104  * 2046:     function isWebFolder($folder)
00105  * 2057:     function checkFolder($folder)
00106  * 2070:     function barheader($str)
00107  * 2087:     function getMsgBox($in_msg,$icon='icon_note')
00108  * 2111:     function printCurrentUrl($str)
00109  * 2131:     function parseCurUrl($href,$siteUrl)
00110  * 2193:     function uploadForm($path)
00111  * 2247:     function createFolder($path)
00112  *
00113  * TOTAL FUNCTIONS: 39
00114  * (This index is automatically created/updated by the extension "extdeveval")
00115  *
00116  */
00117 
00118 
00119     // Include classes
00120 require_once (PATH_typo3.'/class.db_list.inc');
00121 require_once (PATH_typo3.'/class.db_list_extra.inc');
00122 
00123 
00124 
00125 
00126 /**
00127  * Local version of the record list.
00128  *
00129  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00130  * @package TYPO3
00131  * @subpackage core
00132  */
00133 class TBE_browser_recordList extends localRecordList {
00134     var $thisScript = 'browse_links.php';
00135 
00136     /**
00137      * Initializes the script path
00138      *
00139      * @return  void
00140      */
00141     function TBE_browser_recordList () {
00142         parent::__construct();
00143         $this->thisScript = t3lib_div::getIndpEnv('SCRIPT_NAME');
00144     }
00145 
00146     /**
00147      * Creates the URL for links
00148      *
00149      * @param   mixed       If not blank string, this is used instead of $this->id as the id value.
00150      * @param   string      If this is "-1" then $this->table is used, otherwise the value of the input variable.
00151      * @param   string      Commalist of fields NOT to pass as parameters (currently "sortField" and "sortRev")
00152      * @return  string      Query-string for URL
00153      */
00154     function listURL($altId='',$table=-1,$exclList='')  {
00155         return $this->thisScript.
00156             '?id='.(strcmp($altId,'')?$altId:$this->id).
00157             '&table='.rawurlencode($table==-1?$this->table:$table).
00158             ($this->thumbs?'&imagemode='.$this->thumbs:'').
00159             ($this->searchString?'&search_field='.rawurlencode($this->searchString):'').
00160             ($this->searchLevels?'&search_levels='.rawurlencode($this->searchLevels):'').
00161             ((!$exclList || !t3lib_div::inList($exclList,'sortField')) && $this->sortField?'&sortField='.rawurlencode($this->sortField):'').
00162             ((!$exclList || !t3lib_div::inList($exclList,'sortRev')) && $this->sortRev?'&sortRev='.rawurlencode($this->sortRev):'').
00163                 // extra:
00164             $this->ext_addP()
00165             ;
00166     }
00167 
00168     /**
00169      * Returns additional, local GET parameters to include in the links of the record list.
00170      *
00171      * @return  string
00172      */
00173     function ext_addP() {
00174         $str = '&act='.$GLOBALS['SOBE']->browser->act.
00175                 '&mode='.$GLOBALS['SOBE']->browser->mode.
00176                 '&expandPage='.$GLOBALS['SOBE']->browser->expandPage.
00177                 '&bparams='.rawurlencode($GLOBALS['SOBE']->browser->bparams);
00178         return $str;
00179     }
00180 
00181     /**
00182      * 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...)
00183      *
00184      * @param   string      Table name
00185      * @param   integer     UID (not used here)
00186      * @param   string      Title string
00187      * @param   array       Records array (from table name)
00188      * @return  string
00189      */
00190     function linkWrapItems($table,$uid,$code,$row)  {
00191         global $TCA, $BACK_PATH;
00192 
00193         if (!$code) {
00194             $code = '<i>['.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.no_title',1).']</i>';
00195         } else {
00196             $code = t3lib_BEfunc::getRecordTitlePrep($code, $this->fixedL);
00197         }
00198 
00199         $title = t3lib_BEfunc::getRecordTitle($table,$row,FALSE,TRUE);
00200         $ficon = t3lib_iconWorks::getIcon($table,$row);
00201         $aOnClick = "return insertElement('".$table."', '".$row['uid']."', 'db', ".t3lib_div::quoteJSvalue($title).", '', '', '".$ficon."');";
00202         $ATag = '<a href="#" onclick="'.$aOnClick.'">';
00203         $ATag_alt = substr($ATag,0,-4).',\'\',1);">';
00204         $ATag_e = '</a>';
00205 
00206         return $ATag.
00207                 '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/plusbullet2.gif','width="18" height="16"').' title="'.$GLOBALS['LANG']->getLL('addToList',1).'" alt="" />'.
00208                 $ATag_e.
00209                 $ATag_alt.
00210                 $code.
00211                 $ATag_e;
00212     }
00213 
00214     /**
00215      * Local version that sets allFields to true to support userFieldSelect
00216      *
00217      * @return  void
00218      * @see fieldSelectBox
00219      */
00220     function generateList() {
00221         $this->allFields = true;
00222         parent::generateList();
00223     }
00224 }
00225 
00226 
00227 
00228 
00229 
00230 
00231 /**
00232  * Class which generates the page tree
00233  *
00234  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00235  * @package TYPO3
00236  * @subpackage core
00237  */
00238 class localPageTree extends t3lib_browseTree {
00239 
00240     /**
00241      * whether the page ID should be shown next to the title, activate through userTSconfig (options.pageTree.showPageIdWithTitle)
00242      * @boolean
00243      */
00244     public $ext_showPageId = FALSE;
00245 
00246     /**
00247      * Constructor. Just calling init()
00248      *
00249      * @return  void
00250      */
00251     function localPageTree() {
00252         $this->thisScript = t3lib_div::getIndpEnv('SCRIPT_NAME');
00253 
00254         $this->init();
00255 
00256         $this->clause = ' AND doktype!=255'.$this->clause;
00257     }
00258 
00259     /**
00260      * Wrapping the title in a link, if applicable.
00261      *
00262      * @param   string      Title, (must be ready for output, that means it must be htmlspecialchars()'ed).
00263      * @param   array       The record
00264      * @param   boolean     (Ignore)
00265      * @return  string      Wrapping title string.
00266      */
00267     function wrapTitle($title,$v,$ext_pArrPages='') {
00268         if ($this->ext_isLinkable($v['doktype'],$v['uid'])) {
00269             $aOnClick = "return link_typo3Page('".$v['uid']."');";
00270             return '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$title.'</a>';
00271         } else {
00272             return '<span style="color: #666666;">'.$title.'</span>';
00273         }
00274     }
00275 
00276     /**
00277      * Create the page navigation tree in HTML
00278      *
00279      * @param   array       Tree array
00280      * @return  string      HTML output.
00281      */
00282     function printTree($treeArr='') {
00283         global $BACK_PATH;
00284         $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
00285         if (!is_array($treeArr))    $treeArr=$this->tree;
00286 
00287         $out='';
00288         $c=0;
00289 
00290         foreach($treeArr as $k => $v)   {
00291             $c++;
00292             $bgColorClass = ($c+1)%2 ? 'bgColor' : 'bgColor-10';
00293             if ($GLOBALS['SOBE']->browser->curUrlInfo['act']=='page' && $GLOBALS['SOBE']->browser->curUrlInfo['pageid']==$v['row']['uid'] && $GLOBALS['SOBE']->browser->curUrlInfo['pageid'])   {
00294                 $arrCol='<td><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/blinkarrow_right.gif','width="5" height="9"').' class="c-blinkArrowR" alt="" /></td>';
00295                 $bgColorClass='bgColor4';
00296             } else {
00297                 $arrCol='<td></td>';
00298             }
00299 
00300             $aOnClick = 'return jumpToUrl(\''.$this->thisScript.'?act='.$GLOBALS['SOBE']->browser->act.'&mode='.$GLOBALS['SOBE']->browser->mode.'&expandPage='.$v['row']['uid'].'\');';
00301             $cEbullet = $this->ext_isLinkable($v['row']['doktype'],$v['row']['uid']) ?
00302                         '<a href="#" onclick="'.htmlspecialchars($aOnClick).'"><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/arrowbullet.gif','width="18" height="16"').' alt="" /></a>' :
00303                         '';
00304             $out.='
00305                 <tr class="'.$bgColorClass.'">
00306                     <td nowrap="nowrap"'.($v['row']['_CSSCLASS'] ? ' class="'.$v['row']['_CSSCLASS'].'"' : '').'>'.
00307                     $v['HTML'].
00308                     $this->wrapTitle($this->getTitleStr($v['row'],$titleLen),$v['row'],$this->ext_pArrPages).
00309                     '</td>'.
00310                     $arrCol.
00311                     '<td>'.$cEbullet.'</td>
00312                 </tr>';
00313         }
00314         $out='
00315 
00316 
00317             <!--
00318                 Navigation Page Tree:
00319             -->
00320             <table border="0" cellpadding="0" cellspacing="0" id="typo3-tree">
00321                 '.$out.'
00322             </table>';
00323         return $out;
00324     }
00325 
00326     /**
00327      * Returns true if a doktype can be linked.
00328      *
00329      * @param   integer     Doktype value to test
00330      * @param   integer     uid to test.
00331      * @return  boolean
00332      */
00333     function ext_isLinkable($doktype,$uid)  {
00334         if ($uid && $doktype<199)   {
00335             return true;
00336         }
00337     }
00338 
00339     /**
00340      * Wrap the plus/minus icon in a link
00341      *
00342      * @param   string      HTML string to wrap, probably an image tag.
00343      * @param   string      Command for 'PM' get var
00344      * @param   boolean     If set, the link will have a anchor point (=$bMark) and a name attribute (=$bMark)
00345      * @return  string      Link-wrapped input string
00346      */
00347     function PM_ATagWrap($icon,$cmd,$bMark='')  {
00348         if ($bMark) {
00349             $anchor = '#'.$bMark;
00350             $name=' name="'.$bMark.'"';
00351         }
00352         $aOnClick = "return jumpToUrl('".$this->thisScript.'?PM='.$cmd."','".$anchor."');";
00353 
00354         return '<a href="#"'.$name.' onclick="'.htmlspecialchars($aOnClick).'">'.$icon.'</a>';
00355     }
00356 
00357     /**
00358      * Wrapping the image tag, $icon, for the row, $row
00359      *
00360      * @param   string      The image tag for the icon
00361      * @param   array       The row for the current element
00362      * @return  string      The processed icon input value.
00363      */
00364     function wrapIcon($icon, $row) {
00365         $content = $this->addTagAttributes($icon, ' title="id=' . $row['uid'] . '"');
00366         if ($this->ext_showPageId) {
00367             $content .= '[' . $row['uid'] . ']&nbsp;';
00368         }
00369         return $content;
00370     }
00371 }
00372 
00373 
00374 
00375 
00376 
00377 
00378 
00379 
00380 /**
00381  * Page tree for the RTE - totally the same, no changes needed. (Just for the sake of beauty - or confusion... :-)
00382  *
00383  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00384  * @package TYPO3
00385  * @subpackage core
00386  */
00387 class rtePageTree extends localPageTree {
00388 }
00389 
00390 
00391 
00392 
00393 
00394 
00395 
00396 
00397 /**
00398  * For TBE record browser
00399  *
00400  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00401  * @package TYPO3
00402  * @subpackage core
00403  */
00404 class TBE_PageTree extends localPageTree {
00405 
00406     /**
00407      * Returns true if a doktype can be linked (which is always the case here).
00408      *
00409      * @param   integer     Doktype value to test
00410      * @param   integer     uid to test.
00411      * @return  boolean
00412      */
00413     function ext_isLinkable($doktype,$uid)  {
00414         return true;
00415     }
00416 
00417     /**
00418      * Wrapping the title in a link, if applicable.
00419      *
00420      * @param   string      Title, ready for output.
00421      * @param   array       The record
00422      * @param   boolean     If set, pages clicked will return immediately, otherwise reload page.
00423      * @return  string      Wrapping title string.
00424      */
00425     function wrapTitle($title,$v,$ext_pArrPages)    {
00426         if ($ext_pArrPages) {
00427             $ficon=t3lib_iconWorks::getIcon('pages',$v);
00428             $onClick = "return insertElement('pages', '".$v['uid']."', 'db', ".t3lib_div::quoteJSvalue($v['title']).", '', '', '".$ficon."','',1);";
00429         } else {
00430             $onClick = htmlspecialchars('return jumpToUrl(\''.$this->thisScript.'?act='.$GLOBALS['SOBE']->browser->act.'&mode='.$GLOBALS['SOBE']->browser->mode.'&expandPage='.$v['uid'].'\');');
00431         }
00432         return '<a href="#" onclick="'.$onClick.'">'.$title.'</a>';
00433     }
00434 }
00435 
00436 
00437 
00438 
00439 
00440 
00441 
00442 
00443 /**
00444  * Base extension class which generates the folder tree.
00445  * Used directly by the RTE.
00446  *
00447  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00448  * @package TYPO3
00449  * @subpackage core
00450  */
00451 class localFolderTree extends t3lib_folderTree {
00452     var $ext_IconMode=1;
00453 
00454 
00455     /**
00456      * Initializes the script path
00457      *
00458      * @return  void
00459      */
00460     function localFolderTree() {
00461         $this->thisScript = t3lib_div::getIndpEnv('SCRIPT_NAME');
00462         $this->t3lib_folderTree();
00463     }
00464 
00465     /**
00466      * Wrapping the title in a link, if applicable.
00467      *
00468      * @param   string      Title, ready for output.
00469      * @param   array       The "record"
00470      * @return  string      Wrapping title string.
00471      */
00472     function wrapTitle($title,$v)   {
00473         if ($this->ext_isLinkable($v))  {
00474             $aOnClick = 'return jumpToUrl(\''.$this->thisScript.'?act='.$GLOBALS['SOBE']->browser->act.'&mode='.$GLOBALS['SOBE']->browser->mode.'&expandFolder='.rawurlencode($v['path']).'\');';
00475             return '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$title.'</a>';
00476         } else {
00477             return '<span class="typo3-dimmed">'.$title.'</span>';
00478         }
00479     }
00480 
00481     /**
00482      * Returns true if the input "record" contains a folder which can be linked.
00483      *
00484      * @param   array       Array with information about the folder element. Contains keys like title, uid, path, _title
00485      * @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
00486      */
00487     function ext_isLinkable($v) {
00488         $webpath=t3lib_BEfunc::getPathType_web_nonweb($v['path']);  // Checking, if the input path is a web-path.
00489         if (strstr($v['path'],'_recycler_') || strstr($v['path'],'_temp_') || $webpath!='web')  {
00490             return 0;
00491         }
00492         return 1;
00493     }
00494 
00495     /**
00496      * Wrap the plus/minus icon in a link
00497      *
00498      * @param   string      HTML string to wrap, probably an image tag.
00499      * @param   string      Command for 'PM' get var
00500      * @param   boolean     If set, the link will have a anchor point (=$bMark) and a name attribute (=$bMark)
00501      * @return  string      Link-wrapped input string
00502      * @access private
00503      */
00504     function PM_ATagWrap($icon,$cmd,$bMark='')  {
00505         if ($bMark) {
00506             $anchor = '#'.$bMark;
00507             $name=' name="'.$bMark.'"';
00508         }
00509         $aOnClick = 'return jumpToUrl(\''.$this->thisScript.'?PM='.$cmd.'\',\''.$anchor.'\');';
00510         return '<a href="#"'.$name.' onclick="'.htmlspecialchars($aOnClick).'">'.$icon.'</a>';
00511     }
00512 
00513     /**
00514      * Create the folder navigation tree in HTML
00515      *
00516      * @param   mixed       Input tree array. If not array, then $this->tree is used.
00517      * @return  string      HTML output of the tree.
00518      */
00519     function printTree($treeArr='') {
00520         global $BACK_PATH;
00521         $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
00522 
00523         if (!is_array($treeArr))    $treeArr=$this->tree;
00524 
00525         $out='';
00526         $c=0;
00527 
00528             // Preparing the current-path string (if found in the listing we will see a red blinking arrow).
00529         if (!$GLOBALS['SOBE']->browser->curUrlInfo['value'])    {
00530             $cmpPath='';
00531         } else if (substr(trim($GLOBALS['SOBE']->browser->curUrlInfo['info']),-1)!='/') {
00532             $cmpPath=PATH_site.dirname($GLOBALS['SOBE']->browser->curUrlInfo['info']).'/';
00533         } else {
00534             $cmpPath=PATH_site.$GLOBALS['SOBE']->browser->curUrlInfo['info'];
00535         }
00536 
00537             // Traverse rows for the tree and print them into table rows:
00538         foreach($treeArr as $k => $v)   {
00539             $c++;
00540             $bgColorClass=($c+1)%2 ? 'bgColor' : 'bgColor-10';
00541 
00542                 // Creating blinking arrow, if applicable:
00543             if (($GLOBALS['SOBE']->browser->curUrlInfo['act'] == 'file' || $GLOBALS['SOBE']->browser->curUrlInfo['act'] == 'folder') && $cmpPath == $v['row']['path']) {
00544                 $arrCol='<td><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/blinkarrow_right.gif','width="5" height="9"').' class="c-blinkArrowR" alt="" /></td>';
00545                 $bgColorClass='bgColor4';
00546             } else {
00547                 $arrCol='<td></td>';
00548             }
00549                 // Create arrow-bullet for file listing (if folder path is linkable):
00550             $aOnClick = 'return jumpToUrl(\''.$this->thisScript.'?act='.$GLOBALS['SOBE']->browser->act.'&mode='.$GLOBALS['SOBE']->browser->mode.'&expandFolder='.rawurlencode($v['row']['path']).'\');';
00551             $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>' : '';
00552 
00553                 // Put table row with folder together:
00554             $out.='
00555                 <tr class="'.$bgColorClass.'">
00556                     <td nowrap="nowrap">'.$v['HTML'].$this->wrapTitle(t3lib_div::fixed_lgd_cs($v['row']['title'],$titleLen),$v['row']).'</td>
00557                     '.$arrCol.'
00558                     <td>'.$cEbullet.'</td>
00559                 </tr>';
00560         }
00561 
00562         $out='
00563 
00564             <!--
00565                 Folder tree:
00566             -->
00567             <table border="0" cellpadding="0" cellspacing="0" id="typo3-tree">
00568                 '.$out.'
00569             </table>';
00570         return $out;
00571     }
00572 }
00573 
00574 
00575 
00576 
00577 
00578 
00579 /**
00580  * Folder tree for the RTE - totally the same, no changes needed. (Just for the sake of beauty - or confusion... :-)
00581  *
00582  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00583  * @package TYPO3
00584  * @subpackage core
00585  */
00586 class rteFolderTree extends localFolderTree {
00587 }
00588 
00589 
00590 
00591 
00592 
00593 
00594 
00595 /**
00596  * For TBE File Browser
00597  *
00598  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00599  * @package TYPO3
00600  * @subpackage core
00601  */
00602 class TBE_FolderTree extends localFolderTree {
00603     var $ext_noTempRecyclerDirs=0;      // If file-drag mode is set, temp and recycler folders are filtered out.
00604 
00605     /**
00606      * Returns true if the input "record" contains a folder which can be linked.
00607      *
00608      * @param   array       Array with information about the folder element. Contains keys like title, uid, path, _title
00609      * @return  boolean     True is returned if the path is NOT a recycler or temp folder AND if ->ext_noTempRecyclerDirs is not set.
00610      */
00611     function ext_isLinkable($v) {
00612         if ($this->ext_noTempRecyclerDirs && (substr($v['path'],-7)=='_temp_/' || substr($v['path'],-11)=='_recycler_/'))   {
00613             return 0;
00614         } return 1;
00615     }
00616 
00617     /**
00618      * Wrapping the title in a link, if applicable.
00619      *
00620      * @param   string      Title, ready for output.
00621      * @param   array       The 'record'
00622      * @return  string      Wrapping title string.
00623      */
00624     function wrapTitle($title,$v)   {
00625         if ($this->ext_isLinkable($v))  {
00626             $aOnClick = 'return jumpToUrl(\''.$this->thisScript.'?act='.$GLOBALS['SOBE']->browser->act.'&mode='.$GLOBALS['SOBE']->browser->mode.'&expandFolder='.rawurlencode($v['path']).'\');';
00627             return '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$title.'</a>';
00628         } else {
00629             return '<span class="typo3-dimmed">'.$title.'</span>';
00630         }
00631     }
00632 }
00633 
00634 
00635 
00636 
00637 
00638 /**
00639  * class for the Element Browser window.
00640  *
00641  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00642  * @package TYPO3
00643  * @subpackage core
00644  */
00645 class browse_links {
00646 
00647         // Internal, static:
00648     var $siteURL;           // Current site URL (Frontend)
00649     var $thisScript;        // the script to link to
00650     var $thisConfig;        // RTE specific TSconfig
00651     var $setTarget;         // Target (RTE specific)
00652     var $setClass;          // CSS Class (RTE specific)
00653     var $setTitle;              // title (RTE specific)
00654     var $doc;           // Backend template object
00655     var $elements = array();    // Holds information about files
00656 
00657         // GPvars:  (Input variables from outside)
00658     /**
00659      * The mode determines the main kind of output from the element browser.
00660      * There are these options for values: rte, db, file, filedrag, wizard.
00661      * "rte" will show the link selector for the Rich Text Editor (see main_rte())
00662      * "db" will allow you to browse for pages or records in the page tree (for TCEforms, see main_db())
00663      * "file"/"filedrag" will allow you to browse for files or folders in the folder mounts (for TCEforms, main_file())
00664      * "wizard" will allow you to browse for links (like "rte") which are passed back to TCEforms (see main_rte(1))
00665      *
00666      * @see main()
00667      */
00668     var $mode;
00669 
00670     /**
00671      * Link selector action.
00672      * page,file,url,mail,spec are allowed values.
00673      * These are only important with the link selector function and in that case they switch between the various menu options.
00674      */
00675     var $act;
00676 
00677     /**
00678      * 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")
00679      */
00680     var $expandPage;
00681 
00682     /**
00683      * 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/"
00684      */
00685     var $expandFolder;
00686 
00687 
00688 
00689     /**
00690      * TYPO3 Element Browser, wizard mode parameters. There is a heap of parameters there, better debug() them out if you need something... :-)
00691      */
00692     var $P;
00693 
00694     /**
00695      * 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.
00696      * Example value: "data[pages][39][bodytext]|||tt_content|" or "data[tt_content][NEW3fba56fde763d][image]|||gif,jpg,jpeg,tif,bmp,pcx,tga,png,pdf,ai|"
00697      *
00698      * Values:
00699      * 0: form field name reference, eg. "data[tt_content][123][image]"
00700      * 1: htlmArea RTE parameters: editorNo:contentTypo3Language:contentTypo3Charset
00701      * 2: RTE config parameters: RTEtsConfigParams
00702      * 3: allowed types. Eg. "tt_content" or "gif,jpg,jpeg,tif,bmp,pcx,tga,png,pdf,ai"
00703      * 4: IRRE uniqueness: target level object-id to perform actions/checks on, eg. "data[79][tt_address][1][<field>][<foreign_table>]"
00704      * 5: IRRE uniqueness: name of function in opener window that checks if element is already used, eg. "inline.checkUniqueElement"
00705      * 6: IRRE uniqueness: name of function in opener window that performs some additional(!) action, eg. "inline.setUniqueElement"
00706      * 7: IRRE uniqueness: name of function in opener window that performs action instead of using addElement/insertElement, eg. "inline.importElement"
00707      *
00708      * $pArr = explode('|',$this->bparams);
00709      * $formFieldName = $pArr[0];
00710      * $allowedTablesOrFileTypes = $pArr[3];
00711      */
00712     var $bparams;
00713 
00714     /**
00715      * Used with the Rich Text Editor.
00716      * Example value: "tt_content:NEW3fba58c969f5c:bodytext:23:text:23:"
00717      */
00718     var $RTEtsConfigParams;
00719 
00720 
00721 
00722 
00723     /**
00724      * Plus/Minus icon value. Used by the tree class to open/close notes on the trees.
00725      */
00726     var $PM;
00727 
00728     /**
00729      * Pointer, used when browsing a long list of records etc.
00730      */
00731     var $pointer;
00732 
00733 
00734 
00735 
00736     /**
00737      * 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.
00738      */
00739     var $curUrlArray;
00740 
00741     /**
00742      * 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.
00743      */
00744     var $curUrlInfo;
00745 
00746     /**
00747      * array which holds hook objects (initialised in init() )
00748      */
00749     protected $hookObjects = array();
00750 
00751 
00752     /**
00753      * object for t3lib_basicFileFunctions
00754      */
00755     public $fileProcessor;
00756 
00757 
00758     /**
00759      * Constructor:
00760      * Initializes a lot of variables, setting JavaScript functions in header etc.
00761      *
00762      * @return  void
00763      */
00764     function init() {
00765         global $BE_USER,$BACK_PATH;
00766 
00767             // Main GPvars:
00768         $this->pointer           = t3lib_div::_GP('pointer');
00769         $this->bparams           = t3lib_div::_GP('bparams');
00770         $this->P                 = t3lib_div::_GP('P');
00771         $this->RTEtsConfigParams = t3lib_div::_GP('RTEtsConfigParams');
00772         $this->expandPage        = t3lib_div::_GP('expandPage');
00773         $this->expandFolder      = t3lib_div::_GP('expandFolder');
00774         $this->PM                = t3lib_div::_GP('PM');
00775 
00776             // Find "mode"
00777         $this->mode = t3lib_div::_GP('mode');
00778         if (!$this->mode)   {
00779             $this->mode = 'rte';
00780         }
00781             // Creating backend template object:
00782         $this->doc = t3lib_div::makeInstance('template');
00783         $this->doc->backPath = $GLOBALS['BACK_PATH'];
00784             // Load the Prototype library and browse_links.js
00785         $this->doc->getPageRenderer()->loadPrototype();
00786         $this->doc->loadJavascriptLib('js/browse_links.js');
00787 
00788             // init hook objects:
00789         $this->hookObjects = array();
00790         if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['browseLinksHook'])) {
00791             foreach($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['browseLinksHook'] as $classData) {
00792                 $processObject = t3lib_div::getUserObj($classData);
00793 
00794                 if(!($processObject instanceof t3lib_browseLinksHook)) {
00795                     throw new UnexpectedValueException('$processObject must implement interface t3lib_browseLinksHook', 1195039394);
00796                 }
00797 
00798                 $parameters = array();
00799                 $processObject->init($this, $parameters);
00800                 $this->hookObjects[] = $processObject;
00801             }
00802         }
00803 
00804             // Site URL
00805         $this->siteURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL');   // Current site url
00806 
00807             // the script to link to
00808         $this->thisScript = t3lib_div::getIndpEnv('SCRIPT_NAME');
00809 
00810             // init fileProcessor
00811         $this->fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
00812         $this->fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
00813 
00814 
00815             // CurrentUrl - the current link url must be passed around if it exists
00816         if ($this->mode == 'wizard')    {
00817             $currentLinkParts = t3lib_div::unQuoteFilenames($this->P['currentValue'], TRUE);
00818             $initialCurUrlArray = array (
00819                 'href'   => $currentLinkParts[0],
00820                 'target' => $currentLinkParts[1],
00821                 'class'  => $currentLinkParts[2],
00822                 'title'  => $currentLinkParts[3],
00823             );
00824             $this->curUrlArray = (is_array(t3lib_div::_GP('curUrl'))) ?
00825                 array_merge($initialCurUrlArray, t3lib_div::_GP('curUrl')) :
00826                 $initialCurUrlArray;
00827             $this->curUrlInfo = $this->parseCurUrl($this->siteURL.'?id='.$this->curUrlArray['href'], $this->siteURL);
00828             if ($this->curUrlInfo['pageid'] == 0 && $this->curUrlArray['href']) { // pageid == 0 means that this is not an internal (page) link
00829                 if (file_exists(PATH_site.rawurldecode($this->curUrlArray['href'])))    { // check if this is a link to a file
00830                     if (t3lib_div::isFirstPartOfStr($this->curUrlArray['href'], PATH_site)) {
00831                         $currentLinkParts[0] = substr($this->curUrlArray['href'], strlen(PATH_site));
00832                     }
00833                     $this->curUrlInfo = $this->parseCurUrl($this->siteURL.$this->curUrlArray['href'], $this->siteURL);
00834                 } elseif (strstr($this->curUrlArray['href'], '@')) { // check for email link
00835                     if (t3lib_div::isFirstPartOfStr($this->curUrlArray['href'], 'mailto:')) {
00836                         $currentLinkParts[0] = substr($this->curUrlArray['href'], 7);
00837                     }
00838                     $this->curUrlInfo = $this->parseCurUrl('mailto:'.$this->curUrlArray['href'], $this->siteURL);
00839                 } else { // nothing of the above. this is an external link
00840                     if(strpos($this->curUrlArray['href'], '://') === false) {
00841                         $currentLinkParts[0] = 'http://' . $this->curUrlArray['href'];
00842                     }
00843                     $this->curUrlInfo = $this->parseCurUrl($currentLinkParts[0], $this->siteURL);
00844                 }
00845             } elseif (!$this->curUrlArray['href']) {
00846                 $this->curUrlInfo = array();
00847                 $this->act = 'page';
00848             } else {
00849                 $this->curUrlInfo = $this->parseCurUrl($this->siteURL.'?id='.$this->curUrlArray['href'], $this->siteURL);
00850             }
00851         } else {
00852             $this->curUrlArray = t3lib_div::_GP('curUrl');
00853             if ($this->curUrlArray['all'])  {
00854                 $this->curUrlArray=t3lib_div::get_tag_attributes($this->curUrlArray['all']);
00855             }
00856             $this->curUrlInfo=$this->parseCurUrl($this->curUrlArray['href'],$this->siteURL);
00857         }
00858 
00859             // Determine nature of current url:
00860         $this->act=t3lib_div::_GP('act');
00861         if (!$this->act)    {
00862             $this->act=$this->curUrlInfo['act'];
00863         }
00864 
00865             // Rich Text Editor specific configuration:
00866         $addPassOnParams='';
00867         if ((string)$this->mode == 'rte')   {
00868             $RTEtsConfigParts = explode(':',$this->RTEtsConfigParams);
00869             $addPassOnParams.='&RTEtsConfigParams='.rawurlencode($this->RTEtsConfigParams);
00870             $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE',t3lib_BEfunc::getPagesTSconfig($RTEtsConfigParts[5]));
00871             $this->thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup['properties'],$RTEtsConfigParts[0],$RTEtsConfigParts[2],$RTEtsConfigParts[4]);
00872         }
00873 
00874             // Initializing the target value (RTE)
00875         $this->setTarget = ($this->curUrlArray['target'] != '-') ? $this->curUrlArray['target'] : '';
00876         if ($this->thisConfig['defaultLinkTarget'] && !isset($this->curUrlArray['target'])) {
00877             $this->setTarget=$this->thisConfig['defaultLinkTarget'];
00878         }
00879 
00880             // Initializing the class value (RTE)
00881         $this->setClass = ($this->curUrlArray['class'] != '-') ? $this->curUrlArray['class'] : '';
00882 
00883             // Initializing the title value (RTE)
00884         $this->setTitle = ($this->curUrlArray['title'] != '-') ? $this->curUrlArray['title'] : '';
00885 
00886             // BEGIN accumulation of header JavaScript:
00887         $JScode = '
00888                 // This JavaScript is primarily for RTE/Link. jumpToUrl is used in the other cases as well...
00889             var add_href="'.($this->curUrlArray['href']?'&curUrl[href]='.rawurlencode($this->curUrlArray['href']):'').'";
00890             var add_target="'.($this->setTarget?'&curUrl[target]='.rawurlencode($this->setTarget):'').'";
00891             var add_class="'.($this->setClass ? '&curUrl[class]='.rawurlencode($this->setClass) : '').'";
00892             var add_title="'.($this->setTitle?'&curUrl[title]='.rawurlencode($this->setTitle):'').'";
00893             var add_params="'.($this->bparams?'&bparams='.rawurlencode($this->bparams):'').'";
00894 
00895             var cur_href="'.($this->curUrlArray['href']?$this->curUrlArray['href']:'').'";
00896             var cur_target="'.($this->setTarget?$this->setTarget:'').'";
00897             var cur_class = "'.($this->setClass ? $this->setClass : '-').'";
00898             var cur_title="'.($this->setTitle?$this->setTitle:'').'";
00899 
00900             function browse_links_setTarget(target) {   //
00901                 cur_target=target;
00902                 add_target="&curUrl[target]="+escape(target);
00903             }
00904             function browse_links_setClass(cssClass) {   //
00905                 cur_class = cssClass;
00906                 add_class = "&curUrl[class]=" + escape(cssClass);
00907             }
00908             function browse_links_setTitle(title)   {   //
00909                 cur_title=title;
00910                 add_title="&curUrl[title]="+escape(title);
00911             }
00912             function browse_links_setValue(value) { //
00913                 cur_href=value;
00914                 add_href="&curUrl[href]="+value;
00915             }
00916         ';
00917 
00918         if ($this->mode == 'wizard')    {   // Functions used, if the link selector is in wizard mode (= TCEforms fields)
00919             unset($this->P['fieldChangeFunc']['alert']);
00920             $update='';
00921             foreach ($this->P['fieldChangeFunc'] as $k => $v) {
00922                 $update.= '
00923                 window.opener.'.$v;
00924             }
00925 
00926             $P2=array();
00927             $P2['itemName']=$this->P['itemName'];
00928             $P2['formName']=$this->P['formName'];
00929             $P2['fieldChangeFunc']=$this->P['fieldChangeFunc'];
00930             $P2['params']['allowedExtensions']=$this->P['params']['allowedExtensions'];
00931             $P2['params']['blindLinkOptions']=$this->P['params']['blindLinkOptions'];
00932             $addPassOnParams.=t3lib_div::implodeArrayForUrl('P',$P2);
00933 
00934             $JScode.='
00935                 function link_typo3Page(id,anchor)  {   //
00936                     updateValueInMainForm(id + (anchor ? anchor : ""));
00937                     close();
00938                     return false;
00939                 }
00940                 function link_folder(folder)    {   //
00941                     updateValueInMainForm(folder);
00942                     close();
00943                     return false;
00944                 }
00945                 function link_current() {   //
00946                     if (cur_href!="http://" && cur_href!="mailto:") {
00947                         returnBeforeCleaned = cur_href;
00948                         if (returnBeforeCleaned.substr(0, 7) == "http://") {
00949                             returnToMainFormValue = returnBeforeCleaned.substr(7);
00950                         } else if (returnBeforeCleaned.substr(0, 7) == "mailto:") {
00951                             if (returnBeforeCleaned.substr(0, 14) == "mailto:mailto:") {
00952                                 returnToMainFormValue = returnBeforeCleaned.substr(14);
00953                             } else {
00954                                 returnToMainFormValue = returnBeforeCleaned.substr(7);
00955                             }
00956                         } else {
00957                             returnToMainFormValue = returnBeforeCleaned;
00958                         }
00959                         updateValueInMainForm(returnToMainFormValue);
00960                         close();
00961                     }
00962                     return false;
00963                 }
00964                 function checkReference()   {   //
00965                     if (window.opener && window.opener.document && window.opener.document.'.$this->P['formName'].' && window.opener.document.'.$this->P['formName'].'["'.$this->P['itemName'].'"] ) {
00966                         return window.opener.document.'.$this->P['formName'].'["'.$this->P['itemName'].'"];
00967                     } else {
00968                         close();
00969                     }
00970                 }
00971                 function updateValueInMainForm(input)   {   //
00972                     var field = checkReference();
00973                     if (field)  {
00974                         if (cur_target == "" && (cur_title != "" || cur_class != "-")) {
00975                             cur_target = "-";
00976                         }
00977                         if (cur_title == "" && cur_class == "-") {
00978                             cur_class = "";
00979                         }
00980                         cur_class = cur_class.replace(/[\'\"]/g, "");
00981                         if (cur_class.indexOf(" ") != -1) {
00982                             cur_class = "\"" + cur_class + "\"";
00983                         }
00984                         cur_title = cur_title.replace(/(^\")|(\"$)/g, "");
00985                         if (cur_title.indexOf(" ") != -1) {
00986                             cur_title = "\"" + cur_title + "\"";
00987                         }
00988                         input = input + " " + cur_target + " " + cur_class + " " + cur_title;
00989                         field.value = input;
00990                         '.$update.'
00991                     }
00992                 }
00993             ';
00994         } else {    // Functions used, if the link selector is in RTE mode:
00995             $JScode.='
00996                 function link_typo3Page(id,anchor)  {   //
00997                     var theLink = \''.$this->siteURL.'?id=\'+id+(anchor?anchor:"");
00998                     self.parent.parent.renderPopup_addLink(theLink, cur_target, cur_class, cur_title);
00999                     return false;
01000                 }
01001                 function link_folder(folder)    {   //
01002                     var theLink = \''.$this->siteURL.'\'+folder;
01003                     self.parent.parent.renderPopup_addLink(theLink, cur_target, cur_class, cur_title);
01004                     return false;
01005                 }
01006                 function link_spec(theLink) {   //
01007                     self.parent.parent.renderPopup_addLink(theLink, cur_target, cur_class, cur_title);
01008                     return false;
01009                 }
01010                 function link_current() {   //
01011                     if (cur_href!="http://" && cur_href!="mailto:") {
01012                         self.parent.parent.renderPopup_addLink(cur_href, cur_target, cur_class, cur_title);
01013                     }
01014                     return false;
01015                 }
01016             ';
01017         }
01018 
01019             // General "jumpToUrl" function:
01020         $JScode.='
01021             function jumpToUrl(URL,anchor)  {   //
01022                 var add_act = URL.indexOf("act=")==-1 ? "&act='.$this->act.'" : "";
01023                 var add_mode = URL.indexOf("mode=")==-1 ? "&mode='.$this->mode.'" : "";
01024                 var theLocation = URL + add_act + add_mode + add_href + add_target + add_class + add_title + add_params'.($addPassOnParams?'+"'.$addPassOnParams.'"':'').'+(anchor?anchor:"");
01025                 window.location.href = theLocation;
01026                 return false;
01027             }
01028         ';
01029 
01030 
01031         /**
01032          * Splits parts of $this->bparams
01033          * @see $bparams
01034          */
01035         $pArr = explode('|',$this->bparams);
01036 
01037             // This is JavaScript especially for the TBE Element Browser!
01038         $formFieldName = 'data['.$pArr[0].']['.$pArr[1].']['.$pArr[2].']';
01039 
01040             // insertElement - Call check function (e.g. for uniqueness handling):
01041         if ($pArr[4] && $pArr[5]) {
01042             $JScodeCheck = '
01043                     // Call a check function in the opener window (e.g. for uniqueness handling):
01044                 if (parent.window.opener) {
01045                     var res = parent.window.opener.'.$pArr[5].'("'.addslashes($pArr[4]).'",table,uid,type);
01046                     if (!res.passed) {
01047                         if (res.message) alert(res.message);
01048                         performAction = false;
01049                     }
01050                 } else {
01051                     alert("Error - reference to main window is not set properly!");
01052                     parent.close();
01053                 }
01054             ';
01055         }
01056             // insertElement - Call helper function:
01057         if ($pArr[4] && $pArr[6]) {
01058             $JScodeHelper = '
01059                         // Call helper function to manage data in the opener window:
01060                     if (parent.window.opener) {
01061                         parent.window.opener.'.$pArr[6].'("'.addslashes($pArr[4]).'",table,uid,type,"'.addslashes($pArr[0]).'");
01062                     } else {
01063                         alert("Error - reference to main window is not set properly!");
01064                         parent.close();
01065                     }
01066             ';
01067         }
01068             // insertElement - perform action commands:
01069         if ($pArr[4] && $pArr[7]) {
01070                 // Call user defined action function:
01071             $JScodeAction = '
01072                     if (parent.window.opener) {
01073                         parent.window.opener.'.$pArr[7].'("'.addslashes($pArr[4]).'",table,uid,type);
01074                         focusOpenerAndClose(close);
01075                     } else {
01076                         alert("Error - reference to main window is not set properly!");
01077                         parent.close();
01078                     }
01079             ';
01080         } else if ($pArr[0] && !$pArr[1] && !$pArr[2]) {
01081             $JScodeAction = '
01082                     addElement(filename,table+"_"+uid,fp,close);
01083             ';
01084         } else {
01085             $JScodeAction = '
01086                     if (setReferences()) {
01087                         parent.window.opener.group_change("add","'.$pArr[0].'","'.$pArr[1].'","'.$pArr[2].'",elRef,targetDoc);
01088                     } else {
01089                         alert("Error - reference to main window is not set properly!");
01090                     }
01091                     focusOpenerAndClose(close);
01092             ';
01093         }
01094 
01095         $JScode.='
01096             var elRef="";
01097             var targetDoc="";
01098 
01099             function launchView(url)    {   //
01100                 var thePreviewWindow="";
01101                 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");
01102                 if (thePreviewWindow && thePreviewWindow.focus) {
01103                     thePreviewWindow.focus();
01104                 }
01105             }
01106             function setReferences()    {   //
01107                 if (parent.window.opener && parent.window.opener.content && parent.window.opener.content.document.editform && parent.window.opener.content.document.editform["'.$formFieldName.'"]) {
01108                     targetDoc = parent.window.opener.content.document;
01109                     elRef = targetDoc.editform["'.$formFieldName.'"];
01110                     return true;
01111                 } else {
01112                     return false;
01113                 }
01114             }
01115             function insertElement(table, uid, type, filename,fp,filetype,imagefile,action, close)  {   //
01116                 var performAction = true;
01117                 '.$JScodeCheck.'
01118                     // Call performing function and finish this action:
01119                 if (performAction) {
01120                         '.$JScodeHelper.$JScodeAction.'
01121                 }
01122                 return false;
01123             }
01124             function addElement(elName,elValue,altElValue,close)    {   //
01125                 if (parent.window.opener && parent.window.opener.setFormValueFromBrowseWin) {
01126                     parent.window.opener.setFormValueFromBrowseWin("'.$pArr[0].'",altElValue?altElValue:elValue,elName);
01127                     focusOpenerAndClose(close);
01128                 } else {
01129                     alert("Error - reference to main window is not set properly!");
01130                     parent.close();
01131                 }
01132             }
01133             function focusOpenerAndClose(close) {   //
01134                 BrowseLinks.focusOpenerAndClose(close);
01135             }
01136         ';
01137 
01138             // Finally, add the accumulated JavaScript to the template object:
01139         $this->doc->JScode.= $this->doc->wrapScriptTags($JScode);
01140 
01141             // Debugging:
01142         if (FALSE) debug(array(
01143             'pointer' => $this->pointer,
01144             'act' => $this->act,
01145             'mode' => $this->mode,
01146             'curUrlInfo' => $this->curUrlInfo,
01147             'curUrlArray' => $this->curUrlArray,
01148             'P' => $this->P,
01149             'bparams' => $this->bparams,
01150             'RTEtsConfigParams' => $this->RTEtsConfigParams,
01151             'expandPage' => $this->expandPage,
01152             'expandFolder' => $this->expandFolder,
01153             'PM' => $this->PM,
01154         ),'Internal variables of Script Class:');
01155     }
01156 
01157 
01158     /**
01159      * Session data for this class can be set from outside with this method.
01160      * Call after init()
01161      *
01162      * @param   array       Session data array
01163      * @return  array       Session data and boolean which indicates that data needs to be stored in session because it's changed
01164      */
01165     function processSessionData($data) {
01166         $store = false;
01167 
01168         switch((string)$this->mode) {
01169             case 'db':
01170                 if (isset($this->expandPage))   {
01171                     $data['expandPage']=$this->expandPage;
01172                     $store = true;
01173                 } else {
01174                     $this->expandPage=$data['expandPage'];
01175                 }
01176             break;
01177             case 'file':
01178             case 'filedrag':
01179             case 'folder':
01180                 if (isset($this->expandFolder)) {
01181                     $data['expandFolder']=$this->expandFolder;
01182                     $store = true;
01183                 } else {
01184                     $this->expandFolder=$data['expandFolder'];
01185                 }
01186             break;
01187         }
01188 
01189         return array($data, $store);
01190     }
01191 
01192 
01193 
01194 
01195     /******************************************************************
01196      *
01197      * Main functions
01198      *
01199      ******************************************************************/
01200 
01201     /**
01202      * Rich Text Editor (RTE) link selector (MAIN function)
01203      * Generates the link selector for the Rich Text Editor.
01204      * Can also be used to select links for the TCEforms (see $wiz)
01205      *
01206      * @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
01207      * @return  string      Modified content variable.
01208      */
01209     function main_rte($wiz=0)   {
01210         global $LANG, $BACK_PATH;
01211 
01212             // Starting content:
01213         $content=$this->doc->startPage('RTE link');
01214 
01215             // Initializing the action value, possibly removing blinded values etc:
01216         $allowedItems = array_diff(
01217             explode(',','page,file,folder,url,mail,spec'),
01218             t3lib_div::trimExplode(',',$this->thisConfig['blindLinkOptions'],1)
01219         );
01220         $allowedItems = array_diff(
01221             $allowedItems,
01222             t3lib_div::trimExplode(',',$this->P['params']['blindLinkOptions'])
01223         );
01224 
01225             //call hook for extra options
01226         foreach($this->hookObjects as $hookObject) {
01227             $allowedItems = $hookObject->addAllowedItems($allowedItems);
01228         }
01229 
01230         reset($allowedItems);
01231         if (!in_array($this->act,$allowedItems))    $this->act = current($allowedItems);
01232 
01233             // Making menu in top:
01234         $menuDef = array();
01235         if (!$wiz)  {
01236             $menuDef['removeLink']['isActive'] = $this->act=='removeLink';
01237             $menuDef['removeLink']['label'] = $LANG->getLL('removeLink',1);
01238             $menuDef['removeLink']['url'] = '#';
01239             $menuDef['removeLink']['addParams'] = 'onclick="self.parent.parent.renderPopup_unLink();return false;"';
01240         }
01241         if (in_array('page',$allowedItems)) {
01242             $menuDef['page']['isActive'] = $this->act=='page';
01243             $menuDef['page']['label'] = $LANG->getLL('page',1);
01244             $menuDef['page']['url'] = '#';
01245             $menuDef['page']['addParams'] = 'onclick="jumpToUrl(\'?act=page\');return false;"';
01246         }
01247         if (in_array('file',$allowedItems)){
01248             $menuDef['file']['isActive'] = $this->act=='file';
01249             $menuDef['file']['label'] = $LANG->getLL('file',1);
01250             $menuDef['file']['url'] = '#';
01251             $menuDef['file']['addParams'] = 'onclick="jumpToUrl(\'?act=file\');return false;"';
01252         }
01253         if (in_array('folder',$allowedItems)){
01254             $menuDef['folder']['isActive']  = $this->act == 'folder';
01255             $menuDef['folder']['label']     = $LANG->getLL('folder', 1);
01256             $menuDef['folder']['url']       = '#';
01257             $menuDef['folder']['addParams'] = 'onclick="jumpToUrl(\'?act=folder\');return false;"';
01258         }
01259         if (in_array('url',$allowedItems)) {
01260             $menuDef['url']['isActive'] = $this->act=='url';
01261             $menuDef['url']['label'] = $LANG->getLL('extUrl',1);
01262             $menuDef['url']['url'] = '#';
01263             $menuDef['url']['addParams'] = 'onclick="jumpToUrl(\'?act=url\');return false;"';
01264         }
01265         if (in_array('mail',$allowedItems)) {
01266             $menuDef['mail']['isActive'] = $this->act=='mail';
01267             $menuDef['mail']['label'] = $LANG->getLL('email',1);
01268             $menuDef['mail']['url'] = '#';
01269             $menuDef['mail']['addParams'] = 'onclick="jumpToUrl(\'?act=mail\');return false;"';
01270         }
01271         if (is_array($this->thisConfig['userLinks.']) && in_array('spec',$allowedItems)) {
01272             $menuDef['spec']['isActive'] = $this->act=='spec';
01273             $menuDef['spec']['label'] = $LANG->getLL('special',1);
01274             $menuDef['spec']['url'] = '#';
01275             $menuDef['spec']['addParams'] = 'onclick="jumpToUrl(\'?act=spec\');return false;"';
01276         }
01277 
01278             // call hook for extra options
01279         foreach($this->hookObjects as $hookObject) {
01280             $menuDef = $hookObject->modifyMenuDefinition($menuDef);
01281         }
01282 
01283         $content .= $this->doc->getTabMenuRaw($menuDef);
01284 
01285             // Adding the menu and header to the top of page:
01286         $content.=$this->printCurrentUrl($this->curUrlInfo['info']).'<br />';
01287 
01288             // Depending on the current action we will create the actual module content for selecting a link:
01289         switch($this->act)  {
01290             case 'mail':
01291                 $extUrl='
01292 
01293             <!--
01294                 Enter mail address:
01295             -->
01296                     <form action="" name="lurlform" id="lurlform">
01297                         <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkMail">
01298                             <tr>
01299                                 <td style="width: 96px;">' . $GLOBALS['LANG']->getLL('emailAddress', 1) . ':</td>
01300                                 <td><input type="text" name="lemail"'.$this->doc->formWidth(20).' value="'.htmlspecialchars($this->curUrlInfo['act']=='mail'?$this->curUrlInfo['info']:'').'" /> '.
01301                                     '<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>
01302                             </tr>
01303                         </table>
01304                     </form>';
01305                 $content.=$extUrl;
01306             break;
01307             case 'url':
01308                 $extUrl='
01309 
01310             <!--
01311                 Enter External URL:
01312             -->
01313                     <form action="" name="lurlform" id="lurlform">
01314                         <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkURL">
01315                             <tr>
01316                                 <td style="width: 96px;">URL:</td>
01317                                 <td><input type="text" name="lurl"'.$this->doc->formWidth(30).' value="'.htmlspecialchars($this->curUrlInfo['act']=='url'?$this->curUrlInfo['info']:'http://').'" /> '.
01318                                     '<input type="submit" value="' . $GLOBALS['LANG']->getLL('setLink', 1) . '" onclick="browse_links_setValue(document.lurlform.lurl.value); return link_current();" /></td>
01319                             </tr>
01320                         </table>
01321                     </form>';
01322                 $content.=$extUrl;
01323             break;
01324             case 'file':
01325             case 'folder':
01326                 $foldertree             = t3lib_div::makeInstance('rteFolderTree');
01327                 $foldertree->thisScript = $this->thisScript;
01328                 $tree                   = $foldertree->getBrowsableTree();
01329 
01330                 if (!$this->curUrlInfo['value'] || $this->curUrlInfo['act'] != $this->act)  {
01331                     $cmpPath = '';
01332                 } elseif (substr(trim($this->curUrlInfo['info']), -1) != '/')   {
01333                     $cmpPath = PATH_site.dirname($this->curUrlInfo['info']).'/';
01334                     if (!isset($this->expandFolder)) {
01335                         $this->expandFolder = $cmpPath;
01336                     }
01337                 } else {
01338                     $cmpPath = PATH_site.$this->curUrlInfo['info'];
01339                     if (!isset($this->expandFolder) && $this->curUrlInfo['act'] == 'folder') {
01340                         $this->expandFolder = $cmpPath;
01341                     }
01342                 }
01343 
01344                 list(, , $specUid) = explode('_', $this->PM);
01345                 $files = $this->expandFolder(
01346                     $foldertree->specUIDmap[$specUid],
01347                     $this->P['params']['allowedExtensions']
01348                 );
01349                 $content.= '
01350 
01351             <!--
01352                 Wrapper table for folder tree / file/folder list:
01353             -->
01354                     <table border="0" cellpadding="0" cellspacing="0" id="typo3-linkFiles">
01355                         <tr>
01356                             <td class="c-wCell" valign="top">'.$this->barheader($GLOBALS['LANG']->getLL('folderTree').':').$tree.'</td>
01357                             <td class="c-wCell" valign="top">'.$files.'</td>
01358                         </tr>
01359                     </table>
01360                     ';
01361             break;
01362             case 'spec':
01363                 if (is_array($this->thisConfig['userLinks.']))  {
01364                     $subcats=array();
01365                     $v=$this->thisConfig['userLinks.'];
01366                     foreach ($v as $k2 => $value) {
01367                         $k2i = intval($k2);
01368                         if (substr($k2,-1)=='.' && is_array($v[$k2i.'.']))  {
01369 
01370                                 // Title:
01371                             $title = trim($v[$k2i]);
01372                             if (!$title)    {
01373                                 $title=$v[$k2i.'.']['url'];
01374                             } else {
01375                                 $title=$LANG->sL($title);
01376                             }
01377                                 // Description:
01378                             $description=$v[$k2i.'.']['description'] ? $LANG->sL($v[$k2i.'.']['description'],1).'<br />' : '';
01379 
01380                                 // URL + onclick event:
01381                             $onClickEvent='';
01382                             if (isset($v[$k2i.'.']['target']))  $onClickEvent.="browse_links_setTarget('".$v[$k2i.'.']['target']."');";
01383                             $v[$k2i.'.']['url'] = str_replace('###_URL###',$this->siteURL,$v[$k2i.'.']['url']);
01384                             if (substr($v[$k2i.'.']['url'],0,7)=='http://' || substr($v[$k2i.'.']['url'],0,7)=='mailto:')   {
01385                                 $onClickEvent.="cur_href=unescape('".rawurlencode($v[$k2i.'.']['url'])."');link_current();";
01386                             } else {
01387                                 $onClickEvent.="link_spec(unescape('".$this->siteURL.rawurlencode($v[$k2i.'.']['url'])."'));";
01388                             }
01389 
01390                                 // Link:
01391                             $A=array('<a href="#" onclick="'.htmlspecialchars($onClickEvent).'return false;">','</a>');
01392 
01393                                 // Adding link to menu of user defined links:
01394                             $subcats[$k2i]='
01395                                 <tr>
01396                                     <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>
01397                                 </tr>';
01398                         }
01399                     }
01400 
01401                         // Sort by keys:
01402                     ksort($subcats);
01403 
01404                         // Add menu to content:
01405                     $content.= '
01406 
01407             <!--
01408                 Special userdefined menu:
01409             -->
01410                         <table border="0" cellpadding="1" cellspacing="1" id="typo3-linkSpecial">
01411                             <tr>
01412                                 <td class="bgColor5" class="c-wCell" valign="top"><strong>'.$LANG->getLL('special',1).'</strong></td>
01413                             </tr>
01414                             '.implode('',$subcats).'
01415                         </table>
01416                         ';
01417                 }
01418             break;
01419             case 'page':
01420                 $pagetree = t3lib_div::makeInstance('rtePageTree');
01421                 $pagetree->thisScript = $this->thisScript;
01422                 $pagetree->ext_showPageId = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showPageIdWithTitle');
01423                 $tree=$pagetree->getBrowsableTree();
01424                 $cElements = $this->expandPage();
01425 
01426                 // Outputting Temporary DB mount notice:
01427                 if (intval($GLOBALS['BE_USER']->getSessionData('pageTree_temporaryMountPoint')))    {
01428                     $link = '<a href="' . htmlspecialchars(t3lib_div::linkThisScript(array('setTempDBmount' => 0))) . '">' .
01429                                         $LANG->sl('LLL:EXT:lang/locallang_core.xml:labels.temporaryDBmount', 1) .
01430                                     '</a>';
01431                     $flashMessage = t3lib_div::makeInstance(
01432                         't3lib_FlashMessage',
01433                         $link,
01434                         '',
01435                         t3lib_FlashMessage::INFO
01436                     );
01437                     $dbmount = $flashMessage->render();
01438                 }
01439 
01440                 $content.= '
01441 
01442             <!--
01443                 Wrapper table for page tree / record list:
01444             -->
01445                     <table border="0" cellpadding="0" cellspacing="0" id="typo3-linkPages">
01446                         <tr>
01447                             <td class="c-wCell" valign="top">' . $this->barheader($GLOBALS['LANG']->getLL('pageTree') . ':') . $dbmount . $tree . '</td>
01448                             <td class="c-wCell" valign="top">'.$cElements.'</td>
01449                         </tr>
01450                     </table>
01451                     ';
01452             break;
01453             default:
01454                     //call hook
01455                 foreach($this->hookObjects as $hookObject) {
01456                     $content .= $hookObject->getTab($this->act);
01457                 }
01458             break;
01459         }
01460 
01461         $content .= '
01462 
01463             <!--
01464                 Selecting class for link:
01465             -->
01466                 <form action="" name="lclassform" id="lclassform">
01467                     <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkClass">
01468                         <tr>
01469                             <td style="width: 96px;">' . $GLOBALS['LANG']->getLL('class', 1) . '</td>
01470                             <td><input type="text" name="lclass" onchange="browse_links_setClass(this.value);" value="' . htmlspecialchars($this->setClass) . '"' . $this->doc->formWidth(10) . ' /></td>
01471                         </tr>
01472                     </table>
01473                 </form>
01474 
01475             <!--
01476                 Selecting title for link:
01477             -->
01478                 <form action="" name="ltitleform" id="ltitleform">
01479                     <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkTitle">
01480                         <tr>
01481                             <td style="width: 96px;">' . $GLOBALS['LANG']->getLL('title', 1) . '</td>
01482                             <td><input type="text" name="ltitle" onchange="browse_links_setTitle(this.value);" value="' . htmlspecialchars($this->setTitle) . '"' . $this->doc->formWidth(10) . ' /></td>
01483                         </tr>
01484                     </table>
01485                 </form>
01486 ';
01487 
01488             // Target:
01489         if ($this->act!='mail') {
01490             $ltarget='
01491 
01492 
01493 
01494             <!--
01495                 Selecting target for link:
01496             -->
01497                 <form action="" name="ltargetform" id="ltargetform">
01498                     <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkTarget">
01499                         <tr>
01500                             <td>'.$GLOBALS['LANG']->getLL('target',1).':</td>
01501                             <td><input type="text" name="ltarget" onchange="browse_links_setTarget(this.value);" value="' . htmlspecialchars($this->setTarget) . '"' . $this->doc->formWidth(10) . ' /></td>
01502                             <td>
01503                                 <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;">
01504                                     <option></option>
01505                                     <option value="_top">'.$GLOBALS['LANG']->getLL('top',1).'</option>
01506                                     <option value="_blank">'.$GLOBALS['LANG']->getLL('newWindow',1).'</option>
01507                                 </select>
01508                             </td>
01509                             <td>';
01510             if (($this->curUrlInfo['act'] == 'page' || $this->curUrlInfo['act'] == 'file' || $this->curUrlInfo['act'] == 'folder') && $this->curUrlArray['href'] && $this->curUrlInfo['act'] == $this->act) {
01511                 $ltarget.='
01512                             <input type="submit" value="'.$GLOBALS['LANG']->getLL('update',1).'" onclick="return link_current();" />';
01513             }
01514 
01515             $selectJS = '
01516                 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) {
01517                     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;
01518                     browse_links_setTarget(document.ltargetform.ltarget.value);
01519                     browse_links_setClass(document.lclassform.lclass.value);
01520                     browse_links_setTitle(document.ltitleform.ltitle.value);
01521                     document.ltargetform.popup_width.selectedIndex=0;
01522                     document.ltargetform.popup_height.selectedIndex=0;
01523                 }
01524             ';
01525 
01526             $ltarget.='     </td>
01527                         </tr>
01528                         <tr>
01529                             <td>'.$GLOBALS['LANG']->getLL('target_popUpWindow',1).':</td>
01530                             <td colspan="3">
01531                                 <select name="popup_width" onchange="'.htmlspecialchars($selectJS).'">
01532                                     <option value="0">'.$GLOBALS['LANG']->getLL('target_popUpWindow_width',1).'</option>
01533                                     <option value="300">300</option>
01534                                     <option value="400">400</option>
01535                                     <option value="500">500</option>
01536                                     <option value="600">600</option>
01537                                     <option value="700">700</option>
01538                                     <option value="800">800</option>
01539                                 </select>
01540                                 x
01541                                 <select name="popup_height" onchange="'.htmlspecialchars($selectJS).'">
01542                                     <option value="0">'.$GLOBALS['LANG']->getLL('target_popUpWindow_height',1).'</option>
01543                                     <option value="200">200</option>
01544                                     <option value="300">300</option>
01545                                     <option value="400">400</option>
01546                                     <option value="500">500</option>
01547                                     <option value="600">600</option>
01548                                 </select>
01549                             </td>
01550                         </tr>
01551                     </table>
01552                 </form>';
01553 
01554                 // Add "target selector" box to content:
01555             $content.=$ltarget;
01556 
01557                 // Add some space
01558             $content.='<br /><br />';
01559         }
01560 
01561             // End page, return content:
01562         $content.= $this->doc->endPage();
01563         $content = $this->doc->insertStylesAndJS($content);
01564         return $content;
01565     }
01566 
01567     /**
01568      * TYPO3 Element Browser: Showing a page tree and allows you to browse for records
01569      *
01570      * @return  string      HTML content for the module
01571      */
01572     function main_db()  {
01573 
01574             // Starting content:
01575         $content=$this->doc->startPage('TBE record selector');
01576 
01577             // Init variable:
01578         $pArr = explode('|',$this->bparams);
01579 
01580             // Making the browsable pagetree:
01581         $pagetree = t3lib_div::makeInstance('TBE_PageTree');
01582         $pagetree->thisScript=$this->thisScript;
01583         $pagetree->ext_pArrPages = !strcmp($pArr[3],'pages')?1:0;
01584         $pagetree->ext_showNavTitle = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showNavTitle');
01585         $pagetree->ext_showPageId = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showPageIdWithTitle');
01586         $pagetree->addField('nav_title');
01587         $tree=$pagetree->getBrowsableTree();
01588 
01589             // Making the list of elements, if applicable:
01590         $cElements = $this->TBE_expandPage($pArr[3]);
01591 
01592             // Putting the things together, side by side:
01593         $content.= '
01594 
01595             <!--
01596                 Wrapper table for page tree / record list:
01597             -->
01598             <table border="0" cellpadding="0" cellspacing="0" id="typo3-EBrecords">
01599                 <tr>
01600                     <td class="c-wCell" valign="top">'.$this->barheader($GLOBALS['LANG']->getLL('pageTree').':').$tree.'</td>
01601                     <td class="c-wCell" valign="top">'.$cElements.'</td>
01602                 </tr>
01603             </table>
01604             ';
01605 
01606             // Add some space
01607         $content.='<br /><br />';
01608 
01609             // End page, return content:
01610         $content.= $this->doc->endPage();
01611         $content = $this->doc->insertStylesAndJS($content);
01612         return $content;
01613     }
01614 
01615     /**
01616      * TYPO3 Element Browser: Showing a folder tree, allowing you to browse for files.
01617      *
01618      * @return  string      HTML content for the module
01619      */
01620     function main_file()    {
01621         global $BE_USER;
01622 
01623             // Starting content:
01624         $content.=$this->doc->startPage('TBE file selector');
01625 
01626             // Init variable:
01627         $pArr = explode('|',$this->bparams);
01628 
01629             // Create upload/create folder forms, if a path is given:
01630         $path=$this->expandFolder;
01631         if (!$path || !@is_dir($path))  {
01632                 // The closest TEMP-path is found
01633             $path = $this->fileProcessor->findTempFolder().'/';
01634         }
01635         if ($path!='/' && @is_dir($path)) {
01636             $uploadForm=$this->uploadForm($path);
01637             $createFolder=$this->createFolder($path);
01638         } else {
01639             $createFolder='';
01640             $uploadForm='';
01641         }
01642         if ($BE_USER->getTSConfigVal('options.uploadFieldsInTopOfEB'))  $content.=$uploadForm;
01643 
01644             // Getting flag for showing/not showing thumbnails:
01645         $noThumbs = $GLOBALS['BE_USER']->getTSConfigVal('options.noThumbsInEB');
01646 
01647         if (!$noThumbs) {
01648                 // MENU-ITEMS, fetching the setting for thumbnails from File>List module:
01649             $_MOD_MENU = array('displayThumbs' => '');
01650             $_MCONF['name']='file_list';
01651             $_MOD_SETTINGS = t3lib_BEfunc::getModuleData($_MOD_MENU, t3lib_div::_GP('SET'), $_MCONF['name']);
01652             $addParams = '&act='.$this->act.'&mode='.$this->mode.'&expandFolder='.rawurlencode($path).'&bparams='.rawurlencode($this->bparams);
01653             $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>';
01654         } else {
01655             $thumbNailCheck='';
01656         }
01657         $noThumbs = $noThumbs ? $noThumbs : !$_MOD_SETTINGS['displayThumbs'];
01658 
01659             // Create folder tree:
01660         $foldertree = t3lib_div::makeInstance('TBE_FolderTree');
01661         $foldertree->thisScript=$this->thisScript;
01662         $foldertree->ext_noTempRecyclerDirs = ($this->mode == 'filedrag');
01663         $tree=$foldertree->getBrowsableTree();
01664 
01665         list(,,$specUid) = explode('_',$this->PM);
01666 
01667         if ($this->mode=='filedrag')    {
01668             $files = $this->TBE_dragNDrop($foldertree->specUIDmap[$specUid],$pArr[3]);
01669         } else {
01670             $files = $this->TBE_expandFolder($foldertree->specUIDmap[$specUid],$pArr[3],$noThumbs);
01671         }
01672 
01673             // Putting the parts together, side by side:
01674         $content.= '
01675 
01676             <!--
01677                 Wrapper table for folder tree / file list:
01678             -->
01679             <table border="0" cellpadding="0" cellspacing="0" id="typo3-EBfiles">
01680                 <tr>
01681                     <td class="c-wCell" valign="top">'.$this->barheader($GLOBALS['LANG']->getLL('folderTree').':').$tree.'</td>
01682                     <td class="c-wCell" valign="top">'.$files.'</td>
01683                 </tr>
01684             </table>
01685             ';
01686         $content.= $thumbNailCheck;
01687 
01688             // Adding create folder + upload forms if applicable:
01689         if (!$BE_USER->getTSConfigVal('options.uploadFieldsInTopOfEB')) $content.=$uploadForm;
01690         if ($BE_USER->isAdmin() || $BE_USER->getTSConfigVal('options.createFoldersInEB'))   $content.=$createFolder;
01691 
01692             // Add some space
01693         $content.='<br /><br />';
01694 
01695             // Setup indexed elements:
01696         $this->doc->JScode.= $this->doc->wrapScriptTags('BrowseLinks.addElements(' . json_encode($this->elements) . ');');
01697             // Ending page, returning content:
01698         $content.= $this->doc->endPage();
01699         $content = $this->doc->insertStylesAndJS($content);
01700 
01701         return $content;
01702     }
01703 
01704     /**
01705      * TYPO3 Element Browser: Showing a folder tree, allowing you to browse for folders.
01706      *
01707      * @return  string      HTML content for the module
01708      */
01709     function main_folder() {
01710         global $BE_USER;
01711 
01712             // Starting content:
01713         $content = $this->doc->startPage('TBE folder selector');
01714 
01715             // Init variable:
01716         $parameters = explode('|', $this->bparams);
01717 
01718 
01719         $path = $this->expandFolder;
01720         if (!$path || !@is_dir($path)) {
01721                 // The closest TEMP-path is found
01722             $path = $this->fileProcessor->findTempFolder().'/';
01723         }
01724         if ($path != '/' && @is_dir($path)) {
01725             $createFolder = $this->createFolder($path);
01726         } else {
01727             $createFolder='';
01728         }
01729 
01730             // Create folder tree:
01731         $foldertree                         = t3lib_div::makeInstance('TBE_FolderTree');
01732         $foldertree->thisScript             = $this->thisScript;
01733         $foldertree->ext_noTempRecyclerDirs = ($this->mode == 'filedrag');
01734         $tree                                = $foldertree->getBrowsableTree(false);
01735 
01736         list(, , $specUid) = explode('_', $this->PM);
01737 
01738         if($this->mode == 'filedrag') {
01739             $folders = $this->TBE_dragNDrop(
01740                 $foldertree->specUIDmap[$specUid],
01741                 $parameters[3]
01742             );
01743         } else {
01744             $folders = $this->TBE_expandSubFolders($foldertree->specUIDmap[$specUid]);
01745         }
01746 
01747             // Putting the parts together, side by side:
01748         $content.= '
01749 
01750             <!--
01751                 Wrapper table for folder tree / folder list:
01752             -->
01753             <table border="0" cellpadding="0" cellspacing="0" id="typo3-EBfiles">
01754                 <tr>
01755                     <td class="c-wCell" valign="top">'.$this->barheader($GLOBALS['LANG']->getLL('folderTree').':').$tree.'</td>
01756                     <td class="c-wCell" valign="top">'.$folders.'</td>
01757                 </tr>
01758             </table>
01759             ';
01760 
01761             // Adding create folder if applicable:
01762         if($BE_USER->isAdmin() || $BE_USER->getTSConfigVal('options.createFoldersInEB')) {
01763             $content .= $createFolder;
01764         }
01765 
01766             // Add some space
01767         $content .= '<br /><br />';
01768 
01769             // Ending page, returning content:
01770         $content.= $this->doc->endPage();
01771         $content = $this->doc->insertStylesAndJS($content);
01772 
01773         return $content;
01774     }
01775 
01776 
01777 
01778 
01779 
01780 
01781 
01782 
01783 
01784 
01785 
01786 
01787 
01788 
01789 
01790 
01791 
01792     /******************************************************************
01793      *
01794      * Record listing
01795      *
01796      ******************************************************************/
01797     /**
01798      * For RTE: This displays all content elements on a page and lets you create a link to the element.
01799      *
01800      * @return  string      HTML output. Returns content only if the ->expandPage value is set (pointing to a page uid to show tt_content records from ...)
01801      */
01802     function expandPage()   {
01803         global $BE_USER, $BACK_PATH;
01804 
01805         $out='';
01806         $expPageId = $this->expandPage;     // Set page id (if any) to expand
01807 
01808             // If there is an anchor value (content element reference) in the element reference, then force an ID to expand:
01809         if (!$this->expandPage && $this->curUrlInfo['cElement'])    {
01810             $expPageId = $this->curUrlInfo['pageid'];   // Set to the current link page id.
01811         }
01812 
01813             // Draw the record list IF there is a page id to expand:
01814         if ($expPageId && t3lib_div::testInt($expPageId) && $BE_USER->isInWebMount($expPageId)) {
01815 
01816                 // Set header:
01817             $out.=$this->barheader($GLOBALS['LANG']->getLL('contentElements').':');
01818 
01819                 // Create header for listing, showing the page title/icon:
01820             $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
01821             $mainPageRec = t3lib_BEfunc::getRecordWSOL('pages',$expPageId);
01822             $picon = t3lib_iconWorks::getSpriteIconForRecord('pages', $mainPageRec);
01823             $picon.= htmlspecialchars(t3lib_div::fixed_lgd_cs($mainPageRec['title'],$titleLen));
01824             $out.=$picon.'<br />';
01825 
01826                 // Look up tt_content elements from the expanded page:
01827             $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
01828                             'uid,header,hidden,starttime,endtime,fe_group,CType,colpos,bodytext',
01829                             'tt_content',
01830                             'pid='.intval($expPageId).
01831                                 t3lib_BEfunc::deleteClause('tt_content').
01832                                 t3lib_BEfunc::versioningPlaceholderClause('tt_content'),
01833                             '',
01834                             'colpos,sorting'
01835                         );
01836             $cc = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
01837 
01838                 // Traverse list of records:
01839             $c=0;
01840             while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))   {
01841                 $c++;
01842                 $icon = t3lib_iconWorks::getSpriteIconForRecord('tt_content', $row);
01843                 if ($this->curUrlInfo['act']=='page' && $this->curUrlInfo['cElement']==$row['uid']) {
01844                     $arrCol='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/blinkarrow_left.gif','width="5" height="9"').' class="c-blinkArrowL" alt="" />';
01845                 } else {
01846                     $arrCol='';
01847                 }
01848                     // Putting list element HTML together:
01849                 $out.='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/join'.($c==$cc?'bottom':'').'.gif','width="18" height="16"').' alt="" />'.
01850                         $arrCol.
01851                         '<a href="#" onclick="return link_typo3Page(\''.$expPageId.'\',\'#'.$row['uid'].'\');">'.
01852                         $icon.
01853                         htmlspecialchars(t3lib_div::fixed_lgd_cs($row['header'],$titleLen)).
01854                         '</a><br />';
01855 
01856                     // Finding internal anchor points:
01857                 if (t3lib_div::inList('text,textpic', $row['CType']))   {
01858                     $split = preg_split('/(<a[^>]+name=[\'"]?([^"\'>[:space:]]+)[\'"]?[^>]*>)/i', $row['bodytext'], -1, PREG_SPLIT_DELIM_CAPTURE);
01859 
01860                     foreach($split as $skey => $sval)   {
01861                         if (($skey%3)==2)   {
01862                                 // Putting list element HTML together:
01863                             $sval = substr($sval,0,100);
01864                             $out.='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/line.gif','width="18" height="16"').' alt="" />'.
01865                                     '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/join'.($skey+3>count($split)?'bottom':'').'.gif','width="18" height="16"').' alt="" />'.
01866                                     '<a href="#" onclick="return link_typo3Page(\''.$expPageId.'\',\'#'.rawurlencode($sval).'\');">'.
01867                                     htmlspecialchars(' <A> '.$sval).
01868                                     '</a><br />';
01869                         }
01870                     }
01871                 }
01872             }
01873         }
01874         return $out;
01875     }
01876 
01877     /**
01878      * For TYPO3 Element Browser: This lists all content elements from the given list of tables
01879      *
01880      * @param   string      Commalist of tables. Set to "*" if you want all tables.
01881      * @return  string      HTML output.
01882      */
01883     function TBE_expandPage($tables)    {
01884         global $TCA,$BE_USER, $BACK_PATH;
01885 
01886         $out='';
01887         if ($this->expandPage>=0 && t3lib_div::testInt($this->expandPage) && $BE_USER->isInWebMount($this->expandPage)) {
01888 
01889                 // Set array with table names to list:
01890             if (!strcmp(trim($tables),'*')) {
01891                 $tablesArr = array_keys($TCA);
01892             } else {
01893                 $tablesArr = t3lib_div::trimExplode(',',$tables,1);
01894             }
01895             reset($tablesArr);
01896 
01897                 // Headline for selecting records:
01898             $out.=$this->barheader($GLOBALS['LANG']->getLL('selectRecords').':');
01899 
01900                 // Create the header, showing the current page for which the listing is. Includes link to the page itself, if pages are amount allowed tables.
01901             $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
01902             $mainPageRec = t3lib_BEfunc::getRecordWSOL('pages',$this->expandPage);
01903             $ATag='';
01904             $ATag_e='';
01905             $ATag2='';
01906             if (in_array('pages',$tablesArr))   {
01907                 $ficon=t3lib_iconWorks::getIcon('pages',$mainPageRec);
01908                 $ATag="<a href=\"#\" onclick=\"return insertElement('pages', '".$mainPageRec['uid']."', 'db', ".t3lib_div::quoteJSvalue($mainPageRec['title']).", '', '', '".$ficon."','',1);\">";
01909                 $ATag2="<a href=\"#\" onclick=\"return insertElement('pages', '".$mainPageRec['uid']."', 'db', ".t3lib_div::quoteJSvalue($mainPageRec['title']).", '', '', '".$ficon."','',0);\">";
01910                 $ATag_alt=substr($ATag,0,-4).",'',1);\">";
01911                 $ATag_e='</a>';
01912             }
01913             $picon=t3lib_iconWorks::getSpriteIconForRecord('pages', $mainPageRec);
01914             $pBicon=$ATag2?'<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/plusbullet2.gif','width="18" height="16"').' alt="" />':'';
01915             $pText=htmlspecialchars(t3lib_div::fixed_lgd_cs($mainPageRec['title'],$titleLen));
01916             $out.=$picon.$ATag2.$pBicon.$ATag_e.$ATag.$pText.$ATag_e.'<br />';
01917 
01918                 // Initialize the record listing:
01919             $id = $this->expandPage;
01920             $pointer = t3lib_div::intInRange($this->pointer,0,100000);
01921             $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
01922             $pageinfo = t3lib_BEfunc::readPageAccess($id,$perms_clause);
01923             $table='';
01924 
01925                 // Generate the record list:
01926             $dblist = t3lib_div::makeInstance('TBE_browser_recordList');
01927             $dblist->thisScript=$this->thisScript;
01928             $dblist->backPath = $GLOBALS['BACK_PATH'];
01929             $dblist->thumbs = 0;
01930             $dblist->calcPerms = $GLOBALS['BE_USER']->calcPerms($pageinfo);
01931             $dblist->noControlPanels=1;
01932             $dblist->clickMenuEnabled=0;
01933             $dblist->tableList=implode(',',$tablesArr);
01934 
01935             $dblist->start($id,t3lib_div::_GP('table'),$pointer,
01936                 t3lib_div::_GP('search_field'),
01937                 t3lib_div::_GP('search_levels'),
01938                 t3lib_div::_GP('showLimit')
01939             );
01940             $dblist->setDispFields();
01941             $dblist->generateList();
01942             $dblist->writeBottom();
01943 
01944                 //  Add the HTML for the record list to output variable:
01945             $out.=$dblist->HTMLcode;
01946 
01947                 // Add support for fieldselectbox in singleTableMode
01948             if ($dblist->table) {
01949                 $out.= $dblist->fieldSelectBox($dblist->table);
01950             }
01951 
01952             $out.=$dblist->getSearchBox();
01953         }
01954 
01955             // Return accumulated content:
01956         return $out;
01957     }
01958 
01959 
01960     /**
01961      * Render list of folders inside a folder.
01962      *
01963      * @param   string      string of the current folder
01964      * @return  string      HTML output
01965      */
01966     function TBE_expandSubFolders($expandFolder=0) {
01967         $content = '';
01968 
01969         $expandFolder = $expandFolder ?
01970             $expandFolder :
01971             $this->expandFolder;
01972 
01973         if($expandFolder && $this->checkFolder($expandFolder)) {
01974             if(t3lib_div::isFirstPartOfStr($expandFolder, PATH_site)) {
01975                 $rootFolder = substr($expandFolder, strlen(PATH_site));
01976             }
01977 
01978             $folders = array();
01979 
01980                 // Listing the folders:
01981             $folders = t3lib_div::get_dirs($expandFolder);
01982             if(count($folders) > 0) {
01983                 foreach($folders as $index => $folder) {
01984                     $folders[$index] = $rootFolder.$folder.'/';
01985                 }
01986             }
01987             $content.= $this->folderList($rootFolder, $folders);
01988         }
01989 
01990             // Return accumulated content for folderlisting:
01991         return $content;
01992     }
01993 
01994 
01995 
01996 
01997 
01998 
01999 
02000 
02001 
02002 
02003 
02004     /******************************************************************
02005      *
02006      * File listing
02007      *
02008      ******************************************************************/
02009     /**
02010      * For RTE: This displays all files from folder. No thumbnails shown
02011      *
02012      * @param   string      The folder path to expand
02013      * @param   string      List of fileextensions to show
02014      * @return  string      HTML output
02015      */
02016     function expandFolder($expandFolder=0,$extensionList='')    {
02017         global $BACK_PATH;
02018 
02019         $expandFolder = $expandFolder ? $expandFolder : $this->expandFolder;
02020         $out='';
02021         if ($expandFolder && $this->checkFolder($expandFolder)) {
02022 
02023                 // Create header for filelisting:
02024             $out.=$this->barheader($GLOBALS['LANG']->getLL('files').':');
02025 
02026                 // Prepare current path value for comparison (showing red arrow)
02027             if (!$this->curUrlInfo['value'])    {
02028                 $cmpPath='';
02029             } else {
02030                 $cmpPath=PATH_site.$this->curUrlInfo['info'];
02031             }
02032 
02033 
02034                 // Create header element; The folder from which files are listed.
02035             $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
02036             $picon='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/i/_icon_webfolders.gif','width="18" height="16"').' alt="" />';
02037             $picon.=htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($expandFolder),$titleLen));
02038             $picon='<a href="#" onclick="return link_folder(\''.t3lib_div::rawUrlEncodeFP(substr($expandFolder,strlen(PATH_site))).'\');">'.$picon.'</a>';
02039             if ($this->curUrlInfo['act'] == 'folder' && $cmpPath == $expandFolder)  {
02040                 $out.= '<img'.t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/blinkarrow_left.gif', 'width="5" height="9"') . ' class="c-blinkArrowL" alt="" />';
02041             }
02042             $out.=$picon.'<br />';
02043 
02044                 // Get files from the folder:
02045             if ($this->mode == 'wizard' && $this->act == 'folder') {
02046                 $files = t3lib_div::get_dirs($expandFolder);
02047             } else {
02048                 $files = t3lib_div::getFilesInDir($expandFolder, $extensionList, 1, 1); // $extensionList='', $prependPath=0, $order='')
02049             }
02050 
02051             $c=0;
02052             $cc=count($files);
02053             if (is_array($files))   {
02054                 foreach($files as $filepath)    {
02055                     $c++;
02056                     $fI=pathinfo($filepath);
02057 
02058                     if ($this->mode == 'wizard' && $this->act == 'folder') {
02059                         $filepath = $expandFolder.$filepath.'/';
02060                         $icon = '<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/i/_icon_webfolders.gif', 'width="18" height="16"') . ' alt="" />';
02061                     } else {
02062                             // File icon:
02063                         $icon = t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
02064 
02065                             // Get size and icon:
02066                         $size = ' (' . t3lib_div::formatSize(filesize($filepath)) . 'bytes)';
02067                         $icon = '<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/fileicons/' . $icon . '', 'width="18" height="16"') . ' title="' . htmlspecialchars($fI['basename'] . $size) . '" alt="" />';
02068                     }
02069 
02070                         // If the listed file turns out to be the CURRENT file, then show blinking arrow:
02071                     if (($this->curUrlInfo['act'] == 'file' || $this->curUrlInfo['act'] == 'folder') && $cmpPath == $filepath) {
02072                         $arrCol='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/blinkarrow_left.gif','width="5" height="9"').' class="c-blinkArrowL" alt="" />';
02073                     } else {
02074                         $arrCol='';
02075                     }
02076 
02077                         // Put it all together for the file element:
02078                     $out.='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/join'.($c==$cc?'bottom':'').'.gif','width="18" height="16"').' alt="" />'.
02079                             $arrCol.
02080                             '<a href="#" onclick="return link_folder(\''.t3lib_div::rawUrlEncodeFP(substr($filepath,strlen(PATH_site))).'\');">'.
02081                             $icon.
02082                             htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($filepath),$titleLen)).
02083                             '</a><br />';
02084                 }
02085             }
02086         }
02087         return $out;
02088     }
02089 
02090     /**
02091      * For TYPO3 Element Browser: Expand folder of files.
02092      *
02093      * @param   string      The folder path to expand
02094      * @param   string      List of fileextensions to show
02095      * @param   boolean     Whether to show thumbnails or not. If set, no thumbnails are shown.
02096      * @return  string      HTML output
02097      */
02098     function TBE_expandFolder($expandFolder=0,$extensionList='',$noThumbs=0)    {
02099         global $LANG;
02100 
02101         $extensionList = ($extensionList == '*') ? '' : $extensionList;
02102         $expandFolder = $expandFolder ? $expandFolder : $this->expandFolder;
02103         $out='';
02104         if ($expandFolder && $this->checkFolder($expandFolder)) {
02105                 // Listing the files:
02106             $files = t3lib_div::getFilesInDir($expandFolder,$extensionList,1,1);    // $extensionList="",$prependPath=0,$order='')
02107             $out.= $this->fileList($files, $expandFolder, $noThumbs);
02108         }
02109 
02110             // Return accumulated content for filelisting:
02111         return $out;
02112     }
02113 
02114     /**
02115      * Render list of files.
02116      *
02117      * @param   array       List of files. See t3lib_div::getFilesInDir
02118      * @param   string      If set a header with a folder icon and folder name are shown
02119      * @param   boolean     Whether to show thumbnails or not. If set, no thumbnails are shown.
02120      * @return  string      HTML output
02121      */
02122     function fileList($files, $folderName='', $noThumbs=0) {
02123         global $LANG, $BACK_PATH;
02124 
02125         $out='';
02126 
02127             // Listing the files:
02128         if (is_array($files))   {
02129 
02130                 // Create headline (showing number of files):
02131             $filesCount = count($files);
02132             $out.=$this->barheader(sprintf($GLOBALS['LANG']->getLL('files').' (%s):', $filesCount));
02133             $out.=$this->getBulkSelector($filesCount);
02134 
02135             $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
02136 
02137                 // Create the header of current folder:
02138             if($folderName) {
02139                 $picon='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/i/_icon_webfolders.gif','width="18" height="16"').' alt="" />';
02140                 $picon.=htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($folderName),$titleLen));
02141                 $out.=$picon.'<br />';
02142             }
02143 
02144                 // Init graphic object for reading file dimensions:
02145             $imgObj = t3lib_div::makeInstance('t3lib_stdGraphic');
02146             $imgObj->init();
02147             $imgObj->mayScaleUp=0;
02148             $imgObj->tempPath=PATH_site.$imgObj->tempPath;
02149 
02150                 // Traverse the file list:
02151             $lines=array();
02152             foreach($files as $filepath)    {
02153                 $fI=pathinfo($filepath);
02154 
02155                     // Thumbnail/size generation:
02156                 if (t3lib_div::inList(strtolower($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']),strtolower($fI['extension'])) && !$noThumbs)  {
02157                     $imgInfo = $imgObj->getImageDimensions($filepath);
02158                     $pDim = $imgInfo[0].'x'.$imgInfo[1].' pixels';
02159                     $clickIcon = t3lib_BEfunc::getThumbNail($BACK_PATH.'thumbs.php',$filepath,'hspace="5" vspace="5" border="1"');
02160                 } else {
02161                     $clickIcon = '';
02162                     $pDim = '';
02163                 }
02164 
02165                     // Create file icon:
02166                 $ficon = t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
02167                 $size=' ('.t3lib_div::formatSize(filesize($filepath)).'bytes'.($pDim?', '.$pDim:'').')';
02168                 $icon = '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/fileicons/'.$ficon,'width="18" height="16"').' title="'.htmlspecialchars($fI['basename'].$size).'" class="absmiddle" alt="" />';
02169 
02170                     // Create links for adding the file:
02171                 if (strstr($filepath,',') || strstr($filepath,'|')) {   // In case an invalid character is in the filepath, display error message:
02172                     $eMsg = $LANG->JScharCode(sprintf($LANG->getLL('invalidChar'),', |'));
02173                     $ATag = $ATag_alt = "<a href=\"#\" onclick=\"alert(".$eMsg.");return false;\">";
02174                     $bulkCheckBox = '';
02175                 } else {    // If filename is OK, just add it:
02176                     $filesIndex = count($this->elements);
02177                     $this->elements['file_'.$filesIndex] = array(
02178                         'md5' => t3lib_div::shortMD5($filepath),
02179                         'type' => 'file',
02180                         'fileName' => $fI['basename'],
02181                         'filePath' => $filepath,
02182                         'fileExt' => $fI['extension'],
02183                         'fileIcon' => $ficon,
02184                     );
02185                     $ATag = "<a href=\"#\" onclick=\"return BrowseLinks.File.insertElement('file_$filesIndex');\">";
02186                     $ATag_alt = substr($ATag,0,-4).",1);\">";
02187                     $bulkCheckBox = '<input type="checkbox" class="typo3-bulk-item" name="file_'.$filesIndex.'" value="0" /> ';
02188                 }
02189                 $ATag_e='</a>';
02190 
02191                     // Create link to showing details about the file in a window:
02192                 $Ahref = $BACK_PATH.'show_item.php?table='.rawurlencode($filepath).'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
02193                 $ATag2='<a href="'.htmlspecialchars($Ahref).'">';
02194                 $ATag2_e='</a>';
02195 
02196                     // Combine the stuff:
02197                 $filenameAndIcon=$bulkCheckBox.$ATag_alt.$icon.htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($filepath),$titleLen)).$ATag_e;
02198 
02199                     // Show element:
02200                 if ($pDim)  {       // Image...
02201                     $lines[]='
02202                         <tr class="bgColor4">
02203                             <td nowrap="nowrap">'.$filenameAndIcon.'&nbsp;</td>
02204                             <td>'.$ATag.'<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/plusbullet2.gif','width="18" height="16"').' title="'.$LANG->getLL('addToList',1).'" alt="" />'.$ATag_e.'</td>
02205                             <td nowrap="nowrap">'.($ATag2.'<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/zoom2.gif','width="12" height="12"').' title="'.$LANG->getLL('info',1).'" alt="" /> '.$LANG->getLL('info',1).$ATag2_e).'</td>
02206                             <td nowrap="nowrap">&nbsp;'.$pDim.'</td>
02207                         </tr>';
02208                     $lines[]='
02209                         <tr>
02210                             <td colspan="4">'.$ATag_alt.$clickIcon.$ATag_e.'</td>
02211                         </tr>';
02212                 } else {
02213                     $lines[]='
02214                         <tr class="bgColor4">
02215                             <td nowrap="nowrap">'.$filenameAndIcon.'&nbsp;</td>
02216                             <td>'.$ATag.'<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/plusbullet2.gif','width="18" height="16"').' title="'.$LANG->getLL('addToList',1).'" alt="" />'.$ATag_e.'</td>
02217                             <td nowrap="nowrap">'.($ATag2.'<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/zoom2.gif','width="12" height="12"').' title="'.$LANG->getLL('info',1).'" alt="" /> '.$LANG->getLL('info',1).$ATag2_e).'</td>
02218                             <td>&nbsp;</td>
02219                         </tr>';
02220                 }
02221                 $lines[]='
02222                         <tr>
02223                             <td colspan="3"><img src="clear.gif" width="1" height="3" alt="" /></td>
02224                         </tr>';
02225             }
02226 
02227                 // Wrap all the rows in table tags:
02228             $out.='
02229 
02230 
02231 
02232         <!--
02233             File listing
02234         -->
02235                 <table cellpadding="0" cellspacing="0" id="typo3-fileList">
02236                     '.implode('',$lines).'
02237                 </table>';
02238         }
02239             // Return accumulated content for filelisting:
02240         return $out;
02241     }
02242 
02243     /**
02244      * Render list of folders.
02245      *
02246      * @param   array       List of folders. See t3lib_div::get_dirs
02247      * @param   string      If set a header with a folder icon and folder name are shown
02248      * @return  string      HTML output
02249      */
02250     function folderList($baseFolder, $folders) {
02251         global $LANG, $BACK_PATH;
02252 
02253         $content = '';
02254 
02255             // Create headline (showing number of folders):
02256         $content.=$this->barheader(
02257             sprintf($GLOBALS['LANG']->getLL('folders').' (%s):',count($folders))
02258         );
02259 
02260         $titleLength = intval($GLOBALS['BE_USER']->uc['titleLen']);
02261 
02262             // Create the header of current folder:
02263         if($baseFolder) {
02264             if (strstr($baseFolder, ',') || strstr($baseFolder, '|'))   {
02265                     // In case an invalid character is in the filepath, display error message:
02266                 $errorMessage     = $LANG->JScharCode(sprintf($LANG->getLL('invalidChar'),', |'));
02267                 $aTag = $aTag_alt = "<a href=\"#\" onclick=\"alert(".$errorMessage.");return false;\">";
02268             } else {
02269                     // If foldername is OK, just add it:
02270                 $aTag = "<a href=\"#\" onclick=\"return insertElement('','".rawurlencode($baseFolder)."', 'folder', '".rawurlencode($baseFolder)."', unescape('".rawurlencode($baseFolder)."'), '".$fI['extension']."', '".$ficon."');\">";
02271                 $aTag_alt = substr($aTag,0,-4).",'',1);\">";
02272             }
02273             $aTag_e = '</a>';
02274 
02275                 // add the foder icon
02276             $folderIcon = $aTag_alt;
02277             $folderIcon.= '<img'.t3lib_iconWorks::skinImg(
02278                 $BACK_PATH,
02279                 'gfx/i/_icon_webfolders.gif','width="18" height="16"'
02280             ).' alt="" />';
02281             $folderIcon.= htmlspecialchars(
02282                 t3lib_div::fixed_lgd_cs(basename($baseFolder),$titleLength)
02283             );
02284             $folderIcon.= $aTag_e;
02285 
02286             $content.=$folderIcon.'<br />';
02287         }
02288 
02289             // Listing the folders:
02290         if(is_array($folders)) {
02291             if(count($folders) > 0) {
02292                     // Traverse the folder list:
02293                 $lines = array();
02294                 foreach($folders as $folderPath)    {
02295                     $pathInfo = pathinfo($folderPath);
02296 
02297                         // Create folder icon:
02298                     $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="" />';
02299 
02300                         // Create links for adding the folder:
02301                     if($this->P['itemName'] != '' && $this->P['formName'] != '') {
02302                         $aTag = "<a href=\"#\" onclick=\"return set_folderpath(unescape('".rawurlencode($folderPath)."'));\">";
02303                     } else {
02304                         $aTag = "<a href=\"#\" onclick=\"return insertElement('','".rawurlencode($folderPath)."', 'folder', '".rawurlencode($folderPath)."', unescape('".rawurlencode($folderPath)."'), '".$pathInfo['extension']."', '".$ficon."');\">";
02305                     }
02306 
02307                     if (strstr($folderPath,',') || strstr($folderPath,'|')) {
02308                             // In case an invalid character is in the filepath, display error message:
02309                         $errorMessage     = $LANG->JScharCode(sprintf($LANG->getLL('invalidChar'),', |'));
02310                         $aTag = $aTag_alt = "<a href=\"#\" onclick=\"alert(".$errorMessage.");return false;\">";
02311                     } else {
02312                             // If foldername is OK, just add it:
02313                         $aTag_alt = substr($aTag,0,-4).",'',1);\">";
02314                     }
02315                     $aTag_e='</a>';
02316 
02317                         // Combine icon and folderpath:
02318                     $foldernameAndIcon = $aTag_alt.$icon.htmlspecialchars(
02319                         t3lib_div::fixed_lgd_cs(basename($folderPath),$titleLength)
02320                     ).$aTag_e;
02321 
02322                     if($this->P['itemName'] != '') {
02323                         $lines[] = '
02324                             <tr class="bgColor4">
02325                                 <td nowrap="nowrap">'.$foldernameAndIcon.'&nbsp;</td>
02326                                 <td>&nbsp;</td>
02327                             </tr>';
02328                     } else {
02329                         $lines[] = '
02330                             <tr class="bgColor4">
02331                                 <td nowrap="nowrap">'.$foldernameAndIcon.'&nbsp;</td>
02332                                 <td>'.$aTag.'<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/plusbullet2.gif','width="18" height="16"').' title="'.$LANG->getLL('addToList',1).'" alt="" />'.$aTag_e.'</td>
02333                                 <td>&nbsp;</td>
02334                             </tr>';
02335                     }
02336 
02337                     $lines[] = '
02338                             <tr>
02339                                 <td colspan="3"><img src="clear.gif" width="1" height="3" alt="" /></td>
02340                             </tr>';
02341                 }
02342             }
02343 
02344                 // Wrap all the rows in table tags:
02345             $content.='
02346 
02347         <!--
02348             Folder listing
02349         -->
02350                 <table border="0" cellpadding="0" cellspacing="1" id="typo3-folderList">
02351                     '.implode('', $lines).'
02352                 </table>';
02353         }
02354 
02355             // Return accumulated content for folderlisting:
02356         return $content;
02357     }
02358 
02359     /**
02360      * For RTE: This displays all IMAGES (gif,png,jpg) (from extensionList) from folder. Thumbnails are shown for images.
02361      * This listing is of images located in the web-accessible paths ONLY - the listing is for drag-n-drop use in the RTE
02362      *
02363      * @param   string      The folder path to expand
02364      * @param   string      List of fileextensions to show
02365      * @return  string      HTML output
02366      */
02367     function TBE_dragNDrop($expandFolder=0,$extensionList='')   {
02368         global $BACK_PATH;
02369 
02370         $extensionList = ($extensionList == '*') ? '' : $extensionList;
02371         $expandFolder = $expandFolder ? $expandFolder : $this->expandFolder;
02372         $out='';
02373         if ($expandFolder && $this->checkFolder($expandFolder)) {
02374             if ($this->isWebFolder($expandFolder))  {
02375 
02376                     // Read files from directory:
02377                 $files = t3lib_div::getFilesInDir($expandFolder,$extensionList,1,1);    // $extensionList="",$prependPath=0,$order='')
02378                 if (is_array($files))   {
02379                     $out.=$this->barheader(sprintf($GLOBALS['LANG']->getLL('files').' (%s):',count($files)));
02380 
02381                     $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
02382                     $picon='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/i/_icon_webfolders.gif','width="18" height="16"').' alt="" />';
02383                     $picon.=htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($expandFolder),$titleLen));
02384                     $out.=$picon.'<br />';
02385 
02386                         // Init row-array:
02387                     $lines=array();
02388 
02389                         // Add "drag-n-drop" message:
02390                     $lines[]='
02391                         <tr>
02392                             <td colspan="2">'.$this->getMsgBox($GLOBALS['LANG']->getLL('findDragDrop')).'</td>
02393                         </tr>';
02394 
02395                         // Traverse files:
02396                     foreach ($files as $filepath) {
02397                         $fI = pathinfo($filepath);
02398 
02399                             // URL of image:
02400                         $iurl = $this->siteURL.t3lib_div::rawurlencodeFP(substr($filepath,strlen(PATH_site)));
02401 
02402                             // Show only web-images
02403                         if (t3lib_div::inList('gif,jpeg,jpg,png',strtolower($fI['extension']))) {
02404                             $imgInfo = @getimagesize($filepath);
02405                             $pDim = $imgInfo[0].'x'.$imgInfo[1].' pixels';
02406 
02407                             $ficon = t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
02408                             $size=' ('.t3lib_div::formatSize(filesize($filepath)).'bytes'.($pDim?', '.$pDim:'').')';
02409                             $icon = '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/fileicons/'.$ficon,'width="18" height="16"').' class="absmiddle" title="'.htmlspecialchars($fI['basename'].$size).'" alt="" />';
02410                             $filenameAndIcon=$icon.htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($filepath),$titleLen));
02411 
02412                             if (t3lib_div::_GP('noLimit'))  {
02413                                 $maxW=10000;
02414                                 $maxH=10000;
02415                             } else {
02416                                 $maxW=380;
02417                                 $maxH=500;
02418                             }
02419                             $IW = $imgInfo[0];
02420                             $IH = $imgInfo[1];
02421                             if ($IW>$maxW)  {
02422                                 $IH=ceil($IH/$IW*$maxW);
02423                                 $IW=$maxW;
02424                             }
02425                             if ($IH>$maxH)  {
02426                                 $IW=ceil($IW/$IH*$maxH);
02427                                 $IH=$maxH;
02428                             }
02429 
02430                                 // Make row:
02431                             $lines[]='
02432                                 <tr class="bgColor4">
02433                                     <td nowrap="nowrap">'.$filenameAndIcon.'&nbsp;</td>
02434                                     <td nowrap="nowrap">'.
02435                                     ($imgInfo[0]!=$IW ? '<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('noLimit'=>'1'))).'">'.
02436                                                         '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/icon_warning2.gif','width="18" height="16"').' title="'.$GLOBALS['LANG']->getLL('clickToRedrawFullSize',1).'" alt="" />'.
02437                                                         '</a>':'').
02438                                     $pDim.'&nbsp;</td>
02439                                 </tr>';
02440 
02441                             $lines[]='
02442                                 <tr>
02443                                     <td colspan="2"><img src="'.$iurl.'" width="'.$IW.'" height="'.$IH.'" border="1" alt="" /></td>
02444                                 </tr>';
02445                             $lines[]='
02446                                 <tr>
02447                                     <td colspan="2"><img src="clear.gif" width="1" height="3" alt="" /></td>
02448                                 </tr>';
02449                         }
02450                     }
02451 
02452                         // Finally, wrap all rows in a table tag:
02453                     $out.='
02454 
02455 
02456             <!--
02457                 File listing / Drag-n-drop
02458             -->
02459                         <table border="0" cellpadding="0" cellspacing="1" id="typo3-dragBox">
02460                             '.implode('',$lines).'
02461                         </table>';
02462                 }
02463             } else {
02464                     // Print this warning if the folder is NOT a web folder:
02465                 $out.=$this->barheader($GLOBALS['LANG']->getLL('files'));
02466                 $out.=$this->getMsgBox($GLOBALS['LANG']->getLL('noWebFolder'),'icon_warning2');
02467             }
02468         }
02469         return $out;
02470     }
02471 
02472 
02473 
02474 
02475 
02476 
02477 
02478 
02479 
02480 
02481 
02482 
02483     /******************************************************************
02484      *
02485      * Miscellaneous functions
02486      *
02487      ******************************************************************/
02488 
02489 
02490     /**
02491      * Verifies that a path is a web-folder:
02492      *
02493      * @param   string      Absolute filepath
02494      * @return  boolean     If the input path is found in PATH_site then it returns true.
02495      */
02496     function isWebFolder($folder)   {
02497         $folder = rtrim($folder, '/').'/';
02498         return t3lib_div::isFirstPartOfStr($folder,PATH_site) ? TRUE : FALSE;
02499     }
02500 
02501     /**
02502      * Checks, if a path is within the mountpoints of the backend user
02503      *
02504      * @param   string      Absolute filepath
02505      * @return  boolean     If the input path is found in the backend users filemounts, then return true.
02506      */
02507     function checkFolder($folder)   {
02508         return $this->fileProcessor->checkPathAgainstMounts(rtrim($folder, '/') . '/') ? true : false;
02509     }
02510 
02511     /**
02512      * Checks, if a path is within a read-only mountpoint of the backend user
02513      *
02514      * @param   string      Absolute filepath
02515      * @return  boolean     If the input path is found in the backend users filemounts and if the filemount is of type readonly, then return true.
02516      */
02517     function isReadOnlyFolder($folder) {
02518         return ($GLOBALS['FILEMOUNTS'][$this->fileProcessor->checkPathAgainstMounts(rtrim($folder, '/') . '/')]['type'] == 'readonly');
02519     }
02520 
02521     /**
02522      * Prints a 'header' where string is in a tablecell
02523      *
02524      * @param   string      The string to print in the header. The value is htmlspecialchars()'ed before output.
02525      * @return  string      The header HTML (wrapped in a table)
02526      */
02527     function barheader($str)    {
02528         return '
02529             <!-- Bar header: -->
02530             <h3>' . htmlspecialchars($str) . '</h3>
02531             ';
02532     }
02533 
02534     /**
02535      * Displays a message box with the input message
02536      *
02537      * @param   string      Input message to show (will be htmlspecialchars()'ed inside of this function)
02538      * @param   string      Icon filename body from gfx/ (default is "icon_note") - meant to allow change to warning type icons...
02539      * @return  string      HTML for the message (wrapped in a table).
02540      */
02541     function getMsgBox($in_msg,$icon='icon_note')   {
02542         global $BACK_PATH;
02543 
02544         $msg = '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/'.$icon.'.gif','width="18" height="16"').' alt="" />'.htmlspecialchars($in_msg);
02545         $msg = '
02546 
02547             <!--
02548                 Message box:
02549             -->
02550             <table cellspacing="0" class="bgColor4" id="typo3-msgBox">
02551                 <tr>
02552                     <td>'.$msg.'</td>
02553                 </tr>
02554             </table>
02555             ';
02556         return $msg;
02557     }
02558 
02559     /**
02560      * For RTE/link: This prints the 'currentUrl'
02561      *
02562      * @param   string      URL value.  The value is htmlspecialchars()'ed before output.
02563      * @return  string      HTML content, wrapped in a table.
02564      */
02565     function printCurrentUrl($str)  {
02566         if (strlen($str)) {
02567             return '
02568                 <!-- Print current URL -->
02569                 <table border="0" cellpadding="0" cellspacing="0" id="typo3-curUrl">
02570                     <tr>
02571                         <td>' . $GLOBALS['LANG']->getLL('currentLink',1) . ': ' .htmlspecialchars(rawurldecode($str)) . '</td>
02572                     </tr>
02573                 </table>';
02574         } else {
02575             return '';
02576         }
02577     }
02578 
02579     /**
02580      * For RTE/link: Parses the incoming URL and determines if it's a page, file, external or mail address.
02581      *
02582      * @param   string      HREF value tp analyse
02583      * @param   string      The URL of the current website (frontend)
02584      * @return  array       Array with URL information stored in assoc. keys: value, act (page, file, spec, mail), pageid, cElement, info
02585      */
02586     function parseCurUrl($href,$siteUrl)    {
02587         $href = trim($href);
02588         if ($href)  {
02589             $info=array();
02590 
02591                 // Default is "url":
02592             $info['value']=$href;
02593             $info['act']='url';
02594 
02595             $specialParts = explode('#_SPECIAL',$href);
02596             if (count($specialParts)==2)    {   // Special kind (Something RTE specific: User configurable links through: "userLinks." from ->thisConfig)
02597                 $info['value']='#_SPECIAL'.$specialParts[1];
02598                 $info['act']='spec';
02599             } elseif (t3lib_div::isFirstPartOfStr($href,$siteUrl))  {   // If URL is on the current frontend website:
02600                 $rel = substr($href,strlen($siteUrl));
02601                 if (file_exists(PATH_site.rawurldecode($rel)))  {   // URL is a file, which exists:
02602                     $info['value']=rawurldecode($rel);
02603                     if (@is_dir(PATH_site . $info['value'])) {
02604                         $info['act'] = 'folder';
02605                     } else {
02606                         $info['act'] = 'file';
02607                     }
02608                 } else {    // URL is a page (id parameter)
02609                     $uP=parse_url($rel);
02610                     if (!trim($uP['path'])) {
02611                         $pp = preg_split('/^id=/', $uP['query']);
02612                         $pp[1] = preg_replace( '/&id=[^&]*/', '', $pp[1]);
02613                         $parameters = explode('&', $pp[1]);
02614                         $id = array_shift($parameters);
02615                         if ($id)    {
02616                                 // Checking if the id-parameter is an alias.
02617                             if (!t3lib_div::testInt($id))   {
02618                                 list($idPartR) = t3lib_BEfunc::getRecordsByField('pages','alias',$id);
02619                                 $id=intval($idPartR['uid']);
02620                             }
02621 
02622                             $pageRow = t3lib_BEfunc::getRecordWSOL('pages',$id);
02623                             $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
02624                             $info['value']=$GLOBALS['LANG']->getLL('page',1)." '".htmlspecialchars(t3lib_div::fixed_lgd_cs($pageRow['title'],$titleLen))."' (ID:".$id.($uP['fragment']?', #'.$uP['fragment']:'').')';
02625                             $info['pageid']=$id;
02626                             $info['cElement']=$uP['fragment'];
02627                             $info['act']='page';
02628                             $info['query'] = $parameters[0]?'&'.implode('&', $parameters):'';
02629                         }
02630                     }
02631                 }
02632             } else {    // Email link:
02633                 if (strtolower(substr($href,0,7))=='mailto:')   {
02634                     $info['value']=trim(substr($href,7));
02635                     $info['act']='mail';
02636                 }
02637             }
02638             $info['info'] = $info['value'];
02639         } else {    // NO value inputted:
02640             $info=array();
02641             $info['info']=$GLOBALS['LANG']->getLL('none');
02642             $info['value']='';
02643             $info['act']='page';
02644         }
02645 
02646             // let the hook have a look
02647         foreach($this->hookObjects as $hookObject) {
02648             $info = $hookObject->parseCurrentUrl($href, $siteUrl, $info);
02649         }
02650 
02651         return $info;
02652     }
02653 
02654     /**
02655      * For TBE: Makes an upload form for uploading files to the filemount the user is browsing.
02656      * The files are uploaded to the tce_file.php script in the core which will handle the upload.
02657      *
02658      * @param   string      Absolute filepath on server to which to upload.
02659      * @return  string      HTML for an upload form.
02660      */
02661     function uploadForm($path)  {
02662         global $BACK_PATH;
02663 
02664         if ($this->isReadOnlyFolder($path)) return '';
02665 
02666             // Read configuration of upload field count
02667         $userSetting = $GLOBALS['BE_USER']->getTSConfigVal('options.folderTree.uploadFieldsInLinkBrowser');
02668         $count = isset($userSetting) ? $userSetting : 3;
02669         if ($count === '0') {
02670             return '';
02671         }
02672         $count = intval($count) == 0 ? 3 : intval($count);
02673 
02674             // Create header, showing upload path:
02675         $header = t3lib_div::isFirstPartOfStr($path,PATH_site)?substr($path,strlen(PATH_site)):$path;
02676         $code=$this->barheader($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_upload.php.pagetitle',1).':');
02677         $code.='
02678 
02679             <!--
02680                 Form, for uploading files:
02681             -->
02682             <form action="'.$BACK_PATH.'tce_file.php" method="post" name="editform" enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'">
02683                 <table border="0" cellpadding="0" cellspacing="3" id="typo3-uplFiles">
02684                     <tr>
02685                         <td><strong>'.$GLOBALS['LANG']->getLL('path',1).':</strong> '.htmlspecialchars($header).'</td>
02686                     </tr>
02687                     <tr>
02688                         <td>';
02689 
02690             // Traverse the number of upload fields (default is 3):
02691         for ($a=1;$a<=$count;$a++)  {
02692             $code.='<input type="file" name="upload_'.$a.'"'.$this->doc->formWidth(35).' size="50" />
02693                 <input type="hidden" name="file[upload]['.$a.'][target]" value="'.htmlspecialchars($path).'" />
02694                 <input type="hidden" name="file[upload]['.$a.'][data]" value="'.$a.'" /><br />';
02695         }
02696 
02697             // Make footer of upload form, including the submit button:
02698         $redirectValue = $this->thisScript.'?act='.$this->act.'&mode='.$this->mode.'&expandFolder='.rawurlencode($path).'&bparams='.rawurlencode($this->bparams);
02699         $code.='<input type="hidden" name="redirect" value="'.htmlspecialchars($redirectValue).'" />'.
02700                 '<input type="submit" name="submit" value="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_upload.php.submit',1).'" />';
02701 
02702         $code.='
02703             <div id="c-override">
02704                 <input type="checkbox" name="overwriteExistingFiles" id="overwriteExistingFiles" value="1" /> <label for="overwriteExistingFiles">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xml:overwriteExistingFiles',1).'</label>
02705             </div>
02706         ';
02707 
02708 
02709         $code.='</td>
02710                     </tr>
02711                 </table>
02712             </form>';
02713 
02714         return $code;
02715     }
02716 
02717     /**
02718      * For TBE: Makes a form for creating new folders in the filemount the user is browsing.
02719      * The folder creation request is sent to the tce_file.php script in the core which will handle the creation.
02720      *
02721      * @param   string      Absolute filepath on server in which to create the new folder.
02722      * @return  string      HTML for the create folder form.
02723      */
02724     function createFolder($path)    {
02725         global $BACK_PATH;
02726 
02727         if ($this->isReadOnlyFolder($path)) return '';
02728 
02729             // Don't show Folder-create form if it's denied
02730         if ($GLOBALS['BE_USER']->getTSConfigVal('options.folderTree.hideCreateFolder')) {
02731             return '';
02732         }
02733             // Create header, showing upload path:
02734         $header = t3lib_div::isFirstPartOfStr($path,PATH_site)?substr($path,strlen(PATH_site)):$path;
02735         $code=$this->barheader($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.pagetitle').':');
02736         $code.='
02737 
02738             <!--
02739                 Form, for creating new folders:
02740             -->
02741             <form action="'.$BACK_PATH.'tce_file.php" method="post" name="editform2">
02742                 <table border="0" cellpadding="0" cellspacing="3" id="typo3-crFolder">
02743                     <tr>
02744                         <td><strong>'.$GLOBALS['LANG']->getLL('path',1).':</strong> '.htmlspecialchars($header).'</td>
02745                     </tr>
02746                     <tr>
02747                         <td>';
02748 
02749             // Create the new-folder name field:
02750         $a=1;
02751         $code.='<input'.$this->doc->formWidth(20).' type="text" name="file[newfolder]['.$a.'][data]" />'.
02752                 '<input type="hidden" name="file[newfolder]['.$a.'][target]" value="'.htmlspecialchars($path).'" />';
02753 
02754             // Make footer of upload form, including the submit button:
02755         $redirectValue = $this->thisScript.'?act='.$this->act.'&mode='.$this->mode.'&expandFolder='.rawurlencode($path).'&bparams='.rawurlencode($this->bparams);
02756         $code.='<input type="hidden" name="redirect" value="'.htmlspecialchars($redirectValue).'" />'.
02757                 '<input type="submit" name="submit" value="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.submit',1).'" />';
02758 
02759         $code.='</td>
02760                     </tr>
02761                 </table>
02762             </form>';
02763 
02764         return $code;
02765     }
02766 
02767     /**
02768      * Get the HTML data required for a bulk selection of files of the TYPO3 Element Browser.
02769      *
02770      * @param   integer     $filesCount: Number of files currently displayed
02771      * @return  string      HTML data required for a bulk selection of files - if $filesCount is 0, nothing is returned
02772      */
02773     function getBulkSelector($filesCount) {
02774         if ($filesCount) {
02775             $labelToggleSelection = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_browse_links.php:toggleSelection',1);
02776             $labelImportSelection = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_browse_links.php:importSelection',1);
02777 
02778             $out = $this->doc->spacer(15).'<div>' .
02779                     '<a href="#" onclick="BrowseLinks.Selector.toggle()">' .
02780                         '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/clip_select.gif','width="12" height="12"').' title="'.$labelToggleSelection.'" alt="" /> ' .
02781                         $labelToggleSelection.'</a>'.$this->doc->spacer(5) .
02782                     '<a href="#" onclick="BrowseLinks.Selector.handle()">' .
02783                         '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/import.gif','width="12" height="12"').' title="'.$labelImportSelection.'" alt="" /> ' .
02784                         $labelImportSelection.'</a>' .
02785                 '</div>'.$this->doc->spacer(15);
02786         }
02787         return $out;
02788     }
02789 }
02790 
02791 
02792 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.browse_links.php'])    {
02793     include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.browse_links.php']);
02794 }
02795 
02796 ?>

Generated on Sat Jul 24 04:17:28 2010 for TYPO3 API by  doxygen 1.4.7