typo3/browse_links.php

Go to the documentation of this file.
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 ***************************************************************/
00116 $BACK_PATH='';
00117 require ('init.php');
00118 require ('template.php');
00119 require_once (PATH_t3lib.'class.t3lib_browsetree.php');
00120 require_once (PATH_t3lib.'class.t3lib_foldertree.php');
00121 require_once (PATH_t3lib.'class.t3lib_stdgraphic.php');
00122 require_once (PATH_t3lib.'class.t3lib_basicfilefunc.php');
00123 $LANG->includeLLFile('EXT:lang/locallang_browse_links.xml');
00124 
00125 
00126         // Include classes
00127 require_once (PATH_t3lib.'class.t3lib_page.php');
00128 require_once (PATH_t3lib.'class.t3lib_recordlist.php');
00129 require_once ('class.db_list.inc');
00130 require_once ('class.db_list_extra.inc');
00131 
00132 
00133 
00134 
00135 
00136 
00137 
00138 
00139 
00140 
00141 
00142 
00143 
00144 
00145 
00146 
00147 
00148 
00149 
00157 class TBE_browser_recordList extends localRecordList {
00158         var $script='browse_links.php';
00159 
00168         function listURL($altId='',$table=-1,$exclList='')      {
00169                 return $this->script.
00170                         '?id='.(strcmp($altId,'')?$altId:$this->id).
00171                         '&table='.rawurlencode($table==-1?$this->table:$table).
00172                         ($this->thumbs?'&imagemode='.$this->thumbs:'').
00173                         ($this->searchString?'&search_field='.rawurlencode($this->searchString):'').
00174                         ($this->searchLevels?'&search_levels='.rawurlencode($this->searchLevels):'').
00175                         ((!$exclList || !t3lib_div::inList($exclList,'sortField')) && $this->sortField?'&sortField='.rawurlencode($this->sortField):'').
00176                         ((!$exclList || !t3lib_div::inList($exclList,'sortRev')) && $this->sortRev?'&sortRev='.rawurlencode($this->sortRev):'').
00177                                 // extra:
00178                         $this->ext_addP()
00179                         ;
00180         }
00181 
00187         function ext_addP()     {
00188                 $str = '&act='.$GLOBALS['SOBE']->act.
00189                                 '&mode='.$GLOBALS['SOBE']->mode.
00190                                 '&expandPage='.$GLOBALS['SOBE']->expandPage.
00191                                 '&bparams='.rawurlencode($GLOBALS['SOBE']->bparams);
00192                 return $str;
00193         }
00194 
00204         function linkWrapItems($table,$uid,$code,$row)  {
00205                 global $TCA;
00206 
00207                 if (!$code) {
00208                         $code = '<i>['.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.no_title',1).']</i>';
00209                 } else {
00210                         $code = htmlspecialchars(t3lib_div::fixed_lgd_cs($code,$this->fixedL));
00211                 }
00212 
00213                 $titleCol = $TCA[$table]['ctrl']['label'];
00214                 $title = $row[$titleCol];
00215 
00216                 $ficon = t3lib_iconWorks::getIcon($table,$row);
00217                 $aOnClick = "return insertElement('".$table."', '".$row['uid']."', 'db', unescape('".rawurlencode($title)."'), '', '', '".$ficon."');";
00218                 $ATag = '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">';
00219                 $ATag_alt = substr($ATag,0,-4).',\'\',1);">';
00220                 $ATag_e = '</a>';
00221 
00222                 return $ATag.
00223                                 '<img'.t3lib_iconWorks::skinImg('','gfx/plusbullet2.gif','width="18" height="16"').' title="'.$GLOBALS['LANG']->getLL('addToList',1).'" alt="" />'.
00224                                 $ATag_e.
00225                                 $ATag_alt.
00226                                 $code.
00227                                 $ATag_e;
00228         }
00229 
00237         function linkWrapTable($table,$code)    {
00238                 return $code;
00239         }
00240 }
00241 
00242 
00243 
00244 
00245 
00246 
00254 class localPageTree extends t3lib_browseTree {
00255 
00261         function localPageTree() {
00262                 $this->init();
00263 
00264                 $this->clause = ' AND doktype!=255'.$this->clause;
00265         }
00266 
00275         function wrapTitle($title,$v,$ext_pArrPages='') {
00276                 if ($this->ext_isLinkable($v['doktype'],$v['uid']))     {
00277                         $aOnClick = "return link_typo3Page('".$v['uid']."');";
00278                         return '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$title.'</a>';
00279                 } else {
00280                         return '<span style="color: #666666;">'.$title.'</span>';
00281                 }
00282         }
00283 
00290         function printTree($treeArr='') {
00291                 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
00292                 if (!is_array($treeArr))        $treeArr=$this->tree;
00293 
00294                 $out='';
00295                 $c=0;
00296 
00297                 foreach($treeArr as $k => $v)   {
00298                         $c++;
00299                         $bgColorClass = ($c+1)%2 ? 'bgColor' : 'bgColor-10';
00300                         if ($GLOBALS['SOBE']->curUrlInfo['act']=='page' && $GLOBALS['SOBE']->curUrlInfo['pageid']==$v['row']['uid'] && $GLOBALS['SOBE']->curUrlInfo['pageid'])  {
00301                                 $arrCol='<td><img'.t3lib_iconWorks::skinImg('','gfx/blinkarrow_right.gif','width="5" height="9"').' class="c-blinkArrowR" alt="" /></td>';
00302                                 $bgColorClass='bgColor4';
00303                         } else {
00304                                 $arrCol='<td></td>';
00305                         }
00306 
00307                         $aOnClick = 'return jumpToUrl(\''.$this->script.'?act='.$GLOBALS['SOBE']->act.'&mode='.$GLOBALS['SOBE']->mode.'&expandPage='.$v['row']['uid'].'\');';
00308                         $cEbullet = $this->ext_isLinkable($v['row']['doktype'],$v['row']['uid']) ?
00309                                                 '<a href="#" onclick="'.htmlspecialchars($aOnClick).'"><img'.t3lib_iconWorks::skinImg('','gfx/ol/arrowbullet.gif','width="18" height="16"').' alt="" /></a>' :
00310                                                 '';
00311                         $out.='
00312                                 <tr class="'.$bgColorClass.'">
00313                                         <td nowrap="nowrap">'.
00314                                         $v['HTML'].
00315                                         $this->wrapTitle($this->getTitleStr($v['row'],$titleLen),$v['row'],$this->ext_pArrPages).
00316                                         '</td>'.
00317                                         $arrCol.
00318                                         '<td>'.$cEbullet.'</td>
00319                                 </tr>';
00320                 }
00321                 $out='
00322 
00323 
00324                         <!--
00325                                 Navigation Page Tree:
00326                         -->
00327                         <table border="0" cellpadding="0" cellspacing="0" id="typo3-tree">
00328                                 '.$out.'
00329                         </table>';
00330                 return $out;
00331         }
00332 
00340         function ext_isLinkable($doktype,$uid)  {
00341                 if ($uid && $doktype<199)       {
00342                         return true;
00343                 }
00344         }
00345 
00354         function PM_ATagWrap($icon,$cmd,$bMark='')      {
00355                 if ($bMark)     {
00356                         $anchor = '#'.$bMark;
00357                         $name=' name="'.$bMark.'"';
00358                 }
00359                 $aOnClick = "return jumpToUrl('".$this->script.'?PM='.$cmd."','".$anchor."');";
00360 
00361                 return '<a href="#"'.$name.' onclick="'.htmlspecialchars($aOnClick).'">'.$icon.'</a>';
00362         }
00363 
00371         function wrapIcon($icon,$row)   {
00372                 return $this->addTagAttributes($icon,' title="id='.$row['uid'].'"');
00373         }
00374 }
00375 
00376 
00377 
00378 
00379 
00380 
00381 
00382 
00390 class rtePageTree extends localPageTree {
00391 }
00392 
00393 
00394 
00395 
00396 
00397 
00398 
00399 
00407 class TBE_PageTree extends localPageTree {
00408 
00416         function ext_isLinkable($doktype,$uid)  {
00417                 return true;
00418         }
00419 
00428         function wrapTitle($title,$v,$ext_pArrPages)    {
00429                 if ($ext_pArrPages)     {
00430                         $ficon=t3lib_iconWorks::getIcon('pages',$v);
00431                         $onClick = "return insertElement('pages', '".$v['uid']."', 'db', unescape('".rawurlencode($v['title'])."'), '', '', '".$ficon."','',1);";
00432                 } else {
00433                         $onClick = 'return jumpToUrl(\'browse_links.php?act='.$GLOBALS['SOBE']->act.'&mode='.$GLOBALS['SOBE']->mode.'&expandPage='.$v['uid'].'\');';
00434                 }
00435                 return '<a href="#" onclick="'.htmlspecialchars($onClick).'">'.$title.'</a>';
00436         }
00437 }
00438 
00439 
00440 
00441 
00442 
00443 
00444 
00445 
00454 class localFolderTree extends t3lib_folderTree {
00455         var $ext_IconMode=1;
00456 
00464         function wrapTitle($title,$v)   {
00465                 if ($this->ext_isLinkable($v))  {
00466                         $aOnClick = 'return jumpToUrl(\''.$this->script.'?act='.$GLOBALS['SOBE']->act.'&mode='.$GLOBALS['SOBE']->mode.'&expandFolder='.rawurlencode($v['path']).'\');';
00467                         return '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$title.'</a>';
00468                 } else {
00469                         return '<span class="typo3-dimmed">'.$title.'</span>';
00470                 }
00471         }
00472 
00479         function ext_isLinkable($v)     {
00480                 $webpath=t3lib_BEfunc::getPathType_web_nonweb($v['path']);      // Checking, if the input path is a web-path.
00481                 if (strstr($v['path'],'_recycler_') || strstr($v['path'],'_temp_') || $webpath!='web')  {
00482                         return 0;
00483                 }
00484                 return 1;
00485         }
00486 
00496         function PM_ATagWrap($icon,$cmd,$bMark='')      {
00497                 if ($bMark)     {
00498                         $anchor = '#'.$bMark;
00499                         $name=' name="'.$bMark.'"';
00500                 }
00501                 $aOnClick = 'return jumpToUrl(\''.$this->script.'?PM='.$cmd.'\',\''.$anchor.'\');';
00502                 return '<a href="#"'.$name.' onclick="'.htmlspecialchars($aOnClick).'">'.$icon.'</a>';
00503         }
00504 
00511         function printTree($treeArr='') {
00512                 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
00513 
00514                 if (!is_array($treeArr))        $treeArr=$this->tree;
00515 
00516                 $out='';
00517                 $c=0;
00518 
00519                         // Preparing the current-path string (if found in the listing we will see a red blinking arrow).
00520                 if (!$GLOBALS['SOBE']->curUrlInfo['value'])     {
00521                         $cmpPath='';
00522                 } else if (substr(trim($GLOBALS['SOBE']->curUrlInfo['info']),-1)!='/')  {
00523                         $cmpPath=PATH_site.dirname($GLOBALS['SOBE']->curUrlInfo['info']).'/';
00524                 } else {
00525                         $cmpPath=PATH_site.$GLOBALS['SOBE']->curUrlInfo['info'];
00526                 }
00527 
00528                         // Traverse rows for the tree and print them into table rows:
00529                 foreach($treeArr as $k => $v)   {
00530                         $c++;
00531                         $bgColorClass=($c+1)%2 ? 'bgColor' : 'bgColor-10';
00532 
00533                                 // Creating blinking arrow, if applicable:
00534                         if ($GLOBALS['SOBE']->curUrlInfo['act']=='file' && $cmpPath==$v['row']['path']) {
00535                                 $arrCol='<td><img'.t3lib_iconWorks::skinImg('','gfx/blinkarrow_right.gif','width="5" height="9"').' class="c-blinkArrowR" alt="" /></td>';
00536                                 $bgColorClass='bgColor4';
00537                         } else {
00538                                 $arrCol='<td></td>';
00539                         }
00540                                 // Create arrow-bullet for file listing (if folder path is linkable):
00541                         $aOnClick = 'return jumpToUrl(\''.$this->script.'?act='.$GLOBALS['SOBE']->act.'&mode='.$GLOBALS['SOBE']->mode.'&expandFolder='.rawurlencode($v['row']['path']).'\');';
00542                         $cEbullet = $this->ext_isLinkable($v['row']) ? '<a href="#" onclick="'.htmlspecialchars($aOnClick).'"><img'.t3lib_iconWorks::skinImg('','gfx/ol/arrowbullet.gif','width="18" height="16"').' alt="" /></a>' : '';
00543 
00544                                 // Put table row with folder together:
00545                         $out.='
00546                                 <tr class="'.$bgColorClass.'">
00547                                         <td nowrap="nowrap">'.$v['HTML'].$this->wrapTitle(t3lib_div::fixed_lgd_cs($v['row']['title'],$titleLen),$v['row']).'</td>
00548                                         '.$arrCol.'
00549                                         <td>'.$cEbullet.'</td>
00550                                 </tr>';
00551                 }
00552 
00553                 $out='
00554 
00555                         <!--
00556                                 Folder tree:
00557                         -->
00558                         <table border="0" cellpadding="0" cellspacing="0" id="typo3-tree">
00559                                 '.$out.'
00560                         </table>';
00561                 return $out;
00562         }
00563 }
00564 
00565 
00566 
00567 
00568 
00569 
00577 class rteFolderTree extends localFolderTree {
00578 }
00579 
00580 
00581 
00582 
00583 
00584 
00585 
00593 class TBE_FolderTree extends localFolderTree {
00594         var $ext_noTempRecyclerDirs=0;          // If file-drag mode is set, temp and recycler folders are filtered out.
00595 
00602         function ext_isLinkable($v)     {
00603                 if ($this->ext_noTempRecyclerDirs && (substr($v['path'],-7)=='_temp_/' || substr($v['path'],-11)=='_recycler_/'))       {
00604                         return 0;
00605                 } return 1;
00606         }
00607 
00615         function wrapTitle($title,$v)   {
00616                 if ($this->ext_isLinkable($v))  {
00617                         $aOnClick = 'return jumpToUrl(\'browse_links.php?act='.$GLOBALS['SOBE']->act.'&mode='.$GLOBALS['SOBE']->mode.'&expandFolder='.rawurlencode($v['path']).'\');';
00618                         return '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$title.'</a>';
00619                 } else {
00620                         return '<span class="typo3-dimmed">'.$title.'</span>';
00621                 }
00622         }
00623 }
00624 
00625 
00626 
00627 
00628 
00636 class SC_browse_links {
00637 
00638                 // Internal, static:
00639         var $siteURL;                   // Current site URL (Frontend)
00640         var $thisConfig;                // RTE specific TSconfig
00641         var $setTarget;                 // Target (RTE specific)
00642         var $doc;                               // Backend template object
00643 
00644                 // GPvars:      (Input variables from outside)
00655         var $mode;
00656 
00662         var $act;
00663 
00667         var $expandPage;
00668 
00672         var $expandFolder;
00673 
00674 
00675 
00679         var $P;
00680 
00685         var $bparams;
00686 
00691         var $RTEtsConfigParams;
00692 
00693 
00694 
00695 
00699         var $PM;
00700 
00704         var $pointer;
00705 
00706 
00707 
00708 
00712         var $curUrlArray;
00713 
00717         var $curUrlInfo;
00718 
00719 
00720 
00721 
00722 
00729         function init() {
00730                 global $BE_USER,$BACK_PATH;
00731 
00732                         // Main GPvars:
00733                 $this->pointer = t3lib_div::_GP('pointer');
00734                 $this->bparams = t3lib_div::_GP('bparams');
00735                 $this->P = t3lib_div::_GP('P');
00736                 $this->RTEtsConfigParams = t3lib_div::_GP('RTEtsConfigParams');
00737                 $this->expandPage = t3lib_div::_GP('expandPage');
00738                 $this->expandFolder = t3lib_div::_GP('expandFolder');
00739                 $this->PM = t3lib_div::_GP('PM');
00740 
00741                         // Find "mode"
00742                 $this->mode=t3lib_div::_GP('mode');
00743                 if (!$this->mode)       {
00744                         $this->mode='rte';
00745                 }
00746 
00747                         // Site URL
00748                 $this->siteURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL');       // Current site url
00749 
00750                         // CurrentUrl - the current link url must be passed around if it exists
00751                 if ($this->mode=='wizard')      {
00752                         $currentLinkParts = t3lib_div::trimExplode(' ',$this->P['currentValue']);
00753                         $this->curUrlArray = array(
00754                                 'target' => $currentLinkParts[1]
00755                         );
00756                         $this->curUrlInfo=$this->parseCurUrl($this->siteURL.'?id='.$currentLinkParts[0],$this->siteURL);
00757                 } else {
00758                         $this->curUrlArray = t3lib_div::_GP('curUrl');
00759                         if ($this->curUrlArray['all'])  {
00760                                 $this->curUrlArray=t3lib_div::get_tag_attributes($this->curUrlArray['all']);
00761                         }
00762                         $this->curUrlInfo=$this->parseCurUrl($this->curUrlArray['href'],$this->siteURL);
00763                 }
00764 
00765                         // Determine nature of current url:
00766                 $this->act=t3lib_div::_GP('act');
00767                 if (!$this->act)        {
00768                         $this->act=$this->curUrlInfo['act'];
00769                 }
00770 
00771                         // Rich Text Editor specific configuration:
00772                 $addPassOnParams='';
00773                 if ((string)$this->mode=='rte') {
00774                         $RTEtsConfigParts = explode(':',$this->RTEtsConfigParams);
00775                         $addPassOnParams.='&RTEtsConfigParams='.rawurlencode($this->RTEtsConfigParams);
00776                         $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE',t3lib_BEfunc::getPagesTSconfig($RTEtsConfigParts[5]));
00777                         $this->thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup['properties'],$RTEtsConfigParts[0],$RTEtsConfigParts[2],$RTEtsConfigParts[4]);
00778                 }
00779 
00780                         // Initializing the target value (RTE)
00781                 $this->setTarget = $this->curUrlArray['target'];
00782                 if ($this->thisConfig['defaultLinkTarget'] && !isset($this->curUrlArray['target']))     {
00783                         $this->setTarget=$this->thisConfig['defaultLinkTarget'];
00784                 }
00785 
00786 
00787 
00788                         // Creating backend template object:
00789                 $this->doc = t3lib_div::makeInstance('template');
00790                 $this->doc->docType= 'xhtml_trans';
00791                 $this->doc->backPath = $BACK_PATH;
00792 
00793                         // BEGIN accumulation of header JavaScript:
00794                 $JScode = '';
00795                 $JScode.= '
00796                                 // This JavaScript is primarily for RTE/Link. jumpToUrl is used in the other cases as well...
00797                         var add_href="'.($this->curUrlArray['href']?'&curUrl[href]='.rawurlencode($this->curUrlArray['href']):'').'";
00798                         var add_target="'.($this->setTarget?'&curUrl[target]='.rawurlencode($this->setTarget):'').'";
00799                         var add_params="'.($this->bparams?'&bparams='.rawurlencode($this->bparams):'').'";
00800 
00801                         var cur_href="'.($this->curUrlArray['href']?$this->curUrlArray['href']:'').'";
00802                         var cur_target="'.($this->setTarget?$this->setTarget:'').'";
00803 
00804                         function setTarget(target)      {       //
00805                                 cur_target=target;
00806                                 add_target="&curUrl[target]="+escape(target);
00807                         }
00808                         function setValue(value)        {       //
00809                                 cur_href=value;
00810                                 add_href="&curUrl[href]="+value;
00811                         }
00812                 ';
00813 
00814 
00815                 if ($this->mode=='wizard')      {       // Functions used, if the link selector is in wizard mode (= TCEforms fields)
00816                         unset($this->P['fieldChangeFunc']['alert']);
00817                         reset($this->P['fieldChangeFunc']);
00818                         $update='';
00819                         while(list($k,$v)=each($this->P['fieldChangeFunc']))    {
00820                                 $update.= '
00821                                 window.opener.'.$v;
00822                         }
00823 
00824                         $P2=array();
00825                         $P2['itemName']=$this->P['itemName'];
00826                         $P2['formName']=$this->P['formName'];
00827                         $P2['fieldChangeFunc']=$this->P['fieldChangeFunc'];
00828                         $addPassOnParams.=t3lib_div::implodeArrayForUrl('P',$P2);
00829 
00830                         $JScode.='
00831                                 function link_typo3Page(id,anchor)      {       //
00832                                         updateValueInMainForm(id+(anchor?anchor:"")+" "+cur_target);
00833                                         close();
00834                                         return false;
00835                                 }
00836                                 function link_folder(folder)    {       //
00837                                         updateValueInMainForm(folder+" "+cur_target);
00838                                         close();
00839                                         return false;
00840                                 }
00841                                 function link_current() {       //
00842                                         if (cur_href!="http://" && cur_href!="mailto:") {
00843                                                 var setValue = cur_href+" "+cur_target;
00844                                                 if (setValue.substr(0,7)=="http://")    setValue = setValue.substr(7);
00845                                                 if (setValue.substr(0,7)=="mailto:")    setValue = setValue.substr(7);
00846                                                 updateValueInMainForm(setValue);
00847                                                 close();
00848                                         }
00849                                         return false;
00850                                 }
00851                                 function checkReference()       {       //
00852                                         if (window.opener && window.opener.document && window.opener.document.'.$this->P['formName'].' && window.opener.document.'.$this->P['formName'].'["'.$this->P['itemName'].'"] ) {
00853                                                 return window.opener.document.'.$this->P['formName'].'["'.$this->P['itemName'].'"];
00854                                         } else {
00855                                                 close();
00856                                         }
00857                                 }
00858                                 function updateValueInMainForm(input)   {       //
00859                                         var field = checkReference();
00860                                         if (field)      {
00861                                                 field.value = input;
00862                                                 '.$update.'
00863                                         }
00864                                 }
00865                         ';
00866                 } else {        // Functions used, if the link selector is in RTE mode:
00867                         $JScode.='
00868                                 function link_typo3Page(id,anchor)      {       //
00869                                         var theLink = \''.$this->siteURL.'?id=\'+id+(anchor?anchor:"");
00870                                         self.parent.parent.renderPopup_addLink(theLink,cur_target);
00871                                         return false;
00872                                 }
00873                                 function link_folder(folder)    {       //
00874                                         var theLink = \''.$this->siteURL.'\'+folder;
00875                                         self.parent.parent.renderPopup_addLink(theLink,cur_target);
00876                                         return false;
00877                                 }
00878                                 function link_spec(theLink)     {       //
00879                                         self.parent.parent.renderPopup_addLink(theLink,cur_target);
00880                                         return false;
00881                                 }
00882                                 function link_current() {       //
00883                                         if (cur_href!="http://" && cur_href!="mailto:") {
00884                                                 self.parent.parent.renderPopup_addLink(cur_href,cur_target);
00885                                         }
00886                                         return false;
00887                                 }
00888                         ';
00889                 }
00890 
00891                         // General "jumpToUrl" function:
00892                 $JScode.='
00893                         function jumpToUrl(URL,anchor)  {       //
00894                                 var add_act = URL.indexOf("act=")==-1 ? "&act='.$this->act.'" : "";
00895                                 var add_mode = URL.indexOf("mode=")==-1 ? "&mode='.$this->mode.'" : "";
00896                                 var theLocation = URL+add_act+add_mode+add_href+add_target+add_params'.($addPassOnParams?'+"'.$addPassOnParams.'"':'').'+(anchor?anchor:"");
00897                                 document.location = theLocation;
00898                                 return false;
00899                         }
00900                 ';
00901 
00902 
00903                         // This is JavaScript especially for the TBE Element Browser!
00904                 $pArr = explode('|',$this->bparams);
00905                 $formFieldName = 'data['.$pArr[0].']['.$pArr[1].']['.$pArr[2].']';
00906                 $JScode.='
00907                         var elRef="";
00908                         var targetDoc="";
00909 
00910                         function launchView(url)        {       //
00911                                 var thePreviewWindow="";
00912                                 thePreviewWindow = window.open("show_item.php?table="+url,"ShowItem","height=300,width=410,status=0,menubar=0,resizable=0,location=0,directories=0,scrollbars=1,toolbar=0");
00913                                 if (thePreviewWindow && thePreviewWindow.focus) {
00914                                         thePreviewWindow.focus();
00915                                 }
00916                         }
00917                         function setReferences()        {       //
00918                                 if (parent.window.opener
00919                                 && parent.window.opener.content
00920                                 && parent.window.opener.content.document.editform
00921                                 && parent.window.opener.content.document.editform["'.$formFieldName.'"]
00922                                                 ) {
00923                                         targetDoc = parent.window.opener.content.document;
00924                                         elRef = targetDoc.editform["'.$formFieldName.'"];
00925                                         return true;
00926                                 } else {
00927                                         return false;
00928                                 }
00929                         }
00930                         function insertElement(table, uid, type, filename,fp,filetype,imagefile,action, close)  {       //
00931                                 if (1=='.($pArr[0]&&!$pArr[1]&&!$pArr[2] ? 1 : 0).')    {
00932                                         addElement(filename,table+"_"+uid,fp,close);
00933                                 } else {
00934                                         if (setReferences())    {
00935                                                 parent.window.opener.group_change("add","'.$pArr[0].'","'.$pArr[1].'","'.$pArr[2].'",elRef,targetDoc);
00936                                         } else {
00937                                                 alert("Error - reference to main window is not set properly!");
00938                                         }
00939                                         if (close)      {
00940                                                 parent.window.opener.focus();
00941                                                 parent.close();
00942                                         }
00943                                 }
00944                                 return false;
00945                         }
00946                         function addElement(elName,elValue,altElValue,close)    {       //
00947                                 if (parent.window.opener && parent.window.opener.setFormValueFromBrowseWin)     {
00948                                         parent.window.opener.setFormValueFromBrowseWin("'.$pArr[0].'",altElValue?altElValue:elValue,elName);
00949                                         if (close)      {
00950                                                 parent.window.opener.focus();
00951                                                 parent.close();
00952                                         }
00953                                 } else {
00954                                         alert("Error - reference to main window is not set properly!");
00955                                         parent.close();
00956                                 }
00957                         }
00958                 ';
00959 
00960                         // Finally, add the accumulated JavaScript to the template object:
00961                 $this->doc->JScode = $this->doc->wrapScriptTags($JScode);
00962 
00963                         // Debugging:
00964                 if (FALSE) debug(array(
00965                         'pointer' => $this->pointer,
00966                         'act' => $this->act,
00967                         'mode' => $this->mode,
00968                         'curUrlInfo' => $this->curUrlInfo,
00969                         'curUrlArray' => $this->curUrlArray,
00970                         'P' => $this->P,
00971                         'bparams' => $this->bparams,
00972                         'RTEtsConfigParams' => $this->RTEtsConfigParams,
00973                         'expandPage' => $this->expandPage,
00974                         'expandFolder' => $this->expandFolder,
00975                         'PM' => $this->PM,
00976                 ),'Internal variables of Script Class:');
00977         }
00978 
00984         function main() {
00985                 global $BE_USER;
00986 
00987                 $modData = $BE_USER->getModuleData('browse_links.php','ses');
00988 
00989                         // Output the correct content according to $this->mode
00990                 switch((string)$this->mode)     {
00991                         case 'rte':
00992                                 $this->content=$this->main_rte();
00993                         break;
00994                         case 'db':
00995                                 if (isset($this->expandPage))   {
00996                                         $modData['expandPage']=$this->expandPage;
00997                                         $BE_USER->pushModuleData('browse_links.php',$modData);
00998                                 } else {
00999                                         $this->expandPage=$modData['expandPage'];
01000                                 }
01001 
01002                                 $this->content=$this->main_db();
01003                         break;
01004                         case 'file':
01005                         case 'filedrag':
01006                                 if (isset($this->expandFolder)) {
01007                                         $modData['expandFolder']=$this->expandFolder;
01008                                         $BE_USER->pushModuleData('browse_links.php',$modData);
01009                                 } else {
01010                                         $this->expandFolder=$modData['expandFolder'];
01011                                 }
01012 
01013                                 $this->content=$this->main_file();
01014                         break;
01015                         case 'wizard':
01016                                 $this->content=$this->main_rte(1);
01017                         break;
01018                 }
01019         }
01020 
01026         function printContent() {
01027                 echo $this->content;
01028         }
01029 
01030 
01031 
01032 
01033 
01034 
01035 
01036 
01037 
01038 
01039 
01040 
01041 
01042 
01043         /******************************************************************
01044          *
01045          * Main functions
01046          *
01047          ******************************************************************/
01048 
01057         function main_rte($wiz=0)       {
01058                 global $LANG;
01059 
01060                         // Starting content:
01061                 $content=$this->doc->startPage('RTE link');
01062 
01063                         // Initializing the action value, possibly removing blinded values etc:
01064                 $allowedItems = array_diff(explode(',','page,file,url,mail,spec'),t3lib_div::trimExplode(',',$this->thisConfig['blindLinkOptions'],1));
01065                 reset($allowedItems);
01066                 if (!in_array($this->act,$allowedItems))        $this->act = current($allowedItems);
01067 
01068                         // Making menu in top:
01069                 $menuDef = array();
01070                 if (!$wiz)      {
01071                         $menuDef['removeLink']['isActive'] = $this->act=='removeLink';
01072                         $menuDef['removeLink']['label'] = $LANG->getLL('removeLink',1);
01073                         $menuDef['removeLink']['url'] = '#';
01074                         $menuDef['removeLink']['addParams'] = 'onclick="self.parent.parent.renderPopup_unLink();return false;"';
01075                 }
01076                 if (in_array('page',$allowedItems)) {
01077                         $menuDef['page']['isActive'] = $this->act=='page';
01078                         $menuDef['page']['label'] = $LANG->getLL('page',1);
01079                         $menuDef['page']['url'] = '#';
01080                         $menuDef['page']['addParams'] = 'onclick="jumpToUrl(\'?act=page\');return false;"';
01081                 }
01082                 if (in_array('file',$allowedItems)){
01083                         $menuDef['file']['isActive'] = $this->act=='file';
01084                         $menuDef['file']['label'] = $LANG->getLL('file',1);
01085                         $menuDef['file']['url'] = '#';
01086                         $menuDef['file']['addParams'] = 'onclick="jumpToUrl(\'?act=file\');return false;"';
01087                 }
01088                 if (in_array('url',$allowedItems)) {
01089                         $menuDef['url']['isActive'] = $this->act=='url';
01090                         $menuDef['url']['label'] = $LANG->getLL('extUrl',1);
01091                         $menuDef['url']['url'] = '#';
01092                         $menuDef['url']['addParams'] = 'onclick="jumpToUrl(\'?act=url\');return false;"';
01093                 }
01094                 if (in_array('mail',$allowedItems)) {
01095                         $menuDef['mail']['isActive'] = $this->act=='mail';
01096                         $menuDef['mail']['label'] = $LANG->getLL('email',1);
01097                         $menuDef['mail']['url'] = '#';
01098                         $menuDef['mail']['addParams'] = 'onclick="jumpToUrl(\'?act=mail\');return false;"';
01099                 }
01100                 if (is_array($this->thisConfig['userLinks.']) && in_array('spec',$allowedItems)) {
01101                         $menuDef['spec']['isActive'] = $this->act=='spec';
01102                         $menuDef['spec']['label'] = $LANG->getLL('special',1);
01103                         $menuDef['spec']['url'] = '#';
01104                         $menuDef['spec']['addParams'] = 'onclick="jumpToUrl(\'?act=spec\');return false;"';
01105                 }
01106                 $content .= $this->doc->getTabMenuRaw($menuDef);
01107 
01108                         // Adding the menu and header to the top of page:
01109                 $content.=$this->printCurrentUrl($this->curUrlInfo['info']).'<br />';
01110 
01111 
01112                         // Depending on the current action we will create the actual module content for selecting a link:
01113                 switch($this->act)      {
01114                         case 'mail':
01115                                 $extUrl='
01116 
01117                         <!--
01118                                 Enter mail address:
01119                         -->
01120                                         <form action="" name="lurlform" id="lurlform">
01121                                                 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkMail">
01122                                                         <tr>
01123                                                                 <td>'.$GLOBALS['LANG']->getLL('emailAddress',1).':</td>
01124                                                                 <td><input type="text" name="lemail"'.$this->doc->formWidth(20).' value="'.htmlspecialchars($this->curUrlInfo['act']=='mail'?$this->curUrlInfo['info']:'').'" /> '.
01125                                                                         '<input type="submit" value="'.$GLOBALS['LANG']->getLL('setLink',1).'" onclick="setTarget(\'\');setValue(\'mailto:\'+document.lurlform.lemail.value); return link_current();" /></td>
01126                                                         </tr>
01127                                                 </table>
01128                                         </form>';
01129                                 $content.=$extUrl;
01130                         break;
01131                         case 'url':
01132                                 $extUrl='
01133 
01134                         <!--
01135                                 Enter External URL:
01136                         -->
01137                                         <form action="" name="lurlform" id="lurlform">
01138                                                 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkURL">
01139                                                         <tr>
01140                                                                 <td>URL:</td>
01141                                                                 <td><input type="text" name="lurl"'.$this->doc->formWidth(20).' value="'.htmlspecialchars($this->curUrlInfo['act']=='url'?$this->curUrlInfo['info']:'http://').'" /> '.
01142                                                                         '<input type="submit" value="'.$GLOBALS['LANG']->getLL('setLink',1).'" onclick="setValue(document.lurlform.lurl.value); return link_current();" /></td>
01143                                                         </tr>
01144                                                 </table>
01145                                         </form>';
01146                                 $content.=$extUrl;
01147                         break;
01148                         case 'file':
01149                                 $foldertree = t3lib_div::makeInstance('rteFolderTree');
01150                                 $tree=$foldertree->getBrowsableTree();
01151 
01152                                 if (!$this->curUrlInfo['value'] || $this->curUrlInfo['act']!='file')    {
01153                                         $cmpPath='';
01154                                 } elseif (substr(trim($this->curUrlInfo['info']),-1)!='/')      {
01155                                         $cmpPath=PATH_site.dirname($this->curUrlInfo['info']).'/';
01156                                         if (!isset($this->expandFolder))                        $this->expandFolder = $cmpPath;
01157                                 } else {
01158                                         $cmpPath=PATH_site.$this->curUrlInfo['info'];
01159                                 }
01160 
01161                                 list(,,$specUid) = explode('_',$this->PM);
01162                                 $files = $this->expandFolder($foldertree->specUIDmap[$specUid]);
01163 
01164                                 $content.= '
01165 
01166                         <!--
01167                                 Wrapper table for folder tree / file list:
01168                         -->
01169                                         <table border="0" cellpadding="0" cellspacing="0" id="typo3-linkFiles">
01170                                                 <tr>
01171                                                         <td class="c-wCell" valign="top">'.$this->barheader($GLOBALS['LANG']->getLL('folderTree').':').$tree.'</td>
01172                                                         <td class="c-wCell" valign="top">'.$files.'</td>
01173                                                 </tr>
01174                                         </table>
01175                                         ';
01176                         break;
01177                         case 'spec':
01178                                 if (is_array($this->thisConfig['userLinks.']))  {
01179                                         $subcats=array();
01180                                         $v=$this->thisConfig['userLinks.'];
01181                                         reset($v);
01182                                         while(list($k2)=each($v))       {
01183                                                 $k2i = intval($k2);
01184                                                 if (substr($k2,-1)=='.' && is_array($v[$k2i.'.']))      {
01185 
01186                                                                 // Title:
01187                                                         $title = trim($v[$k2i]);
01188                                                         if (!$title)    {
01189                                                                 $title=$v[$k2i.'.']['url'];
01190                                                         } else {
01191                                                                 $title=$LANG->sL($title);
01192                                                         }
01193                                                                 // Description:
01194                                                         $description=$v[$k2i.'.']['description'] ? $LANG->sL($v[$k2i.'.']['description'],1).'<br />' : '';
01195 
01196                                                                 // URL + onclick event:
01197                                                         $onClickEvent='';
01198                                                         if (isset($v[$k2i.'.']['target']))      $onClickEvent.="setTarget('".$v[$k2i.'.']['target']."');";
01199                                                         $v[$k2i.'.']['url'] = str_replace('###_URL###',$this->siteURL,$v[$k2i.'.']['url']);
01200                                                         if (substr($v[$k2i.'.']['url'],0,7)=="http://" || substr($v[$k2i.'.']['url'],0,7)=='mailto:')   {
01201                                                                 $onClickEvent.="cur_href=unescape('".rawurlencode($v[$k2i.'.']['url'])."');link_current();";
01202                                                         } else {
01203                                                                 $onClickEvent.="link_spec(unescape('".$this->siteURL.rawurlencode($v[$k2i.'.']['url'])."'));";
01204                                                         }
01205 
01206                                                                 // Link:
01207                                                         $A=array('<a href="#" onclick="'.htmlspecialchars($onClickEvent).'return false;">','</a>');
01208 
01209                                                                 // Adding link to menu of user defined links:
01210                                                         $subcats[$k2i]='
01211                                                                 <tr>
01212                                                                         <td class="bgColor4">'.$A[0].'<strong>'.htmlspecialchars($title).($this->curUrlInfo['info']==$v[$k2i.'.']['url']?'<img'.t3lib_iconWorks::skinImg('','gfx/blinkarrow_right.gif','width="5" height="9"').' class="c-blinkArrowR" alt="" />':'').'</strong><br />'.$description.$A[1].'</td>
01213                                                                 </tr>';
01214                                                 }
01215                                         }
01216 
01217                                                 // Sort by keys:
01218                                         ksort($subcats);
01219 
01220                                                 // Add menu to content:
01221                                         $content.= '
01222 
01223                         <!--
01224                                 Special userdefined menu:
01225                         -->
01226                                                 <table border="0" cellpadding="1" cellspacing="1" id="typo3-linkSpecial">
01227                                                         <tr>
01228                                                                 <td class="bgColor5" class="c-wCell" valign="top"><strong>'.$LANG->getLL('special',1).'</strong></td>
01229                                                         </tr>
01230                                                         '.implode('',$subcats).'
01231                                                 </table>
01232                                                 ';
01233                                 }
01234                         break;
01235                         case 'page':
01236                         default:
01237                                 $pagetree = t3lib_div::makeInstance('rtePageTree');
01238                                 $tree=$pagetree->getBrowsableTree();
01239                                 $cElements = $this->expandPage();
01240                                 $content.= '
01241 
01242                         <!--
01243                                 Wrapper table for page tree / record list:
01244                         -->
01245                                         <table border="0" cellpadding="0" cellspacing="0" id="typo3-linkPages">
01246                                                 <tr>
01247                                                         <td class="c-wCell" valign="top">'.$this->barheader($GLOBALS['LANG']->getLL('pageTree').':').$tree.'</td>
01248                                                         <td class="c-wCell" valign="top">'.$cElements.'</td>
01249                                                 </tr>
01250                                         </table>
01251                                         ';
01252                         break;
01253                 }
01254 
01255                         // Target:
01256                 if ($this->act!='mail') {
01257                         $ltarget='
01258 
01259 
01260                         <!--
01261                                 Selecting target for link:
01262                         -->
01263                                 <form action="" name="ltargetform" id="ltargetform">
01264                                         <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkTarget">
01265                                                 <tr>
01266                                                         <td>'.$GLOBALS['LANG']->getLL('target',1).':</td>
01267                                                         <td><input type="text" name="ltarget" onchange="setTarget(this.value);" value="'.htmlspecialchars($this->setTarget).'"'.$this->doc->formWidth(10).' /></td>
01268                                                         <td>
01269                                                                 <select name="ltarget_type" onchange="setTarget(this.options[this.selectedIndex].value);document.ltargetform.ltarget.value=this.options[this.selectedIndex].value;this.selectedIndex=0;">
01270                                                                         <option></option>
01271                                                                         <option value="_top">'.$GLOBALS['LANG']->getLL('top',1).'</option>
01272                                                                         <option value="_blank">'.$GLOBALS['LANG']->getLL('newWindow',1).'</option>
01273                                                                 </select>
01274                                                         </td>
01275                                                         <td>';
01276 
01277                         if (($this->curUrlInfo['act']=="page" || $this->curUrlInfo['act']=='file') && $this->curUrlArray['href'])       {
01278                                 $ltarget.='
01279                                                         <input type="submit" value="'.$GLOBALS['LANG']->getLL('update',1).'" onclick="return link_current();" />';
01280                         }
01281 
01282                         $selectJS = '
01283                                 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)     {
01284                                         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;
01285                                         setTarget(document.ltargetform.ltarget.value);
01286                                         document.ltargetform.popup_width.selectedIndex=0;
01287                                         document.ltargetform.popup_height.selectedIndex=0;
01288                                 }
01289                         ';
01290 
01291                         $ltarget.='             </td>
01292                                                 </tr>
01293                                                 <tr>
01294                                                         <td>'.$GLOBALS['LANG']->getLL('target_popUpWindow',1).':</td>
01295                                                         <td colspan="3">
01296                                                                 <select name="popup_width" onchange="'.htmlspecialchars($selectJS).'">
01297                                                                         <option value="0">'.$GLOBALS['LANG']->getLL('target_popUpWindow_width',1).'</option>
01298                                                                         <option value="300">300</option>
01299                                                                         <option value="400">400</option>
01300                                                                         <option value="500">500</option>
01301                                                                         <option value="600">600</option>
01302                                                                         <option value="700">700</option>
01303                                                                         <option value="800">800</option>
01304                                                                 </select>
01305                                                                 x
01306                                                                 <select name="popup_height" onchange="'.htmlspecialchars($selectJS).'">
01307                                                                         <option value="0">'.$GLOBALS['LANG']->getLL('target_popUpWindow_height',1).'</option>
01308                                                                         <option value="200">200</option>
01309                                                                         <option value="300">300</option>
01310                                                                         <option value="400">400</option>
01311                                                                         <option value="500">500</option>
01312                                                                         <option value="600">600</option>
01313                                                                 </select>
01314                                                         </td>
01315                                                 </tr>
01316                                         </table>
01317                                 </form>';
01318 
01319                                 // Add "target selector" box to content:
01320                         $content.=$ltarget;
01321 
01322                                 // Add some space
01323                         $content.='<br /><br />';
01324                 }
01325 
01326                         // End page, return content:
01327                 $content.= $this->doc->endPage();
01328                 return $content;
01329         }
01330 
01336         function main_db()      {
01337 
01338                         // Starting content:
01339                 $content=$this->doc->startPage('TBE file selector');
01340 
01341                         // Init variable:
01342                 $pArr = explode('|',$this->bparams);
01343 
01344                         // Making the browsable pagetree:
01345                 $pagetree = t3lib_div::makeInstance('TBE_PageTree');
01346                 $pagetree->script='browse_links.php';
01347                 $pagetree->ext_pArrPages = !strcmp($pArr[3],'pages')?1:0;
01348                 $tree=$pagetree->getBrowsableTree();
01349 
01350                         // Making the list of elements, if applicable:
01351                 $cElements = $this->TBE_expandPage($pArr[3]);
01352 
01353                         // Putting the things together, side by side:
01354                 $content.= '
01355 
01356                         <!--
01357                                 Wrapper table for page tree / record list:
01358                         -->
01359                         <table border="0" cellpadding="0" cellspacing="0" id="typo3-EBrecords">
01360                                 <tr>
01361                                         <td class="c-wCell" valign="top">'.$this->barheader($GLOBALS['LANG']->getLL('pageTree').':').$tree.'</td>
01362                                         <td class="c-wCell" valign="top">'.$cElements.'</td>
01363                                 </tr>
01364                         </table>
01365                         ';
01366 
01367                         // Add some space
01368                 $content.='<br /><br />';
01369 
01370                         // End page, return content:
01371                 $content.= $this->doc->endPage();
01372                 return $content;
01373         }
01374 
01380         function main_file()    {
01381                 global $BE_USER;
01382 
01383                         // Starting content:
01384