Documentation TYPO3 par Ameos

class.browse_links.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00118 require_once (PATH_t3lib.'class.t3lib_browsetree.php');
00119 require_once (PATH_t3lib.'class.t3lib_foldertree.php');
00120 require_once (PATH_t3lib.'class.t3lib_stdgraphic.php');
00121 require_once (PATH_t3lib.'class.t3lib_basicfilefunc.php');
00122 
00123 
00124         // Include classes
00125 require_once (PATH_t3lib.'class.t3lib_page.php');
00126 require_once (PATH_t3lib.'class.t3lib_recordlist.php');
00127 require_once (PATH_typo3.'/class.db_list.inc');
00128 require_once (PATH_typo3.'/class.db_list_extra.inc');
00129 require_once (PATH_t3lib.'/class.t3lib_pagetree.php');
00130 
00131 
00132 
00133 
00134 
00135 
00136 
00137 
00138 
00139 
00140 
00141 
00142 
00143 
00144 
00145 
00146 
00147 
00148 
00156 class TBE_browser_recordList extends localRecordList {
00157         var $thisScript = 'browse_links.php';
00158 
00164         function TBE_browser_recordList () {
00165                 $this->thisScript = t3lib_div::getIndpEnv('SCRIPT_NAME');
00166         }
00167 
00176         function listURL($altId='',$table=-1,$exclList='')      {
00177                 return $this->thisScript.
00178                         '?id='.(strcmp($altId,'')?$altId:$this->id).
00179                         '&table='.rawurlencode($table==-1?$this->table:$table).
00180                         ($this->thumbs?'&imagemode='.$this->thumbs:'').
00181                         ($this->searchString?'&search_field='.rawurlencode($this->searchString):'').
00182                         ($this->searchLevels?'&search_levels='.rawurlencode($this->searchLevels):'').
00183                         ((!$exclList || !t3lib_div::inList($exclList,'sortField')) && $this->sortField?'&sortField='.rawurlencode($this->sortField):'').
00184                         ((!$exclList || !t3lib_div::inList($exclList,'sortRev')) && $this->sortRev?'&sortRev='.rawurlencode($this->sortRev):'').
00185                                 // extra:
00186                         $this->ext_addP()
00187                         ;
00188         }
00189 
00195         function ext_addP()     {
00196                 $str = '&act='.$GLOBALS['SOBE']->browser->act.
00197                                 '&mode='.$GLOBALS['SOBE']->browser->mode.
00198                                 '&expandPage='.$GLOBALS['SOBE']->browser->expandPage.
00199                                 '&bparams='.rawurlencode($GLOBALS['SOBE']->browser->bparams);
00200                 return $str;
00201         }
00202 
00212         function linkWrapItems($table,$uid,$code,$row)  {
00213                 global $TCA, $BACK_PATH;
00214 
00215                 if (!$code) {
00216                         $code = '<i>['.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.no_title',1).']</i>';
00217                 } else {
00218                         $code = htmlspecialchars(t3lib_div::fixed_lgd_cs($code,$this->fixedL));
00219                 }
00220 
00221                 $title = t3lib_BEfunc::getRecordTitle($table,$row,FALSE,TRUE);
00222                 $ficon = t3lib_iconWorks::getIcon($table,$row);
00223                 $aOnClick = "return insertElement('".$table."', '".$row['uid']."', 'db', ".t3lib_div::quoteJSvalue($title).", '', '', '".$ficon."');";
00224                 $ATag = '<a href="#" onclick="'.$aOnClick.'">';
00225                 $ATag_alt = substr($ATag,0,-4).',\'\',1);">';
00226                 $ATag_e = '</a>';
00227 
00228                 return $ATag.
00229                                 '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/plusbullet2.gif','width="18" height="16"').' title="'.$GLOBALS['LANG']->getLL('addToList',1).'" alt="" />'.
00230                                 $ATag_e.
00231                                 $ATag_alt.
00232                                 $code.
00233                                 $ATag_e;
00234         }
00235 
00243         function linkWrapTable($table,$code)    {
00244                 return $code;
00245         }
00246 }
00247 
00248 
00249 
00250 
00251 
00252 
00260 class localPageTree extends t3lib_browseTree {
00261 
00267         function localPageTree() {
00268                 $this->thisScript = t3lib_div::getIndpEnv('SCRIPT_NAME');
00269 
00270                 $this->init();
00271 
00272                 $this->clause = ' AND doktype!=255'.$this->clause;
00273         }
00274 
00283         function wrapTitle($title,$v,$ext_pArrPages='') {
00284                 if ($this->ext_isLinkable($v['doktype'],$v['uid']))     {
00285                         $aOnClick = "return link_typo3Page('".$v['uid']."');";
00286                         return '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$title.'</a>';
00287                 } else {
00288                         return '<span style="color: #666666;">'.$title.'</span>';
00289                 }
00290         }
00291 
00298         function printTree($treeArr='') {
00299                 global $BACK_PATH;
00300                 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
00301                 if (!is_array($treeArr))        $treeArr=$this->tree;
00302 
00303                 $out='';
00304                 $c=0;
00305 
00306                 foreach($treeArr as $k => $v)   {
00307                         $c++;
00308                         $bgColorClass = ($c+1)%2 ? 'bgColor' : 'bgColor-10';
00309                         if ($GLOBALS['SOBE']->browser->curUrlInfo['act']=='page' && $GLOBALS['SOBE']->browser->curUrlInfo['pageid']==$v['row']['uid'] && $GLOBALS['SOBE']->browser->curUrlInfo['pageid'])       {
00310                                 $arrCol='<td><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/blinkarrow_right.gif','width="5" height="9"').' class="c-blinkArrowR" alt="" /></td>';
00311                                 $bgColorClass='bgColor4';
00312                         } else {
00313                                 $arrCol='<td></td>';
00314                         }
00315 
00316                         $aOnClick = 'return jumpToUrl(\''.$this->thisScript.'?act='.$GLOBALS['SOBE']->browser->act.'&mode='.$GLOBALS['SOBE']->browser->mode.'&expandPage='.$v['row']['uid'].'\');';
00317                         $cEbullet = $this->ext_isLinkable($v['row']['doktype'],$v['row']['uid']) ?
00318                                                 '<a href="#" onclick="'.htmlspecialchars($aOnClick).'"><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/arrowbullet.gif','width="18" height="16"').' alt="" /></a>' :
00319                                                 '';
00320                         $out.='
00321                                 <tr class="'.$bgColorClass.'">
00322                                         <td nowrap="nowrap"'.($v['row']['_CSSCLASS'] ? ' class="'.$v['row']['_CSSCLASS'].'"' : '').'>'.
00323                                         $v['HTML'].
00324                                         $this->wrapTitle($this->getTitleStr($v['row'],$titleLen),$v['row'],$this->ext_pArrPages).
00325                                         '</td>'.
00326                                         $arrCol.
00327                                         '<td>'.$cEbullet.'</td>
00328                                 </tr>';
00329                 }
00330                 $out='
00331 
00332 
00333                         <!--
00334                                 Navigation Page Tree:
00335                         -->
00336                         <table border="0" cellpadding="0" cellspacing="0" id="typo3-tree">
00337                                 '.$out.'
00338                         </table>';
00339                 return $out;
00340         }
00341 
00349         function ext_isLinkable($doktype,$uid)  {
00350                 if ($uid && $doktype<199)       {
00351                         return true;
00352                 }
00353         }
00354 
00363         function PM_ATagWrap($icon,$cmd,$bMark='')      {
00364                 if ($bMark)     {
00365                         $anchor = '#'.$bMark;
00366                         $name=' name="'.$bMark.'"';
00367                 }
00368                 $aOnClick = "return jumpToUrl('".$this->thisScript.'?PM='.$cmd."','".$anchor."');";
00369 
00370                 return '<a href="#"'.$name.' onclick="'.htmlspecialchars($aOnClick).'">'.$icon.'</a>';
00371         }
00372 
00380         function wrapIcon($icon,$row)   {
00381                 return $this->addTagAttributes($icon,' title="id='.$row['uid'].'"');
00382         }
00383 }
00384 
00385 
00386 
00387 
00388 
00389 
00390 
00391 
00399 class rtePageTree extends localPageTree {
00400 }
00401 
00402 
00403 
00404 
00405 
00406 
00407 
00408 
00416 class TBE_PageTree extends localPageTree {
00417 
00425         function ext_isLinkable($doktype,$uid)  {
00426                 return true;
00427         }
00428 
00437         function wrapTitle($title,$v,$ext_pArrPages)    {
00438                 if ($ext_pArrPages)     {
00439                         $ficon=t3lib_iconWorks::getIcon('pages',$v);
00440                         $onClick = "return insertElement('pages', '".$v['uid']."', 'db', ".t3lib_div::quoteJSvalue($v['title']).", '', '', '".$ficon."','',1);";
00441                 } else {
00442                         $onClick = htmlspecialchars('return jumpToUrl(\''.$this->thisScript.'?act='.$GLOBALS['SOBE']->browser->act.'&mode='.$GLOBALS['SOBE']->browser->mode.'&expandPage='.$v['uid'].'\');');
00443                 }
00444                 return '<a href="#" onclick="'.$onClick.'">'.$title.'</a>';
00445         }
00446 }
00447 
00448 
00449 
00450 
00451 
00452 
00453 
00454 
00463 class localFolderTree extends t3lib_folderTree {
00464         var $ext_IconMode=1;
00465 
00466 
00472         function localFolderTree() {
00473                 $this->thisScript = t3lib_div::getIndpEnv('SCRIPT_NAME');
00474                 $this->t3lib_folderTree();
00475         }
00476 
00484         function wrapTitle($title,$v)   {
00485                 if ($this->ext_isLinkable($v))  {
00486                         $aOnClick = 'return jumpToUrl(\''.$this->thisScript.'?act='.$GLOBALS['SOBE']->browser->act.'&mode='.$GLOBALS['SOBE']->browser->mode.'&expandFolder='.rawurlencode($v['path']).'\');';
00487                         return '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$title.'</a>';
00488                 } else {
00489                         return '<span class="typo3-dimmed">'.$title.'</span>';
00490                 }
00491         }
00492 
00499         function ext_isLinkable($v)     {
00500                 $webpath=t3lib_BEfunc::getPathType_web_nonweb($v['path']);      // Checking, if the input path is a web-path.
00501                 if (strstr($v['path'],'_recycler_') || strstr($v['path'],'_temp_') || $webpath!='web')  {
00502                         return 0;
00503                 }
00504                 return 1;
00505         }
00506 
00516         function PM_ATagWrap($icon,$cmd,$bMark='')      {
00517                 if ($bMark)     {
00518                         $anchor = '#'.$bMark;
00519                         $name=' name="'.$bMark.'"';
00520                 }
00521                 $aOnClick = 'return jumpToUrl(\''.$this->thisScript.'?PM='.$cmd.'\',\''.$anchor.'\');';
00522                 return '<a href="#"'.$name.' onclick="'.htmlspecialchars($aOnClick).'">'.$icon.'</a>';
00523         }
00524 
00531         function printTree($treeArr='') {
00532                 global $BACK_PATH;
00533                 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
00534 
00535                 if (!is_array($treeArr))        $treeArr=$this->tree;
00536 
00537                 $out='';
00538                 $c=0;
00539 
00540                         // Preparing the current-path string (if found in the listing we will see a red blinking arrow).
00541                 if (!$GLOBALS['SOBE']->browser->curUrlInfo['value'])    {
00542                         $cmpPath='';
00543                 } else if (substr(trim($GLOBALS['SOBE']->browser->curUrlInfo['info']),-1)!='/') {
00544                         $cmpPath=PATH_site.dirname($GLOBALS['SOBE']->browser->curUrlInfo['info']).'/';
00545                 } else {
00546                         $cmpPath=PATH_site.$GLOBALS['SOBE']->browser->curUrlInfo['info'];
00547                 }
00548 
00549                         // Traverse rows for the tree and print them into table rows:
00550                 foreach($treeArr as $k => $v)   {
00551                         $c++;
00552                         $bgColorClass=($c+1)%2 ? 'bgColor' : 'bgColor-10';
00553 
00554                                 // Creating blinking arrow, if applicable:
00555                         if ($GLOBALS['SOBE']->browser->curUrlInfo['act']=='file' && $cmpPath==$v['row']['path'])        {
00556                                 $arrCol='<td><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/blinkarrow_right.gif','width="5" height="9"').' class="c-blinkArrowR" alt="" /></td>';
00557                                 $bgColorClass='bgColor4';
00558                         } else {
00559                                 $arrCol='<td></td>';
00560                         }
00561                                 // Create arrow-bullet for file listing (if folder path is linkable):
00562                         $aOnClick = 'return jumpToUrl(\''.$this->thisScript.'?act='.$GLOBALS['SOBE']->browser->act.'&mode='.$GLOBALS['SOBE']->browser->mode.'&expandFolder='.rawurlencode($v['row']['path']).'\');';
00563                         $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>' : '';
00564 
00565                                 // Put table row with folder together:
00566                         $out.='
00567                                 <tr class="'.$bgColorClass.'">
00568                                         <td nowrap="nowrap">'.$v['HTML'].$this->wrapTitle(t3lib_div::fixed_lgd_cs($v['row']['title'],$titleLen),$v['row']).'</td>
00569                                         '.$arrCol.'
00570                                         <td>'.$cEbullet.'</td>
00571                                 </tr>';
00572                 }
00573 
00574                 $out='
00575 
00576                         <!--
00577                                 Folder tree:
00578                         -->
00579                         <table border="0" cellpadding="0" cellspacing="0" id="typo3-tree">
00580                                 '.$out.'
00581                         </table>';
00582                 return $out;
00583         }
00584 }
00585 
00586 
00587 
00588 
00589 
00590 
00598 class rteFolderTree extends localFolderTree {
00599 }
00600 
00601 
00602 
00603 
00604 
00605 
00606 
00614 class TBE_FolderTree extends localFolderTree {
00615         var $ext_noTempRecyclerDirs=0;          // If file-drag mode is set, temp and recycler folders are filtered out.
00616 
00623         function ext_isLinkable($v)     {
00624                 if ($this->ext_noTempRecyclerDirs && (substr($v['path'],-7)=='_temp_/' || substr($v['path'],-11)=='_recycler_/'))       {
00625                         return 0;
00626                 } return 1;
00627         }
00628 
00636         function wrapTitle($title,$v)   {
00637                 if ($this->ext_isLinkable($v))  {
00638                         $aOnClick = 'return jumpToUrl(\''.$this->thisScript.'?act='.$GLOBALS['SOBE']->browser->act.'&mode='.$GLOBALS['SOBE']->browser->mode.'&expandFolder='.rawurlencode($v['path']).'\');';
00639                         return '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$title.'</a>';
00640                 } else {
00641                         return '<span class="typo3-dimmed">'.$title.'</span>';
00642                 }
00643         }
00644 }
00645 
00646 
00647 
00648 
00649 
00657 class browse_links {
00658 
00659                 // Internal, static:
00660         var $siteURL;                   // Current site URL (Frontend)
00661         var $thisScript;                // the script to link to
00662         var $thisConfig;                // RTE specific TSconfig
00663         var $setTarget;                 // Target (RTE specific)
00664         var $setTitle;                  // title (RTE specific)
00665         var $doc;                               // Backend template object
00666 
00667                 // GPvars:      (Input variables from outside)
00678         var $mode;
00679 
00685         var $act;
00686 
00690         var $expandPage;
00691 
00695         var $expandFolder;
00696 
00697 
00698 
00702         var $P;
00703 
00722         var $bparams;
00723 
00728         var $RTEtsConfigParams;
00729 
00730 
00731 
00732 
00736         var $PM;
00737 
00741         var $pointer;
00742 
00743 
00744 
00745 
00749         var $curUrlArray;
00750 
00754         var $curUrlInfo;
00755 
00756 
00757 
00758 
00759 
00760 
00767         function init() {
00768                 global $BE_USER,$BACK_PATH;
00769 
00770                         // Main GPvars:
00771                 $this->pointer = t3lib_div::_GP('pointer');
00772                 $this->bparams = t3lib_div::_GP('bparams');
00773                 $this->P = t3lib_div::_GP('P');
00774                 $this->RTEtsConfigParams = t3lib_div::_GP('RTEtsConfigParams');
00775                 $this->expandPage = t3lib_div::_GP('expandPage');
00776                 $this->expandFolder = t3lib_div::_GP('expandFolder');
00777                 $this->PM = t3lib_div::_GP('PM');
00778 
00779                         // Find "mode"
00780                 $this->mode=t3lib_div::_GP('mode');
00781                 if (!$this->mode)       {
00782                         $this->mode='rte';
00783                 }
00784 
00785                         // Site URL
00786                 $this->siteURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL');       // Current site url
00787 
00788                         // the script to link to
00789                 $this->thisScript = t3lib_div::getIndpEnv('SCRIPT_NAME');
00790 
00791                         // CurrentUrl - the current link url must be passed around if it exists
00792                 if ($this->mode=='wizard')      {
00793                         $currentLinkParts = t3lib_div::trimExplode(' ',$this->P['currentValue']);
00794                         $this->curUrlArray = array(
00795                                 'target' => $currentLinkParts[1]
00796                         );
00797                         $this->curUrlInfo=$this->parseCurUrl($this->siteURL.'?id='.$currentLinkParts[0],$this->siteURL);
00798                 } else {
00799                         $this->curUrlArray = t3lib_div::_GP('curUrl');
00800                         if ($this->curUrlArray['all'])  {
00801                                 $this->curUrlArray=t3lib_div::get_tag_attributes($this->curUrlArray['all']);
00802                         }
00803                         $this->curUrlInfo=$this->parseCurUrl($this->curUrlArray['href'],$this->siteURL);
00804                 }
00805 
00806                         // Determine nature of current url:
00807                 $this->act=t3lib_div::_GP('act');
00808                 if (!$this->act)        {
00809                         $this->act=$this->curUrlInfo['act'];
00810                 }
00811 
00812                         // Rich Text Editor specific configuration:
00813                 $addPassOnParams='';
00814                 if ((string)$this->mode=='rte') {
00815                         $RTEtsConfigParts = explode(':',$this->RTEtsConfigParams);
00816                         $addPassOnParams.='&RTEtsConfigParams='.rawurlencode($this->RTEtsConfigParams);
00817                         $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE',t3lib_BEfunc::getPagesTSconfig($RTEtsConfigParts[5]));
00818                         $this->thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup['properties'],$RTEtsConfigParts[0],$RTEtsConfigParts[2],$RTEtsConfigParts[4]);
00819                 }
00820 
00821                         // Initializing the target value (RTE)
00822                 $this->setTarget = $this->curUrlArray['target'];
00823                 if ($this->thisConfig['defaultLinkTarget'] && !isset($this->curUrlArray['target']))     {
00824                         $this->setTarget=$this->thisConfig['defaultLinkTarget'];
00825                 }
00826 
00827                         // Initializing the title value (RTE)
00828                 $this->setTitle = $this->curUrlArray['title'];
00829 
00830 
00831 
00832                         // Creating backend template object:
00833                 $this->doc = t3lib_div::makeInstance('template');
00834                 $this->doc->docType= 'xhtml_trans';
00835                 $this->doc->backPath = $BACK_PATH;
00836 
00837                         // BEGIN accumulation of header JavaScript:
00838                 $JScode = '';
00839                 $JScode.= '
00840                                 // This JavaScript is primarily for RTE/Link. jumpToUrl is used in the other cases as well...
00841                         var add_href="'.($this->curUrlArray['href']?'&curUrl[href]='.rawurlencode($this->curUrlArray['href']):'').'";
00842                         var add_target="'.($this->setTarget?'&curUrl[target]='.rawurlencode($this->setTarget):'').'";
00843                         var add_title="'.($this->setTitle?'&curUrl[title]='.rawurlencode($this->setTitle):'').'";
00844                         var add_params="'.($this->bparams?'&bparams='.rawurlencode($this->bparams):'').'";
00845 
00846                         var cur_href="'.($this->curUrlArray['href']?$this->curUrlArray['href']:'').'";
00847                         var cur_target="'.($this->setTarget?$this->setTarget:'').'";
00848                         var cur_title="'.($this->setTitle?$this->setTitle:'').'";
00849 
00850                         function setTarget(target)      {       //
00851                                 cur_target=target;
00852                                 add_target="&curUrl[target]="+escape(target);
00853                         }
00854                         function setTitle(title)        {       //
00855                                 cur_title=title;
00856                                 add_title="&curUrl[title]="+escape(title);
00857                         }
00858                         function setValue(value)        {       //
00859                                 cur_href=value;
00860                                 add_href="&curUrl[href]="+value;
00861                         }
00862                 ';
00863 
00864 
00865                 if ($this->mode=='wizard')      {       // Functions used, if the link selector is in wizard mode (= TCEforms fields)
00866                         unset($this->P['fieldChangeFunc']['alert']);
00867                         reset($this->P['fieldChangeFunc']);
00868                         $update='';
00869                         while(list($k,$v)=each($this->P['fieldChangeFunc']))    {
00870                                 $update.= '
00871                                 window.opener.'.$v;
00872                         }
00873 
00874                         $P2=array();
00875                         $P2['itemName']=$this->P['itemName'];
00876                         $P2['formName']=$this->P['formName'];
00877                         $P2['fieldChangeFunc']=$this->P['fieldChangeFunc'];
00878                         $addPassOnParams.=t3lib_div::implodeArrayForUrl('P',$P2);
00879 
00880                         $JScode.='
00881                                 function link_typo3Page(id,anchor)      {       //
00882                                         updateValueInMainForm(id+(anchor?anchor:"")+" "+cur_target);
00883                                         close();
00884                                         return false;
00885                                 }
00886                                 function link_folder(folder)    {       //
00887                                         updateValueInMainForm(folder+" "+cur_target);
00888                                         close();
00889                                         return false;
00890                                 }
00891                                 function link_current() {       //
00892                                         if (cur_href!="http://" && cur_href!="mailto:") {
00893                                                 var setValue = cur_href+" "+cur_target+" "+cur_title;
00894                                                 if (setValue.substr(0,7)=="http://")    setValue = setValue.substr(7);
00895                                                 if (setValue.substr(0,7)=="mailto:")    setValue = setValue.substr(7);
00896                                                 updateValueInMainForm(setValue);
00897                                                 close();
00898                                         }
00899                                         return false;
00900                                 }
00901                                 function checkReference()       {       //
00902                                         if (window.opener && window.opener.document && window.opener.document.'.$this->P['formName'].' && window.opener.document.'.$this->P['formName'].'["'.$this->P['itemName'].'"] ) {
00903                                                 return window.opener.document.'.$this->P['formName'].'["'.$this->P['itemName'].'"];
00904                                         } else {
00905                                                 close();
00906                                         }
00907                                 }
00908                                 function updateValueInMainForm(input)   {       //
00909                                         var field = checkReference();
00910                                         if (field)      {
00911                                                 field.value = input;
00912                                                 '.$update.'
00913                                         }
00914                                 }
00915                         ';
00916                 } else {        // Functions used, if the link selector is in RTE mode:
00917                         $JScode.='
00918                                 function link_typo3Page(id,anchor)      {       //
00919                                         var theLink = \''.$this->siteURL.'?id=\'+id+(anchor?anchor:"");
00920                                         self.parent.parent.renderPopup_addLink(theLink,cur_target,cur_title);
00921                                         return false;
00922                                 }
00923                                 function link_folder(folder)    {       //
00924                                         var theLink = \''.$this->siteURL.'\'+folder;
00925                                         self.parent.parent.renderPopup_addLink(theLink,cur_target,cur_title);
00926                                         return false;
00927                                 }
00928                                 function link_spec(theLink)     {       //
00929                                         self.parent.parent.renderPopup_addLink(theLink,cur_target,cur_title);
00930                                         return false;
00931                                 }
00932                                 function link_current() {       //
00933                                         if (cur_href!="http://" && cur_href!="mailto:") {
00934                                                 self.parent.parent.renderPopup_addLink(cur_href,cur_target,cur_title);
00935                                         }
00936                                         return false;
00937                                 }
00938                         ';
00939                 }
00940 
00941                         // General "jumpToUrl" function:
00942                 $JScode.='
00943                         function jumpToUrl(URL,anchor)  {       //
00944                                 var add_act = URL.indexOf("act=")==-1 ? "&act='.$this->act.'" : "";
00945                                 var add_mode = URL.indexOf("mode=")==-1 ? "&mode='.$this->mode.'" : "";
00946                                 var theLocation = URL+add_act+add_mode+add_href+add_target+add_title+add_params'.($addPassOnParams?'+"'.$addPassOnParams.'"':'').'+(anchor?anchor:"");
00947                                 window.location.href = theLocation;
00948                                 return false;
00949                         }
00950                 ';
00951 
00952 
00957                 $pArr = explode('|',$this->bparams);
00958 
00959                         // This is JavaScript especially for the TBE Element Browser!
00960                 $formFieldName = 'data['.$pArr[0].']['.$pArr[1].']['.$pArr[2].']';
00961                 
00962                         // insertElement - Call check function (e.g. for uniqueness handling):
00963                 if ($pArr[4] && $pArr[5]) {
00964                         $JScodeCheck = '
00965                                         // Call a check function in the opener window (e.g. for uniqueness handling):
00966                                 if (parent.window.opener) {
00967                                         var res = parent.window.opener.'.$pArr[5].'("'.addslashes($pArr[4]).'",table,uid,type);
00968                                         if (!res.passed) {
00969                                                 if (res.message) alert(res.message);
00970                                                 performAction = false;
00971                                         }
00972                                 } else {
00973                                         alert("Error - reference to main window is not set properly!");
00974                                         parent.close();
00975                                 }
00976                         ';
00977                 }
00978                         // insertElement - Call helper function:
00979                 if ($pArr[4] && $pArr[6]) {
00980                         $JScodeHelper = '
00981                                                 // Call helper function to manage data in the opener window:
00982                                         if (parent.window.opener) {
00983                                                 parent.window.opener.'.$pArr[6].'("'.addslashes($pArr[4]).'",table,uid,type,"'.addslashes($pArr[0]).'");
00984                                         } else {
00985                                                 alert("Error - reference to main window is not set properly!");
00986                                                 parent.close();
00987                                         }
00988                         ';
00989                 }
00990                         // insertElement - perform action commands:
00991                 if ($pArr[4] && $pArr[7]) {
00992                                 // Call user defined action function:
00993                         $JScodeAction = '
00994                                         if (parent.window.opener) {
00995                                                 parent.window.opener.'.$pArr[7].'("'.addslashes($pArr[4]).'",table,uid,type);
00996                                                 focusOpenerAndClose(close);
00997                                         } else {
00998                                                 alert("Error - reference to main window is not set properly!");
00999                                                 parent.close();
01000                                         }
01001                         ';
01002                 } else if ($pArr[0] && !$pArr[1] && !$pArr[2]) {
01003                         $JScodeAction = '
01004                                         addElement(filename,table+"_"+uid,fp,close);
01005                         ';
01006                 } else {
01007                         $JScodeAction = '
01008                                         if (setReferences()) {
01009                                                 parent.window.opener.group_change("add","'.$pArr[0].'","'.$pArr[1].'","'.$pArr[2].'",elRef,targetDoc);
01010                                         } else {
01011                                                 alert("Error - reference to main window is not set properly!");
01012                                         }
01013                                         focusOpenerAndClose(close);
01014                         ';
01015                 }
01016                 
01017                 $JScode.='
01018                         var elRef="";
01019                         var targetDoc="";
01020 
01021                         function launchView(url)        {       //
01022                                 var thePreviewWindow="";
01023                                 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");
01024                                 if (thePreviewWindow && thePreviewWindow.focus) {
01025                                         thePreviewWindow.focus();
01026                                 }
01027                         }
01028                         function setReferences()        {       //
01029                                 if (parent.window.opener
01030                                 && parent.window.opener.content
01031                                 && parent.window.opener.content.document.editform
01032                                 && parent.window.opener.content.document.editform["'.$formFieldName.'"]
01033                                                 ) {
01034                                         targetDoc = parent.window.opener.content.document;
01035                                         elRef = targetDoc.editform["'.$formFieldName.'"];
01036                                         return true;
01037                                 } else {
01038                                         return false;
01039                                 }
01040                         }
01041                         function insertElement(table, uid, type, filename,fp,filetype,imagefile,action, close)  {       //
01042                                 var performAction = true;
01043                                 '.$JScodeCheck.'
01044                                         // Call performing function and finish this action:
01045                                 if (performAction) {
01046                                                 '.$JScodeHelper.$JScodeAction.'
01047                                 }
01048                                 return false;
01049                         }
01050                         function addElement(elName,elValue,altElValue,close)    {       //
01051                                 if (parent.window.opener && parent.window.opener.setFormValueFromBrowseWin)     {
01052                                         parent.window.opener.setFormValueFromBrowseWin("'.$pArr[0].'",altElValue?altElValue:elValue,elName);
01053                                         focusOpenerAndClose(close);
01054                                 } else {
01055                                         alert("Error - reference to main window is not set properly!");
01056                                         parent.close();
01057                                 }
01058                         }
01059                         function focusOpenerAndClose(close)     {       //
01060                                 if (close)      {
01061                                         parent.window.opener.focus();
01062                                         parent.close();
01063                                 }
01064                         }
01065                 ';
01066 
01067                         // Finally, add the accumulated JavaScript to the template object:
01068                 $this->doc->JScode = $this->doc->wrapScriptTags($JScode);
01069 
01070                         // Debugging:
01071                 if (FALSE) debug(array(
01072                         'pointer' => $this->pointer,
01073                         'act' => $this->act,
01074                         'mode' => $this->mode,
01075                         'curUrlInfo' => $this->curUrlInfo,
01076                         'curUrlArray' => $this->curUrlArray,
01077                         'P' => $this->P,
01078                         'bparams' => $this->bparams,
01079                         'RTEtsConfigParams' => $this->RTEtsConfigParams,
01080                         'expandPage' => $this->expandPage,
01081                         'expandFolder' => $this->expandFolder,
01082                         'PM' => $this->PM,
01083                 ),'Internal variables of Script Class:');
01084         }
01085 
01086 
01094         function processSessionData($data) {
01095                 $store = false;
01096 
01097                 switch((string)$this->mode)     {
01098                         case 'db':
01099                                 if (isset($this->expandPage))   {
01100                                         $data['expandPage']=$this->expandPage;
01101                                         $store = true;
01102                                 } else {
01103                                         $this->expandPage=$data['expandPage'];
01104                                 }
01105                         break;
01106                         case 'file':
01107                         case 'filedrag':
01108                                 if (isset($this->expandFolder)) {
01109                                         $data['expandFolder']=$this->expandFolder;
01110                                         $store = true;
01111                                 } else {
01112                                         $this->expandFolder=$data['expandFolder'];
01113                                 }
01114                         break;
01115                 }
01116 
01117                 return array($data, $store);
01118         }
01119 
01120 
01121 
01122 
01123         /******************************************************************
01124          *
01125          * Main functions
01126          *
01127          ******************************************************************/
01128 
01137         function main_rte($wiz=0)       {
01138                 global $LANG, $BACK_PATH;
01139 
01140                         // Starting content:
01141                 $content=$this->doc->startPage('RTE link');
01142 
01143                         // Initializing the action value, possibly removing blinded values etc:
01144                 $allowedItems = array_diff(explode(',','page,file,url,mail,spec'),t3lib_div::trimExplode(',',$this->thisConfig['blindLinkOptions'],1));
01145                 reset($allowedItems);
01146                 if (!in_array($this->act,$allowedItems))        $this->act = current($allowedItems);
01147 
01148                         // Making menu in top:
01149                 $menuDef = array();
01150                 if (!$wiz)      {
01151                         $menuDef['removeLink']['isActive'] = $this->act=='removeLink';
01152                         $menuDef['removeLink']['label'] = $LANG->getLL('removeLink',1);
01153                         $menuDef['removeLink']['url'] = '#';
01154                         $menuDef['removeLink']['addParams'] = 'onclick="self.parent.parent.renderPopup_unLink();return false;"';
01155                 }
01156                 if (in_array('page',$allowedItems)) {
01157                         $menuDef['page']['isActive'] = $this->act=='page';
01158                         $menuDef['page']['label'] = $LANG->getLL('page',1);
01159                         $menuDef['page']['url'] = '#';
01160                         $menuDef['page']['addParams'] = 'onclick="jumpToUrl(\'?act=page\');return false;"';
01161                 }
01162                 if (in_array('file',$allowedItems)){
01163                         $menuDef['file']['isActive'] = $this->act=='file';
01164                         $menuDef['file']['label'] = $LANG->getLL('file',1);
01165                         $menuDef['file']['url'] = '#';
01166                         $menuDef['file']['addParams'] = 'onclick="jumpToUrl(\'?act=file\');return false;"';
01167                 }
01168                 if (in_array('url',$allowedItems)) {
01169                         $menuDef['url']['isActive'] = $this->act=='url';
01170                         $menuDef['url']['label'] = $LANG->getLL('extUrl',1);
01171                         $menuDef['url']['url'] = '#';
01172                         $menuDef['url']['addParams'] = 'onclick="jumpToUrl(\'?act=url\');return false;"';
01173                 }
01174                 if (in_array('mail',$allowedItems)) {
01175                         $menuDef['mail']['isActive'] = $this->act=='mail';
01176                         $menuDef['mail']['label'] = $LANG->getLL('email',1);
01177                         $menuDef['mail']['url'] = '#';
01178                         $menuDef['mail']['addParams'] = 'onclick="jumpToUrl(\'?act=mail\');return false;"';
01179                 }
01180                 if (is_array($this->thisConfig['userLinks.']) && in_array('spec',$allowedItems)) {
01181                         $menuDef['spec']['isActive'] = $this->act=='spec';
01182                         $menuDef['spec']['label'] = $LANG->getLL('special',1);
01183                         $menuDef['spec']['url'] = '#';
01184                         $menuDef['spec']['addParams'] = 'onclick="jumpToUrl(\'?act=spec\');return false;"';
01185                 }
01186                 $content .= $this->doc->getTabMenuRaw($menuDef);
01187 
01188                         // Adding the menu and header to the top of page:
01189                 $content.=$this->printCurrentUrl($this->curUrlInfo['info']).'<br />';
01190 
01191 
01192                         // Depending on the current action we will create the actual module content for selecting a link:
01193                 switch($this->act)      {
01194                         case 'mail':
01195                                 $extUrl='
01196 
01197                         <!--
01198                                 Enter mail address:
01199                         -->
01200                                         <form action="" name="lurlform" id="lurlform">
01201                                                 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkMail">
01202                                                         <tr>
01203                                                                 <td>'.$GLOBALS['LANG']->getLL('emailAddress',1).':</td>
01204                                                                 <td><input type="text" name="lemail"'.$this->doc->formWidth(20).' value="'.htmlspecialchars($this->curUrlInfo['act']=='mail'?$this->curUrlInfo['info']:'').'" /> '.
01205                                                                         '<input type="submit" value="'.$GLOBALS['LANG']->getLL('setLink',1).'" onclick="setTarget(\'\');setValue(\'mailto:\'+document.lurlform.lemail.value); return link_current();" /></td>
01206                                                         </tr>
01207                                                 </table>
01208                                         </form>';
01209                                 $content.=$extUrl;
01210                         break;
01211                         case 'url':
01212                                 $extUrl='
01213 
01214                         <!--
01215                                 Enter External URL:
01216                         -->
01217                                         <form action="" name="lurlform" id="lurlform">
01218                                                 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkURL">
01219                                                         <tr>
01220                                                                 <td>URL:</td>
01221                                                                 <td><input type="text" name="lurl"'.$this->doc->formWidth(20).' value="'.htmlspecialchars($this->curUrlInfo['act']=='url'?$this->curUrlInfo['info']:'http://').'" /> '.
01222                                                                         '<input type="submit" value="'.$GLOBALS['LANG']->getLL('setLink',1).'" onclick="setValue(document.lurlform.lurl.value); return link_current();" /></td>
01223                                                         </tr>
01224                                                 </table>
01225                                         </form>';
01226                                 $content.=$extUrl;
01227                         break;
01228                         case 'file':
01229                                 $foldertree = t3lib_div::makeInstance('rteFolderTree');
01230                                 $foldertree->thisScript = $this->thisScript;
01231                                 $tree=$foldertree->getBrowsableTree();
01232 
01233                                 if (!$this->curUrlInfo['value'] || $this->curUrlInfo['act']!='file')    {
01234                                         $cmpPath='';
01235                                 } elseif (substr(trim($this->curUrlInfo['info']),-1)!='/')      {
01236                                         $cmpPath=PATH_site.dirname($this->curUrlInfo['info']).'/';
01237                                         if (!isset($this->expandFolder))                        $this->expandFolder = $cmpPath;
01238                                 } else {
01239                                         $cmpPath=PATH_site.$this->curUrlInfo['info'];
01240                                 }
01241 
01242                                 list(,,$specUid) = explode('_',$this->PM);
01243                                 $files = $this->expandFolder($foldertree->specUIDmap[$specUid]);
01244 
01245                                 $content.= '
01246 
01247                         <!--
01248                                 Wrapper table for folder tree / file list:
01249                         -->
01250                                         <table border="0" cellpadding="0" cellspacing="0" id="typo3-linkFiles">
01251                                                 <tr>
01252                                                         <td class="c-wCell" valign="top">'.$this->barheader($GLOBALS['LANG']->getLL('folderTree').':').$tree.'</td>
01253                                                         <td class="c-wCell" valign="top">'.$files.'</td>
01254                                                 </tr>
01255                                         </table>
01256                                         ';
01257                         break;
01258                         case 'spec':
01259                                 if (is_array($this->thisConfig['userLinks.']))  {
01260                                         $subcats=array();
01261                                         $v=$this->thisConfig['userLinks.'];
01262                                         reset($v);
01263                                         while(list($k2)=each($v))       {
01264                                                 $k2i = intval($k2);
01265                                                 if (substr($k2,-1)=='.' && is_array($v[$k2i.'.']))      {
01266 
01267                                                                 // Title:
01268                                                         $title = trim($v[$k2i]);
01269                                                         if (!$title)    {
01270                                                                 $title=$v[$k2i.'.']['url'];
01271                                                         } else {
01272                                                                 $title=$LANG->sL($title);
01273                                                         }
01274                                                                 // Description:
01275                                                         $description=$v[$k2i.'.']['description'] ? $LANG->sL($v[$k2i.'.']['description'],1).'<br />' : '';
01276 
01277                                                                 // URL + onclick event:
01278                                                         $onClickEvent='';
01279                                                         if (isset($v[$k2i.'.']['target']))      $onClickEvent.="setTarget('".$v[$k2i.'.']['target']."');";
01280                                                         $v[$k2i.'.']['url'] = str_replace('###_URL###',$this->siteURL,$v[$k2i.'.']['url']);
01281                                                         if (substr($v[$k2i.'.']['url'],0,7)=='http://' || substr($v[$k2i.'.']['url'],0,7)=='mailto:')   {
01282                                                                 $onClickEvent.="cur_href=unescape('".rawurlencode($v[$k2i.'.']['url'])."');link_current();";
01283                                                         } else {
01284                                                                 $onClickEvent.="link_spec(unescape('".$this->siteURL.rawurlencode($v[$k2i.'.']['url'])."'));";
01285                                                         }
01286 
01287                                                                 // Link:
01288                                                         $A=array('<a href="#" onclick="'.htmlspecialchars($onClickEvent).'return false;">','</a>');
01289 
01290                                                                 // Adding link to menu of user defined links:
01291                                                         $subcats[$k2i]='
01292                                                                 <tr>
01293                                                                         <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>
01294                                                                 </tr>';
01295                                                 }
01296                                         }
01297 
01298                                                 // Sort by keys:
01299                                         ksort($subcats);
01300 
01301                                                 // Add menu to content:
01302                                         $content.= '
01303 
01304                         <!--
01305                                 Special userdefined menu:
01306                         -->
01307                                                 <table border="0" cellpadding="1" cellspacing="1" id="typo3-linkSpecial">
01308                                                         <tr>
01309                                                                 <td class="bgColor5" class="c-wCell" valign="top"><strong>'.$LANG->getLL('special',1).'</strong></td>
01310                                                         </tr>
01311                                                         '.implode('',$subcats).'
01312                                                 </table>
01313                                                 ';
01314                                 }
01315                         break;
01316                         case 'page':
01317                         default:
01318                                 $pagetree = t3lib_div::makeInstance('rtePageTree');
01319                                 $pagetree->thisScript = $this->thisScript;
01320                                 $tree=$pagetree->getBrowsableTree();
01321                                 $cElements = $this->expandPage();
01322                                 $content.= '
01323 
01324                         <!--
01325                                 Wrapper table for page tree / record list:
01326                         -->
01327                                         <table border="0" cellpadding="0" cellspacing="0" id="typo3-linkPages">
01328                                                 <tr>
01329                                                         <td class="c-wCell" valign="top">'.$this->barheader($GLOBALS['LANG']->getLL('pageTree').':').$tree.'</td>
01330                                                         <td class="c-wCell" valign="top">'.$cElements.'</td>
01331                                                 </tr>
01332                                         </table>
01333                                         ';
01334                         break;
01335                 }
01336 
01337                 $content .= '
01338 
01339 
01340 
01341                         <!--
01342                                 Selecting title for link:
01343                         -->
01344                                 <form action="" name="ltitleform" id="ltargetform">
01345                                         <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkTarget">
01346                                                 <tr>
01347                                                         <td>'.$GLOBALS['LANG']->getLL('title',1).'</td>
01348                                                         <td><input type="text" name="ltitle" onchange="setTitle(this.value);" value="'.htmlspecialchars($this->setTitle).'"'.$this->doc->formWidth(10).' /></td>
01349                                                         <td><input type="submit" value="'.$GLOBALS['LANG']->getLL('update',1).'" onclick="return link_current();" /></td>
01350                                                 </tr>
01351                                         </table>
01352                                 </form>
01353 ';
01354 
01355                         // Target:
01356                 if ($this->act!='mail') {
01357                         $ltarget='
01358 
01359 
01360 
01361                         <!--
01362                                 Selecting target for link:
01363                         -->
01364                                 <form action="" name="ltargetform" id="ltargetform">
01365                                         <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkTarget">
01366                                                 <tr>
01367                                                         <td>'.$GLOBALS['LANG']->getLL('target',1).':</td>
01368                                                         <td><input type="text" name="ltarget" onchange="setTarget(this.value);" value="'.htmlspecialchars($this->setTarget).'"'.$this->doc->formWidth(10).' /></td>
01369                                                         <td>
01370                                                                 <select name="ltarget_type" onchange="setTarget(this.options[this.selectedIndex].value);document.ltargetform.ltarget.value=this.options[this.selectedIndex].value;this.selectedIndex=0;">
01371                                                                         <option></option>
01372                                                                         <option value="_top">'.$GLOBALS['LANG']->getLL('top',1).'</option>
01373                                                                         <option value="_blank">'.$GLOBALS['LANG']->getLL('newWindow',1).'</option>
01374                                                                 </select>
01375                                                         </td>
01376                                                         <td>';
01377 
01378                         if (($this->curUrlInfo['act']=="page" || $this->curUrlInfo['act']=='file') && $this->curUrlArray['href'])       {
01379                                 $ltarget.='
01380                                                         <input type="submit" value="'.$GLOBALS['LANG']->getLL('update',1).'" onclick="return link_current();" />';
01381                         }
01382 
01383                         $selectJS = '
01384                                 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)     {
01385                                         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;
01386                                         setTarget(document.ltargetform.ltarget.value);
01387                                 setTitle(document.ltitleform.ltitle.value);
01388                                         document.ltargetform.popup_width.selectedIndex=0;
01389                                         document.ltargetform.popup_height.selectedIndex=0;
01390                                 }
01391                         ';
01392 
01393                         $ltarget.='             </td>
01394                                                 </tr>
01395                                                 <tr>
01396                                                         <td>'.$GLOBALS['LANG']->getLL('target_popUpWindow',1).':</td>
01397                                                         <td colspan="3">
01398                                                                 <select name="popup_width" onchange="'.htmlspecialchars($selectJS).'">
01399                                                                         <option value="0">'.$GLOBALS['LANG']->getLL('target_popUpWindow_width',1).'</option>
01400                                                                         <option value="300">300</option>
01401                                                                         <option value="400">400</option>
01402                                                                         <option value="500">500</option>
01403                                                                         <option value="600">600</option>
01404                                                                         <option value="700">700</option>
01405                                                                         <option value="800">800</option>
01406                                                                 </select>
01407                                                                 x
01408                                                                 <select name="popup_height" onchange="'.htmlspecialchars($selectJS).'">
01409                                                                         <option value="0">'.$GLOBALS['LANG']->getLL('target_popUpWindow_height',1).'</option>
01410                                                                         <option value="200">200</option>
01411                                                                         <option value="300">300</option>
01412                                                                         <option value="400">400</option>
01413                                                                         <option value="500">500</option>
01414                                                                         <option value="600">600</option>
01415                                                                 </select>
01416                                                         </td>
01417                                                 </tr>
01418                                         </table>
01419                                 </form>';
01420 
01421                                 // Add "target selector" box to content:
01422                         $content.=$ltarget;
01423 
01424                                 // Add some space
01425                         $content.='<br /><br />';
01426                 }
01427 
01428                         // End page, return content:
01429                 $content.= $this->doc->endPage();
01430                 $content = $this->doc->insertStylesAndJS($content);
01431                 return $content;
01432         }
01433 
01439         function main_db()      {
01440 
01441                         // Starting content:
01442                 $content=$this->doc->startPage('TBE record selector');
01443 
01444                         // Init variable:
01445                 $pArr = explode('|',$this->bparams);
01446 
01447                         // Making the browsable pagetree:
01448                 $pagetree = t3lib_div::makeInstance('TBE_PageTree');
01449                 $pagetree->thisScript=$this->thisScript;
01450                 $pagetree->ext_pArrPages = !strcmp($pArr[3],'pages')?1:0;
01451                 $tree=$pagetree->getBrowsableTree();
01452 
01453                         // Making the list of elements, if applicable:
01454                 $cElements = $this->TBE_expandPage($pArr[3]);
01455 
01456                         // Putting the things together, side by side:
01457                 $content.= '
01458 
01459                         <!--
01460                                 Wrapper table for page tree / record list:
01461                         -->
01462                         <table border="0" cellpadding="0" cellspacing="0" id="typo3-EBrecords">
01463                                 <tr>
01464                                         <td class="c-wCell" valign="top">'.$this->barheader($GLOBALS['LANG']->getLL('pageTree').':').$tree.'</td>
01465                                         <td class="c-wCell" valign="top">'.$cElements.'</td>
01466                                 </tr>
01467                         </table>
01468                         ';
01469 
01470                         // Add some space
01471                 $content.='<br /><br />';
01472 
01473                         // End page, return content:
01474                 $content.= $this->doc->endPage();
01475                 $content = $this->doc->insertStylesAndJS($content);
01476                 return $content;
01477         }
01478 
01484         function main_file()    {
01485                 global $BE_USER;
01486 
01487                         // Starting content:
01488                 $content.=$this->doc->startPage('TBE file selector');
01489 
01490                         // Init variable:
01491                 $pArr = explode('|',$this->bparams);
01492 
01493                         // Create upload/create folder forms, if a path is given:
01494                 $fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
01495                 $fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
01496                 $path=$this->expandFolder;
01497                 if (!$path || !@is_dir($path))  {
01498                         $path = $fileProcessor->findTempFolder().'/';   // The closest TEMP-path is found
01499                 }
01500                 if ($path!='/' && @is_dir($path))       {
01501                         $uploadForm=$this->uploadForm($path);
01502                         $createFolder=$this->createFolder($path);
01503                 } else {
01504                         $createFolder='';
01505                         $uploadForm='';
01506                 }
01507                 if ($BE_USER->getTSConfigVal('options.uploadFieldsInTopOfEB'))  $content.=$uploadForm;
01508 
01509                         // Getting flag for showing/not showing thumbnails:
01510                 $noThumbs = $GLOBALS['BE_USER']->getTSConfigVal('options.noThumbsInEB');
01511 
01512                 if (!$noThumbs) {
01513                                 // MENU-ITEMS, fetching the setting for thumbnails from File>List module:
01514                         $_MOD_MENU = array('displayThumbs' => '');
01515                         $_MCONF['name']='file_list';
01516                         $_MOD_SETTINGS = t3lib_BEfunc::getModuleData($_MOD_MENU, t3lib_div::_GP('SET'), $_MCONF['name']);
01517                         $addParams = '&act='.$this->act.'&mode='.$this->mode.'&expandFolder='.rawurlencode($path).'&bparams='.rawurlencode($this->bparams);
01518                         $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>';
01519                 } else {
01520                         $thumbNailCheck='';
01521                 }
01522                 $noThumbs = $noThumbs ? $noThumbs : !$_MOD_SETTINGS['displayThumbs'];
01523 
01524                         // Create folder tree:
01525                 $foldertree = t3lib_div::makeInstance('TBE_FolderTree');
01526                 $foldertree->thisScript=$this->thisScript;
01527                 $foldertree->ext_noTempRecyclerDirs = ($this->mode == 'filedrag');
01528                 $tree=$foldertree->getBrowsableTree();
01529 
01530                 list(,,$specUid) = explode('_',$this->PM);
01531 
01532                 if ($this->mode=='filedrag')    {
01533                         $files = $this->TBE_dragNDrop($foldertree->specUIDmap[$specUid],$pArr[3]);
01534                 } else {
01535                         $files = $this->TBE_expandFolder($foldertree->specUIDmap[$specUid],$pArr[3],$noThumbs);
01536                 }
01537 
01538                         // Putting the parts together, side by side:
01539                 $content.= '
01540 
01541                         <!--
01542                                 Wrapper table for folder tree / file list:
01543                         -->
01544                         <table border="0" cellpadding="0" cellspacing="0" id="typo3-EBfiles">
01545                                 <tr>
01546                                         <td class="c-wCell" valign="top">'.$this->barheader($GLOBALS['LANG']->getLL('folderTree').':').$tree.'</td>
01547                                         <td class="c-wCell" valign="top">'.$files.'</td>
01548                                 </tr>
01549                         </table>
01550                         ';
01551                 $content.= $thumbNailCheck;
01552 
01553                         // Adding create folder + upload forms if applicable:
01554                 if (!$BE_USER->getTSConfigVal('options.uploadFieldsInTopOfEB')) $content.=$uploadForm;
01555                 if ($BE_USER->isAdmin() || $BE_USER->getTSConfigVal('options.createFoldersInEB'))       $content.=$createFolder;
01556 
01557                         // Add some space
01558                 $content.='<br /><br />';
01559 
01560                         // Ending page, returning content:
01561                 $content.= $this->doc->endPage();
01562                 $content = $this->doc->insertStylesAndJS($content);
01563                 return $content;
01564         }
01565 
01566 
01567 
01568 
01569 
01570 
01571 
01572 
01573 
01574 
01575 
01576 
01577 
01578 
01579 
01580 
01581 
01582 
01583 
01584         /******************************************************************
01585          *
01586          * Record listing
01587          *
01588          ******************************************************************/
01594         function expandPage()   {
01595                 global $BE_USER, $BACK_PATH;
01596 
01597                 $out='';
01598                 $expPageId = $this->expandPage;         // Set page id (if any) to expand
01599 
01600                         // If there is an anchor value (content element reference) in the element reference, then force an ID to expand:
01601                 if (!$this->expandPage && $this->curUrlInfo['cElement'])        {
01602                         $expPageId = $this->curUrlInfo['pageid'];       // Set to the current link page id.
01603                 }
01604 
01605                         // Draw the record list IF there is a page id to expand:
01606                 if ($expPageId && t3lib_div::testInt($expPageId) && $BE_USER->isInWebMount($expPageId)) {
01607 
01608                                 // Set header:
01609                         $out.=$this->barheader($GLOBALS['LANG']->getLL('contentElements').':');
01610 
01611                                 // Create header for listing, showing the page title/icon:
01612                         $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
01613                         $mainPageRec = t3lib_BEfunc::getRecordWSOL('pages',$expPageId);
01614                         $picon=t3lib_iconWorks::getIconImage('pages',$mainPageRec,'','');
01615                         $picon.= htmlspecialchars(t3lib_div::fixed_lgd_cs($mainPageRec['title'],$titleLen));
01616                         $out.=$picon.'<br />';
01617 
01618                                 // Look up tt_content elements from the expanded page:
01619                         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
01620                                                         'uid,header,hidden,starttime,endtime,fe_group,CType,colpos,bodytext',
01621                                                         'tt_content',
01622                                                         'pid='.intval($expPageId).
01623                                                                 t3lib_BEfunc::deleteClause('tt_content').
01624                                                                 t3lib_BEfunc::versioningPlaceholderClause('tt_content'),
01625                                                         '',
01626                                                         'colpos,sorting'
01627                                                 );
01628                         $cc = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
01629 
01630                                 // Traverse list of records:
01631                         $c=0;
01632                         while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
01633                                 $c++;
01634                                 $icon=t3lib_iconWorks::getIconImage('tt_content',$row,$BACK_PATH,'');
01635                                 if ($this->curUrlInfo['act']=='page' && $this->curUrlInfo['cElement']==$row['uid'])     {
01636                                         $arrCol='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/blinkarrow_left.gif','width="5" height="9"').' class="c-blinkArrowL" alt="" />';
01637                                 } else {
01638                                         $arrCol='';
01639                                 }
01640                                         // Putting list element HTML together:
01641                                 $out.='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/join'.($c==$cc?'bottom':'').'.gif','width="18" height="16"').' alt="" />'.
01642                                                 $arrCol.
01643                                                 '<a href="#" onclick="return link_typo3Page(\''.$expPageId.'\',\'#'.$row['uid'].'\');">'.
01644                                                 $icon.
01645                                                 htmlspecialchars(t3lib_div::fixed_lgd_cs($row['header'],$titleLen)).
01646                                                 '</a><br />';
01647 
01648                                         // Finding internal anchor points:
01649                                 if (t3lib_div::inList('text,textpic', $row['CType']))   {
01650                                         $split = preg_split('/(<a[^>]+name=[\'"]?([^"\'>[:space:]]+)[\'"]?[^>]*>)/i', $row['bodytext'], -1, PREG_SPLIT_DELIM_CAPTURE);
01651 
01652                                         foreach($split as $skey => $sval)       {
01653                                                 if (($skey%3)==2)       {
01654                                                                 // Putting list element HTML together:
01655                                                         $sval = substr($sval,0,100);
01656                                                         $out.='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/line.gif','width="18" height="16"').' alt="" />'.
01657                                                                         '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/join'.($skey+3>count($split)?'bottom':'').'.gif','width="18" height="16"').' alt="" />'.
01658                                                                         '<a href="#" onclick="return link_typo3Page(\''.$expPageId.'\',\'#'.rawurlencode($sval).'\');">'.
01659                                                                         htmlspecialchars(' <A> '.$sval).
01660                                                                         '</a><br />';
01661                                                 }
01662                                         }
01663                                 }
01664                         }
01665                 }
01666                 return $out;
01667         }
01668 
01675         function TBE_expandPage($tables)        {
01676                 global $TCA,$BE_USER, $BACK_PATH;
01677 
01678                 $out='';
01679                 if ($this->expandPage>=0 && t3lib_div::testInt($this->expandPage) && $BE_USER->isInWebMount($this->expandPage)) {
01680 
01681                                 // Set array with table names to list:
01682                         if (!strcmp(trim($tables),'*')) {
01683                                 $tablesArr = array_keys($TCA);
01684                         } else {
01685                                 $tablesArr = t3lib_div::trimExplode(',',$tables,1);
01686                         }
01687                         reset($tablesArr);
01688 
01689                                 // Headline for selecting records:
01690                         $out.=$this->barheader($GLOBALS['LANG']->getLL('selectRecords').':');
01691 
01692                                 // Create the header, showing the current page for which the listing is. Includes link to the page itself, if pages are amount allowed tables.
01693                         $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
01694                         $mainPageRec = t3lib_BEfunc::getRecordWSOL('pages',$this->expandPage);
01695                         $ATag='';
01696                         $ATag_e='';
01697                         $ATag2='';
01698                         if (in_array('pages',$tablesArr))       {
01699                                 $ficon=t3lib_iconWorks::getIcon('pages',$mainPageRec);
01700                                 $ATag="<a href=\"#\" onclick=\"return insertElement('pages', '".$mainPageRec['uid']."', 'db', ".t3lib_div::quoteJSvalue($mainPageRec['title']).", '', '', '".$ficon."','',1);\">";
01701                                 $ATag2="<a href=\"#\" onclick=\"return insertElement('pages', '".$mainPageRec['uid']."', 'db', ".t3lib_div::quoteJSvalue($mainPageRec['title']).", '', '', '".$ficon."','',0);\">";
01702                                 $ATag_alt=substr($ATag,0,-4).",'',1);\">";
01703                                 $ATag_e='</a>';
01704                         }
01705                         $picon=t3lib_iconWorks::getIconImage('pages',$mainPageRec,$BACK_PATH,'');
01706                         $pBicon=$ATag2?'<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/plusbullet2.gif','width="18" height="16"').' alt="" />':'';
01707                         $pText=htmlspecialchars(t3lib_div::fixed_lgd_cs($mainPageRec['title'],$titleLen));
01708                         $out.=$picon.$ATag2.$pBicon.$ATag_e.$ATag.$pText.$ATag_e.'<br />';
01709 
01710                                 // Initialize the record listing:
01711                         $id = $this->expandPage;
01712                         $pointer = t3lib_div::intInRange($this->pointer,0,100000);
01713                         $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
01714                         $pageinfo = t3lib_BEfunc::readPageAccess($id,$perms_clause);
01715                         $table='';
01716 
01717                                 // Generate the record list:
01718                         $dblist = t3lib_div::makeInstance('TBE_browser_recordList');
01719                         $dblist->thisScript=$this->thisScript;
01720                         $dblist->backPath = $GLOBALS['BACK_PATH'];
01721                         $dblist->thumbs = 0;
01722                         $dblist->calcPerms = $GLOBALS['BE_USER']->calcPerms($pageinfo);
01723                         $dblist->noControlPanels=1;
01724                         $dblist->clickMenuEnabled=0;
01725                         $dblist->tableList=implode(',',$tablesArr);
01726 
01727                         $dblist->start($id,t3lib_div::_GP('table'),$pointer,
01728                                 t3lib_div::_GP('search_field'),
01729                                 t3lib_div::_GP('search_levels'),
01730                                 t3lib_div::_GP('showLimit')
01731                         );
01732                         $dblist->setDispFields();
01733                         $dblist->generateList();
01734                         $dblist->writeBottom();
01735 
01736                                 //      Add the HTML for the record list to output variable:
01737                         $out.=$dblist->HTMLcode;
01738                         $out.=$dblist->getSearchBox();
01739                 }
01740 
01741                         // Return accumulated content:
01742                 return $out;
01743         }
01744 
01745 
01746 
01747 
01748 
01749 
01750 
01751 
01752 
01753 
01754 
01755 
01756         /******************************************************************
01757          *
01758          * File listing
01759          *
01760          ******************************************************************/
01768         function expandFolder($expandFolder=0,$extensionList='')        {
01769                 global $BACK_PATH;
01770 
01771                 $expandFolder = $expandFolder ? $expandFolder : $this->expandFolder;
01772                 $out='';
01773                 if ($expandFolder && $this->checkFolder($expandFolder)) {
01774 
01775                                 // Create header for filelisting:
01776                         $out.=$this->barheader($GLOBALS['LANG']->getLL('files').':');
01777 
01778                                 // Prepare current path value for comparison (showing red arrow)
01779                         if (!$this->curUrlInfo['value'])        {
01780                                 $cmpPath='';
01781                         } else {
01782                                 $cmpPath=PATH_site.$this->curUrlInfo['info'];
01783                         }
01784 
01785 
01786                                 // Create header element; The folder from which files are listed.
01787                         $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
01788                         $picon='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/i/_icon_webfolders.gif','width="18" height="16"').' alt="" />';
01789                         $picon.=htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($expandFolder),$titleLen));
01790                         $picon='<a href="#" onclick="return link_folder(\''.t3lib_div::rawUrlEncodeFP(substr($expandFolder,strlen(PATH_site))).'\');">'.$picon.'</a>';
01791                         $out.=$picon.'<br />';
01792 
01793                                 // Get files from the folder:
01794                         $files = t3lib_div::getFilesInDir($expandFolder,$extensionList,1,1);    // $extensionList="",$prependPath=0,$order='')
01795                         $c=0;
01796                         $cc=count($files);
01797 
01798                         if (is_array($files))   {
01799                                 foreach($files as $filepath)    {
01800                                         $c++;
01801                                         $fI=pathinfo($filepath);
01802 
01803                                                 // File icon:
01804                                         $icon = t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
01805 
01806                                                 // If the listed file turns out to be the CURRENT file, then show blinking arrow:
01807                                         if ($this->curUrlInfo['act']=="file" && $cmpPath==$filepath)    {
01808                                                 $arrCol='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/blinkarrow_left.gif','width="5" height="9"').' class="c-blinkArrowL" alt="" />';
01809                                         } else {
01810                                                 $arrCol='';
01811                                         }
01812 
01813                                                 // Get size and icon:
01814                                         $size=' ('.t3lib_div::formatSize(filesize($filepath)).'bytes)';
01815                                         $icon = '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/fileicons/'.$icon.'','width="18" height="16"').' title="'.htmlspecialchars($fI['basename'].$size).'" alt="" />';
01816 
01817                                                 // Put it all together for the file element:
01818                                         $out.='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/join'.($c==$cc?'bottom':'').'.gif','width="18" height="16"').' alt="" />'.
01819                                                         $arrCol.
01820                                                         '<a href="#" onclick="return link_folder(\''.t3lib_div::rawUrlEncodeFP(substr($filepath,strlen(PATH_site))).'\');">'.
01821                                                         $icon.
01822                                                         htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($filepath),$titleLen)).
01823                                                         '</a><br />';
01824                                 }
01825                         }
01826                 }
01827                 return $out;
01828         }
01829 
01838         function TBE_expandFolder($expandFolder=0,$extensionList='',$noThumbs=0)        {
01839                 global $LANG;
01840 
01841                 $expandFolder = $expandFolder ? $expandFolder : $this->expandFolder;
01842                 $out='';
01843                 if ($expandFolder && $this->checkFolder($expandFolder)) {
01844                                 // Listing the files:
01845                         $files = t3lib_div::getFilesInDir($expandFolder,$extensionList,1,1);    // $extensionList="",$prependPath=0,$order='')
01846                         $out.= $this->fileList($files, $expandFolder, $noThumbs);
01847                 }
01848 
01849                         // Return accumulated content for filelisting:
01850                 return $out;
01851         }
01852 
01861         function fileList($files, $folderName='', $noThumbs=0) {
01862                 global $LANG, $BACK_PATH;
01863 
01864                 $out='';
01865 
01866                         // Listing the files:
01867                 if (is_array($files))   {
01868 
01869                                 // Create headline (showing number of files):
01870                         $out.=$this->barheader(sprintf($GLOBALS['LANG']->getLL('files').' (%s):',count($files)));
01871 
01872                         $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
01873 
01874                                 // Create the header of current folder:
01875                         if($folderName) {
01876                                 $picon='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/i/_icon_webfolders.gif','width="18" height="16"').' alt="" />';
01877                                 $picon.=htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($folderName),$titleLen));
01878                                 $out.=$picon.'<br />';
01879                         }
01880 
01881                                 // Init graphic object for reading file dimensions:
01882                         $imgObj = t3lib_div::makeInstance('t3lib_stdGraphic');
01883                         $imgObj->init();
01884                         $imgObj->mayScaleUp=0;
01885                         $imgObj->tempPath=PATH_site.$imgObj->tempPath;
01886 
01887                                 // Traverse the file list:
01888                         $lines=array();
01889                         foreach($files as $filepath)    {
01890                                 $fI=pathinfo($filepath);
01891 
01892                                         // Thumbnail/size generation:
01893                                 if (t3lib_div::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'],$fI['extension']) && !$noThumbs)      {
01894                                         $imgInfo = $imgObj->getImageDimensions($filepath);
01895                                         $pDim = $imgInfo[0].'x'.$imgInfo[1].' pixels';
01896                                         $clickIcon = t3lib_BEfunc::getThumbNail($BACK_PATH.'thumbs.php',$filepath,'hspace="5" vspace="5" border="1"');
01897                                 } else {
01898                                         $clickIcon = '';
01899                                         $pDim = '';
01900                                 }
01901 
01902                                         // Create file icon:
01903                                 $ficon = t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
01904                                 $size=' ('.t3lib_div::formatSize(filesize($filepath)).'bytes'.($pDim?', '.$pDim:'').')';
01905                                 $icon = '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/fileicons/'.$ficon,'width="18" height="16"').' title="'.htmlspecialchars($fI['basename'].$size).'" class="absmiddle" alt="" />';
01906 
01907                                         // Create links for adding the file:
01908                                 if (strstr($filepath,',') || strstr($filepath,'|'))     {       // In case an invalid character is in the filepath, display error message:
01909                                         $eMsg = $LANG->JScharCode(sprintf($LANG->getLL('invalidChar'),', |'));
01910                                         $ATag = $ATag_alt = "<a href=\"#\" onclick=\"alert(".$eMsg.");return false;\">";
01911                                 } else {        // If filename is OK, just add it:
01912                                         $ATag = "<a href=\"#\" onclick=\"return insertElement('','".t3lib_div::shortMD5($filepath)."', 'file', ".t3lib_div::quoteJSvalue($fI['basename']).", ".t3lib_div::quoteJSvalue($filepath).", '".$fI['extension']."', '".$ficon."');\">";
01913                                         $ATag_alt = substr($ATag,0,-4).",'',1);\">";
01914                                 }
01915                                 $ATag_e='</a>';
01916 
01917                                         // Create link to showing details about the file in a window:
01918                                 $Ahref = $BACK_PATH.'show_item.php?table='.rawurlencode($filepath).'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
01919                                 $ATag2='<a href="'.htmlspecialchars($Ahref).'">';
01920                                 $ATag2_e='</a>';
01921 
01922                                         // Combine the stuff:
01923                                         $filenameAndIcon=$ATag_alt.$icon.htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($filepath),$titleLen)).$ATag_e;
01924 
01925                                         // Show element:
01926                                 if ($pDim)      {               // Image...
01927                                         $lines[]='
01928                                                 <tr class="bgColor4">
01929                                                         <td nowrap="nowrap">'.$filenameAndIcon.'&nbsp;</td>
01930                                                         <td>'.$ATag.'<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/plusbullet2.gif','width="18" height="16"').' title="'.$LANG->getLL('addToList',1).'" alt="" />'.$ATag_e.'</td>
01931                                                         <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>
01932                                                         <td nowrap="nowrap">&nbsp;'.$pDim.'</td>
01933                                                 </tr>';
01934                                         $lines[]='
01935                                                 <tr>
01936                                                         <td colspan="4">'.$ATag_alt.$clickIcon.$ATag_e.'</td>
01937                                                 </tr>';
01938                                 } else {
01939                                         $lines[]='
01940                                                 <tr class="bgColor4">
01941                                                         <td nowrap="nowrap">'.$filenameAndIcon.'&nbsp;</td>
01942                                                         <td>'.$ATag.'<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/plusbullet2.gif','width="18" height="16"').' title="'.$LANG->getLL('addToList',1).'" alt="" />'.$ATag_e.'</td>
01943                                                         <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>
01944                                                         <td>&nbsp;</td>
01945                                                 </tr>';
01946                                 }
01947                                 $lines[]='
01948                                                 <tr>
01949                                                         <td colspan="3"><img src="clear.gif" width="1" height="3" alt="" /></td>
01950                                                 </tr>';
01951                         }
01952 
01953                                 // Wrap all the rows in table tags:
01954                         $out.='
01955 
01956 
01957 
01958                 <!--
01959                         File listing
01960                 -->
01961                                 <table border="0" cellpadding="0" cellspacing="1" id="typo3-fileList">
01962                                         '.implode('',$lines).'
01963                                 </table>';
01964                 }
01965 
01966                         // Return accumulated content for filelisting:
01967                 return $out;
01968         }
01969 
01978         function TBE_dragNDrop($expandFolder=0,$extensionList='')       {
01979                 global $BACK_PATH;
01980 
01981                 $expandFolder = $expandFolder ? $expandFolder : $this->expandFolder;
01982                 $out='';
01983                 if ($expandFolder && $this->checkFolder($expandFolder)) {
01984                         if ($this->isWebFolder($expandFolder))  {
01985 
01986                                         // Read files from directory:
01987                                 $files = t3lib_div::getFilesInDir($expandFolder,$extensionList,1,1);    // $extensionList="",$prependPath=0,$order='')
01988                                 if (is_array($files))   {
01989                                         $out.=$this->barheader(sprintf($GLOBALS['LANG']->getLL('files').' (%s):',count($files)));
01990 
01991                                         $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
01992                                         $picon='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/i/_icon_webfolders.gif','width="18" height="16"').' alt="" />';
01993                                         $picon.=htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($expandFolder),$titleLen));
01994                                         $out.=$picon.'<br />';
01995 
01996                                                 // Init row-array:
01997                                         $lines=array();
01998 
01999                                                 // Add "drag-n-drop" message:
02000                                         $lines[]='
02001                                                 <tr>
02002                                                         <td colspan="2">'.$this->getMsgBox($GLOBALS['LANG']->getLL('findDragDrop')).'</td>
02003                                                 </tr>';
02004 
02005                                                 // Fraverse files:
02006                                         while(list(,$filepath)=each($files))    {
02007                                                 $fI=pathinfo($filepath);
02008 
02009                                                         // URL of image:
02010                                                 $iurl = $this->siteURL.t3lib_div::rawurlencodeFP(substr($filepath,strlen(PATH_site)));
02011 
02012                                                         // Show only web-images
02013                                                 if (t3lib_div::inList('gif,jpeg,jpg,png',$fI['extension']))     {
02014                                                         $imgInfo = @getimagesize($filepath);
02015                                                         $pDim = $imgInfo[0].'x'.$imgInfo[1].' pixels';
02016 
02017                                                         $ficon = t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
02018                                                         $size=' ('.t3lib_div::formatSize(filesize($filepath)).'bytes'.($pDim?', '.$pDim:'').')';
02019                                                         $icon = '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/fileicons/'.$ficon,'width="18" height="16"').' class="absmiddle" title="'.htmlspecialchars($fI['basename'].$size).'" alt="" />';
02020                                                         $filenameAndIcon=$icon.htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($filepath),$titleLen));
02021 
02022                                                         if (t3lib_div::_GP('noLimit'))  {
02023                                                                 $maxW=10000;
02024                                                                 $maxH=10000;
02025                                                         } else {
02026                                                                 $maxW=380;
02027                                                                 $maxH=500;
02028                                                         }
02029                                                         $IW = $imgInfo[0];
02030                                                         $IH = $imgInfo[1];
02031                                                         if ($IW>$maxW)  {
02032                                                                 $IH=ceil($IH/$IW*$maxW);
02033                                                                 $IW=$maxW;
02034                                                         }
02035                                                         if ($IH>$maxH)  {
02036                                                                 $IW=ceil($IW/$IH*$maxH);
02037                                                                 $IH=$maxH;
02038                                                         }
02039 
02040                                                                 // Make row:
02041                                                         $lines[]='
02042                                                                 <tr class="bgColor4">
02043                                                                         <td nowrap="nowrap">'.$filenameAndIcon.'&nbsp;</td>
02044                                                                         <td nowrap="nowrap">'.
02045                                                                         ($imgInfo[0]!=$IW ? '<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('noLimit'=>'1'))).'">'.
02046                                                                                                                 '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/icon_warning2.gif','width="18" height="16"').' title="'.$GLOBALS['LANG']->getLL('clickToRedrawFullSize',1).'" alt="" />'.
02047                                                                                                                 '</a>':'').
02048                                                                         $pDim.'&nbsp;</td>
02049                                                                 </tr>';
02050 
02051                                                         $lines[]='
02052                                                                 <tr>
02053                                                                         <td colspan="2"><img src="'.$iurl.'" width="'.$IW.'" height="'.$IH.'" border="1" alt="" /></td>
02054                                                                 </tr>';
02055                                                         $lines[]='
02056                                                                 <tr>
02057                                                                         <td colspan="2"><img src="clear.gif" width="1" height="3" alt="" /></td>
02058                                                                 </tr>';
02059                                                 }
02060                                         }
02061 
02062                                                 // Finally, wrap all rows in a table tag:
02063                                         $out.='
02064 
02065 
02066                         <!--
02067                                 File listing / Drag-n-drop
02068                         -->
02069                                                 <table border="0" cellpadding="0" cellspacing="1" id="typo3-dragBox">
02070                                                         '.implode('',$lines).'
02071                                                 </table>';
02072                                 }
02073                         } else {
02074                                         // Print this warning if the folder is NOT a web folder:
02075                                 $out.=$this->barheader($GLOBALS['LANG']->getLL('files'));
02076                                 $out.=$this->getMsgBox($GLOBALS['LANG']->getLL('noWebFolder'),'icon_warning2');
02077                         }
02078                 }
02079                 return $out;
02080         }
02081 
02082 
02083 
02084 
02085 
02086 
02087 
02088 
02089 
02090 
02091 
02092 
02093         /******************************************************************
02094          *
02095          * Miscellaneous functions
02096          *
02097          ******************************************************************/
02098 
02099 
02106         function isWebFolder($folder)   {
02107                 $folder = ereg_replace('\/$','',$folder).'/';
02108                 return t3lib_div::isFirstPartOfStr($folder,PATH_site) ? TRUE : FALSE;
02109         }
02110 
02117         function checkFolder($folder)   {
02118                 $fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
02119                 $fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
02120 
02121                 return $fileProcessor->checkPathAgainstMounts(ereg_replace('\/$','',$folder).'/') ? TRUE : FALSE;
02122         }
02123 
02130         function barheader($str)        {
02131                 return '
02132 
02133                         <!--
02134                                 Bar header:
02135                         -->
02136                         <h3 class="bgColor5">'.htmlspecialchars($str).'</h3>
02137                         ';
02138         }
02139 
02147         function getMsgBox($in_msg,$icon='icon_note')   {
02148                 global $BACK_PATH;
02149 
02150                 $msg = '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/'.$icon.'.gif','width="18" height="16"').' alt="" />'.htmlspecialchars($in_msg);
02151                 $msg = '
02152 
02153                         <!--
02154                                 Message box:
02155                         -->
02156                         <table cellspacing="0" class="bgColor4" id="typo3-msgBox">
02157                                 <tr>
02158                                         <td>'.$msg.'</td>
02159                                 </tr>
02160                         </table>
02161                         ';
02162                 return $msg;
02163         }
02164 
02171         function printCurrentUrl($str)  {
02172                 return '
02173 
02174                         <!--
02175                                 Print current URL
02176                         -->
02177                         <table border="0" cellpadding="0" cellspacing="0" class="bgColor5" id="typo3-curUrl">
02178                                 <tr>
02179                                         <td>'.$GLOBALS['LANG']->getLL('currentLink',1).': '.htmlspecialchars(rawurldecode($str)).'</td>
02180                                 </tr>
02181                         </table>';
02182         }
02183 
02191         function parseCurUrl($href,$siteUrl)    {
02192                 $href = trim($href);
02193                 if ($href)      {
02194                         $info=array();
02195 
02196                                 // Default is "url":
02197                         $info['value']=$href;
02198                         $info['act']='url';
02199 
02200                         $specialParts = explode('#_SPECIAL',$href);
02201                         if (count($specialParts)==2)    {       // Special kind (Something RTE specific: User configurable links through: "userLinks." from ->thisConfig)
02202                                 $info['value']='#_SPECIAL'.$specialParts[1];
02203                                 $info['act']='spec';
02204                         } elseif (t3lib_div::isFirstPartOfStr($href,$siteUrl))  {       // If URL is on the current frontend website:
02205                                 $rel = substr($href,strlen($siteUrl));
02206                                 if (@file_exists(PATH_site.rawurldecode($rel))) {       // URL is a file, which exists:
02207                                         $info['value']=rawurldecode($rel);
02208                                         $info['act']='file';
02209                                 } else {        // URL is a page (id parameter)
02210                                         $uP=parse_url($rel);
02211                                         if (!trim($uP['path'])) {
02212                                                 $pp = explode('id=',$uP['query']);
02213                                                 $id = $pp[1];
02214                                                 if ($id)        {
02215                                                                 // Checking if the id-parameter is an alias.
02216                                                         if (!t3lib_div::testInt($id))   {
02217                                                                 list($idPartR) = t3lib_BEfunc::getRecordsByField('pages','alias',$id);
02218                                                                 $id=intval($idPartR['uid']);
02219                                                         }
02220 
02221                                                         $pageRow = t3lib_BEfunc::getRecordWSOL('pages',$id);
02222                                                         $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
02223                                                         $info['value']=$GLOBALS['LANG']->getLL('page',1)." '".htmlspecialchars(t3lib_div::fixed_lgd_cs($pageRow['title'],$titleLen))."' (ID:".$id.($uP['fragment']?', #'.$uP['fragment']:'').')';
02224                                                         $info['pageid']=$id;
02225                                                         $info['cElement']=$uP['fragment'];
02226                                                         $info['act']='page';
02227                                                 }
02228                                         }
02229                                 }
02230                         } else {        // Email link:
02231                                 if (strtolower(substr($href,0,7))=='mailto:')   {
02232                                         $info['value']=trim(substr($href,7));
02233                                         $info['act']='mail';
02234                                 }
02235                         }
02236                         $info['info'] = $info['value'];
02237                 } else {        // NO value inputted:
02238                         $info=array();
02239                         $info['info']=$GLOBALS['LANG']->getLL('none');
02240                         $info['value']='';
02241                         $info['act']='page';
02242                 }
02243                 return $info;
02244         }
02245 
02253         function uploadForm($path)      {
02254                 global $BACK_PATH;
02255                 $count=3;
02256 
02257                         // Create header, showing upload path:
02258                 $header = t3lib_div::isFirstPartOfStr($path,PATH_site)?substr($path,strlen(PATH_site)):$path;
02259                 $code=$this->barheader($GLOBALS['LANG']->getLL('uploadImage').':');
02260                 $code.='
02261 
02262                         <!--
02263                                 Form, for uploading files:
02264                         -->
02265                         <form action="'.$BACK_PATH.'tce_file.php" method="post" name="editform" enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'">
02266                                 <table border="0" cellpadding="0" cellspacing="3" id="typo3-uplFiles">
02267                                         <tr>
02268                                                 <td><strong>'.$GLOBALS['LANG']->getLL('path',1).':</strong> '.htmlspecialchars($header).'</td>
02269                                         </tr>
02270                                         <tr>
02271                                                 <td>';
02272 
02273                         // Traverse the number of upload fields (default is 3):
02274                 for ($a=1;$a<=$count;$a++)      {
02275                         $code.='<input type="file" name="upload_'.$a.'"'.$this->doc->formWidth(35).' size="50" />
02276                                 <input type="hidden" name="file[upload]['.$a.'][target]" value="'.htmlspecialchars($path).'" />
02277                                 <input type="hidden" name="file[upload]['.$a.'][data]" value="'.$a.'" /><br />';
02278                 }
02279 
02280                         // Make footer of upload form, including the submit button:
02281                 $redirectValue = $this->thisScript.'?act='.$this->act.'&mode='.$this->mode.'&expandFolder='.rawurlencode($path).'&bparams='.rawurlencode($this->bparams);
02282                 $code.='<input type="hidden" name="redirect" value="'.htmlspecialchars($redirectValue).'" />'.
02283                                 '<input type="submit" name="submit" value="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_upload.php.submit',1).'" />';
02284 
02285                 $code.='
02286                         <div id="c-override">
02287                                 <input type="checkbox" name="overwriteExistingFiles" id="overwriteExistingFiles" value="1" /> <label for="overwriteExistingFiles">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xml:overwriteExistingFiles',1).'</label>
02288                         </div>
02289                 ';
02290 
02291 
02292                 $code.='</td>
02293                                         </tr>
02294                                 </table>
02295                         </form>';
02296 
02297                 return $code;
02298         }
02299 
02307         function createFolder($path)    {
02308                 global $BACK_PATH;
02309                         // Create header, showing upload path:
02310                 $header = t3lib_div::isFirstPartOfStr($path,PATH_site)?substr($path,strlen(PATH_site)):$path;
02311                 $code=$this->barheader($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.pagetitle').':');
02312                 $code.='
02313 
02314                         <!--
02315                                 Form, for creating new folders:
02316                         -->
02317                         <form action="'.$BACK_PATH.'tce_file.php" method="post" name="editform2">
02318                                 <table border="0" cellpadding="0" cellspacing="3" id="typo3-crFolder">
02319                                         <tr>
02320                                                 <td><strong>'.$GLOBALS['LANG']->getLL('path',1).':</strong> '.htmlspecialchars($header).'</td>
02321                                         </tr>
02322                                         <tr>
02323                                                 <td>';
02324 
02325                         // Create the new-folder name field:
02326                 $a=1;
02327                 $code.='<input'.$this->doc->formWidth(20).' type="text" name="file[newfolder]['.$a.'][data]" />'.
02328                                 '<input type="hidden" name="file[newfolder]['.$a.'][target]" value="'.htmlspecialchars($path).'" />';
02329 
02330                         // Make footer of upload form, including the submit button:
02331                 $redirectValue = $this->thisScript.'?act='.$this->act.'&mode='.$this->mode.'&expandFolder='.rawurlencode($path).'&bparams='.rawurlencode($this->bparams);
02332                 $code.='<input type="hidden" name="redirect" value="'.htmlspecialchars($redirectValue).'" />'.
02333                                 '<input type="submit" name="submit" value="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.submit',1).'" />';
02334 
02335                 $code.='</td>
02336                                         </tr>
02337                                 </table>
02338                         </form>';
02339 
02340                 return $code;
02341         }
02342 }
02343 
02344 // Include extension?
02345 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.browse_links.php'])    {
02346         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.browse_links.php']);
02347 }
02348 
02349 
02350 ?>


Généré par Les experts TYPO3 avec  doxygen 1.4.6