Documentation TYPO3 par Ameos |
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 1999-2004 Kasper Skaarhoj (kasperYYYY@typo3.com) 00006 * All rights reserved 00007 * 00008 * This script is part of the TYPO3 project. The TYPO3 project is 00009 * free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * The GNU General Public License can be found at 00015 * http://www.gnu.org/copyleft/gpl.html. 00016 * A copy is found in the textfile GPL.txt and important notices to the license 00017 * from the author is found in LICENSE.txt distributed with these scripts. 00018 * 00019 * 00020 * This script is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 * GNU General Public License for more details. 00024 * 00025 * This copyright notice MUST APPEAR in all copies of the script! 00026 ***************************************************************/ 00052 unset($MCONF); 00053 require ('conf.php'); 00054 require ($BACK_PATH.'init.php'); 00055 require ($BACK_PATH.'template.php'); 00056 00057 $LANG->includeLLFile('EXT:rte/app/locallang_rte_user.php'); 00058 00059 00060 00061 00062 00063 00064 00065 00066 00067 00068 00076 class SC_rte_user { 00077 var $content; 00078 var $modData; 00079 var $siteUrl; 00080 var $doc; 00081 00085 function init() { 00086 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS; 00087 00088 /* $PRE_CODED["clear_gifs"] = Array ( 00089 "100" => "Clear-gif, 100x20", 00090 "100." => Array ( 00091 "content" => '<img src=clear.gif width=100 height=20><BR>' 00092 ), 00093 "110" => "Clear-gif, 200x50", 00094 "110." => Array ( 00095 "content" => '<img src=clear.gif width=200 height=50><BR>' 00096 ) 00097 ); 00098 */ 00099 00100 00101 // Current site url: 00102 $this->siteUrl = t3lib_div::getIndpEnv("TYPO3_SITE_URL"); 00103 00104 $this->doc = t3lib_div::makeInstance("template"); 00105 $this->doc->backPath = $BACK_PATH; 00106 $this->doc->form = '<form action="" name="process" method="POST"> 00107 <input type="hidden" name="processContent" value=""> 00108 <input type="hidden" name="returnUrl" value="'.htmlspecialchars(t3lib_div::getIndpEnv("REQUEST_URI")).'"> 00109 '; 00110 $this->doc->JScode=' 00111 <script language="javascript" type="text/javascript"> 00112 var RTEobj = self.parent.parent; 00113 00114 function getSelectedTextContent() { // 00115 var oSel = RTEobj.GLOBAL_SEL; 00116 var sType = oSel.type; 00117 // alert(sType); 00118 // RTEobj.debugObj(oSel); 00119 if (sType=="Text") { 00120 return oSel.htmlText; 00121 } 00122 return ""; 00123 } 00124 function insertHTML(content,noHide) { // 00125 // alert(content); 00126 RTEobj.insertHTML(content); 00127 if (!noHide) RTEobj.edHidePopup(); 00128 } 00129 function wrapHTML(wrap1,wrap2,noHide) { // 00130 var contentToWrap = getSelectedTextContent(); 00131 if (contentToWrap) { 00132 contentToWrap = ""+wrap1+contentToWrap+wrap2; 00133 setSelectedTextContent(contentToWrap); 00134 } else { 00135 alert('.$GLOBALS['LANG']->JScharCode($LANG->getLL("noTextSelection")).'); 00136 } 00137 if (!noHide) RTEobj.edHidePopup(); 00138 } 00139 function processSelection(script) { // 00140 document.process.action = script; 00141 document.process.processContent.value = getSelectedTextContent(); 00142 document.process.submit(); 00143 } 00144 function setSelectedTextContent(content) { // 00145 var oSel = RTEobj.GLOBAL_SEL; 00146 var sType = oSel.type; 00147 if (sType=="Text") { 00148 oSel.pasteHTML(content); 00149 } 00150 } 00151 // alert(RTEobj.getHTML()); 00152 // RTEobj.setHTML("Hej <b>Kasper</b>-dreng!",1); 00153 </script> 00154 '; 00155 00156 00157 $this->modData = $BE_USER->getModuleData("rte_user.php","ses"); 00158 if (t3lib_div::_GP("OC_key")) { 00159 $parts = explode("|",t3lib_div::_GP("OC_key")); 00160 $this->modData["openKeys"][$parts[1]] = $parts[0]=="O" ? 1 : 0; 00161 $BE_USER->pushModuleData("rte_user.php",$this->modData); 00162 } 00163 } 00164 00170 function main() { 00171 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS; 00172 00173 $this->content=""; 00174 $this->content.=$this->main_user($this->modData["openKeys"]); 00175 } 00176 00182 function printContent() { 00183 echo $this->content; 00184 } 00185 00186 00187 00188 00189 00190 00191 00192 00193 00194 00195 00196 /******************************** 00197 * 00198 * Other functions 00199 * 00200 *********************************/ 00201 00208 function calcWH($imgInfo,$maxW=380,$maxH=500) { 00209 $IW = $imgInfo[0]; 00210 $IH = $imgInfo[1]; 00211 if ($IW>$maxW) { 00212 $IH=ceil($IH/$IW*$maxW); 00213 $IW=$maxW; 00214 } 00215 if ($IH>$maxH) { 00216 $IW=ceil($IW/$IH*$maxH); 00217 $IH=$maxH; 00218 } 00219 00220 $imgInfo[3]='width="'.$IW.'" height="'.$IH.'"'; 00221 return $imgInfo; 00222 } 00223 00230 function main_user($openKeys) { 00231 global $SOBE,$LANG,$BACK_PATH; 00232 // Starting content: 00233 $content.=$this->doc->startPage("RTE user"); 00234 00235 $RTEtsConfigParts = explode(":",t3lib_div::_GP("RTEtsConfigParams")); 00236 $RTEsetup = $GLOBALS["BE_USER"]->getTSConfig("RTE",t3lib_BEfunc::getPagesTSconfig($RTEtsConfigParts[5])); 00237 $thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup["properties"],$RTEtsConfigParts[0],$RTEtsConfigParts[2],$RTEtsConfigParts[4]); 00238 00239 //debug($RTEtsConfigParts); 00240 //debug($thisConfig); 00241 if (is_array($thisConfig["userElements."])) { 00242 00243 $categories=array(); 00244 reset($thisConfig["userElements."]); 00245 while(list($k)=each($thisConfig["userElements."])) { 00246 $ki=intval($k); 00247 $v = $thisConfig["userElements."][$ki."."]; 00248 if (substr($k,-1)=="." && is_array($v)) { 00249 $subcats=array(); 00250 $openK = $ki; 00251 if ($openKeys[$openK]) { 00252 00253 $mArray = ""; 00254 switch ((string)$v["load"]) { 00255 case "images_from_folder": 00256 $mArray=array(); 00257 if ($v["path"] && @is_dir(PATH_site.$v["path"])) { 00258 $files = t3lib_div::getFilesInDir(PATH_site.$v["path"],"gif,jpg,jpeg,png",0,""); 00259 if (is_array($files)) { 00260 reset($files); 00261 $c=0; 00262 while(list(,$filename)=each($files)) { 00263 $iInfo = @getimagesize(PATH_site.$v["path"].$filename); 00264 $iInfo = $this->calcWH($iInfo,50,100); 00265 00266 $ks=(string)(100+$c); 00267 $mArray[$ks]=$filename; 00268 $mArray[$ks."."]=array( 00269 "content" => '<img src="'.$this->siteUrl.$v["path"].$filename.'">', 00270 "_icon" => '<img src="'.$this->siteUrl.$v["path"].$filename.'" '.$iInfo[3].' border=0>', 00271 "description" => $LANG->getLL("filesize").': '.str_replace(" "," ",t3lib_div::formatSize(@filesize(PATH_site.$v["path"].$filename))).', '.$LANG->getLL("pixels").': '.$iInfo[0].'x'.$iInfo[1] 00272 ); 00273 $c++; 00274 } 00275 } 00276 } 00277 break; 00278 /* case "clear_gifs": 00279 $mArray=$GLOBALS["PRE_CODED"]["clear_gifs"]; 00280 break;*/ 00281 } 00282 if (is_array($mArray)) { 00283 if ($v["merge"]) { 00284 $v=t3lib_div::array_merge_recursive_overrule($mArray,$v); 00285 } else { 00286 $v=$mArray; 00287 } 00288 } 00289 00290 // debug($v); 00291 reset($v); 00292 while(list($k2)=each($v)) { 00293 $k2i = intval($k2); 00294 if (substr($k2,-1)=="." && is_array($v[$k2i."."])) { 00295 $title = trim($v[$k2i]); 00296 if (!$title) { 00297 $title="[".$LANG->getLL("noTitle")."]"; 00298 } else { 00299 $title=$LANG->sL($title,1); 00300 } 00301 $description=$LANG->sL($v[$k2i."."]["description"],1)."<BR>"; 00302 if (!$v[$k2i."."]["dontInsertSiteUrl"]) $v[$k2i."."]["content"] = str_replace("###_URL###",$this->siteUrl,$v[$k2i."."]["content"]); 00303 00304 $logo = $v[$k2i."."]["_icon"] ? $v[$k2i."."]["_icon"] : ''; 00305 00306 $onClickEvent=''; 00307 switch((string)$v[$k2i."."]["mode"]) { 00308 case "wrap": 00309 $wrap = explode("|",$v[$k2i."."]["content"]); 00310 $onClickEvent="wrapHTML(unescape('".str_replace("%20"," ",rawurlencode($wrap[0]))."'),unescape('".str_replace("%20"," ",rawurlencode($wrap[1]))."'));"; 00311 break; 00312 case "processor": 00313 $script = trim($v[$k2i."."]["submitToScript"]); 00314 if (substr($script,0,4)!="http") $script = $this->siteUrl.$script; 00315 //debug($script); 00316 if ($script) { 00317 $onClickEvent="processSelection(unescape('".rawurlencode($script)."'));"; 00318 } 00319 break; 00320 case "insert": 00321 default: 00322 $onClickEvent="insertHTML(unescape('".str_replace("%20"," ",rawurlencode($v[$k2i."."]["content"]))."'));"; 00323 break; 00324 } 00325 $A=array('<a href="#" onClick="'.$onClickEvent.'return false;">','</a>'); 00326 // debug($v[$k2i."."]); 00327 00328 $subcats[$k2i]='<tr> 00329 <td><img src="clear.gif" width="18" height="1"></td> 00330 <td class="bgColor4" valign=top>'.$A[0].$logo.$A[1].'</td> 00331 <td class="bgColor4" valign=top>'.$A[0].'<strong>'.$title.'</strong><BR>'.$description.$A[1].'</td> 00332 </tr>'; 00333 } 00334 } 00335 ksort($subcats); 00336 } 00337 $categories[$ki]=implode("",$subcats); 00338 } 00339 } 00340 ksort($categories); 00341 00342 # Render menu of the items: 00343 $lines=array(); 00344 reset($categories); 00345 while(list($k,$v)=each($categories)) { 00346 $title = trim($thisConfig["userElements."][$k]); 00347 $openK = $k; 00348 if (!$title) { 00349 $title="[".$LANG->getLL("noTitle")."]"; 00350 } else { 00351 $title=$LANG->sL($title,1); 00352 } 00353 $lines[]='<tr><td colspan=3 class="bgColor5"><a href="'.t3lib_div::linkThisScript(array("OC_key"=>($openKeys[$openK]?"C|":"O|").$openK)).'" title="'.$LANG->getLL("expand",1).'"><img src="'.$BACK_PATH.'gfx/ol/'.($openKeys[$openK]?"minus":"plus").'bullet.gif" width="18" height="16" border="0" align=top title="'.$LANG->getLL("expand",1).'"><strong>'.$title.'</strong></a></td></tr>'; 00354 $lines[]=$v; 00355 } 00356 00357 $content.='<table border=0 cellpadding=1 cellspacing=1>'.implode("",$lines).'</table>'; 00358 } 00359 00360 $content.= $this->doc->endPage(); 00361 return $content; 00362 } 00363 } 00364 00365 // Include extension? 00366 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rte/app/rte_user.php']) { 00367 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rte/app/rte_user.php']); 00368 } 00369 00370 00371 00372 00373 00374 00375 00376 00377 00378 00379 00380 00381 // Make instance: 00382 $SOBE = t3lib_div::makeInstance('SC_rte_user'); 00383 $SOBE->init(); 00384 $SOBE->main(); 00385 $SOBE->printContent(); 00386 ?>