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