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