* Fixed bug #8716: htmlArea RTE: target configured on link class not honoured
[Packages/TYPO3.CMS.git] / typo3 / sysext / rtehtmlarea / mod3 / class.tx_rtehtmlarea_browse_links.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2008 Kasper Skaarhoj (kasperYYYY@typo3.com)
6 * (c) 2005-2008 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 * $Id$
36 *
37 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
38 * @author Stanislas Rolland <typo3(arobas)sjbr.ca>
39 */
40
41 require_once (PATH_typo3.'class.browse_links.php');
42 require_once (PATH_t3lib.'class.t3lib_basicfilefunc.php');
43
44
45 /**
46 * Class which generates the page tree
47 *
48 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
49 * @package TYPO3
50 * @subpackage core
51 */
52 class tx_rtehtmlarea_pageTree extends rtePageTree {
53
54 /**
55 * Create the page navigation tree in HTML
56 *
57 * @param array Tree array
58 * @return string HTML output.
59 */
60 function printTree($treeArr='') {
61 global $BACK_PATH;
62 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
63 if (!is_array($treeArr)) $treeArr=$this->tree;
64
65 $out='';
66 $c=0;
67
68 foreach($treeArr as $k => $v) {
69 $c++;
70 $bgColorClass = ($c+1)%2 ? 'bgColor' : 'bgColor-10';
71 if ($GLOBALS['SOBE']->browser->curUrlInfo['act']=='page' && $GLOBALS['SOBE']->browser->curUrlInfo['pageid']==$v['row']['uid'] && $GLOBALS['SOBE']->browser->curUrlInfo['pageid']) {
72 $arrCol='<td><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/blinkarrow_right.gif','width="5" height="9"').' class="c-blinkArrowR" alt="" /></td>';
73 $bgColorClass='bgColor4';
74 } else {
75 $arrCol='<td></td>';
76 }
77
78 $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'].'\');';
79 $cEbullet = $this->ext_isLinkable($v['row']['doktype'],$v['row']['uid']) ?
80 '<a href="#" onclick="'.htmlspecialchars($aOnClick).'"><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/arrowbullet.gif','width="18" height="16"').' alt="" /></a>' :
81 '';
82 $out.='
83 <tr class="'.$bgColorClass.'">
84 <td nowrap="nowrap"'.($v['row']['_CSSCLASS'] ? ' class="'.$v['row']['_CSSCLASS'].'"' : '').'>'.
85 $v['HTML'].
86 $this->wrapTitle($this->getTitleStr($v['row'],$titleLen),$v['row'],$this->ext_pArrPages).
87 '</td>'.
88 $arrCol.
89 '<td>'.$cEbullet.'</td>
90 </tr>';
91 }
92 $out='
93
94
95 <!--
96 Navigation Page Tree:
97 -->
98 <table border="0" cellpadding="0" cellspacing="0" id="typo3-tree">
99 '.$out.'
100 </table>';
101 return $out;
102 }
103 }
104
105 /**
106 * Base extension class which generates the folder tree.
107 * Used directly by the RTE.
108 *
109 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
110 * @package TYPO3
111 * @subpackage core
112 */
113 class tx_rtehtmlarea_folderTree extends rteFolderTree {
114
115 /**
116 * Wrapping the title in a link, if applicable.
117 *
118 * @param string Title, ready for output.
119 * @param array The "record"
120 * @return string Wrapping title string.
121 */
122 function wrapTitle($title,$v) {
123 if ($this->ext_isLinkable($v)) {
124 $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']).'\');';
125 return '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$title.'</a>';
126 } else {
127 return '<span class="typo3-dimmed">'.$title.'</span>';
128 }
129 }
130
131 /**
132 * Create the folder navigation tree in HTML
133 *
134 * @param mixed Input tree array. If not array, then $this->tree is used.
135 * @return string HTML output of the tree.
136 */
137 function printTree($treeArr='') {
138 global $BACK_PATH;
139 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
140
141 if (!is_array($treeArr)) $treeArr=$this->tree;
142
143 $out='';
144 $c=0;
145
146 // Preparing the current-path string (if found in the listing we will see a red blinking arrow).
147 if (!$GLOBALS['SOBE']->browser->curUrlInfo['value']) {
148 $cmpPath='';
149 } else if (substr(trim($GLOBALS['SOBE']->browser->curUrlInfo['info']),-1)!='/') {
150 $cmpPath=PATH_site.dirname($GLOBALS['SOBE']->browser->curUrlInfo['info']).'/';
151 } else {
152 $cmpPath=PATH_site.$GLOBALS['SOBE']->browser->curUrlInfo['info'];
153 }
154
155 // Traverse rows for the tree and print them into table rows:
156 foreach($treeArr as $k => $v) {
157 $c++;
158 $bgColorClass=($c+1)%2 ? 'bgColor' : 'bgColor-10';
159
160 // Creating blinking arrow, if applicable:
161 if ($GLOBALS['SOBE']->browser->curUrlInfo['act']=='file' && $cmpPath==$v['row']['path']) {
162 $arrCol='<td><img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/blinkarrow_right.gif','width="5" height="9"').' class="c-blinkArrowR" alt="" /></td>';
163 $bgColorClass='bgColor4';
164 } else {
165 $arrCol='<td></td>';
166 }
167 // Create arrow-bullet for file listing (if folder path is linkable):
168 $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']).'\');';
169 $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>' : '';
170
171 // Put table row with folder together:
172 $out.='
173 <tr class="'.$bgColorClass.'">
174 <td nowrap="nowrap">'.$v['HTML'].$this->wrapTitle(t3lib_div::fixed_lgd_cs($v['row']['title'],$titleLen),$v['row']).'</td>
175 '.$arrCol.'
176 <td>'.$cEbullet.'</td>
177 </tr>';
178 }
179
180 $out='
181
182 <!--
183 Folder tree:
184 -->
185 <table border="0" cellpadding="0" cellspacing="0" id="typo3-tree">
186 '.$out.'
187 </table>';
188 return $out;
189 }
190
191 }
192
193 /**
194 * Script class for the Element Browser window.
195 *
196 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
197 * @package TYPO3
198 * @subpackage core
199 */
200 class tx_rtehtmlarea_browse_links extends browse_links {
201
202 // Internal, static:
203 var $setTarget; // Target (RTE specific)
204 var $setClass; // Class (RTE specific)
205 var $setTitle; // Title (RTE specific)
206
207 var $contentTypo3Language;
208 var $contentTypo3Charset;
209
210 var $editorNo;
211 var $buttonConfig = array();
212
213 protected $classesAnchorDefault = array();
214 protected $classesAnchorDefaultTitle = array();
215 protected $classesAnchorDefaultTarget = array();
216 protected $classesAnchorJSOptions = array();
217 public $allowedItems;
218
219 /**
220 * Constructor:
221 * Initializes a lot of variables, setting JavaScript functions in header etc.
222 *
223 * @return void
224 */
225 function init() {
226 global $BE_USER,$BACK_PATH,$LANG,$TYPO3_CONF_VARS;
227
228 // Main GPvars:
229 $this->pointer = t3lib_div::_GP('pointer');
230 $this->bparams = t3lib_div::_GP('bparams');
231 $this->P = t3lib_div::_GP('P');
232 $this->RTEtsConfigParams = t3lib_div::_GP('RTEtsConfigParams');
233 $this->expandPage = t3lib_div::_GP('expandPage');
234 $this->expandFolder = t3lib_div::_GP('expandFolder');
235 $this->PM = t3lib_div::_GP('PM');
236 $this->contentTypo3Language = t3lib_div::_GP('contentTypo3Language');
237 $this->contentTypo3Charset = t3lib_div::_GP('contentTypo3Charset');
238 $this->editorNo = t3lib_div::_GP('editorNo');
239
240 // Find "mode"
241 $this->mode=t3lib_div::_GP('mode');
242 if (!$this->mode) {
243 $this->mode='rte';
244 }
245
246 // init hook objects:
247 $this->hookObjects = array();
248 if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.browse_links.php']['browseLinksHook'])) {
249 foreach($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.browse_links.php']['browseLinksHook'] as $classData) {
250 $processObject = &t3lib_div::getUserObj($classData);
251
252 if(!($processObject instanceof t3lib_browseLinksHook)) {
253 throw new UnexpectedValueException('$processObject must implement interface t3lib_browseLinksHook', 1195115652);
254 }
255
256 $parameters = array();
257 $processObject->init($this, $parameters);
258 $this->hookObjects[] = $processObject;
259 }
260 }
261
262 // Site URL
263 $this->siteURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL'); // Current site url
264
265 // the script to link to
266 $this->thisScript = t3lib_div::getIndpEnv('SCRIPT_NAME');
267
268 // CurrentUrl - the current link url must be passed around if it exists
269 if ($this->mode=='wizard') {
270 $currentLinkParts = t3lib_div::trimExplode(' ',$this->P['currentValue']);
271 $this->curUrlArray = array(
272 'target' => $currentLinkParts[1]
273 );
274 $this->curUrlInfo=$this->parseCurUrl($this->siteURL.'?id='.$currentLinkParts[0],$this->siteURL);
275 } else {
276 $this->curUrlArray = t3lib_div::_GP('curUrl');
277 if ($this->curUrlArray['all']) {
278 $this->curUrlArray=t3lib_div::get_tag_attributes($this->curUrlArray['all']);
279 }
280 $this->curUrlInfo=$this->parseCurUrl($this->curUrlArray['href'],$this->siteURL);
281 }
282
283 // Determine nature of current url:
284 $this->act=t3lib_div::_GP('act');
285 if (!$this->act) {
286 $this->act=$this->curUrlInfo['act'];
287 }
288
289 // Initializing the titlevalue
290 $this->setTitle = $LANG->csConvObj->conv($this->curUrlArray['title'], 'utf-8', $LANG->charSet);
291
292 // Rich Text Editor specific configuration:
293 $addPassOnParams='';
294 $classSelected = array();
295 if ((string)$this->mode=='rte') {
296 $RTEtsConfigParts = explode(':',$this->RTEtsConfigParams);
297 $addPassOnParams .= '&RTEtsConfigParams='.rawurlencode($this->RTEtsConfigParams);
298 $addPassOnParams .= ($this->contentTypo3Language ? '&typo3ContentLanguage=' . rawurlencode($this->contentTypo3Language) : '');
299 $addPassOnParams .= ($this->contentTypo3Charset ? '&typo3ContentCharset=' . rawurlencode($this->contentTypo3Charset) : '');
300 $RTEsetup = $BE_USER->getTSConfig('RTE',t3lib_BEfunc::getPagesTSconfig($RTEtsConfigParts[5]));
301 $this->thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup['properties'],$RTEtsConfigParts[0],$RTEtsConfigParts[2],$RTEtsConfigParts[4]);
302 if (is_array($this->thisConfig['buttons.']) && is_array($this->thisConfig['buttons.']['link.'])) {
303 $this->buttonConfig = $this->thisConfig['buttons.']['link.'];
304 }
305 if ($this->thisConfig['classesAnchor'] || $this->thisConfig['classesLinks']) {
306 $this->setClass = $this->curUrlArray['class'];
307 if ($this->thisConfig['classesAnchor']) {
308 $classesAnchorArray = t3lib_div::trimExplode(',',$this->thisConfig['classesAnchor'], 1);
309 } else {
310 $classesAnchorArray = t3lib_div::trimExplode(',',$this->thisConfig['classesLinks'], 1);
311 }
312 $anchorTypes = array( 'page', 'url', 'file', 'mail', 'spec');
313 $classesAnchor = array();
314 $classesAnchor['all'] = array();
315 if (is_array($RTEsetup['properties']['classesAnchor.'])) {
316 reset($RTEsetup['properties']['classesAnchor.']);
317 while(list($label,$conf)=each($RTEsetup['properties']['classesAnchor.'])) {
318 if (in_array($conf['class'], $classesAnchorArray)) {
319 $classesAnchor['all'][] = $conf['class'];
320 if (in_array($conf['type'], $anchorTypes)) {
321 $classesAnchor[$conf['type']][] = $conf['class'];
322 if (is_array($this->thisConfig['classesAnchor.']) && is_array($this->thisConfig['classesAnchor.']['default.']) && $this->thisConfig['classesAnchor.']['default.'][$conf['type']] == $conf['class']) {
323 $this->classesAnchorDefault[$conf['type']] = $conf['class'];
324 if ($conf['titleText']) {
325 $this->classesAnchorDefaultTitle[$conf['type']] = $this->getLLContent(trim($conf['titleText']));
326 }
327 if ($conf['target']) {
328 $this->classesAnchorDefaultTarget[$conf['type']] = trim($conf['target']);
329 }
330 }
331 }
332 }
333 }
334 }
335 reset($anchorTypes);
336 while (list(, $anchorType) = each($anchorTypes) ) {
337 reset($classesAnchorArray);
338 while(list(,$class)=each($classesAnchorArray)) {
339 if (!in_array($class, $classesAnchor['all']) || (in_array($class, $classesAnchor['all']) && is_array($classesAnchor[$anchorType]) && in_array($class, $classesAnchor[$anchorType]))) {
340 $selected = '';
341 if ($this->setClass == $class || (!$this->setClass && $this->classesAnchorDefault[$anchorType] == $class)) {
342 $selected = 'selected="selected"';
343 $classSelected[$anchorType] = true;
344 }
345 $classLabel = (is_array($RTEsetup['properties']['classes.']) && is_array($RTEsetup['properties']['classes.'][$class.'.']) && $RTEsetup['properties']['classes.'][$class.'.']['name']) ? $this->getPageConfigLabel($RTEsetup['properties']['classes.'][$class.'.']['name'], 0) : $class;
346 $classStyle = (is_array($RTEsetup['properties']['classes.']) && is_array($RTEsetup['properties']['classes.'][$class.'.']) && $RTEsetup['properties']['classes.'][$class.'.']['value']) ? $RTEsetup['properties']['classes.'][$class.'.']['value'] : '';
347 $this->classesAnchorJSOptions[$anchorType] .= '<option ' . $selected . ' value="' .$class . '"' . ($classStyle?' style="'.$classStyle.'"':'') . '>' . $classLabel . '</option>';
348 }
349 }
350 if ($this->classesAnchorJSOptions[$anchorType]) {
351 $selected = '';
352 if (!$this->setClass && !$this->classesAnchorDefault[$anchorType]) $selected = 'selected="selected"';
353 $this->classesAnchorJSOptions[$anchorType] = '<option ' . $selected . ' value=""></option>' . $this->classesAnchorJSOptions[$anchorType];
354 }
355 }
356 }
357 }
358
359 // Initializing the target value (RTE)
360 // 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
361 // In other words, do not forward the target if we changed tab and the target field is not displayed
362 $this->setTarget = (isset($this->curUrlArray['target'])
363 && !(
364 ($this->curUrlArray['target'] != $this->thisConfig['defaultLinkTarget'])
365 && !$classSelected[$this->act]
366 && is_array($this->buttonConfig['targetSelector.']) && $this->buttonConfig['targetSelector.']['disabled'] && is_array($this->buttonConfig['popupSelector.']) && $this->buttonConfig['popupSelector.']['disabled'])
367 ) ? $this->curUrlArray['target'] : '';
368 if ($this->thisConfig['defaultLinkTarget'] && !isset($this->curUrlArray['target'])) {
369 $this->setTarget=$this->thisConfig['defaultLinkTarget'];
370 }
371
372 // Creating backend template object:
373 $this->doc = t3lib_div::makeInstance('template');
374 $this->doc->bodyTagAdditions = 'onLoad="initDialog();"';
375 $this->doc->docType= 'xhtml_trans';
376 $this->doc->backPath = $BACK_PATH;
377
378 // BEGIN accumulation of header JavaScript:
379 $JScode = '';
380 $JScode.= '
381 var dialog = window.opener.HTMLArea.Dialog.TYPO3Link;
382 var plugin = dialog.plugin;
383 var HTMLArea = window.opener.HTMLArea;
384
385 function initDialog() {
386 dialog.captureEvents("skipUnload");
387 }
388 // This JavaScript is primarily for RTE/Link. jumpToUrl is used in the other cases as well...
389 var add_href="'.($this->curUrlArray['href']?'&curUrl[href]='.rawurlencode($this->curUrlArray['href']):'').'";
390 var add_target="'.($this->setTarget?'&curUrl[target]='.rawurlencode($this->setTarget):'').'";
391 var add_class="'.($this->setClass?'&curUrl[class]='.rawurlencode($this->setClass):'').'";
392 var add_title="'.($this->setTitle?'&curUrl[title]='.rawurlencode($this->setTitle):'').'";
393 var add_params="'.($this->bparams?'&bparams='.rawurlencode($this->bparams):'').'";
394
395 var cur_href="'.($this->curUrlArray['href']?$this->curUrlArray['href']:'').'";
396 var cur_target="'.($this->setTarget?$this->setTarget:'').'";
397 var cur_class="'.($this->setClass?$this->setClass:'').'";
398 var cur_title="'.($this->setTitle?$this->setTitle:'').'";
399
400 function setTarget(value) {
401 cur_target=value;
402 add_target="&curUrl[target]="+encodeURIComponent(value);
403 }
404 function setClass(value) {
405 cur_class=value;
406 add_class="&curUrl[class]="+encodeURIComponent(value);
407 }
408 function setTitle(value) {
409 cur_title=value;
410 add_title="&curUrl[title]="+encodeURIComponent(value);
411 }
412 function setValue(value) {
413 cur_href=value;
414 add_href="&curUrl[href]="+value;
415 }
416 ';
417
418 if ($this->mode=='wizard') { // Functions used, if the link selector is in wizard mode (= TCEforms fields)
419 unset($this->P['fieldChangeFunc']['alert']);
420 reset($this->P['fieldChangeFunc']);
421 $update='';
422 while(list($k,$v)=each($this->P['fieldChangeFunc'])) {
423
424 $update.= '
425 window.opener.'.$v;
426 }
427
428 $P2=array();
429 $P2['itemName']=$this->P['itemName'];
430 $P2['formName']=$this->P['formName'];
431 $P2['fieldChangeFunc']=$this->P['fieldChangeFunc'];
432 $addPassOnParams.=t3lib_div::implodeArrayForUrl('P',$P2);
433
434 $JScode.='
435 function link_typo3Page(id,anchor) { //
436 updateValueInMainForm(id+(anchor?anchor:"")+" "+cur_target);
437 close();
438 return false;
439 }
440 function link_folder(folder) { //
441 updateValueInMainForm(folder+" "+cur_target);
442 close();
443 return false;
444 }
445 function link_current() { //
446 if (cur_href!="http://" && cur_href!="mailto:") {
447 var setValue = cur_href+" "+cur_target+" "+cur_class+" "+cur_title;
448 if (setValue.substr(0,7)=="http://") setValue = setValue.substr(7);
449 if (setValue.substr(0,7)=="mailto:") setValue = setValue.substr(7);
450 updateValueInMainForm(setValue);
451 close();
452 }
453 return false;
454 }
455 function checkReference() { //
456 if (window.opener && window.opener.document && window.opener.document.'.$this->P['formName'].' && window.opener.document.'.$this->P['formName'].'["'.$this->P['itemName'].'"] ) {
457 return window.opener.document.'.$this->P['formName'].'["'.$this->P['itemName'].'"];
458 } else {
459 close();
460 }
461 }
462 function updateValueInMainForm(input) { //
463 var field = checkReference();
464 if (field) {
465 field.value = input;
466 '.$update.'
467 }
468 }
469 ';
470 } else { // Functions used, if the link selector is in RTE mode:
471 $JScode.='
472 function link_typo3Page(id,anchor) {
473 var theLink = \''.$this->siteURL.'?id=\'+id+(anchor?anchor:"");
474 if (document.ltargetform.anchor_title) setTitle(document.ltargetform.anchor_title.value);
475 if (document.ltargetform.anchor_class) setClass(document.ltargetform.anchor_class.value);
476 if (document.ltargetform.ltarget) setTarget(document.ltargetform.ltarget.value);
477 plugin.createLink(theLink,cur_target,cur_class,cur_title);
478 return false;
479 }
480 function link_folder(folder) { //
481 var theLink = \''.$this->siteURL.'\'+folder;
482 if (document.ltargetform.anchor_title) setTitle(document.ltargetform.anchor_title.value);
483 if (document.ltargetform.anchor_class) setClass(document.ltargetform.anchor_class.value);
484 if (document.ltargetform.ltarget) setTarget(document.ltargetform.ltarget.value);
485 plugin.createLink(theLink,cur_target,cur_class,cur_title);
486 return false;
487 }
488 function link_spec(theLink) { //
489 if (document.ltargetform.anchor_title) setTitle(document.ltargetform.anchor_title.value);
490 if (document.ltargetform.anchor_class) setClass(document.ltargetform.anchor_class.value);
491 if (document.ltargetform.ltarget) setTarget(document.ltargetform.ltarget.value);
492 plugin.createLink(theLink,cur_target,cur_class,cur_title);
493 return false;
494 }
495 function link_current() { //
496 if (document.ltargetform.anchor_title) setTitle(document.ltargetform.anchor_title.value);
497 if (document.ltargetform.anchor_class) setClass(document.ltargetform.anchor_class.value);
498 if (document.ltargetform.ltarget) setTarget(document.ltargetform.ltarget.value);
499 if (cur_href!="http://" && cur_href!="mailto:") {
500 plugin.createLink(cur_href,cur_target,cur_class,cur_title);
501 }
502 return false;
503 }
504 ';
505 }
506
507 // General "jumpToUrl" function:
508 $JScode.='
509 function jumpToUrl(URL,anchor) { //
510 var add_editorNo = URL.indexOf("editorNo=")==-1 ? "&editorNo='.$this->editorNo.'" : "";
511 var add_contentTypo3Language = URL.indexOf("contentTypo3Language=")==-1 ? "&contentTypo3Language='.$this->contentTypo3Language.'" : "";
512 var add_contentTypo3Charset = URL.indexOf("contentTypo3Charset=")==-1 ? "&contentTypo3Charset='.$this->contentTypo3Charset.'" : "";
513 var add_act = URL.indexOf("act=")==-1 ? "&act='.$this->act.'" : "";
514 var add_mode = URL.indexOf("mode=")==-1 ? "&mode='.$this->mode.'" : "";
515 var theLocation = URL+add_act+add_editorNo+add_contentTypo3Language+add_contentTypo3Charset+add_mode+add_href+add_target+add_class+add_title+add_params'.($addPassOnParams?'+"'.$addPassOnParams.'"':'').'+(anchor?anchor:"");
516 window.location.href = theLocation;
517 return false;
518 }
519 ';
520
521 // This is JavaScript especially for the TBE Element Browser!
522 $pArr = explode('|',$this->bparams);
523 $formFieldName = 'data['.$pArr[0].']['.$pArr[1].']['.$pArr[2].']';
524 $JScode.='
525 var elRef="";
526 var targetDoc="";
527
528 function launchView(url) { //
529 var thePreviewWindow="";
530 thePreviewWindow = window.open("' . $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");
531 if (thePreviewWindow && thePreviewWindow.focus) {
532 thePreviewWindow.focus();
533 }
534 }
535 function setReferences() { //
536 if (parent.window.opener
537 && parent.window.opener.content
538 && parent.window.opener.content.document.editform
539 && parent.window.opener.content.document.editform["'.$formFieldName.'"]
540 ) {
541 targetDoc = parent.window.opener.content.document;
542 elRef = targetDoc.editform["'.$formFieldName.'"];
543 return true;
544 } else {
545 return false;
546 }
547 }
548 function insertElement(table, uid, type, filename,fp,filetype,imagefile,action, close) { //
549 if (1=='.($pArr[0]&&!$pArr[1]&&!$pArr[2] ? 1 : 0).') {
550 addElement(filename,table+"_"+uid,fp,close);
551 } else {
552 if (setReferences()) {
553 parent.window.opener.group_change("add","'.$pArr[0].'","'.$pArr[1].'","'.$pArr[2].'",elRef,targetDoc);
554 } else {
555 alert("Error - reference to main window is not set properly!");
556 }
557 if (close) {
558 parent.window.opener.focus();
559 parent.close();
560 }
561 }
562 return false;
563 }
564 function addElement(elName,elValue,altElValue,close) { //
565 if (parent.window.opener && parent.window.opener.setFormValueFromBrowseWin) {
566 parent.window.opener.setFormValueFromBrowseWin("'.$pArr[0].'",altElValue?altElValue:elValue,elName);
567 if (close) {
568 parent.window.opener.focus();
569 parent.close();
570 }
571 } else {
572 alert("Error - reference to main window is not set properly!");
573 parent.close();
574 }
575 }
576 ';
577
578 // Finally, add the accumulated JavaScript to the template object:
579 $this->doc->JScode = $this->doc->wrapScriptTags($JScode);
580
581 // Debugging:
582 if (FALSE) debug(array(
583 'pointer' => $this->pointer,
584 'act' => $this->act,
585 'mode' => $this->mode,
586 'curUrlInfo' => $this->curUrlInfo,
587 'curUrlArray' => $this->curUrlArray,
588 'P' => $this->P,
589 'bparams' => $this->bparams,
590 'RTEtsConfigParams' => $this->RTEtsConfigParams,
591 'expandPage' => $this->expandPage,
592 'expandFolder' => $this->expandFolder,
593 'PM' => $this->PM,
594 ),'Internal variables of Script Class:');
595 }
596
597 /******************************************************************
598 *
599 * Main functions
600 *
601 ******************************************************************/
602 /**
603 * Rich Text Editor (RTE) link selector (MAIN function)
604 * Generates the link selector for the Rich Text Editor.
605 * Can also be used to select links for the TCEforms (see $wiz)
606 *
607 * @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
608 * @return string Modified content variable.
609 */
610 function main_rte($wiz=0) {
611 global $LANG, $BE_USER, $BACK_PATH;
612
613 // Starting content:
614 $content=$this->doc->startPage($LANG->getLL('Insert/Modify Link',1));
615
616 // Initializing the action value, possibly removing blinded values etc:
617 $this->allowedItems = explode(',','page,file,url,mail,spec');
618
619 //call hook for extra options
620 foreach($this->hookObjects as $hookObject) {
621 $this->allowedItems = $hookObject->addAllowedItems($this->allowedItems);
622 }
623
624 if (is_array($this->buttonConfig['options.']) && $this->buttonConfig['options.']['removeItems']) {
625 $this->allowedItems = array_diff($this->allowedItems,t3lib_div::trimExplode(',',$this->buttonConfig['options.']['removeItems'],1));
626 } else {
627 $this->allowedItems = array_diff($this->allowedItems,t3lib_div::trimExplode(',',$this->thisConfig['blindLinkOptions'],1));
628 }
629 reset($this->allowedItems);
630 if (!in_array($this->act,$this->allowedItems)) {
631 $this->act = current($this->allowedItems);
632 }
633
634 // Making menu in top:
635 $menuDef = array();
636 if (!$wiz && $this->curUrlArray['href']) {
637 $menuDef['removeLink']['isActive'] = $this->act=='removeLink';
638 $menuDef['removeLink']['label'] = $LANG->getLL('removeLink',1);
639 $menuDef['removeLink']['url'] = '#';
640 $menuDef['removeLink']['addParams'] = 'onclick="plugin.unLink();return false;"';
641 }
642 if (in_array('page',$this->allowedItems)) {
643 $menuDef['page']['isActive'] = $this->act=='page';
644 $menuDef['page']['label'] = $LANG->getLL('page',1);
645 $menuDef['page']['url'] = '#';
646 $menuDef['page']['addParams'] = 'onclick="jumpToUrl(\''.htmlspecialchars('?act=page&editorNo='.$this->editorNo.'&contentTypo3Language='.$this->contentTypo3Language.'&contentTypo3Charset='.$this->contentTypo3Charset).'\');return false;"';
647 }
648 if (in_array('file',$this->allowedItems)){
649 $menuDef['file']['isActive'] = $this->act=='file';
650 $menuDef['file']['label'] = $LANG->getLL('file',1);
651 $menuDef['file']['url'] = '#';
652 $menuDef['file']['addParams'] = 'onclick="jumpToUrl(\''.htmlspecialchars('?act=file&editorNo='.$this->editorNo.'&contentTypo3Language='.$this->contentTypo3Language.'&contentTypo3Charset='.$this->contentTypo3Charset).'\');return false;"';
653 }
654 if (in_array('url',$this->allowedItems)) {
655 $menuDef['url']['isActive'] = $this->act=='url';
656 $menuDef['url']['label'] = $LANG->getLL('extUrl',1);
657 $menuDef['url']['url'] = '#';
658 $menuDef['url']['addParams'] = 'onclick="jumpToUrl(\''.htmlspecialchars('?act=url&editorNo='.$this->editorNo.'&contentTypo3Language='.$this->contentTypo3Language.'&contentTypo3Charset='.$this->contentTypo3Charset).'\');return false;"';
659 }
660 if (in_array('mail',$this->allowedItems)) {
661 $menuDef['mail']['isActive'] = $this->act=='mail';
662 $menuDef['mail']['label'] = $LANG->getLL('email',1);
663 $menuDef['mail']['url'] = '#';
664 $menuDef['mail']['addParams'] = 'onclick="jumpToUrl(\''.htmlspecialchars('?act=mail&editorNo='.$this->editorNo.'&contentTypo3Language='.$this->contentTypo3Language.'&contentTypo3Charset='.$this->contentTypo3Charset).'\');return false;"';
665 }
666 if (is_array($this->thisConfig['userLinks.']) && in_array('spec',$this->allowedItems)) {
667 $menuDef['spec']['isActive'] = $this->act=='spec';
668 $menuDef['spec']['label'] = $LANG->getLL('special',1);
669 $menuDef['spec']['url'] = '#';
670 $menuDef['spec']['addParams'] = 'onclick="jumpToUrl(\''.htmlspecialchars('?act=spec&editorNo='.$this->editorNo.'&contentTypo3Language='.$this->contentTypo3Language.'&contentTypo3Charset='.$this->contentTypo3Charset).'\');return false;"';
671 }
672
673 // call hook for extra options
674 foreach($this->hookObjects as $hookObject) {
675 $menuDef = $hookObject->modifyMenuDefinition($menuDef);
676 }
677
678 $content .= $this->doc->getTabMenuRaw($menuDef);
679
680 // Adding the menu and header to the top of page:
681 $content.=$this->printCurrentUrl($this->curUrlInfo['info']).'<br />';
682
683 // Depending on the current action we will create the actual module content for selecting a link:
684 switch($this->act) {
685 case 'mail':
686 $extUrl='
687 <!--
688 Enter mail address:
689 -->
690 <form action="" name="lurlform" id="lurlform">
691 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkMail">
692 <tr>
693 <td>'.$LANG->getLL('emailAddress',1).':</td>
694 <td><input type="text" name="lemail"'.$this->doc->formWidth(20).' value="'.htmlspecialchars($this->curUrlInfo['act']=='mail'?$this->curUrlInfo['info']:'').'" /> '.
695 '<input type="submit" value="'.$LANG->getLL('setLink',1).'" onclick="setTarget(\'\');setValue(\'mailto:\'+document.lurlform.lemail.value); return link_current();" /></td>
696 </tr>
697 </table>
698 </form>';
699 $content.=$extUrl;
700 $content.=$this->addAttributesForm();
701 break;
702 case 'url':
703 $extUrl='
704 <!--
705 Enter External URL:
706 -->
707 <form action="" name="lurlform" id="lurlform">
708 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkURL">
709 <tr>
710 <td>URL:</td>
711 <td><input type="text" name="lurl"'.$this->doc->formWidth(20).' value="'.htmlspecialchars($this->curUrlInfo['act']=='url'?$this->curUrlInfo['info']:'http://').'" /> '.
712 '<input type="submit" value="'.$LANG->getLL('setLink',1).'" onclick="setValue(document.lurlform.lurl.value); return link_current();" /></td>
713 </tr>
714 </table>
715 </form>';
716 $content.=$extUrl;
717 $content.=$this->addAttributesForm();
718 break;
719 case 'file':
720 $content.=$this->addAttributesForm();
721
722 $foldertree = t3lib_div::makeInstance('tx_rtehtmlarea_folderTree');
723 $tree=$foldertree->getBrowsableTree();
724
725 if (!$this->curUrlInfo['value'] || $this->curUrlInfo['act']!='file') {
726 $cmpPath='';
727 } elseif (substr(trim($this->curUrlInfo['info']),-1)!='/') {
728 $cmpPath=PATH_site.dirname($this->curUrlInfo['info']).'/';
729 if (!isset($this->expandFolder)) $this->expandFolder = $cmpPath;
730 } else {
731 $cmpPath=PATH_site.$this->curUrlInfo['info'];
732 }
733
734 list(,,$specUid) = explode('_',$this->PM);
735 $files = $this->expandFolder($foldertree->specUIDmap[$specUid]);
736
737 // Create upload/create folder forms, if a path is given:
738 if ($BE_USER->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
739 $fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
740 $fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
741 $path=$this->expandFolder;
742 if (!$path || !@is_dir($path)) {
743 $path = $fileProcessor->findTempFolder().'/'; // The closest TEMP-path is found
744 }
745 if ($path!='/' && @is_dir($path)) {
746 $uploadForm=$this->uploadForm($path);
747 $createFolder=$this->createFolder($path);
748 } else {
749 $createFolder='';
750 $uploadForm='';
751 }
752 $content.=$uploadForm;
753 if ($BE_USER->isAdmin() || $BE_USER->getTSConfigVal('options.createFoldersInEB')) {
754 $content.=$createFolder;
755 }
756 }
757
758 $content.= '
759 <!--
760 Wrapper table for folder tree / file list:
761 -->
762 <table border="0" cellpadding="0" cellspacing="0" id="typo3-linkFiles">
763 <tr>
764 <td class="c-wCell" valign="top">'.$this->barheader($LANG->getLL('folderTree').':').$tree.'</td>
765 <td class="c-wCell" valign="top">'.$files.'</td>
766 </tr>
767 </table>
768 ';
769 break;
770 case 'spec':
771 if (is_array($this->thisConfig['userLinks.'])) {
772 $subcats=array();
773 $v=$this->thisConfig['userLinks.'];
774 reset($v);
775 while(list($k2)=each($v)) {
776 $k2i = intval($k2);
777 if (substr($k2,-1)=='.' && is_array($v[$k2i.'.'])) {
778
779 // Title:
780 $title = trim($v[$k2i]);
781 if (!$title) {
782 $title=$v[$k2i.'.']['url'];
783 } else {
784 $title=$LANG->sL($title);
785 }
786 // Description:
787 $description=$v[$k2i.'.']['description'] ? $LANG->sL($v[$k2i.'.']['description'],1).'<br />' : '';
788
789 // URL + onclick event:
790 $onClickEvent='';
791 if (isset($v[$k2i.'.']['target'])) $onClickEvent.="setTarget('".$v[$k2i.'.']['target']."');";
792 $v[$k2i.'.']['url'] = str_replace('###_URL###',$this->siteURL,$v[$k2i.'.']['url']);
793 if (substr($v[$k2i.'.']['url'],0,7)=="http://" || substr($v[$k2i.'.']['url'],0,7)=='mailto:') {
794 $onClickEvent.="cur_href=unescape('".rawurlencode($v[$k2i.'.']['url'])."');link_current();";
795 } else {
796 $onClickEvent.="link_spec(unescape('".$this->siteURL.rawurlencode($v[$k2i.'.']['url'])."'));";
797 }
798
799 // Link:
800 $A=array('<a href="#" onclick="'.htmlspecialchars($onClickEvent).'return false;">','</a>');
801
802 // Adding link to menu of user defined links:
803 $subcats[$k2i]='
804 <tr>
805 <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>
806 </tr>';
807 }
808 }
809
810 // Sort by keys:
811 ksort($subcats);
812
813 // Add menu to content:
814 $content.= '
815 <!--
816 Special userdefined menu:
817 -->
818 <table border="0" cellpadding="1" cellspacing="1" id="typo3-linkSpecial">
819 <tr>
820 <td class="bgColor5" class="c-wCell" valign="top"><strong>'.$LANG->getLL('special',1).'</strong></td>
821 </tr>
822 '.implode('',$subcats).'
823 </table>
824 ';
825 }
826 break;
827 case 'page':
828 $content.=$this->addAttributesForm();
829
830 $pagetree = t3lib_div::makeInstance('tx_rtehtmlarea_pageTree');
831 $pagetree->ext_showNavTitle = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showNavTitle');
832 $pagetree->addField('nav_title');
833 $tree=$pagetree->getBrowsableTree();
834 $cElements = $this->expandPage();
835 $content.= '
836 <!--
837 Wrapper table for page tree / record list:
838 -->
839 <table border="0" cellpadding="0" cellspacing="0" id="typo3-linkPages">
840 <tr>
841 <td class="c-wCell" valign="top">'.$this->barheader($LANG->getLL('pageTree').':').$tree.'</td>
842 <td class="c-wCell" valign="top">'.$cElements.'</td>
843 </tr>
844 </table>
845 ';
846 break;
847 default:
848 // call hook
849 foreach($this->hookObjects as $hookObject) {
850 $content .= $hookObject->getTab($this->act);
851 }
852
853 break;
854 }
855
856 // End page, return content:
857 $content.= $this->doc->endPage();
858 return $content;
859 }
860
861 function addAttributesForm() {
862 $ltargetForm = '';
863 // Add page id, target, class selector box and title field:
864 $lpageId = $this->addPageIdSelector();
865 $ltarget = $this->addTargetSelector();
866 $lclass = $this->addClassSelector();
867 $ltitle = $this->addTitleSelector();
868 if ($lpageId || $ltarget || $lclass || $ltitle) {
869 $ltargetForm = $this->wrapInForm($lpageId.$ltarget.$lclass.$ltitle);
870 }
871 return $ltargetForm;
872 }
873
874 function wrapInForm($string) {
875 global $LANG;
876
877 $form = '
878 <!--
879 Selecting target for link:
880 -->
881 <form action="" name="ltargetform" id="ltargetform">
882 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkTarget">'. $string;
883 if ((($this->act == 'page' && $this->curUrlInfo['act']=='page') || ($this->act == 'file' && $this->curUrlInfo['act']=='file') || ($this->act == 'url' && $this->curUrlInfo['act']!='page')) && $this->curUrlArray['href']) {
884 $form .='
885 <tr>
886 <td>
887 </td>
888 <td colspan="3">
889 <input type="submit" value="'.$LANG->getLL('update',1).'" onclick="return link_current();" />
890 </td>
891 </tr>';
892 }
893 $form .= '
894 </table>
895 </form>';
896 return $form;
897 }
898
899 function addPageIdSelector() {
900 global $LANG;
901
902 return ($this->act == 'page' && $this->buttonConfig && is_array($this->buttonConfig['pageIdSelector.']) && $this->buttonConfig['pageIdSelector.']['enabled'])?'
903 <tr>
904 <td>'.$LANG->getLL('page_id',1).':</td>
905 <td colspan="3">
906 <input type="text" size="6" name="luid" />&nbsp;<input type="submit" value="'.$LANG->getLL('setLink',1).'" onclick="return link_typo3Page(document.ltargetform.luid.value);" />
907 </td>
908 </tr>':'';
909 }
910
911 function addTargetSelector() {
912 global $LANG;
913
914 $targetSelectorConfig = array();
915 $popupSelectorConfig = array();
916 if (is_array($this->buttonConfig['targetSelector.'])) {
917 $targetSelectorConfig = $this->buttonConfig['targetSelector.'];
918 }
919 if (is_array($this->buttonConfig['popupSelector.'])) {
920 $popupSelectorConfig = $this->buttonConfig['popupSelector.'];
921 }
922
923 $ltarget = '';
924 if ($this->act != 'mail') {
925 $ltarget .= '
926 <tr id="ltargetrow"'. (($targetSelectorConfig['disabled'] && $popupSelectorConfig['disabled']) ? ' style="display: none;"' : '') . '>
927 <td>'.$LANG->getLL('target',1).':</td>
928 <td><input type="text" name="ltarget" onchange="setTarget(this.value);" value="'.htmlspecialchars($this->setTarget?$this->setTarget:(($this->setClass || !$this->classesAnchorDefault[$this->act])?'':$this->classesAnchorDefaultTarget[$this->act])).'"'.$this->doc->formWidth(10).' /></td>';
929 $ltarget .= '
930 <td colspan="2">';
931 if (!$targetSelectorConfig['disabled']) {
932 $ltarget .= '
933 <select name="ltarget_type" onchange="setTarget(this.options[this.selectedIndex].value);document.ltargetform.ltarget.value=this.options[this.selectedIndex].value;this.selectedIndex=0;">
934 <option></option>
935 <option value="_top">'.$LANG->getLL('top',1).'</option>
936 <option value="_blank">'.$LANG->getLL('newWindow',1).'</option>
937 </select>';
938 }
939 $ltarget .= '
940 </td>
941 </tr>';
942 if (!$popupSelectorConfig['disabled']) {
943
944 $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) {
945 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;
946 setTarget(document.ltargetform.ltarget.value);
947 document.ltargetform.popup_width.selectedIndex=0;
948 document.ltargetform.popup_height.selectedIndex=0;
949 }';
950
951 $ltarget.='
952 <tr>
953 <td>'.$LANG->getLL('target_popUpWindow',1).':</td>
954 <td colspan="3">
955 <select name="popup_width" onchange="'.$selectJS.'">
956 <option value="0">'.$LANG->getLL('target_popUpWindow_width',1).'</option>
957 <option value="300">300</option>
958 <option value="400">400</option>
959 <option value="500">500</option>
960 <option value="600">600</option>
961 <option value="700">700</option>
962 <option value="800">800</option>
963 </select>
964 x
965 <select name="popup_height" onchange="'.$selectJS.'">
966 <option value="0">'.$LANG->getLL('target_popUpWindow_height',1).'</option>
967 <option value="200">200</option>
968 <option value="300">300</option>
969 <option value="400">400</option>
970 <option value="500">500</option>
971 <option value="600">600</option>
972 </select>
973 </td>
974 </tr>';
975 }
976 }
977 return $ltarget;
978 }
979
980 function addClassSelector() {
981 global $LANG;
982
983 $selectClass = '';
984 if ($this->classesAnchorJSOptions[$this->act]) {
985 $selectClassJS = '
986 if (document.ltargetform.anchor_class) {
987 document.ltargetform.anchor_class.value = document.ltargetform.anchor_class.options[document.ltargetform.anchor_class.selectedIndex].value;
988 if (document.ltargetform.anchor_class.value && HTMLArea.classesAnchorSetup) {
989 for (var i = HTMLArea.classesAnchorSetup.length; --i >= 0;) {
990 var anchorClass = HTMLArea.classesAnchorSetup[i];
991 if (anchorClass[\'name\'] == document.ltargetform.anchor_class.value) {
992 if (anchorClass[\'titleText\'] && document.ltargetform.anchor_title) {
993 document.ltargetform.anchor_title.value = anchorClass[\'titleText\'];
994 setTitle(anchorClass[\'titleText\']);
995 }
996 if (anchorClass[\'target\']) {
997 if (document.ltargetform.ltarget) {
998 document.ltargetform.ltarget.value = anchorClass[\'target\'];
999 }
1000 setTarget(anchorClass[\'target\']);
1001 } else if (document.ltargetform.ltarget && document.getElementById(\'ltargetrow\').style.display == \'none\') {
1002 // Reset target to default if field is not displayed and class has no configured target
1003 document.ltargetform.ltarget.value = \''. ($this->thisConfig['defaultLinkTarget']?$this->thisConfig['defaultLinkTarget']:'') .'\';
1004 setTarget(document.ltargetform.ltarget.value);
1005 }
1006 break;
1007 }
1008 }
1009 }
1010 setClass(document.ltargetform.anchor_class.value);
1011 }
1012 ';
1013 $selectClass ='
1014 <tr>
1015 <td>'.$LANG->getLL('anchor_class',1).':</td>
1016 <td colspan="3">
1017 <select name="anchor_class" onchange="'.$selectClassJS.'">
1018 ' . $this->classesAnchorJSOptions[$this->act] . '
1019 </select>
1020 </td>
1021 </tr>';
1022 }
1023 return $selectClass;
1024 }
1025
1026 function addTitleSelector() {
1027 global $LANG;
1028
1029 return '
1030 <tr>
1031 <td>'.$LANG->getLL('anchor_title',1).':</td>
1032 <td colspan="3">
1033 <input type="text" name="anchor_title" value="' . ($this->setTitle?$this->setTitle:(($this->setClass || !$this->classesAnchorDefault[$this->act])?'':$this->classesAnchorDefaultTitle[$this->act])) . '" ' . $this->doc->formWidth(30) . ' />
1034 </td>
1035 </tr>';
1036 }
1037
1038 /**
1039 * For TBE: Makes an upload form for uploading files to the filemount the user is browsing.
1040 * The files are uploaded to the tce_file.php script in the core which will handle the upload.
1041 *
1042 * @param string Absolute filepath on server to which to upload.
1043 * @return string HTML for an upload form.
1044 */
1045 function uploadForm($path) {
1046 global $BACK_PATH;
1047 $count=3;
1048
1049 // Create header, showing upload path:
1050 $header = t3lib_div::isFirstPartOfStr($path,PATH_site)?substr($path,strlen(PATH_site)):$path;
1051 $code=$this->barheader($GLOBALS['LANG']->getLL('uploadImage').':');
1052 $code.='
1053
1054 <!--
1055 Form, for uploading files:
1056 -->
1057 <form action="'.$BACK_PATH.'tce_file.php" method="post" name="editform" enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'">
1058 <table border="0" cellpadding="0" cellspacing="3" id="typo3-uplFiles">
1059 <tr>
1060 <td><strong>'.$GLOBALS['LANG']->getLL('path',1).':</strong> '.htmlspecialchars($header).'</td>
1061 </tr>
1062 <tr>
1063 <td>';
1064
1065 // Traverse the number of upload fields (default is 3):
1066 for ($a=1;$a<=$count;$a++) {
1067 $code.='<input type="file" name="upload_'.$a.'"'.$this->doc->formWidth(35).' size="50" />
1068 <input type="hidden" name="file[upload]['.$a.'][target]" value="'.htmlspecialchars($path).'" />
1069 <input type="hidden" name="file[upload]['.$a.'][data]" value="'.$a.'" /><br />';
1070 }
1071
1072 // Make footer of upload form, including the submit button:
1073 $redirectValue = $this->thisScript.'?act='.$this->act.'&editorNo='.$this->editorNo.'&mode='.$this->mode.'&expandFolder='.rawurlencode($path).'&bparams='.rawurlencode($this->bparams);
1074 $code.='<input type="hidden" name="redirect" value="'.htmlspecialchars($redirectValue).'" />'.
1075 '<input type="submit" name="submit" value="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_upload.php.submit',1).'" />';
1076
1077 $code.='
1078 <div id="c-override">
1079 <input type="checkbox" name="overwriteExistingFiles" value="1" /> '.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xml:overwriteExistingFiles',1).'
1080 </div>
1081 ';
1082
1083
1084 $code.='</td>
1085 </tr>
1086 </table>
1087 </form>';
1088
1089 return $code;
1090 }
1091
1092 /**
1093 * For TBE: Makes a form for creating new folders in the filemount the user is browsing.
1094 * The folder creation request is sent to the tce_file.php script in the core which will handle the creation.
1095 *
1096 * @param string Absolute filepath on server in which to create the new folder.
1097 * @return string HTML for the create folder form.
1098 */
1099 function createFolder($path) {
1100 global $BACK_PATH;
1101 // Create header, showing upload path:
1102 $header = t3lib_div::isFirstPartOfStr($path,PATH_site)?substr($path,strlen(PATH_site)):$path;
1103 $code=$this->barheader($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.pagetitle').':');
1104 $code.='
1105
1106 <!--
1107 Form, for creating new folders:
1108 -->
1109 <form action="'.$BACK_PATH.'tce_file.php" method="post" name="editform2">
1110 <table border="0" cellpadding="0" cellspacing="3" id="typo3-crFolder">
1111 <tr>
1112 <td><strong>'.$GLOBALS['LANG']->getLL('path',1).':</strong> '.htmlspecialchars($header).'</td>
1113 </tr>
1114 <tr>
1115 <td>';
1116
1117 // Create the new-folder name field:
1118 $a=1;
1119 $code.='<input'.$this->doc->formWidth(20).' type="text" name="file[newfolder]['.$a.'][data]" />'.
1120 '<input type="hidden" name="file[newfolder]['.$a.'][target]" value="'.htmlspecialchars($path).'" />';
1121
1122 // Make footer of upload form, including the submit button:
1123 $redirectValue = $this->thisScript.'?act='.$this->act.'&editorNo='.$this->editorNo.'&mode='.$this->mode.'&expandFolder='.rawurlencode($path).'&bparams='.rawurlencode($this->bparams);
1124 $code.='<input type="hidden" name="redirect" value="'.htmlspecialchars($redirectValue).'" />'.
1125 '<input type="submit" name="submit" value="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.submit',1).'" />';
1126
1127 $code.='</td>
1128 </tr>
1129 </table>
1130 </form>';
1131
1132 return $code;
1133 }
1134
1135 /**
1136 * Localize a string using the language of the content element rather than the language of the BE interface
1137 *
1138 * @param string string: the label to be localized
1139 * @return string Localized string.
1140 */
1141 public function getLLContent($string) {
1142 global $LANG;
1143
1144 $BE_lang = $LANG->lang;
1145 $BE_origCharSet = $LANG->origCharSet;
1146 $BE_charSet = $LANG->charSet;
1147
1148 $LANG->lang = $this->contentTypo3Language;
1149 $LANG->origCharSet = $LANG->csConvObj->charSetArray[$this->contentTypo3Language];
1150 $LANG->origCharSet = $LANG->origCharSet ? $LANG->origCharSet : 'iso-8859-1';
1151 $LANG->charSet = $this->contentTypo3Charset;
1152 $LLString = $LANG->sL($string);
1153
1154 $LANG->lang = $BE_lang;
1155 $LANG->origCharSet = $BE_origCharSet;
1156 $LANG->charSet = $BE_charSet;
1157 return $LLString;
1158 }
1159
1160 /**
1161 * Localize a label obtained from Page TSConfig
1162 *
1163 * @param string string: the label to be localized
1164 * @return string Localized string.
1165 */
1166 public function getPageConfigLabel($string,$JScharCode=1) {
1167 global $LANG;
1168 if (strcmp(substr($string,0,4),'LLL:')) {
1169 $label = $string;
1170 } else {
1171 $label = $LANG->sL(trim($string));
1172 }
1173 $label = str_replace('"', '\"', str_replace('\\\'', '\'', $label));
1174 $label = $JScharCode ? $LANG->JScharCode($label): $label;
1175 return $label;
1176 }
1177
1178 }
1179
1180 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php']) {
1181 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php']);
1182 }
1183
1184 ?>