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