class.tx_rtehtmlarea_browse_links.php

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2010 Kasper Skårhøj (kasperYYYY@typo3.com)
00006 *  (c) 2005-2010 Stanislas Rolland <typo3(arobas)sjbr.ca>
00007 *  All rights reserved
00008 *
00009 *  This script is part of the TYPO3 project. The TYPO3 project is
00010 *  free software; you can redistribute it and/or modify
00011 *  it under the terms of the GNU General Public License as published by
00012 *  the Free Software Foundation; either version 2 of the License, or
00013 *  (at your option) any later version.
00014 *
00015 *  The GNU General Public License can be found at
00016 *  http://www.gnu.org/copyleft/gpl.html.
00017 *  A copy is found in the textfile GPL.txt and important notices to the license
00018 *  from the author is found in LICENSE.txt distributed with these scripts.
00019 *
00020 *
00021 *  This script is distributed in the hope that it will be useful,
00022 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00023 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00024 *  GNU General Public License for more details.
00025 *
00026 *  This copyright notice MUST APPEAR in all copies of the script!
00027 ***************************************************************/
00028 /**
00029  * Displays the page/file tree for browsing database records or files.
00030  * Used from TCEFORMS an other elements
00031  * In other words: This is the ELEMENT BROWSER!
00032  *
00033  * Adapted for htmlArea RTE by Stanislas Rolland
00034  *
00035  * $Id: class.tx_rtehtmlarea_browse_links.php 8742 2010-08-30 18:55:32Z baschny $
00036  *
00037  * @author  Kasper Skårhøj <kasperYYYY@typo3.com>
00038  * @author  Stanislas Rolland <typo3(arobas)sjbr.ca>
00039  */
00040 
00041 require_once (PATH_typo3.'class.browse_links.php');
00042 
00043 
00044 /**
00045  * Class which generates the page tree
00046  *
00047  * @author  Kasper Skårhøj <kasperYYYY@typo3.com>
00048  * @package TYPO3
00049  * @subpackage core
00050  */
00051 class tx_rtehtmlarea_pageTree extends rtePageTree {
00052 
00053     /**
00054      * Create the page navigation tree in HTML
00055      *
00056      * @param   array       Tree array
00057      * @return  string      HTML output.
00058      */
00059     function printTree($treeArr='') {
00060         global $BACK_PATH;
00061         $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
00062         if (!is_array($treeArr))    $treeArr=$this->tree;
00063 
00064         $out='';
00065         $c=0;
00066 
00067         foreach($treeArr as $k => $v)   {
00068             $c++;
00069             $bgColorClass = ($c+1)%2 ? 'bgColor' : 'bgColor-10';
00070             if ($GLOBALS['SOBE']->browser->curUrlInfo['act']=='page' && $GLOBALS['SOBE']->browser->curUrlInfo['pageid']==$v['row']['uid'] && $GLOBALS['SOBE']->browser->curUrlInfo['pageid'])   {
00071                 $arrCol='<td><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/blinkarrow_right.gif','width="5" height="9"').' class="c-blinkArrowR" alt="" /></td>';
00072                 $bgColorClass='bgColor4';
00073             } else {
00074                 $arrCol='<td></td>';
00075             }
00076 
00077             $aOnClick = 'return jumpToUrl(\''.$this->thisScript.'?act='.$GLOBALS['SOBE']->browser->act.'&editorNo='.$GLOBALS['SOBE']->browser->editorNo.'&contentTypo3Language='.$GLOBALS['SOBE']->browser->contentTypo3Language.'&contentTypo3Charset='.$GLOBALS['SOBE']->browser->contentTypo3Charset.'&mode='.$GLOBALS['SOBE']->browser->mode.'&expandPage='.$v['row']['uid'].'\');';
00078             $cEbullet = $this->ext_isLinkable($v['row']['doktype'],$v['row']['uid']) ?
00079                         '<a href="#" onclick="'.htmlspecialchars($aOnClick).'"><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/arrowbullet.gif','width="18" height="16"').' alt="" /></a>' :
00080                         '';
00081             $out.='
00082                 <tr class="'.$bgColorClass.'">
00083                     <td nowrap="nowrap"'.($v['row']['_CSSCLASS'] ? ' class="'.$v['row']['_CSSCLASS'].'"' : '').'>'.
00084                     $v['HTML'].
00085                     $this->wrapTitle($this->getTitleStr($v['row'],$titleLen),$v['row'],$this->ext_pArrPages).
00086                     '</td>'.
00087                     $arrCol.
00088                     '<td>'.$cEbullet.'</td>
00089                 </tr>';
00090         }
00091         $out='
00092 
00093 
00094             <!--
00095                 Navigation Page Tree:
00096             -->
00097             <table border="0" cellpadding="0" cellspacing="0" id="typo3-tree">
00098                 '.$out.'
00099             </table>';
00100         return $out;
00101     }
00102 }
00103 
00104 /**
00105  * Base extension class which generates the folder tree.
00106  * Used directly by the RTE.
00107  *
00108  * @author  Kasper Skårhøj <kasperYYYY@typo3.com>
00109  * @package TYPO3
00110  * @subpackage core
00111  */
00112 class tx_rtehtmlarea_folderTree extends rteFolderTree {
00113 
00114     /**
00115      * Wrapping the title in a link, if applicable.
00116      *
00117      * @param   string      Title, ready for output.
00118      * @param   array       The "record"
00119      * @return  string      Wrapping title string.
00120      */
00121     function wrapTitle($title,$v)   {
00122         $title = htmlspecialchars($title);
00123         
00124         if ($this->ext_isLinkable($v))  {
00125             $aOnClick = 'return jumpToUrl(\''.$this->thisScript.'?act='.$GLOBALS['SOBE']->browser->act.'&editorNo='.$GLOBALS['SOBE']->browser->editorNo.'&contentTypo3Language='.$GLOBALS['SOBE']->browser->contentTypo3Language.'&contentTypo3Charset='.$GLOBALS['SOBE']->browser->contentTypo3Charset.'&mode='.$GLOBALS['SOBE']->browser->mode.'&expandFolder='.rawurlencode($v['path']).'\');';
00126             return '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$title.'</a>';
00127         } else {
00128             return '<span class="typo3-dimmed">'.$title.'</span>';
00129         }
00130     }
00131 
00132     /**
00133      * Create the folder navigation tree in HTML
00134      *
00135      * @param   mixed       Input tree array. If not array, then $this->tree is used.
00136      * @return  string      HTML output of the tree.
00137      */
00138     function printTree($treeArr='') {
00139         global $BACK_PATH;
00140         $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
00141 
00142         if (!is_array($treeArr))    $treeArr=$this->tree;
00143 
00144         $out='';
00145         $c=0;
00146 
00147             // Preparing the current-path string (if found in the listing we will see a red blinking arrow).
00148         if (!$GLOBALS['SOBE']->browser->curUrlInfo['value'])    {
00149             $cmpPath='';
00150         } else if (substr(trim($GLOBALS['SOBE']->browser->curUrlInfo['info']),-1)!='/') {
00151             $cmpPath=PATH_site.dirname($GLOBALS['SOBE']->browser->curUrlInfo['info']).'/';
00152         } else {
00153             $cmpPath=PATH_site.$GLOBALS['SOBE']->browser->curUrlInfo['info'];
00154         }
00155 
00156             // Traverse rows for the tree and print them into table rows:
00157         foreach($treeArr as $k => $v)   {
00158             $c++;
00159             $bgColorClass=($c+1)%2 ? 'bgColor' : 'bgColor-10';
00160 
00161                 // Creating blinking arrow, if applicable:
00162             if ($GLOBALS['SOBE']->browser->curUrlInfo['act']=='file' && $cmpPath==$v['row']['path'])    {
00163                 $arrCol='<td><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/blinkarrow_right.gif','width="5" height="9"').' class="c-blinkArrowR" alt="" /></td>';
00164                 $bgColorClass='bgColor4';
00165             } else {
00166                 $arrCol='<td></td>';
00167             }
00168                 // Create arrow-bullet for file listing (if folder path is linkable):
00169             $aOnClick = 'return jumpToUrl(\''.$this->thisScript.'?act='.$GLOBALS['SOBE']->browser->act.'&editorNo='.$GLOBALS['SOBE']->browser->editorNo.'&contentTypo3Language='.$GLOBALS['SOBE']->browser->contentTypo3Language.'&contentTypo3Charset='.$GLOBALS['SOBE']->browser->contentTypo3Charset.'&mode='.$GLOBALS['SOBE']->browser->mode.'&expandFolder='.rawurlencode($v['row']['path']).'\');';
00170             $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>' : '';
00171 
00172                 // Put table row with folder together:
00173             $out.='
00174                 <tr class="'.$bgColorClass.'">
00175                     <td nowrap="nowrap">'.$v['HTML'].$this->wrapTitle(t3lib_div::fixed_lgd_cs($v['row']['title'],$titleLen),$v['row']).'</td>
00176                     '.$arrCol.'
00177                     <td>'.$cEbullet.'</td>
00178                 </tr>';
00179         }
00180 
00181         $out='
00182 
00183             <!--
00184                 Folder tree:
00185             -->
00186             <table border="0" cellpadding="0" cellspacing="0" id="typo3-tree">
00187                 '.$out.'
00188             </table>';
00189         return $out;
00190     }
00191 
00192 }
00193 
00194 /**
00195  * Script class for the Element Browser window.
00196  *
00197  * @author  Kasper Skårhøj <kasperYYYY@typo3.com>
00198  * @package TYPO3
00199  * @subpackage core
00200  */
00201 class tx_rtehtmlarea_browse_links extends browse_links {
00202 
00203     var $editorNo;
00204     var $contentTypo3Language;
00205     var $contentTypo3Charset;
00206     public $additionalAttributes = array();
00207     public $buttonConfig = array();
00208     public $RTEProperties = array();
00209 
00210     public $anchorTypes = array( 'page', 'url', 'file', 'mail', 'spec');
00211     public $classesAnchorDefault = array();
00212     public $classesAnchorDefaultTitle = array();
00213     public $classesAnchorClassTitle = array();
00214     public $classesAnchorDefaultTarget = array();
00215     public $classesAnchorJSOptions = array();
00216 
00217     public $allowedItems;
00218 
00219     /**
00220      * Constructor:
00221      * Initializes a lot of variables, setting JavaScript functions in header etc.
00222      *
00223      * @return  void
00224      */
00225     function init() {
00226 
00227         $this->initVariables();
00228         $this->initConfiguration();
00229 
00230             // Creating backend template object:
00231         $this->doc = t3lib_div::makeInstance('template');
00232         $this->doc->backPath = $GLOBALS['BACK_PATH'];
00233             // Loading the Prototype library and browse_links.js
00234         $this->doc->getPageRenderer()->loadPrototype();
00235         $this->doc->loadJavascriptLib('js/browse_links.js');
00236             // Adding context menu code
00237         $this->doc->getContextMenuCode();
00238             // Init fileProcessor
00239         $this->fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
00240         $this->fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
00241 
00242             // Initializing hooking browsers
00243         $this->initHookObjects('ext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php');
00244 
00245             // CurrentUrl - the current link url must be passed around if it exists
00246         $this->curUrlArray = t3lib_div::_GP('curUrl');
00247         if ($this->curUrlArray['all'])  {
00248             $this->curUrlArray=t3lib_div::get_tag_attributes($this->curUrlArray['all']);
00249         }
00250             // Note: parseCurUrl will invoke the hooks
00251         $this->curUrlInfo = $this->parseCurUrl($this->curUrlArray['href'],$this->siteURL);
00252         if (isset($this->curUrlArray['external']) && $this->curUrlInfo['act'] != 'mail') {
00253             $this->curUrlInfo['act'] = 'url';
00254             $this->curUrlInfo['info'] = $this->curUrlArray['href'];
00255         }
00256             // Determine nature of current url:
00257         $this->act = t3lib_div::_GP('act');
00258         if (!$this->act)    {
00259             $this->act=$this->curUrlInfo['act'];
00260         }
00261             // Setting intial values for link attributes
00262         $this->initLinkAttributes();
00263 
00264             // Add attributes to body tag. Note: getBodyTagAdditions will invoke the hooks
00265         $this->doc->bodyTagAdditions = $this->getBodyTagAdditions();
00266             // Adding RTE JS code
00267         $this->doc->JScodeArray['rtehtmlarea'] = $this->getJSCode();
00268     }
00269 
00270     /**
00271      * Initialize class variables
00272      *
00273      * @return  void
00274      */
00275     public function initVariables() {
00276 
00277             // Process bparams
00278         $this->bparams = t3lib_div::_GP('bparams');
00279         $pArr = explode('|', $this->bparams);
00280         $pRteArr = explode(':', $pArr[1]);
00281         $this->editorNo = $pRteArr[0];
00282         $this->contentTypo3Language = $pRteArr[1];
00283         $this->contentTypo3Charset = $pRteArr[2];
00284         $this->RTEtsConfigParams = $pArr[2];
00285         if (!$this->editorNo) {
00286             $this->editorNo = t3lib_div::_GP('editorNo');
00287             $this->contentTypo3Language = t3lib_div::_GP('contentTypo3Language');
00288             $this->contentTypo3Charset = t3lib_div::_GP('contentTypo3Charset');
00289             $this->RTEtsConfigParams = t3lib_div::_GP('RTEtsConfigParams');
00290         }
00291         $this->pointer = t3lib_div::_GP('pointer');
00292         $this->expandPage = t3lib_div::_GP('expandPage');
00293         $this->expandFolder = t3lib_div::_GP('expandFolder');
00294         $this->P = t3lib_div::_GP('P');
00295         $this->PM = t3lib_div::_GP('PM');
00296         $pArr[1] = implode(':', array($this->editorNo, $this->contentTypo3Language, $this->contentTypo3Charset));
00297         $pArr[2] = $this->RTEtsConfigParams;
00298         $this->bparams = implode('|', $pArr);
00299 
00300             // Find "mode"
00301         $this->mode = t3lib_div::_GP('mode');
00302         if (!$this->mode)   {
00303             $this->mode = 'rte';
00304         }
00305             // Current site url
00306         $this->siteURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL');
00307 
00308             // the script to link to
00309         $this->thisScript = t3lib_div::getIndpEnv('SCRIPT_NAME');
00310     }
00311 
00312     /**
00313      * Initializes the configuration variables
00314      *
00315      * @return  void
00316      */
00317      public function initConfiguration() {
00318         $this->thisConfig = $this->getRTEConfig();
00319         $this->buttonConfig = $this->getButtonConfig('link');
00320      }
00321 
00322     /**
00323      * Get the RTE configuration from Page TSConfig
00324      *
00325      * @return  array       RTE configuration array
00326      */
00327     protected function getRTEConfig()   {
00328         global $BE_USER;
00329 
00330         $RTEtsConfigParts = explode(':', $this->RTEtsConfigParams);
00331         $RTEsetup = $BE_USER->getTSConfig('RTE',t3lib_BEfunc::getPagesTSconfig($RTEtsConfigParts[5]));
00332         $this->RTEProperties = $RTEsetup['properties'];
00333         return t3lib_BEfunc::RTEsetup($this->RTEProperties, $RTEtsConfigParts[0],$RTEtsConfigParts[2],$RTEtsConfigParts[4]);
00334     }
00335 
00336     /**
00337      * Get the configuration of the button
00338      *
00339      * @param   string      $buttonName: the name of the button
00340      * @return  array       the configuration array of the image button
00341      */
00342     protected function getButtonConfig($buttonName) {
00343         return ((is_array($this->thisConfig['buttons.']) && is_array($this->thisConfig['buttons.'][$buttonName.'.'])) ? $this->thisConfig['buttons.'][$buttonName.'.'] : array());
00344     }
00345 
00346     /**
00347      * Initialize hook objects implementing interface t3lib_browseLinksHook
00348      * @param   string      $hookKey: the hook key
00349      * @return  void
00350      */
00351     protected function initHookObjects($hookKey) {
00352         global $TYPO3_CONF_VARS;
00353         if (is_array($TYPO3_CONF_VARS['SC_OPTIONS'][$hookKey]['browseLinksHook'])) {
00354             foreach ($TYPO3_CONF_VARS['SC_OPTIONS'][$hookKey]['browseLinksHook'] as $classData) {
00355                 $processObject = t3lib_div::getUserObj($classData);
00356                 if(!($processObject instanceof t3lib_browseLinksHook)) {
00357                     throw new UnexpectedValueException('$processObject must implement interface t3lib_browseLinksHook', 1195115652);
00358                 }
00359                 $parameters = array();
00360                 $processObject->init($this, $parameters);
00361                 $this->hookObjects[] = $processObject;
00362             }
00363         }
00364     }
00365 
00366     /**
00367      * Initialize the current or default values of the link attributes
00368      *
00369      * @return  void
00370      */
00371     protected function initLinkAttributes() {
00372 
00373             // Initializing the title value
00374         $this->setTitle = $GLOBALS['LANG']->csConvObj->conv($this->curUrlArray['title'], 'utf-8', $GLOBALS['LANG']->charSet);
00375 
00376             // Processing the classes configuration
00377         $classSelected = array();
00378         if ($this->thisConfig['classesAnchor'] || $this->thisConfig['classesLinks']) {
00379             $this->setClass = $this->curUrlArray['class'];
00380             if ($this->thisConfig['classesAnchor']) {
00381                 $classesAnchorArray = t3lib_div::trimExplode(',',$this->thisConfig['classesAnchor'], 1);
00382             } else {
00383                 $classesAnchorArray = t3lib_div::trimExplode(',',$this->thisConfig['classesLinks'], 1);
00384             }
00385                 // Collecting allowed classes and configured default values
00386             $classesAnchor = array();
00387             $classesAnchor['all'] = array();
00388             $titleReadOnly = $this->buttonConfig['properties.']['title.']['readOnly'] || $this->buttonConfig[$this->act.'.']['properties.']['title.']['readOnly'];
00389             if (is_array($this->RTEProperties['classesAnchor.'])) {
00390                 foreach ($this->RTEProperties['classesAnchor.'] as $label => $conf) {
00391                     if (in_array($conf['class'], $classesAnchorArray)) {
00392                         $classesAnchor['all'][] = $conf['class'];
00393                         if (in_array($conf['type'], $this->anchorTypes)) {
00394                             $classesAnchor[$conf['type']][] = $conf['class'];
00395                             if (is_array($this->thisConfig['classesAnchor.']) && is_array($this->thisConfig['classesAnchor.']['default.']) && $this->thisConfig['classesAnchor.']['default.'][$conf['type']] == $conf['class']) {
00396                                 $this->classesAnchorDefault[$conf['type']] = $conf['class'];
00397                                 if ($conf['titleText']) {
00398                                     $this->classesAnchorDefaultTitle[$conf['type']] = $this->getLLContent(trim($conf['titleText']));
00399                                 }
00400                                 if ($conf['target']) {
00401                                     $this->classesAnchorDefaultTarget[$conf['type']] = trim($conf['target']);
00402                                 }
00403                             }
00404                         }
00405                         if ($titleReadOnly && $conf['titleText']) {
00406                             $this->classesAnchorClassTitle[$conf['class']] = $this->classesAnchorDefaultTitle[$conf['type']] = $this->getLLContent(trim($conf['titleText']));
00407                         }
00408                     }
00409                 }
00410             }
00411                 // Constructing the class selector options
00412             foreach ($this->anchorTypes as $anchorType) {
00413                 foreach ($classesAnchorArray as $class) {
00414                     if (!in_array($class, $classesAnchor['all']) || (in_array($class, $classesAnchor['all']) && is_array($classesAnchor[$anchorType]) && in_array($class, $classesAnchor[$anchorType]))) {
00415                         $selected = '';
00416                         if ($this->setClass == $class || (!$this->setClass && $this->classesAnchorDefault[$anchorType] == $class)) {
00417                             $selected = 'selected="selected"';
00418                             $classSelected[$anchorType] = true;
00419                         }
00420                         $classLabel = (is_array($this->RTEProperties['classes.']) && is_array($this->RTEProperties['classes.'][$class.'.']) && $this->RTEProperties['classes.'][$class.'.']['name']) ? $this->getPageConfigLabel($this->RTEProperties['classes.'][$class.'.']['name'], 0) : $class;
00421                         $classStyle = (is_array($this->RTEProperties['classes.']) && is_array($this->RTEProperties['classes.'][$class.'.']) && $this->RTEProperties['classes.'][$class.'.']['value']) ? $this->RTEProperties['classes.'][$class.'.']['value'] : '';
00422                         $this->classesAnchorJSOptions[$anchorType] .= '<option ' . $selected . ' value="' .$class . '"' . ($classStyle?' style="'.$classStyle.'"':'') . '>' . $classLabel . '</option>';
00423                     }
00424                 }
00425                 if ($this->classesAnchorJSOptions[$anchorType] && !($this->buttonConfig['properties.']['class.']['required'] || $this->buttonConfig[$this->act.'.']['properties.']['class.']['required'])) {
00426                     $selected = '';
00427                     if (!$this->setClass && !$this->classesAnchorDefault[$anchorType])  $selected = 'selected="selected"';
00428                     $this->classesAnchorJSOptions[$anchorType] =  '<option ' . $selected . ' value=""></option>' . $this->classesAnchorJSOptions[$anchorType];
00429                 }
00430             }
00431         }
00432             // Initializing the target value
00433             // Unset the target if it is set to a value different than default and if no class is selected and the target field is not displayed
00434             // In other words, do not forward the target if we changed tab and the target field is not displayed
00435         $this->setTarget = (isset($this->curUrlArray['target'])
00436                 && !(
00437                     ($this->curUrlArray['target'] != $this->thisConfig['defaultLinkTarget'])
00438                     && !$classSelected[$this->act]
00439                     && is_array($this->buttonConfig['targetSelector.']) && $this->buttonConfig['targetSelector.']['disabled'] && is_array($this->buttonConfig['popupSelector.']) && $this->buttonConfig['popupSelector.']['disabled'])
00440                 ) ? $this->curUrlArray['target'] : '';
00441         if ($this->thisConfig['defaultLinkTarget'] && !isset($this->curUrlArray['target'])) {
00442             $this->setTarget=$this->thisConfig['defaultLinkTarget'];
00443         }
00444             // Initializing additional attributes
00445         if ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['rtehtmlarea']['plugins']['TYPO3Link']['additionalAttributes']) {
00446             $addAttributes = t3lib_div::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['rtehtmlarea']['plugins']['TYPO3Link']['additionalAttributes'], 1);
00447             foreach ($addAttributes as $attribute) {
00448                 $this->additionalAttributes[$attribute] = isset($this->curUrlArray[$attribute]) ? $this->curUrlArray[$attribute] : '';
00449             }
00450         }
00451     }
00452 
00453     /**
00454      * Provide the additional parameters to be included in the template body tag
00455      *
00456      * @return  string      the body tag additions
00457      */
00458     public function getBodyTagAdditions() {
00459         $bodyTagAdditions = array();
00460             // call hook for extra additions
00461         foreach ($this->hookObjects as $hookObject) {
00462             if (method_exists($hookObject, 'addBodyTagAdditions')) {
00463                 $bodyTagAdditions = $hookObject->addBodyTagAdditions($bodyTagAdditions);
00464             }
00465         }
00466         return t3lib_div::implodeAttributes($bodyTagAdditions, TRUE);
00467     }
00468 
00469     /**
00470      * Generate JS code to be used on the link insert/modify dialogue
00471      *
00472      * @return  string      the generated JS code
00473      */
00474     function getJSCode()    {
00475         global $BACK_PATH;
00476             // BEGIN accumulation of header JavaScript:
00477         $JScode = '';
00478         $JScode.= '
00479             var plugin = window.parent.RTEarea["' . $this->editorNo . '"].editor.getPlugin("TYPO3Link");
00480             var HTMLArea = window.parent.HTMLArea;
00481             var add_href="'.($this->curUrlArray['href']?'&curUrl[href]='.rawurlencode($this->curUrlArray['href']):'').'";
00482             var add_target="'.($this->setTarget?'&curUrl[target]='.rawurlencode($this->setTarget):'').'";
00483             var add_class="'.($this->setClass?'&curUrl[class]='.rawurlencode($this->setClass):'').'";
00484             var add_title="'.($this->setTitle?'&curUrl[title]='.rawurlencode($this->setTitle):'').'";
00485             var add_params="'.($this->bparams?'&bparams='.rawurlencode($this->bparams):'').'";
00486             var additionalValues = ' . (count($this->additionalAttributes) ? json_encode($this->additionalAttributes) : '{}') . ';';
00487 
00488             // Attributes setting functions
00489         $JScode.= '
00490             var cur_href="'.($this->curUrlArray['href'] ? ($this->curUrlInfo['query'] ? substr($this->curUrlArray['href'], 0, -strlen($this->curUrlInfo['query'])) :$this->curUrlArray['href']):'').'";
00491             var cur_target="'.($this->setTarget?$this->setTarget:'').'";
00492             var cur_class="'.($this->setClass?$this->setClass:'').'";
00493             var cur_title="'.($this->setTitle?$this->setTitle:'').'";
00494 
00495             function browse_links_setTarget(value)  {
00496                 cur_target=value;
00497                 add_target="&curUrl[target]="+encodeURIComponent(value);
00498             }
00499             function browse_links_setClass(value)   {
00500                 cur_class=value;
00501                 add_class="&curUrl[class]="+encodeURIComponent(value);
00502             }
00503             function browse_links_setTitle(value)   {
00504                 cur_title=value;
00505                 add_title="&curUrl[title]="+encodeURIComponent(value);
00506             }
00507             function browse_links_setHref(value)    {
00508                 cur_href=value;
00509                 add_href="&curUrl[href]="+value;
00510             }
00511             function browse_links_setAdditionalValue(name, value) {
00512                 additionalValues[name] = value;
00513             }
00514         ';
00515             // Link setting functions
00516         $JScode.='
00517             function link_typo3Page(id,anchor) {
00518                 var parameters = (document.ltargetform.query_parameters && document.ltargetform.query_parameters.value) ? (document.ltargetform.query_parameters.value.charAt(0) == "&" ? "" : "&") + document.ltargetform.query_parameters.value : "";
00519                 var theLink = \'' . $this->siteURL . '?id=\' + id + parameters + (anchor ? anchor : "");
00520                 if (document.ltargetform.anchor_title) browse_links_setTitle(document.ltargetform.anchor_title.value);
00521                 if (document.ltargetform.anchor_class) browse_links_setClass(document.ltargetform.anchor_class.value);
00522                 if (document.ltargetform.ltarget) browse_links_setTarget(document.ltargetform.ltarget.value);
00523                 if (document.ltargetform.lrel) browse_links_setAdditionalValue("rel", document.ltargetform.lrel.value);
00524                 plugin.createLink(theLink,cur_target,cur_class,cur_title,additionalValues);
00525                 return false;
00526             }
00527             function link_folder(folder) {
00528                 var theLink = \''.$this->siteURL.'\'+folder;
00529                 if (document.ltargetform.anchor_title) browse_links_setTitle(document.ltargetform.anchor_title.value);
00530                 if (document.ltargetform.anchor_class) browse_links_setClass(document.ltargetform.anchor_class.value);
00531                 if (document.ltargetform.ltarget) browse_links_setTarget(document.ltargetform.ltarget.value);
00532                 if (document.ltargetform.lrel) browse_links_setAdditionalValue("rel", document.ltargetform.lrel.value);
00533                 plugin.createLink(theLink,cur_target,cur_class,cur_title,additionalValues);
00534                 return false;
00535             }
00536             function link_spec(theLink) {
00537                 if (document.ltargetform.anchor_title) browse_links_setTitle(document.ltargetform.anchor_title.value);
00538                 if (document.ltargetform.anchor_class) browse_links_setClass(document.ltargetform.anchor_class.value);
00539                 if (document.ltargetform.ltarget) browse_links_setTarget(document.ltargetform.ltarget.value);
00540                 plugin.createLink(theLink,cur_target,cur_class,cur_title,additionalValues);
00541                 return false;
00542             }
00543             function link_current() {
00544                 var parameters = (document.ltargetform.query_parameters && document.ltargetform.query_parameters.value) ? (document.ltargetform.query_parameters.value.charAt(0) == "&" ? "" : "&") + document.ltargetform.query_parameters.value : "";
00545                 if (document.ltargetform.anchor_title) browse_links_setTitle(document.ltargetform.anchor_title.value);
00546                 if (document.ltargetform.anchor_class) browse_links_setClass(document.ltargetform.anchor_class.value);
00547                 if (document.ltargetform.ltarget) browse_links_setTarget(document.ltargetform.ltarget.value);
00548                 if (document.ltargetform.lrel) browse_links_setAdditionalValue("rel", document.ltargetform.lrel.value);
00549                 if (cur_href!="http://" && cur_href!="mailto:") {
00550                     plugin.createLink(cur_href + parameters,cur_target,cur_class,cur_title,additionalValues);
00551                 }
00552                 return false;
00553             }
00554         ';
00555             // General "jumpToUrl" and launchView functions:
00556         $JScode.='
00557             function jumpToUrl(URL,anchor) {
00558                 var add_editorNo = URL.indexOf("editorNo=")==-1 ? "&editorNo='.$this->editorNo.'" : "";
00559                 var add_contentTypo3Language = URL.indexOf("contentTypo3Language=")==-1 ? "&contentTypo3Language='.$this->contentTypo3Language.'" : "";
00560                 var add_contentTypo3Charset = URL.indexOf("contentTypo3Charset=")==-1 ? "&contentTypo3Charset='.$this->contentTypo3Charset.'" : "";
00561                 var add_act = URL.indexOf("act=")==-1 ? "&act='.$this->act.'" : "";
00562                 var add_mode = URL.indexOf("mode=")==-1 ? "&mode='.$this->mode.'" : "";
00563                 var add_additionalValues = "";
00564                 if (plugin.pageTSConfiguration && plugin.pageTSConfiguration.additionalAttributes) {
00565                     var additionalAttributes = plugin.pageTSConfiguration.additionalAttributes.split(",");
00566                     for (var i = additionalAttributes.length; --i >= 0;) {
00567                         if (additionalValues[additionalAttributes[i]] != "") {
00568                             add_additionalValues += "&curUrl[" + additionalAttributes[i] + "]=" + encodeURIComponent(additionalValues[additionalAttributes[i]]);
00569                         }
00570                     }
00571                 }
00572                 var theLocation = URL+add_act+add_editorNo+add_contentTypo3Language+add_contentTypo3Charset+add_mode+add_href+add_target+add_class+add_title+add_additionalValues+add_params+(anchor?anchor:"");
00573                 window.location.href = theLocation;
00574                 return false;
00575             }
00576             function launchView(url) {
00577                 var thePreviewWindow="";
00578                 thePreviewWindow = window.open("' . $GLOBALS['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");
00579                 if (thePreviewWindow && thePreviewWindow.focus) {
00580                     thePreviewWindow.focus();
00581                 }
00582             }
00583         ';
00584         return $JScode;
00585     }
00586 
00587     /******************************************************************
00588      *
00589      * Main functions
00590      *
00591      ******************************************************************/
00592     /**
00593      * Rich Text Editor (RTE) link selector (MAIN function)
00594      * Generates the link selector for the Rich Text Editor.
00595      * Can also be used to select links for the TCEforms (see $wiz)
00596      *
00597      * @param   boolean     If set, the "remove link" is not shown in the menu: Used for the "Select link" wizard which is used by the TCEforms
00598      * @return  string      Modified content variable.
00599      */
00600     function main_rte($wiz=0)   {
00601         global $LANG, $BE_USER, $BACK_PATH;
00602 
00603             // Starting content:
00604         $content=$this->doc->startPage($LANG->getLL('Insert/Modify Link',1));
00605 
00606             // Initializing the action value, possibly removing blinded values etc:
00607         $this->allowedItems = explode(',','page,file,url,mail,spec');
00608 
00609             // Calling hook for extra options
00610         foreach($this->hookObjects as $hookObject) {
00611             $this->allowedItems = $hookObject->addAllowedItems($this->allowedItems);
00612         }
00613 
00614         if (is_array($this->buttonConfig['options.']) && $this->buttonConfig['options.']['removeItems']) {
00615             $this->allowedItems = array_diff($this->allowedItems,t3lib_div::trimExplode(',',$this->buttonConfig['options.']['removeItems'],1));
00616         } else {
00617             $this->allowedItems = array_diff($this->allowedItems,t3lib_div::trimExplode(',',$this->thisConfig['blindLinkOptions'],1));
00618         }
00619         reset($this->allowedItems);
00620         if (!in_array($this->act,$this->allowedItems)) {
00621             $this->act = current($this->allowedItems);
00622         }
00623 
00624             // Making menu in top:
00625         $menuDef = array();
00626         if (!$wiz && $this->curUrlArray['href'])    {
00627             $menuDef['removeLink']['isActive'] = $this->act=='removeLink';
00628             $menuDef['removeLink']['label'] = $LANG->getLL('removeLink',1);
00629             $menuDef['removeLink']['url'] = '#';
00630             $menuDef['removeLink']['addParams'] = 'onclick="plugin.unLink();return false;"';
00631         }
00632         if (in_array('page',$this->allowedItems)) {
00633             $menuDef['page']['isActive'] = $this->act=='page';
00634             $menuDef['page']['label'] = $LANG->getLL('page',1);
00635             $menuDef['page']['url'] = '#';
00636             $menuDef['page']['addParams'] = 'onclick="jumpToUrl(\''.htmlspecialchars('?act=page&mode='.$this->mode.'&bparams='.$this->bparams).'\');return false;"';
00637         }
00638         if (in_array('file',$this->allowedItems)){
00639             $menuDef['file']['isActive'] = $this->act=='file';
00640             $menuDef['file']['label'] = $LANG->getLL('file',1);
00641             $menuDef['file']['url'] = '#';
00642             $menuDef['file']['addParams'] = 'onclick="jumpToUrl(\''.htmlspecialchars('?act=file&mode='.$this->mode.'&bparams='.$this->bparams).'\');return false;"';
00643         }
00644         if (in_array('url',$this->allowedItems)) {
00645             $menuDef['url']['isActive'] = $this->act=='url';
00646             $menuDef['url']['label'] = $LANG->getLL('extUrl',1);
00647             $menuDef['url']['url'] = '#';
00648             $menuDef['url']['addParams'] = 'onclick="jumpToUrl(\''.htmlspecialchars('?act=url&mode='.$this->mode.'&bparams='.$this->bparams).'\');return false;"';
00649         }
00650         if (in_array('mail',$this->allowedItems)) {
00651             $menuDef['mail']['isActive'] = $this->act=='mail';
00652             $menuDef['mail']['label'] = $LANG->getLL('email',1);
00653             $menuDef['mail']['url'] = '#';
00654             $menuDef['mail']['addParams'] = 'onclick="jumpToUrl(\''.htmlspecialchars('?act=mail&mode='.$this->mode.'&bparams='.$this->bparams).'\');return false;"';
00655         }
00656         if (is_array($this->thisConfig['userLinks.']) && in_array('spec',$this->allowedItems)) {
00657             $menuDef['spec']['isActive'] = $this->act=='spec';
00658             $menuDef['spec']['label'] = $LANG->getLL('special',1);
00659             $menuDef['spec']['url'] = '#';
00660             $menuDef['spec']['addParams'] = 'onclick="jumpToUrl(\''.htmlspecialchars('?act=spec&mode='.$this->mode.'&bparams='.$this->bparams).'\');return false;"';
00661         }
00662 
00663             // call hook for extra options
00664         foreach($this->hookObjects as $hookObject) {
00665             $menuDef = $hookObject->modifyMenuDefinition($menuDef);
00666         }
00667 
00668         $content .= $this->doc->getTabMenuRaw($menuDef);
00669 
00670             // Adding the menu and header to the top of page:
00671         $content.=$this->printCurrentUrl($this->curUrlInfo['info']).'<br />';
00672 
00673             // Depending on the current action we will create the actual module content for selecting a link:
00674         switch($this->act)  {
00675             case 'mail':
00676                 $extUrl='
00677             <!--
00678                 Enter mail address:
00679             -->
00680                     <form action="" name="lurlform" id="lurlform">
00681                         <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkMail">
00682                             <tr>
00683                                 <td>'.$LANG->getLL('emailAddress',1).':</td>
00684                                 <td><input type="text" name="lemail"'.$this->doc->formWidth(20).' value="'.htmlspecialchars($this->curUrlInfo['act']=='mail'?$this->curUrlInfo['info']:'').'" /> '.
00685                                     '<input type="submit" value="'.$LANG->getLL('setLink',1).'" onclick="browse_links_setTarget(\'\');browse_links_setHref(\'mailto:\'+document.lurlform.lemail.value); return link_current();" /></td>
00686                             </tr>
00687                         </table>
00688                     </form>';
00689                 $content.=$extUrl;
00690                 $content.=$this->addAttributesForm();
00691             break;
00692             case 'url':
00693                 $extUrl='
00694             <!--
00695                 Enter External URL:
00696             -->
00697                     <form action="" name="lurlform" id="lurlform">
00698                         <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkURL">
00699                             <tr>
00700                                 <td>URL:</td>
00701                                 <td><input type="text" name="lurl"'.$this->doc->formWidth(20).' value="'.htmlspecialchars($this->curUrlInfo['act']=='url'?$this->curUrlInfo['info']:'http://').'" /> '.
00702                                     '<input type="submit" value="'.$LANG->getLL('setLink',1).'" onclick="if (/^[A-Za-z0-9_+]{1,8}:/.test(document.lurlform.lurl.value)) { browse_links_setHref(document.lurlform.lurl.value); } else { browse_links_setHref(\'http://\'+document.lurlform.lurl.value); }; browse_links_setAdditionalValue(\'external\', \'1\'); return link_current();" /></td>
00703                             </tr>
00704                         </table>
00705                     </form>';
00706                 $content.=$extUrl;
00707                 $content.=$this->addAttributesForm();
00708             break;
00709             case 'file':
00710                 $content.=$this->addAttributesForm();
00711 
00712                 $foldertree = t3lib_div::makeInstance('tx_rtehtmlarea_folderTree');
00713                 $tree=$foldertree->getBrowsableTree();
00714 
00715                 if (!$this->curUrlInfo['value'] || $this->curUrlInfo['act']!='file')    {
00716                     $cmpPath='';
00717                 } elseif (substr(trim($this->curUrlInfo['info']),-1)!='/')  {
00718                     $cmpPath=PATH_site.dirname($this->curUrlInfo['info']).'/';
00719                     if (!isset($this->expandFolder)) $this->expandFolder = $cmpPath;
00720                 } else {
00721                     $cmpPath=PATH_site.$this->curUrlInfo['info'];
00722                 }
00723 
00724                 list(,,$specUid) = explode('_',$this->PM);
00725                 $files = $this->expandFolder($foldertree->specUIDmap[$specUid]);
00726 
00727                     // Create upload/create folder forms, if a path is given:
00728                 if ($BE_USER->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
00729                     $path=$this->expandFolder;
00730                     if (!$path || !@is_dir($path))  {
00731                         $path = $this->fileProcessor->findTempFolder().'/'; // The closest TEMP-path is found
00732                     }
00733                     if ($path!='/' && @is_dir($path)) {
00734                         $uploadForm=$this->uploadForm($path);
00735                         $createFolder=$this->createFolder($path);
00736                     } else {
00737                         $createFolder='';
00738                         $uploadForm='';
00739                     }
00740                     $content.=$uploadForm;
00741                     if ($BE_USER->isAdmin() || $BE_USER->getTSConfigVal('options.createFoldersInEB')) {
00742                         $content.=$createFolder;
00743                     }
00744                 }
00745 
00746 
00747 
00748                 $content.= '
00749             <!--
00750             Wrapper table for folder tree / file list:
00751             -->
00752                     <table border="0" cellpadding="0" cellspacing="0" id="typo3-linkFiles">
00753                         <tr>
00754                             <td class="c-wCell" valign="top">'.$this->barheader($LANG->getLL('folderTree').':').$tree.'</td>
00755                             <td class="c-wCell" valign="top">'.$files.'</td>
00756                         </tr>
00757                     </table>
00758                     ';
00759             break;
00760             case 'spec':
00761                 if (is_array($this->thisConfig['userLinks.']))  {
00762                     $subcats=array();
00763                     $v=$this->thisConfig['userLinks.'];
00764                     foreach ($v as $k2 => $dummyValue) {
00765                         $k2i = intval($k2);
00766                         if (substr($k2,-1)=='.' && is_array($v[$k2i.'.']))  {
00767 
00768                                 // Title:
00769                             $title = trim($v[$k2i]);
00770                             if (!$title)    {
00771                                 $title=$v[$k2i.'.']['url'];
00772                             } else {
00773                                 $title=$LANG->sL($title);
00774                             }
00775                                 // Description:
00776                             $description=$v[$k2i.'.']['description'] ? $LANG->sL($v[$k2i.'.']['description'],1).'<br />' : '';
00777 
00778                                 // URL + onclick event:
00779                             $onClickEvent='';
00780                             if (isset($v[$k2i.'.']['target']))  $onClickEvent.="browse_links_setTarget('".$v[$k2i.'.']['target']."');";
00781                             $v[$k2i.'.']['url'] = str_replace('###_URL###',$this->siteURL,$v[$k2i.'.']['url']);
00782                             if (substr($v[$k2i.'.']['url'],0,7)=="http://" || substr($v[$k2i.'.']['url'],0,7)=='mailto:')   {
00783                                 $onClickEvent.="cur_href=unescape('".rawurlencode($v[$k2i.'.']['url'])."');link_current();";
00784                             } else {
00785                                 $onClickEvent.="link_spec(unescape('".$this->siteURL.rawurlencode($v[$k2i.'.']['url'])."'));";
00786                             }
00787 
00788                                 // Link:
00789                             $A=array('<a href="#" onclick="'.htmlspecialchars($onClickEvent).'return false;">','</a>');
00790 
00791                                 // Adding link to menu of user defined links:
00792                             $subcats[$k2i]='
00793                                 <tr>
00794                                     <td class="bgColor4">'.$A[0].'<strong>'.htmlspecialchars($title).($this->curUrlInfo['info']==$v[$k2i.'.']['url']?'<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/blinkarrow_right.gif','width="5" height="9"').' class="c-blinkArrowR" alt="" />':'').'</strong><br />'.$description.$A[1].'</td>
00795                                 </tr>';
00796                         }
00797                     }
00798 
00799                         // Sort by keys:
00800                     ksort($subcats);
00801 
00802                         // Add menu to content:
00803                     $content.= '
00804             <!--
00805                 Special userdefined menu:
00806             -->
00807                         <table border="0" cellpadding="1" cellspacing="1" id="typo3-linkSpecial">
00808                             <tr>
00809                                 <td class="bgColor5" class="c-wCell" valign="top"><strong>'.$LANG->getLL('special',1).'</strong></td>
00810                             </tr>
00811                             '.implode('',$subcats).'
00812                         </table>
00813                         ';
00814                 }
00815             break;
00816             case 'page':
00817                 $content.=$this->addAttributesForm();
00818 
00819                 $pagetree = t3lib_div::makeInstance('tx_rtehtmlarea_pageTree');
00820                 $pagetree->ext_showNavTitle = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showNavTitle');
00821                 $pagetree->ext_showPageId = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showPageIdWithTitle');
00822                 $pagetree->addField('nav_title');
00823                 $tree=$pagetree->getBrowsableTree();
00824                 $cElements = $this->expandPage();
00825 
00826 
00827                 // Outputting Temporary DB mount notice:
00828                 if (intval($GLOBALS['BE_USER']->getSessionData('pageTree_temporaryMountPoint')))    {
00829                     $link = '<a href="' . htmlspecialchars(t3lib_div::linkThisScript(array('setTempDBmount' => 0))) . '">' .
00830                                         $LANG->sl('LLL:EXT:lang/locallang_core.xml:labels.temporaryDBmount', 1) .
00831                                     '</a>';
00832                     $flashMessage = t3lib_div::makeInstance(
00833                         't3lib_FlashMessage',
00834                         $link,
00835                         '',
00836                         t3lib_FlashMessage::INFO
00837                     );
00838                     $dbmount = $flashMessage->render();
00839                 }
00840 
00841                 $content .= '
00842             <!--
00843                 Wrapper table for page tree / record list:
00844             -->
00845                     <table border="0" cellpadding="0" cellspacing="0" id="typo3-linkPages">
00846                         <tr>
00847                             <td class="c-wCell" valign="top">' . $this->barheader($LANG->getLL('pageTree') . ':') . $dbmount . $tree . '</td>
00848                             <td class="c-wCell" valign="top">' . $cElements . '</td>
00849                         </tr>
00850                     </table>
00851                     ';
00852             break;
00853             default:
00854                     // call hook
00855                 foreach($this->hookObjects as $hookObject) {
00856                     $content .= $hookObject->getTab($this->act);
00857                 }
00858 
00859             break;
00860         }
00861 
00862             // End page, return content:
00863         $content.= $this->doc->endPage();
00864         $content = $this->doc->insertStylesAndJS($content);
00865         return $content;
00866     }
00867 
00868     function addAttributesForm() {
00869         $ltargetForm = '';
00870             // Add page id, target, class selector box, title and parameters fields:
00871         $lpageId = $this->addPageIdSelector();
00872         $queryParameters = $this->addQueryParametersSelector();
00873         $ltarget = $this->addTargetSelector();
00874         $lclass = $this->addClassSelector();
00875         $ltitle = $this->addTitleSelector();
00876         $rel = $this->addRelField();
00877         if ($lpageId || $queryParameters || $ltarget || $lclass || $ltitle || $rel) {
00878             $ltargetForm = $this->wrapInForm($lpageId.$queryParameters.$ltarget.$lclass.$ltitle.$rel);
00879         }
00880         return $ltargetForm;
00881     }
00882 
00883     function wrapInForm($string) {
00884         global $LANG;
00885 
00886         $form = '
00887             <!--
00888                 Selecting target for link:
00889             -->
00890                 <form action="" name="ltargetform" id="ltargetform">
00891                     <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkTarget">'. $string;
00892         if ($this->act == $this->curUrlInfo['act'] && $this->act != 'mail' && $this->curUrlArray['href']) {
00893             $form .='
00894                         <tr>
00895                             <td>
00896                             </td>
00897                             <td colspan="3">
00898                                 <input type="submit" value="'.$LANG->getLL('update',1).'" onclick="' . (($this->act == 'url') ? 'browse_links_setAdditionalValue(\'external\', \'1\'); ' : '') .'return link_current();" />
00899                             </td>
00900                         </tr>';
00901         }
00902         $form .= '
00903                     </table>
00904                 </form>';
00905         return $form;
00906     }
00907 
00908     function addPageIdSelector() {
00909         global $LANG;
00910 
00911         return ($this->act == 'page' && $this->buttonConfig && is_array($this->buttonConfig['pageIdSelector.']) && $this->buttonConfig['pageIdSelector.']['enabled'])?'
00912                         <tr>
00913                             <td>'.$LANG->getLL('page_id',1).':</td>
00914                             <td colspan="3">
00915                                 <input type="text" size="6" name="luid" />&nbsp;<input type="submit" value="'.$LANG->getLL('setLink',1).'" onclick="return link_typo3Page(document.ltargetform.luid.value);" />
00916                             </td>
00917                         </tr>':'';
00918     }
00919 
00920     function addRelField() {
00921         return (($this->act == 'page' || $this->act == 'url' || $this->act == 'file') && $this->buttonConfig && is_array($this->buttonConfig['relAttribute.']) && $this->buttonConfig['relAttribute.']['enabled'])?'
00922                         <tr>
00923                             <td>'.$GLOBALS['LANG']->getLL('linkRelationship',1).':</td>
00924                             <td colspan="3">
00925                                 <input type="text" name="lrel" value="' . $this->additionalAttributes['rel']. '"  ' . $this->doc->formWidth(30) . ' />
00926                             </td>
00927                         </tr>':'';
00928     }
00929 
00930     function addQueryParametersSelector() {
00931         global $LANG;
00932 
00933         return ($this->act == 'page' && $this->buttonConfig && is_array($this->buttonConfig['queryParametersSelector.']) && $this->buttonConfig['queryParametersSelector.']['enabled'])?'
00934                         <tr>
00935                             <td>'.$LANG->getLL('query_parameters',1).':</td>
00936                             <td colspan="3">
00937                                 <input type="text" name="query_parameters" value="' . ($this->curUrlInfo['query']?$this->curUrlInfo['query']:'') . '" ' . $this->doc->formWidth(30) . ' />
00938                             </td>
00939                         </tr>':'';
00940     }
00941 
00942     function addTargetSelector() {
00943         global $LANG;
00944 
00945         $targetSelectorConfig = array();
00946         $popupSelectorConfig = array();
00947         if (is_array($this->buttonConfig['targetSelector.'])) {
00948             $targetSelectorConfig = $this->buttonConfig['targetSelector.'];
00949         }
00950         if (is_array($this->buttonConfig['popupSelector.'])) {
00951             $popupSelectorConfig = $this->buttonConfig['popupSelector.'];
00952         }
00953 
00954         $ltarget = '';
00955         if ($this->act != 'mail')   {
00956             $ltarget .= '
00957                     <tr id="ltargetrow"'. (($targetSelectorConfig['disabled'] && $popupSelectorConfig['disabled']) ? ' style="display: none;"' : '') . '>
00958                         <td>'.$LANG->getLL('target',1).':</td>
00959                         <td><input type="text" name="ltarget" onchange="browse_links_setTarget(this.value);" value="'.htmlspecialchars($this->setTarget?$this->setTarget:(($this->setClass || !$this->classesAnchorDefault[$this->act])?'':$this->classesAnchorDefaultTarget[$this->act])).'"'.$this->doc->formWidth(10).' /></td>';
00960             $ltarget .= '
00961                         <td colspan="2">';
00962             if (!$targetSelectorConfig['disabled']) {
00963                 $ltarget .= '
00964                             <select name="ltarget_type" onchange="browse_links_setTarget(this.options[this.selectedIndex].value);document.ltargetform.ltarget.value=this.options[this.selectedIndex].value;this.selectedIndex=0;">
00965                                 <option></option>
00966                                 <option value="_top">'.$LANG->getLL('top',1).'</option>
00967                                 <option value="_blank">'.$LANG->getLL('newWindow',1).'</option>
00968                             </select>';
00969             }
00970             $ltarget .= '
00971                         </td>
00972                     </tr>';
00973             if (!$popupSelectorConfig['disabled']) {
00974 
00975                 $selectJS = '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)    {
00976                     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;
00977                     browse_links_setTarget(document.ltargetform.ltarget.value);
00978                     document.ltargetform.popup_width.selectedIndex=0;
00979                     document.ltargetform.popup_height.selectedIndex=0;
00980                 }';
00981 
00982                 $ltarget.='
00983                         <tr>
00984                             <td>'.$LANG->getLL('target_popUpWindow',1).':</td>
00985                             <td colspan="3">
00986                                 <select name="popup_width" onchange="'.$selectJS.'">
00987                                     <option value="0">'.$LANG->getLL('target_popUpWindow_width',1).'</option>
00988                                     <option value="300">300</option>
00989                                     <option value="400">400</option>
00990                                     <option value="500">500</option>
00991                                     <option value="600">600</option>
00992                                     <option value="700">700</option>
00993                                     <option value="800">800</option>
00994                                 </select>
00995                                 x
00996                                 <select name="popup_height" onchange="'.$selectJS.'">
00997                                     <option value="0">'.$LANG->getLL('target_popUpWindow_height',1).'</option>
00998                                     <option value="200">200</option>
00999                                     <option value="300">300</option>
01000                                     <option value="400">400</option>
01001                                     <option value="500">500</option>
01002                                     <option value="600">600</option>
01003                                 </select>
01004                             </td>
01005                         </tr>';
01006             }
01007         }
01008         return $ltarget;
01009     }
01010 
01011     /**
01012      * Return html code for the class selector
01013      *
01014      * @return  string      the html code to be added to the form
01015      */
01016     public function addClassSelector() {
01017         $selectClass = '';
01018         if ($this->classesAnchorJSOptions[$this->act]) {
01019             $selectClass ='
01020                         <tr>
01021                             <td>'.$GLOBALS['LANG']->getLL('anchor_class',1).':</td>
01022                             <td colspan="3">
01023                                 <select name="anchor_class" onchange="'.$this->getClassOnChangeJS().'">
01024                                     ' . $this->classesAnchorJSOptions[$this->act] . '
01025                                 </select>
01026                             </td>
01027                         </tr>';
01028         }
01029         return $selectClass;
01030     }
01031 
01032     /**
01033      * Return JS code for the class selector onChange event
01034      *
01035      * @return  string  class selector onChange JS code
01036      */
01037      public function getClassOnChangeJS() {
01038          return '
01039                     if (document.ltargetform.anchor_class) {
01040                         document.ltargetform.anchor_class.value = document.ltargetform.anchor_class.options[document.ltargetform.anchor_class.selectedIndex].value;
01041                         if (document.ltargetform.anchor_class.value && HTMLArea.classesAnchorSetup) {
01042                             for (var i = HTMLArea.classesAnchorSetup.length; --i >= 0;) {
01043                                 var anchorClass = HTMLArea.classesAnchorSetup[i];
01044                                 if (anchorClass[\'name\'] == document.ltargetform.anchor_class.value) {
01045                                     if (anchorClass[\'titleText\'] && document.ltargetform.anchor_title) {
01046                                         document.ltargetform.anchor_title.value = anchorClass[\'titleText\'];
01047                                         document.getElementById(\'rtehtmlarea-browse-links-title-readonly\').innerHTML = anchorClass[\'titleText\'];
01048                                         browse_links_setTitle(anchorClass[\'titleText\']);
01049                                     }
01050                                     if (anchorClass[\'target\']) {
01051                                         if (document.ltargetform.ltarget) {
01052                                             document.ltargetform.ltarget.value = anchorClass[\'target\'];
01053                                         }
01054                                         browse_links_setTarget(anchorClass[\'target\']);
01055                                     } else if (document.ltargetform.ltarget && document.getElementById(\'ltargetrow\').style.display == \'none\') {
01056                                             // Reset target to default if field is not displayed and class has no configured target
01057                                         document.ltargetform.ltarget.value = \''. ($this->thisConfig['defaultLinkTarget']?$this->thisConfig['defaultLinkTarget']:'') .'\';
01058                                         browse_links_setTarget(document.ltargetform.ltarget.value);
01059                                     }
01060                                     break;
01061                                 }
01062                             }
01063                         }
01064                         browse_links_setClass(document.ltargetform.anchor_class.value);
01065                     }
01066                                 ';
01067      }
01068 
01069     function addTitleSelector() {
01070         $title = ($this->setTitle ? $this->setTitle : (($this->setClass || !$this->classesAnchorDefault[$this->act]) ? '' : $this->classesAnchorDefaultTitle[$this->act]));
01071         $readOnly = $this->buttonConfig['properties.']['title.']['readOnly'] || $this->buttonConfig[$this->act.'.']['properties.']['title.']['readOnly'];
01072         if ($readOnly) {
01073             $title = $this->setClass ? $this->classesAnchorClassTitle[$this->setClass] : $this->classesAnchorDefaultTitle[$this->act];
01074         }
01075         return '
01076                         <tr>
01077                             <td><label for="rtehtmlarea-browse-links-anchor_title" id="rtehtmlarea-browse-links-title-label">' . $GLOBALS['LANG']->getLL('anchor_title',1) . ':</label></td>
01078                             <td colspan="3">
01079                                 <span id="rtehtmlarea-browse-links-title-input" style="display: ' . ($readOnly ? 'none' : 'inline') . ';">
01080                                     <input type="text" id="rtehtmlarea-browse-links-anchor_title" name="anchor_title" value="' . $title . '" ' . $this->doc->formWidth(30) . ' />
01081                                 </span>
01082                                 <span id="rtehtmlarea-browse-links-title-readonly" style="display: ' . ($readOnly ? 'inline' : 'none') . ';">' . $title . '</span>
01083                             </td>
01084                         </tr>';
01085     }
01086 
01087     /**
01088      * Localize a string using the language of the content element rather than the language of the BE interface
01089      *
01090      * @param   string      string: the label to be localized
01091      * @return  string      Localized string.
01092      */
01093     public function getLLContent($string) {
01094         global $LANG;
01095 
01096         $BE_lang = $LANG->lang;
01097         $BE_origCharSet = $LANG->origCharSet;
01098         $BE_charSet = $LANG->charSet;
01099 
01100         $LANG->lang = $this->contentTypo3Language;
01101         $LANG->origCharSet = $LANG->csConvObj->charSetArray[$this->contentTypo3Language];
01102         $LANG->origCharSet = $LANG->origCharSet ? $LANG->origCharSet : 'iso-8859-1';
01103         $LANG->charSet = $this->contentTypo3Charset;
01104         $LLString = $LANG->sL($string);
01105 
01106         $LANG->lang = $BE_lang;
01107         $LANG->origCharSet = $BE_origCharSet;
01108         $LANG->charSet = $BE_charSet;
01109         return $LLString;
01110     }
01111 
01112     /**
01113      * Localize a label obtained from Page TSConfig
01114      *
01115      * @param   string      string: the label to be localized
01116      * @return  string      Localized string.
01117      */
01118     public function getPageConfigLabel($string,$JScharCode=1) {
01119         global $LANG;
01120         if (strcmp(substr($string,0,4),'LLL:')) {
01121             $label = $string;
01122         } else {
01123             $label = $LANG->sL(trim($string));
01124         }
01125         $label = str_replace('"', '\"', str_replace('\\\'', '\'', $label));
01126         $label = $JScharCode ? $LANG->JScharCode($label): $label;
01127         return $label;
01128     }
01129 
01130 }
01131 
01132 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php'])  {
01133     include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php']);
01134 }
01135 
01136 ?>

Generated on Sat Sep 4 04:17:22 2010 for TYPO3 API by  doxygen 1.4.7