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