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