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