TYPO3 API  SVNRelease
class.browse_links.php
Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2011 Kasper Skårhøj (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 10142 2011-01-19 20:50:34Z lolli $
00033  * Revised for TYPO3 3.6 November/2003 by Kasper Skårhøj
00034  * XHTML compliant
00035  *
00036  * @author  Kasper Skårhøj <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 Skårhøj <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 Skårhøj <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!=' . t3lib_pageSelect::DOKTYPE_RECYCLER . $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 Skårhøj <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 Skårhøj <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 Skårhøj <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(htmlspecialchars(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 Skårhøj <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 Skårhøj <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 Skårhøj <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             $currentValues = t3lib_div::trimExplode(LF, trim($this->P['currentValue']));
00818             if (count($currentValues) > 0) {
00819                 $currentValue = array_pop($currentValues);
00820             } else {
00821                 $currentValue = '';
00822             }
00823             $currentLinkParts = t3lib_div::unQuoteFilenames($currentValue, TRUE);
00824             $initialCurUrlArray = array (
00825                 'href'   => $currentLinkParts[0],
00826                 'target' => $currentLinkParts[1],
00827                 'class'  => $currentLinkParts[2],
00828                 'title'  => $currentLinkParts[3],
00829                 'params'  => $currentLinkParts[4]
00830             );
00831             $this->curUrlArray = (is_array(t3lib_div::_GP('curUrl'))) ?
00832                 array_merge($initialCurUrlArray, t3lib_div::_GP('curUrl')) :
00833                 $initialCurUrlArray;
00834             $this->curUrlInfo = $this->parseCurUrl($this->siteURL.'?id='.$this->curUrlArray['href'], $this->siteURL);
00835             if ($this->curUrlInfo['pageid'] == 0 && $this->curUrlArray['href']) { // pageid == 0 means that this is not an internal (page) link
00836                 if (file_exists(PATH_site.rawurldecode($this->curUrlArray['href'])))    { // check if this is a link to a file
00837                     if (t3lib_div::isFirstPartOfStr($this->curUrlArray['href'], PATH_site)) {
00838                         $currentLinkParts[0] = substr($this->curUrlArray['href'], strlen(PATH_site));
00839                     }
00840                     $this->curUrlInfo = $this->parseCurUrl($this->siteURL.$this->curUrlArray['href'], $this->siteURL);
00841                 } elseif (strstr($this->curUrlArray['href'], '@')) { // check for email link
00842                     if (t3lib_div::isFirstPartOfStr($this->curUrlArray['href'], 'mailto:')) {
00843                         $currentLinkParts[0] = substr($this->curUrlArray['href'], 7);
00844                     }
00845                     $this->curUrlInfo = $this->parseCurUrl('mailto:'.$this->curUrlArray['href'], $this->siteURL);
00846                 } else { // nothing of the above. this is an external link
00847                     if(strpos($this->curUrlArray['href'], '://') === false) {
00848                         $currentLinkParts[0] = 'http://' . $this->curUrlArray['href'];
00849                     }
00850                     $this->curUrlInfo = $this->parseCurUrl($currentLinkParts[0], $this->siteURL);
00851                 }
00852             } elseif (!$this->curUrlArray['href']) {
00853                 $this->curUrlInfo = array();
00854                 $this->act = 'page';
00855             } else {
00856                 $this->curUrlInfo = $this->parseCurUrl($this->siteURL.'?id='.$this->curUrlArray['href'], $this->siteURL);
00857             }
00858         } else {
00859             $this->curUrlArray = t3lib_div::_GP('curUrl');
00860             if ($this->curUrlArray['all'])  {
00861                 $this->curUrlArray=t3lib_div::get_tag_attributes($this->curUrlArray['all']);
00862             }
00863             $this->curUrlInfo=$this->parseCurUrl($this->curUrlArray['href'],$this->siteURL);
00864         }
00865 
00866             // Determine nature of current url:
00867         $this->act=t3lib_div::_GP('act');
00868         if (!$this->act)    {
00869             $this->act=$this->curUrlInfo['act'];
00870         }
00871 
00872             // Rich Text Editor specific configuration:
00873         $addPassOnParams='';
00874         if ((string)$this->mode == 'rte')   {
00875             $RTEtsConfigParts = explode(':',$this->RTEtsConfigParams);
00876             $addPassOnParams.='&RTEtsConfigParams='.rawurlencode($this->RTEtsConfigParams);
00877             $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE',t3lib_BEfunc::getPagesTSconfig($RTEtsConfigParts[5]));
00878             $this->thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup['properties'],$RTEtsConfigParts[0],$RTEtsConfigParts[2],$RTEtsConfigParts[4]);
00879         }
00880 
00881             // Initializing the target value (RTE)
00882         $this->setTarget = ($this->curUrlArray['target'] != '-') ? $this->curUrlArray['target'] : '';
00883         if ($this->thisConfig['defaultLinkTarget'] && !isset($this->curUrlArray['target'])) {
00884             $this->setTarget=$this->thisConfig['defaultLinkTarget'];
00885         }
00886 
00887             // Initializing the class value (RTE)
00888         $this->setClass = ($this->curUrlArray['class'] != '-') ? $this->curUrlArray['class'] : '';
00889 
00890             // Initializing the title value (RTE)
00891         $this->setTitle = ($this->curUrlArray['title'] != '-') ? $this->curUrlArray['title'] : '';
00892         
00893             // Initializing the params value
00894         $this->setParams = ($this->curUrlArray['params'] != '-') ? $this->curUrlArray['params'] : '';
00895 
00896             // BEGIN accumulation of header JavaScript:
00897         $JScode = '
00898                 // This JavaScript is primarily for RTE/Link. jumpToUrl is used in the other cases as well...
00899             var add_href="'.($this->curUrlArray['href']?'&curUrl[href]='.rawurlencode($this->curUrlArray['href']):'').'";
00900             var add_target="'.($this->setTarget?'&curUrl[target]='.rawurlencode($this->setTarget):'').'";
00901             var add_class="'.($this->setClass ? '&curUrl[class]='.rawurlencode($this->setClass) : '').'";
00902             var add_title="'.($this->setTitle?'&curUrl[title]='.rawurlencode($this->setTitle):'').'";
00903             var add_params="'.($this->bparams?'&bparams='.rawurlencode($this->bparams):'').'";
00904 
00905             var cur_href="'.($this->curUrlArray['href']?$this->curUrlArray['href']:'').'";
00906             var cur_target="'.($this->setTarget?$this->setTarget:'').'";
00907             var cur_class = "' . ($this->setClass ? $this->setClass : '') . '";
00908             var cur_title="'.($this->setTitle?$this->setTitle:'').'";
00909             var cur_params="' . ($this->setParams ? $this->setParams : '') . '";
00910 
00911             function browse_links_setTarget(target) {   //
00912                 cur_target=target;
00913                 add_target="&curUrl[target]="+escape(target);
00914             }
00915             function browse_links_setClass(cssClass) {   //
00916                 cur_class = cssClass;
00917                 add_class = "&curUrl[class]=" + escape(cssClass);
00918             }
00919             function browse_links_setTitle(title)   {   //
00920                 cur_title=title;
00921                 add_title="&curUrl[title]="+escape(title);
00922             }
00923             function browse_links_setValue(value) { //
00924                 cur_href=value;
00925                 add_href="&curUrl[href]="+value;
00926             }
00927             function browse_links_setParams(params) {   //
00928                 cur_params=params;
00929                 add_params="&curUrl[params]="+escape(params);
00930             }
00931         ';
00932 
00933         if ($this->mode == 'wizard')    {   // Functions used, if the link selector is in wizard mode (= TCEforms fields)
00934             if (!$this->areFieldChangeFunctionsValid() && !$this->areFieldChangeFunctionsValid(TRUE)) {
00935                 $this->P['fieldChangeFunc'] = array();
00936             }
00937             unset($this->P['fieldChangeFunc']['alert']);
00938             $update='';
00939             foreach ($this->P['fieldChangeFunc'] as $k => $v) {
00940                 $update.= '
00941                 window.opener.'.$v;
00942             }
00943 
00944             $P2=array();
00945             $P2['itemName']=$this->P['itemName'];
00946             $P2['formName']=$this->P['formName'];
00947             $P2['fieldChangeFunc']=$this->P['fieldChangeFunc'];
00948             $P2['fieldChangeFuncHash'] = t3lib_div::hmac(serialize($this->P['fieldChangeFunc']));
00949             $P2['params']['allowedExtensions']=$this->P['params']['allowedExtensions'];
00950             $P2['params']['blindLinkOptions']=$this->P['params']['blindLinkOptions'];
00951             $addPassOnParams.=t3lib_div::implodeArrayForUrl('P',$P2);
00952 
00953             $JScode.='
00954                 function link_typo3Page(id,anchor)  {   //
00955                     updateValueInMainForm(id + (anchor ? anchor : ""));
00956                     close();
00957                     return false;
00958                 }
00959                 function link_folder(folder)    {   //
00960                     updateValueInMainForm(folder);
00961                     close();
00962                     return false;
00963                 }
00964                 function link_current() {   //
00965                     if (cur_href!="http://" && cur_href!="mailto:") {
00966                         returnBeforeCleaned = cur_href;
00967                         if (returnBeforeCleaned.substr(0, 7) == "http://") {
00968                             returnToMainFormValue = returnBeforeCleaned.substr(7);
00969                         } else if (returnBeforeCleaned.substr(0, 7) == "mailto:") {
00970                             if (returnBeforeCleaned.substr(0, 14) == "mailto:mailto:") {
00971                                 returnToMainFormValue = returnBeforeCleaned.substr(14);
00972                             } else {
00973                                 returnToMainFormValue = returnBeforeCleaned.substr(7);
00974                             }
00975                         } else {
00976                             returnToMainFormValue = returnBeforeCleaned;
00977                         }
00978                         updateValueInMainForm(returnToMainFormValue);
00979                         close();
00980                     }
00981                     return false;
00982                 }
00983                 function checkReference()   {   //
00984                     if (window.opener && window.opener.document && window.opener.document.'.$this->P['formName'].' && window.opener.document.'.$this->P['formName'].'["'.$this->P['itemName'].'"] ) {
00985                         return window.opener.document.'.$this->P['formName'].'["'.$this->P['itemName'].'"];
00986                     } else {
00987                         close();
00988                     }
00989                 }
00990                 function updateValueInMainForm(input)   {   //
00991                     var field = checkReference();
00992                     if (field)  {
00993                         if (cur_target == "" && (cur_class != "" || cur_title != "" || cur_params != "")) {
00994                             cur_target = "-";
00995                         }
00996                         if (cur_class == "" && (cur_title != "" || cur_params != "")) {
00997                             cur_class = "-";
00998                         }
00999                         cur_class = cur_class.replace(/[\'\"]/g, "");
01000                         if (cur_class.indexOf(" ") != -1) {
01001                             cur_class = "\"" + cur_class + "\"";
01002                         }
01003                         if (cur_title == "" && cur_params != "") {
01004                             cur_title = "-";
01005                         }
01006                         cur_title = cur_title.replace(/(^\")|(\"$)/g, "");
01007                         if (cur_title.indexOf(" ") != -1) {
01008                             cur_title = "\"" + cur_title + "\"";
01009                         }
01010                         if (cur_params) {
01011                             cur_params = cur_params.replace(/\bid\=.*?(\&|$)/, "");
01012                         }
01013                         input = input + " " + cur_target + " " + cur_class + " " + cur_title + " " + cur_params;
01014                         if(field.value && field.className.search(/textarea/) != -1) {
01015                             field.value += "\n" + input;
01016                         } else {
01017                             field.value = input;
01018                         }
01019                         '.$update.'
01020                     }
01021                 }
01022             ';
01023         } else {    // Functions used, if the link selector is in RTE mode:
01024             $JScode.='
01025                 function link_typo3Page(id,anchor)  {   //
01026                     var theLink = \''.$this->siteURL.'?id=\'+id+(anchor?anchor:"");
01027                     self.parent.parent.renderPopup_addLink(theLink, cur_target, cur_class, cur_title);
01028                     return false;
01029                 }
01030                 function link_folder(folder)    {   //
01031                     var theLink = \''.$this->siteURL.'\'+folder;
01032                     self.parent.parent.renderPopup_addLink(theLink, cur_target, cur_class, cur_title);
01033                     return false;
01034                 }
01035                 function link_spec(theLink) {   //
01036                     self.parent.parent.renderPopup_addLink(theLink, cur_target, cur_class, cur_title);
01037                     return false;
01038                 }
01039                 function link_current() {   //
01040                     if (cur_href!="http://" && cur_href!="mailto:") {
01041                         self.parent.parent.renderPopup_addLink(cur_href, cur_target, cur_class, cur_title);
01042                     }
01043                     return false;
01044                 }
01045             ';
01046         }
01047 
01048             // General "jumpToUrl" function:
01049         $JScode.='
01050             function jumpToUrl(URL,anchor)  {   //
01051                 var add_act = URL.indexOf("act=")==-1 ? "&act='.$this->act.'" : "";
01052                 var add_mode = URL.indexOf("mode=")==-1 ? "&mode='.$this->mode.'" : "";
01053                 var theLocation = URL + add_act + add_mode + add_href + add_target + add_class + add_title + add_params'.($addPassOnParams?'+"'.$addPassOnParams.'"':'').'+(anchor?anchor:"");
01054                 window.location.href = theLocation;
01055                 return false;
01056             }
01057         ';
01058 
01059 
01060         /**
01061          * Splits parts of $this->bparams
01062          * @see $bparams
01063          */
01064         $pArr = explode('|',$this->bparams);
01065 
01066             // This is JavaScript especially for the TBE Element Browser!
01067         $formFieldName = 'data['.$pArr[0].']['.$pArr[1].']['.$pArr[2].']';
01068 
01069             // insertElement - Call check function (e.g. for uniqueness handling):
01070         if ($pArr[4] && $pArr[5]) {
01071             $JScodeCheck = '
01072                     // Call a check function in the opener window (e.g. for uniqueness handling):
01073                 if (parent.window.opener) {
01074                     var res = parent.window.opener.'.$pArr[5].'("'.addslashes($pArr[4]).'",table,uid,type);
01075                     if (!res.passed) {
01076                         if (res.message) alert(res.message);
01077                         performAction = false;
01078                     }
01079                 } else {
01080                     alert("Error - reference to main window is not set properly!");
01081                     parent.close();
01082                 }
01083             ';
01084         }
01085             // insertElement - Call helper function:
01086         if ($pArr[4] && $pArr[6]) {
01087             $JScodeHelper = '
01088                         // Call helper function to manage data in the opener window:
01089                     if (parent.window.opener) {
01090                         parent.window.opener.'.$pArr[6].'("'.addslashes($pArr[4]).'",table,uid,type,"'.addslashes($pArr[0]).'");
01091                     } else {
01092                         alert("Error - reference to main window is not set properly!");
01093                         parent.close();
01094                     }
01095             ';
01096         }
01097             // insertElement - perform action commands:
01098         if ($pArr[4] && $pArr[7]) {
01099                 // Call user defined action function:
01100             $JScodeAction = '
01101                     if (parent.window.opener) {
01102                         parent.window.opener.'.$pArr[7].'("'.addslashes($pArr[4]).'",table,uid,type);
01103                         focusOpenerAndClose(close);
01104                     } else {
01105                         alert("Error - reference to main window is not set properly!");
01106                         parent.close();
01107                     }
01108             ';
01109         } else if ($pArr[0] && !$pArr[1] && !$pArr[2]) {
01110             $JScodeAction = '
01111                     addElement(filename,table+"_"+uid,fp,close);
01112             ';
01113         } else {
01114             $JScodeAction = '
01115                     if (setReferences()) {
01116                         parent.window.opener.group_change("add","'.$pArr[0].'","'.$pArr[1].'","'.$pArr[2].'",elRef,targetDoc);
01117                     } else {
01118                         alert("Error - reference to main window is not set properly!");
01119                     }
01120                     focusOpenerAndClose(close);
01121             ';
01122         }
01123 
01124         $JScode.='
01125             var elRef="";
01126             var targetDoc="";
01127 
01128             function launchView(url)    {   //
01129                 var thePreviewWindow="";
01130                 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");
01131                 if (thePreviewWindow && thePreviewWindow.focus) {
01132                     thePreviewWindow.focus();
01133                 }
01134             }
01135             function setReferences()    {   //
01136                 if (parent.window.opener && parent.window.opener.content && parent.window.opener.content.document.editform && parent.window.opener.content.document.editform["'.$formFieldName.'"]) {
01137                     targetDoc = parent.window.opener.content.document;
01138                     elRef = targetDoc.editform["'.$formFieldName.'"];
01139                     return true;
01140                 } else {
01141                     return false;
01142                 }
01143             }
01144             function insertElement(table, uid, type, filename,fp,filetype,imagefile,action, close)  {   //
01145                 var performAction = true;
01146                 '.$JScodeCheck.'
01147                     // Call performing function and finish this action:
01148                 if (performAction) {
01149                         '.$JScodeHelper.$JScodeAction.'
01150                 }
01151                 return false;
01152             }
01153             function addElement(elName,elValue,altElValue,close)    {   //
01154                 if (parent.window.opener && parent.window.opener.setFormValueFromBrowseWin) {
01155                     parent.window.opener.setFormValueFromBrowseWin("'.$pArr[0].'",altElValue?altElValue:elValue,elName);
01156                     focusOpenerAndClose(close);
01157                 } else {
01158                     alert("Error - reference to main window is not set properly!");
01159                     parent.close();
01160                 }
01161             }
01162             function focusOpenerAndClose(close) {   //
01163                 BrowseLinks.focusOpenerAndClose(close);
01164             }
01165         ';
01166 
01167             // Finally, add the accumulated JavaScript to the template object:
01168         $this->doc->JScode.= $this->doc->wrapScriptTags($JScode);
01169 
01170             // Debugging:
01171         if (FALSE) debug(array(
01172             'pointer' => $this->pointer,
01173             'act' => $this->act,
01174             'mode' => $this->mode,
01175             'curUrlInfo' => $this->curUrlInfo,
01176             'curUrlArray' => $this->curUrlArray,
01177             'P' => $this->P,
01178             'bparams' => $this->bparams,
01179             'RTEtsConfigParams' => $this->RTEtsConfigParams,
01180             'expandPage' => $this->expandPage,
01181             'expandFolder' => $this->expandFolder,
01182             'PM' => $this->PM,
01183         ),'Internal variables of Script Class:');
01184     }
01185 
01186 
01187     /**
01188      * Session data for this class can be set from outside with this method.
01189      * Call after init()
01190      *
01191      * @param   array       Session data array
01192      * @return  array       Session data and boolean which indicates that data needs to be stored in session because it's changed
01193      */
01194     function processSessionData($data) {
01195         $store = false;
01196 
01197         switch((string)$this->mode) {
01198             case 'db':
01199                 if (isset($this->expandPage))   {
01200                     $data['expandPage']=$this->expandPage;
01201                     $store = true;
01202                 } else {
01203                     $this->expandPage=$data['expandPage'];
01204                 }
01205             break;
01206             case 'file':
01207             case 'filedrag':
01208             case 'folder':
01209                 if (isset($this->expandFolder)) {
01210                     $data['expandFolder']=$this->expandFolder;
01211                     $store = true;
01212                 } else {
01213                     $this->expandFolder=$data['expandFolder'];
01214                 }
01215             break;
01216         }
01217 
01218         return array($data, $store);
01219     }
01220 
01221 
01222 
01223 
01224     /******************************************************************
01225      *
01226      * Main functions
01227      *
01228      ******************************************************************/
01229 
01230     /**
01231      * Rich Text Editor (RTE) link selector (MAIN function)
01232      * Generates the link selector for the Rich Text Editor.
01233      * Can also be used to select links for the TCEforms (see $wiz)
01234      *
01235      * @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
01236      * @return  string      Modified content variable.
01237      */
01238     function main_rte($wiz=0)   {
01239         global $LANG, $BACK_PATH;
01240 
01241             // Starting content:
01242         $content=$this->doc->startPage('RTE link');
01243 
01244             // Initializing the action value, possibly removing blinded values etc:
01245         $allowedItems = array_diff(
01246             explode(',','page,file,folder,url,mail,spec'),
01247             t3lib_div::trimExplode(',',$this->thisConfig['blindLinkOptions'],1)
01248         );
01249         $allowedItems = array_diff(
01250             $allowedItems,
01251             t3lib_div::trimExplode(',',$this->P['params']['blindLinkOptions'])
01252         );
01253 
01254             //call hook for extra options
01255         foreach($this->hookObjects as $hookObject) {
01256             $allowedItems = $hookObject->addAllowedItems($allowedItems);
01257         }
01258 
01259         reset($allowedItems);
01260         if (!in_array($this->act,$allowedItems))    $this->act = current($allowedItems);
01261 
01262             // Making menu in top:
01263         $menuDef = array();
01264         if (!$wiz)  {
01265             $menuDef['removeLink']['isActive'] = $this->act=='removeLink';
01266             $menuDef['removeLink']['label'] = $LANG->getLL('removeLink',1);
01267             $menuDef['removeLink']['url'] = '#';
01268             $menuDef['removeLink']['addParams'] = 'onclick="self.parent.parent.renderPopup_unLink();return false;"';
01269         }
01270         if (in_array('page',$allowedItems)) {
01271             $menuDef['page']['isActive'] = $this->act=='page';
01272             $menuDef['page']['label'] = $LANG->getLL('page',1);
01273             $menuDef['page']['url'] = '#';
01274             $menuDef['page']['addParams'] = 'onclick="jumpToUrl(\'?act=page\');return false;"';
01275         }
01276         if (in_array('file',$allowedItems)){
01277             $menuDef['file']['isActive'] = $this->act=='file';
01278             $menuDef['file']['label'] = $LANG->getLL('file',1);
01279             $menuDef['file']['url'] = '#';
01280             $menuDef['file']['addParams'] = 'onclick="jumpToUrl(\'?act=file\');return false;"';
01281         }
01282         if (in_array('folder',$allowedItems)){
01283             $menuDef['folder']['isActive']  = $this->act == 'folder';
01284             $menuDef['folder']['label']     = $LANG->getLL('folder', 1);
01285             $menuDef['folder']['url']       = '#';
01286             $menuDef['folder']['addParams'] = 'onclick="jumpToUrl(\'?act=folder\');return false;"';
01287         }
01288         if (in_array('url',$allowedItems)) {
01289             $menuDef['url']['isActive'] = $this->act=='url';
01290             $menuDef['url']['label'] = $LANG->getLL('extUrl',1);
01291             $menuDef['url']['url'] = '#';
01292             $menuDef['url']['addParams'] = 'onclick="jumpToUrl(\'?act=url\');return false;"';
01293         }
01294         if (in_array('mail',$allowedItems)) {
01295             $menuDef['mail']['isActive'] = $this->act=='mail';
01296             $menuDef['mail']['label'] = $LANG->getLL('email',1);
01297             $menuDef['mail']['url'] = '#';
01298             $menuDef['mail']['addParams'] = 'onclick="jumpToUrl(\'?act=mail\');return false;"';
01299         }
01300         if (is_array($this->thisConfig['userLinks.']) && in_array('spec',$allowedItems)) {
01301             $menuDef['spec']['isActive'] = $this->act=='spec';
01302             $menuDef['spec']['label'] = $LANG->getLL('special',1);
01303             $menuDef['spec']['url'] = '#';
01304             $menuDef['spec']['addParams'] = 'onclick="jumpToUrl(\'?act=spec\');return false;"';
01305         }
01306 
01307             // call hook for extra options
01308         foreach($this->hookObjects as $hookObject) {
01309             $menuDef = $hookObject->modifyMenuDefinition($menuDef);
01310         }
01311 
01312         $content .= $this->doc->getTabMenuRaw($menuDef);
01313 
01314             // Adding the menu and header to the top of page:
01315         $content.=$this->printCurrentUrl($this->curUrlInfo['info']).'<br />';
01316 
01317             // Depending on the current action we will create the actual module content for selecting a link:
01318         switch($this->act)  {
01319             case 'mail':
01320                 $extUrl='
01321 
01322             <!--
01323                 Enter mail address:
01324             -->
01325                     <form action="" name="lurlform" id="lurlform">
01326                         <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkMail">
01327                             <tr>
01328                                 <td style="width: 96px;">' . $GLOBALS['LANG']->getLL('emailAddress', 1) . ':</td>
01329                                 <td><input type="text" name="lemail"'.$this->doc->formWidth(20).' value="'.htmlspecialchars($this->curUrlInfo['act']=='mail'?$this->curUrlInfo['info']:'').'" /> '.
01330                                     '<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>
01331                             </tr>
01332                         </table>
01333                     </form>';
01334                 $content.=$extUrl;
01335             break;
01336             case 'url':
01337                 $extUrl='
01338 
01339             <!--
01340                 Enter External URL:
01341             -->
01342                     <form action="" name="lurlform" id="lurlform">
01343                         <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkURL">
01344                             <tr>
01345                                 <td style="width: 96px;">URL:</td>
01346                                 <td><input type="text" name="lurl"'.$this->doc->formWidth(30).' value="'.htmlspecialchars($this->curUrlInfo['act']=='url'?$this->curUrlInfo['info']:'http://').'" /> '.
01347                                     '<input type="submit" value="' . $GLOBALS['LANG']->getLL('setLink', 1) . '" onclick="browse_links_setValue(document.lurlform.lurl.value); return link_current();" /></td>
01348                             </tr>
01349                         </table>
01350                     </form>';
01351                 $content.=$extUrl;
01352             break;
01353             case 'file':
01354             case 'folder':
01355                 $foldertree             = t3lib_div::makeInstance('rteFolderTree');
01356                 $foldertree->thisScript = $this->thisScript;
01357                 $tree                   = $foldertree->getBrowsableTree();
01358 
01359                 if (!$this->curUrlInfo['value'] || $this->curUrlInfo['act'] != $this->act)  {
01360                     $cmpPath = '';
01361                 } elseif (substr(trim($this->curUrlInfo['info']), -1) != '/')   {
01362                     $cmpPath = PATH_site.dirname($this->curUrlInfo['info']).'/';
01363                     if (!isset($this->expandFolder)) {
01364                         $this->expandFolder = $cmpPath;
01365                     }
01366                 } else {
01367                     $cmpPath = PATH_site.$this->curUrlInfo['info'];
01368                     if (!isset($this->expandFolder) && $this->curUrlInfo['act'] == 'folder') {
01369                         $this->expandFolder = $cmpPath;
01370                     }
01371                 }
01372 
01373                 list(, , $specUid) = explode('_', $this->PM);
01374                 $files = $this->expandFolder(
01375                     $foldertree->specUIDmap[$specUid],
01376                     $this->P['params']['allowedExtensions']
01377                 );
01378                 $content.= '
01379 
01380             <!--
01381                 Wrapper table for folder tree / file/folder list:
01382             -->
01383                     <table border="0" cellpadding="0" cellspacing="0" id="typo3-linkFiles">
01384                         <tr>
01385                             <td class="c-wCell" valign="top">'.$this->barheader($GLOBALS['LANG']->getLL('folderTree').':').$tree.'</td>
01386                             <td class="c-wCell" valign="top">'.$files.'</td>
01387                         </tr>
01388                     </table>
01389                     ';
01390             break;
01391             case 'spec':
01392                 if (is_array($this->thisConfig['userLinks.']))  {
01393                     $subcats=array();
01394                     $v=$this->thisConfig['userLinks.'];
01395                     foreach ($v as $k2 => $value) {
01396                         $k2i = intval($k2);
01397                         if (substr($k2,-1)=='.' && is_array($v[$k2i.'.']))  {
01398 
01399                                 // Title:
01400                             $title = trim($v[$k2i]);
01401                             if (!$title)    {
01402                                 $title=$v[$k2i.'.']['url'];
01403                             } else {
01404                                 $title=$LANG->sL($title);
01405                             }
01406                                 // Description:
01407                             $description=$v[$k2i.'.']['description'] ? $LANG->sL($v[$k2i.'.']['description'],1).'<br />' : '';
01408 
01409                                 // URL + onclick event:
01410                             $onClickEvent='';
01411                             if (isset($v[$k2i.'.']['target']))  $onClickEvent.="browse_links_setTarget('".$v[$k2i.'.']['target']."');";
01412                             $v[$k2i.'.']['url'] = str_replace('###_URL###',$this->siteURL,$v[$k2i.'.']['url']);
01413                             if (substr($v[$k2i.'.']['url'],0,7)=='http://' || substr($v[$k2i.'.']['url'],0,7)=='mailto:')   {
01414                                 $onClickEvent.="cur_href=unescape('".rawurlencode($v[$k2i.'.']['url'])."');link_current();";
01415                             } else {
01416                                 $onClickEvent.="link_spec(unescape('".$this->siteURL.rawurlencode($v[$k2i.'.']['url'])."'));";
01417                             }
01418 
01419                                 // Link:
01420                             $A=array('<a href="#" onclick="'.htmlspecialchars($onClickEvent).'return false;">','</a>');
01421 
01422                                 // Adding link to menu of user defined links:
01423                             $subcats[$k2i]='
01424                                 <tr>
01425                                     <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>
01426                                 </tr>';
01427                         }
01428                     }
01429 
01430                         // Sort by keys:
01431                     ksort($subcats);
01432 
01433                         // Add menu to content:
01434                     $content.= '
01435 
01436             <!--
01437                 Special userdefined menu:
01438             -->
01439                         <table border="0" cellpadding="1" cellspacing="1" id="typo3-linkSpecial">
01440                             <tr>
01441                                 <td class="bgColor5" class="c-wCell" valign="top"><strong>'.$LANG->getLL('special',1).'</strong></td>
01442                             </tr>
01443                             '.implode('',$subcats).'
01444                         </table>
01445                         ';
01446                 }
01447             break;
01448             case 'page':
01449                 $pagetree = t3lib_div::makeInstance('rtePageTree');
01450                 $pagetree->thisScript = $this->thisScript;
01451                 $pagetree->ext_showPageId = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showPageIdWithTitle');
01452                 $pagetree->ext_showNavTitle = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showNavTitle');
01453                 $pagetree->addField('nav_title');
01454                 $tree=$pagetree->getBrowsableTree();
01455                 $cElements = $this->expandPage();
01456 
01457                 // Outputting Temporary DB mount notice:
01458                 if (intval($GLOBALS['BE_USER']->getSessionData('pageTree_temporaryMountPoint')))    {
01459                     $link = '<a href="' . htmlspecialchars(t3lib_div::linkThisScript(array('setTempDBmount' => 0))) . '">' .
01460                                         $LANG->sl('LLL:EXT:lang/locallang_core.xml:labels.temporaryDBmount', 1) .
01461                                     '</a>';
01462                     $flashMessage = t3lib_div::makeInstance(
01463                         't3lib_FlashMessage',
01464                         $link,
01465                         '',
01466                         t3lib_FlashMessage::INFO
01467                     );
01468                     $dbmount = $flashMessage->render();
01469                 }
01470 
01471                 $content.= '
01472 
01473             <!--
01474                 Wrapper table for page tree / record list:
01475             -->
01476                     <table border="0" cellpadding="0" cellspacing="0" id="typo3-linkPages">
01477                         <tr>
01478                             <td class="c-wCell" valign="top">' . $this->barheader($GLOBALS['LANG']->getLL('pageTree') . ':') . $dbmount . $tree . '</td>
01479                             <td class="c-wCell" valign="top">'.$cElements.'</td>
01480                         </tr>
01481                     </table>
01482                     ';
01483             break;
01484             default:
01485                     //call hook
01486                 foreach($this->hookObjects as $hookObject) {
01487                     $content .= $hookObject->getTab($this->act);
01488                 }
01489             break;
01490         }
01491 
01492         $content .= '
01493             <!--
01494                 Selecting params for link:
01495             -->
01496                 <form action="" name="lparamsform" id="lparamsform">
01497                     <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkParams">
01498                         <tr>
01499                             <td style="width: 96px;">' . $GLOBALS['LANG']->getLL('params', 1) . '</td>
01500                             <td><input type="text" name="lparams" class="typo3-link-input" onchange="browse_links_setParams(this.value);" value="' . htmlspecialchars($this->setParams) . '" /></td>
01501                         </tr>
01502                     </table>
01503                 </form>
01504 
01505             <!--
01506                 Selecting class for link:
01507             -->
01508                 <form action="" name="lclassform" id="lclassform">
01509                     <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkClass">
01510                         <tr>
01511                             <td style="width: 96px;">' . $GLOBALS['LANG']->getLL('class', 1) . '</td>
01512                             <td><input type="text" name="lclass" class="typo3-link-input" onchange="browse_links_setClass(this.value);" value="' . htmlspecialchars($this->setClass) . '" /></td>
01513                         </tr>
01514                     </table>
01515                 </form>
01516 
01517             <!--
01518                 Selecting title for link:
01519             -->
01520                 <form action="" name="ltitleform" id="ltitleform">
01521                     <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkTitle">
01522                         <tr>
01523                             <td style="width: 96px;">' . $GLOBALS['LANG']->getLL('title', 1) . '</td>
01524                             <td><input type="text" name="ltitle" class="typo3-link-input" onchange="browse_links_setTitle(this.value);" value="' . htmlspecialchars($this->setTitle) . '" /></td>
01525                         </tr>
01526                     </table>
01527                 </form>
01528 ';
01529 
01530             // Target:
01531         if ($this->act!='mail') {
01532             $ltarget='
01533 
01534 
01535 
01536             <!--
01537                 Selecting target for link:
01538             -->
01539                 <form action="" name="ltargetform" id="ltargetform">
01540                     <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkTarget">
01541                         <tr>
01542                             <td>'.$GLOBALS['LANG']->getLL('target',1).':</td>
01543                             <td><input type="text" name="ltarget" onchange="browse_links_setTarget(this.value);" value="' . htmlspecialchars($this->setTarget) . '"' . $this->doc->formWidth(10) . ' /></td>
01544                             <td>
01545                                 <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;">
01546                                     <option></option>
01547                                     <option value="_top">'.$GLOBALS['LANG']->getLL('top',1).'</option>
01548                                     <option value="_blank">'.$GLOBALS['LANG']->getLL('newWindow',1).'</option>
01549                                 </select>
01550                             </td>
01551                             <td>';
01552             if (($this->curUrlInfo['act'] == 'page' || $this->curUrlInfo['act'] == 'file' || $this->curUrlInfo['act'] == 'folder') && $this->curUrlArray['href'] && $this->curUrlInfo['act'] == $this->act) {
01553                 $ltarget.='
01554                             <input type="submit" value="'.$GLOBALS['LANG']->getLL('update',1).'" onclick="return link_current();" />';
01555             }
01556 
01557             $selectJS = '
01558                 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) {
01559                     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;
01560                     browse_links_setTarget(document.ltargetform.ltarget.value);
01561                     browse_links_setClass(document.lclassform.lclass.value);
01562                     browse_links_setTitle(document.ltitleform.ltitle.value);
01563                     browse_links_setParams(document.lparamsform.lparams.value);
01564                     document.ltargetform.popup_width.selectedIndex=0;
01565                     document.ltargetform.popup_height.selectedIndex=0;
01566                 }
01567             ';
01568 
01569             $ltarget.='     </td>
01570                         </tr>
01571                         <tr>
01572                             <td>'.$GLOBALS['LANG']->getLL('target_popUpWindow',1).':</td>
01573                             <td colspan="3">
01574                                 <select name="popup_width" onchange="'.htmlspecialchars($selectJS).'">
01575                                     <option value="0">'.$GLOBALS['LANG']->getLL('target_popUpWindow_width',1).'</option>
01576                                     <option value="300">300</option>
01577                                     <option value="400">400</option>
01578                                     <option value="500">500</option>
01579                                     <option value="600">600</option>
01580                                     <option value="700">700</option>
01581                                     <option value="800">800</option>
01582                                 </select>
01583                                 x
01584                                 <select name="popup_height" onchange="'.htmlspecialchars($selectJS).'">
01585                                     <option value="0">'.$GLOBALS['LANG']->getLL('target_popUpWindow_height',1).'</option>
01586                                     <option value="200">200</option>
01587                                     <option value="300">300</option>
01588                                     <option value="400">400</option>
01589                                     <option value="500">500</option>
01590                                     <option value="600">600</option>
01591                                 </select>
01592                             </td>
01593                         </tr>
01594                     </table>
01595                 </form>';
01596 
01597                 // Add "target selector" box to content:
01598             $content.=$ltarget;
01599 
01600                 // Add some space
01601             $content.='<br /><br />';
01602         }
01603 
01604             // End page, return content:
01605         $content.= $this->doc->endPage();
01606         $content = $this->doc->insertStylesAndJS($content);
01607         return $content;
01608     }
01609 
01610     /**
01611      * TYPO3 Element Browser: Showing a page tree and allows you to browse for records
01612      *
01613      * @return  string      HTML content for the module
01614      */
01615     function main_db()  {
01616 
01617             // Starting content:
01618         $content=$this->doc->startPage('TBE record selector');
01619 
01620             // Init variable:
01621         $pArr = explode('|',$this->bparams);
01622 
01623             // Making the browsable pagetree:
01624         $pagetree = t3lib_div::makeInstance('TBE_PageTree');
01625         $pagetree->thisScript=$this->thisScript;
01626         $pagetree->ext_pArrPages = !strcmp($pArr[3],'pages')?1:0;
01627         $pagetree->ext_showNavTitle = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showNavTitle');
01628         $pagetree->ext_showPageId = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showPageIdWithTitle');
01629         $pagetree->addField('nav_title');
01630         $tree=$pagetree->getBrowsableTree();
01631 
01632             // Making the list of elements, if applicable:
01633         $cElements = $this->TBE_expandPage($pArr[3]);
01634 
01635             // Putting the things together, side by side:
01636         $content.= '
01637 
01638             <!--
01639                 Wrapper table for page tree / record list:
01640             -->
01641             <table border="0" cellpadding="0" cellspacing="0" id="typo3-EBrecords">
01642                 <tr>
01643                     <td class="c-wCell" valign="top">'.$this->barheader($GLOBALS['LANG']->getLL('pageTree').':').$tree.'</td>
01644                     <td class="c-wCell" valign="top">'.$cElements.'</td>
01645                 </tr>
01646             </table>
01647             ';
01648 
01649             // Add some space
01650         $content.='<br /><br />';
01651 
01652             // End page, return content:
01653         $content.= $this->doc->endPage();
01654         $content = $this->doc->insertStylesAndJS($content);
01655         return $content;
01656     }
01657 
01658     /**
01659      * TYPO3 Element Browser: Showing a folder tree, allowing you to browse for files.
01660      *
01661      * @return  string      HTML content for the module
01662      */
01663     function main_file()    {
01664         global $BE_USER;
01665 
01666             // Starting content:
01667         $content.=$this->doc->startPage('TBE file selector');
01668 
01669             // Init variable:
01670         $pArr = explode('|',$this->bparams);
01671 
01672             // Create upload/create folder forms, if a path is given:
01673         $path=$this->expandFolder;
01674         if (!$path || !@is_dir($path))  {
01675                 // The closest TEMP-path is found
01676             $path = $this->fileProcessor->findTempFolder().'/';
01677         }
01678         if ($path!='/' && @is_dir($path)) {
01679             $uploadForm=$this->uploadForm($path);
01680             $createFolder=$this->createFolder($path);
01681         } else {
01682             $createFolder='';
01683             $uploadForm='';
01684         }
01685         if ($BE_USER->getTSConfigVal('options.uploadFieldsInTopOfEB'))  $content.=$uploadForm;
01686 
01687             // Getting flag for showing/not showing thumbnails:
01688         $noThumbs = $GLOBALS['BE_USER']->getTSConfigVal('options.noThumbsInEB');
01689 
01690         if (!$noThumbs) {
01691                 // MENU-ITEMS, fetching the setting for thumbnails from File>List module:
01692             $_MOD_MENU = array('displayThumbs' => '');
01693             $_MCONF['name']='file_list';
01694             $_MOD_SETTINGS = t3lib_BEfunc::getModuleData($_MOD_MENU, t3lib_div::_GP('SET'), $_MCONF['name']);
01695             $addParams = '&act='.$this->act.'&mode='.$this->mode.'&expandFolder='.rawurlencode($path).'&bparams='.rawurlencode($this->bparams);
01696             $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>';
01697         } else {
01698             $thumbNailCheck='';
01699         }
01700         $noThumbs = $noThumbs ? $noThumbs : !$_MOD_SETTINGS['displayThumbs'];
01701 
01702             // Create folder tree:
01703         $foldertree = t3lib_div::makeInstance('TBE_FolderTree');
01704         $foldertree->thisScript=$this->thisScript;
01705         $foldertree->ext_noTempRecyclerDirs = ($this->mode == 'filedrag');
01706         $tree=$foldertree->getBrowsableTree();
01707 
01708         list(,,$specUid) = explode('_',$this->PM);
01709 
01710         if ($this->mode=='filedrag')    {
01711             $files = $this->TBE_dragNDrop($foldertree->specUIDmap[$specUid],$pArr[3]);
01712         } else {
01713             $files = $this->TBE_expandFolder($foldertree->specUIDmap[$specUid],$pArr[3],$noThumbs);
01714         }
01715 
01716             // Putting the parts together, side by side:
01717         $content.= '
01718 
01719             <!--
01720                 Wrapper table for folder tree / file list:
01721             -->
01722             <table border="0" cellpadding="0" cellspacing="0" id="typo3-EBfiles">
01723                 <tr>
01724                     <td class="c-wCell" valign="top">'.$this->barheader($GLOBALS['LANG']->getLL('folderTree').':').$tree.'</td>
01725                     <td class="c-wCell" valign="top">'.$files.'</td>
01726                 </tr>
01727             </table>
01728             ';
01729         $content.= $thumbNailCheck;
01730 
01731             // Adding create folder + upload forms if applicable:
01732         if (!$BE_USER->getTSConfigVal('options.uploadFieldsInTopOfEB')) $content.=$uploadForm;
01733         if ($BE_USER->isAdmin() || $BE_USER->getTSConfigVal('options.createFoldersInEB'))   $content.=$createFolder;
01734 
01735             // Add some space
01736         $content.='<br /><br />';
01737 
01738             // Setup indexed elements:
01739         $this->doc->JScode.= $this->doc->wrapScriptTags('BrowseLinks.addElements(' . json_encode($this->elements) . ');');
01740             // Ending page, returning content:
01741         $content.= $this->doc->endPage();
01742         $content = $this->doc->insertStylesAndJS($content);
01743 
01744         return $content;
01745     }
01746 
01747     /**
01748      * TYPO3 Element Browser: Showing a folder tree, allowing you to browse for folders.
01749      *
01750      * @return  string      HTML content for the module
01751      */
01752     function main_folder() {
01753         global $BE_USER;
01754 
01755             // Starting content:
01756         $content = $this->doc->startPage('TBE folder selector');
01757 
01758             // Init variable:
01759         $parameters = explode('|', $this->bparams);
01760 
01761 
01762         $path = $this->expandFolder;
01763         if (!$path || !@is_dir($path)) {
01764                 // The closest TEMP-path is found
01765             $path = $this->fileProcessor->findTempFolder().'/';
01766         }
01767         if ($path != '/' && @is_dir($path)) {
01768             $createFolder = $this->createFolder($path);
01769         } else {
01770             $createFolder='';
01771         }
01772 
01773             // Create folder tree:
01774         $foldertree                         = t3lib_div::makeInstance('TBE_FolderTree');
01775         $foldertree->thisScript             = $this->thisScript;
01776         $foldertree->ext_noTempRecyclerDirs = ($this->mode == 'filedrag');
01777         $tree                                = $foldertree->getBrowsableTree(false);
01778 
01779         list(, , $specUid) = explode('_', $this->PM);
01780 
01781         if($this->mode == 'filedrag') {
01782             $folders = $this->TBE_dragNDrop(
01783                 $foldertree->specUIDmap[$specUid],
01784                 $parameters[3]
01785             );
01786         } else {
01787             $folders = $this->TBE_expandSubFolders($foldertree->specUIDmap[$specUid]);
01788         }
01789 
01790             // Putting the parts together, side by side:
01791         $content.= '
01792 
01793             <!--
01794                 Wrapper table for folder tree / folder list:
01795             -->
01796             <table border="0" cellpadding="0" cellspacing="0" id="typo3-EBfiles">
01797                 <tr>
01798                     <td class="c-wCell" valign="top">'.$this->barheader($GLOBALS['LANG']->getLL('folderTree').':').$tree.'</td>
01799                     <td class="c-wCell" valign="top">'.$folders.'</td>
01800                 </tr>
01801             </table>
01802             ';
01803 
01804             // Adding create folder if applicable:
01805         if($BE_USER->isAdmin() || $BE_USER->getTSConfigVal('options.createFoldersInEB')) {
01806             $content .= $createFolder;
01807         }
01808 
01809             // Add some space
01810         $content .= '<br /><br />';
01811 
01812             // Ending page, returning content:
01813         $content.= $this->doc->endPage();
01814         $content = $this->doc->insertStylesAndJS($content);
01815 
01816         return $content;
01817     }
01818 
01819 
01820 
01821 
01822 
01823 
01824 
01825 
01826 
01827 
01828 
01829 
01830 
01831 
01832 
01833 
01834 
01835     /******************************************************************
01836      *
01837      * Record listing
01838      *
01839      ******************************************************************/
01840     /**
01841      * For RTE: This displays all content elements on a page and lets you create a link to the element.
01842      *
01843      * @return  string      HTML output. Returns content only if the ->expandPage value is set (pointing to a page uid to show tt_content records from ...)
01844      */
01845     function expandPage()   {
01846         global $BE_USER, $BACK_PATH;
01847 
01848         $out='';
01849         $expPageId = $this->expandPage;     // Set page id (if any) to expand
01850 
01851             // If there is an anchor value (content element reference) in the element reference, then force an ID to expand:
01852         if (!$this->expandPage && $this->curUrlInfo['cElement'])    {
01853             $expPageId = $this->curUrlInfo['pageid'];   // Set to the current link page id.
01854         }
01855 
01856             // Draw the record list IF there is a page id to expand:
01857         if ($expPageId && t3lib_div::testInt($expPageId) && $BE_USER->isInWebMount($expPageId)) {
01858 
01859                 // Set header:
01860             $out.=$this->barheader($GLOBALS['LANG']->getLL('contentElements').':');
01861 
01862                 // Create header for listing, showing the page title/icon:
01863             $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
01864             $mainPageRec = t3lib_BEfunc::getRecordWSOL('pages',$expPageId);
01865             $picon = t3lib_iconWorks::getSpriteIconForRecord('pages', $mainPageRec);
01866             $picon .= t3lib_BEfunc::getRecordTitle('pages', $mainPageRec, TRUE);
01867             $out.=$picon.'<br />';
01868 
01869                 // Look up tt_content elements from the expanded page:
01870             $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
01871                             'uid,header,hidden,starttime,endtime,fe_group,CType,colpos,bodytext',
01872                             'tt_content',
01873                             'pid='.intval($expPageId).
01874                                 t3lib_BEfunc::deleteClause('tt_content').
01875                                 t3lib_BEfunc::versioningPlaceholderClause('tt_content'),
01876                             '',
01877                             'colpos,sorting'
01878                         );
01879             $cc = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
01880 
01881                 // Traverse list of records:
01882             $c=0;
01883             while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))   {
01884                 $c++;
01885                 $icon = t3lib_iconWorks::getSpriteIconForRecord('tt_content', $row);
01886                 if ($this->curUrlInfo['act']=='page' && $this->curUrlInfo['cElement']==$row['uid']) {
01887                     $arrCol='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/blinkarrow_left.gif','width="5" height="9"').' class="c-blinkArrowL" alt="" />';
01888                 } else {
01889                     $arrCol='';
01890                 }
01891                     // Putting list element HTML together:
01892                 $out.='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/join'.($c==$cc?'bottom':'').'.gif','width="18" height="16"').' alt="" />'.
01893                         $arrCol.
01894                         '<a href="#" onclick="return link_typo3Page(\''.$expPageId.'\',\'#'.$row['uid'].'\');">'.
01895                         $icon.
01896                         t3lib_BEfunc::getRecordTitle('tt_content', $row, TRUE) .
01897                         '</a><br />';
01898 
01899                     // Finding internal anchor points:
01900                 if (t3lib_div::inList('text,textpic', $row['CType']))   {
01901                     $split = preg_split('/(<a[^>]+name=[\'"]?([^"\'>[:space:]]+)[\'"]?[^>]*>)/i', $row['bodytext'], -1, PREG_SPLIT_DELIM_CAPTURE);
01902 
01903                     foreach($split as $skey => $sval)   {
01904                         if (($skey%3)==2)   {
01905                                 // Putting list element HTML together:
01906                             $sval = substr($sval,0,100);
01907                             $out.='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/line.gif','width="18" height="16"').' alt="" />'.
01908                                     '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/join'.($skey+3>count($split)?'bottom':'').'.gif','width="18" height="16"').' alt="" />'.
01909                                     '<a href="#" onclick="return link_typo3Page(\''.$expPageId.'\',\'#'.rawurlencode($sval).'\');">'.
01910                                     htmlspecialchars(' <A> '.$sval).
01911                                     '</a><br />';
01912                         }
01913                     }
01914                 }
01915             }
01916         }
01917         return $out;
01918     }
01919 
01920     /**
01921      * For TYPO3 Element Browser: This lists all content elements from the given list of tables
01922      *
01923      * @param   string      Commalist of tables. Set to "*" if you want all tables.
01924      * @return  string      HTML output.
01925      */
01926     function TBE_expandPage($tables)    {
01927         global $TCA,$BE_USER, $BACK_PATH;
01928 
01929         $out='';
01930         if ($this->expandPage>=0 && t3lib_div::testInt($this->expandPage) && $BE_USER->isInWebMount($this->expandPage)) {
01931 
01932                 // Set array with table names to list:
01933             if (!strcmp(trim($tables),'*')) {
01934                 $tablesArr = array_keys($TCA);
01935             } else {
01936                 $tablesArr = t3lib_div::trimExplode(',',$tables,1);
01937             }
01938             reset($tablesArr);
01939 
01940                 // Headline for selecting records:
01941             $out.=$this->barheader($GLOBALS['LANG']->getLL('selectRecords').':');
01942 
01943                 // Create the header, showing the current page for which the listing is. Includes link to the page itself, if pages are amount allowed tables.
01944             $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
01945             $mainPageRec = t3lib_BEfunc::getRecordWSOL('pages',$this->expandPage);
01946             $ATag='';
01947             $ATag_e='';
01948             $ATag2='';
01949             $picon = '';
01950             if (is_array($mainPageRec)) {
01951                 $picon = t3lib_iconWorks::getSpriteIconForRecord('pages', $mainPageRec);
01952                 if (in_array('pages', $tablesArr)) {
01953                     $ATag = "<a href=\"#\" onclick=\"return insertElement('pages', '" . $mainPageRec['uid'] .
01954                         "', 'db', " . t3lib_div::quoteJSvalue($mainPageRec['title']) . ", '', '', '','',1);\">";
01955                     $ATag2 = "<a href=\"#\" onclick=\"return insertElement('pages', '" . $mainPageRec['uid'] .
01956                         "', 'db', " . t3lib_div::quoteJSvalue($mainPageRec['title']) . ", '', '', '','',0);\">";
01957                     $ATag_alt = substr($ATag, 0, -4) . ",'',1);\">";
01958                     $ATag_e = '</a>';
01959                 }
01960             }
01961             $pBicon=$ATag2?'<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/plusbullet2.gif','width="18" height="16"').' alt="" />':'';
01962             $pText=htmlspecialchars(t3lib_div::fixed_lgd_cs($mainPageRec['title'],$titleLen));
01963             $out.=$picon.$ATag2.$pBicon.$ATag_e.$ATag.$pText.$ATag_e.'<br />';
01964 
01965                 // Initialize the record listing:
01966             $id = $this->expandPage;
01967             $pointer = t3lib_div::intInRange($this->pointer,0,100000);
01968             $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
01969             $pageinfo = t3lib_BEfunc::readPageAccess($id,$perms_clause);
01970             $table='';
01971 
01972                 // Generate the record list:
01973             $dblist = t3lib_div::makeInstance('TBE_browser_recordList');
01974             $dblist->thisScript=$this->thisScript;
01975             $dblist->backPath = $GLOBALS['BACK_PATH'];
01976             $dblist->thumbs = 0;
01977             $dblist->calcPerms = $GLOBALS['BE_USER']->calcPerms($pageinfo);
01978             $dblist->noControlPanels=1;
01979             $dblist->clickMenuEnabled=0;
01980             $dblist->tableList=implode(',',$tablesArr);
01981 
01982             $dblist->start($id,t3lib_div::_GP('table'),$pointer,
01983                 t3lib_div::_GP('search_field'),
01984                 t3lib_div::_GP('search_levels'),
01985                 t3lib_div::_GP('showLimit')
01986             );
01987             $dblist->setDispFields();
01988             $dblist->generateList();
01989             $dblist->writeBottom();
01990 
01991                 //  Add the HTML for the record list to output variable:
01992             $out.=$dblist->HTMLcode;
01993 
01994                 // Add support for fieldselectbox in singleTableMode
01995             if ($dblist->table) {
01996                 $out.= $dblist->fieldSelectBox($dblist->table);
01997             }
01998 
01999             $out.=$dblist->getSearchBox();
02000         }
02001 
02002             // Return accumulated content:
02003         return $out;
02004     }
02005 
02006 
02007     /**
02008      * Render list of folders inside a folder.
02009      *
02010      * @param   string      string of the current folder
02011      * @return  string      HTML output
02012      */
02013     function TBE_expandSubFolders($expandFolder=0) {
02014         $content = '';
02015 
02016         $expandFolder = $expandFolder ?
02017             $expandFolder :
02018             $this->expandFolder;
02019 
02020         if($expandFolder && $this->checkFolder($expandFolder)) {
02021             if(t3lib_div::isFirstPartOfStr($expandFolder, PATH_site)) {
02022                 $rootFolder = substr($expandFolder, strlen(PATH_site));
02023             }
02024 
02025             $folders = array();
02026 
02027                 // Listing the folders:
02028             $folders = t3lib_div::get_dirs($expandFolder);
02029             if(count($folders) > 0) {
02030                 foreach($folders as $index => $folder) {
02031                     $folders[$index] = $rootFolder.$folder.'/';
02032                 }
02033             }
02034             $content.= $this->folderList($rootFolder, $folders);
02035         }
02036 
02037             // Return accumulated content for folderlisting:
02038         return $content;
02039     }
02040 
02041 
02042 
02043 
02044 
02045 
02046 
02047 
02048 
02049 
02050 
02051     /******************************************************************
02052      *
02053      * File listing
02054      *
02055      ******************************************************************/
02056     /**
02057      * For RTE: This displays all files from folder. No thumbnails shown
02058      *
02059      * @param   string      The folder path to expand
02060      * @param   string      List of fileextensions to show
02061      * @return  string      HTML output
02062      */
02063     function expandFolder($expandFolder=0,$extensionList='')    {
02064         global $BACK_PATH;
02065 
02066         $expandFolder = $expandFolder ? $expandFolder : $this->expandFolder;
02067         $out='';
02068         if ($expandFolder && $this->checkFolder($expandFolder)) {
02069 
02070                 // Create header for filelisting:
02071             $out.=$this->barheader($GLOBALS['LANG']->getLL('files').':');
02072 
02073                 // Prepare current path value for comparison (showing red arrow)
02074             if (!$this->curUrlInfo['value'])    {
02075                 $cmpPath='';
02076             } else {
02077                 $cmpPath=PATH_site.$this->curUrlInfo['info'];
02078             }
02079 
02080 
02081                 // Create header element; The folder from which files are listed.
02082             $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
02083             $picon='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/i/_icon_webfolders.gif','width="18" height="16"').' alt="" />';
02084             $picon.=htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($expandFolder),$titleLen));
02085             $picon='<a href="#" onclick="return link_folder(\''.t3lib_div::rawUrlEncodeFP(substr($expandFolder,strlen(PATH_site))).'\');">'.$picon.'</a>';
02086             if ($this->curUrlInfo['act'] == 'folder' && $cmpPath == $expandFolder)  {
02087                 $out.= '<img'.t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/blinkarrow_left.gif', 'width="5" height="9"') . ' class="c-blinkArrowL" alt="" />';
02088             }
02089             $out.=$picon.'<br />';
02090 
02091                 // Get files from the folder:
02092             if ($this->mode == 'wizard' && $this->act == 'folder') {
02093                 $files = t3lib_div::get_dirs($expandFolder);
02094             } else {
02095                 $files = t3lib_div::getFilesInDir($expandFolder, $extensionList, 1, 1); // $extensionList='', $prependPath=0, $order='')
02096             }
02097 
02098             $c=0;
02099             $cc=count($files);
02100             if (is_array($files))   {
02101                 foreach($files as $filepath)    {
02102                     $c++;
02103                     $fI=pathinfo($filepath);
02104 
02105                     if ($this->mode == 'wizard' && $this->act == 'folder') {
02106                         $filepath = $expandFolder.$filepath.'/';
02107                         $icon = '<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/i/_icon_webfolders.gif', 'width="18" height="16"') . ' alt="" />';
02108                     } else {
02109                             // File icon:
02110                         $icon = t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
02111 
02112                             // Get size and icon:
02113                         $size = ' (' . t3lib_div::formatSize(filesize($filepath)) . 'bytes)';
02114                         $icon = '<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/fileicons/' . $icon . '', 'width="18" height="16"') . ' title="' . htmlspecialchars($fI['basename'] . $size) . '" alt="" />';
02115                     }
02116 
02117                         // If the listed file turns out to be the CURRENT file, then show blinking arrow:
02118                     if (($this->curUrlInfo['act'] == 'file' || $this->curUrlInfo['act'] == 'folder') && $cmpPath == $filepath) {
02119                         $arrCol='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/blinkarrow_left.gif','width="5" height="9"').' class="c-blinkArrowL" alt="" />';
02120                     } else {
02121                         $arrCol='';
02122                     }
02123 
02124                         // Put it all together for the file element:
02125                     $out.='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/join'.($c==$cc?'bottom':'').'.gif','width="18" height="16"').' alt="" />'.
02126                             $arrCol.
02127                             '<a href="#" onclick="return link_folder(\''.t3lib_div::rawUrlEncodeFP(substr($filepath,strlen(PATH_site))).'\');">'.
02128                             $icon.
02129                             htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($filepath),$titleLen)).
02130                             '</a><br />';
02131                 }
02132             }
02133         }
02134         return $out;
02135     }
02136 
02137     /**
02138      * For TYPO3 Element Browser: Expand folder of files.
02139      *
02140      * @param   string      The folder path to expand
02141      * @param   string      List of fileextensions to show
02142      * @param   boolean     Whether to show thumbnails or not. If set, no thumbnails are shown.
02143      * @return  string      HTML output
02144      */
02145     function TBE_expandFolder($expandFolder=0,$extensionList='',$noThumbs=0)    {
02146         global $LANG;
02147 
02148         $extensionList = ($extensionList == '*') ? '' : $extensionList;
02149         $expandFolder = $expandFolder ? $expandFolder : $this->expandFolder;
02150         $out='';
02151         if ($expandFolder && $this->checkFolder($expandFolder)) {
02152                 // Listing the files:
02153             $files = t3lib_div::getFilesInDir($expandFolder,$extensionList,1,1);    // $extensionList="",$prependPath=0,$order='')
02154             $out.= $this->fileList($files, $expandFolder, $noThumbs);
02155         }
02156 
02157             // Return accumulated content for filelisting:
02158         return $out;
02159     }
02160 
02161     /**
02162      * Render list of files.
02163      *
02164      * @param   array       List of files. See t3lib_div::getFilesInDir
02165      * @param   string      If set a header with a folder icon and folder name are shown
02166      * @param   boolean     Whether to show thumbnails or not. If set, no thumbnails are shown.
02167      * @return  string      HTML output
02168      */
02169     function fileList($files, $folderName='', $noThumbs=0) {
02170         global $LANG, $BACK_PATH;
02171 
02172         $out='';
02173 
02174             // Listing the files:
02175         if (is_array($files))   {
02176 
02177                 // Create headline (showing number of files):
02178             $filesCount = count($files);
02179             $out.=$this->barheader(sprintf($GLOBALS['LANG']->getLL('files').' (%s):', $filesCount));
02180             $out.=$this->getBulkSelector($filesCount);
02181 
02182             $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
02183 
02184                 // Create the header of current folder:
02185             if($folderName) {
02186                 $picon='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/i/_icon_webfolders.gif','width="18" height="16"').' alt="" />';
02187                 $picon.=htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($folderName),$titleLen));
02188                 $out.=$picon.'<br />';
02189             }
02190 
02191                 // Init graphic object for reading file dimensions:
02192             $imgObj = t3lib_div::makeInstance('t3lib_stdGraphic');
02193             $imgObj->init();
02194             $imgObj->mayScaleUp=0;
02195             $imgObj->tempPath=PATH_site.$imgObj->tempPath;
02196 
02197                 // Traverse the file list:
02198             $lines=array();
02199             foreach($files as $filepath)    {
02200                 $fI=pathinfo($filepath);
02201 
02202                     // Thumbnail/size generation:
02203                 if (t3lib_div::inList(strtolower($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']),strtolower($fI['extension'])) && !$noThumbs)  {
02204                     $imgInfo = $imgObj->getImageDimensions($filepath);
02205                     $pDim = $imgInfo[0].'x'.$imgInfo[1].' pixels';
02206                     $clickIcon = t3lib_BEfunc::getThumbNail($BACK_PATH.'thumbs.php',$filepath,'hspace="5" vspace="5" border="1"');
02207                 } else {
02208                     $clickIcon = '';
02209                     $pDim = '';
02210                 }
02211 
02212                     // Create file icon:
02213                 $ficon = t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
02214                 $size=' ('.t3lib_div::formatSize(filesize($filepath)).'bytes'.($pDim?', '.$pDim:'').')';
02215                 $icon = '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/fileicons/'.$ficon,'width="18" height="16"').' title="'.htmlspecialchars($fI['basename'].$size).'" class="absmiddle" alt="" />';
02216 
02217                     // Create links for adding the file:
02218                 if (strstr($filepath,',') || strstr($filepath,'|')) {   // In case an invalid character is in the filepath, display error message:
02219                     $eMsg = $LANG->JScharCode(sprintf($LANG->getLL('invalidChar'),', |'));
02220                     $ATag = $ATag_alt = "<a href=\"#\" onclick=\"alert(".$eMsg.");return false;\">";
02221                     $bulkCheckBox = '';
02222                 } else {    // If filename is OK, just add it:
02223                     $filesIndex = count($this->elements);
02224                     $this->elements['file_'.$filesIndex] = array(
02225                         'md5' => t3lib_div::shortMD5($filepath),
02226                         'type' => 'file',
02227                         'fileName' => $fI['basename'],
02228                         'filePath' => $filepath,
02229                         'fileExt' => $fI['extension'],
02230                         'fileIcon' => $ficon,
02231                     );
02232                     $ATag = "<a href=\"#\" onclick=\"return BrowseLinks.File.insertElement('file_$filesIndex');\">";
02233                     $ATag_alt = substr($ATag,0,-4).",1);\">";
02234                     $bulkCheckBox = '<input type="checkbox" class="typo3-bulk-item" name="file_'.$filesIndex.'" value="0" /> ';
02235                 }
02236                 $ATag_e='</a>';
02237 
02238                     // Create link to showing details about the file in a window:
02239                 $Ahref = $BACK_PATH.'show_item.php?table='.rawurlencode($filepath).'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
02240                 $ATag2='<a href="'.htmlspecialchars($Ahref).'">';
02241                 $ATag2_e='</a>';
02242 
02243                     // Combine the stuff:
02244                 $filenameAndIcon=$bulkCheckBox.$ATag_alt.$icon.htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($filepath),$titleLen)).$ATag_e;
02245 
02246                     // Show element:
02247                 if ($pDim)  {       // Image...
02248                     $lines[]='
02249                         <tr class="bgColor4">
02250                             <td nowrap="nowrap">'.$filenameAndIcon.'&nbsp;</td>
02251                             <td>'.$ATag.'<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/plusbullet2.gif','width="18" height="16"').' title="'.$LANG->getLL('addToList',1).'" alt="" />'.$ATag_e.'</td>
02252                             <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>
02253                             <td nowrap="nowrap">&nbsp;'.$pDim.'</td>
02254                         </tr>';
02255                     $lines[]='
02256                         <tr>
02257                             <td colspan="4">'.$ATag_alt.$clickIcon.$ATag_e.'</td>
02258                         </tr>';
02259                 } else {
02260                     $lines[]='
02261                         <tr class="bgColor4">
02262                             <td nowrap="nowrap">'.$filenameAndIcon.'&nbsp;</td>
02263                             <td>'.$ATag.'<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/plusbullet2.gif','width="18" height="16"').' title="'.$LANG->getLL('addToList',1).'" alt="" />'.$ATag_e.'</td>
02264                             <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>
02265                             <td>&nbsp;</td>
02266                         </tr>';
02267                 }
02268                 $lines[]='
02269                         <tr>
02270                             <td colspan="3"><img src="clear.gif" width="1" height="3" alt="" /></td>
02271                         </tr>';
02272             }
02273 
02274                 // Wrap all the rows in table tags:
02275             $out.='
02276 
02277 
02278 
02279         <!--
02280             File listing
02281         -->
02282                 <table cellpadding="0" cellspacing="0" id="typo3-fileList">
02283                     '.implode('',$lines).'
02284                 </table>';
02285         }
02286             // Return accumulated content for filelisting:
02287         return $out;
02288     }
02289 
02290     /**
02291      * Render list of folders.
02292      *
02293      * @param   array       List of folders. See t3lib_div::get_dirs
02294      * @param   string      If set a header with a folder icon and folder name are shown
02295      * @return  string      HTML output
02296      */
02297     function folderList($baseFolder, $folders) {
02298         global $LANG, $BACK_PATH;
02299 
02300         $content = '';
02301 
02302             // Create headline (showing number of folders):
02303         $content.=$this->barheader(
02304             sprintf($GLOBALS['LANG']->getLL('folders').' (%s):',count($folders))
02305         );
02306 
02307         $titleLength = intval($GLOBALS['BE_USER']->uc['titleLen']);
02308 
02309             // Create the header of current folder:
02310         if($baseFolder) {
02311             if (strstr($baseFolder, ',') || strstr($baseFolder, '|'))   {
02312                     // In case an invalid character is in the filepath, display error message:
02313                 $errorMessage     = $LANG->JScharCode(sprintf($LANG->getLL('invalidChar'),', |'));
02314                 $aTag = $aTag_alt = "<a href=\"#\" onclick=\"alert(".$errorMessage.");return false;\">";
02315             } else {
02316                     // If foldername is OK, just add it:
02317                 $aTag = "<a href=\"#\" onclick=\"return insertElement('','".rawurlencode($baseFolder)."', 'folder', '".rawurlencode($baseFolder)."', unescape('".rawurlencode($baseFolder)."'), '".$fI['extension']."', '".$ficon."');\">";
02318                 $aTag_alt = substr($aTag,0,-4).",'',1);\">";
02319             }
02320             $aTag_e = '</a>';
02321 
02322                 // add the foder icon
02323             $folderIcon = $aTag_alt;
02324             $folderIcon.= '<img'.t3lib_iconWorks::skinImg(
02325                 $BACK_PATH,
02326                 'gfx/i/_icon_webfolders.gif','width="18" height="16"'
02327             ).' alt="" />';
02328             $folderIcon.= htmlspecialchars(
02329                 t3lib_div::fixed_lgd_cs(basename($baseFolder),$titleLength)
02330             );
02331             $folderIcon.= $aTag_e;
02332 
02333             $content.=$folderIcon.'<br />';
02334         }
02335 
02336             // Listing the folders:
02337         if(is_array($folders)) {
02338             if(count($folders) > 0) {
02339                     // Traverse the folder list:
02340                 $lines = array();
02341                 foreach($folders as $folderPath)    {
02342                     $pathInfo = pathinfo($folderPath);
02343 
02344                         // Create folder icon:
02345                     $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="" />';
02346 
02347                         // Create links for adding the folder:
02348                     if($this->P['itemName'] != '' && $this->P['formName'] != '') {
02349                         $aTag = "<a href=\"#\" onclick=\"return set_folderpath(unescape('".rawurlencode($folderPath)."'));\">";
02350                     } else {
02351                         $aTag = "<a href=\"#\" onclick=\"return insertElement('','".rawurlencode($folderPath)."', 'folder', '".rawurlencode($folderPath)."', unescape('".rawurlencode($folderPath)."'), '".$pathInfo['extension']."', '".$ficon."');\">";
02352                     }
02353 
02354                     if (strstr($folderPath,',') || strstr($folderPath,'|')) {
02355                             // In case an invalid character is in the filepath, display error message:
02356                         $errorMessage     = $LANG->JScharCode(sprintf($LANG->getLL('invalidChar'),', |'));
02357                         $aTag = $aTag_alt = "<a href=\"#\" onclick=\"alert(".$errorMessage.");return false;\">";
02358                     } else {
02359                             // If foldername is OK, just add it:
02360                         $aTag_alt = substr($aTag,0,-4).",'',1);\">";
02361                     }
02362                     $aTag_e='</a>';
02363 
02364                         // Combine icon and folderpath:
02365                     $foldernameAndIcon = $aTag_alt.$icon.htmlspecialchars(
02366                         t3lib_div::fixed_lgd_cs(basename($folderPath),$titleLength)
02367                     ).$aTag_e;
02368 
02369                     if($this->P['itemName'] != '') {
02370                         $lines[] = '
02371                             <tr class="bgColor4">
02372                                 <td nowrap="nowrap">'.$foldernameAndIcon.'&nbsp;</td>
02373                                 <td>&nbsp;</td>
02374                             </tr>';
02375                     } else {
02376                         $lines[] = '
02377                             <tr class="bgColor4">
02378                                 <td nowrap="nowrap">'.$foldernameAndIcon.'&nbsp;</td>
02379                                 <td>'.$aTag.'<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/plusbullet2.gif','width="18" height="16"').' title="'.$LANG->getLL('addToList',1).'" alt="" />'.$aTag_e.'</td>
02380                                 <td>&nbsp;</td>
02381                             </tr>';
02382                     }
02383 
02384                     $lines[] = '
02385                             <tr>
02386                                 <td colspan="3"><img src="clear.gif" width="1" height="3" alt="" /></td>
02387                             </tr>';
02388                 }
02389             }
02390 
02391                 // Wrap all the rows in table tags:
02392             $content.='
02393 
02394         <!--
02395             Folder listing
02396         -->
02397                 <table border="0" cellpadding="0" cellspacing="1" id="typo3-folderList">
02398                     '.implode('', $lines).'
02399                 </table>';
02400         }
02401 
02402             // Return accumulated content for folderlisting:
02403         return $content;
02404     }
02405 
02406     /**
02407      * For RTE: This displays all IMAGES (gif,png,jpg) (from extensionList) from folder. Thumbnails are shown for images.
02408      * This listing is of images located in the web-accessible paths ONLY - the listing is for drag-n-drop use in the RTE
02409      *
02410      * @param   string      The folder path to expand
02411      * @param   string      List of fileextensions to show
02412      * @return  string      HTML output
02413      */
02414     function TBE_dragNDrop($expandFolder=0,$extensionList='')   {
02415         global $BACK_PATH;
02416 
02417         $extensionList = ($extensionList == '*') ? '' : $extensionList;
02418         $expandFolder = $expandFolder ? $expandFolder : $this->expandFolder;
02419         $out='';
02420         if ($expandFolder && $this->checkFolder($expandFolder)) {
02421             if ($this->isWebFolder($expandFolder))  {
02422 
02423                     // Read files from directory:
02424                 $files = t3lib_div::getFilesInDir($expandFolder,$extensionList,1,1);    // $extensionList="",$prependPath=0,$order='')
02425                 if (is_array($files))   {
02426                     $out.=$this->barheader(sprintf($GLOBALS['LANG']->getLL('files').' (%s):',count($files)));
02427 
02428                     $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
02429                     $picon='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/i/_icon_webfolders.gif','width="18" height="16"').' alt="" />';
02430                     $picon.=htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($expandFolder),$titleLen));
02431                     $out.=$picon.'<br />';
02432 
02433                         // Init row-array:
02434                     $lines=array();
02435 
02436                         // Add "drag-n-drop" message:
02437                     $lines[]='
02438                         <tr>
02439                             <td colspan="2">'.$this->getMsgBox($GLOBALS['LANG']->getLL('findDragDrop')).'</td>
02440                         </tr>';
02441 
02442                         // Traverse files:
02443                     foreach ($files as $filepath) {
02444                         $fI = pathinfo($filepath);
02445 
02446                             // URL of image:
02447                         $iurl = $this->siteURL.t3lib_div::rawurlencodeFP(substr($filepath,strlen(PATH_site)));
02448 
02449                             // Show only web-images
02450                         if (t3lib_div::inList('gif,jpeg,jpg,png',strtolower($fI['extension']))) {
02451                             $imgInfo = @getimagesize($filepath);
02452                             $pDim = $imgInfo[0].'x'.$imgInfo[1].' pixels';
02453 
02454                             $ficon = t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
02455                             $size=' ('.t3lib_div::formatSize(filesize($filepath)).'bytes'.($pDim?', '.$pDim:'').')';
02456                             $icon = '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/fileicons/'.$ficon,'width="18" height="16"').' class="absmiddle" title="'.htmlspecialchars($fI['basename'].$size).'" alt="" />';
02457                             $filenameAndIcon=$icon.htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($filepath),$titleLen));
02458 
02459                             if (t3lib_div::_GP('noLimit'))  {
02460                                 $maxW=10000;
02461                                 $maxH=10000;
02462                             } else {
02463                                 $maxW=380;
02464                                 $maxH=500;
02465                             }
02466                             $IW = $imgInfo[0];
02467                             $IH = $imgInfo[1];
02468                             if ($IW>$maxW)  {
02469                                 $IH=ceil($IH/$IW*$maxW);
02470                                 $IW=$maxW;
02471                             }
02472                             if ($IH>$maxH)  {
02473                                 $IW=ceil($IW/$IH*$maxH);
02474                                 $IH=$maxH;
02475                             }
02476 
02477                                 // Make row:
02478                             $lines[]='
02479                                 <tr class="bgColor4">
02480                                     <td nowrap="nowrap">'.$filenameAndIcon.'&nbsp;</td>
02481                                     <td nowrap="nowrap">'.
02482                                     ($imgInfo[0]!=$IW ? '<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('noLimit'=>'1'))).'">'.
02483                                                         '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/icon_warning2.gif','width="18" height="16"').' title="'.$GLOBALS['LANG']->getLL('clickToRedrawFullSize',1).'" alt="" />'.
02484                                                         '</a>':'').
02485                                     $pDim.'&nbsp;</td>
02486                                 </tr>';
02487 
02488                             $lines[]='
02489                                 <tr>
02490                                     <td colspan="2"><img src="'.$iurl.'" width="'.$IW.'" height="'.$IH.'" border="1" alt="" /></td>
02491                                 </tr>';
02492                             $lines[]='
02493                                 <tr>
02494                                     <td colspan="2"><img src="clear.gif" width="1" height="3" alt="" /></td>
02495                                 </tr>';
02496                         }
02497                     }
02498 
02499                         // Finally, wrap all rows in a table tag:
02500                     $out.='
02501 
02502 
02503             <!--
02504                 File listing / Drag-n-drop
02505             -->
02506                         <table border="0" cellpadding="0" cellspacing="1" id="typo3-dragBox">
02507                             '.implode('',$lines).'
02508                         </table>';
02509                 }
02510             } else {
02511                     // Print this warning if the folder is NOT a web folder:
02512                 $out.=$this->barheader($GLOBALS['LANG']->getLL('files'));
02513                 $out.=$this->getMsgBox($GLOBALS['LANG']->getLL('noWebFolder'),'icon_warning2');
02514             }
02515         }
02516         return $out;
02517     }
02518 
02519 
02520 
02521 
02522 
02523 
02524 
02525 
02526 
02527 
02528 
02529 
02530     /******************************************************************
02531      *
02532      * Miscellaneous functions
02533      *
02534      ******************************************************************/
02535 
02536 
02537     /**
02538      * Verifies that a path is a web-folder:
02539      *
02540      * @param   string      Absolute filepath
02541      * @return  boolean     If the input path is found in PATH_site then it returns true.
02542      */
02543     function isWebFolder($folder)   {
02544         $folder = rtrim($folder, '/').'/';
02545         return t3lib_div::isFirstPartOfStr($folder,PATH_site) ? TRUE : FALSE;
02546     }
02547 
02548     /**
02549      * Checks, if a path is within the mountpoints of the backend user
02550      *
02551      * @param   string      Absolute filepath
02552      * @return  boolean     If the input path is found in the backend users filemounts, then return true.
02553      */
02554     function checkFolder($folder)   {
02555         return $this->fileProcessor->checkPathAgainstMounts(rtrim($folder, '/') . '/') ? true : false;
02556     }
02557 
02558     /**
02559      * Checks, if a path is within a read-only mountpoint of the backend user
02560      *
02561      * @param   string      Absolute filepath
02562      * @return  boolean     If the input path is found in the backend users filemounts and if the filemount is of type readonly, then return true.
02563      */
02564     function isReadOnlyFolder($folder) {
02565         return ($GLOBALS['FILEMOUNTS'][$this->fileProcessor->checkPathAgainstMounts(rtrim($folder, '/') . '/')]['type'] == 'readonly');
02566     }
02567 
02568     /**
02569      * Prints a 'header' where string is in a tablecell
02570      *
02571      * @param   string      The string to print in the header. The value is htmlspecialchars()'ed before output.
02572      * @return  string      The header HTML (wrapped in a table)
02573      */
02574     function barheader($str)    {
02575         return '
02576             <!-- Bar header: -->
02577             <h3>' . htmlspecialchars($str) . '</h3>
02578             ';
02579     }
02580 
02581     /**
02582      * Displays a message box with the input message
02583      *
02584      * @param   string      Input message to show (will be htmlspecialchars()'ed inside of this function)
02585      * @param   string      Icon filename body from gfx/ (default is "icon_note") - meant to allow change to warning type icons...
02586      * @return  string      HTML for the message (wrapped in a table).
02587      */
02588     function getMsgBox($in_msg,$icon='icon_note')   {
02589         global $BACK_PATH;
02590 
02591         $msg = '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/'.$icon.'.gif','width="18" height="16"').' alt="" />'.htmlspecialchars($in_msg);
02592         $msg = '
02593 
02594             <!--
02595                 Message box:
02596             -->
02597             <table cellspacing="0" class="bgColor4" id="typo3-msgBox">
02598                 <tr>
02599                     <td>'.$msg.'</td>
02600                 </tr>
02601             </table>
02602             ';
02603         return $msg;
02604     }
02605 
02606     /**
02607      * For RTE/link: This prints the 'currentUrl'
02608      *
02609      * @param   string      URL value.  The value is htmlspecialchars()'ed before output.
02610      * @return  string      HTML content, wrapped in a table.
02611      */
02612     function printCurrentUrl($str)  {
02613         if (strlen($str)) {
02614             return '
02615                 <!-- Print current URL -->
02616                 <table border="0" cellpadding="0" cellspacing="0" id="typo3-curUrl">
02617                     <tr>
02618                         <td>' . $GLOBALS['LANG']->getLL('currentLink',1) . ': ' .htmlspecialchars(rawurldecode($str)) . '</td>
02619                     </tr>
02620                 </table>';
02621         } else {
02622             return '';
02623         }
02624     }
02625 
02626     /**
02627      * For RTE/link: Parses the incoming URL and determines if it's a page, file, external or mail address.
02628      *
02629      * @param   string      HREF value tp analyse
02630      * @param   string      The URL of the current website (frontend)
02631      * @return  array       Array with URL information stored in assoc. keys: value, act (page, file, spec, mail), pageid, cElement, info
02632      */
02633     function parseCurUrl($href,$siteUrl)    {
02634         $href = trim($href);
02635         if ($href)  {
02636             $info=array();
02637 
02638                 // Default is "url":
02639             $info['value']=$href;
02640             $info['act']='url';
02641 
02642             $specialParts = explode('#_SPECIAL',$href);
02643             if (count($specialParts)==2)    {   // Special kind (Something RTE specific: User configurable links through: "userLinks." from ->thisConfig)
02644                 $info['value']='#_SPECIAL'.$specialParts[1];
02645                 $info['act']='spec';
02646             } elseif (t3lib_div::isFirstPartOfStr($href,$siteUrl))  {   // If URL is on the current frontend website:
02647                 $rel = substr($href,strlen($siteUrl));
02648                 if (file_exists(PATH_site.rawurldecode($rel)))  {   // URL is a file, which exists:
02649                     $info['value']=rawurldecode($rel);
02650                     if (@is_dir(PATH_site . $info['value'])) {
02651                         $info['act'] = 'folder';
02652                     } else {
02653                         $info['act'] = 'file';
02654                     }
02655                 } else {    // URL is a page (id parameter)
02656                     $uP=parse_url($rel);
02657                     if (!trim($uP['path'])) {
02658                         $pp = preg_split('/^id=/', $uP['query']);
02659                         $pp[1] = preg_replace( '/&id=[^&]*/', '', $pp[1]);
02660                         $parameters = explode('&', $pp[1]);
02661                         $id = array_shift($parameters);
02662                         if ($id)    {
02663                                 // Checking if the id-parameter is an alias.
02664                             if (!t3lib_div::testInt($id))   {
02665                                 list($idPartR) = t3lib_BEfunc::getRecordsByField('pages','alias',$id);
02666                                 $id=intval($idPartR['uid']);
02667                             }
02668 
02669                             $pageRow = t3lib_BEfunc::getRecordWSOL('pages',$id);
02670                             $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
02671                             $info['value']=$GLOBALS['LANG']->getLL('page',1)." '".htmlspecialchars(t3lib_div::fixed_lgd_cs($pageRow['title'],$titleLen))."' (ID:".$id.($uP['fragment']?', #'.$uP['fragment']:'').')';
02672                             $info['pageid']=$id;
02673                             $info['cElement']=$uP['fragment'];
02674                             $info['act']='page';
02675                             $info['query'] = $parameters[0]?'&'.implode('&', $parameters):'';
02676                         }
02677                     }
02678                 }
02679             } else {    // Email link:
02680                 if (strtolower(substr($href,0,7))=='mailto:')   {
02681                     $info['value']=trim(substr($href,7));
02682                     $info['act']='mail';
02683                 }
02684             }
02685             $info['info'] = $info['value'];
02686         } else {    // NO value inputted:
02687             $info=array();
02688             $info['info']=$GLOBALS['LANG']->getLL('none');
02689             $info['value']='';
02690             $info['act']='page';
02691         }
02692 
02693             // let the hook have a look
02694         foreach($this->hookObjects as $hookObject) {
02695             $info = $hookObject->parseCurrentUrl($href, $siteUrl, $info);
02696         }
02697 
02698         return $info;
02699     }
02700 
02701     /**
02702      * For TBE: Makes an upload form for uploading files to the filemount the user is browsing.
02703      * The files are uploaded to the tce_file.php script in the core which will handle the upload.
02704      *
02705      * @param   string      Absolute filepath on server to which to upload.
02706      * @return  string      HTML for an upload form.
02707      */
02708     function uploadForm($path)  {
02709         global $BACK_PATH;
02710 
02711         if ($this->isReadOnlyFolder($path)) return '';
02712 
02713             // Read configuration of upload field count
02714         $userSetting = $GLOBALS['BE_USER']->getTSConfigVal('options.folderTree.uploadFieldsInLinkBrowser');
02715         $count = isset($userSetting) ? $userSetting : 3;
02716         if ($count === '0') {
02717             return '';
02718         }
02719         $count = intval($count) == 0 ? 3 : intval($count);
02720 
02721             // Create header, showing upload path:
02722         $header = t3lib_div::isFirstPartOfStr($path,PATH_site)?substr($path,strlen(PATH_site)):$path;
02723         $code=$this->barheader($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_upload.php.pagetitle',1).':');
02724         $code.='
02725 
02726             <!--
02727                 Form, for uploading files:
02728             -->
02729             <form action="'.$BACK_PATH.'tce_file.php" method="post" name="editform" enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'">
02730                 <table border="0" cellpadding="0" cellspacing="3" id="typo3-uplFiles">
02731                     <tr>
02732                         <td><strong>'.$GLOBALS['LANG']->getLL('path',1).':</strong> '.htmlspecialchars($header).'</td>
02733                     </tr>
02734                     <tr>
02735                         <td>';
02736 
02737             // Traverse the number of upload fields (default is 3):
02738         for ($a=1;$a<=$count;$a++)  {
02739             $code.='<input type="file" name="upload_'.$a.'"'.$this->doc->formWidth(35).' size="50" />
02740                 <input type="hidden" name="file[upload]['.$a.'][target]" value="'.htmlspecialchars($path).'" />
02741                 <input type="hidden" name="file[upload]['.$a.'][data]" value="'.$a.'" /><br />';
02742         }
02743 
02744             // Make footer of upload form, including the submit button:
02745         $redirectValue = $this->thisScript.'?act='.$this->act.'&mode='.$this->mode.'&expandFolder='.rawurlencode($path).'&bparams='.rawurlencode($this->bparams);
02746         $code.='<input type="hidden" name="redirect" value="'.htmlspecialchars($redirectValue).'" />'.
02747                 '<input type="submit" name="submit" value="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_upload.php.submit',1).'" />';
02748 
02749         $code.='
02750             <div id="c-override">
02751                 <input type="checkbox" name="overwriteExistingFiles" id="overwriteExistingFiles" value="1" /> <label for="overwriteExistingFiles">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xml:overwriteExistingFiles',1).'</label>
02752             </div>
02753         ';
02754 
02755 
02756         $code.='</td>
02757                     </tr>
02758                 </table>
02759             </form>';
02760 
02761         return $code;
02762     }
02763 
02764     /**
02765      * For TBE: Makes a form for creating new folders in the filemount the user is browsing.
02766      * The folder creation request is sent to the tce_file.php script in the core which will handle the creation.
02767      *
02768      * @param   string      Absolute filepath on server in which to create the new folder.
02769      * @return  string      HTML for the create folder form.
02770      */
02771     function createFolder($path)    {
02772         global $BACK_PATH;
02773 
02774         if ($this->isReadOnlyFolder($path)) return '';
02775 
02776             // Don't show Folder-create form if it's denied
02777         if ($GLOBALS['BE_USER']->getTSConfigVal('options.folderTree.hideCreateFolder')) {
02778             return '';
02779         }
02780             // Create header, showing upload path:
02781         $header = t3lib_div::isFirstPartOfStr($path,PATH_site)?substr($path,strlen(PATH_site)):$path;
02782         $code=$this->barheader($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.pagetitle').':');
02783         $code.='
02784 
02785             <!--
02786                 Form, for creating new folders:
02787             -->
02788             <form action="'.$BACK_PATH.'tce_file.php" method="post" name="editform2">
02789                 <table border="0" cellpadding="0" cellspacing="3" id="typo3-crFolder">
02790                     <tr>
02791                         <td><strong>'.$GLOBALS['LANG']->getLL('path',1).':</strong> '.htmlspecialchars($header).'</td>
02792                     </tr>
02793                     <tr>
02794                         <td>';
02795 
02796             // Create the new-folder name field:
02797         $a=1;
02798         $code.='<input'.$this->doc->formWidth(20).' type="text" name="file[newfolder]['.$a.'][data]" />'.
02799                 '<input type="hidden" name="file[newfolder]['.$a.'][target]" value="'.htmlspecialchars($path).'" />';
02800 
02801             // Make footer of upload form, including the submit button:
02802         $redirectValue = $this->thisScript.'?act='.$this->act.'&mode='.$this->mode.'&expandFolder='.rawurlencode($path).'&bparams='.rawurlencode($this->bparams);
02803         $code.='<input type="hidden" name="redirect" value="'.htmlspecialchars($redirectValue).'" />'.
02804                 '<input type="submit" name="submit" value="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.submit',1).'" />';
02805 
02806         $code.='</td>
02807                     </tr>
02808                 </table>
02809             </form>';
02810 
02811         return $code;
02812     }
02813 
02814     /**
02815      * Get the HTML data required for a bulk selection of files of the TYPO3 Element Browser.
02816      *
02817      * @param   integer     $filesCount: Number of files currently displayed
02818      * @return  string      HTML data required for a bulk selection of files - if $filesCount is 0, nothing is returned
02819      */
02820     function getBulkSelector($filesCount) {
02821         if ($filesCount) {
02822             $labelToggleSelection = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_browse_links.php:toggleSelection',1);
02823             $labelImportSelection = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_browse_links.php:importSelection',1);
02824 
02825             $out = $this->doc->spacer(15).'<div>' .
02826                     '<a href="#" onclick="BrowseLinks.Selector.toggle()">' .
02827                         '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/clip_select.gif','width="12" height="12"').' title="'.$labelToggleSelection.'" alt="" /> ' .
02828                         $labelToggleSelection.'</a>'.$this->doc->spacer(5) .
02829                     '<a href="#" onclick="BrowseLinks.Selector.handle()">' .
02830                         '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/import.gif','width="12" height="12"').' title="'.$labelImportSelection.'" alt="" /> ' .
02831                         $labelImportSelection.'</a>' .
02832                 '</div>'.$this->doc->spacer(15);
02833         }
02834         return $out;
02835     }
02836 
02837     /**
02838      * Determines whether submitted field change functions are valid
02839      * and are coming from the system and not from an external abuse.
02840      *
02841      * @param boolean $allowFlexformSections Whether to handle flexform sections differently
02842      * @return boolean Whether the submitted field change functions are valid
02843      */
02844     protected function areFieldChangeFunctionsValid($handleFlexformSections = FALSE) {
02845         $result = FALSE;
02846 
02847         if (isset($this->P['fieldChangeFunc']) && is_array($this->P['fieldChangeFunc']) && isset($this->P['fieldChangeFuncHash'])) {
02848             $matches = array();
02849             $pattern = '#\[el\]\[(([^]-]+-[^]-]+-)(idx\d+-)([^]]+))\]#i';
02850 
02851             $fieldChangeFunctions = $this->P['fieldChangeFunc'];
02852 
02853                 // Special handling of flexform sections:
02854                 // Field change functions are modified in JavaScript, thus the hash is always invalid
02855             if ($handleFlexformSections && preg_match($pattern, $this->P['itemName'], $matches)) {
02856                 $originalName = $matches[1];
02857                 $cleanedName = $matches[2] . $matches[4];
02858 
02859                 foreach ($fieldChangeFunctions as &$value) {
02860                     $value = str_replace($originalName, $cleanedName, $value);
02861                 }
02862             }
02863 
02864             $result = ($this->P['fieldChangeFuncHash'] === t3lib_div::hmac(serialize($fieldChangeFunctions)));
02865         }
02866 
02867         return $result;
02868     }
02869 }
02870 
02871 
02872 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/class.browse_links.php'])) {
02873     include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/class.browse_links.php']);
02874 }
02875 
02876 ?>