Fixed bug #9255: External URLs cannot be set in RTEhtmlarea anymore
[Packages/TYPO3.CMS.git] / typo3 / sysext / rtehtmlarea / mod3 / class.tx_rtehtmlarea_browse_links.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2008 Kasper Skaarhoj (kasperYYYY@typo3.com)
6 * (c) 2005-2008 Stanislas Rolland <typo3(arobas)sjbr.ca>
7 * All rights reserved
8 *
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.
14 *
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.
19 *
20 *
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.
25 *
26 * This copyright notice MUST APPEAR in all copies of the script!
27 ***************************************************************/
28 /**
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!
32 *
33 * Adapted for htmlArea RTE by Stanislas Rolland
34 *
35 * $Id$
36 *
37 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
38 * @author Stanislas Rolland <typo3(arobas)sjbr.ca>
39 */
40
41 require_once (PATH_typo3.'class.browse_links.php');
42 require_once (PATH_t3lib.'class.t3lib_basicfilefunc.php');
43
44
45 /**
46 * Class which generates the page tree
47 *
48 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
49 * @package TYPO3
50 * @subpackage core
51 */
52 class tx_rtehtmlarea_pageTree extends rtePageTree {
53
54 /**
55 * Create the page navigation tree in HTML
56 *
57 * @param array Tree array
58 * @return string HTML output.
59 */
60 function printTree($treeArr='') {
61 global $BACK_PATH;
62 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
63 if (!is_array($treeArr)) $treeArr=$this->tree;
64
65 $out='';
66 $c=0;
67
68 foreach($treeArr as $k => $v) {
69 $c++;
70 $bgColorClass = ($c+1)%2 ? 'bgColor' : 'bgColor-10';
71 if ($GLOBALS['SOBE']->browser->curUrlInfo['act']=='page' && $GLOBALS['SOBE']->browser->curUrlInfo['pageid']==$v['row']['uid'] && $GLOBALS['SOBE']->browser->curUrlInfo['pageid']) {
72 $arrCol='<td><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/blinkarrow_right.gif','width="5" height="9"').' class="c-blinkArrowR" alt="" /></td>';
73 $bgColorClass='bgColor4';
74 } else {
75 $arrCol='<td></td>';
76 }
77
78 $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'].'\');';
79 $cEbullet = $this->ext_isLinkable($v['row']['doktype'],$v['row']['uid']) ?
80 '<a href="#" onclick="'.htmlspecialchars($aOnClick).'"><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/arrowbullet.gif','width="18" height="16"').' alt="" /></a>' :
81 '';
82 $out.='
83 <tr class="'.$bgColorClass.'">
84 <td nowrap="nowrap"'.($v['row']['_CSSCLASS'] ? ' class="'.$v['row']['_CSSCLASS'].'"' : '').'>'.
85 $v['HTML'].
86 $this->wrapTitle($this->getTitleStr($v['row'],$titleLen),$v['row'],$this->ext_pArrPages).
87 '</td>'.
88 $arrCol.
89 '<td>'.$cEbullet.'</td>
90 </tr>';
91 }
92 $out='
93
94
95 <!--
96 Navigation Page Tree:
97 -->
98 <table border="0" cellpadding="0" cellspacing="0" id="typo3-tree">
99 '.$out.'
100 </table>';
101 return $out;
102 }
103 }
104
105 /**
106 * Base extension class which generates the folder tree.
107 * Used directly by the RTE.
108 *
109 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
110 * @package TYPO3
111 * @subpackage core
112 */
113 class tx_rtehtmlarea_folderTree extends rteFolderTree {
114
115 /**
116 * Wrapping the title in a link, if applicable.
117 *
118 * @param string Title, ready for output.
119 * @param array The "record"
120 * @return string Wrapping title string.
121 */
122 function wrapTitle($title,$v) {
123 if ($this->ext_isLinkable($v)) {
124 $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']).'\');';
125 return '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$title.'</a>';
126 } else {
127 return '<span class="typo3-dimmed">'.$title.'</span>';
128 }
129 }
130
131 /**
132 * Create the folder navigation tree in HTML
133 *
134 * @param mixed Input tree array. If not array, then $this->tree is used.
135 * @return string HTML output of the tree.
136 */
137 function printTree($treeArr='') {
138 global $BACK_PATH;
139 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
140
141 if (!is_array($treeArr)) $treeArr=$this->tree;
142
143 $out='';
144 $c=0;
145
146 // Preparing the current-path string (if found in the listing we will see a red blinking arrow).
147 if (!$GLOBALS['SOBE']->browser->curUrlInfo['value']) {
148 $cmpPath='';
149 } else if (substr(trim($GLOBALS['SOBE']->browser->curUrlInfo['info']),-1)!='/') {
150 $cmpPath=PATH_site.dirname($GLOBALS['SOBE']->browser->curUrlInfo['info']).'/';
151 } else {
152 $cmpPath=PATH_site.$GLOBALS['SOBE']->browser->curUrlInfo['info'];
153 }
154
155 // Traverse rows for the tree and print them into table rows:
156 foreach($treeArr as $k => $v) {
157 $c++;
158 $bgColorClass=($c+1)%2 ? 'bgColor' : 'bgColor-10';
159
160 // Creating blinking arrow, if applicable:
161 if ($GLOBALS['SOBE']->browser->curUrlInfo['act']=='file' && $cmpPath==$v['row']['path']) {
162 $arrCol='<td><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/blinkarrow_right.gif','width="5" height="9"').' class="c-blinkArrowR" alt="" /></td>';
163 $bgColorClass='bgColor4';
164 } else {
165 $arrCol='<td></td>';
166 }
167 // Create arrow-bullet for file listing (if folder path is linkable):
168 $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']).'\');';
169 $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
171 // Put table row with folder together:
172 $out.='
173 <tr class="'.$bgColorClass.'">
174 <td nowrap="nowrap">'.$v['HTML'].$this->wrapTitle(t3lib_div::fixed_lgd_cs($v['row']['title'],$titleLen),$v['row']).'</td>
175 '.$arrCol.'
176 <td>'.$cEbullet.'</td>
177 </tr>';
178 }
179
180 $out='
181
182 <!--
183 Folder tree:
184 -->
185 <table border="0" cellpadding="0" cellspacing="0" id="typo3-tree">
186 '.$out.'
187 </table>';
188 return $out;
189 }
190
191 }
192
193 /**
194 * Script class for the Element Browser window.
195 *
196 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
197 * @package TYPO3
198 * @subpackage core
199 */
200 class tx_rtehtmlarea_browse_links extends browse_links {
201
202 var $editorNo;
203 var $contentTypo3Language;
204 var $contentTypo3Charset;
205 public $buttonConfig = array();
206 public $RTEProperties = array();
207
208 public $anchorTypes = array( 'page', 'url', 'file', 'mail', 'spec');
209 protected $classesAnchorDefault = array();
210 protected $classesAnchorDefaultTitle = array();
211 protected $classesAnchorDefaultTarget = array();
212 protected $classesAnchorJSOptions = array();
213
214 public $allowedItems;
215
216 /**
217 * Constructor:
218 * Initializes a lot of variables, setting JavaScript functions in header etc.
219 *
220 * @return void
221 */
222 function init() {
223 global $BACK_PATH,$LANG;
224
225 $this->initVariables();
226 $this->initConfiguration();
227 $this->initHookObjects('ext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php');
228
229 // CurrentUrl - the current link url must be passed around if it exists
230 $this->curUrlArray = t3lib_div::_GP('curUrl');
231 if ($this->curUrlArray['all']) {
232 $this->curUrlArray=t3lib_div::get_tag_attributes($this->curUrlArray['all']);
233 }
234 // Note: parseCurUrl will invoke the hooks
235 $this->curUrlInfo = $this->parseCurUrl($this->curUrlArray['href'],$this->siteURL);
236
237 // Determine nature of current url:
238 $this->act = t3lib_div::_GP('act');
239 if (!$this->act) {
240 $this->act=$this->curUrlInfo['act'];
241 }
242
243 // Initializing the title value
244 $this->setTitle = $LANG->csConvObj->conv($this->curUrlArray['title'], 'utf-8', $LANG->charSet);
245
246 // Rich Text Editor specific configuration:
247 $addPassOnParams='';
248 $classSelected = array();
249 $addPassOnParams .= '&RTEtsConfigParams='.rawurlencode($this->RTEtsConfigParams);
250 $addPassOnParams .= ($this->contentTypo3Language ? '&contentTypo3Language=' . rawurlencode($this->contentTypo3Language) : '');
251 $addPassOnParams .= ($this->contentTypo3Charset ? '&contentTypo3Charset=' . rawurlencode($this->contentTypo3Charset) : '');
252 if ($this->thisConfig['classesAnchor'] || $this->thisConfig['classesLinks']) {
253 $this->setClass = $this->curUrlArray['class'];
254 if ($this->thisConfig['classesAnchor']) {
255 $classesAnchorArray = t3lib_div::trimExplode(',',$this->thisConfig['classesAnchor'], 1);
256 } else {
257 $classesAnchorArray = t3lib_div::trimExplode(',',$this->thisConfig['classesLinks'], 1);
258 }
259 $classesAnchor = array();
260 $classesAnchor['all'] = array();
261 if (is_array($this->RTEProperties['classesAnchor.'])) {
262 reset($this->RTEProperties['classesAnchor.']);
263 while(list($label,$conf)=each($this->RTEProperties['classesAnchor.'])) {
264 if (in_array($conf['class'], $classesAnchorArray)) {
265 $classesAnchor['all'][] = $conf['class'];
266 if (in_array($conf['type'], $this->anchorTypes)) {
267 $classesAnchor[$conf['type']][] = $conf['class'];
268 if (is_array($this->thisConfig['classesAnchor.']) && is_array($this->thisConfig['classesAnchor.']['default.']) && $this->thisConfig['classesAnchor.']['default.'][$conf['type']] == $conf['class']) {
269 $this->classesAnchorDefault[$conf['type']] = $conf['class'];
270 if ($conf['titleText']) {
271 $this->classesAnchorDefaultTitle[$conf['type']] = $this->getLLContent(trim($conf['titleText']));
272 }
273 if ($conf['target']) {
274 $this->classesAnchorDefaultTarget[$conf['type']] = trim($conf['target']);
275 }
276 }
277 }
278 }
279 }
280 }
281 foreach ($this->anchorTypes as $anchorType) {
282 foreach ($classesAnchorArray as $class) {
283 if (!in_array($class, $classesAnchor['all']) || (in_array($class, $classesAnchor['all']) && is_array($classesAnchor[$anchorType]) && in_array($class, $classesAnchor[$anchorType]))) {
284 $selected = '';
285 if ($this->setClass == $class || (!$this->setClass && $this->classesAnchorDefault[$anchorType] == $class)) {
286 $selected = 'selected="selected"';
287 $classSelected[$anchorType] = true;
288 }
289 $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;
290 $classStyle = (is_array($this->RTEProperties['classes.']) && is_array($this->RTEProperties['classes.'][$class.'.']) && $this->RTEProperties['classes.'][$class.'.']['value']) ? $this->RTEProperties['classes.'][$class.'.']['value'] : '';
291 $this->classesAnchorJSOptions[$anchorType] .= '<option ' . $selected . ' value="' .$class . '"' . ($classStyle?' style="'.$classStyle.'"':'') . '>' . $classLabel . '</option>';
292 }
293 }
294 if ($this->classesAnchorJSOptions[$anchorType]) {
295 $selected = '';
296 if (!$this->setClass && !$this->classesAnchorDefault[$anchorType]) $selected = 'selected="selected"';
297 $this->classesAnchorJSOptions[$anchorType] = '<option ' . $selected . ' value=""></option>' . $this->classesAnchorJSOptions[$anchorType];
298 }
299 }
300 }
301
302 // Initializing the target value
303 // 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
304 // In other words, do not forward the target if we changed tab and the target field is not displayed
305 $this->setTarget = (isset($this->curUrlArray['target'])
306 && !(
307 ($this->curUrlArray['target'] != $this->thisConfig['defaultLinkTarget'])
308 && !$classSelected[$this->act]
309 && is_array($this->buttonConfig['targetSelector.']) && $this->buttonConfig['targetSelector.']['disabled'] && is_array($this->buttonConfig['popupSelector.']) && $this->buttonConfig['popupSelector.']['disabled'])
310 ) ? $this->curUrlArray['target'] : '';
311 if ($this->thisConfig['defaultLinkTarget'] && !isset($this->curUrlArray['target'])) {
312 $this->setTarget=$this->thisConfig['defaultLinkTarget'];
313 }
314
315 // Creating backend template object:
316 $this->doc = t3lib_div::makeInstance('template');
317 $this->doc->bodyTagAdditions = $this->getBodyTagAdditions();
318 $this->doc->backPath = $BACK_PATH;
319
320 // Load the Prototype library and browse_links.js
321 $this->doc->loadJavascriptLib('contrib/prototype/prototype.js');
322 $this->doc->loadJavascriptLib('js/browse_links.js');
323
324 $this->doc->getContextMenuCode();
325 }
326
327 /**
328 * Initialize class variables
329 *
330 * @return void
331 */
332 public function initVariables() {
333
334 // Process bparams
335 $this->bparams = t3lib_div::_GP('bparams');
336 $pArr = explode('|', $this->bparams);
337 $pRteArr = explode(':', $pArr[1]);
338 $this->editorNo = $pRteArr[0];
339 $this->contentTypo3Language = $pRteArr[1];
340 $this->contentTypo3Charset = $pRteArr[2];
341 $this->RTEtsConfigParams = $pArr[2];
342 if (!$this->editorNo) {
343 $this->editorNo = t3lib_div::_GP('editorNo');
344 $this->contentTypo3Language = t3lib_div::_GP('contentTypo3Language');
345 $this->contentTypo3Charset = t3lib_div::_GP('contentTypo3Charset');
346 $this->RTEtsConfigParams = t3lib_div::_GP('RTEtsConfigParams');
347 }
348 $this->pointer = t3lib_div::_GP('pointer');
349 $this->expandPage = t3lib_div::_GP('expandPage');
350 $this->expandFolder = t3lib_div::_GP('expandFolder');
351 $this->P = t3lib_div::_GP('P');
352 $this->PM = t3lib_div::_GP('PM');
353 $pArr[1] = implode(':', array($this->editorNo, $this->contentTypo3Language, $this->contentTypo3Charset));
354 $pArr[2] = $this->RTEtsConfigParams;
355 $this->bparams = implode('|', $pArr);
356
357 // Find "mode"
358 $this->mode = t3lib_div::_GP('mode');
359 if (!$this->mode) {
360 $this->mode = 'rte';
361 }
362 // Current site url
363 $this->siteURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL');
364
365 // the script to link to
366 $this->thisScript = t3lib_div::getIndpEnv('SCRIPT_NAME');
367 }
368
369 /**
370 * Initializes the configuration variables
371 *
372 * @return void
373 */
374 public function initConfiguration() {
375 $this->thisConfig = $this->getRTEConfig();
376 $this->buttonConfig = $this->getButtonConfig('link');
377 }
378
379 /**
380 * Get the RTE configuration from Page TSConfig
381 *
382 * @return array RTE configuration array
383 */
384 protected function getRTEConfig() {
385 global $BE_USER;
386
387 $RTEtsConfigParts = explode(':', $this->RTEtsConfigParams);
388 $RTEsetup = $BE_USER->getTSConfig('RTE',t3lib_BEfunc::getPagesTSconfig($RTEtsConfigParts[5]));
389 $this->RTEProperties = $RTEsetup['properties'];
390 return t3lib_BEfunc::RTEsetup($this->RTEProperties, $RTEtsConfigParts[0],$RTEtsConfigParts[2],$RTEtsConfigParts[4]);
391 }
392
393 /**
394 * Get the configuration of the button
395 *
396 * @param string $buttonName: the name of the button
397 * @return array the configuration array of the image button
398 */
399 protected function getButtonConfig($buttonName) {
400 return ((is_array($this->thisConfig['buttons.']) && is_array($this->thisConfig['buttons.'][$buttonName.'.'])) ? $this->thisConfig['buttons.'][$buttonName.'.'] : array());
401 }
402
403 /**
404 * Initialize hook objects implementing interface t3lib_browseLinksHook
405 * @param string $hookKey: the hook key
406 * @return void
407 */
408 protected function initHookObjects($hookKey) {
409 global $TYPO3_CONF_VARS;
410 if (is_array($TYPO3_CONF_VARS['SC_OPTIONS'][$hookKey]['browseLinksHook'])) {
411 foreach ($TYPO3_CONF_VARS['SC_OPTIONS'][$hookKey]['browseLinksHook'] as $classData) {
412 $processObject = &t3lib_div::getUserObj($classData);
413 if(!($processObject instanceof t3lib_browseLinksHook)) {
414 throw new UnexpectedValueException('$processObject must implement interface t3lib_browseLinksHook', 1195115652);
415 }
416 $parameters = array();
417 $processObject->init($this, $parameters);
418 $this->hookObjects[] = $processObject;
419 }
420 }
421 }
422
423 /**
424 * Provide the additional parameters to be included in the template body tag
425 *
426 * @return string the body tag additions
427 */
428 public function getBodyTagAdditions() {
429 return 'onLoad="initDialog();"';
430 }
431
432 /**
433 * Generate JS code to be used on the link insert/modify dialogue
434 *
435 * @return string the generated JS code
436 */
437 function getJSCode() {
438 global $BACK_PATH;
439 // BEGIN accumulation of header JavaScript:
440 $JScode = '';
441 $JScode.= '
442 var dialog = window.opener.HTMLArea.Dialog.TYPO3Link;
443 var plugin = dialog.plugin;
444 var HTMLArea = window.opener.HTMLArea;
445
446 function initDialog() {
447 window.dialog = window.opener.HTMLArea.Dialog.TYPO3Link;
448 window.plugin = dialog.plugin;
449 window.HTMLArea = window.opener.HTMLArea;
450 dialog.captureEvents("skipUnload");
451 }
452 // This JavaScript is primarily for RTE/Link. jumpToUrl is used in the other cases as well...
453 var add_href="'.($this->curUrlArray['href']?'&curUrl[href]='.rawurlencode($this->curUrlArray['href']):'').'";
454 var add_target="'.($this->setTarget?'&curUrl[target]='.rawurlencode($this->setTarget):'').'";
455 var add_class="'.($this->setClass?'&curUrl[class]='.rawurlencode($this->setClass):'').'";
456 var add_title="'.($this->setTitle?'&curUrl[title]='.rawurlencode($this->setTitle):'').'";
457 var add_params="'.($this->bparams?'&bparams='.rawurlencode($this->bparams):'').'";
458
459 var cur_href="'.($this->curUrlArray['href'] ? ($this->curUrlInfo['query'] ? substr($this->curUrlArray['href'], 0, -strlen($this->curUrlInfo['query'])) :$this->curUrlArray['href']):'').'";
460 var cur_target="'.($this->setTarget?$this->setTarget:'').'";
461 var cur_class="'.($this->setClass?$this->setClass:'').'";
462 var cur_title="'.($this->setTitle?$this->setTitle:'').'";
463
464 function browse_links_setTarget(value) {
465 cur_target=value;
466 add_target="&curUrl[target]="+encodeURIComponent(value);
467 }
468 function browse_links_setClass(value) {
469 cur_class=value;
470 add_class="&curUrl[class]="+encodeURIComponent(value);
471 }
472 function browse_links_setTitle(value) {
473 cur_title=value;
474 add_title="&curUrl[title]="+encodeURIComponent(value);
475 }
476 function browse_links_setHref(value) {
477 cur_href=value;
478 add_href="&curUrl[href]="+value;
479 }
480 ';
481
482 // Functions used, if the link selector is in RTE mode:
483 $JScode.='
484 function link_typo3Page(id,anchor) {
485 var parameters = document.ltargetform.query_parameters ? (document.ltargetform.query_parameters.value.charAt(0) == "&"?"":"&") + document.ltargetform.query_parameters.value : "";
486 var theLink = \''.$this->siteURL.'?id=\'+id+(anchor?anchor:"")+parameters;
487 if (document.ltargetform.anchor_title) browse_links_setTitle(document.ltargetform.anchor_title.value);
488 if (document.ltargetform.anchor_class) browse_links_setClass(document.ltargetform.anchor_class.value);
489 if (document.ltargetform.ltarget) browse_links_setTarget(document.ltargetform.ltarget.value);
490 plugin.createLink(theLink,cur_target,cur_class,cur_title);
491 return false;
492 }
493 function link_folder(folder) { //
494 var theLink = \''.$this->siteURL.'\'+folder;
495 if (document.ltargetform.anchor_title) browse_links_setTitle(document.ltargetform.anchor_title.value);
496 if (document.ltargetform.anchor_class) browse_links_setClass(document.ltargetform.anchor_class.value);
497 if (document.ltargetform.ltarget) browse_links_setTarget(document.ltargetform.ltarget.value);
498 plugin.createLink(theLink,cur_target,cur_class,cur_title);
499 return false;
500 }
501 function link_spec(theLink) { //
502 if (document.ltargetform.anchor_title) browse_links_setTitle(document.ltargetform.anchor_title.value);
503 if (document.ltargetform.anchor_class) browse_links_setClass(document.ltargetform.anchor_class.value);
504 if (document.ltargetform.ltarget) browse_links_setTarget(document.ltargetform.ltarget.value);
505 plugin.createLink(theLink,cur_target,cur_class,cur_title);
506 return false;
507 }
508 function link_current() { //
509 var parameters = document.ltargetform.query_parameters ? (document.ltargetform.query_parameters.value.charAt(0) == "&"?"":"&") + document.ltargetform.query_parameters.value : "";
510 if (document.ltargetform.anchor_title) browse_links_setTitle(document.ltargetform.anchor_title.value);
511 if (document.ltargetform.anchor_class) browse_links_setClass(document.ltargetform.anchor_class.value);
512 if (document.ltargetform.ltarget) browse_links_setTarget(document.ltargetform.ltarget.value);
513 if (cur_href!="http://" && cur_href!="mailto:") {
514 plugin.createLink(cur_href + parameters,cur_target,cur_class,cur_title);
515 }
516 return false;
517 }
518 ';
519
520 // General "jumpToUrl" function:
521 $JScode.='
522 function jumpToUrl(URL,anchor) { //
523 var add_editorNo = URL.indexOf("editorNo=")==-1 ? "&editorNo='.$this->editorNo.'" : "";
524 var add_contentTypo3Language = URL.indexOf("contentTypo3Language=")==-1 ? "&contentTypo3Language='.$this->contentTypo3Language.'" : "";
525 var add_contentTypo3Charset = URL.indexOf("contentTypo3Charset=")==-1 ? "&contentTypo3Charset='.$this->contentTypo3Charset.'" : "";
526 var add_act = URL.indexOf("act=")==-1 ? "&act='.$this->act.'" : "";
527 var add_mode = URL.indexOf("mode=")==-1 ? "&mode='.$this->mode.'" : "";
528 var theLocation = URL+add_act+add_editorNo+add_contentTypo3Language+add_contentTypo3Charset+add_mode+add_href+add_target+add_class+add_title+add_params'.($addPassOnParams?'+"'.$addPassOnParams.'"':'').'+(anchor?anchor:"");
529 window.location.href = theLocation;
530 return false;
531 }
532 ';
533 // This is JavaScript especially for the TBE Element Browser!
534 $pArr = explode('|',$this->bparams);
535 $formFieldName = 'data['.$pArr[0].']['.$pArr[1].']['.$pArr[2].']';
536 $JScode.='
537 var elRef="";
538 var targetDoc="";
539
540 function launchView(url) { //
541 var thePreviewWindow="";
542 thePreviewWindow = window.open("' . $BACK_PATH . 'show_item.php?table="+url,"ShowItem","height=300,width=410,status=0,menubar=0,resizable=0,location=0,directories=0,scrollbars=1,toolbar=0");
543 if (thePreviewWindow && thePreviewWindow.focus) {
544 thePreviewWindow.focus();
545 }
546 }
547 function setReferences() { //
548 if (parent.window.opener
549 && parent.window.opener.content
550 && parent.window.opener.content.document.editform
551 && parent.window.opener.content.document.editform["'.$formFieldName.'"]
552 ) {
553 targetDoc = parent.window.opener.content.document;
554 elRef = targetDoc.editform["'.$formFieldName.'"];
555 return true;
556 } else {
557 return false;
558 }
559 }
560 function insertElement(table, uid, type, filename,fp,filetype,imagefile,action, close) { //
561 if (1=='.($pArr[0]&&!$pArr[1]&&!$pArr[2] ? 1 : 0).') {
562 addElement(filename,table+"_"+uid,fp,close);
563 } else {
564 if (setReferences()) {
565 parent.window.opener.group_change("add","'.$pArr[0].'","'.$pArr[1].'","'.$pArr[2].'",elRef,targetDoc);
566 } else {
567 alert("Error - reference to main window is not set properly!");
568 }
569 if (close) {
570 parent.window.opener.focus();
571 parent.close();
572 }
573 }
574 return false;
575 }
576 function addElement(elName,elValue,altElValue,close) { //
577 if (parent.window.opener && parent.window.opener.setFormValueFromBrowseWin) {
578 parent.window.opener.setFormValueFromBrowseWin("'.$pArr[0].'",altElValue?altElValue:elValue,elName);
579 if (close) {
580 parent.window.opener.focus();
581 parent.close();
582 }
583 } else {
584 alert("Error - reference to main window is not set properly!");
585 parent.close();
586 }
587 }
588 ';
589 return $JScode;
590 }
591
592 /******************************************************************
593 *
594 * Main functions
595 *
596 ******************************************************************/
597 /**
598 * Rich Text Editor (RTE) link selector (MAIN function)
599 * Generates the link selector for the Rich Text Editor.
600 * Can also be used to select links for the TCEforms (see $wiz)
601 *
602 * @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
603 * @return string Modified content variable.
604 */
605 function main_rte($wiz=0) {
606 global $LANG, $BE_USER, $BACK_PATH;
607
608 // Starting content:
609 $content=$this->doc->startPage($LANG->getLL('Insert/Modify Link',1));
610
611 // Initializing the action value, possibly removing blinded values etc:
612 $this->allowedItems = explode(',','page,file,url,mail,spec');
613
614 //call hook for extra options
615 foreach($this->hookObjects as $hookObject) {
616 $this->allowedItems = $hookObject->addAllowedItems($this->allowedItems);
617 }
618
619 if (is_array($this->buttonConfig['options.']) && $this->buttonConfig['options.']['removeItems']) {
620 $this->allowedItems = array_diff($this->allowedItems,t3lib_div::trimExplode(',',$this->buttonConfig['options.']['removeItems'],1));
621 } else {
622 $this->allowedItems = array_diff($this->allowedItems,t3lib_div::trimExplode(',',$this->thisConfig['blindLinkOptions'],1));
623 }
624 reset($this->allowedItems);
625 if (!in_array($this->act,$this->allowedItems)) {
626 $this->act = current($this->allowedItems);
627 }
628
629 // Making menu in top:
630 $menuDef = array();
631 if (!$wiz && $this->curUrlArray['href']) {
632 $menuDef['removeLink']['isActive'] = $this->act=='removeLink';
633 $menuDef['removeLink']['label'] = $LANG->getLL('removeLink',1);
634 $menuDef['removeLink']['url'] = '#';
635 $menuDef['removeLink']['addParams'] = 'onclick="plugin.unLink();return false;"';
636 }
637 if (in_array('page',$this->allowedItems)) {
638 $menuDef['page']['isActive'] = $this->act=='page';
639 $menuDef['page']['label'] = $LANG->getLL('page',1);
640 $menuDef['page']['url'] = '#';
641 $menuDef['page']['addParams'] = 'onclick="jumpToUrl(\''.htmlspecialchars('?act=page&mode='.$this->mode.'&bparams='.$this->bparams).'\');return false;"';
642 }
643 if (in_array('file',$this->allowedItems)){
644 $menuDef['file']['isActive'] = $this->act=='file';
645 $menuDef['file']['label'] = $LANG->getLL('file',1);
646 $menuDef['file']['url'] = '#';
647 $menuDef['file']['addParams'] = 'onclick="jumpToUrl(\''.htmlspecialchars('?act=file&mode='.$this->mode.'&bparams='.$this->bparams).'\');return false;"';
648 }
649 if (in_array('url',$this->allowedItems)) {
650 $menuDef['url']['isActive'] = $this->act=='url';
651 $menuDef['url']['label'] = $LANG->getLL('extUrl',1);
652 $menuDef['url']['url'] = '#';
653 $menuDef['url']['addParams'] = 'onclick="jumpToUrl(\''.htmlspecialchars('?act=url&mode='.$this->mode.'&bparams='.$this->bparams).'\');return false;"';
654 }
655 if (in_array('mail',$this->allowedItems)) {
656 $menuDef['mail']['isActive'] = $this->act=='mail';
657 $menuDef['mail']['label'] = $LANG->getLL('email',1);
658 $menuDef['mail']['url'] = '#';
659 $menuDef['mail']['addParams'] = 'onclick="jumpToUrl(\''.htmlspecialchars('?act=mail&mode='.$this->mode.'&bparams='.$this->bparams).'\');return false;"';
660 }
661 if (is_array($this->thisConfig['userLinks.']) && in_array('spec',$this->allowedItems)) {
662 $menuDef['spec']['isActive'] = $this->act=='spec';
663 $menuDef['spec']['label'] = $LANG->getLL('special',1);
664 $menuDef['spec']['url'] = '#';
665 $menuDef['spec']['addParams'] = 'onclick="jumpToUrl(\''.htmlspecialchars('?act=spec&mode='.$this->mode.'&bparams='.$this->bparams).'\');return false;"';
666 }
667
668 // call hook for extra options
669 foreach($this->hookObjects as $hookObject) {
670 $menuDef = $hookObject->modifyMenuDefinition($menuDef);
671 }
672
673 $content .= $this->doc->getTabMenuRaw($menuDef);
674
675 // Adding the menu and header to the top of page:
676 $content.=$this->printCurrentUrl($this->curUrlInfo['info']).'<br />';
677
678 // Depending on the current action we will create the actual module content for selecting a link:
679 switch($this->act) {
680 case 'mail':
681 $extUrl='
682 <!--
683 Enter mail address:
684 -->
685 <form action="" name="lurlform" id="lurlform">
686 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkMail">
687 <tr>
688 <td>'.$LANG->getLL('emailAddress',1).':</td>
689 <td><input type="text" name="lemail"'.$this->doc->formWidth(20).' value="'.htmlspecialchars($this->curUrlInfo['act']=='mail'?$this->curUrlInfo['info']:'').'" /> '.
690 '<input type="submit" value="'.$LANG->getLL('setLink',1).'" onclick="browse_links_setTarget(\'\');browse_links_setHref(\'mailto:\'+document.lurlform.lemail.value); return link_current();" /></td>
691 </tr>
692 </table>
693 </form>';
694 $content.=$extUrl;
695 $content.=$this->addAttributesForm();
696 break;
697 case 'url':
698 $extUrl='
699 <!--
700 Enter External URL:
701 -->
702 <form action="" name="lurlform" id="lurlform">
703 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkURL">
704 <tr>
705 <td>URL:</td>
706 <td><input type="text" name="lurl"'.$this->doc->formWidth(20).' value="'.htmlspecialchars($this->curUrlInfo['act']=='url'?$this->curUrlInfo['info']:'http://').'" /> '.
707 '<input type="submit" value="'.$LANG->getLL('setLink',1).'" onclick="browse_links_setHref(document.lurlform.lurl.value); return link_current();" /></td>
708 </tr>
709 </table>
710 </form>';
711 $content.=$extUrl;
712 $content.=$this->addAttributesForm();
713 break;
714 case 'file':
715 $content.=$this->addAttributesForm();
716
717 $foldertree = t3lib_div::makeInstance('tx_rtehtmlarea_folderTree');
718 $tree=$foldertree->getBrowsableTree();
719
720 if (!$this->curUrlInfo['value'] || $this->curUrlInfo['act']!='file') {
721 $cmpPath='';
722 } elseif (substr(trim($this->curUrlInfo['info']),-1)!='/') {
723 $cmpPath=PATH_site.dirname($this->curUrlInfo['info']).'/';
724 if (!isset($this->expandFolder)) $this->expandFolder = $cmpPath;
725 } else {
726 $cmpPath=PATH_site.$this->curUrlInfo['info'];
727 }
728
729 list(,,$specUid) = explode('_',$this->PM);
730 $files = $this->expandFolder($foldertree->specUIDmap[$specUid]);
731
732 // Create upload/create folder forms, if a path is given:
733 if ($BE_USER->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
734 $fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
735 $fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
736 $path=$this->expandFolder;
737 if (!$path || !@is_dir($path)) {
738 $path = $fileProcessor->findTempFolder().'/'; // The closest TEMP-path is found
739 }
740 if ($path!='/' && @is_dir($path) && !$this->readOnly && count($GLOBALS['FILEMOUNTS'])) {
741 $uploadForm=$this->uploadForm($path);
742 $createFolder=$this->createFolder($path);
743 } else {
744 $createFolder='';
745 $uploadForm='';
746 }
747 $content.=$uploadForm;
748 if ($BE_USER->isAdmin() || $BE_USER->getTSConfigVal('options.createFoldersInEB')) {
749 $content.=$createFolder;
750 }
751 }
752
753
754
755 $content.= '
756 <!--
757 Wrapper table for folder tree / file list:
758 -->
759 <table border="0" cellpadding="0" cellspacing="0" id="typo3-linkFiles">
760 <tr>
761 <td class="c-wCell" valign="top">'.$this->barheader($LANG->getLL('folderTree').':').$tree.'</td>
762 <td class="c-wCell" valign="top">'.$files.'</td>
763 </tr>
764 </table>
765 ';
766 break;
767 case 'spec':
768 if (is_array($this->thisConfig['userLinks.'])) {
769 $subcats=array();
770 $v=$this->thisConfig['userLinks.'];
771 reset($v);
772 while(list($k2)=each($v)) {
773 $k2i = intval($k2);
774 if (substr($k2,-1)=='.' && is_array($v[$k2i.'.'])) {
775
776 // Title:
777 $title = trim($v[$k2i]);
778 if (!$title) {
779 $title=$v[$k2i.'.']['url'];
780 } else {
781 $title=$LANG->sL($title);
782 }
783 // Description:
784 $description=$v[$k2i.'.']['description'] ? $LANG->sL($v[$k2i.'.']['description'],1).'<br />' : '';
785
786 // URL + onclick event:
787 $onClickEvent='';
788 if (isset($v[$k2i.'.']['target'])) $onClickEvent.="browse_links_setTarget('".$v[$k2i.'.']['target']."');";
789 $v[$k2i.'.']['url'] = str_replace('###_URL###',$this->siteURL,$v[$k2i.'.']['url']);
790 if (substr($v[$k2i.'.']['url'],0,7)=="http://" || substr($v[$k2i.'.']['url'],0,7)=='mailto:') {
791 $onClickEvent.="cur_href=unescape('".rawurlencode($v[$k2i.'.']['url'])."');link_current();";
792 } else {
793 $onClickEvent.="link_spec(unescape('".$this->siteURL.rawurlencode($v[$k2i.'.']['url'])."'));";
794 }
795
796 // Link:
797 $A=array('<a href="#" onclick="'.htmlspecialchars($onClickEvent).'return false;">','</a>');
798
799 // Adding link to menu of user defined links:
800 $subcats[$k2i]='
801 <tr>
802 <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>
803 </tr>';
804 }
805 }
806
807 // Sort by keys:
808 ksort($subcats);
809
810 // Add menu to content:
811 $content.= '
812 <!--
813 Special userdefined menu:
814 -->
815 <table border="0" cellpadding="1" cellspacing="1" id="typo3-linkSpecial">
816 <tr>
817 <td class="bgColor5" class="c-wCell" valign="top"><strong>'.$LANG->getLL('special',1).'</strong></td>
818 </tr>
819 '.implode('',$subcats).'
820 </table>
821 ';
822 }
823 break;
824 case 'page':
825 $content.=$this->addAttributesForm();
826
827 $pagetree = t3lib_div::makeInstance('tx_rtehtmlarea_pageTree');
828 $pagetree->ext_showNavTitle = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showNavTitle');
829 $pagetree->addField('nav_title');
830 $tree=$pagetree->getBrowsableTree();
831 $cElements = $this->expandPage();
832 $content.= '
833 <!--
834 Wrapper table for page tree / record list:
835 -->
836 <table border="0" cellpadding="0" cellspacing="0" id="typo3-linkPages">
837 <tr>
838 <td class="c-wCell" valign="top">'.$this->barheader($LANG->getLL('pageTree').':').$tree.'</td>
839 <td class="c-wCell" valign="top">'.$cElements.'</td>
840 </tr>
841 </table>
842 ';
843 break;
844 default:
845 // call hook
846 foreach($this->hookObjects as $hookObject) {
847 $content .= $hookObject->getTab($this->act);
848 }
849
850 break;
851 }
852
853 // End page, return content:
854 $content.= $this->doc->endPage();
855 $this->doc->JScodeArray['rtehtmlarea'] = $this->getJSCode();
856 $content = $this->doc->insertStylesAndJS($content);
857 return $content;
858 }
859
860 function addAttributesForm() {
861 $ltargetForm = '';
862 // Add page id, target, class selector box, title and parameters fields:
863 $lpageId = $this->addPageIdSelector();
864 $queryParameters = $this->addQueryParametersSelector();
865 $ltarget = $this->addTargetSelector();
866 $lclass = $this->addClassSelector();
867 $ltitle = $this->addTitleSelector();
868 if ($lpageId || $queryParameters || $ltarget || $lclass || $ltitle) {
869 $ltargetForm = $this->wrapInForm($lpageId.$queryParameters.$ltarget.$lclass.$ltitle);
870 }
871 return $ltargetForm;
872 }
873
874 function wrapInForm($string) {
875 global $LANG;
876
877 $form = '
878 <!--
879 Selecting target for link:
880 -->
881 <form action="" name="ltargetform" id="ltargetform">
882 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkTarget">'. $string;
883 if ($this->act == $this->curUrlInfo['act'] && $this->act != 'mail' && $this->curUrlArray['href']) {
884 $form .='
885 <tr>
886 <td>
887 </td>
888 <td colspan="3">
889 <input type="submit" value="'.$LANG->getLL('update',1).'" onclick="return link_current();" />
890 </td>
891 </tr>';
892 }
893 $form .= '
894 </table>
895 </form>';
896 return $form;
897 }
898
899 function addPageIdSelector() {
900 global $LANG;
901
902 return ($this->act == 'page' && $this->buttonConfig && is_array($this->buttonConfig['pageIdSelector.']) && $this->buttonConfig['pageIdSelector.']['enabled'])?'
903 <tr>
904 <td>'.$LANG->getLL('page_id',1).':</td>
905 <td colspan="3">
906 <input type="text" size="6" name="luid" />&nbsp;<input type="submit" value="'.$LANG->getLL('setLink',1).'" onclick="return link_typo3Page(document.ltargetform.luid.value);" />
907 </td>
908 </tr>':'';
909 }
910
911 function addQueryParametersSelector() {
912 global $LANG;
913
914 return ($this->act == 'page' && $this->buttonConfig && is_array($this->buttonConfig['queryParametersSelector.']) && $this->buttonConfig['queryParametersSelector.']['enabled'])?'
915 <tr>
916 <td>'.$LANG->getLL('query_parameters',1).':</td>
917 <td colspan="3">
918 <input type="text" name="query_parameters" value="' . ($this->curUrlInfo['query']?$this->curUrlInfo['query']:'') . '" ' . $this->doc->formWidth(30) . ' />
919 </td>
920 </tr>':'';
921 }
922
923 function addTargetSelector() {
924 global $LANG;
925
926 $targetSelectorConfig = array();
927 $popupSelectorConfig = array();
928 if (is_array($this->buttonConfig['targetSelector.'])) {
929 $targetSelectorConfig = $this->buttonConfig['targetSelector.'];
930 }
931 if (is_array($this->buttonConfig['popupSelector.'])) {
932 $popupSelectorConfig = $this->buttonConfig['popupSelector.'];
933 }
934
935 $ltarget = '';
936 if ($this->act != 'mail') {
937 $ltarget .= '
938 <tr id="ltargetrow"'. (($targetSelectorConfig['disabled'] && $popupSelectorConfig['disabled']) ? ' style="display: none;"' : '') . '>
939 <td>'.$LANG->getLL('target',1).':</td>
940 <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>';
941 $ltarget .= '
942 <td colspan="2">';
943 if (!$targetSelectorConfig['disabled']) {
944 $ltarget .= '
945 <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;">
946 <option></option>
947 <option value="_top">'.$LANG->getLL('top',1).'</option>
948 <option value="_blank">'.$LANG->getLL('newWindow',1).'</option>
949 </select>';
950 }
951 $ltarget .= '
952 </td>
953 </tr>';
954 if (!$popupSelectorConfig['disabled']) {
955
956 $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) {
957 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;
958 browse_links_setTarget(document.ltargetform.ltarget.value);
959 document.ltargetform.popup_width.selectedIndex=0;
960 document.ltargetform.popup_height.selectedIndex=0;
961 }';
962
963 $ltarget.='
964 <tr>
965 <td>'.$LANG->getLL('target_popUpWindow',1).':</td>
966 <td colspan="3">
967 <select name="popup_width" onchange="'.$selectJS.'">
968 <option value="0">'.$LANG->getLL('target_popUpWindow_width',1).'</option>
969 <option value="300">300</option>
970 <option value="400">400</option>
971 <option value="500">500</option>
972 <option value="600">600</option>
973 <option value="700">700</option>
974 <option value="800">800</option>
975 </select>
976 x
977 <select name="popup_height" onchange="'.$selectJS.'">
978 <option value="0">'.$LANG->getLL('target_popUpWindow_height',1).'</option>
979 <option value="200">200</option>
980 <option value="300">300</option>
981 <option value="400">400</option>
982 <option value="500">500</option>
983 <option value="600">600</option>
984 </select>
985 </td>
986 </tr>';
987 }
988 }
989 return $ltarget;
990 }
991
992 function addClassSelector() {
993 global $LANG;
994
995 $selectClass = '';
996 if ($this->classesAnchorJSOptions[$this->act]) {
997 $selectClassJS = '
998 if (document.ltargetform.anchor_class) {
999 document.ltargetform.anchor_class.value = document.ltargetform.anchor_class.options[document.ltargetform.anchor_class.selectedIndex].value;
1000 if (document.ltargetform.anchor_class.value && HTMLArea.classesAnchorSetup) {
1001 for (var i = HTMLArea.classesAnchorSetup.length; --i >= 0;) {
1002 var anchorClass = HTMLArea.classesAnchorSetup[i];
1003 if (anchorClass[\'name\'] == document.ltargetform.anchor_class.value) {
1004 if (anchorClass[\'titleText\'] && document.ltargetform.anchor_title) {
1005 document.ltargetform.anchor_title.value = anchorClass[\'titleText\'];
1006 browse_links_setTitle(anchorClass[\'titleText\']);
1007 }
1008 if (anchorClass[\'target\']) {
1009 if (document.ltargetform.ltarget) {
1010 document.ltargetform.ltarget.value = anchorClass[\'target\'];
1011 }
1012 browse_links_setTarget(anchorClass[\'target\']);
1013 } else if (document.ltargetform.ltarget && document.getElementById(\'ltargetrow\').style.display == \'none\') {
1014 // Reset target to default if field is not displayed and class has no configured target
1015 document.ltargetform.ltarget.value = \''. ($this->thisConfig['defaultLinkTarget']?$this->thisConfig['defaultLinkTarget']:'') .'\';
1016 browse_links_setTarget(document.ltargetform.ltarget.value);
1017 }
1018 break;
1019 }
1020 }
1021 }
1022 browse_links_setClass(document.ltargetform.anchor_class.value);
1023 }
1024 ';
1025 $selectClass ='
1026 <tr>
1027 <td>'.$LANG->getLL('anchor_class',1).':</td>
1028 <td colspan="3">
1029 <select name="anchor_class" onchange="'.$selectClassJS.'">
1030 ' . $this->classesAnchorJSOptions[$this->act] . '
1031 </select>
1032 </td>
1033 </tr>';
1034 }
1035 return $selectClass;
1036 }
1037
1038 function addTitleSelector() {
1039 global $LANG;
1040
1041 return '
1042 <tr>
1043 <td>'.$LANG->getLL('anchor_title',1).':</td>
1044 <td colspan="3">
1045 <input type="text" name="anchor_title" value="' . ($this->setTitle?$this->setTitle:(($this->setClass || !$this->classesAnchorDefault[$this->act])?'':$this->classesAnchorDefaultTitle[$this->act])) . '" ' . $this->doc->formWidth(30) . ' />
1046 </td>
1047 </tr>';
1048 }
1049
1050 /**
1051 * Localize a string using the language of the content element rather than the language of the BE interface
1052 *
1053 * @param string string: the label to be localized
1054 * @return string Localized string.
1055 */
1056 public function getLLContent($string) {
1057 global $LANG;
1058
1059 $BE_lang = $LANG->lang;
1060 $BE_origCharSet = $LANG->origCharSet;
1061 $BE_charSet = $LANG->charSet;
1062
1063 $LANG->lang = $this->contentTypo3Language;
1064 $LANG->origCharSet = $LANG->csConvObj->charSetArray[$this->contentTypo3Language];
1065 $LANG->origCharSet = $LANG->origCharSet ? $LANG->origCharSet : 'iso-8859-1';
1066 $LANG->charSet = $this->contentTypo3Charset;
1067 $LLString = $LANG->sL($string);
1068
1069 $LANG->lang = $BE_lang;
1070 $LANG->origCharSet = $BE_origCharSet;
1071 $LANG->charSet = $BE_charSet;
1072 return $LLString;
1073 }
1074
1075 /**
1076 * Localize a label obtained from Page TSConfig
1077 *
1078 * @param string string: the label to be localized
1079 * @return string Localized string.
1080 */
1081 public function getPageConfigLabel($string,$JScharCode=1) {
1082 global $LANG;
1083 if (strcmp(substr($string,0,4),'LLL:')) {
1084 $label = $string;
1085 } else {
1086 $label = $LANG->sL(trim($string));
1087 }
1088 $label = str_replace('"', '\"', str_replace('\\\'', '\'', $label));
1089 $label = $JScharCode ? $LANG->JScharCode($label): $label;
1090 return $label;
1091 }
1092
1093 }
1094
1095 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php']) {
1096 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php']);
1097 }
1098
1099 ?>