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