Fixed issue #10764: Use new JS-function for loading prototype/scriptaculous/extJS
[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 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 $additionalAttributes = array();
206 public $buttonConfig = array();
207 public $RTEProperties = array();
208
209 public $anchorTypes = array( 'page', 'url', 'file', 'mail', 'spec');
210 public $classesAnchorDefault = array();
211 public $classesAnchorDefaultTitle = array();
212 public $classesAnchorClassTitle = array();
213 public $classesAnchorDefaultTarget = array();
214 public $classesAnchorJSOptions = array();
215
216 public $allowedItems;
217
218 /**
219 * Constructor:
220 * Initializes a lot of variables, setting JavaScript functions in header etc.
221 *
222 * @return void
223 */
224 function init() {
225
226 $this->initVariables();
227 $this->initConfiguration();
228
229 // Creating backend template object:
230 $this->doc = t3lib_div::makeInstance('template');
231 $this->doc->backPath = $GLOBALS['BACK_PATH'];
232 // Loading the Prototype library and browse_links.js
233 $this->doc->loadPrototype();
234 $this->doc->loadJavascriptLib('js/browse_links.js');
235 // Adding context menu code
236 $this->doc->getContextMenuCode();
237 // Init fileProcessor
238 $this->fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
239 $this->fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
240
241 // Initializing hooking browsers
242 $this->initHookObjects('ext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php');
243
244 // CurrentUrl - the current link url must be passed around if it exists
245 $this->curUrlArray = t3lib_div::_GP('curUrl');
246 if ($this->curUrlArray['all']) {
247 $this->curUrlArray=t3lib_div::get_tag_attributes($this->curUrlArray['all']);
248 }
249 // Note: parseCurUrl will invoke the hooks
250 $this->curUrlInfo = $this->parseCurUrl($this->curUrlArray['href'],$this->siteURL);
251 // Determine nature of current url:
252 $this->act = t3lib_div::_GP('act');
253 if (!$this->act) {
254 $this->act=$this->curUrlInfo['act'];
255 }
256 // Setting intial values for link attributes
257 $this->initLinkAttributes();
258
259 // Add attributes to body tag. Note: getBodyTagAdditions will invoke the hooks
260 $this->doc->bodyTagAdditions = $this->getBodyTagAdditions();
261 // Adding RTE JS code
262 $this->doc->JScodeArray['rtehtmlarea'] = $this->getJSCode();
263 }
264
265 /**
266 * Initialize class variables
267 *
268 * @return void
269 */
270 public function initVariables() {
271
272 // Process bparams
273 $this->bparams = t3lib_div::_GP('bparams');
274 $pArr = explode('|', $this->bparams);
275 $pRteArr = explode(':', $pArr[1]);
276 $this->editorNo = $pRteArr[0];
277 $this->contentTypo3Language = $pRteArr[1];
278 $this->contentTypo3Charset = $pRteArr[2];
279 $this->RTEtsConfigParams = $pArr[2];
280 if (!$this->editorNo) {
281 $this->editorNo = t3lib_div::_GP('editorNo');
282 $this->contentTypo3Language = t3lib_div::_GP('contentTypo3Language');
283 $this->contentTypo3Charset = t3lib_div::_GP('contentTypo3Charset');
284 $this->RTEtsConfigParams = t3lib_div::_GP('RTEtsConfigParams');
285 }
286 $this->pointer = t3lib_div::_GP('pointer');
287 $this->expandPage = t3lib_div::_GP('expandPage');
288 $this->expandFolder = t3lib_div::_GP('expandFolder');
289 $this->P = t3lib_div::_GP('P');
290 $this->PM = t3lib_div::_GP('PM');
291 $pArr[1] = implode(':', array($this->editorNo, $this->contentTypo3Language, $this->contentTypo3Charset));
292 $pArr[2] = $this->RTEtsConfigParams;
293 $this->bparams = implode('|', $pArr);
294
295 // Find "mode"
296 $this->mode = t3lib_div::_GP('mode');
297 if (!$this->mode) {
298 $this->mode = 'rte';
299 }
300 // Current site url
301 $this->siteURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL');
302
303 // the script to link to
304 $this->thisScript = t3lib_div::getIndpEnv('SCRIPT_NAME');
305 }
306
307 /**
308 * Initializes the configuration variables
309 *
310 * @return void
311 */
312 public function initConfiguration() {
313 $this->thisConfig = $this->getRTEConfig();
314 $this->buttonConfig = $this->getButtonConfig('link');
315 }
316
317 /**
318 * Get the RTE configuration from Page TSConfig
319 *
320 * @return array RTE configuration array
321 */
322 protected function getRTEConfig() {
323 global $BE_USER;
324
325 $RTEtsConfigParts = explode(':', $this->RTEtsConfigParams);
326 $RTEsetup = $BE_USER->getTSConfig('RTE',t3lib_BEfunc::getPagesTSconfig($RTEtsConfigParts[5]));
327 $this->RTEProperties = $RTEsetup['properties'];
328 return t3lib_BEfunc::RTEsetup($this->RTEProperties, $RTEtsConfigParts[0],$RTEtsConfigParts[2],$RTEtsConfigParts[4]);
329 }
330
331 /**
332 * Get the configuration of the button
333 *
334 * @param string $buttonName: the name of the button
335 * @return array the configuration array of the image button
336 */
337 protected function getButtonConfig($buttonName) {
338 return ((is_array($this->thisConfig['buttons.']) && is_array($this->thisConfig['buttons.'][$buttonName.'.'])) ? $this->thisConfig['buttons.'][$buttonName.'.'] : array());
339 }
340
341 /**
342 * Initialize hook objects implementing interface t3lib_browseLinksHook
343 * @param string $hookKey: the hook key
344 * @return void
345 */
346 protected function initHookObjects($hookKey) {
347 global $TYPO3_CONF_VARS;
348 if (is_array($TYPO3_CONF_VARS['SC_OPTIONS'][$hookKey]['browseLinksHook'])) {
349 foreach ($TYPO3_CONF_VARS['SC_OPTIONS'][$hookKey]['browseLinksHook'] as $classData) {
350 $processObject = &t3lib_div::getUserObj($classData);
351 if(!($processObject instanceof t3lib_browseLinksHook)) {
352 throw new UnexpectedValueException('$processObject must implement interface t3lib_browseLinksHook', 1195115652);
353 }
354 $parameters = array();
355 $processObject->init($this, $parameters);
356 $this->hookObjects[] = $processObject;
357 }
358 }
359 }
360
361 /**
362 * Initialize the current or default values of the link attributes
363 *
364 * @return void
365 */
366 protected function initLinkAttributes() {
367
368 // Initializing the title value
369 $this->setTitle = $GLOBALS['LANG']->csConvObj->conv($this->curUrlArray['title'], 'utf-8', $GLOBALS['LANG']->charSet);
370
371 // Processing the classes configuration
372 $classSelected = array();
373 if ($this->thisConfig['classesAnchor'] || $this->thisConfig['classesLinks']) {
374 $this->setClass = $this->curUrlArray['class'];
375 if ($this->thisConfig['classesAnchor']) {
376 $classesAnchorArray = t3lib_div::trimExplode(',',$this->thisConfig['classesAnchor'], 1);
377 } else {
378 $classesAnchorArray = t3lib_div::trimExplode(',',$this->thisConfig['classesLinks'], 1);
379 }
380 // Collecting allowed classes and configured default values
381 $classesAnchor = array();
382 $classesAnchor['all'] = array();
383 $titleReadOnly = $this->buttonConfig['properties.']['title.']['readOnly'] || $this->buttonConfig[$this->act.'.']['properties.']['title.']['readOnly'];
384 if (is_array($this->RTEProperties['classesAnchor.'])) {
385 foreach ($this->RTEProperties['classesAnchor.'] as $label => $conf) {
386 if (in_array($conf['class'], $classesAnchorArray)) {
387 $classesAnchor['all'][] = $conf['class'];
388 if (in_array($conf['type'], $this->anchorTypes)) {
389 $classesAnchor[$conf['type']][] = $conf['class'];
390 if (is_array($this->thisConfig['classesAnchor.']) && is_array($this->thisConfig['classesAnchor.']['default.']) && $this->thisConfig['classesAnchor.']['default.'][$conf['type']] == $conf['class']) {
391 $this->classesAnchorDefault[$conf['type']] = $conf['class'];
392 if ($conf['titleText']) {
393 $this->classesAnchorDefaultTitle[$conf['type']] = $this->getLLContent(trim($conf['titleText']));
394 }
395 if ($conf['target']) {
396 $this->classesAnchorDefaultTarget[$conf['type']] = trim($conf['target']);
397 }
398 }
399 }
400 if ($titleReadOnly && $conf['titleText']) {
401 $this->classesAnchorClassTitle[$conf['class']] = $this->classesAnchorDefaultTitle[$conf['type']] = $this->getLLContent(trim($conf['titleText']));
402 }
403 }
404 }
405 }
406 // Constructing the class selector options
407 foreach ($this->anchorTypes as $anchorType) {
408 foreach ($classesAnchorArray as $class) {
409 if (!in_array($class, $classesAnchor['all']) || (in_array($class, $classesAnchor['all']) && is_array($classesAnchor[$anchorType]) && in_array($class, $classesAnchor[$anchorType]))) {
410 $selected = '';
411 if ($this->setClass == $class || (!$this->setClass && $this->classesAnchorDefault[$anchorType] == $class)) {
412 $selected = 'selected="selected"';
413 $classSelected[$anchorType] = true;
414 }
415 $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;
416 $classStyle = (is_array($this->RTEProperties['classes.']) && is_array($this->RTEProperties['classes.'][$class.'.']) && $this->RTEProperties['classes.'][$class.'.']['value']) ? $this->RTEProperties['classes.'][$class.'.']['value'] : '';
417 $this->classesAnchorJSOptions[$anchorType] .= '<option ' . $selected . ' value="' .$class . '"' . ($classStyle?' style="'.$classStyle.'"':'') . '>' . $classLabel . '</option>';
418 }
419 }
420 if ($this->classesAnchorJSOptions[$anchorType] && !($this->buttonConfig['properties.']['class.']['required'] || $this->buttonConfig[$this->act.'.']['properties.']['class.']['required'])) {
421 $selected = '';
422 if (!$this->setClass && !$this->classesAnchorDefault[$anchorType]) $selected = 'selected="selected"';
423 $this->classesAnchorJSOptions[$anchorType] = '<option ' . $selected . ' value=""></option>' . $this->classesAnchorJSOptions[$anchorType];
424 }
425 }
426 }
427 // Initializing the target value
428 // 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
429 // In other words, do not forward the target if we changed tab and the target field is not displayed
430 $this->setTarget = (isset($this->curUrlArray['target'])
431 && !(
432 ($this->curUrlArray['target'] != $this->thisConfig['defaultLinkTarget'])
433 && !$classSelected[$this->act]
434 && is_array($this->buttonConfig['targetSelector.']) && $this->buttonConfig['targetSelector.']['disabled'] && is_array($this->buttonConfig['popupSelector.']) && $this->buttonConfig['popupSelector.']['disabled'])
435 ) ? $this->curUrlArray['target'] : '';
436 if ($this->thisConfig['defaultLinkTarget'] && !isset($this->curUrlArray['target'])) {
437 $this->setTarget=$this->thisConfig['defaultLinkTarget'];
438 }
439 // Initializing additional attributes
440 if ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['rtehtmlarea']['plugins']['TYPO3Link']['additionalAttributes']) {
441 $addAttributes = t3lib_div::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['rtehtmlarea']['plugins']['TYPO3Link']['additionalAttributes'], 1);
442 foreach ($addAttributes as $attribute) {
443 $this->additionalAttributes[$attribute] = isset($this->curUrlArray[$attribute]) ? $this->curUrlArray[$attribute] : '';
444 }
445 }
446 }
447
448 /**
449 * Provide the additional parameters to be included in the template body tag
450 *
451 * @return string the body tag additions
452 */
453 public function getBodyTagAdditions() {
454 $bodyTagAdditions = array();
455 // call hook for extra additions
456 foreach ($this->hookObjects as $hookObject) {
457 if (method_exists($hookObject, 'addBodyTagAdditions')) {
458 $bodyTagAdditions = $hookObject->addBodyTagAdditions($bodyTagAdditions);
459 }
460 }
461 $bodyTagAdditions['onLoad'] = 'initDialog();' . $bodyTagAdditions['onLoad'];
462 return t3lib_div::implodeAttributes($bodyTagAdditions, TRUE);
463 }
464
465 /**
466 * Generate JS code to be used on the link insert/modify dialogue
467 *
468 * @return string the generated JS code
469 */
470 function getJSCode() {
471 global $BACK_PATH;
472 // BEGIN accumulation of header JavaScript:
473 $JScode = '';
474 $JScode.= '
475 var dialog = window.opener.HTMLArea.Dialog.TYPO3Link;
476 var plugin = dialog.plugin;
477 var HTMLArea = window.opener.HTMLArea;
478
479 function initDialog() {
480 window.dialog = window.opener.HTMLArea.Dialog.TYPO3Link;
481 window.plugin = dialog.plugin;
482 window.HTMLArea = window.opener.HTMLArea;
483 dialog.captureEvents("skipUnload");
484 }
485 var add_href="'.($this->curUrlArray['href']?'&curUrl[href]='.rawurlencode($this->curUrlArray['href']):'').'";
486 var add_target="'.($this->setTarget?'&curUrl[target]='.rawurlencode($this->setTarget):'').'";
487 var add_class="'.($this->setClass?'&curUrl[class]='.rawurlencode($this->setClass):'').'";
488 var add_title="'.($this->setTitle?'&curUrl[title]='.rawurlencode($this->setTitle):'').'";
489 var add_params="'.($this->bparams?'&bparams='.rawurlencode($this->bparams):'').'";
490 var additionalValues = ' . (count($this->additionalAttributes) ? json_encode($this->additionalAttributes) : '{}') . ';';
491
492 // Attributes setting functions
493 $JScode.= '
494 var cur_href="'.($this->curUrlArray['href'] ? ($this->curUrlInfo['query'] ? substr($this->curUrlArray['href'], 0, -strlen($this->curUrlInfo['query'])) :$this->curUrlArray['href']):'').'";
495 var cur_target="'.($this->setTarget?$this->setTarget:'').'";
496 var cur_class="'.($this->setClass?$this->setClass:'').'";
497 var cur_title="'.($this->setTitle?$this->setTitle:'').'";
498
499 function browse_links_setTarget(value) {
500 cur_target=value;
501 add_target="&curUrl[target]="+encodeURIComponent(value);
502 }
503 function browse_links_setClass(value) {
504 cur_class=value;
505 add_class="&curUrl[class]="+encodeURIComponent(value);
506 }
507 function browse_links_setTitle(value) {
508 cur_title=value;
509 add_title="&curUrl[title]="+encodeURIComponent(value);
510 }
511 function browse_links_setHref(value) {
512 cur_href=value;
513 add_href="&curUrl[href]="+value;
514 }
515 function browse_links_setAdditionalValue(name, value) {
516 additionalValues[name] = value;
517 }
518 ';
519 // Link setting functions
520 $JScode.='
521 function link_typo3Page(id,anchor) {
522 var parameters = document.ltargetform.query_parameters ? (document.ltargetform.query_parameters.value.charAt(0) == "&"?"":"&") + document.ltargetform.query_parameters.value : "";
523 var theLink = \''.$this->siteURL.'?id=\'+id+(anchor?anchor:"")+parameters;
524 if (document.ltargetform.anchor_title) browse_links_setTitle(document.ltargetform.anchor_title.value);
525 if (document.ltargetform.anchor_class) browse_links_setClass(document.ltargetform.anchor_class.value);
526 if (document.ltargetform.ltarget) browse_links_setTarget(document.ltargetform.ltarget.value);
527 plugin.createLink(theLink,cur_target,cur_class,cur_title,additionalValues);
528 return false;
529 }
530 function link_folder(folder) {
531 var theLink = \''.$this->siteURL.'\'+folder;
532 if (document.ltargetform.anchor_title) browse_links_setTitle(document.ltargetform.anchor_title.value);
533 if (document.ltargetform.anchor_class) browse_links_setClass(document.ltargetform.anchor_class.value);
534 if (document.ltargetform.ltarget) browse_links_setTarget(document.ltargetform.ltarget.value);
535 plugin.createLink(theLink,cur_target,cur_class,cur_title,additionalValues);
536 return false;
537 }
538 function link_spec(theLink) {
539 if (document.ltargetform.anchor_title) browse_links_setTitle(document.ltargetform.anchor_title.value);
540 if (document.ltargetform.anchor_class) browse_links_setClass(document.ltargetform.anchor_class.value);
541 if (document.ltargetform.ltarget) browse_links_setTarget(document.ltargetform.ltarget.value);
542 plugin.createLink(theLink,cur_target,cur_class,cur_title,additionalValues);
543 return false;
544 }
545 function link_current() {
546 var parameters = document.ltargetform.query_parameters ? (document.ltargetform.query_parameters.value.charAt(0) == "&"?"":"&") + document.ltargetform.query_parameters.value : "";
547 if (document.ltargetform.anchor_title) browse_links_setTitle(document.ltargetform.anchor_title.value);
548 if (document.ltargetform.anchor_class) browse_links_setClass(document.ltargetform.anchor_class.value);
549 if (document.ltargetform.ltarget) browse_links_setTarget(document.ltargetform.ltarget.value);
550 if (cur_href!="http://" && cur_href!="mailto:") {
551 plugin.createLink(cur_href + parameters,cur_target,cur_class,cur_title,additionalValues);
552 }
553 return false;
554 }
555 ';
556 // General "jumpToUrl" and launchView functions:
557 $JScode.='
558 function jumpToUrl(URL,anchor) {
559 var add_editorNo = URL.indexOf("editorNo=")==-1 ? "&editorNo='.$this->editorNo.'" : "";
560 var add_contentTypo3Language = URL.indexOf("contentTypo3Language=")==-1 ? "&contentTypo3Language='.$this->contentTypo3Language.'" : "";
561 var add_contentTypo3Charset = URL.indexOf("contentTypo3Charset=")==-1 ? "&contentTypo3Charset='.$this->contentTypo3Charset.'" : "";
562 var add_act = URL.indexOf("act=")==-1 ? "&act='.$this->act.'" : "";
563 var add_mode = URL.indexOf("mode=")==-1 ? "&mode='.$this->mode.'" : "";
564 var add_additionalValues = "";
565 if (plugin.pageTSConfiguration && plugin.pageTSConfiguration.additionalAttributes) {
566 var additionalAttributes = plugin.pageTSConfiguration.additionalAttributes.split(",");
567 for (var i = additionalAttributes.length; --i >= 0;) {
568 if (additionalValues[additionalAttributes[i]] != "") {
569 add_additionalValues += "&curUrl[" + additionalAttributes[i] + "]=" + encodeURIComponent(additionalValues[additionalAttributes[i]]);
570 }
571 }
572 }
573 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:"");
574 window.location.href = theLocation;
575 return false;
576 }
577 function launchView(url) {
578 var thePreviewWindow="";
579 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");
580 if (thePreviewWindow && thePreviewWindow.focus) {
581 thePreviewWindow.focus();
582 }
583 }
584 ';
585 return $JScode;
586 }
587
588 /******************************************************************
589 *
590 * Main functions
591 *
592 ******************************************************************/
593 /**
594 * Rich Text Editor (RTE) link selector (MAIN function)
595 * Generates the link selector for the Rich Text Editor.
596 * Can also be used to select links for the TCEforms (see $wiz)
597 *
598 * @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
599 * @return string Modified content variable.
600 */
601 function main_rte($wiz=0) {
602 global $LANG, $BE_USER, $BACK_PATH;
603
604 // Starting content:
605 $content=$this->doc->startPage($LANG->getLL('Insert/Modify Link',1));
606
607 // Initializing the action value, possibly removing blinded values etc:
608 $this->allowedItems = explode(',','page,file,url,mail,spec');
609
610 // Calling hook for extra options
611 foreach($this->hookObjects as $hookObject) {
612 $this->allowedItems = $hookObject->addAllowedItems($this->allowedItems);
613 }
614
615 if (is_array($this->buttonConfig['options.']) && $this->buttonConfig['options.']['removeItems']) {
616 $this->allowedItems = array_diff($this->allowedItems,t3lib_div::trimExplode(',',$this->buttonConfig['options.']['removeItems'],1));
617 } else {
618 $this->allowedItems = array_diff($this->allowedItems,t3lib_div::trimExplode(',',$this->thisConfig['blindLinkOptions'],1));
619 }
620 reset($this->allowedItems);
621 if (!in_array($this->act,$this->allowedItems)) {
622 $this->act = current($this->allowedItems);
623 }
624
625 // Making menu in top:
626 $menuDef = array();
627 if (!$wiz && $this->curUrlArray['href']) {
628 $menuDef['removeLink']['isActive'] = $this->act=='removeLink';
629 $menuDef['removeLink']['label'] = $LANG->getLL('removeLink',1);
630 $menuDef['removeLink']['url'] = '#';
631 $menuDef['removeLink']['addParams'] = 'onclick="plugin.unLink();return false;"';
632 }
633 if (in_array('page',$this->allowedItems)) {
634 $menuDef['page']['isActive'] = $this->act=='page';
635 $menuDef['page']['label'] = $LANG->getLL('page',1);
636 $menuDef['page']['url'] = '#';
637 $menuDef['page']['addParams'] = 'onclick="jumpToUrl(\''.htmlspecialchars('?act=page&mode='.$this->mode.'&bparams='.$this->bparams).'\');return false;"';
638 }
639 if (in_array('file',$this->allowedItems)){
640 $menuDef['file']['isActive'] = $this->act=='file';
641 $menuDef['file']['label'] = $LANG->getLL('file',1);
642 $menuDef['file']['url'] = '#';
643 $menuDef['file']['addParams'] = 'onclick="jumpToUrl(\''.htmlspecialchars('?act=file&mode='.$this->mode.'&bparams='.$this->bparams).'\');return false;"';
644 }
645 if (in_array('url',$this->allowedItems)) {
646 $menuDef['url']['isActive'] = $this->act=='url';
647 $menuDef['url']['label'] = $LANG->getLL('extUrl',1);
648 $menuDef['url']['url'] = '#';
649 $menuDef['url']['addParams'] = 'onclick="jumpToUrl(\''.htmlspecialchars('?act=url&mode='.$this->mode.'&bparams='.$this->bparams).'\');return false;"';
650 }
651 if (in_array('mail',$this->allowedItems)) {
652 $menuDef['mail']['isActive'] = $this->act=='mail';
653 $menuDef['mail']['label'] = $LANG->getLL('email',1);
654 $menuDef['mail']['url'] = '#';
655 $menuDef['mail']['addParams'] = 'onclick="jumpToUrl(\''.htmlspecialchars('?act=mail&mode='.$this->mode.'&bparams='.$this->bparams).'\');return false;"';
656 }
657 if (is_array($this->thisConfig['userLinks.']) && in_array('spec',$this->allowedItems)) {
658 $menuDef['spec']['isActive'] = $this->act=='spec';
659 $menuDef['spec']['label'] = $LANG->getLL('special',1);
660 $menuDef['spec']['url'] = '#';
661 $menuDef['spec']['addParams'] = 'onclick="jumpToUrl(\''.htmlspecialchars('?act=spec&mode='.$this->mode.'&bparams='.$this->bparams).'\');return false;"';
662 }
663
664 // call hook for extra options
665 foreach($this->hookObjects as $hookObject) {
666 $menuDef = $hookObject->modifyMenuDefinition($menuDef);
667 }
668
669 $content .= $this->doc->getTabMenuRaw($menuDef);
670
671 // Adding the menu and header to the top of page:
672 $content.=$this->printCurrentUrl($this->curUrlInfo['info']).'<br />';
673
674 // Depending on the current action we will create the actual module content for selecting a link:
675 switch($this->act) {
676 case 'mail':
677 $extUrl='
678 <!--
679 Enter mail address:
680 -->
681 <form action="" name="lurlform" id="lurlform">
682 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkMail">
683 <tr>
684 <td>'.$LANG->getLL('emailAddress',1).':</td>
685 <td><input type="text" name="lemail"'.$this->doc->formWidth(20).' value="'.htmlspecialchars($this->curUrlInfo['act']=='mail'?$this->curUrlInfo['info']:'').'" /> '.
686 '<input type="submit" value="'.$LANG->getLL('setLink',1).'" onclick="browse_links_setTarget(\'\');browse_links_setHref(\'mailto:\'+document.lurlform.lemail.value); return link_current();" /></td>
687 </tr>
688 </table>
689 </form>';
690 $content.=$extUrl;
691 $content.=$this->addAttributesForm();
692 break;
693 case 'url':
694 $extUrl='
695 <!--
696 Enter External URL:
697 -->
698 <form action="" name="lurlform" id="lurlform">
699 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkURL">
700 <tr>
701 <td>URL:</td>
702 <td><input type="text" name="lurl"'.$this->doc->formWidth(20).' value="'.htmlspecialchars($this->curUrlInfo['act']=='url'?$this->curUrlInfo['info']:'http://').'" /> '.
703 '<input type="submit" value="'.$LANG->getLL('setLink',1).'" onclick="browse_links_setHref(document.lurlform.lurl.value); return link_current();" /></td>
704 </tr>
705 </table>
706 </form>';
707 $content.=$extUrl;
708 $content.=$this->addAttributesForm();
709 break;
710 case 'file':
711 $content.=$this->addAttributesForm();
712
713 $foldertree = t3lib_div::makeInstance('tx_rtehtmlarea_folderTree');
714 $tree=$foldertree->getBrowsableTree();
715
716 if (!$this->curUrlInfo['value'] || $this->curUrlInfo['act']!='file') {
717 $cmpPath='';
718 } elseif (substr(trim($this->curUrlInfo['info']),-1)!='/') {
719 $cmpPath=PATH_site.dirname($this->curUrlInfo['info']).'/';
720 if (!isset($this->expandFolder)) $this->expandFolder = $cmpPath;
721 } else {
722 $cmpPath=PATH_site.$this->curUrlInfo['info'];
723 }
724
725 list(,,$specUid) = explode('_',$this->PM);
726 $files = $this->expandFolder($foldertree->specUIDmap[$specUid]);
727
728 // Create upload/create folder forms, if a path is given:
729 if ($BE_USER->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
730 $path=$this->expandFolder;
731 if (!$path || !@is_dir($path)) {
732 $path = $this->fileProcessor->findTempFolder().'/'; // The closest TEMP-path is found
733 }
734 if ($path!='/' && @is_dir($path)) {
735 $uploadForm=$this->uploadForm($path);
736 $createFolder=$this->createFolder($path);
737 } else {
738 $createFolder='';
739 $uploadForm='';
740 }
741 $content.=$uploadForm;
742 if ($BE_USER->isAdmin() || $BE_USER->getTSConfigVal('options.createFoldersInEB')) {
743 $content.=$createFolder;
744 }
745 }
746
747
748
749 $content.= '
750 <!--
751 Wrapper table for folder tree / file list:
752 -->
753 <table border="0" cellpadding="0" cellspacing="0" id="typo3-linkFiles">
754 <tr>
755 <td class="c-wCell" valign="top">'.$this->barheader($LANG->getLL('folderTree').':').$tree.'</td>
756 <td class="c-wCell" valign="top">'.$files.'</td>
757 </tr>
758 </table>
759 ';
760 break;
761 case 'spec':
762 if (is_array($this->thisConfig['userLinks.'])) {
763 $subcats=array();
764 $v=$this->thisConfig['userLinks.'];
765 reset($v);
766 while(list($k2)=each($v)) {
767 $k2i = intval($k2);
768 if (substr($k2,-1)=='.' && is_array($v[$k2i.'.'])) {
769
770 // Title:
771 $title = trim($v[$k2i]);
772 if (!$title) {
773 $title=$v[$k2i.'.']['url'];
774 } else {
775 $title=$LANG->sL($title);
776 }
777 // Description:
778 $description=$v[$k2i.'.']['description'] ? $LANG->sL($v[$k2i.'.']['description'],1).'<br />' : '';
779
780 // URL + onclick event:
781 $onClickEvent='';
782 if (isset($v[$k2i.'.']['target'])) $onClickEvent.="browse_links_setTarget('".$v[$k2i.'.']['target']."');";
783 $v[$k2i.'.']['url'] = str_replace('###_URL###',$this->siteURL,$v[$k2i.'.']['url']);
784 if (substr($v[$k2i.'.']['url'],0,7)=="http://" || substr($v[$k2i.'.']['url'],0,7)=='mailto:') {
785 $onClickEvent.="cur_href=unescape('".rawurlencode($v[$k2i.'.']['url'])."');link_current();";
786 } else {
787 $onClickEvent.="link_spec(unescape('".$this->siteURL.rawurlencode($v[$k2i.'.']['url'])."'));";
788 }
789
790 // Link:
791 $A=array('<a href="#" onclick="'.htmlspecialchars($onClickEvent).'return false;">','</a>');
792
793 // Adding link to menu of user defined links:
794 $subcats[$k2i]='
795 <tr>
796 <td class="bgColor4">'.$A[0].'<strong>'.htmlspecialchars($title).($this->curUrlInfo['info']==$v[$k2i.'.']['url']?'<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/blinkarrow_right.gif','width="5" height="9"').' class="c-blinkArrowR" alt="" />':'').'</strong><br />'.$description.$A[1].'</td>
797 </tr>';
798 }
799 }
800
801 // Sort by keys:
802 ksort($subcats);
803
804 // Add menu to content:
805 $content.= '
806 <!--
807 Special userdefined menu:
808 -->
809 <table border="0" cellpadding="1" cellspacing="1" id="typo3-linkSpecial">
810 <tr>
811 <td class="bgColor5" class="c-wCell" valign="top"><strong>'.$LANG->getLL('special',1).'</strong></td>
812 </tr>
813 '.implode('',$subcats).'
814 </table>
815 ';
816 }
817 break;
818 case 'page':
819 $content.=$this->addAttributesForm();
820
821 $pagetree = t3lib_div::makeInstance('tx_rtehtmlarea_pageTree');
822 $pagetree->ext_showNavTitle = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showNavTitle');
823 $pagetree->addField('nav_title');
824 $tree=$pagetree->getBrowsableTree();
825 $cElements = $this->expandPage();
826 $content.= '
827 <!--
828 Wrapper table for page tree / record list:
829 -->
830 <table border="0" cellpadding="0" cellspacing="0" id="typo3-linkPages">
831 <tr>
832 <td class="c-wCell" valign="top">'.$this->barheader($LANG->getLL('pageTree').':').$tree.'</td>
833 <td class="c-wCell" valign="top">'.$cElements.'</td>
834 </tr>
835 </table>
836 ';
837 break;
838 default:
839 // call hook
840 foreach($this->hookObjects as $hookObject) {
841 $content .= $hookObject->getTab($this->act);
842 }
843
844 break;
845 }
846
847 // End page, return content:
848 $content.= $this->doc->endPage();
849 $content = $this->doc->insertStylesAndJS($content);
850 return $content;
851 }
852
853 function addAttributesForm() {
854 $ltargetForm = '';
855 // Add page id, target, class selector box, title and parameters fields:
856 $lpageId = $this->addPageIdSelector();
857 $queryParameters = $this->addQueryParametersSelector();
858 $ltarget = $this->addTargetSelector();
859 $lclass = $this->addClassSelector();
860 $ltitle = $this->addTitleSelector();
861 if ($lpageId || $queryParameters || $ltarget || $lclass || $ltitle) {
862 $ltargetForm = $this->wrapInForm($lpageId.$queryParameters.$ltarget.$lclass.$ltitle);
863 }
864 return $ltargetForm;
865 }
866
867 function wrapInForm($string) {
868 global $LANG;
869
870 $form = '
871 <!--
872 Selecting target for link:
873 -->
874 <form action="" name="ltargetform" id="ltargetform">
875 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkTarget">'. $string;
876 if ($this->act == $this->curUrlInfo['act'] && $this->act != 'mail' && $this->curUrlArray['href']) {
877 $form .='
878 <tr>
879 <td>
880 </td>
881 <td colspan="3">
882 <input type="submit" value="'.$LANG->getLL('update',1).'" onclick="return link_current();" />
883 </td>
884 </tr>';
885 }
886 $form .= '
887 </table>
888 </form>';
889 return $form;
890 }
891
892 function addPageIdSelector() {
893 global $LANG;
894
895 return ($this->act == 'page' && $this->buttonConfig && is_array($this->buttonConfig['pageIdSelector.']) && $this->buttonConfig['pageIdSelector.']['enabled'])?'
896 <tr>
897 <td>'.$LANG->getLL('page_id',1).':</td>
898 <td colspan="3">
899 <input type="text" size="6" name="luid" />&nbsp;<input type="submit" value="'.$LANG->getLL('setLink',1).'" onclick="return link_typo3Page(document.ltargetform.luid.value);" />
900 </td>
901 </tr>':'';
902 }
903
904 function addQueryParametersSelector() {
905 global $LANG;
906
907 return ($this->act == 'page' && $this->buttonConfig && is_array($this->buttonConfig['queryParametersSelector.']) && $this->buttonConfig['queryParametersSelector.']['enabled'])?'
908 <tr>
909 <td>'.$LANG->getLL('query_parameters',1).':</td>
910 <td colspan="3">
911 <input type="text" name="query_parameters" value="' . ($this->curUrlInfo['query']?$this->curUrlInfo['query']:'') . '" ' . $this->doc->formWidth(30) . ' />
912 </td>
913 </tr>':'';
914 }
915
916 function addTargetSelector() {
917 global $LANG;
918
919 $targetSelectorConfig = array();
920 $popupSelectorConfig = array();
921 if (is_array($this->buttonConfig['targetSelector.'])) {
922 $targetSelectorConfig = $this->buttonConfig['targetSelector.'];
923 }
924 if (is_array($this->buttonConfig['popupSelector.'])) {
925 $popupSelectorConfig = $this->buttonConfig['popupSelector.'];
926 }
927
928 $ltarget = '';
929 if ($this->act != 'mail') {
930 $ltarget .= '
931 <tr id="ltargetrow"'. (($targetSelectorConfig['disabled'] && $popupSelectorConfig['disabled']) ? ' style="display: none;"' : '') . '>
932 <td>'.$LANG->getLL('target',1).':</td>
933 <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>';
934 $ltarget .= '
935 <td colspan="2">';
936 if (!$targetSelectorConfig['disabled']) {
937 $ltarget .= '
938 <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;">
939 <option></option>
940 <option value="_top">'.$LANG->getLL('top',1).'</option>
941 <option value="_blank">'.$LANG->getLL('newWindow',1).'</option>
942 </select>';
943 }
944 $ltarget .= '
945 </td>
946 </tr>';
947 if (!$popupSelectorConfig['disabled']) {
948
949 $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) {
950 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;
951 browse_links_setTarget(document.ltargetform.ltarget.value);
952 document.ltargetform.popup_width.selectedIndex=0;
953 document.ltargetform.popup_height.selectedIndex=0;
954 }';
955
956 $ltarget.='
957 <tr>
958 <td>'.$LANG->getLL('target_popUpWindow',1).':</td>
959 <td colspan="3">
960 <select name="popup_width" onchange="'.$selectJS.'">
961 <option value="0">'.$LANG->getLL('target_popUpWindow_width',1).'</option>
962 <option value="300">300</option>
963 <option value="400">400</option>
964 <option value="500">500</option>
965 <option value="600">600</option>
966 <option value="700">700</option>
967 <option value="800">800</option>
968 </select>
969 x
970 <select name="popup_height" onchange="'.$selectJS.'">
971 <option value="0">'.$LANG->getLL('target_popUpWindow_height',1).'</option>
972 <option value="200">200</option>
973 <option value="300">300</option>
974 <option value="400">400</option>
975 <option value="500">500</option>
976 <option value="600">600</option>
977 </select>
978 </td>
979 </tr>';
980 }
981 }
982 return $ltarget;
983 }
984
985 /**
986 * Return html code for the class selector
987 *
988 * @return string the html code to be added to the form
989 */
990 public function addClassSelector() {
991 $selectClass = '';
992 if ($this->classesAnchorJSOptions[$this->act]) {
993 $selectClass ='
994 <tr>
995 <td>'.$GLOBALS['LANG']->getLL('anchor_class',1).':</td>
996 <td colspan="3">
997 <select name="anchor_class" onchange="'.$this->getClassOnChangeJS().'">
998 ' . $this->classesAnchorJSOptions[$this->act] . '
999 </select>
1000 </td>
1001 </tr>';
1002 }
1003 return $selectClass;
1004 }
1005
1006 /**
1007 * Return JS code for the class selector onChange event
1008 *
1009 * @return string class selector onChange JS code
1010 */
1011 public function getClassOnChangeJS() {
1012 return '
1013 if (document.ltargetform.anchor_class) {
1014 document.ltargetform.anchor_class.value = document.ltargetform.anchor_class.options[document.ltargetform.anchor_class.selectedIndex].value;
1015 if (document.ltargetform.anchor_class.value && HTMLArea.classesAnchorSetup) {
1016 for (var i = HTMLArea.classesAnchorSetup.length; --i >= 0;) {
1017 var anchorClass = HTMLArea.classesAnchorSetup[i];
1018 if (anchorClass[\'name\'] == document.ltargetform.anchor_class.value) {
1019 if (anchorClass[\'titleText\'] && document.ltargetform.anchor_title) {
1020 document.ltargetform.anchor_title.value = anchorClass[\'titleText\'];
1021 document.getElementById(\'rtehtmlarea-browse-links-title-readonly\').innerHTML = anchorClass[\'titleText\'];
1022 browse_links_setTitle(anchorClass[\'titleText\']);
1023 }
1024 if (anchorClass[\'target\']) {
1025 if (document.ltargetform.ltarget) {
1026 document.ltargetform.ltarget.value = anchorClass[\'target\'];
1027 }
1028 browse_links_setTarget(anchorClass[\'target\']);
1029 } else if (document.ltargetform.ltarget && document.getElementById(\'ltargetrow\').style.display == \'none\') {
1030 // Reset target to default if field is not displayed and class has no configured target
1031 document.ltargetform.ltarget.value = \''. ($this->thisConfig['defaultLinkTarget']?$this->thisConfig['defaultLinkTarget']:'') .'\';
1032 browse_links_setTarget(document.ltargetform.ltarget.value);
1033 }
1034 break;
1035 }
1036 }
1037 }
1038 browse_links_setClass(document.ltargetform.anchor_class.value);
1039 }
1040 ';
1041 }
1042
1043 function addTitleSelector() {
1044 $title = ($this->setTitle ? $this->setTitle : (($this->setClass || !$this->classesAnchorDefault[$this->act]) ? '' : $this->classesAnchorDefaultTitle[$this->act]));
1045 $readOnly = $this->buttonConfig['properties.']['title.']['readOnly'] || $this->buttonConfig[$this->act.'.']['properties.']['title.']['readOnly'];
1046 if ($readOnly) {
1047 $title = $this->setClass ? $this->classesAnchorClassTitle[$this->setClass] : $this->classesAnchorDefaultTitle[$this->act];
1048 }
1049 return '
1050 <tr>
1051 <td><label for="rtehtmlarea-browse-links-anchor_title" id="rtehtmlarea-browse-links-title-label">' . $GLOBALS['LANG']->getLL('anchor_title',1) . ':</label></td>
1052 <td colspan="3">
1053 <span id="rtehtmlarea-browse-links-title-input" style="display: ' . ($readOnly ? 'none' : 'inline') . ';">
1054 <input type="text" id="rtehtmlarea-browse-links-anchor_title" name="anchor_title" value="' . $title . '" ' . $this->doc->formWidth(30) . ' />
1055 </span>
1056 <span id="rtehtmlarea-browse-links-title-readonly" style="display: ' . ($readOnly ? 'inline' : 'none') . ';">' . $title . '</span>
1057 </td>
1058 </tr>';
1059 }
1060
1061 /**
1062 * Localize a string using the language of the content element rather than the language of the BE interface
1063 *
1064 * @param string string: the label to be localized
1065 * @return string Localized string.
1066 */
1067 public function getLLContent($string) {
1068 global $LANG;
1069
1070 $BE_lang = $LANG->lang;
1071 $BE_origCharSet = $LANG->origCharSet;
1072 $BE_charSet = $LANG->charSet;
1073
1074 $LANG->lang = $this->contentTypo3Language;
1075 $LANG->origCharSet = $LANG->csConvObj->charSetArray[$this->contentTypo3Language];
1076 $LANG->origCharSet = $LANG->origCharSet ? $LANG->origCharSet : 'iso-8859-1';
1077 $LANG->charSet = $this->contentTypo3Charset;
1078 $LLString = $LANG->sL($string);
1079
1080 $LANG->lang = $BE_lang;
1081 $LANG->origCharSet = $BE_origCharSet;
1082 $LANG->charSet = $BE_charSet;
1083 return $LLString;
1084 }
1085
1086 /**
1087 * Localize a label obtained from Page TSConfig
1088 *
1089 * @param string string: the label to be localized
1090 * @return string Localized string.
1091 */
1092 public function getPageConfigLabel($string,$JScharCode=1) {
1093 global $LANG;
1094 if (strcmp(substr($string,0,4),'LLL:')) {
1095 $label = $string;
1096 } else {
1097 $label = $LANG->sL(trim($string));
1098 }
1099 $label = str_replace('"', '\"', str_replace('\\\'', '\'', $label));
1100 $label = $JScharCode ? $LANG->JScharCode($label): $label;
1101 return $label;
1102 }
1103
1104 }
1105
1106 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php']) {
1107 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php']);
1108 }
1109
1110 ?>