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