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