Initial revision
[Packages/TYPO3.CMS.git] / typo3 / browse_links.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2003 Kasper Skårhøj (kasper@typo3.com)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Displays the page/file tree for browsing database records or files.
29 * Used from TCEFORMS an other elements
30 *
31 * Revised for TYPO3 3.6 July/2003 by Kasper Skårhøj
32 * XHTML compliant
33 */
34 /**
35 * [CLASS/FUNCTION INDEX of SCRIPT]
36 *
37 *
38 *
39 * 151: class TBE_browser_recordList extends localRecordList
40 * 160: function listURL($altId="",$table=-1,$exclList="")
41 * 179: function ext_addP()
42 * 194: function linkWrapItems($table,$uid,$code,$row)
43 *
44 *
45 * 224: class localPageTree extends t3lib_browseTree
46 * 232: function wrapTitle($title,$v,$ext_pArrPages)
47 * 249: function printTree($treeArr="")
48 * 277: function ext_isLinkable($doktype,$uid)
49 * 291: function PM_ATagWrap($icon,$cmd,$bMark="")
50 * 306: function wrapIcon($icon,$row)
51 *
52 *
53 * 322: class rtePageTree extends localPageTree
54 *
55 *
56 * 336: class TBE_PageTree extends localPageTree
57 * 343: function ext_isLinkable($doktype,$uid)
58 * 355: function wrapTitle($title,$v,$ext_pArrPages)
59 *
60 *
61 * 378: class localFolderTree extends t3lib_browseTree
62 * 385: function wrapTitle($title,$v)
63 * 400: function printTree($treeArr="")
64 * 434: function ext_isLinkable($v)
65 * 452: function PM_ATagWrap($icon,$cmd,$bMark="")
66 * 466: function ext_getRelFolder($path)
67 *
68 *
69 * 483: class rteFolderTree extends localFolderTree
70 *
71 *
72 * 495: class TBE_FolderTree extends localFolderTree
73 * 502: function ext_isLinkable($v)
74 * 515: function wrapTitle($title,$v)
75 *
76 *
77 * 535: class SC_browse_links
78 * 547: function init()
79 * 611: function setTarget(target)
80 * 616: function setValue(value)
81 * 642: function link_typo3Page(id,anchor)
82 * 648: function link_folder(folder)
83 * 654: function link_current()
84 * 665: function checkReference()
85 * 673: function updateValueInMainForm(input)
86 * 684: function link_typo3Page(id,anchor)
87 * 690: function link_folder(folder)
88 * 696: function link_spec(theLink)
89 * 701: function link_current()
90 * 711: function jumpToUrl(URL,anchor)
91 * 733: function launchView(url)
92 * 741: function setReferences()
93 * 755: function insertElement(table, uid, type, filename,fp,filetype,imagefile,action, close)
94 * 775: function addElement(elName,elValue,altElValue,close)
95 * 795: function main()
96 * 845: function printContent()
97 *
98 * SECTION: OTHER FUNCTIONS:
99 * 863: function expandPage()
100 * 899: function TBE_expandPage($tables)
101 * 1002: function isWebFolder($folder)
102 * 1013: function checkFolder($folder)
103 *
104 * SECTION: OTHER FUNCTIONS:
105 * 1037: function expandFolder($expandFolder=0,$extensionList="")
106 * 1080: function TBE_expandFolder($expandFolder=0,$extensionList="")
107 * 1164: function TBE_dragNDrop($expandFolder=0,$extensionList="")
108 * 1245: function getMsgBox($in_msg,$icon="icon_note")
109 *
110 * SECTION: Miscellaneous functions
111 * 1266: function barheader($str)
112 * 1276: function printCurrentUrl($str)
113 * 1287: function parseCurUrl($href,$siteUrl)
114 * 1348: function uploadForm($path)
115 * 1370: function createFolder($path)
116 * 1398: function main_rte($content="",$wiz=0)
117 * 1564: function main_db($content="")
118 * 1610: function main_file($content="",$mode)
119 *
120 * TOTAL FUNCTIONS: 52
121 * (This index is automatically created/updated by the extension "extdeveval")
122 *
123 */
124 $BACK_PATH='';
125 require ('init.php');
126 require ('template.php');
127 require_once (PATH_t3lib.'class.t3lib_browsetree.php');
128 require_once (PATH_t3lib.'class.t3lib_foldertree.php');
129 require_once (PATH_t3lib.'class.t3lib_stdgraphic.php');
130 require_once (PATH_t3lib.'class.t3lib_basicfilefunc.php');
131 include ('sysext/lang/locallang_browse_links.php');
132
133 // **************************
134 // Functions and classes
135 // **************************
136 require_once (PATH_t3lib.'class.t3lib_page.php');
137 require_once (PATH_t3lib.'class.t3lib_recordlist.php');
138 require_once ('class.db_list.inc');
139 require_once ('class.db_list_extra.inc');
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159 /**
160 * @author Kasper Skårhøj <kasper@typo3.com>
161 * @package TYPO3
162 * @subpackage core
163 */
164 class TBE_browser_recordList extends localRecordList {
165 var $script='browse_links.php';
166
167 /**
168 * @param [type] $altId: ...
169 * @param [type] $table: ...
170 * @param [type] $exclList: ...
171 * @return [type] ...
172 */
173 function listURL($altId='',$table=-1,$exclList='') {
174 return $this->script.
175 '?id='.(strcmp($altId,'')?$altId:$this->id).
176 '&table='.rawurlencode($table==-1?$this->table:$table).
177 ($this->thumbs?'&imagemode='.$this->thumbs:'').
178 ($this->searchString?'&search_field='.rawurlencode($this->searchString):'').
179 ($this->searchLevels?'&search_levels='.rawurlencode($this->searchLevels):'').
180 ((!$exclList || !t3lib_div::inList($exclList,'sortField')) && $this->sortField?'&sortField='.rawurlencode($this->sortField):'').
181 ((!$exclList || !t3lib_div::inList($exclList,'sortRev')) && $this->sortRev?'&sortRev='.rawurlencode($this->sortRev):'').
182 // extra:
183 $this->ext_addP()
184 ;
185 }
186
187 /**
188 * [Describe function...]
189 *
190 * @return [type] ...
191 */
192 function ext_addP() {
193 $str = '&act='.$GLOBALS['act'].
194 '&mode='.$GLOBALS['mode'].
195 '&expandPage='.t3lib_div::GPvar('expandPage').
196 '&bparams='.rawurlencode(t3lib_div::GPvar('bparams'));
197 return $str;
198 }
199
200 /**
201 * Returns the title (based on $code) of a record (from table $table) with the proper link around (that is for "pages"-records a link to the level of that record...)
202 *
203 * @param [type] $table: ...
204 * @param [type] $uid: ...
205 * @param [type] $code: ...
206 * @param [type] $row: ...
207 * @return [type] ...
208 */
209 function linkWrapItems($table,$uid,$code,$row) {
210 global $TCA;
211
212 if (!$code) {$code='<i>['.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.no_title').']</i>';}
213 $code=t3lib_div::fixed_lgd('&nbsp;'.$code,$this->fixedL);
214
215 $titleCol = $TCA[$table]['ctrl']['label'];
216 $title=$row[$titleCol];
217
218 $ficon=t3lib_iconWorks::getIcon($table,$row);
219 $aOnClick = "return insertElement('".$table."', '".$row['uid']."', 'db', unescape('".rawurlencode($title)."'), '', '', '".$ficon."');";
220 $ATag='<a href="#" onclick="'.htmlspecialchars($aOnClick).'">';
221 $ATag_alt=substr($ATag,0,-4).',\'\',1);">';
222 $ATag_e='</a>';
223
224 return $ATag.
225 '<img src="gfx/plusbullet2.gif" width="18" height="16" border="0" align="top"'.t3lib_BEfunc::titleAttrib($GLOBALS['LANG']->getLL('addToList')).' alt="" />'.
226 $ATag_e.
227 $ATag_alt.
228 $code.
229 $ATag_e;
230 }
231 }
232
233
234
235
236
237
238 /**
239 * Class which generates the page tree
240 *
241 * @author Kasper Skårhøj <kasper@typo3.com>
242 * @package TYPO3
243 * @subpackage core
244 */
245 class localPageTree extends t3lib_browseTree {
246
247 function localPageTree() {
248 $this->init();
249 }
250
251 /**
252 * @param [type] $title: ...
253 * @param [type] $v: ...
254 * @param [type] $ext_pArrPages: ...
255 * @return [type] ...
256 */
257 function wrapTitle($title,$v,$ext_pArrPages) {
258 $title= (!strcmp(trim($title),'')) ? '<em>['.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.no_title').']</em>' : htmlspecialchars($title);
259
260 if ($this->ext_isLinkable($v['doktype'],$v['uid'])) {
261 return '<a href="#" onclick="return link_typo3Page(\''.$v["uid"].'\');">'.$title.'</a>';
262 } else {
263 return '<font color=#666666>'.$title.'</font>';
264 }
265 }
266
267 /**
268 * [Describe function...]
269 *
270 * @param [type] $treeArr: ...
271 * @return [type] ...
272 */
273 function printTree($treeArr="") {
274 $titleLen=intval($GLOBALS["BE_USER"]->uc["titleLen"]);
275 if (!is_array($treeArr)) $treeArr=$this->tree;
276 reset($treeArr);
277 $out="";
278 $c=0;
279 $xCol = t3lib_div::modifyHTMLColor($GLOBALS["SOBE"]->doc->bgColor,-10,-10,-10);
280 while(list($k,$v)=each($treeArr)) {
281 $c++;
282 $bgColor=' bgColor="'.(($c+1)%2 ? $GLOBALS["SOBE"]->doc->bgColor : $xCol).'"';
283 if ($GLOBALS["curUrlInfo"]["act"]=="page" && $GLOBALS["curUrlInfo"]["pageid"]==$v["row"]["uid"] && $GLOBALS["curUrlInfo"]["pageid"]) {
284 $arrCol='<td><img src="gfx/blinkarrow_right.gif" width="5" height="9" vspace=1></td>';
285 $bgColor=' bgColor="'.$GLOBALS["SOBE"]->doc->bgColor4.'"';
286 } else {$arrCol='<td></td>';}
287 $cEbullet = $this->ext_isLinkable($v["row"]["doktype"],$v["row"]["uid"]) ? '<a href="#" onclick="return jumpToUrl(\''.$this->script.'?act='.$GLOBALS["act"].'&mode='.$GLOBALS["mode"].'&expandPage='.$v["row"]["uid"].'\');"><img src="gfx/ol/arrowbullet.gif" width="18" hspace=5 height="16" border="0"></a>' : '';
288 $out.='<tr'.$bgColor.'><td nowrap>'.$v["HTML"].$this->wrapTitle(t3lib_div::fixed_lgd($v["row"]["title"],$titleLen),$v["row"],$this->ext_pArrPages).'</td>'.$arrCol.'<td>'.$cEbullet.'</td></tr>';
289 }
290 $out='<table border=0 cellpadding=0 cellspacing=0>'.$out.'</table>';
291 return $out;
292 }
293
294 /**
295 * [Describe function...]
296 *
297 * @param [type] $doktype: ...
298 * @param [type] $uid: ...
299 * @return [type] ...
300 */
301 function ext_isLinkable($doktype,$uid) {
302 if ($uid && $doktype<199) {
303 return true;
304 }
305 }
306
307 /**
308 * [Describe function...]
309 *
310 * @param [type] $icon: ...
311 * @param [type] $cmd: ...
312 * @param [type] $bMark: ...
313 * @return [type] ...
314 */
315 function PM_ATagWrap($icon,$cmd,$bMark="") {
316 if ($bMark) {
317 $anchor = "#".$bMark;
318 $name=' name="'.$bMark.'"';
319 }
320 return '<a href="#"'.$name.' onclick="return jumpToUrl(\''.$this->script.'?PM='.$cmd.'\',\''.$anchor.'\');">'.$icon.'</a>';
321 }
322
323 /**
324 * [Describe function...]
325 *
326 * @param [type] $icon: ...
327 * @param [type] $row: ...
328 * @return [type] ...
329 */
330 function wrapIcon($icon,$row) {
331 return substr($icon,0,-1).' title="id='.$row["uid"].'">';
332 }
333 }
334
335
336
337
338
339 /**
340 * For RTE
341 *
342 * @author Kasper Skårhøj <kasper@typo3.com>
343 * @package TYPO3
344 * @subpackage core
345 */
346 class rtePageTree extends localPageTree {
347 }
348
349
350
351
352
353 /**
354 * For TBE record browser
355 *
356 * @author Kasper Skårhøj <kasper@typo3.com>
357 * @package TYPO3
358 * @subpackage core
359 */
360 class TBE_PageTree extends localPageTree {
361
362 /**
363 * @param [type] $doktype: ...
364 * @param [type] $uid: ...
365 * @return [type] ...
366 */
367 function ext_isLinkable($doktype,$uid) {
368 return true;
369 }
370
371 /**
372 * [Describe function...]
373 *
374 * @param [type] $title: ...
375 * @param [type] $v: ...
376 * @param [type] $ext_pArrPages: ...
377 * @return [type] ...
378 */
379 function wrapTitle($title,$v,$ext_pArrPages) {
380 $title= (!strcmp(trim($title),"")) ? "<em>[".$GLOBALS["LANG"]->sL("LLL:EXT:lang/locallang_core.php:labels.no_title")."]</em>" : htmlspecialchars($title);
381 if ($ext_pArrPages) {
382 $ficon=t3lib_iconWorks::getIcon("pages",$v);
383 $onClick = "return insertElement('pages', '".$v["uid"]."', 'db', unescape('".rawurlencode($v["title"])."'), '', '', '".$ficon."','',1);";
384 } else {
385 $onClick = 'return jumpToUrl(\'browse_links.php?act='.$GLOBALS["act"].'&mode='.$GLOBALS["mode"].'&expandPage='.$v["uid"].'\');';
386 }
387 return '<a href="#" onclick="'.htmlspecialchars($onClick).'">'.$title.'</a>';
388 }
389 }
390
391
392
393
394
395 /**
396 * Class which generates the folder tree
397 *
398 * @author Kasper Skårhøj <kasper@typo3.com>
399 * @package TYPO3
400 * @subpackage core
401 */
402 class localFolderTree extends t3lib_folderTree {
403
404 /**
405 * @param [type] $title: ...
406 * @param [type] $v: ...
407 * @return [type] ...
408 */
409 function wrapTitle($title,$v) {
410 if ($this->ext_isLinkable($v)) {
411 return '<a href="#" onclick="return jumpToUrl(\''.$this->script.'?act='.$GLOBALS["act"].'&mode='.$GLOBALS["mode"].'&expandFolder='.rawurlencode($v["path"]).'\');">'.$title.'</a>';
412 // return '<a href="#" onclick="return link_folder(\''.$this->ext_getRelFolder($v["path"]).'\');">'.$title.'</a>';
413 } else {
414 return '<font color=#666666>'.$title.'</font>';
415 }
416 }
417
418 /**
419 * [Describe function...]
420 *
421 * @param [type] $treeArr: ...
422 * @return [type] ...
423 */
424 function printTree($treeArr="") {
425 $titleLen=intval($GLOBALS["BE_USER"]->uc["titleLen"]);
426 if (!is_array($treeArr)) $treeArr=$this->tree;
427 reset($treeArr);
428 $out="";
429 $c=0;
430 $xCol = t3lib_div::modifyHTMLColorAll($GLOBALS["SOBE"]->doc->bgColor,-10);
431 if (!$GLOBALS["curUrlInfo"]["value"]) {
432 $cmpPath="";
433 } else if (substr(trim($GLOBALS["curUrlInfo"]["info"]),-1)!="/") {
434 $cmpPath=PATH_site.dirname($GLOBALS["curUrlInfo"]["info"])."/";
435 } else {
436 $cmpPath=PATH_site.$GLOBALS["curUrlInfo"]["info"];
437 }
438 while(list($k,$v)=each($treeArr)) {
439 $c++;
440 $bgColor=' bgColor="'.(($c+1)%2 ? $GLOBALS["SOBE"]->doc->bgColor : $xCol).'"';
441 if ($GLOBALS["curUrlInfo"]["act"]=="file" && $cmpPath==$v["row"]["path"]) {
442 $arrCol='<td><img src="gfx/blinkarrow_right.gif" width="5" height="9" vspace=1></td>';
443 $bgColor=' bgColor="'.$GLOBALS["SOBE"]->doc->bgColor4.'"';
444 } else {$arrCol='<td></td>';}
445 $cEbullet = $this->ext_isLinkable($v["row"]) ? '<a href="#" onclick="return jumpToUrl(\''.$this->script.'?act='.$GLOBALS["act"].'&mode='.$GLOBALS["mode"].'&expandFolder='.rawurlencode($v["row"]["path"]).'\');"><img src="gfx/ol/arrowbullet.gif" width="18" hspace=5 height="16" border="0"></a>' : '';
446 $out.='<tr'.$bgColor.'><td nowrap>'.$v["HTML"].$this->wrapTitle(t3lib_div::fixed_lgd($v["row"]["title"],$titleLen),$v["row"]).'</td>'.$arrCol.'<td>'.$cEbullet.'</td></tr>';
447 }
448 $out='<table border=0 cellpadding=0 cellspacing=0>'.$out.'</table>';
449 return $out;
450 }
451
452 /**
453 * [Describe function...]
454 *
455 * @param [type] $v: ...
456 * @return [type] ...
457 */
458 function ext_isLinkable($v) {
459 // debug($v);
460 $webpath=t3lib_BEfunc::getPathType_web_nonweb($v["path"]);
461 // debug($webpath);
462 if (strstr($v["path"],"_recycler_") || strstr($v["path"],"_temp_") || $webpath!="web") {
463 return 0;
464 }
465 return 1;
466 }
467
468 /**
469 * [Describe function...]
470 *
471 * @param [type] $icon: ...
472 * @param [type] $cmd: ...
473 * @param [type] $bMark: ...
474 * @return [type] ...
475 */
476 function PM_ATagWrap($icon,$cmd,$bMark="") {
477 if ($bMark) {
478 $anchor = "#".$bMark;
479 $name=' name="'.$bMark.'"';
480 }
481 return '<a href="#"'.$name.' onclick="return jumpToUrl(\''.$this->script.'?PM='.$cmd.'\',\''.$anchor.'\');">'.$icon.'</a>';
482 }
483
484 /**
485 * [Describe function...]
486 *
487 * @param [type] $path: ...
488 * @return [type] ...
489 */
490 function ext_getRelFolder($path) {
491 return substr($path,strlen(PATH_site));
492 }
493 }
494
495
496
497
498
499
500 /**
501 * For RTE
502 *
503 * @author Kasper Skårhøj <kasper@typo3.com>
504 * @package TYPO3
505 * @subpackage core
506 */
507 class rteFolderTree extends localFolderTree {
508 }
509
510
511
512 /**
513 * For TBE File Browser
514 *
515 * @author Kasper Skårhøj <kasper@typo3.com>
516 * @package TYPO3
517 * @subpackage core
518 */
519 class TBE_FolderTree extends localFolderTree {
520 var $ext_noTempRecyclerDirs=0;
521
522 /**
523 * @param [type] $v: ...
524 * @return [type] ...
525 */
526 function ext_isLinkable($v) {
527 if ($this->ext_noTempRecyclerDirs && (substr($v["path"],-7)=="_temp_/" || substr($v["path"],-11)=="_recycler_/")) {
528 return 0;
529 } return 1;
530 }
531
532 /**
533 * [Describe function...]
534 *
535 * @param [type] $title: ...
536 * @param [type] $v: ...
537 * @return [type] ...
538 */
539 function wrapTitle($title,$v) {
540 if ($this->ext_isLinkable($v)) {
541 return '<a href="#" onclick="return jumpToUrl(\'browse_links.php?act='.$GLOBALS["act"].'&mode='.$GLOBALS["mode"].'&expandFolder='.rawurlencode($v["path"]).'\');">'.$title.'</a>';
542 } else {
543 return '<font color=#666666>'.$title.'</font>';
544 }
545 }
546 }
547
548
549
550
551
552 /**
553 * Script class
554 *
555 * @author Kasper Skårhøj <kasper@typo3.com>
556 * @package TYPO3
557 * @subpackage core
558 */
559 class SC_browse_links {
560 var $pointer;
561 var $siteURL;
562 var $thisConfig;
563 var $setTarget;
564 var $doc;
565
566 /**
567 * Constructor
568 *
569 * @return [type] ...
570 */
571 function init() {
572 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$HTTP_GET_VARS,$HTTP_POST_VARS,$CLIENT,$TYPO3_CONF_VARS;
573 global $act,$mode,$curUrlInfo,$curUrlArray;
574
575 $this->pointer = t3lib_div::GPvar("pointer");
576
577
578 // **************************
579 // For RTE/Link: Pre-processing
580 // **************************
581 $addPassOnParams="";
582
583 // Current site url:
584 $this->siteURL = t3lib_div::getIndpEnv("TYPO3_SITE_URL");
585
586 // CurrentUrl - the current link url must be passed around if it exists
587 $curUrlArray = t3lib_div::GPvar("curUrl",1);
588 if ($curUrlArray["all"]) {
589 $curUrlArray=t3lib_div::get_tag_attributes($curUrlArray["all"]);
590 }
591 // debug($curUrlArray);
592 $curUrlInfo=$this->parseCurUrl($curUrlArray["href"],$this->siteURL);
593
594 // Determine nature of current url:
595 $act=t3lib_div::GPvar("act");
596 if (!$act) {
597 $act=$curUrlInfo["act"];
598 }
599
600 $mode=t3lib_div::GPvar("mode");
601 if (!$mode) {
602 $mode="rte";
603 }
604
605
606 if ((string)$mode=="rte") {
607 $RTEtsConfigParts = explode(":",t3lib_div::GPvar("RTEtsConfigParams"));
608 $addPassOnParams.="&RTEtsConfigParams=".rawurlencode(t3lib_div::GPvar("RTEtsConfigParams"));
609 $RTEsetup = $GLOBALS["BE_USER"]->getTSConfig("RTE",t3lib_BEfunc::getPagesTSconfig($RTEtsConfigParts[5]));
610 $this->thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup["properties"],$RTEtsConfigParts[0],$RTEtsConfigParts[2],$RTEtsConfigParts[4]);
611 }
612 $this->setTarget = $curUrlArray["target"];
613 if ($this->thisConfig["defaultLinkTarget"] && !isset($curUrlArray["target"])) {
614 $this->setTarget=$this->thisConfig["defaultLinkTarget"];
615 }
616
617 // **************************
618 // Main thing:
619 // **************************
620
621 $this->doc = t3lib_div::makeInstance("template");
622 $this->doc->backPath = $BACK_PATH;
623 $this->doc->JScode='
624 <script language="javascript" type="text/javascript">
625 // This JavaScript is primarily for RTE/Link. jumpToUrl is used in the other cases as well...
626
627 var add_href="'.($curUrlArray["href"]?"&curUrl[href]=".rawurlencode($curUrlArray["href"]):"").'";
628 var add_target="'.($this->setTarget?"&curUrl[target]=".rawurlencode($this->setTarget):"").'";
629 var add_params="'.(t3lib_div::GPvar("bparams")?"&bparams=".rawurlencode(t3lib_div::GPvar("bparams")):"").'";
630
631 var cur_href="'.($curUrlArray["href"]?$curUrlArray["href"]:"").'";
632 var cur_target="'.($this->setTarget?$this->setTarget:"").'";
633
634 //
635 function setTarget(target) {
636 cur_target=target;
637 add_target="&curUrl[target]="+target;
638 }
639 //
640 function setValue(value) {
641 cur_href=value;
642 add_href="&curUrl[href]="+value;
643 }
644 ';
645
646
647 if ($mode=="wizard") {
648 $P = t3lib_div::GPvar("P",1);
649 //debug($P);
650 unset($P["fieldChangeFunc"]["alert"]);
651 reset($P["fieldChangeFunc"]);
652 $update="";
653 while(list($k,$v)=each($P["fieldChangeFunc"])) {
654 $update.= "
655 window.opener.".$v;
656 }
657
658 $P2=array();
659 $P2["itemName"]=$P["itemName"];
660 $P2["formName"]=$P["formName"];
661 $P2["fieldChangeFunc"]=$P["fieldChangeFunc"];
662 $addPassOnParams.=t3lib_div::implodeArrayForUrl("P",$P2);
663
664 $this->doc->JScode.='
665 //
666 function link_typo3Page(id,anchor) {
667 updateValueInMainForm(id+(anchor?anchor:"")+" "+cur_target);
668 close();
669 return false;
670 }
671 //
672 function link_folder(folder) {
673 updateValueInMainForm(folder+" "+cur_target);
674 close();
675 return false;
676 }
677 //
678 function link_current() {
679 if (cur_href!="http://" && cur_href!="mailto:") {
680 var setValue = cur_href+" "+cur_target;
681 if (setValue.substr(0,7)=="http://") setValue = setValue.substr(7);
682 if (setValue.substr(0,7)=="mailto:") setValue = setValue.substr(7);
683 updateValueInMainForm(setValue);
684 close();
685 }
686 return false;
687 }
688 //
689 function checkReference() {
690 if (window.opener && window.opener.document && window.opener.document.'.$P["formName"].' && window.opener.document.'.$P["formName"].'["'.$P["itemName"].'"] ) {
691 return window.opener.document.'.$P["formName"].'["'.$P["itemName"].'"];
692 } else {
693 close();
694 }
695 }
696 //
697 function updateValueInMainForm(input) {
698 var field = checkReference();
699 if (field) {
700 field.value = input;
701 '.$update.'
702 }
703 }
704 ';
705 } else {
706 $this->doc->JScode.='
707 //
708 function link_typo3Page(id,anchor) {
709 var theLink = \''.$this->siteURL.'?id=\'+id+(anchor?anchor:"");
710 self.parent.parent.renderPopup_addLink(theLink,cur_target);
711 return false;
712 }
713 //
714 function link_folder(folder) {
715 var theLink = \''.$this->siteURL.'\'+folder;
716 self.parent.parent.renderPopup_addLink(theLink,cur_target);
717 return false;
718 }
719 //
720 function link_spec(theLink) {
721 self.parent.parent.renderPopup_addLink(theLink,cur_target);
722 return false;
723 }
724 //
725 function link_current() {
726 if (cur_href!="http://" && cur_href!="mailto:") {
727 self.parent.parent.renderPopup_addLink(cur_href,cur_target);
728 }
729 return false;
730 }
731 ';
732 }
733 $this->doc->JScode.='
734 //
735 function jumpToUrl(URL,anchor) {
736 var add_act = URL.indexOf("act=")==-1 ? "&act='.$act.'" : "";
737 var add_mode = URL.indexOf("mode=")==-1 ? "&mode='.$mode.'" : "";
738 var theLocation = URL+add_act+add_mode+add_href+add_target+add_params'.($addPassOnParams?'+"'.$addPassOnParams.'"':"").'+(anchor?anchor:"");
739 document.location = theLocation;
740 return false;
741 }
742 </script>
743 ';
744
745
746 // This is JavaScript especially for the TBE Element Browser!
747
748 $pArr = explode("|",t3lib_div::GPvar("bparams"));
749 #debug($pArr);
750 $formFieldName = 'data['.$pArr[0].']['.$pArr[1].']['.$pArr[2].']';
751 $this->doc->JScode.='
752 <script language="javascript" type="text/javascript">
753 var elRef="";
754 var targetDoc="";
755
756 //
757 function launchView(url) {
758 var thePreviewWindow="";
759 thePreviewWindow = window.open("show_item.php?table="+url,"ShowItem","height=300,width=410,status=0,menubar=0,resizable=0,location=0,directories=0,scrollbars=1,toolbar=0");
760 if (thePreviewWindow && thePreviewWindow.focus) {
761 thePreviewWindow.focus();
762 }
763 }
764 //
765 function setReferences() {
766 if (parent.typoWin
767 && parent.typoWin.content
768 && parent.typoWin.content.document.editform
769 && parent.typoWin.content.document.editform["'.$formFieldName.'"]
770 ) {
771 targetDoc = parent.typoWin.content.document;
772 elRef = targetDoc.editform["'.$formFieldName.'"];
773 return true;
774 } else {
775 return false;
776 }
777 }
778 //
779 function insertElement(table, uid, type, filename,fp,filetype,imagefile,action, close) {
780 if (1=='.($pArr[0]&&!$pArr[1]&&!$pArr[2] ? 1 : 0).') {
781 addElement(filename,table+"_"+uid,fp,close);
782 } else {
783 if (setReferences()) {
784 if (parent.typoWin.clipBrd.clipboard) parent.typoWin.clipBrd.clipboard.closing();
785 parent.typoWin.clipBrd.swPad("normal");
786 parent.typoWin.clipBrd.aI("normal", table, uid, type, filename,fp,filetype,imagefile,action);
787 parent.typoWin.group_change("add","'.$pArr[0].'","'.$pArr[1].'","'.$pArr[2].'",elRef,targetDoc);
788 } else {
789 alert("Error - reference to main window is not set properly!");
790 }
791 if (close) {
792 parent.typoWin.focus();
793 parent.close();
794 }
795 }
796 return false;
797 }
798 //
799 function addElement(elName,elValue,altElValue,close) {
800 if (parent.typoWin && parent.typoWin.setFormValueFromBrowseWin) {
801 parent.typoWin.setFormValueFromBrowseWin("'.$pArr[0].'",altElValue?altElValue:elValue,elName);
802 if (close) {
803 parent.typoWin.focus();
804 parent.close();
805 }
806 } else {
807 alert("Error - refderence to main window is not set properly!");
808 parent.close();
809 }
810 }
811 </script>';
812 }
813
814 /**
815 * [Describe function...]
816 *
817 * @return [type] ...
818 */
819 function main() {
820 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$HTTP_GET_VARS,$HTTP_POST_VARS,$CLIENT,$TYPO3_CONF_VARS;
821 global $act,$mode,$curUrlInfo,$curUrlArray;
822
823 $modData = $BE_USER->getModuleData("browse_links.php","ses");
824
825 // Output the correct content according to $mode
826 switch((string)$mode) {
827 case "rte":
828 $this->content="";
829 $this->content.=$this->main_rte();
830 break;
831 case "db":
832 $expandPage = t3lib_div::GPvar("expandPage");
833 if (isset($expandPage)) {
834 $modData["expandPage"]=$expandPage;
835 $BE_USER->pushModuleData("browse_links.php",$modData);
836 } else {
837 $HTTP_GET_VARS["expandPage"]=$modData["expandPage"];
838 }
839
840 $this->content="";
841 $this->content.=$this->main_db();
842 break;
843 case "file":
844 case "filedrag":
845 $expandPage = t3lib_div::GPvar("expandFolder");
846 if (isset($expandPage)) {
847 $modData["expandFolder"]=$expandPage;
848 $BE_USER->pushModuleData("browse_links.php",$modData);
849 } else {
850 $HTTP_GET_VARS["expandFolder"]=$modData["expandFolder"];
851 }
852
853 $this->content="";
854 $this->content.=$this->main_file("",$mode);
855 break;
856 case "wizard":
857 $this->content="";
858 $this->content.=$this->main_rte("",1);
859 break;
860 }
861
862 }
863
864 /**
865 * [Describe function...]
866 *
867 * @return [type] ...
868 */
869 function printContent() {
870 echo $this->content;
871 }
872
873
874
875
876 /******************************************************************
877 *
878 * OTHER FUNCTIONS:
879 * These functions are designed to display the records from a page
880 *
881 ******************************************************************/
882 /**
883 * For RTE: This displays all content elements on a page and lets you create a link to the element.
884 *
885 * @return [type] ...
886 */
887 function expandPage() {
888 $expandPage = t3lib_div::GPvar("expandPage");
889 $out="";
890 if ($expandPage) {
891 $out.=$this->barheader($GLOBALS["LANG"]->getLL("contentElements").':');
892
893 $titleLen=intval($GLOBALS["BE_USER"]->uc["titleLen"]);
894 $mainPageRec = t3lib_BEfunc::getRecord("pages",$expandPage);
895 $picon=t3lib_iconWorks::getIconImage("pages",$mainPageRec,"","align=top");
896 $picon.=htmlspecialchars(t3lib_div::fixed_lgd($mainPageRec["title"],$titleLen));
897 $out.='<nobr>'.$picon.'</nobr><BR>';
898
899 $query="SELECT uid,header,hidden,starttime,endtime,fe_group,CType,colpos FROM tt_content WHERE pid=".intval($expandPage).t3lib_BEfunc::deleteClause("tt_content")." ORDER BY colpos,sorting";
900 $res = mysql(TYPO3_db,$query);
901 echo mysql_error();
902 $cc=mysql_num_rows($res);
903 $c=0;
904 while($row=mysql_fetch_assoc($res)) {
905 $c++;
906 $icon=t3lib_iconWorks::getIconImage("tt_content",$row,"","align=top");
907 if ($GLOBALS["curUrlInfo"]["act"]=="page" && $GLOBALS["curUrlInfo"]["cElement"]==$row["uid"]) {
908 $arrCol='<img src="gfx/blinkarrow_left.gif" width="5" height="9" vspace=3 hspace=2 align=top>';
909 } else {$arrCol="";}
910 $out.='<nobr><img src="gfx/ol/join'.($c==$cc?"bottom":"").'.gif" width="18" height="16" align=top>'.$arrCol.'<a href="#" onclick="return link_typo3Page(\''.$expandPage.'\',\'#'.$row["uid"].'\');">'.$icon.htmlspecialchars(t3lib_div::fixed_lgd($row["header"],$titleLen)).'</a></nobr><BR>';
911 // debug($row);
912 }
913 }
914 return $out;
915 }
916
917 /**
918 * For TBE Record Browser: This lists all content elements from the given category!
919 *
920 * @param [type] $tables: ...
921 * @return [type] ...
922 */
923 function TBE_expandPage($tables) {
924 global $TCA;
925 $expandPage = t3lib_div::GPvar("expandPage");
926 /* if (isset($id)) {
927 $expandPage=$id;
928 }
929 */ $out="";
930 if (t3lib_div::testInt($expandPage) && $expandPage>=0) {
931 if (!strcmp(trim($tables),"*")) {
932 $tablesArr = array_keys($TCA);
933 } else {
934 $tablesArr = t3lib_div::trimExplode(",",$tables,1);
935 }
936
937 reset($tablesArr);
938 $titleLen=intval($GLOBALS["BE_USER"]->uc["titleLen"]);
939
940 $out.=$this->barheader($GLOBALS["LANG"]->getLL("selectRecords").':');
941
942 $mainPageRec = t3lib_BEfunc::getRecord("pages",$expandPage);
943 $ATag="";
944 $ATag_e="";
945 if (in_array("pages",$tablesArr)) {
946 $ficon=t3lib_iconWorks::getIcon("pages",$mainPageRec);
947 $ATag="<a href=\"#\" onclick=\"return insertElement('pages', '".$mainPageRec["uid"]."', 'db', unescape('".rawurlencode($mainPageRec["title"])."'), '', '', '".$ficon."','',1);\">";
948 $ATag2="<a href=\"#\" onclick=\"return insertElement('pages', '".$mainPageRec["uid"]."', 'db', unescape('".rawurlencode($mainPageRec["title"])."'), '', '', '".$ficon."','',0);\">";
949 $ATag_alt=substr($ATag,0,-4).",'',1);\">";
950 $ATag_e="</a>";
951 }
952 $picon=t3lib_iconWorks::getIconImage("pages",$mainPageRec,"","align=top");
953 $pBicon='<img src="gfx/plusbullet2.gif" width="18" height="16" border="0" align="top">';
954 $pText=htmlspecialchars(t3lib_div::fixed_lgd($mainPageRec["title"],$titleLen));
955 $out.='<nobr>'.$picon.$ATag2.$pBicon.$ATag_e.$ATag.$pText.$ATag_e.'</nobr><BR>';
956
957
958
959
960
961 $id = $expandPage;
962 $pointer = t3lib_div::intInRange($this->pointer,0,100000);
963 $perms_clause = $GLOBALS["BE_USER"]->getPagePermsClause(1);
964 $pageinfo = t3lib_BEfunc::readPageAccess($id,$perms_clause);
965 $table="";
966
967 $dblist = t3lib_div::makeInstance("TBE_browser_recordList");
968 $dblist->script="browse_links.php";
969 $dblist->backPath = $GLOBALS["BACK_PATH"];
970 $dblist->thumbs = 0;
971 $dblist->calcPerms = $GLOBALS["BE_USER"]->calcPerms($pageinfo);
972 $dblist->noControlPanels=1;
973 $dblist->tableList=implode(",",$tablesArr);
974
975 $dblist->start($id,t3lib_div::GPvar("table"),$pointer,
976 t3lib_div::GPvar("search_field"),
977 t3lib_div::GPvar("search_levels"),
978 t3lib_div::GPvar("showLimit")
979 );
980 $dblist->setDispFields();
981 // $dblist->writeTop($pageinfo,$pageinfo["_thePath"]);
982 $dblist->generateList($id,$table);
983 $dblist->writeBottom();
984
985
986 $out.=$dblist->HTMLcode;
987 $out.=$dblist->getSearchBox();
988
989 /*
990
991 while(list(,$table)=each($tablesArr)) {
992 if ($table=="tt_content" && $TCA[$table]) {
993 $query="SELECT uid,header,hidden,starttime,endtime,fe_group,CType,colpos FROM tt_content WHERE pid=".intval($expandPage).t3lib_BEfunc::deleteClause("tt_content")." ORDER BY colpos,sorting";
994 $res = mysql(TYPO3_db,$query);
995 echo mysql_error();
996 $cc=mysql_num_rows($res);
997 $c=0;
998 while($row=mysql_fetch_assoc($res)) {
999 $c++;
1000 $icon=t3lib_iconWorks::getIconImage("tt_content",$row,"","align=top");
1001
1002 $ficon=t3lib_iconWorks::getIcon("tt_content",$row);
1003 $ATag="<a href=\"#\" onclick=\"return insertElement('".$table."', '".$row["uid"]."', 'db', unescape('".rawurlencode($row["header"])."'), '', '', '".$ficon."');\">";
1004 $ATag_alt=substr($ATag,0,-4).",'',1);\">";
1005 $ATag_e="</a>";
1006
1007 $out.='<nobr><img src="gfx/ol/join'.($c==$cc?"bottom":"").'.gif" width="18" height="16" align=top>'.$ATag.$icon.htmlspecialchars(t3lib_div::fixed_lgd($row["header"],$titleLen)).$ATag_e.'</nobr><BR>';
1008 // debug($row);
1009 }
1010 }
1011 }
1012 */
1013
1014
1015
1016 }
1017 return $out;
1018 }
1019
1020 /**
1021 * [Describe function...]
1022 *
1023 * @param [type] $folder: ...
1024 * @return [type] ...
1025 */
1026 function isWebFolder($folder) {
1027 $folder = ereg_replace("\/$","",$folder)."/";
1028 return t3lib_div::isFirstPartOfStr($folder,PATH_site);
1029 }
1030
1031 /**
1032 * [Describe function...]
1033 *
1034 * @param [type] $folder: ...
1035 * @return [type] ...
1036 */
1037 function checkFolder($folder) {
1038 $fileProcessor = t3lib_div::makeInstance("t3lib_basicFileFunctions");
1039 $fileProcessor->init($GLOBALS["FILEMOUNTS"], $GLOBALS["TYPO3_CONF_VARS"]["BE"]["fileExtensions"]);
1040 //debug(array($GLOBALS["FILEMOUNTS"],$folder."/"));
1041 $ret= $fileProcessor->checkPathAgainstMounts(ereg_replace("\/$","",$folder)."/");
1042 //debug($ret);
1043 return $ret;
1044 }
1045
1046
1047
1048 /******************************************************************
1049 *
1050 * OTHER FUNCTIONS:
1051 * These functions are designed to display the files from a folder
1052 *
1053 ******************************************************************/
1054 /**
1055 * For RTE: This displays all files from folder. No thumbnails shown
1056 *
1057 * @param [type] $expandFolder: ...
1058 * @param [type] $extensionList: ...
1059 * @return [type] ...
1060 */
1061 function expandFolder($expandFolder=0,$extensionList="") {
1062 $expandFolder = $expandFolder?$expandFolder:t3lib_div::GPvar("expandFolder");
1063 $out="";
1064 if ($expandFolder && $this->checkFolder($expandFolder)) {
1065 $out.=$this->barheader($GLOBALS["LANG"]->getLL("files").':');
1066
1067 if (!$GLOBALS["curUrlInfo"]["value"]) {
1068 $cmpPath="";
1069 } else $cmpPath=PATH_site.$GLOBALS["curUrlInfo"]["info"];
1070
1071 $titleLen=intval($GLOBALS["BE_USER"]->uc["titleLen"]);
1072 $picon='<img src="gfx/i/_icon_webfolders.gif" width="18" height="16" align=top border=0>';
1073 $picon.=htmlspecialchars(t3lib_div::fixed_lgd(basename($expandFolder),$titleLen));
1074 $picon='<a href="#" onclick="return link_folder(\''.substr($expandFolder,strlen(PATH_site)).'\');">'.$picon.'</a>';
1075 $out.='<nobr>'.$picon.'</nobr><BR>';
1076
1077 $files = t3lib_div::getFilesInDir($expandFolder,$extensionList,1,1); // $extensionList="",$prependPath=0,$order="")
1078 reset($files);
1079 $c=0;
1080 $cc=count($files);
1081 while(list(,$filepath)=each($files)) {
1082 $c++;
1083 $fI=pathinfo($filepath);
1084 // debug($fI);
1085 $icon = t3lib_BEfunc::getFileIcon(strtolower($fI["extension"]));
1086 if ($GLOBALS["curUrlInfo"]["act"]=="file" && $cmpPath==$filepath) {
1087 $arrCol='<img src="gfx/blinkarrow_left.gif" width="5" height="9" vspace=3 hspace=2 align=top>';
1088 } else {$arrCol='';}
1089 $size=" (".t3lib_div::formatSize(filesize($filepath))."bytes)";
1090 $icon = '<img src="gfx/fileicons/'.$icon.'" width=18 height=16 border=0 title="'.$fI["basename"].$size.'" align=top>';
1091 $out.='<nobr><img src="gfx/ol/join'.($c==$cc?"bottom":"").'.gif" width="18" height="16" align=top>'.$arrCol.'<a href="#" onclick="return link_folder(\''.substr($filepath,strlen(PATH_site)).'\');">'.$icon.htmlspecialchars(t3lib_div::fixed_lgd(basename($filepath),$titleLen)).'</a></nobr><BR>';
1092 }
1093 }
1094 return $out;
1095 }
1096
1097 /**
1098 * [Describe function...]
1099 *
1100 * @param [type] $expandFolder: ...
1101 * @param [type] $extensionList: ...
1102 * @return [type] ...
1103 */
1104 function TBE_expandFolder($expandFolder=0,$extensionList="") {
1105 global $LANG;
1106 $expandFolder = $expandFolder?$expandFolder:t3lib_div::GPvar("expandFolder");
1107 $out="";
1108 if ($expandFolder && $this->checkFolder($expandFolder)) {
1109 $files = t3lib_div::getFilesInDir($expandFolder,$extensionList,1,1); // $extensionList="",$prependPath=0,$order="")
1110 if (is_array($files)) {
1111 reset($files);
1112
1113 $out.=$this->barheader(sprintf($GLOBALS["LANG"]->getLL("files").' (%s):',count($files)));
1114
1115 $titleLen=intval($GLOBALS["BE_USER"]->uc["titleLen"]);
1116 $picon='<img src="gfx/i/_icon_webfolders.gif" width="18" height="16" align=top>';
1117 $picon.=htmlspecialchars(t3lib_div::fixed_lgd(basename($expandFolder),$titleLen));
1118 $out.='<nobr>'.$picon.'</nobr><BR>';
1119
1120 $imgObj = t3lib_div::makeInstance("t3lib_stdGraphic");
1121 $imgObj->init();
1122 $imgObj->mayScaleUp=0;
1123 $imgObj->tempPath=PATH_site.$imgObj->tempPath;
1124
1125 $noThumbs = $GLOBALS["BE_USER"]->getTSConfigVal("options.noThumbsInEB");
1126
1127 $lines=array();
1128 while(list(,$filepath)=each($files)) {
1129 $fI=pathinfo($filepath);
1130
1131 $iurl = $this->siteURL.substr($filepath,strlen(PATH_site));
1132
1133 if (t3lib_div::inList($GLOBALS["TYPO3_CONF_VARS"]["GFX"]["imagefile_ext"],$fI["extension"]) && !$noThumbs) {
1134 $imgInfo = $imgObj->getImageDimensions($filepath);
1135 $pDim = $imgInfo[0]."x".$imgInfo[1]." pixels";
1136 $clickIcon = t3lib_BEfunc::getThumbNail("thumbs.php",$filepath,"hspace=5 vspace=5 border=1");
1137 } else {
1138 $clickIcon = '';
1139 $pDim = "";
1140 }
1141
1142 $ficon = t3lib_BEfunc::getFileIcon(strtolower($fI["extension"]));
1143 $size=" (".t3lib_div::formatSize(filesize($filepath))."bytes".($pDim?", ".$pDim:"").")";
1144 $icon = '<img src="gfx/fileicons/'.$ficon.'" width=18 height=16 border=0 title="'.$fI["basename"].$size.'" align=absmiddle>';
1145
1146 // table, uid, type, filename,fp,filetype,imagefile,action
1147 $ATag = "<a href=\"#\" onclick=\"return insertElement('','".t3lib_div::shortMD5($filepath)."', 'file', '".rawurlencode($fI["basename"])."', unescape('".rawurlencode($filepath)."'), '".$fI["extension"]."', '".$ficon."');\">";
1148 $ATag_alt = substr($ATag,0,-4).",'',1);\">";
1149 $ATag_e="</a>";
1150
1151 // $ATag2='<a href="#" onclick="launchView(\''.rawurlencode($filepath).'\'); return false;">';
1152 $ATag2='<a href="show_item.php?table='.rawurlencode($filepath).'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv("REQUEST_URI")).'">';
1153 $ATag2_e="</a>";
1154
1155 $filenameAndIcon=$ATag_alt.$icon.htmlspecialchars(t3lib_div::fixed_lgd(basename($filepath),$titleLen)).$ATag_e;
1156
1157 if ($pDim) { // Image...
1158 $lines[]='<tr bgcolor="'.$this->doc->bgColor4.'">
1159 <td nowrap>'.$filenameAndIcon.'&nbsp;</td>
1160 <td>'.$ATag.'<img src="gfx/plusbullet2.gif" width="18" height="16" border="0"'.t3lib_BEfunc::titleAttrib($LANG->getLL("addToList")).'>'.$ATag_e.'</td>
1161 <td nowrap>'.($ATag2.'<img src="gfx/zoom2.gif" width="12" height="12" border="0" align=top'.t3lib_BEfunc::titleAttrib($LANG->getLL("info")).'> '.$LANG->getLL("info").$ATag2_e).'</td>
1162 <td nowrap>&nbsp;'.$pDim.'</td>
1163 </tr>';
1164 $lines[]='<tr><td colspan=4>'.$ATag_alt.$clickIcon.$ATag_e.'</td></tr>';
1165 } else {
1166 $lines[]='<tr bgcolor="'.$this->doc->bgColor4.'">
1167 <td nowrap>'.$filenameAndIcon.'&nbsp;</td>
1168 <td>'.$ATag.'<img src="gfx/plusbullet2.gif" width="18" height="16" border="0"'.t3lib_BEfunc::titleAttrib($LANG->getLL("addToList")).'>'.$ATag_e.'</td>
1169 <td nowrap>'.($ATag2.'<img src="gfx/zoom2.gif" width="12" height="12" border="0" align=top'.t3lib_BEfunc::titleAttrib($LANG->getLL("info")).'> '.$LANG->getLL("info").$ATag2_e).'</td>
1170 <td>&nbsp;</td>
1171 </tr>';
1172 }
1173 $lines[]='<tr><td colspan=3><img src=clear.gif width=1 height=3></td></tr>';
1174 }
1175 $out.='<table border=0 cellpadding=0 cellspacing=1>'.implode("",$lines).'</table>';
1176 }
1177 }
1178 return $out;
1179 }
1180
1181 /**
1182 * For RTE: This displays all files (from extensionList) from folder. Thumbnails are shown for images.
1183 *
1184 * @param [type] $expandFolder: ...
1185 * @param [type] $extensionList: ...
1186 * @return [type] ...
1187 */
1188 function TBE_dragNDrop($expandFolder=0,$extensionList="") {
1189 $expandFolder = $expandFolder?$expandFolder:t3lib_div::GPvar("expandFolder");
1190 $out="";
1191 if ($expandFolder && $this->checkFolder($expandFolder)) {
1192 if ($this->isWebFolder($expandFolder)) {
1193 $files = t3lib_div::getFilesInDir($expandFolder,$extensionList,1,1); // $extensionList="",$prependPath=0,$order="")
1194 if (is_array($files)) {
1195 reset($files);
1196
1197 $out.=$this->barheader(sprintf($GLOBALS["LANG"]->getLL("files").' (%s):',count($files)));
1198
1199 $titleLen=intval($GLOBALS["BE_USER"]->uc["titleLen"]);
1200 $picon='<img src="gfx/i/_icon_webfolders.gif" width="18" height="16" align=top>';
1201 $picon.=htmlspecialchars(t3lib_div::fixed_lgd(basename($expandFolder),$titleLen));
1202 $out.='<nobr>'.$picon.'</nobr><BR>';
1203
1204 $lines=array();
1205 $lines[]='<tr><td colspan=2>'.$this->getMsgBox($GLOBALS["LANG"]->getLL("findDragDrop")).'</td></tr>';
1206
1207 while(list(,$filepath)=each($files)) {
1208 $fI=pathinfo($filepath);
1209
1210 $iurl = $this->siteURL.substr($filepath,strlen(PATH_site));
1211
1212 if (t3lib_div::inList("gif,jpeg,jpg,png",$fI["extension"])) {
1213 $imgInfo = @getimagesize($filepath);
1214 $pDim = $imgInfo[0]."x".$imgInfo[1]." pixels";
1215
1216 $ficon = t3lib_BEfunc::getFileIcon(strtolower($fI["extension"]));
1217 $size=" (".t3lib_div::formatSize(filesize($filepath))."bytes".($pDim?", ".$pDim:"").")";
1218 $icon = '<img src="gfx/fileicons/'.$ficon.'" width=18 height=16 border=0 title="'.$fI["basename"].$size.'" align=absmiddle>';
1219 $filenameAndIcon=$icon.htmlspecialchars(t3lib_div::fixed_lgd(basename($filepath),$titleLen));
1220
1221 if (t3lib_div::GPvar("noLimit")) {
1222 $maxW=10000;
1223 $maxH=10000;
1224 } else {
1225 $maxW=380;
1226 $maxH=500;
1227 }
1228 $IW = $imgInfo[0];
1229 $IH = $imgInfo[1];
1230 if ($IW>$maxW) {
1231 $IH=ceil($IH/$IW*$maxW);
1232 $IW=$maxW;
1233 }
1234 if ($IH>$maxH) {
1235 $IW=ceil($IW/$IH*$maxH);
1236 $IH=$maxH;
1237 }
1238
1239
1240 $lines[]='<tr bgcolor="'.$this->doc->bgColor4.'">
1241 <td nowrap>'.$filenameAndIcon.'&nbsp;</td>
1242 <td nowrap>'.
1243 ($imgInfo[0]!=$IW ? '<a href="'.t3lib_div::linkThisScript(array("noLimit"=>"1")).'"><img src="gfx/icon_warning2.gif" width="18" height="16" border="0"'.t3lib_BEfunc::titleAttrib($GLOBALS["LANG"]->getLL("clickToRedrawFullSize")).' align=top></a>':'').
1244
1245 $pDim.'&nbsp;</td>
1246 </tr>';
1247
1248 $lines[]='<tr><td colspan=2><img src="'.$iurl.'" width="'.$IW.'" height="'.$IH.'" border=1></td></tr>';
1249 $lines[]='<tr><td colspan=2><img src=clear.gif width=1 height=3></td></tr>';
1250 }
1251 }
1252 $out.='<table border=0 cellpadding=0 cellspacing=1>'.implode("",$lines).'</table>';
1253 }
1254 } else {
1255 $out.=$this->barheader($GLOBALS["LANG"]->getLL("files"));
1256 $out.=$this->getMsgBox($GLOBALS["LANG"]->getLL("noWebFolder"),"icon_warning2");
1257 }
1258 }
1259 return $out;
1260 }
1261
1262 /**
1263 * [Describe function...]
1264 *
1265 * @param [type] $in_msg: ...
1266 * @param [type] $icon: ...
1267 * @return [type] ...
1268 */
1269 function getMsgBox($in_msg,$icon="icon_note") {
1270 $msg = '<img src="gfx/'.$icon.'.gif" width="18" height="16" align=top>'.$in_msg;
1271 $msg = '<table border=1 align=center width="95%" bordercolor="black" cellpadding=10 cellspacing=0 bgColor="'.$this->doc->bgColor4.'"><tr><td>'.$msg.'</td></tr></table><BR>';
1272 return $msg;
1273 }
1274
1275
1276
1277
1278 /******************************************************************
1279 *
1280 * Miscellaneous functions
1281 *
1282 ******************************************************************/
1283
1284 /**
1285 * Prints a 'header' where string is in a tablecell
1286 *
1287 * @param [type] $str: ...
1288 * @return [type] ...
1289 */
1290 function barheader($str) {
1291 return '<table border=0 cellpadding=2 cellspacing=0 width=100% bgcolor="'.$this->doc->bgColor5.'"><tr><td><strong>'.$str.'</strong></td></tr></table>';
1292 }
1293
1294 /**
1295 * For RTE/link: This prints the 'currentUrl'
1296 *
1297 * @param [type] $str: ...
1298 * @return [type] ...
1299 */
1300 function printCurrentUrl($str) {
1301 return '<table border=0 cellpadding=0 cellspacing=0 width=100% bgcolor="'.$this->doc->bgColor5.'"><tr><td><strong>'.$GLOBALS["LANG"]->getLL("currentLink").':</strong> '.$str.'</td></tr></table>';
1302 }
1303
1304 /**
1305 * For RTE/link: Parses the incoming URL and determins if it's a page, file, external or mail address.
1306 *
1307 * @param [type] $href: ...
1308 * @param [type] $siteUrl: ...
1309 * @return [type] ...
1310 */
1311 function parseCurUrl($href,$siteUrl) {
1312 $href = trim($href);
1313 if ($href) {
1314 $info=array();
1315
1316 // Default is "url":
1317 $info["value"]=$href;
1318 $info["act"]="url";
1319
1320 $specialParts = explode("#_SPECIAL",$href);
1321 if (count($specialParts)==2) {
1322 $info["value"]="#_SPECIAL".$specialParts[1];
1323 $info["act"]="spec";
1324 } elseif (t3lib_div::isFirstPartOfStr($href,$siteUrl)) { // Checking for other kinds:
1325 $rel = substr($href,strlen($siteUrl));
1326 if (@file_exists(PATH_site.$rel)) {
1327 $info["value"]=$rel;
1328 $info["act"]="file";
1329 } else {
1330 $uP=parse_url($rel);
1331 if (!trim($uP["path"])) {
1332 $pp = explode("id=",$uP["query"]);
1333 $id = $pp[1];
1334 if ($id) {
1335 // Checking if the id-parameter is an alias.
1336 if (!t3lib_div::testInt($id)) {
1337 list($idPartR) = t3lib_BEfunc::getRecordsByField("pages","alias",$id);
1338 $id=intval($idPartR["uid"]);
1339 }
1340
1341 $pageRow = t3lib_BEfunc::getRecord("pages",$id);
1342 $titleLen=intval($GLOBALS["BE_USER"]->uc["titleLen"]);
1343 $info["value"]=$GLOBALS["LANG"]->getLL("page")." '".htmlspecialchars(t3lib_div::fixed_lgd($pageRow["title"],$titleLen))."' (ID:".$id.($uP["fragment"]?", #".$uP["fragment"]:"").")";
1344 $info["pageid"]=$id;
1345 $info["cElement"]=$uP["fragment"];
1346 $info["act"]="page";
1347 }
1348 }
1349 }
1350 } else {
1351 if (strtolower(substr($href,0,7))=="mailto:") {
1352 $info["value"]=trim(substr($href,7));
1353 $info["act"]="mail";
1354 }
1355 }
1356 $info["info"] = $info["value"];
1357 } else {
1358 $info=array();
1359 $info["info"]=$GLOBALS["LANG"]->getLL("none");
1360 $info["value"]="";
1361 $info["act"]="page";
1362 }
1363 return $info;
1364 }
1365
1366 /**
1367 * For TBE: Makes an upload form (similar to the one from rte_select_image.php)
1368 *
1369 * @param [type] $path: ...
1370 * @return [type] ...
1371 */
1372 function uploadForm($path) {
1373 // debug($path);
1374 $count=3;
1375 $header = t3lib_div::isFirstPartOfStr($path,PATH_site)?substr($path,strlen(PATH_site)):$path;
1376 $code=$this->barheader($GLOBALS["LANG"]->getLL("uploadImage").":");
1377 $code.='<table border=0 cellpadding=0 cellspacing=3><FORM action="tce_file.php" method="POST" name="editform" enctype="'.$GLOBALS["TYPO3_CONF_VARS"]["SYS"]["form_enctype"].'"><tr><td>';
1378 $code.="<strong>".$GLOBALS["LANG"]->getLL("path").":</strong> ".$header."</td></tr><tr><td>";
1379 for ($a=1;$a<=$count;$a++) {
1380 $code.='<input type="File" name="upload_'.$a.'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(30).'>
1381 <input type="Hidden" name="file[upload]['.$a.'][target]" value="'.$path.'">
1382 <input type="Hidden" name="file[upload]['.$a.'][data]" value="'.$a.'"><BR>';
1383 }
1384 $code.='<input type="Hidden" name="redirect" value="browse_links.php?act='.$GLOBALS["act"].'&mode='.$GLOBALS["mode"].'&expandFolder='.rawurlencode($path).'&bparams='.rawurlencode(t3lib_div::GPvar("bparams")).'"><input type="Submit" name="submit" value="'.$GLOBALS["LANG"]->sL("LLL:EXT:lang/locallang_core.php:file_upload.php.submit").'"></td></tr></FORM></table>';
1385 return $code;
1386 }
1387
1388 /**
1389 * For TBE: Makes an upload form (similar to the one from rte_select_image.php)
1390 *
1391 * @param [type] $path: ...
1392 * @return [type] ...
1393 */
1394 function createFolder($path) {
1395 $header = t3lib_div::isFirstPartOfStr($path,PATH_site)?substr($path,strlen(PATH_site)):$path;
1396 $code=$this->barheader($GLOBALS["LANG"]->sL("LLL:EXT:lang/locallang_core.php:file_newfolder.php.pagetitle").":");
1397 $code.='<table border=0 cellpadding=0 cellspacing=3><FORM action="tce_file.php" method="POST" name="editform2"><tr><td>';
1398 $code.="<strong>".$GLOBALS["LANG"]->getLL("path").":</strong> ".$header."</td></tr><tr><td>";
1399 $a=1;
1400 $code.='<input'.$GLOBALS["TBE_TEMPLATE"]->formWidth(20).' type="Text" name="file[newfolder]['.$a.'][data]"><input type="Hidden" name="file[newfolder]['.$a.'][target]" value="'.$path.'">';
1401 $code.='<input type="Hidden" name="redirect" value="browse_links.php?act='.$GLOBALS["act"].'&mode='.$GLOBALS["mode"].'&expandFolder='.rawurlencode($path).'&bparams='.rawurlencode(t3lib_div::GPvar("bparams")).'"><input type="Submit" name="submit" value="'.$GLOBALS["LANG"]->sL("LLL:EXT:lang/locallang_core.php:file_newfolder.php.submit").'"></td></tr></FORM></table>';
1402 return $code;
1403 }
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415 /**
1416 * Rich Text Editor (RTE) link selector (MAIN function)
1417 *
1418 * @param [type] $content: ...
1419 * @param [type] $wiz: ...
1420 * @return [type] ...
1421 */
1422 function main_rte($content="",$wiz=0) {
1423 global $SOBE,$act,$mode,$curUrlInfo,$curUrlArray,$LANG;
1424 // Starting content:
1425 // debug($this->thisConfig);
1426 $content.=$this->doc->startPage("RTE link");
1427
1428 $allowedItems = array_diff(explode(",","page,file,url,mail,spec"),t3lib_div::trimExplode(",",$this->thisConfig["blindLinkOptions"],1));
1429 reset($allowedItems);
1430 if (!in_array($act,$allowedItems)) $act = current($allowedItems);
1431
1432 // Making menu in top:
1433 $menu='<table border=0 cellpadding=2 cellspacing=1><tr>';
1434 $bgcolor=' bgcolor="'.$this->doc->bgColor4.'"';
1435 $bgcolorA=' bgcolor="'.$this->doc->bgColor5.'"';
1436 if (!$wiz) $menu.='<td align=center nowrap width=15%'.$bgcolor.'><a href="#" onclick="self.parent.parent.renderPopup_unLink();return false;"><strong>'.$GLOBALS["LANG"]->getLL("removeLink").'</strong></a></td>';
1437 if (in_array("page",$allowedItems)) $menu.='<td align=center nowrap width=15%'.($act=="page"?$bgcolorA:$bgcolor).'><a href="#" onclick="jumpToUrl(\'?act=page\');return false;"><strong>'.$GLOBALS["LANG"]->getLL("page").'</strong></a></td>';
1438 if (in_array("file",$allowedItems)) $menu.='<td align=center nowrap width=15%'.($act=="file"?$bgcolorA:$bgcolor).'><a href="#" onclick="jumpToUrl(\'?act=file\');return false;"><strong>'.$GLOBALS["LANG"]->getLL("file").'</strong></a></td>';
1439 if (in_array("url",$allowedItems)) $menu.='<td align=center nowrap width=15%'.($act=="url"?$bgcolorA:$bgcolor).'><a href="#" onclick="jumpToUrl(\'?act=url\');return false;"><strong>'.$GLOBALS["LANG"]->getLL("extUrl").'</strong></a></td>';
1440 if (in_array("mail",$allowedItems)) $menu.='<td align=center nowrap width=15%'.($act=="mail"?$bgcolorA:$bgcolor).'><a href="#" onclick="jumpToUrl(\'?act=mail\');return false;"><strong>'.$GLOBALS["LANG"]->getLL("email").'</strong></a></td>';
1441 if (is_array($this->thisConfig["userLinks."]) && in_array("spec",$allowedItems)) $menu.='<td align=center nowrap width=15%'.($act=="spec"?$bgcolorA:$bgcolor).'><a href="#" onclick="jumpToUrl(\'?act=spec\');return false;"><strong>'.$GLOBALS["LANG"]->getLL("special").'</strong></a></td>';
1442 $menu.='</tr></table>';
1443
1444 $content.='<img src=clear.gif width=1 height=2>';
1445 $content.=$this->printCurrentUrl($curUrlInfo["info"]);
1446 $content.='<img src=clear.gif width=1 height=2>';
1447 $content.=$menu;
1448 $content.='<img src=clear.gif width=1 height=10>';
1449
1450 switch($act) {
1451 case "mail":
1452 $extUrl='<table border=0 cellpadding=2 cellspacing=1><form name="lurlform" id="lurlform"><tr>';
1453 $extUrl.='<td width=90>'.$GLOBALS["LANG"]->getLL("emailAddress").':</td>';
1454 $extUrl.='<td><input type="text" name="lemail"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(20).' value="'.($curUrlInfo["act"]=="mail"?$curUrlInfo["info"]:"").'"> <input type="submit" value="'.$GLOBALS["LANG"]->getLL("setLink").'" onclick="setTarget(\'\');setValue(\'mailto:\'+document.lurlform.lemail.value); return link_current();"></td>';
1455 $extUrl.='</tr></form></table>';
1456
1457 $content.=$extUrl;
1458 break;
1459 case "url":
1460 $extUrl='<table border=0 cellpadding=2 cellspacing=1><form name="lurlform" id="lurlform"><tr>';
1461 $extUrl.='<td width=90>URL:</td>';
1462 $extUrl.='<td><input type="text" name="lurl"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(20).' value="'.($curUrlInfo["act"]=="url"?$curUrlInfo["info"]:"http://").'"> <input type="submit" value="'.$GLOBALS["LANG"]->getLL("setLink").'" onclick="setValue(document.lurlform.lurl.value); return link_current();"></td>';
1463 $extUrl.='</tr></form></table>';
1464
1465 $content.=$extUrl;
1466 break;
1467 case "file":
1468 $foldertree = t3lib_div::makeInstance("rteFolderTree");
1469 $tree=$foldertree->getBrowsableTree();
1470
1471
1472 // debug($GLOBALS["HTTP_GET_VARS"]);
1473 if (!$GLOBALS["curUrlInfo"]["value"] || $GLOBALS["curUrlInfo"]["act"]!="file") {
1474 $cmpPath="";
1475 } else if (substr(trim($GLOBALS["curUrlInfo"]["info"]),-1)!="/") {
1476 $cmpPath=PATH_site.dirname($GLOBALS["curUrlInfo"]["info"])."/";
1477 if (!isset($GLOBALS["HTTP_GET_VARS"]["expandFolder"])) $GLOBALS["HTTP_GET_VARS"]["expandFolder"] = $cmpPath;
1478 } else {
1479 $cmpPath=PATH_site.$GLOBALS["curUrlInfo"]["info"];
1480 }
1481
1482
1483 list(,,$specUid) = explode("_",t3lib_div::GPvar("PM"));
1484 $files = $this->expandFolder($foldertree->specUIDmap[$specUid]);
1485
1486 $content.= '<table border=0 cellpadding=0 cellspacing=0>
1487 <tr>
1488 <td valign=top><font face=verdana size=1 color=black>'.$this->barheader($GLOBALS["LANG"]->getLL("folderTree").':').$tree.'</font></td>
1489 <td>&nbsp;</td>
1490 <td valign=top><font face=verdana size=1 color=black>'.$files.'</font></td>
1491 </tr>
1492 </table>
1493 <BR>';
1494 break;
1495 case "spec":
1496 if (is_array($this->thisConfig["userLinks."])) {
1497 $subcats=array();
1498 $v=$this->thisConfig["userLinks."];
1499 reset($v);
1500 while(list($k2)=each($v)) {
1501 $k2i = intval($k2);
1502 if (substr($k2,-1)=="." && is_array($v[$k2i."."])) {
1503 $title = trim($v[$k2i]);
1504 if (!$title) {
1505 $title=$v[$k2i."."]["url"];
1506 } else {
1507 $title=$LANG->sL($title,1);
1508 }
1509 $description=$v[$k2i."."]["description"] ? $LANG->sL($v[$k2i."."]["description"],1)."<BR>" : "";
1510 $onClickEvent='';
1511 if (isset($v[$k2i."."]["target"])) $onClickEvent.="setTarget('".$v[$k2i."."]["target"]."');";
1512 $v[$k2i."."]["url"] = str_replace("###_URL###",$this->siteURL,$v[$k2i."."]["url"]);
1513
1514 if (substr($v[$k2i."."]["url"],0,7)=="http://" || substr($v[$k2i."."]["url"],0,7)=="mailto:") {
1515 $onClickEvent.="cur_href=unescape('".rawurlencode($v[$k2i."."]["url"])."');link_current();";
1516 } else {
1517 $onClickEvent.="link_spec(unescape('".$this->siteURL.rawurlencode($v[$k2i."."]["url"])."'));";
1518 }
1519 $icon = ''; //'<img src="gfx/123_go.png" width="50" border=0>';
1520 $A=array('<a href="#" onclick="'.htmlspecialchars($onClickEvent).'return false;">','</a>');
1521
1522 // debug(array($onClickEvent));
1523 $subcats[$k2i]='<tr>
1524 <td bgColor="'.$this->doc->bgColor4.'" valign=top>'.$A[0].$icon.$A[1].'</td>
1525 <td bgColor="'.$this->doc->bgColor4.'" valign=top>'.$A[0].'<strong>'.$title.($curUrlInfo["info"]==$v[$k2i."."]["url"]?'<img src="gfx/blinkarrow_right.gif" width="5" height="9" align=top vspace=1 hspace=5 border=0>':'').'</strong><BR>'.$description.$A[1].'</td>
1526 </tr>';
1527 }
1528 }
1529 ksort($subcats);
1530 $content.= '<table border=0 cellpadding=1 cellspacing=1>
1531 <tr>
1532 <td bgColor="'.$this->doc->bgColor5.'" valign=top colspan=2><strong>'.$LANG->getLL("special").'</strong></td>
1533 </tr>
1534 '.implode("",$subcats).'</table><BR>';
1535 // debug($subcats);
1536 }
1537 break;
1538 case "page":
1539 default:
1540 $pagetree = t3lib_div::makeInstance("rtePageTree");
1541 $tree=$pagetree->getBrowsableTree(" AND doktype!=255");
1542 $cElements = $this->expandPage();
1543 $content.= '<table border=0 cellpadding=0 cellspacing=0>
1544 <tr>
1545 <td valign=top><font face=verdana size=1 color=black>'.$this->barheader($GLOBALS["LANG"]->getLL("pageTree").':').$tree.'</font></td>
1546 <td>&nbsp;</td>
1547 <td valign=top><font face=verdana size=1 color=black>'.$cElements.'</font></td>
1548 </tr>
1549 </table>
1550 <BR>';
1551 break;
1552 }
1553
1554 // Target:
1555 if ($act!="mail") {
1556 $ltarget='<table border=0 cellpadding=2 cellspacing=1><form name="ltargetform" id="ltargetform"><tr>';
1557 $ltarget.='<td width=90>'.$GLOBALS["LANG"]->getLL("target").':</td>';
1558 $ltarget.='<td><input type="text" name="ltarget" onChange="setTarget(this.value);" value="'.htmlspecialchars($this->setTarget).'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(20).'></td>';
1559 $ltarget.='<td><select name="ltarget_type" onChange="setTarget(this.options[this.selectedIndex].value);document.ltargetform.ltarget.value=this.options[this.selectedIndex].value;this.selectedIndex=0;">
1560 <option></option>
1561 <option value="_top">'.$GLOBALS["LANG"]->getLL("top").'</option>
1562 <option value="_blank">'.$GLOBALS["LANG"]->getLL("newWindow").'</option>
1563 </select></td>';
1564 if (($curUrlInfo["act"]=="page" || $curUrlInfo["act"]=="file") && $curUrlArray["href"]) {
1565 $ltarget.='<td><input type="submit" value="'.$GLOBALS["LANG"]->getLL("update").'" onclick="return link_current();"></td>';
1566 }
1567 $ltarget.='</tr></form></table>';
1568
1569 $content.=$ltarget;
1570 }
1571
1572 $content.= $this->doc->endPage();
1573 return $content;
1574 }
1575
1576
1577
1578
1579
1580
1581
1582 /**
1583 * TBE Record Browser (MAIN function)
1584 *
1585 * @param [type] $content: ...
1586 * @return [type] ...
1587 */
1588 function main_db($content="") {
1589 global $SOBE;
1590
1591 // Starting content:
1592 $content.=$this->doc->startPage("TBE file selector");
1593 $content.='<img src=clear.gif width=1 height=2>';
1594 $pArr = explode("|",t3lib_div::GPvar("bparams"));
1595
1596 // debug($pArr);
1597
1598 $pagetree = t3lib_div::makeInstance("TBE_PageTree");
1599 $pagetree->script="browse_links.php";
1600 $pagetree->ext_pArrPages = !strcmp($pArr[3],"pages")?1:0;
1601
1602 $tree=$pagetree->getBrowsableTree(" AND doktype!=255");
1603 $cElements = $this->TBE_expandPage($pArr[3]);
1604
1605 $content.= '<table border=0 cellpadding=0 cellspacing=0>
1606 <tr>
1607 <td valign=top><font face=verdana size=1 color=black>'.$this->barheader($GLOBALS["LANG"]->getLL("pageTree").':').$tree.'</font></td>
1608 <td>&nbsp;</td>
1609 <td valign=top><font face=verdana size=1 color=black>'.$cElements.'</font></td>
1610 </tr>
1611 </table>
1612 <BR>';
1613
1614 return $content;
1615 }
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627 /**
1628 * TBE File Browser (MAIN function)
1629 *
1630 * @param [type] $content: ...
1631 * @param [type] $mode: ...
1632 * @return [type] ...
1633 */
1634 function main_file($content="",$mode) {
1635 global $SOBE,$BE_USER;
1636
1637 // Starting content:
1638 $content.=$this->doc->startPage("TBE file selector");
1639 $content.='<img src=clear.gif width=1 height=2>';
1640 $pArr = explode("|",t3lib_div::GPvar("bparams"));
1641
1642
1643 // ***************************
1644 // Upload
1645 // ***************************
1646 $fileProcessor = t3lib_div::makeInstance("t3lib_basicFileFunctions");
1647 $fileProcessor->init($GLOBALS["FILEMOUNTS"], $GLOBALS["TYPO3_CONF_VARS"]["BE"]["fileExtensions"]);
1648 $path=t3lib_div::GPvar("expandFolder");
1649 if (!$path || !@is_dir($path)) {
1650 $path = $fileProcessor->findTempFolder()."/"; // The closest TEMP-path is found
1651 }
1652 if ($path!="/" && @is_dir($path)) {
1653 $uploadForm=$this->uploadForm($path)."<BR>";
1654 $createFolder=$this->createFolder($path)."<BR>";
1655 } else {
1656 $createFolder="";
1657 $uploadForm="";
1658 }
1659
1660 if ($BE_USER->getTSConfigVal("options.uploadFieldsInTopOfEB")) $content.=$uploadForm;
1661
1662 // FOLDER TREE:
1663
1664 $foldertree = t3lib_div::makeInstance("TBE_FolderTree");
1665 $foldertree->script="browse_links.php";
1666 $foldertree->ext_noTempRecyclerDirs = ($mode == "filedrag");
1667 $tree=$foldertree->getBrowsableTree();
1668
1669 list(,,$specUid) = explode("_",t3lib_div::GPvar("PM"));
1670
1671 if ($mode=="filedrag") {
1672 $files = $this->TBE_dragNDrop($foldertree->specUIDmap[$specUid],$pArr[3]);
1673 } else {
1674 $files = $this->TBE_expandFolder($foldertree->specUIDmap[$specUid],$pArr[3]);
1675 }
1676
1677 $content.= '<table border=0 cellpadding=0 cellspacing=0>
1678 <tr>
1679 <td valign=top><font face=verdana size=1 color=black>'.$this->barheader($GLOBALS["LANG"]->getLL("folderTree").':').$tree.'</font></td>
1680 <td>&nbsp;</td>
1681 <td valign=top><font face=verdana size=1 color=black>'.$files.'</font></td>
1682 </tr>
1683 </table>
1684 <BR>';
1685
1686 if (!$BE_USER->getTSConfigVal("options.uploadFieldsInTopOfEB")) $content.=$uploadForm;
1687 if ($BE_USER->isAdmin() || $BE_USER->getTSConfigVal("options.createFoldersInEB")) $content.=$createFolder;
1688
1689 $content.= $this->doc->endPage();
1690 return $content;
1691 }
1692 }
1693
1694 // Include extension?
1695 if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["typo3/browse_links.php"]) {
1696 include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["typo3/browse_links.php"]);
1697 }
1698
1699
1700
1701
1702
1703
1704
1705
1706 // Make instance:
1707 $SOBE = t3lib_div::makeInstance("SC_browse_links");
1708 $SOBE->init();
1709 $SOBE->main();
1710 $SOBE->printContent();
1711 ?>