[BUGFIX] Adjustments to FAL-enabled RTE image and link dialogues
[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 require_once (PATH_typo3.'class.browse_links.php');
40
41
42 /**
43 * Class which generates the page tree
44 *
45 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
46 * @package TYPO3
47 * @subpackage core
48 */
49 class tx_rtehtmlarea_pageTree extends rtePageTree {
50
51 /**
52 * Create the page navigation tree in HTML
53 *
54 * @param array Tree array
55 * @return string HTML output.
56 */
57 function printTree($treeArr='') {
58 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
59 if (!is_array($treeArr)) $treeArr=$this->tree;
60
61 $out='';
62 $c=0;
63
64 foreach($treeArr as $k => $v) {
65 $c++;
66 $bgColorClass = ($c+1)%2 ? 'bgColor' : 'bgColor-10';
67 if ($GLOBALS['SOBE']->browser->curUrlInfo['act']=='page' && $GLOBALS['SOBE']->browser->curUrlInfo['pageid']==$v['row']['uid'] && $GLOBALS['SOBE']->browser->curUrlInfo['pageid']) {
68 $arrCol = '<td><img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/blinkarrow_right.gif', 'width="5" height="9"') . ' class="c-blinkArrowR" alt="" /></td>';
69 $bgColorClass='bgColor4';
70 } else {
71 $arrCol='<td></td>';
72 }
73
74 $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'].'\');';
75 $cEbullet = ($this->ext_isLinkable($v['row']['doktype'], $v['row']['uid'])
76 ? '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '"><img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/ol/arrowbullet.gif', 'width="18" height="16"') . ' alt="" /></a>'
77 : '');
78 $out.='
79 <tr class="'.$bgColorClass.'">
80 <td nowrap="nowrap"'.($v['row']['_CSSCLASS'] ? ' class="'.$v['row']['_CSSCLASS'].'"' : '').'>'.
81 $v['HTML'].
82 $this->wrapTitle($this->getTitleStr($v['row'],$titleLen),$v['row'],$this->ext_pArrPages).
83 '</td>'.
84 $arrCol.
85 '<td>'.$cEbullet.'</td>
86 </tr>';
87 }
88 $out='
89
90
91 <!--
92 Navigation Page Tree:
93 -->
94 <table border="0" cellpadding="0" cellspacing="0" id="typo3-tree">
95 '.$out.'
96 </table>';
97 return $out;
98 }
99 }
100
101 /**
102 * Base extension class which generates the folder tree.
103 * Used directly by the RTE.
104 *
105 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
106 * @package TYPO3
107 * @subpackage core
108 */
109 class tx_rtehtmlarea_folderTree extends rteFolderTree {
110
111 /**
112 * Wrapping the title in a link, if applicable.
113 *
114 * @param string Title, ready for output.
115 * @param t3lib_file_Folder The "record"
116 * @return string Wrapping title string.
117 */
118 function wrapTitle ($title, t3lib_file_Folder $folderObject) {
119 if ($this->ext_isLinkable($folderObject)) {
120 $aOnClick = 'return jumpToUrl(\'' . $this->thisScript .
121 '?act=' . $GLOBALS['SOBE']->browser->act .
122 '&mode=' . $GLOBALS['SOBE']->browser->mode .
123 '&editorNo=' . $GLOBALS['SOBE']->browser->editorNo .
124 '&contentTypo3Language=' . $GLOBALS['SOBE']->browser->contentTypo3Language .
125 '&contentTypo3Charset=' . $GLOBALS['SOBE']->browser->contentTypo3Charset .
126 '&expandFolder=' . rawurlencode($folderObject->getCombinedIdentifier()) . '\');';
127 return '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '">' . $title . '</a>';
128 } else {
129 return '<span class="typo3-dimmed">' . $title . '</span>';
130 }
131 }
132
133 /**
134 * Wrap the plus/minus icon in a link
135 *
136 * @param string HTML string to wrap, probably an image tag.
137 * @param string Command for 'PM' get var
138 * @return string Link-wrapped input string
139 * @access private
140 */
141 public function PMiconATagWrap ($icon, $cmd, $isExpand = TRUE) {
142 if ($this->thisScript) {
143 $js = htmlspecialchars('Tree.thisScript=\'' . $GLOBALS['BACK_PATH'] . 'ajax.php\',Tree.load(\'' . $cmd . '\', ' . intval($isExpand) . ', this);');
144 return '<a class="pm" onclick="' . $js . '">' . $icon . '</a>';
145 } else {
146 return $icon;
147 }
148 }
149 }
150
151 /**
152 * Script class for the Element Browser window.
153 *
154 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
155 * @package TYPO3
156 * @subpackage core
157 */
158 class tx_rtehtmlarea_browse_links extends browse_links {
159
160 public $editorNo;
161 public $contentTypo3Language;
162 public $contentTypo3Charset = 'utf-8';
163 public $additionalAttributes = array();
164 public $buttonConfig = array();
165 public $RTEProperties = array();
166
167 public $anchorTypes = array( 'page', 'url', 'file', 'mail', 'spec');
168 public $classesAnchorDefault = array();
169 public $classesAnchorDefaultTitle = array();
170 public $classesAnchorClassTitle = array();
171 public $classesAnchorDefaultTarget = array();
172 public $classesAnchorJSOptions = array();
173 protected $defaultLinkTarget;
174
175 public $allowedItems;
176
177 /**
178 * Constructor:
179 * Initializes a lot of variables, setting JavaScript functions in header etc.
180 *
181 * @return void
182 */
183 function init() {
184 $this->initVariables();
185 $this->initConfiguration();
186 // init fileProcessor
187 $this->fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
188 $this->fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
189 // Creating backend template object:
190 $this->doc = t3lib_div::makeInstance('template');
191 $this->doc->backPath = $GLOBALS['BACK_PATH'];
192 // Loading the Prototype library and browse_links.js
193 $this->doc->getPageRenderer()->loadPrototype();
194 $this->doc->loadJavascriptLib('js/tree.js');
195 $this->doc->loadJavascriptLib('js/browse_links.js');
196 // Adding context menu code
197 $this->doc->getContextMenuCode();
198 // Initializing hooking browsers
199 $this->initHookObjects('ext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php');
200 // CurrentUrl - the current link url must be passed around if it exists
201 $this->curUrlArray = t3lib_div::_GP('curUrl');
202 if ($this->curUrlArray['all']) {
203 $this->curUrlArray = t3lib_div::get_tag_attributes($this->curUrlArray['all']);
204 $this->curUrlArray['href'] = htmlspecialchars_decode($this->curUrlArray['href']);
205 }
206 // Note: parseCurUrl will invoke the hooks
207 $this->curUrlInfo = $this->parseCurUrl($this->curUrlArray['href'], $this->siteURL);
208 if (isset($this->curUrlArray['data-htmlarea-external']) && $this->curUrlInfo['act'] != 'mail') {
209 $this->curUrlInfo['act'] = 'url';
210 $this->curUrlInfo['info'] = $this->curUrlArray['href'];
211 }
212 // Determine nature of current url:
213 $this->act = t3lib_div::_GP('act');
214 if (!$this->act) {
215 $this->act = $this->curUrlInfo['act'];
216 }
217 // Setting intial values for link attributes
218 $this->initLinkAttributes();
219 // Apply the same styles as those of the base script
220 $this->doc->bodyTagId = 'typo3-browse-links-php';
221 // Add attributes to body tag. Note: getBodyTagAdditions will invoke the hooks
222 $this->doc->bodyTagAdditions = $this->getBodyTagAdditions();
223 // Adding RTE JS code
224 $this->doc->JScodeArray['rtehtmlarea'] = $this->getJSCode();
225 }
226
227 /**
228 * Initialize class variables
229 *
230 * @return void
231 */
232 public function initVariables() {
233
234 // Main GPvars:
235 $this->pointer = t3lib_div::_GP('pointer');
236 $this->bparams = t3lib_div::_GP('bparams');
237 $this->P = t3lib_div::_GP('P');
238 $this->expandPage = t3lib_div::_GP('expandPage');
239 $this->expandFolder = t3lib_div::_GP('expandFolder');
240 $this->PM = t3lib_div::_GP('PM');
241
242 // Process bparams
243 $pArr = explode('|', $this->bparams);
244 $pRteArr = explode(':', $pArr[1]);
245 $this->editorNo = $pRteArr[0];
246 $this->contentTypo3Language = $pRteArr[1];
247 $this->RTEtsConfigParams = $pArr[2];
248 if (!$this->editorNo) {
249 $this->editorNo = t3lib_div::_GP('editorNo');
250 $this->contentTypo3Language = t3lib_div::_GP('contentTypo3Language');
251 $this->RTEtsConfigParams = t3lib_div::_GP('RTEtsConfigParams');
252 }
253 $pArr[1] = implode(':', array($this->editorNo, $this->contentTypo3Language, $this->contentTypo3Charset));
254 $pArr[2] = $this->RTEtsConfigParams;
255 $this->bparams = implode('|', $pArr);
256
257 // Find "mode"
258 $this->mode = t3lib_div::_GP('mode');
259 if (!$this->mode) {
260 $this->mode = 'rte';
261 }
262 // Current site url
263 $this->siteURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL');
264
265 // the script to link to
266 $this->thisScript = t3lib_div::getIndpEnv('SCRIPT_NAME');
267 }
268
269 /**
270 * Initializes the configuration variables
271 *
272 * @return void
273 */
274 public function initConfiguration() {
275 $this->thisConfig = $this->getRTEConfig();
276 $this->buttonConfig = $this->getButtonConfig('link');
277 }
278
279 /**
280 * Get the RTE configuration from Page TSConfig
281 *
282 * @return array RTE configuration array
283 */
284 protected function getRTEConfig() {
285 $RTEtsConfigParts = explode(':', $this->RTEtsConfigParams);
286 $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE', t3lib_BEfunc::getPagesTSconfig($RTEtsConfigParts[5]));
287 $this->RTEProperties = $RTEsetup['properties'];
288 return t3lib_BEfunc::RTEsetup($this->RTEProperties, $RTEtsConfigParts[0],$RTEtsConfigParts[2],$RTEtsConfigParts[4]);
289 }
290
291 /**
292 * Get the configuration of the button
293 *
294 * @param string $buttonName: the name of the button
295 * @return array the configuration array of the image button
296 */
297 protected function getButtonConfig($buttonName) {
298 return ((is_array($this->thisConfig['buttons.']) && is_array($this->thisConfig['buttons.'][$buttonName.'.'])) ? $this->thisConfig['buttons.'][$buttonName.'.'] : array());
299 }
300
301 /**
302 * Initialize hook objects implementing interface t3lib_browseLinksHook
303 * @param string $hookKey: the hook key
304 * @return void
305 */
306 protected function initHookObjects($hookKey) {
307 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][$hookKey]['browseLinksHook'])) {
308 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][$hookKey]['browseLinksHook'] as $classData) {
309 $processObject = t3lib_div::getUserObj($classData);
310 if(!($processObject instanceof t3lib_browseLinksHook)) {
311 throw new UnexpectedValueException('$processObject must implement interface t3lib_browseLinksHook', 1195115652);
312 }
313 $parameters = array();
314 $processObject->init($this, $parameters);
315 $this->hookObjects[] = $processObject;
316 }
317 }
318 }
319
320 /**
321 * Initialize the current or default values of the link attributes
322 *
323 * @return void
324 */
325 protected function initLinkAttributes() {
326
327 // Initializing the title value
328 $this->setTitle = $this->curUrlArray['title'];
329
330 // Processing the classes configuration
331 $classSelected = array();
332 if ($this->buttonConfig['properties.']['class.']['allowedClasses']) {
333 $this->setClass = $this->curUrlArray['class'];
334 $classesAnchorArray = t3lib_div::trimExplode(',', $this->buttonConfig['properties.']['class.']['allowedClasses'], 1);
335 $classesAnchorConfigArray = array();
336 // Collecting allowed classes and configured default values
337 $classesAnchor = array();
338 $classesAnchor['all'] = array();
339 $titleReadOnly = $this->buttonConfig['properties.']['title.']['readOnly'] || $this->buttonConfig[$this->act.'.']['properties.']['title.']['readOnly'];
340 if (is_array($this->RTEProperties['classesAnchor.'])) {
341 foreach ($this->RTEProperties['classesAnchor.'] as $label => $conf) {
342 if (in_array($conf['class'], $classesAnchorArray)) {
343 $classesAnchor['all'][] = $conf['class'];
344 if (in_array($conf['type'], $this->anchorTypes)) {
345 $classesAnchor[$conf['type']][] = $conf['class'];
346 if ($this->buttonConfig[$conf['type']. '.']['properties.']['class.']['default'] == $conf['class']) {
347 $this->classesAnchorDefault[$conf['type']] = $conf['class'];
348 if ($conf['titleText']) {
349 $this->classesAnchorDefaultTitle[$conf['type']] = $this->getLLContent(trim($conf['titleText']));
350 }
351 if ($conf['target']) {
352 $this->classesAnchorDefaultTarget[$conf['type']] = trim($conf['target']);
353 }
354 }
355 }
356 if ($titleReadOnly && $conf['titleText']) {
357 $this->classesAnchorClassTitle[$conf['class']] = $this->classesAnchorDefaultTitle[$conf['type']] = $this->getLLContent(trim($conf['titleText']));
358 }
359 }
360 }
361 }
362 // Constructing the class selector options
363 foreach ($this->anchorTypes as $anchorType) {
364 foreach ($classesAnchorArray as $class) {
365 if (!in_array($class, $classesAnchor['all']) || (in_array($class, $classesAnchor['all']) && is_array($classesAnchor[$anchorType]) && in_array($class, $classesAnchor[$anchorType]))) {
366 $selected = '';
367 if ($this->setClass == $class || (!$this->setClass && $this->classesAnchorDefault[$anchorType] == $class)) {
368 $selected = 'selected="selected"';
369 $classSelected[$anchorType] = TRUE;
370 }
371 $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;
372 $classStyle = (is_array($this->RTEProperties['classes.']) && is_array($this->RTEProperties['classes.'][$class.'.']) && $this->RTEProperties['classes.'][$class.'.']['value']) ? $this->RTEProperties['classes.'][$class.'.']['value'] : '';
373 $this->classesAnchorJSOptions[$anchorType] .= '<option ' . $selected . ' value="' .$class . '"' . ($classStyle?' style="'.$classStyle.'"':'') . '>' . $classLabel . '</option>';
374 }
375 }
376 if ($this->classesAnchorJSOptions[$anchorType] && !($this->buttonConfig['properties.']['class.']['required'] || $this->buttonConfig[$this->act.'.']['properties.']['class.']['required'])) {
377 $selected = '';
378 if (!$this->setClass && !$this->classesAnchorDefault[$anchorType]) $selected = 'selected="selected"';
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'])) $onClickEvent.="browse_links_setTarget('".$v[$k2i.'.']['target']."');";
786 $v[$k2i.'.']['url'] = str_replace('###_URL###',$this->siteURL,$v[$k2i.'.']['url']);
787 if (substr($v[$k2i.'.']['url'],0,7)=="http://" || substr($v[$k2i.'.']['url'],0,7)=='mailto:') {
788 $onClickEvent.="cur_href=unescape('".rawurlencode($v[$k2i.'.']['url'])."');link_current();";
789 } else {
790 $onClickEvent.="link_spec(unescape('".$this->siteURL.rawurlencode($v[$k2i.'.']['url'])."'));";
791 }
792
793 // Link:
794 $A=array('<a href="#" onclick="'.htmlspecialchars($onClickEvent).'return false;">','</a>');
795
796 // Adding link to menu of user defined links:
797 $subcats[$k2i]='
798 <tr>
799 <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>
800 </tr>';
801 }
802 }
803
804 // Sort by keys:
805 ksort($subcats);
806
807 // Add menu to content:
808 $content.= '
809 <!--
810 Special userdefined menu:
811 -->
812 <table border="0" cellpadding="1" cellspacing="1" id="typo3-linkSpecial">
813 <tr>
814 <td class="bgColor5" class="c-wCell" valign="top"><strong>' . $GLOBALS['LANG']->getLL('special', 1) . '</strong></td>
815 </tr>
816 '.implode('',$subcats).'
817 </table>
818 ';
819 }
820 break;
821 case 'page':
822 $content.=$this->addAttributesForm();
823
824 $pagetree = t3lib_div::makeInstance('tx_rtehtmlarea_pageTree');
825 $pagetree->ext_showNavTitle = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showNavTitle');
826 $pagetree->ext_showPageId = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showPageIdWithTitle');
827 $pagetree->addField('nav_title');
828 $tree=$pagetree->getBrowsableTree();
829 $cElements = $this->expandPage();
830
831
832 // Outputting Temporary DB mount notice:
833 if (intval($GLOBALS['BE_USER']->getSessionData('pageTree_temporaryMountPoint'))) {
834 $link = '<a href="' . htmlspecialchars(t3lib_div::linkThisScript(array('setTempDBmount' => 0))) . '">' .
835 $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_core.xml:labels.temporaryDBmount', 1) .
836 '</a>';
837 $flashMessage = t3lib_div::makeInstance(
838 't3lib_FlashMessage',
839 $link,
840 '',
841 t3lib_FlashMessage::INFO
842 );
843 $dbmount = $flashMessage->render();
844 }
845
846 $content .= '
847 <!--
848 Wrapper table for page tree / record list:
849 -->
850 <table border="0" cellpadding="0" cellspacing="0" id="typo3-linkPages">
851 <tr>
852 <td class="c-wCell" valign="top">' . $this->barheader($GLOBALS['LANG']->getLL('pageTree') . ':') . $dbmount . $tree . '</td>
853 <td class="c-wCell" valign="top">' . $cElements . '</td>
854 </tr>
855 </table>
856 ';
857 break;
858 default:
859 // call hook
860 foreach($this->hookObjects as $hookObject) {
861 $content .= $hookObject->getTab($this->act);
862 }
863
864 break;
865 }
866
867 // End page, return content:
868 $content.= $this->doc->endPage();
869 $content = $this->doc->insertStylesAndJS($content);
870 return $content;
871 }
872
873 /**
874 * Creates a form for link attributes
875 *
876 * @return string The HTML code of the form
877 */
878 public function addAttributesForm() {
879 $ltargetForm = '';
880 $additionalAttributeFields = '';
881 // Add page id, target, class selector box, title and parameters fields:
882 $lpageId = $this->addPageIdSelector();
883 $queryParameters = $this->addQueryParametersSelector();
884 $ltarget = $this->addTargetSelector();
885 $lclass = $this->addClassSelector();
886 $ltitle = $this->addTitleSelector();
887 $rel = $this->addRelField();
888
889 // additional fields for links
890 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'])) {
891 $_params = array(
892 'conf' => &$conf
893 );
894 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php']['addAttributeFields'] as $objRef) {
895 $processor = &t3lib_div::getUserObj($objRef);
896 $additionalAttributeFields .= $processor->getAttributefields( $_params, $this);
897 }
898 }
899
900 if ($lpageId || $queryParameters || $ltarget || $lclass || $ltitle || $rel) {
901 $ltargetForm = $this->wrapInForm($lpageId . $queryParameters . $ltarget . $lclass . $ltitle . $rel . $additionalAttributeFields);
902 }
903 return $ltargetForm;
904 }
905
906 function wrapInForm($string) {
907
908 $form = '
909 <!--
910 Selecting target for link:
911 -->
912 <form action="" name="ltargetform" id="ltargetform">
913 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkTarget">'. $string;
914 if ($this->act == $this->curUrlInfo['act'] && $this->act != 'mail' && $this->curUrlArray['href']) {
915 $form .='
916 <tr>
917 <td>
918 </td>
919 <td colspan="3">
920 <input type="submit" value="' . $GLOBALS['LANG']->getLL('update',1) . '" onclick="' . (($this->act == 'url') ? 'browse_links_setAdditionalValue(\'data-htmlarea-external\', \'1\'); ' : '') . 'return link_current();" />
921 </td>
922 </tr>';
923 }
924 $form .= '
925 </table>
926 </form>';
927 return $form;
928 }
929
930 function addPageIdSelector() {
931
932 return ($this->act == 'page' && $this->buttonConfig && is_array($this->buttonConfig['pageIdSelector.']) && $this->buttonConfig['pageIdSelector.']['enabled'])?'
933 <tr>
934 <td>' . $GLOBALS['LANG']->getLL('page_id',1) . ':</td>
935 <td colspan="3">
936 <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);" />
937 </td>
938 </tr>':'';
939 }
940
941 function addRelField() {
942 return (($this->act == 'page' || $this->act == 'url' || $this->act == 'file') && $this->buttonConfig && is_array($this->buttonConfig['relAttribute.']) && $this->buttonConfig['relAttribute.']['enabled'])?'
943 <tr>
944 <td>'.$GLOBALS['LANG']->getLL('linkRelationship',1).':</td>
945 <td colspan="3">
946 <input type="text" name="lrel" value="' . $this->additionalAttributes['rel']. '" ' . $this->doc->formWidth(30) . ' />
947 </td>
948 </tr>':'';
949 }
950
951 function addQueryParametersSelector() {
952
953 return ($this->act == 'page' && $this->buttonConfig && is_array($this->buttonConfig['queryParametersSelector.']) && $this->buttonConfig['queryParametersSelector.']['enabled'])?'
954 <tr>
955 <td>' . $GLOBALS['LANG']->getLL('query_parameters', 1) . ':</td>
956 <td colspan="3">
957 <input type="text" name="query_parameters" value="' . ($this->curUrlInfo['query']?$this->curUrlInfo['query']:'') . '" ' . $this->doc->formWidth(30) . ' />
958 </td>
959 </tr>':'';
960 }
961
962 function addTargetSelector() {
963
964 $targetSelectorConfig = array();
965 $popupSelectorConfig = array();
966 if (is_array($this->buttonConfig['targetSelector.'])) {
967 $targetSelectorConfig = $this->buttonConfig['targetSelector.'];
968 }
969 if (is_array($this->buttonConfig['popupSelector.'])) {
970 $popupSelectorConfig = $this->buttonConfig['popupSelector.'];
971 }
972
973 $ltarget = '';
974 if ($this->act != 'mail') {
975 $ltarget .= '
976 <tr id="ltargetrow"'. (($targetSelectorConfig['disabled'] && $popupSelectorConfig['disabled']) ? ' style="display: none;"' : '') . '>
977 <td>' . $GLOBALS['LANG']->getLL('target', 1) . ':</td>
978 <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>';
979 $ltarget .= '
980 <td colspan="2">';
981 if (!$targetSelectorConfig['disabled']) {
982 $ltarget .= '
983 <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;">
984 <option></option>
985 <option value="_top">' . $GLOBALS['LANG']->getLL('top', 1) . '</option>
986 <option value="_blank">' . $GLOBALS['LANG']->getLL('newWindow', 1) . '</option>
987 </select>';
988 }
989 $ltarget .= '
990 </td>
991 </tr>';
992 if (!$popupSelectorConfig['disabled']) {
993
994 $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) {
995 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;
996 browse_links_setTarget(document.ltargetform.ltarget.value);
997 document.ltargetform.popup_width.selectedIndex=0;
998 document.ltargetform.popup_height.selectedIndex=0;
999 }';
1000
1001 $ltarget.='
1002 <tr>
1003 <td>' . $GLOBALS['LANG']->getLL('target_popUpWindow', 1) . ':</td>
1004 <td colspan="3">
1005 <select name="popup_width" onchange="'.$selectJS.'">
1006 <option value="0">' . $GLOBALS['LANG']->getLL('target_popUpWindow_width', 1) . '</option>
1007 <option value="300">300</option>
1008 <option value="400">400</option>
1009 <option value="500">500</option>
1010 <option value="600">600</option>
1011 <option value="700">700</option>
1012 <option value="800">800</option>
1013 </select>
1014 x
1015 <select name="popup_height" onchange="'.$selectJS.'">
1016 <option value="0">' . $GLOBALS['LANG']->getLL('target_popUpWindow_height', 1) . '</option>
1017 <option value="200">200</option>
1018 <option value="300">300</option>
1019 <option value="400">400</option>
1020 <option value="500">500</option>
1021 <option value="600">600</option>
1022 </select>
1023 </td>
1024 </tr>';
1025 }
1026 }
1027 return $ltarget;
1028 }
1029
1030 /**
1031 * Return html code for the class selector
1032 *
1033 * @return string the html code to be added to the form
1034 */
1035 public function addClassSelector() {
1036 $selectClass = '';
1037 if ($this->classesAnchorJSOptions[$this->act]) {
1038 $selectClass ='
1039 <tr>
1040 <td>'.$GLOBALS['LANG']->getLL('anchor_class',1).':</td>
1041 <td colspan="3">
1042 <select name="anchor_class" onchange="'.$this->getClassOnChangeJS().'">
1043 ' . $this->classesAnchorJSOptions[$this->act] . '
1044 </select>
1045 </td>
1046 </tr>';
1047 }
1048 return $selectClass;
1049 }
1050
1051 /**
1052 * Return JS code for the class selector onChange event
1053 *
1054 * @return string class selector onChange JS code
1055 */
1056 public function getClassOnChangeJS() {
1057 return '
1058 if (document.ltargetform.anchor_class) {
1059 document.ltargetform.anchor_class.value = document.ltargetform.anchor_class.options[document.ltargetform.anchor_class.selectedIndex].value;
1060 if (document.ltargetform.anchor_class.value && HTMLArea.classesAnchorSetup) {
1061 for (var i = HTMLArea.classesAnchorSetup.length; --i >= 0;) {
1062 var anchorClass = HTMLArea.classesAnchorSetup[i];
1063 if (anchorClass[\'name\'] == document.ltargetform.anchor_class.value) {
1064 if (anchorClass[\'titleText\'] && document.ltargetform.anchor_title) {
1065 document.ltargetform.anchor_title.value = anchorClass[\'titleText\'];
1066 document.getElementById(\'rtehtmlarea-browse-links-title-readonly\').innerHTML = anchorClass[\'titleText\'];
1067 browse_links_setTitle(anchorClass[\'titleText\']);
1068 }
1069 if (anchorClass[\'target\']) {
1070 if (document.ltargetform.ltarget) {
1071 document.ltargetform.ltarget.value = anchorClass[\'target\'];
1072 }
1073 browse_links_setTarget(anchorClass[\'target\']);
1074 } else if (document.ltargetform.ltarget && document.getElementById(\'ltargetrow\').style.display == \'none\') {
1075 // Reset target to default if field is not displayed and class has no configured target
1076 document.ltargetform.ltarget.value = \''. ($this->defaultLinkTarget ? $this->defaultLinkTarget : '') .'\';
1077 browse_links_setTarget(document.ltargetform.ltarget.value);
1078 }
1079 break;
1080 }
1081 }
1082 }
1083 browse_links_setClass(document.ltargetform.anchor_class.value);
1084 }
1085 ';
1086 }
1087
1088 function addTitleSelector() {
1089 $title = ($this->setTitle ? $this->setTitle : (($this->setClass || !$this->classesAnchorDefault[$this->act]) ? '' : $this->classesAnchorDefaultTitle[$this->act]));
1090 $readOnly = $this->buttonConfig['properties.']['title.']['readOnly'] || $this->buttonConfig[$this->act.'.']['properties.']['title.']['readOnly'];
1091 if ($readOnly) {
1092 $title = $this->setClass ? $this->classesAnchorClassTitle[$this->setClass] : $this->classesAnchorDefaultTitle[$this->act];
1093 }
1094 return '
1095 <tr>
1096 <td><label for="rtehtmlarea-browse-links-anchor_title" id="rtehtmlarea-browse-links-title-label">' . $GLOBALS['LANG']->getLL('anchor_title',1) . ':</label></td>
1097 <td colspan="3">
1098 <span id="rtehtmlarea-browse-links-title-input" style="display: ' . ($readOnly ? 'none' : 'inline') . ';">
1099 <input type="text" id="rtehtmlarea-browse-links-anchor_title" name="anchor_title" value="' . $title . '" ' . $this->doc->formWidth(30) . ' />
1100 </span>
1101 <span id="rtehtmlarea-browse-links-title-readonly" style="display: ' . ($readOnly ? 'inline' : 'none') . ';">' . $title . '</span>
1102 </td>
1103 </tr>';
1104 }
1105
1106 /**
1107 * Localize a string using the language of the content element rather than the language of the BE interface
1108 *
1109 * @param string string: the label to be localized
1110 * @return string Localized string.
1111 */
1112 public function getLLContent($string) {
1113 $BE_lang = $GLOBALS['LANG']->lang;
1114
1115 $GLOBALS['LANG']->lang = $this->contentTypo3Language;
1116 $LLString = $GLOBALS['LANG']->sL($string);
1117
1118 $GLOBALS['LANG']->lang = $BE_lang;
1119 return $LLString;
1120 }
1121
1122 /**
1123 * Localize a label obtained from Page TSConfig
1124 *
1125 * @param string string: the label to be localized
1126 * @return string Localized string.
1127 */
1128 public function getPageConfigLabel($string,$JScharCode=1) {
1129 if (strcmp(substr($string,0,4),'LLL:')) {
1130 $label = $string;
1131 } else {
1132 $label = $GLOBALS['LANG']->sL(trim($string));
1133 }
1134 $label = str_replace('"', '\"', str_replace('\\\'', '\'', $label));
1135 $label = $JScharCode ? $GLOBALS['LANG']->JScharCode($label): $label;
1136 return $label;
1137 }
1138 }
1139 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php'])) {
1140 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php']);
1141 }
1142 ?>