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