class.browse_links.php

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2008 Kasper Skaarhoj (kasperYYYY@typo3.com)
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00027 /**
00028  * Displays the page/file tree for browsing database records or files.
00029  * Used from TCEFORMS an other elements
00030  * In other words: This is the ELEMENT BROWSER!
00031  *
00032  * $Id: class.browse_links.php 4450 2008-11-11 19:42:32Z stan $
00033  * Revised for TYPO3 3.6 November/2003 by Kasper Skaarhoj
00034  * XHTML compliant
00035  *
00036  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00037  */
00038 /**
00039  * [CLASS/FUNCTION INDEX of SCRIPT]
00040  *
00041  *
00042  *
00043  *  155: class TBE_browser_recordList extends localRecordList
00044  *  163:     function TBE_browser_recordList ()
00045  *  175:     function listURL($altId='',$table=-1,$exclList='')
00046  *  194:     function ext_addP()
00047  *  211:     function linkWrapItems($table,$uid,$code,$row)
00048  *  244:     function linkWrapTable($table,$code)
00049  *
00050  *
00051  *  261: class localPageTree extends t3lib_browseTree
00052  *  268:     function localPageTree()
00053  *  284:     function wrapTitle($title,$v,$ext_pArrPages='')
00054  *  299:     function printTree($treeArr='')
00055  *  350:     function ext_isLinkable($doktype,$uid)
00056  *  364:     function PM_ATagWrap($icon,$cmd,$bMark='')
00057  *  381:     function wrapIcon($icon,$row)
00058  *
00059  *
00060  *  400: class rtePageTree extends localPageTree
00061  *
00062  *
00063  *  417: class TBE_PageTree extends localPageTree
00064  *  426:     function ext_isLinkable($doktype,$uid)
00065  *  438:     function wrapTitle($title,$v,$ext_pArrPages)
00066  *
00067  *
00068  *  464: class localFolderTree extends t3lib_folderTree
00069  *  473:     function localFolderTree()
00070  *  485:     function wrapTitle($title,$v)
00071  *  500:     function ext_isLinkable($v)
00072  *  517:     function PM_ATagWrap($icon,$cmd,$bMark='')
00073  *  532:     function printTree($treeArr='')
00074  *
00075  *
00076  *  599: class rteFolderTree extends localFolderTree
00077  *
00078  *
00079  *  615: class TBE_FolderTree extends localFolderTree
00080  *  624:     function ext_isLinkable($v)
00081  *  637:     function wrapTitle($title,$v)
00082  *
00083  *
00084  *  658: class browse_links
00085  *  764:     function init()
00086  * 1034:     function processSessionData($data)
00087  *
00088  *              SECTION: Main functions
00089  * 1077:     function main_rte($wiz=0)
00090  * 1379:     function main_db()
00091  * 1424:     function main_file()
00092  *
00093  *              SECTION: Record listing
00094  * 1534:     function expandPage()
00095  * 1615:     function TBE_expandPage($tables)
00096  *
00097  *              SECTION: File listing
00098  * 1708:     function expandFolder($expandFolder=0,$extensionList='')
00099  * 1778:     function TBE_expandFolder($expandFolder=0,$extensionList='',$noThumbs=0)
00100  * 1801:     function fileList($files, $folderName='', $noThumbs=0)
00101  * 1918:     function TBE_dragNDrop($expandFolder=0,$extensionList='')
00102  *
00103  *              SECTION: Miscellaneous functions
00104  * 2046:     function isWebFolder($folder)
00105  * 2057:     function checkFolder($folder)
00106  * 2070:     function barheader($str)
00107  * 2087:     function getMsgBox($in_msg,$icon='icon_note')
00108  * 2111:     function printCurrentUrl($str)
00109  * 2131:     function parseCurUrl($href,$siteUrl)
00110  * 2193:     function uploadForm($path)
00111  * 2247:     function createFolder($path)
00112  *
00113  * TOTAL FUNCTIONS: 39
00114  * (This index is automatically created/updated by the extension "extdeveval")
00115  *
00116  */
00117 
00118 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 
00149 /**
00150  * Local version of the record list.
00151  *
00152  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00153  * @package TYPO3
00154  * @subpackage core
00155  */
00156 class TBE_browser_recordList extends localRecordList {
00157     var $thisScript = 'browse_links.php';
00158 
00159     /**
00160      * Initializes the script path
00161      *
00162      * @return  void
00163      */
00164     function TBE_browser_recordList () {
00165         $this->thisScript = t3lib_div::getIndpEnv('SCRIPT_NAME');
00166     }
00167 
00168     /**
00169      * Creates the URL for links
00170      *
00171      * @param   mixed       If not blank string, this is used instead of $this->id as the id value.
00172      * @param   string      If this is "-1" then $this->table is used, otherwise the value of the input variable.
00173      * @param   string      Commalist of fields NOT to pass as parameters (currently "sortField" and "sortRev")
00174      * @return  string      Query-string for URL
00175      */
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 
00190     /**
00191      * Returns additional, local GET parameters to include in the links of the record list.
00192      *
00193      * @return  string
00194      */
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 
00203     /**
00204      * Returns the title (based on $code) of a record (from table $table) with the proper link around (that is for "pages"-records a link to the level of that record...)
00205      *
00206      * @param   string      Table name
00207      * @param   integer     UID (not used here)
00208      * @param   string      Title string
00209      * @param   array       Records array (from table name)
00210      * @return  string
00211      */
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 
00236     /**
00237      * Local version that sets allFields to true to support userFieldSelect
00238      *
00239      * @return  void
00240      * @see fieldSelectBox
00241      */
00242     function generateList() {
00243         $this->allFields = true;
00244         parent::generateList();
00245     }
00246 }
00247 
00248 
00249 
00250 
00251 
00252 
00253 /**
00254  * Class which generates the page tree
00255  *
00256  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00257  * @package TYPO3
00258  * @subpackage core
00259  */
00260 class localPageTree extends t3lib_browseTree {
00261 
00262     /**
00263      * Constructor. Just calling init()
00264      *
00265      * @return  void
00266      */
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 
00275     /**
00276      * Wrapping the title in a link, if applicable.
00277      *
00278      * @param   string      Title, (must be ready for output, that means it must be htmlspecialchars()'ed).
00279      * @param   array       The record
00280      * @param   boolean     (Ignore)
00281      * @return  string      Wrapping title string.
00282      */
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 
00292     /**
00293      * Create the page navigation tree in HTML
00294      *
00295      * @param   array       Tree array
00296      * @return  string      HTML output.
00297      */
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 
00342     /**
00343      * Returns true if a doktype can be linked.
00344      *
00345      * @param   integer     Doktype value to test
00346      * @param   integer     uid to test.
00347      * @return  boolean
00348      */
00349     function ext_isLinkable($doktype,$uid)  {
00350         if ($uid && $doktype<199)   {
00351             return true;
00352         }
00353     }
00354 
00355     /**
00356      * Wrap the plus/minus icon in a link
00357      *
00358      * @param   string      HTML string to wrap, probably an image tag.
00359      * @param   string      Command for 'PM' get var
00360      * @param   boolean     If set, the link will have a anchor point (=$bMark) and a name attribute (=$bMark)
00361      * @return  string      Link-wrapped input string
00362      */
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 
00373     /**
00374      * Wrapping the image tag, $icon, for the row, $row
00375      *
00376      * @param   string      The image tag for the icon
00377      * @param   array       The row for the current element
00378      * @return  string      The processed icon input value.
00379      */
00380     function wrapIcon($icon,$row)   {
00381         return $this->addTagAttributes($icon,' title="id='.$row['uid'].'"');
00382     }
00383 }
00384 
00385 
00386 
00387 
00388 
00389 
00390 
00391 
00392 /**
00393  * Page tree for the RTE - totally the same, no changes needed. (Just for the sake of beauty - or confusion... :-)
00394  *
00395  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00396  * @package TYPO3
00397  * @subpackage core
00398  */
00399 class rtePageTree extends localPageTree {
00400 }
00401 
00402 
00403 
00404 
00405 
00406 
00407 
00408 
00409 /**
00410  * For TBE record browser
00411  *
00412  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00413  * @package TYPO3
00414  * @subpackage core
00415  */
00416 class TBE_PageTree extends localPageTree {
00417 
00418     /**
00419      * Returns true if a doktype can be linked (which is always the case here).
00420      *
00421      * @param   integer     Doktype value to test
00422      * @param   integer     uid to test.
00423      * @return  boolean
00424      */
00425     function ext_isLinkable($doktype,$uid)  {
00426         return true;
00427     }
00428 
00429     /**
00430      * Wrapping the title in a link, if applicable.
00431      *
00432      * @param   string      Title, ready for output.
00433      * @param   array       The record
00434      * @param   boolean     If set, pages clicked will return immediately, otherwise reload page.
00435      * @return  string      Wrapping title string.
00436      */
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 
00455 /**
00456  * Base extension class which generates the folder tree.
00457  * Used directly by the RTE.
00458  *
00459  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00460  * @package TYPO3
00461  * @subpackage core
00462  */
00463 class localFolderTree extends t3lib_folderTree {
00464     var $ext_IconMode=1;
00465 
00466 
00467     /**
00468      * Initializes the script path
00469      *
00470      * @return  void
00471      */
00472     function localFolderTree() {
00473         $this->thisScript = t3lib_div::getIndpEnv('SCRIPT_NAME');
00474         $this->t3lib_folderTree();
00475     }
00476 
00477     /**
00478      * Wrapping the title in a link, if applicable.
00479      *
00480      * @param   string      Title, ready for output.
00481      * @param   array       The "record"
00482      * @return  string      Wrapping title string.
00483      */
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 
00493     /**
00494      * Returns true if the input "record" contains a folder which can be linked.
00495      *
00496      * @param   array       Array with information about the folder element. Contains keys like title, uid, path, _title
00497      * @return  boolean     True is returned if the path is found in the web-part of the server and is NOT a recycler or temp folder
00498      */
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 
00507     /**
00508      * Wrap the plus/minus icon in a link
00509      *
00510      * @param   string      HTML string to wrap, probably an image tag.
00511      * @param   string      Command for 'PM' get var
00512      * @param   boolean     If set, the link will have a anchor point (=$bMark) and a name attribute (=$bMark)
00513      * @return  string      Link-wrapped input string
00514      * @access private
00515      */
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 
00525     /**
00526      * Create the folder navigation tree in HTML
00527      *
00528      * @param   mixed       Input tree array. If not array, then $this->tree is used.
00529      * @return  string      HTML output of the tree.
00530      */
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' || $GLOBALS['SOBE']->browser->curUrlInfo['act'] == 'folder') && $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 
00591 /**
00592  * Folder tree for the RTE - totally the same, no changes needed. (Just for the sake of beauty - or confusion... :-)
00593  *
00594  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00595  * @package TYPO3
00596  * @subpackage core
00597  */
00598 class rteFolderTree extends localFolderTree {
00599 }
00600 
00601 
00602 
00603 
00604 
00605 
00606 
00607 /**
00608  * For TBE File Browser
00609  *
00610  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00611  * @package TYPO3
00612  * @subpackage core
00613  */
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 
00617     /**
00618      * Returns true if the input "record" contains a folder which can be linked.
00619      *
00620      * @param   array       Array with information about the folder element. Contains keys like title, uid, path, _title
00621      * @return  boolean     True is returned if the path is NOT a recycler or temp folder AND if ->ext_noTempRecyclerDirs is not set.
00622      */
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 
00629     /**
00630      * Wrapping the title in a link, if applicable.
00631      *
00632      * @param   string      Title, ready for output.
00633      * @param   array       The 'record'
00634      * @return  string      Wrapping title string.
00635      */
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 
00650 /**
00651  * class for the Element Browser window.
00652  *
00653  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00654  * @package TYPO3
00655  * @subpackage core
00656  */
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 $setClass;          // CSS Class (RTE specific)
00665     var $setTitle;              // title (RTE specific)
00666     var $doc;           // Backend template object
00667     var $elements = array();    // Holds information about files
00668 
00669         // GPvars:  (Input variables from outside)
00670     /**
00671      * The mode determines the main kind of output from the element browser.
00672      * There are these options for values: rte, db, file, filedrag, wizard.
00673      * "rte" will show the link selector for the Rich Text Editor (see main_rte())
00674      * "db" will allow you to browse for pages or records in the page tree (for TCEforms, see main_db())
00675      * "file"/"filedrag" will allow you to browse for files or folders in the folder mounts (for TCEforms, main_file())
00676      * "wizard" will allow you to browse for links (like "rte") which are passed back to TCEforms (see main_rte(1))
00677      *
00678      * @see main()
00679      */
00680     var $mode;
00681 
00682     /**
00683      * Link selector action.
00684      * page,file,url,mail,spec are allowed values.
00685      * These are only important with the link selector function and in that case they switch between the various menu options.
00686      */
00687     var $act;
00688 
00689     /**
00690      * When you click a page title/expand icon to see the content of a certain page, this value will contain that value (the ID of the expanded page). If the value is NOT set, then it will be restored from the module session data (see main(), mode="db")
00691      */
00692     var $expandPage;
00693 
00694     /**
00695      * When you click a folder name/expand icon to see the content of a certain file folder, this value will contain that value (the path of the expanded file folder). If the value is NOT set, then it will be restored from the module session data (see main(), mode="file"/"filedrag"). Example value: "/www/htdocs/typo3/32/3dsplm/fileadmin/css/"
00696      */
00697     var $expandFolder;
00698 
00699 
00700 
00701     /**
00702      * TYPO3 Element Browser, wizard mode parameters. There is a heap of parameters there, better debug() them out if you need something... :-)
00703      */
00704     var $P;
00705 
00706     /**
00707      * Active with TYPO3 Element Browser: Contains the name of the form field for which this window opens - thus allows us to make references back to the main window in which the form is.
00708      * Example value: "data[pages][39][bodytext]|||tt_content|" or "data[tt_content][NEW3fba56fde763d][image]|||gif,jpg,jpeg,tif,bmp,pcx,tga,png,pdf,ai|"
00709      *
00710      * Values:
00711      * 0: form field name reference, eg. "data[tt_content][123][image]"
00712      * 1: htlmArea RTE parameters: editorNo:contentTypo3Language:contentTypo3Charset
00713      * 2: RTE config parameters: RTEtsConfigParams
00714      * 3: allowed types. Eg. "tt_content" or "gif,jpg,jpeg,tif,bmp,pcx,tga,png,pdf,ai"
00715      * 4: IRRE uniqueness: target level object-id to perform actions/checks on, eg. "data[79][tt_address][1][<field>][<foreign_table>]"
00716      * 5: IRRE uniqueness: name of function in opener window that checks if element is already used, eg. "inline.checkUniqueElement"
00717      * 6: IRRE uniqueness: name of function in opener window that performs some additional(!) action, eg. "inline.setUniqueElement"
00718      * 7: IRRE uniqueness: name of function in opener window that performs action instead of using addElement/insertElement, eg. "inline.importElement"
00719      *
00720      * $pArr = explode('|',$this->bparams);
00721      * $formFieldName = $pArr[0];
00722      * $allowedTablesOrFileTypes = $pArr[3];
00723      */
00724     var $bparams;
00725 
00726     /**
00727      * Used with the Rich Text Editor.
00728      * Example value: "tt_content:NEW3fba58c969f5c:bodytext:23:text:23:"
00729      */
00730     var $RTEtsConfigParams;
00731 
00732 
00733 
00734 
00735     /**
00736      * Plus/Minus icon value. Used by the tree class to open/close notes on the trees.
00737      */
00738     var $PM;
00739 
00740     /**
00741      * Pointer, used when browsing a long list of records etc.
00742      */
00743     var $pointer;
00744 
00745 
00746 
00747 
00748     /**
00749      * Used with the link selector: Contains the GET input information about the CURRENT link in the RTE/TCEform field. This consists of "href", "target" and "title" keys. This information is passed around in links.
00750      */
00751     var $curUrlArray;
00752 
00753     /**
00754      * Used with the link selector: Contains a processed version of the input values from curUrlInfo. This is splitted into pageid, content element id, label value etc. This is used for the internal processing of that information.
00755      */
00756     var $curUrlInfo;
00757 
00758     /**
00759      * array which holds hook objects (initialised in init() )
00760      */
00761     protected $hookObjects = array();
00762 
00763 
00764     /**
00765      * object for t3lib_basicFileFunctions
00766      */
00767     public $fileProcessor;
00768 
00769 
00770     /**
00771      * Constructor:
00772      * Initializes a lot of variables, setting JavaScript functions in header etc.
00773      *
00774      * @return  void
00775      */
00776     function init() {
00777         global $BE_USER,$BACK_PATH;
00778 
00779             // Main GPvars:
00780         $this->pointer           = t3lib_div::_GP('pointer');
00781         $this->bparams           = t3lib_div::_GP('bparams');
00782         $this->P                 = t3lib_div::_GP('P');
00783         $this->RTEtsConfigParams = t3lib_div::_GP('RTEtsConfigParams');
00784         $this->expandPage        = t3lib_div::_GP('expandPage');
00785         $this->expandFolder      = t3lib_div::_GP('expandFolder');
00786         $this->PM                = t3lib_div::_GP('PM');
00787 
00788             // Find "mode"
00789         $this->mode = t3lib_div::_GP('mode');
00790         if (!$this->mode)   {
00791             $this->mode = 'rte';
00792         }
00793             // Creating backend template object:
00794         $this->doc = t3lib_div::makeInstance('template');
00795         $this->doc->backPath = $GLOBALS['BACK_PATH'];
00796             // Load the Prototype library and browse_links.js
00797         $this->doc->loadJavascriptLib('contrib/prototype/prototype.js');
00798         $this->doc->loadJavascriptLib('js/browse_links.js');
00799 
00800             // init hook objects:
00801         $this->hookObjects = array();
00802         if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['browseLinksHook'])) {
00803             foreach($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['browseLinksHook'] as $classData) {
00804                 $processObject = &t3lib_div::getUserObj($classData);
00805 
00806                 if(!($processObject instanceof t3lib_browseLinksHook)) {
00807                     throw new UnexpectedValueException('$processObject must implement interface t3lib_browseLinksHook', 1195039394);
00808                 }
00809 
00810                 $parameters = array();
00811                 $processObject->init($this, $parameters);
00812                 $this->hookObjects[] = $processObject;
00813             }
00814         }
00815 
00816             // Site URL
00817         $this->siteURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL');   // Current site url
00818 
00819             // the script to link to
00820         $this->thisScript = t3lib_div::getIndpEnv('SCRIPT_NAME');
00821 
00822             // init fileProcessor
00823         $this->fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
00824         $this->fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
00825 
00826 
00827             // CurrentUrl - the current link url must be passed around if it exists
00828         if ($this->mode == 'wizard')    {
00829             $currentLinkParts = t3lib_div::trimExplode(' ',$this->P['currentValue']);
00830             $initialCurUrlArray = array (
00831                 'href'   => $currentLinkParts[0],
00832                 'target' => $currentLinkParts[1],
00833                 'class'  => $currentLinkParts[2],
00834                 'title'  => $currentLinkParts[3],
00835             );
00836             $this->curUrlArray = (is_array(t3lib_div::_GP('curUrl'))) ?
00837                 array_merge($initialCurUrlArray, t3lib_div::_GP('curUrl')) :
00838                 $initialCurUrlArray;
00839             $this->curUrlInfo = $this->parseCurUrl($this->siteURL.'?id='.$this->curUrlArray['href'], $this->siteURL);
00840             if ($this->curUrlInfo['pageid'] == 0 && $this->curUrlArray['href']) { // pageid == 0 means that this is not an internal (page) link
00841                 if (file_exists(PATH_site.rawurldecode($this->curUrlArray['href'])))    { // check if this is a link to a file
00842                     if (t3lib_div::isFirstPartOfStr($this->curUrlArray['href'], PATH_site)) {
00843                         $currentLinkParts[0] = substr($this->curUrlArray['href'], strlen(PATH_site));
00844                     }
00845                     $this->curUrlInfo = $this->parseCurUrl($this->siteURL.$this->curUrlArray['href'], $this->siteURL);
00846                 } elseif (strstr($this->curUrlArray['href'], '@')) { // check for email link
00847                     if (t3lib_div::isFirstPartOfStr($this->curUrlArray['href'], 'mailto:')) {
00848                         $currentLinkParts[0] = substr($this->curUrlArray['href'], 7);
00849                     }
00850                     $this->curUrlInfo = $this->parseCurUrl('mailto:'.$this->curUrlArray['href'], $this->siteURL);
00851                 } else { // nothing of the above. this is an external link
00852                     if(strpos($this->curUrlArray['href'], '://') === false) {
00853                         $currentLinkParts[0] = 'http://' . $this->curUrlArray['href'];
00854                     }
00855                     $this->curUrlInfo = $this->parseCurUrl($currentLinkParts[0], $this->siteURL);
00856                 }
00857             } elseif (!$this->curUrlArray['href']) {
00858                 $this->curUrlInfo = array();
00859                 $this->act = 'page';
00860             } else {
00861                 $this->curUrlInfo = $this->parseCurUrl($this->siteURL.'?id='.$this->curUrlArray['href'], $this->siteURL);
00862             }
00863         } else {
00864             $this->curUrlArray = t3lib_div::_GP('curUrl');
00865             if ($this->curUrlArray['all'])  {
00866                 $this->curUrlArray=t3lib_div::get_tag_attributes($this->curUrlArray['all']);
00867             }
00868             $this->curUrlInfo=$this->parseCurUrl($this->curUrlArray['href'],$this->siteURL);
00869         }
00870 
00871             // Determine nature of current url:
00872         $this->act=t3lib_div::_GP('act');
00873         if (!$this->act)    {
00874             $this->act=$this->curUrlInfo['act'];
00875         }
00876 
00877             // Rich Text Editor specific configuration:
00878         $addPassOnParams='';
00879         if ((string)$this->mode == 'rte')   {
00880             $RTEtsConfigParts = explode(':',$this->RTEtsConfigParams);
00881             $addPassOnParams.='&RTEtsConfigParams='.rawurlencode($this->RTEtsConfigParams);
00882             $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE',t3lib_BEfunc::getPagesTSconfig($RTEtsConfigParts[5]));
00883             $this->thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup['properties'],$RTEtsConfigParts[0],$RTEtsConfigParts[2],$RTEtsConfigParts[4]);
00884         }
00885 
00886             // Initializing the target value (RTE)
00887         $this->setTarget = ($this->curUrlArray['target'] != '-') ? $this->curUrlArray['target'] : '';
00888         if ($this->thisConfig['defaultLinkTarget'] && !isset($this->curUrlArray['target'])) {
00889             $this->setTarget=$this->thisConfig['defaultLinkTarget'];
00890         }
00891 
00892             // Initializing the class value (RTE)
00893         $this->setClass = ($this->curUrlArray['class'] != '-') ? $this->curUrlArray['class'] : '';
00894 
00895             // Initializing the title value (RTE)
00896         $this->setTitle = ($this->curUrlArray['title'] != '-') ? $this->curUrlArray['title'] : '';
00897 
00898             // BEGIN accumulation of header JavaScript:
00899         $JScode = '
00900                 // This JavaScript is primarily for RTE/Link. jumpToUrl is used in the other cases as well...
00901             var add_href="'.($this->curUrlArray['href']?'&curUrl[href]='.rawurlencode($this->curUrlArray['href']):'').'";
00902             var add_target="'.($this->setTarget?'&curUrl[target]='.rawurlencode($this->setTarget):'').'";
00903             var add_class="'.($this->setClass ? '&curUrl[class]='.rawurlencode($this->setClass) : '').'";
00904             var add_title="'.($this->setTitle?'&curUrl[title]='.rawurlencode($this->setTitle):'').'";
00905             var add_params="'.($this->bparams?'&bparams='.rawurlencode($this->bparams):'').'";
00906 
00907             var cur_href="'.($this->curUrlArray['href']?$this->curUrlArray['href']:'').'";
00908             var cur_target="'.($this->setTarget?$this->setTarget:'').'";
00909             var cur_class = "'.($this->setClass ? $this->setClass : '-').'";
00910             var cur_title="'.($this->setTitle?$this->setTitle:'').'";
00911 
00912             function browse_links_setTarget(target) {   //
00913                 cur_target=target;
00914                 add_target="&curUrl[target]="+escape(target);
00915             }
00916             function browse_links_setClass(cssClass) {   //
00917                 cur_class = cssClass;
00918                 add_class = "&curUrl[class]=" + escape(cssClass);
00919             }
00920             function browse_links_setTitle(title)   {   //
00921                 cur_title=title;
00922                 add_title="&curUrl[title]="+escape(title);
00923             }
00924             function browse_links_setValue(value) { //
00925                 cur_href=value;
00926                 add_href="&curUrl[href]="+value;
00927             }
00928         ';
00929 
00930         if ($this->mode == 'wizard')    {   // Functions used, if the link selector is in wizard mode (= TCEforms fields)
00931             unset($this->P['fieldChangeFunc']['alert']);
00932             reset($this->P['fieldChangeFunc']);
00933             $update='';
00934             while(list($k,$v)=each($this->P['fieldChangeFunc']))    {
00935                 $update.= '
00936                 window.opener.'.$v;
00937             }
00938 
00939             $P2=array();
00940             $P2['itemName']=$this->P['itemName'];
00941             $P2['formName']=$this->P['formName'];
00942             $P2['fieldChangeFunc']=$this->P['fieldChangeFunc'];
00943             $P2['params']['allowedExtensions']=$this->P['params']['allowedExtensions'];
00944             $P2['params']['blindLinkOptions']=$this->P['params']['blindLinkOptions'];
00945             $addPassOnParams.=t3lib_div::implodeArrayForUrl('P',$P2);
00946 
00947             $JScode.='
00948                 function link_typo3Page(id,anchor)  {   //
00949                     updateValueInMainForm(id + (anchor ? anchor : ""));
00950                     close();
00951                     return false;
00952                 }
00953                 function link_folder(folder)    {   //
00954                     updateValueInMainForm(folder);
00955                     close();
00956                     return false;
00957                 }
00958                 function link_current() {   //
00959                     if (cur_href!="http://" && cur_href!="mailto:") {
00960                         returnBeforeCleaned = cur_href;
00961                         if (returnBeforeCleaned.substr(0, 7) == "http://") {
00962                             returnToMainFormValue = returnBeforeCleaned.substr(7);
00963                         } else if (returnBeforeCleaned.substr(0, 7) == "mailto:") {
00964                             if (returnBeforeCleaned.substr(0, 14) == "mailto:mailto:") {
00965                                 returnToMainFormValue = returnBeforeCleaned.substr(14);
00966                             } else {
00967                                 returnToMainFormValue = returnBeforeCleaned.substr(7);
00968                             }
00969                         } else {
00970                             returnToMainFormValue = returnBeforeCleaned;
00971                         }
00972                         updateValueInMainForm(returnToMainFormValue);
00973                         close();
00974                     }
00975                     return false;
00976                 }
00977                 function checkReference()   {   //
00978                     if (window.opener && window.opener.document && window.opener.document.'.$this->P['formName'].' && window.opener.document.'.$this->P['formName'].'["'.$this->P['itemName'].'"] ) {
00979                         return window.opener.document.'.$this->P['formName'].'["'.$this->P['itemName'].'"];
00980                     } else {
00981                         close();
00982                     }
00983                 }
00984                 function updateValueInMainForm(input)   {   //
00985                     var field = checkReference();
00986                     if (field)  {
00987                         if (cur_target == "" && (cur_title != "" || cur_class != "-")) {
00988                             cur_target = "-";
00989                         }
00990                         if (cur_title == "" && cur_class == "-") {
00991                             cur_class = "";
00992                         }
00993                         input = input + " " + cur_target + " " + cur_class + " " + cur_title;
00994                         field.value = input;
00995                         '.$update.'
00996                     }
00997                 }
00998             ';
00999         } else {    // Functions used, if the link selector is in RTE mode:
01000             $JScode.='
01001                 function link_typo3Page(id,anchor)  {   //
01002                     var theLink = \''.$this->siteURL.'?id=\'+id+(anchor?anchor:"");
01003                     self.parent.parent.renderPopup_addLink(theLink, cur_target, cur_class, cur_title);
01004                     return false;
01005                 }
01006                 function link_folder(folder)    {   //
01007                     var theLink = \''.$this->siteURL.'\'+folder;
01008                     self.parent.parent.renderPopup_addLink(theLink, cur_target, cur_class, cur_title);
01009                     return false;
01010                 }
01011                 function link_spec(theLink) {   //
01012                     self.parent.parent.renderPopup_addLink(theLink, cur_target, cur_class, cur_title);
01013                     return false;
01014                 }
01015                 function link_current() {   //
01016                     if (cur_href!="http://" && cur_href!="mailto:") {
01017                         self.parent.parent.renderPopup_addLink(cur_href, cur_target, cur_class, cur_title);
01018                     }
01019                     return false;
01020                 }
01021             ';
01022         }
01023 
01024             // General "jumpToUrl" function:
01025         $JScode.='
01026             function jumpToUrl(URL,anchor)  {   //
01027                 var add_act = URL.indexOf("act=")==-1 ? "&act='.$this->act.'" : "";
01028                 var add_mode = URL.indexOf("mode=")==-1 ? "&mode='.$this->mode.'" : "";
01029                 var theLocation = URL + add_act + add_mode + add_href + add_target + add_class + add_title + add_params'.($addPassOnParams?'+"'.$addPassOnParams.'"':'').'+(anchor?anchor:"");
01030                 window.location.href = theLocation;
01031                 return false;
01032             }
01033         ';
01034 
01035 
01036         /**
01037          * Splits parts of $this->bparams
01038          * @see $bparams
01039          */
01040         $pArr = explode('|',$this->bparams);
01041 
01042             // This is JavaScript especially for the TBE Element Browser!
01043         $formFieldName = 'data['.$pArr[0].']['.$pArr[1].']['.$pArr[2].']';
01044 
01045             // insertElement - Call check function (e.g. for uniqueness handling):
01046         if ($pArr[4] && $pArr[5]) {
01047             $JScodeCheck = '
01048                     // Call a check function in the opener window (e.g. for uniqueness handling):
01049                 if (parent.window.opener) {
01050                     var res = parent.window.opener.'.$pArr[5].'("'.addslashes($pArr[4]).'",table,uid,type);
01051                     if (!res.passed) {
01052                         if (res.message) alert(res.message);
01053                         performAction = false;
01054                     }
01055                 } else {
01056                     alert("Error - reference to main window is not set properly!");
01057                     parent.close();
01058                 }
01059             ';
01060         }
01061             // insertElement - Call helper function:
01062         if ($pArr[4] && $pArr[6]) {
01063             $JScodeHelper = '
01064                         // Call helper function to manage data in the opener window:
01065                     if (parent.window.opener) {
01066                         parent.window.opener.'.$pArr[6].'("'.addslashes($pArr[4]).'",table,uid,type,"'.addslashes($pArr[0]).'");
01067                     } else {
01068                         alert("Error - reference to main window is not set properly!");
01069                         parent.close();
01070                     }
01071             ';
01072         }
01073             // insertElement - perform action commands:
01074         if ($pArr[4] && $pArr[7]) {
01075                 // Call user defined action function:
01076             $JScodeAction = '
01077                     if (parent.window.opener) {
01078                         parent.window.opener.'.$pArr[7].'("'.addslashes($pArr[4]).'",table,uid,type);
01079                         focusOpenerAndClose(close);
01080                     } else {
01081                         alert("Error - reference to main window is not set properly!");
01082                         parent.close();
01083                     }
01084             ';
01085         } else if ($pArr[0] && !$pArr[1] && !$pArr[2]) {
01086             $JScodeAction = '
01087                     addElement(filename,table+"_"+uid,fp,close);
01088             ';
01089         } else {
01090             $JScodeAction = '
01091                     if (setReferences()) {
01092                         parent.window.opener.group_change("add","'.$pArr[0].'","'.$pArr[1].'","'.$pArr[2].'",elRef,targetDoc);
01093                     } else {
01094                         alert("Error - reference to main window is not set properly!");
01095                     }
01096                     focusOpenerAndClose(close);
01097             ';
01098         }
01099 
01100         $JScode.='
01101             var elRef="";
01102             var targetDoc="";
01103 
01104             function launchView(url)    {   //
01105                 var thePreviewWindow="";
01106                 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");
01107                 if (thePreviewWindow && thePreviewWindow.focus) {
01108                     thePreviewWindow.focus();
01109                 }
01110             }
01111             function setReferences()    {   //
01112                 if (parent.window.opener && parent.window.opener.content && parent.window.opener.content.document.editform && parent.window.opener.content.document.editform["'.$formFieldName.'"]) {
01113                     targetDoc = parent.window.opener.content.document;
01114                     elRef = targetDoc.editform["'.$formFieldName.'"];
01115                     return true;
01116                 } else {
01117                     return false;
01118                 }
01119             }
01120             function insertElement(table, uid, type, filename,fp,filetype,imagefile,action, close)  {   //
01121                 var performAction = true;
01122                 '.$JScodeCheck.'
01123                     // Call performing function and finish this action:
01124                 if (performAction) {
01125                         '.$JScodeHelper.$JScodeAction.'
01126                 }
01127                 return false;
01128             }
01129             function addElement(elName,elValue,altElValue,close)    {   //
01130                 if (parent.window.opener && parent.window.opener.setFormValueFromBrowseWin) {
01131                     parent.window.opener.setFormValueFromBrowseWin("'.$pArr[0].'",altElValue?altElValue:elValue,elName);
01132                     focusOpenerAndClose(close);
01133                 } else {
01134                     alert("Error - reference to main window is not set properly!");
01135                     parent.close();
01136                 }
01137             }
01138             function focusOpenerAndClose(close) {   //
01139                 BrowseLinks.focusOpenerAndClose(close);
01140             }
01141         ';
01142 
01143             // Finally, add the accumulated JavaScript to the template object:
01144         $this->doc->JScode.= $this->doc->wrapScriptTags($JScode);
01145 
01146             // Debugging:
01147         if (FALSE) debug(array(
01148             'pointer' => $this->pointer,
01149             'act' => $this->act,
01150             'mode' => $this->mode,
01151             'curUrlInfo' => $this->curUrlInfo,
01152             'curUrlArray' => $this->curUrlArray,
01153             'P' => $this->P,
01154             'bparams' => $this->bparams,
01155             'RTEtsConfigParams' => $this->RTEtsConfigParams,
01156             'expandPage' => $this->expandPage,
01157             'expandFolder' => $this->expandFolder,
01158             'PM' => $this->PM,
01159         ),'Internal variables of Script Class:');
01160     }
01161 
01162 
01163     /**
01164      * Session data for this class can be set from outside with this method.
01165      * Call after init()
01166      *
01167      * @param   array       Session data array
01168      * @return  array       Session data and boolean which indicates that data needs to be stored in session because it's changed
01169      */
01170     function processSessionData($data) {
01171         $store = false;
01172 
01173         switch((string)$this->mode) {
01174             case 'db':
01175                 if (isset($this->expandPage))   {
01176                     $data['expandPage']=$this->expandPage;
01177                     $store = true;
01178                 } else {
01179                     $this->expandPage=$data['expandPage'];
01180                 }
01181             break;
01182             case 'file':
01183             case 'filedrag':
01184             case 'folder':
01185                 if (isset($this->expandFolder)) {
01186                     $data['expandFolder']=$this->expandFolder;
01187                     $store = true;
01188                 } else {
01189                     $this->expandFolder=$data['expandFolder'];
01190                 }
01191             break;
01192         }
01193 
01194         return array($data, $store);
01195     }
01196 
01197 
01198 
01199 
01200     /******************************************************************
01201      *
01202