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