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