2 /***************************************************************
5 * (c) 1999-2009 Kasper Skaarhoj (kasperYYYY@typo3.com)
6 * (c) 2005-2010 Stanislas Rolland <typo3(arobas)sjbr.ca>
9 * This script is part of the TYPO3 project. The TYPO3 project is
10 * free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * The GNU General Public License can be found at
16 * http://www.gnu.org/copyleft/gpl.html.
17 * A copy is found in the textfile GPL.txt and important notices to the license
18 * from the author is found in LICENSE.txt distributed with these scripts.
21 * This script is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
26 * This copyright notice MUST APPEAR in all copies of the script!
27 ***************************************************************/
29 * Displays the page/file tree for browsing database records or files.
30 * Used from TCEFORMS an other elements
31 * In other words: This is the ELEMENT BROWSER!
33 * Adapted for htmlArea RTE by Stanislas Rolland
37 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
38 * @author Stanislas Rolland <typo3(arobas)sjbr.ca>
41 require_once (PATH_typo3
.'class.browse_links.php');
45 * Class which generates the page tree
47 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
51 class tx_rtehtmlarea_pageTree
extends rtePageTree
{
54 * Create the page navigation tree in HTML
56 * @param array Tree array
57 * @return string HTML output.
59 function printTree($treeArr='') {
61 $titleLen=intval($GLOBALS['BE_USER']->uc
['titleLen']);
62 if (!is_array($treeArr)) $treeArr=$this->tree
;
67 foreach($treeArr as $k => $v) {
69 $bgColorClass = ($c+
1)%2 ?
'bgColor' : 'bgColor-10';
70 if ($GLOBALS['SOBE']->browser
->curUrlInfo
['act']=='page' && $GLOBALS['SOBE']->browser
->curUrlInfo
['pageid']==$v['row']['uid'] && $GLOBALS['SOBE']->browser
->curUrlInfo
['pageid']) {
71 $arrCol='<td><img'.t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/blinkarrow_right.gif','width="5" height="9"').' class="c-blinkArrowR" alt="" /></td>';
72 $bgColorClass='bgColor4';
77 $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'].'\');';
78 $cEbullet = $this->ext_isLinkable($v['row']['doktype'],$v['row']['uid']) ?
79 '<a href="#" onclick="'.htmlspecialchars($aOnClick).'"><img'.t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/ol/arrowbullet.gif','width="18" height="16"').' alt="" /></a>' :
82 <tr class="'.$bgColorClass.'">
83 <td nowrap="nowrap"'.($v['row']['_CSSCLASS'] ?
' class="'.$v['row']['_CSSCLASS'].'"' : '').'>'.
85 $this->wrapTitle($this->getTitleStr($v['row'],$titleLen),$v['row'],$this->ext_pArrPages
).
88 '<td>'.$cEbullet.'</td>
97 <table border="0" cellpadding="0" cellspacing="0" id="typo3-tree">
105 * Base extension class which generates the folder tree.
106 * Used directly by the RTE.
108 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
112 class tx_rtehtmlarea_folderTree
extends rteFolderTree
{
115 * Wrapping the title in a link, if applicable.
117 * @param string Title, ready for output.
118 * @param array The "record"
119 * @return string Wrapping title string.
121 function wrapTitle($title,$v) {
122 if ($this->ext_isLinkable($v)) {
123 $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']).'\');';
124 return '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$title.'</a>';
126 return '<span class="typo3-dimmed">'.$title.'</span>';
131 * Create the folder navigation tree in HTML
133 * @param mixed Input tree array. If not array, then $this->tree is used.
134 * @return string HTML output of the tree.
136 function printTree($treeArr='') {
138 $titleLen=intval($GLOBALS['BE_USER']->uc
['titleLen']);
140 if (!is_array($treeArr)) $treeArr=$this->tree
;
145 // Preparing the current-path string (if found in the listing we will see a red blinking arrow).
146 if (!$GLOBALS['SOBE']->browser
->curUrlInfo
['value']) {
148 } else if (substr(trim($GLOBALS['SOBE']->browser
->curUrlInfo
['info']),-1)!='/') {
149 $cmpPath=PATH_site
.dirname($GLOBALS['SOBE']->browser
->curUrlInfo
['info']).'/';
151 $cmpPath=PATH_site
.$GLOBALS['SOBE']->browser
->curUrlInfo
['info'];
154 // Traverse rows for the tree and print them into table rows:
155 foreach($treeArr as $k => $v) {
157 $bgColorClass=($c+
1)%2 ?
'bgColor' : 'bgColor-10';
159 // Creating blinking arrow, if applicable:
160 if ($GLOBALS['SOBE']->browser
->curUrlInfo
['act']=='file' && $cmpPath==$v['row']['path']) {
161 $arrCol='<td><img'.t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/blinkarrow_right.gif','width="5" height="9"').' class="c-blinkArrowR" alt="" /></td>';
162 $bgColorClass='bgColor4';
166 // Create arrow-bullet for file listing (if folder path is linkable):
167 $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']).'\');';
168 $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>' : '';
170 // Put table row with folder together:
172 <tr class="'.$bgColorClass.'">
173 <td nowrap="nowrap">'.$v['HTML'].$this->wrapTitle(t3lib_div
::fixed_lgd_cs($v['row']['title'],$titleLen),$v['row']).'</td>
175 <td>'.$cEbullet.'</td>
184 <table border="0" cellpadding="0" cellspacing="0" id="typo3-tree">
193 * Script class for the Element Browser window.
195 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
199 class tx_rtehtmlarea_browse_links
extends browse_links
{
202 var $contentTypo3Language;
203 var $contentTypo3Charset;
204 public $additionalAttributes = array();
205 public $buttonConfig = array();
206 public $RTEProperties = array();
208 public $anchorTypes = array( 'page', 'url', 'file', 'mail', 'spec');
209 public $classesAnchorDefault = array();
210 public $classesAnchorDefaultTitle = array();
211 public $classesAnchorClassTitle = array();
212 public $classesAnchorDefaultTarget = array();
213 public $classesAnchorJSOptions = array();
215 public $allowedItems;
219 * Initializes a lot of variables, setting JavaScript functions in header etc.
225 $this->initVariables();
226 $this->initConfiguration();
228 // Creating backend template object:
229 $this->doc
= t3lib_div
::makeInstance('template');
230 $this->doc
->backPath
= $GLOBALS['BACK_PATH'];
231 // Loading the Prototype library and browse_links.js
232 $this->doc
->getPageRenderer()->loadPrototype();
233 $this->doc
->loadJavascriptLib('js/browse_links.js');
234 // Adding context menu code
235 $this->doc
->getContextMenuCode();
236 // Init fileProcessor
237 $this->fileProcessor
= t3lib_div
::makeInstance('t3lib_basicFileFunctions');
238 $this->fileProcessor
->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
240 // Initializing hooking browsers
241 $this->initHookObjects('ext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php');
243 // CurrentUrl - the current link url must be passed around if it exists
244 $this->curUrlArray
= t3lib_div
::_GP('curUrl');
245 if ($this->curUrlArray
['all']) {
246 $this->curUrlArray
=t3lib_div
::get_tag_attributes($this->curUrlArray
['all']);
248 // Note: parseCurUrl will invoke the hooks
249 $this->curUrlInfo
= $this->parseCurUrl($this->curUrlArray
['href'],$this->siteURL
);
250 // Determine nature of current url:
251 $this->act
= t3lib_div
::_GP('act');
253 $this->act
=$this->curUrlInfo
['act'];
255 // Setting intial values for link attributes
256 $this->initLinkAttributes();
258 // Add attributes to body tag. Note: getBodyTagAdditions will invoke the hooks
259 $this->doc
->bodyTagAdditions
= $this->getBodyTagAdditions();
260 // Adding RTE JS code
261 $this->doc
->JScodeArray
['rtehtmlarea'] = $this->getJSCode();
265 * Initialize class variables
269 public function initVariables() {
272 $this->bparams
= t3lib_div
::_GP('bparams');
273 $pArr = explode('|', $this->bparams
);
274 $pRteArr = explode(':', $pArr[1]);
275 $this->editorNo
= $pRteArr[0];
276 $this->contentTypo3Language
= $pRteArr[1];
277 $this->contentTypo3Charset
= $pRteArr[2];
278 $this->RTEtsConfigParams
= $pArr[2];
279 if (!$this->editorNo
) {
280 $this->editorNo
= t3lib_div
::_GP('editorNo');
281 $this->contentTypo3Language
= t3lib_div
::_GP('contentTypo3Language');
282 $this->contentTypo3Charset
= t3lib_div
::_GP('contentTypo3Charset');
283 $this->RTEtsConfigParams
= t3lib_div
::_GP('RTEtsConfigParams');
285 $this->pointer
= t3lib_div
::_GP('pointer');
286 $this->expandPage
= t3lib_div
::_GP('expandPage');
287 $this->expandFolder
= t3lib_div
::_GP('expandFolder');
288 $this->P
= t3lib_div
::_GP('P');
289 $this->PM
= t3lib_div
::_GP('PM');
290 $pArr[1] = implode(':', array($this->editorNo
, $this->contentTypo3Language
, $this->contentTypo3Charset
));
291 $pArr[2] = $this->RTEtsConfigParams
;
292 $this->bparams
= implode('|', $pArr);
295 $this->mode
= t3lib_div
::_GP('mode');
300 $this->siteURL
= t3lib_div
::getIndpEnv('TYPO3_SITE_URL');
302 // the script to link to
303 $this->thisScript
= t3lib_div
::getIndpEnv('SCRIPT_NAME');
307 * Initializes the configuration variables
311 public function initConfiguration() {
312 $this->thisConfig
= $this->getRTEConfig();
313 $this->buttonConfig
= $this->getButtonConfig('link');
317 * Get the RTE configuration from Page TSConfig
319 * @return array RTE configuration array
321 protected function getRTEConfig() {
324 $RTEtsConfigParts = explode(':', $this->RTEtsConfigParams
);
325 $RTEsetup = $BE_USER->getTSConfig('RTE',t3lib_BEfunc
::getPagesTSconfig($RTEtsConfigParts[5]));
326 $this->RTEProperties
= $RTEsetup['properties'];
327 return t3lib_BEfunc
::RTEsetup($this->RTEProperties
, $RTEtsConfigParts[0],$RTEtsConfigParts[2],$RTEtsConfigParts[4]);
331 * Get the configuration of the button
333 * @param string $buttonName: the name of the button
334 * @return array the configuration array of the image button
336 protected function getButtonConfig($buttonName) {
337 return ((is_array($this->thisConfig
['buttons.']) && is_array($this->thisConfig
['buttons.'][$buttonName.'.'])) ?
$this->thisConfig
['buttons.'][$buttonName.'.'] : array());
341 * Initialize hook objects implementing interface t3lib_browseLinksHook
342 * @param string $hookKey: the hook key
345 protected function initHookObjects($hookKey) {
346 global $TYPO3_CONF_VARS;
347 if (is_array($TYPO3_CONF_VARS['SC_OPTIONS'][$hookKey]['browseLinksHook'])) {
348 foreach ($TYPO3_CONF_VARS['SC_OPTIONS'][$hookKey]['browseLinksHook'] as $classData) {
349 $processObject = t3lib_div
::getUserObj($classData);
350 if(!($processObject instanceof t3lib_browseLinksHook
)) {
351 throw new UnexpectedValueException('$processObject must implement interface t3lib_browseLinksHook', 1195115652);
353 $parameters = array();
354 $processObject->init($this, $parameters);
355 $this->hookObjects
[] = $processObject;
361 * Initialize the current or default values of the link attributes
365 protected function initLinkAttributes() {
367 // Initializing the title value
368 $this->setTitle
= $GLOBALS['LANG']->csConvObj
->conv($this->curUrlArray
['title'], 'utf-8', $GLOBALS['LANG']->charSet
);
370 // Processing the classes configuration
371 $classSelected = array();
372 if ($this->thisConfig
['classesAnchor'] ||
$this->thisConfig
['classesLinks']) {
373 $this->setClass
= $this->curUrlArray
['class'];
374 if ($this->thisConfig
['classesAnchor']) {
375 $classesAnchorArray = t3lib_div
::trimExplode(',',$this->thisConfig
['classesAnchor'], 1);
377 $classesAnchorArray = t3lib_div
::trimExplode(',',$this->thisConfig
['classesLinks'], 1);
379 // Collecting allowed classes and configured default values
380 $classesAnchor = array();
381 $classesAnchor['all'] = array();
382 $titleReadOnly = $this->buttonConfig
['properties.']['title.']['readOnly'] ||
$this->buttonConfig
[$this->act
.'.']['properties.']['title.']['readOnly'];
383 if (is_array($this->RTEProperties
['classesAnchor.'])) {
384 foreach ($this->RTEProperties
['classesAnchor.'] as $label => $conf) {
385 if (in_array($conf['class'], $classesAnchorArray)) {
386 $classesAnchor['all'][] = $conf['class'];
387 if (in_array($conf['type'], $this->anchorTypes
)) {
388 $classesAnchor[$conf['type']][] = $conf['class'];
389 if (is_array($this->thisConfig
['classesAnchor.']) && is_array($this->thisConfig
['classesAnchor.']['default.']) && $this->thisConfig
['classesAnchor.']['default.'][$conf['type']] == $conf['class']) {
390 $this->classesAnchorDefault
[$conf['type']] = $conf['class'];
391 if ($conf['titleText']) {
392 $this->classesAnchorDefaultTitle
[$conf['type']] = $this->getLLContent(trim($conf['titleText']));
394 if ($conf['target']) {
395 $this->classesAnchorDefaultTarget
[$conf['type']] = trim($conf['target']);
399 if ($titleReadOnly && $conf['titleText']) {
400 $this->classesAnchorClassTitle
[$conf['class']] = $this->classesAnchorDefaultTitle
[$conf['type']] = $this->getLLContent(trim($conf['titleText']));
405 // Constructing the class selector options
406 foreach ($this->anchorTypes
as $anchorType) {
407 foreach ($classesAnchorArray as $class) {
408 if (!in_array($class, $classesAnchor['all']) ||
(in_array($class, $classesAnchor['all']) && is_array($classesAnchor[$anchorType]) && in_array($class, $classesAnchor[$anchorType]))) {
410 if ($this->setClass
== $class ||
(!$this->setClass
&& $this->classesAnchorDefault
[$anchorType] == $class)) {
411 $selected = 'selected="selected"';
412 $classSelected[$anchorType] = true;
414 $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;
415 $classStyle = (is_array($this->RTEProperties
['classes.']) && is_array($this->RTEProperties
['classes.'][$class.'.']) && $this->RTEProperties
['classes.'][$class.'.']['value']) ?
$this->RTEProperties
['classes.'][$class.'.']['value'] : '';
416 $this->classesAnchorJSOptions
[$anchorType] .= '<option ' . $selected . ' value="' .$class . '"' . ($classStyle?
' style="'.$classStyle.'"':'') . '>' . $classLabel . '</option>';
419 if ($this->classesAnchorJSOptions
[$anchorType] && !($this->buttonConfig
['properties.']['class.']['required'] ||
$this->buttonConfig
[$this->act
.'.']['properties.']['class.']['required'])) {
421 if (!$this->setClass
&& !$this->classesAnchorDefault
[$anchorType]) $selected = 'selected="selected"';
422 $this->classesAnchorJSOptions
[$anchorType] = '<option ' . $selected . ' value=""></option>' . $this->classesAnchorJSOptions
[$anchorType];
426 // Initializing the target value
427 // 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
428 // In other words, do not forward the target if we changed tab and the target field is not displayed
429 $this->setTarget
= (isset($this->curUrlArray
['target'])
431 ($this->curUrlArray
['target'] != $this->thisConfig
['defaultLinkTarget'])
432 && !$classSelected[$this->act
]
433 && is_array($this->buttonConfig
['targetSelector.']) && $this->buttonConfig
['targetSelector.']['disabled'] && is_array($this->buttonConfig
['popupSelector.']) && $this->buttonConfig
['popupSelector.']['disabled'])
434 ) ?
$this->curUrlArray
['target'] : '';
435 if ($this->thisConfig
['defaultLinkTarget'] && !isset($this->curUrlArray
['target'])) {
436 $this->setTarget
=$this->thisConfig
['defaultLinkTarget'];
438 // Initializing additional attributes
439 if ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['rtehtmlarea']['plugins']['TYPO3Link']['additionalAttributes']) {
440 $addAttributes = t3lib_div
::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['rtehtmlarea']['plugins']['TYPO3Link']['additionalAttributes'], 1);
441 foreach ($addAttributes as $attribute) {
442 $this->additionalAttributes
[$attribute] = isset($this->curUrlArray
[$attribute]) ?
$this->curUrlArray
[$attribute] : '';
448 * Provide the additional parameters to be included in the template body tag
450 * @return string the body tag additions
452 public function getBodyTagAdditions() {
453 $bodyTagAdditions = array();
454 // call hook for extra additions
455 foreach ($this->hookObjects
as $hookObject) {
456 if (method_exists($hookObject, 'addBodyTagAdditions')) {
457 $bodyTagAdditions = $hookObject->addBodyTagAdditions($bodyTagAdditions);
460 return t3lib_div
::implodeAttributes($bodyTagAdditions, TRUE);
464 * Generate JS code to be used on the link insert/modify dialogue
466 * @return string the generated JS code
468 function getJSCode() {
470 // BEGIN accumulation of header JavaScript:
473 var plugin = window.parent.RTEarea["' . $this->editorNo
. '"].editor.getPlugin("TYPO3Link");
474 var HTMLArea = window.parent.HTMLArea;
475 var add_href="'.($this->curUrlArray
['href']?
'&curUrl[href]='.rawurlencode($this->curUrlArray
['href']):'').'";
476 var add_target="'.($this->setTarget?
'&curUrl[target]='.rawurlencode($this->setTarget
):'').'";
477 var add_class="'.($this->setClass?
'&curUrl[class]='.rawurlencode($this->setClass
):'').'";
478 var add_title="'.($this->setTitle?
'&curUrl[title]='.rawurlencode($this->setTitle
):'').'";
479 var add_params="'.($this->bparams?
'&bparams='.rawurlencode($this->bparams
):'').'";
480 var additionalValues = ' . (count($this->additionalAttributes
) ?
json_encode($this->additionalAttributes
) : '{}') . ';';
482 // Attributes setting functions
484 var cur_href="'.($this->curUrlArray
['href'] ?
($this->curUrlInfo
['query'] ?
substr($this->curUrlArray
['href'], 0, -strlen($this->curUrlInfo
['query'])) :$this->curUrlArray
['href']):'').'";
485 var cur_target="'.($this->setTarget?
$this->setTarget
:'').'";
486 var cur_class="'.($this->setClass?
$this->setClass
:'').'";
487 var cur_title="'.($this->setTitle?
$this->setTitle
:'').'";
489 function browse_links_setTarget(value) {
491 add_target="&curUrl[target]="+encodeURIComponent(value);
493 function browse_links_setClass(value) {
495 add_class="&curUrl[class]="+encodeURIComponent(value);
497 function browse_links_setTitle(value) {
499 add_title="&curUrl[title]="+encodeURIComponent(value);
501 function browse_links_setHref(value) {
503 add_href="&curUrl[href]="+value;
505 function browse_links_setAdditionalValue(name, value) {
506 additionalValues[name] = value;
509 // Link setting functions
511 function link_typo3Page(id,anchor) {
512 var parameters = (document.ltargetform.query_parameters && document.ltargetform.query_parameters.value) ? (document.ltargetform.query_parameters.value.charAt(0) == "&" ? "" : "&") + document.ltargetform.query_parameters.value : "";
513 var theLink = \'' . $this->siteURL
. '?id=\' + id + parameters + (anchor ? anchor : "");
514 if (document.ltargetform.anchor_title) browse_links_setTitle(document.ltargetform.anchor_title.value);
515 if (document.ltargetform.anchor_class) browse_links_setClass(document.ltargetform.anchor_class.value);
516 if (document.ltargetform.ltarget) browse_links_setTarget(document.ltargetform.ltarget.value);
517 if (document.ltargetform.lrel) browse_links_setAdditionalValue("rel", document.ltargetform.lrel.value);
518 plugin.createLink(theLink,cur_target,cur_class,cur_title,additionalValues);
521 function link_folder(folder) {
522 var theLink = \''.$this->siteURL
.'\'+folder;
523 if (document.ltargetform.anchor_title) browse_links_setTitle(document.ltargetform.anchor_title.value);
524 if (document.ltargetform.anchor_class) browse_links_setClass(document.ltargetform.anchor_class.value);
525 if (document.ltargetform.ltarget) browse_links_setTarget(document.ltargetform.ltarget.value);
526 if (document.ltargetform.lrel) browse_links_setAdditionalValue("rel", document.ltargetform.lrel.value);
527 plugin.createLink(theLink,cur_target,cur_class,cur_title,additionalValues);
530 function link_spec(theLink) {
531 if (document.ltargetform.anchor_title) browse_links_setTitle(document.ltargetform.anchor_title.value);
532 if (document.ltargetform.anchor_class) browse_links_setClass(document.ltargetform.anchor_class.value);
533 if (document.ltargetform.ltarget) browse_links_setTarget(document.ltargetform.ltarget.value);
534 plugin.createLink(theLink,cur_target,cur_class,cur_title,additionalValues);
537 function link_current() {
538 var parameters = (document.ltargetform.query_parameters && document.ltargetform.query_parameters.value) ? (document.ltargetform.query_parameters.value.charAt(0) == "&" ? "" : "&") + document.ltargetform.query_parameters.value : "";
539 if (document.ltargetform.anchor_title) browse_links_setTitle(document.ltargetform.anchor_title.value);
540 if (document.ltargetform.anchor_class) browse_links_setClass(document.ltargetform.anchor_class.value);
541 if (document.ltargetform.ltarget) browse_links_setTarget(document.ltargetform.ltarget.value);
542 if (document.ltargetform.lrel) browse_links_setAdditionalValue("rel", document.ltargetform.lrel.value);
543 if (cur_href!="http://" && cur_href!="mailto:") {
544 plugin.createLink(cur_href + parameters,cur_target,cur_class,cur_title,additionalValues);
549 // General "jumpToUrl" and launchView functions:
551 function jumpToUrl(URL,anchor) {
552 var add_editorNo = URL.indexOf("editorNo=")==-1 ? "&editorNo='.$this->editorNo
.'" : "";
553 var add_contentTypo3Language = URL.indexOf("contentTypo3Language=")==-1 ? "&contentTypo3Language='.$this->contentTypo3Language
.'" : "";
554 var add_contentTypo3Charset = URL.indexOf("contentTypo3Charset=")==-1 ? "&contentTypo3Charset='.$this->contentTypo3Charset
.'" : "";
555 var add_act = URL.indexOf("act=")==-1 ? "&act='.$this->act
.'" : "";
556 var add_mode = URL.indexOf("mode=")==-1 ? "&mode='.$this->mode
.'" : "";
557 var add_additionalValues = "";
558 if (plugin.pageTSConfiguration && plugin.pageTSConfiguration.additionalAttributes) {
559 var additionalAttributes = plugin.pageTSConfiguration.additionalAttributes.split(",");
560 for (var i = additionalAttributes.length; --i >= 0;) {
561 if (additionalValues[additionalAttributes[i]] != "") {
562 add_additionalValues += "&curUrl[" + additionalAttributes[i] + "]=" + encodeURIComponent(additionalValues[additionalAttributes[i]]);
566 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:"");
567 window.location.href = theLocation;
570 function launchView(url) {
571 var thePreviewWindow="";
572 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");
573 if (thePreviewWindow && thePreviewWindow.focus) {
574 thePreviewWindow.focus();
581 /******************************************************************
585 ******************************************************************/
587 * Rich Text Editor (RTE) link selector (MAIN function)
588 * Generates the link selector for the Rich Text Editor.
589 * Can also be used to select links for the TCEforms (see $wiz)
591 * @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
592 * @return string Modified content variable.
594 function main_rte($wiz=0) {
595 global $LANG, $BE_USER, $BACK_PATH;
598 $content=$this->doc
->startPage($LANG->getLL('Insert/Modify Link',1));
600 // Initializing the action value, possibly removing blinded values etc:
601 $this->allowedItems
= explode(',','page,file,url,mail,spec');
603 // Calling hook for extra options
604 foreach($this->hookObjects
as $hookObject) {
605 $this->allowedItems
= $hookObject->addAllowedItems($this->allowedItems
);
608 if (is_array($this->buttonConfig
['options.']) && $this->buttonConfig
['options.']['removeItems']) {
609 $this->allowedItems
= array_diff($this->allowedItems
,t3lib_div
::trimExplode(',',$this->buttonConfig
['options.']['removeItems'],1));
611 $this->allowedItems
= array_diff($this->allowedItems
,t3lib_div
::trimExplode(',',$this->thisConfig
['blindLinkOptions'],1));
613 reset($this->allowedItems
);
614 if (!in_array($this->act
,$this->allowedItems
)) {
615 $this->act
= current($this->allowedItems
);
618 // Making menu in top:
620 if (!$wiz && $this->curUrlArray
['href']) {
621 $menuDef['removeLink']['isActive'] = $this->act
=='removeLink';
622 $menuDef['removeLink']['label'] = $LANG->getLL('removeLink',1);
623 $menuDef['removeLink']['url'] = '#';
624 $menuDef['removeLink']['addParams'] = 'onclick="plugin.unLink();return false;"';
626 if (in_array('page',$this->allowedItems
)) {
627 $menuDef['page']['isActive'] = $this->act
=='page';
628 $menuDef['page']['label'] = $LANG->getLL('page',1);
629 $menuDef['page']['url'] = '#';
630 $menuDef['page']['addParams'] = 'onclick="jumpToUrl(\''.htmlspecialchars('?act=page&mode='.$this->mode
.'&bparams='.$this->bparams
).'\');return false;"';
632 if (in_array('file',$this->allowedItems
)){
633 $menuDef['file']['isActive'] = $this->act
=='file';
634 $menuDef['file']['label'] = $LANG->getLL('file',1);
635 $menuDef['file']['url'] = '#';
636 $menuDef['file']['addParams'] = 'onclick="jumpToUrl(\''.htmlspecialchars('?act=file&mode='.$this->mode
.'&bparams='.$this->bparams
).'\');return false;"';
638 if (in_array('url',$this->allowedItems
)) {
639 $menuDef['url']['isActive'] = $this->act
=='url';
640 $menuDef['url']['label'] = $LANG->getLL('extUrl',1);
641 $menuDef['url']['url'] = '#';
642 $menuDef['url']['addParams'] = 'onclick="jumpToUrl(\''.htmlspecialchars('?act=url&mode='.$this->mode
.'&bparams='.$this->bparams
).'\');return false;"';
644 if (in_array('mail',$this->allowedItems
)) {
645 $menuDef['mail']['isActive'] = $this->act
=='mail';
646 $menuDef['mail']['label'] = $LANG->getLL('email',1);
647 $menuDef['mail']['url'] = '#';
648 $menuDef['mail']['addParams'] = 'onclick="jumpToUrl(\''.htmlspecialchars('?act=mail&mode='.$this->mode
.'&bparams='.$this->bparams
).'\');return false;"';
650 if (is_array($this->thisConfig
['userLinks.']) && in_array('spec',$this->allowedItems
)) {
651 $menuDef['spec']['isActive'] = $this->act
=='spec';
652 $menuDef['spec']['label'] = $LANG->getLL('special',1);
653 $menuDef['spec']['url'] = '#';
654 $menuDef['spec']['addParams'] = 'onclick="jumpToUrl(\''.htmlspecialchars('?act=spec&mode='.$this->mode
.'&bparams='.$this->bparams
).'\');return false;"';
657 // call hook for extra options
658 foreach($this->hookObjects
as $hookObject) {
659 $menuDef = $hookObject->modifyMenuDefinition($menuDef);
662 $content .= $this->doc
->getTabMenuRaw($menuDef);
664 // Adding the menu and header to the top of page:
665 $content.=$this->printCurrentUrl($this->curUrlInfo
['info']).'<br />';
667 // Depending on the current action we will create the actual module content for selecting a link:
674 <form action="" name="lurlform" id="lurlform">
675 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkMail">
677 <td>'.$LANG->getLL('emailAddress',1).':</td>
678 <td><input type="text" name="lemail"'.$this->doc
->formWidth(20).' value="'.htmlspecialchars($this->curUrlInfo
['act']=='mail'?
$this->curUrlInfo
['info']:'').'" /> '.
679 '<input type="submit" value="'.$LANG->getLL('setLink',1).'" onclick="browse_links_setTarget(\'\');browse_links_setHref(\'mailto:\'+document.lurlform.lemail.value); return link_current();" /></td>
684 $content.=$this->addAttributesForm();
691 <form action="" name="lurlform" id="lurlform">
692 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkURL">
695 <td><input type="text" name="lurl"'.$this->doc
->formWidth(20).' value="'.htmlspecialchars($this->curUrlInfo
['act']=='url'?
$this->curUrlInfo
['info']:'http://').'" /> '.
696 '<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); }; return link_current();" /></td>
701 $content.=$this->addAttributesForm();
704 $content.=$this->addAttributesForm();
706 $foldertree = t3lib_div
::makeInstance('tx_rtehtmlarea_folderTree');
707 $tree=$foldertree->getBrowsableTree();
709 if (!$this->curUrlInfo
['value'] ||
$this->curUrlInfo
['act']!='file') {
711 } elseif (substr(trim($this->curUrlInfo
['info']),-1)!='/') {
712 $cmpPath=PATH_site
.dirname($this->curUrlInfo
['info']).'/';
713 if (!isset($this->expandFolder
)) $this->expandFolder
= $cmpPath;
715 $cmpPath=PATH_site
.$this->curUrlInfo
['info'];
718 list(,,$specUid) = explode('_',$this->PM
);
719 $files = $this->expandFolder($foldertree->specUIDmap
[$specUid]);
721 // Create upload/create folder forms, if a path is given:
722 if ($BE_USER->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
723 $path=$this->expandFolder
;
724 if (!$path ||
!@is_dir
($path)) {
725 $path = $this->fileProcessor
->findTempFolder().'/'; // The closest TEMP-path is found
727 if ($path!='/' && @is_dir
($path)) {
728 $uploadForm=$this->uploadForm($path);
729 $createFolder=$this->createFolder($path);
734 $content.=$uploadForm;
735 if ($BE_USER->isAdmin() ||
$BE_USER->getTSConfigVal('options.createFoldersInEB')) {
736 $content.=$createFolder;
744 Wrapper table for folder tree / file list:
746 <table border="0" cellpadding="0" cellspacing="0" id="typo3-linkFiles">
748 <td class="c-wCell" valign="top">'.$this->barheader($LANG->getLL('folderTree').':').$tree.'</td>
749 <td class="c-wCell" valign="top">'.$files.'</td>
755 if (is_array($this->thisConfig
['userLinks.'])) {
757 $v=$this->thisConfig
['userLinks.'];
759 while(list($k2)=each($v)) {
761 if (substr($k2,-1)=='.' && is_array($v[$k2i.'.'])) {
764 $title = trim($v[$k2i]);
766 $title=$v[$k2i.'.']['url'];
768 $title=$LANG->sL($title);
771 $description=$v[$k2i.'.']['description'] ?
$LANG->sL($v[$k2i.'.']['description'],1).'<br />' : '';
773 // URL + onclick event:
775 if (isset($v[$k2i.'.']['target'])) $onClickEvent.="browse_links_setTarget('".$v[$k2i.'.']['target']."');";
776 $v[$k2i.'.']['url'] = str_replace('###_URL###',$this->siteURL
,$v[$k2i.'.']['url']);
777 if (substr($v[$k2i.'.']['url'],0,7)=="http://" ||
substr($v[$k2i.'.']['url'],0,7)=='mailto:') {
778 $onClickEvent.="cur_href=unescape('".rawurlencode($v[$k2i.'.']['url'])."');link_current();";
780 $onClickEvent.="link_spec(unescape('".$this->siteURL
.rawurlencode($v[$k2i.'.']['url'])."'));";
784 $A=array('<a href="#" onclick="'.htmlspecialchars($onClickEvent).'return false;">','</a>');
786 // Adding link to menu of user defined links:
789 <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>
797 // Add menu to content:
800 Special userdefined menu:
802 <table border="0" cellpadding="1" cellspacing="1" id="typo3-linkSpecial">
804 <td class="bgColor5" class="c-wCell" valign="top"><strong>'.$LANG->getLL('special',1).'</strong></td>
806 '.implode('',$subcats).'
812 $content.=$this->addAttributesForm();
814 $pagetree = t3lib_div
::makeInstance('tx_rtehtmlarea_pageTree');
815 $pagetree->ext_showNavTitle
= $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showNavTitle');
816 $pagetree->addField('nav_title');
817 $tree=$pagetree->getBrowsableTree();
818 $cElements = $this->expandPage();
821 Wrapper table for page tree / record list:
823 <table border="0" cellpadding="0" cellspacing="0" id="typo3-linkPages">
825 <td class="c-wCell" valign="top">'.$this->barheader($LANG->getLL('pageTree').':').$tree.'</td>
826 <td class="c-wCell" valign="top">'.$cElements.'</td>
833 foreach($this->hookObjects
as $hookObject) {
834 $content .= $hookObject->getTab($this->act
);
840 // End page, return content:
841 $content.= $this->doc
->endPage();
842 $content = $this->doc
->insertStylesAndJS($content);
846 function addAttributesForm() {
848 // Add page id, target, class selector box, title and parameters fields:
849 $lpageId = $this->addPageIdSelector();
850 $queryParameters = $this->addQueryParametersSelector();
851 $ltarget = $this->addTargetSelector();
852 $lclass = $this->addClassSelector();
853 $ltitle = $this->addTitleSelector();
854 $rel = $this->addRelField();
855 if ($lpageId ||
$queryParameters ||
$ltarget ||
$lclass ||
$ltitle ||
$rel) {
856 $ltargetForm = $this->wrapInForm($lpageId.$queryParameters.$ltarget.$lclass.$ltitle.$rel);
861 function wrapInForm($string) {
866 Selecting target for link:
868 <form action="" name="ltargetform" id="ltargetform">
869 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkTarget">'. $string;
870 if ($this->act
== $this->curUrlInfo
['act'] && $this->act
!= 'mail' && $this->curUrlArray
['href']) {
876 <input type="submit" value="'.$LANG->getLL('update',1).'" onclick="return link_current();" />
886 function addPageIdSelector() {
889 return ($this->act
== 'page' && $this->buttonConfig
&& is_array($this->buttonConfig
['pageIdSelector.']) && $this->buttonConfig
['pageIdSelector.']['enabled'])?
'
891 <td>'.$LANG->getLL('page_id',1).':</td>
893 <input type="text" size="6" name="luid" /> <input type="submit" value="'.$LANG->getLL('setLink',1).'" onclick="return link_typo3Page(document.ltargetform.luid.value);" />
898 function addRelField() {
899 return (($this->act
== 'page' ||
$this->act
== 'url' ||
$this->act
== 'file') && $this->buttonConfig
&& is_array($this->buttonConfig
['relAttribute.']) && $this->buttonConfig
['relAttribute.']['enabled'])?
'
901 <td>'.$GLOBALS['LANG']->getLL('linkRelationship',1).':</td>
903 <input type="text" name="lrel" value="' . $this->additionalAttributes
['rel']. '" ' . $this->doc
->formWidth(30) . ' />
908 function addQueryParametersSelector() {
911 return ($this->act
== 'page' && $this->buttonConfig
&& is_array($this->buttonConfig
['queryParametersSelector.']) && $this->buttonConfig
['queryParametersSelector.']['enabled'])?
'
913 <td>'.$LANG->getLL('query_parameters',1).':</td>
915 <input type="text" name="query_parameters" value="' . ($this->curUrlInfo
['query']?
$this->curUrlInfo
['query']:'') . '" ' . $this->doc
->formWidth(30) . ' />
920 function addTargetSelector() {
923 $targetSelectorConfig = array();
924 $popupSelectorConfig = array();
925 if (is_array($this->buttonConfig
['targetSelector.'])) {
926 $targetSelectorConfig = $this->buttonConfig
['targetSelector.'];
928 if (is_array($this->buttonConfig
['popupSelector.'])) {
929 $popupSelectorConfig = $this->buttonConfig
['popupSelector.'];
933 if ($this->act
!= 'mail') {
935 <tr id="ltargetrow"'. (($targetSelectorConfig['disabled'] && $popupSelectorConfig['disabled']) ?
' style="display: none;"' : '') . '>
936 <td>'.$LANG->getLL('target',1).':</td>
937 <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>';
940 if (!$targetSelectorConfig['disabled']) {
942 <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;">
944 <option value="_top">'.$LANG->getLL('top',1).'</option>
945 <option value="_blank">'.$LANG->getLL('newWindow',1).'</option>
951 if (!$popupSelectorConfig['disabled']) {
953 $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) {
954 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;
955 browse_links_setTarget(document.ltargetform.ltarget.value);
956 document.ltargetform.popup_width.selectedIndex=0;
957 document.ltargetform.popup_height.selectedIndex=0;
962 <td>'.$LANG->getLL('target_popUpWindow',1).':</td>
964 <select name="popup_width" onchange="'.$selectJS.'">
965 <option value="0">'.$LANG->getLL('target_popUpWindow_width',1).'</option>
966 <option value="300">300</option>
967 <option value="400">400</option>
968 <option value="500">500</option>
969 <option value="600">600</option>
970 <option value="700">700</option>
971 <option value="800">800</option>
974 <select name="popup_height" onchange="'.$selectJS.'">
975 <option value="0">'.$LANG->getLL('target_popUpWindow_height',1).'</option>
976 <option value="200">200</option>
977 <option value="300">300</option>
978 <option value="400">400</option>
979 <option value="500">500</option>
980 <option value="600">600</option>
990 * Return html code for the class selector
992 * @return string the html code to be added to the form
994 public function addClassSelector() {
996 if ($this->classesAnchorJSOptions
[$this->act
]) {
999 <td>'.$GLOBALS['LANG']->getLL('anchor_class',1).':</td>
1001 <select name="anchor_class" onchange="'.$this->getClassOnChangeJS().'">
1002 ' . $this->classesAnchorJSOptions
[$this->act
] . '
1007 return $selectClass;
1011 * Return JS code for the class selector onChange event
1013 * @return string class selector onChange JS code
1015 public function getClassOnChangeJS() {
1017 if (document.ltargetform.anchor_class) {
1018 document.ltargetform.anchor_class.value = document.ltargetform.anchor_class.options[document.ltargetform.anchor_class.selectedIndex].value;
1019 if (document.ltargetform.anchor_class.value && HTMLArea.classesAnchorSetup) {
1020 for (var i = HTMLArea.classesAnchorSetup.length; --i >= 0;) {
1021 var anchorClass = HTMLArea.classesAnchorSetup[i];
1022 if (anchorClass[\'name\'] == document.ltargetform.anchor_class.value) {
1023 if (anchorClass[\'titleText\'] && document.ltargetform.anchor_title) {
1024 document.ltargetform.anchor_title.value = anchorClass[\'titleText\'];
1025 document.getElementById(\'rtehtmlarea-browse-links-title-readonly\').innerHTML = anchorClass[\'titleText\'];
1026 browse_links_setTitle(anchorClass[\'titleText\']);
1028 if (anchorClass[\'target\']) {
1029 if (document.ltargetform.ltarget) {
1030 document.ltargetform.ltarget.value = anchorClass[\'target\'];
1032 browse_links_setTarget(anchorClass[\'target\']);
1033 } else if (document.ltargetform.ltarget && document.getElementById(\'ltargetrow\').style.display == \'none\') {
1034 // Reset target to default if field is not displayed and class has no configured target
1035 document.ltargetform.ltarget.value = \''. ($this->thisConfig
['defaultLinkTarget']?
$this->thisConfig
['defaultLinkTarget']:'') .'\';
1036 browse_links_setTarget(document.ltargetform.ltarget.value);
1042 browse_links_setClass(document.ltargetform.anchor_class.value);
1047 function addTitleSelector() {
1048 $title = ($this->setTitle ?
$this->setTitle
: (($this->setClass ||
!$this->classesAnchorDefault
[$this->act
]) ?
'' : $this->classesAnchorDefaultTitle
[$this->act
]));
1049 $readOnly = $this->buttonConfig
['properties.']['title.']['readOnly'] ||
$this->buttonConfig
[$this->act
.'.']['properties.']['title.']['readOnly'];
1051 $title = $this->setClass ?
$this->classesAnchorClassTitle
[$this->setClass
] : $this->classesAnchorDefaultTitle
[$this->act
];
1055 <td><label for="rtehtmlarea-browse-links-anchor_title" id="rtehtmlarea-browse-links-title-label">' . $GLOBALS['LANG']->getLL('anchor_title',1) . ':</label></td>
1057 <span id="rtehtmlarea-browse-links-title-input" style="display: ' . ($readOnly ?
'none' : 'inline') . ';">
1058 <input type="text" id="rtehtmlarea-browse-links-anchor_title" name="anchor_title" value="' . $title . '" ' . $this->doc
->formWidth(30) . ' />
1060 <span id="rtehtmlarea-browse-links-title-readonly" style="display: ' . ($readOnly ?
'inline' : 'none') . ';">' . $title . '</span>
1066 * Localize a string using the language of the content element rather than the language of the BE interface
1068 * @param string string: the label to be localized
1069 * @return string Localized string.
1071 public function getLLContent($string) {
1074 $BE_lang = $LANG->lang
;
1075 $BE_origCharSet = $LANG->origCharSet
;
1076 $BE_charSet = $LANG->charSet
;
1078 $LANG->lang
= $this->contentTypo3Language
;
1079 $LANG->origCharSet
= $LANG->csConvObj
->charSetArray
[$this->contentTypo3Language
];
1080 $LANG->origCharSet
= $LANG->origCharSet ?
$LANG->origCharSet
: 'iso-8859-1';
1081 $LANG->charSet
= $this->contentTypo3Charset
;
1082 $LLString = $LANG->sL($string);
1084 $LANG->lang
= $BE_lang;
1085 $LANG->origCharSet
= $BE_origCharSet;
1086 $LANG->charSet
= $BE_charSet;
1091 * Localize a label obtained from Page TSConfig
1093 * @param string string: the label to be localized
1094 * @return string Localized string.
1096 public function getPageConfigLabel($string,$JScharCode=1) {
1098 if (strcmp(substr($string,0,4),'LLL:')) {
1101 $label = $LANG->sL(trim($string));
1103 $label = str_replace('"', '\"', str_replace('\\\'', '\'', $label));
1104 $label = $JScharCode ?
$LANG->JScharCode($label): $label;
1110 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['ext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php']) {
1111 include_once($TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['ext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php']);