"TYPO3 4.0.1: typo3_src-4.0.1/typo3/sysext/rtehtmlarea/mod5/user.php Source File", "datetime" => "Sat Dec 2 19:22:34 2006", "date" => "2 Dec 2006", "doxygenversion" => "1.4.6", "projectname" => "TYPO3 4.0.1", "projectnumber" => "4.0.1" ); get_header($doxygen_vars); ?>

user.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *  
00005 *  (c) 1999-2004 Kasper Skaarhoj (kasper@typo3.com)
00006 *  (c) 2005-2006 Stanislas Rolland <stanislas.rolland(arobas)fructifor.ca>
00007 *  All rights reserved
00008 *
00009 *  This script is part of the TYPO3 project. The TYPO3 project is 
00010 *  free software; you can redistribute it and/or modify
00011 *  it under the terms of the GNU General Public License as published by
00012 *  the Free Software Foundation; either version 2 of the License, or
00013 *  (at your option) any later version.
00014 * 
00015 *  The GNU General Public License can be found at
00016 *  http://www.gnu.org/copyleft/gpl.html.
00017 *  A copy is found in the textfile GPL.txt and important notices to the license 
00018 *  from the author is found in LICENSE.txt distributed with these scripts.
00019 *
00020 * 
00021 *  This script is distributed in the hope that it will be useful,
00022 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00023 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00024 *  GNU General Public License for more details.
00025 *
00026 *  This copyright notice MUST APPEAR in all copies of the script!
00027 ***************************************************************/
00056 error_reporting (E_ALL ^ E_NOTICE);
00057 unset($MCONF);
00058 require ('conf.php');
00059 require ($BACK_PATH.'init.php');
00060 require ($BACK_PATH.'template.php');
00061 $LANG->includeLLFile('EXT:rtehtmlarea/mod5/locallang.xml');
00062 
00070 class tx_rtehtmlarea_user {
00071         var $content;
00072         var $modData;
00073         var $siteUrl;
00074         var $doc;       
00075 
00079         function init() {
00080                 global $BE_USER, $LANG, $BACK_PATH;
00081 
00082                 $this->siteUrl = t3lib_div::getIndpEnv("TYPO3_SITE_URL");
00083                 $this->doc = t3lib_div::makeInstance("template");
00084                 $this->doc->backPath = $BACK_PATH;
00085                 $this->doc->form = '<form action="" name="process" method="POST">
00086                 <input type="hidden" name="processContent" value="">
00087                 <input type="hidden" name="returnUrl" value="'.htmlspecialchars(t3lib_div::getIndpEnv("REQUEST_URI")).'">
00088                 ';
00089                 $this->doc->JScode='
00090                 <script language="javascript" type="text/javascript">
00091                         /*<![CDATA[*/
00092                         var editor = parent.editor;
00093                         var HTMLArea = parent.HTMLArea;
00094                         function insertHTML(content,noHide) {
00095                                 editor.insertHTML(content);
00096                                 if(!noHide) HTMLArea.edHidePopup();
00097                         }
00098                         function wrapHTML(wrap1,wrap2,noHide) {
00099                                 if(editor.hasSelectedText()) {
00100                                         editor.surroundHTML(wrap1,wrap2);
00101                                 } else {
00102                                         alert('.$LANG->JScharCode($LANG->getLL("noTextSelection")).');
00103                                 }
00104                                 if(!noHide) HTMLArea.edHidePopup();
00105                         }
00106                         function processSelection(script) {
00107                                 document.process.action = script;
00108                                 document.process.processContent.value = editor.getSelectedHTML();
00109                                 document.process.submit();
00110                         }
00111                         /*]]>*/
00112                 </script>
00113                 ';
00114 
00115                 $this->modData = $BE_USER->getModuleData("user.php","ses");
00116                 if (t3lib_div::_GP("OC_key"))   {
00117                         $parts = explode("|",t3lib_div::_GP("OC_key"));
00118                         $this->modData["openKeys"][$parts[1]] = $parts[0]=="O" ? 1 : 0;
00119                         $BE_USER->pushModuleData("user.php",$this->modData);
00120                 }
00121         }
00122 
00128         function main() {
00129 
00130                 $this->content="";
00131                 $this->content.=$this->main_user($this->modData["openKeys"]);
00132         }
00133 
00139         function printContent() {
00140                 echo $this->content;
00141         }
00142 
00143 
00144 
00145         /********************************
00146          *
00147          * Other functions
00148          *
00149          *********************************/
00150 
00157         function calcWH($imgInfo,$maxW=380,$maxH=500)   {
00158                 $IW = $imgInfo[0];
00159                 $IH = $imgInfo[1];
00160                 if ($IW>$maxW)  {
00161                         $IH=ceil($IH/$IW*$maxW);
00162                         $IW=$maxW;
00163                 }
00164                 if ($IH>$maxH)  {
00165                         $IW=ceil($IW/$IH*$maxH);
00166                         $IH=$maxH;
00167                 }
00168                 
00169                 $imgInfo[3]='width="'.$IW.'" height="'.$IH.'"';
00170                 return $imgInfo;
00171         }
00172         
00179         function main_user($openKeys)   {
00180                 global $LANG, $BACK_PATH, $BE_USER;
00181                         // Starting content:
00182                 $content.=$this->doc->startPage("RTE user");
00183                 
00184                 $RTEtsConfigParts = explode(":",t3lib_div::_GP("RTEtsConfigParams"));
00185                 $RTEsetup = $BE_USER->getTSConfig("RTE",t3lib_BEfunc::getPagesTSconfig($RTEtsConfigParts[5])); 
00186                 $thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup["properties"],$RTEtsConfigParts[0],$RTEtsConfigParts[2],$RTEtsConfigParts[4]);
00187 
00188                 if (is_array($thisConfig["userElements."]))     {
00189 
00190                         $categories=array();
00191                         reset($thisConfig["userElements."]);
00192                         while(list($k)=each($thisConfig["userElements."]))      {
00193                                 $ki=intval($k);
00194                                 $v = $thisConfig["userElements."][$ki."."];
00195                                 if (substr($k,-1)=="." && is_array($v)) {
00196                                         $subcats=array();
00197                                         $openK = $ki;
00198                                         if ($openKeys[$openK])  {
00199                                                 
00200                                                 $mArray = "";
00201                                                 switch ((string)$v["load"])     {
00202                                                         case "images_from_folder":
00203                                                                 $mArray=array();
00204                                                                 if ($v["path"] && @is_dir(PATH_site.$v["path"]))        {
00205                                                                         $files = t3lib_div::getFilesInDir(PATH_site.$v["path"],"gif,jpg,jpeg,png",0,"");
00206                                                                         if (is_array($files))   {
00207                                                                                 reset($files);
00208                                                                                 $c=0;
00209                                                                                 while(list(,$filename)=each($files))    {
00210                                                                                         $iInfo = @getimagesize(PATH_site.$v["path"].$filename);
00211                                                                                         $iInfo = $this->calcWH($iInfo,50,100);
00212                                                                                 
00213                                                                                         $ks=(string)(100+$c);
00214                                                                                         $mArray[$ks]=$filename;
00215                                                                                         $mArray[$ks."."]=array(
00216                                                                                                 "content" => '<img src="'.$this->siteUrl.$v["path"].$filename.'">',
00217                                                                                                 "_icon" => '<img src="'.$this->siteUrl.$v["path"].$filename.'" '.$iInfo[3].' border=0>',
00218                                                                                                 "description" => $LANG->getLL("filesize").': '.str_replace("&nbsp;"," ",t3lib_div::formatSize(@filesize(PATH_site.$v["path"].$filename))).', '.$LANG->getLL("pixels").': '.$iInfo[0].'x'.$iInfo[1]
00219                                                                                         );
00220                                                                                         $c++;
00221                                                                                 }
00222                                                                         }                                               
00223                                                                 }
00224                                                         break;
00225                                                 }
00226                                                 if (is_array($mArray))  {
00227                                                         if ($v["merge"])        {
00228                                                                 $v=t3lib_div::array_merge_recursive_overrule($mArray,$v);
00229                                                         } else {
00230                                                                 $v=$mArray;
00231                                                         }
00232                                                 }
00233                                                 reset($v);
00234                                                 while(list($k2)=each($v))       {
00235                                                         $k2i = intval($k2);
00236                                                         if (substr($k2,-1)=="." && is_array($v[$k2i."."]))      {
00237                                                                 $title = trim($v[$k2i]);
00238                                                                 if (!$title)    {
00239                                                                         $title="[".$LANG->getLL("noTitle")."]";
00240                                                                 } else {
00241                                                                         $title=$LANG->sL($title,1);
00242                                                                 }
00243                                                                 $description=$LANG->sL($v[$k2i."."]["description"],1)."<BR>";
00244                                                                 if (!$v[$k2i."."]["dontInsertSiteUrl"]) $v[$k2i."."]["content"] = str_replace("###_URL###",$this->siteUrl,$v[$k2i."."]["content"]);
00245                 
00246                                                                 $logo = $v[$k2i."."]["_icon"] ? $v[$k2i."."]["_icon"] : '';
00247                                                                 
00248                                                                 $onClickEvent='';
00249                                                                 switch((string)$v[$k2i."."]["mode"])    {
00250                                                                         case "wrap":
00251                                                                                 $wrap = explode("|",$v[$k2i."."]["content"]); 
00252                                                                                 //$onClickEvent="wrapHTML(unescape('" . str_replace("%20"," ",rawurlencode($wrap[0])) . "'),unescape('".str_replace("%20"," ",rawurlencode($wrap[1]))."'));";
00253                                                                                 //$onClickEvent="alert(wrapHTML(" . $GLOBALS['LANG']->JScharCode(t3lib_div::htmlspecialchars_decode($wrap[0])) . ", " . $GLOBALS['LANG']->JScharCode(t3lib_div::htmlspecialchars_decode($wrap[1])) . "));";
00254                                                                                 $onClickEvent='wrapHTML(' . $LANG->JScharCode($wrap[0]) . ',' . $LANG->JScharCode($wrap[1]) . ',false);';
00255                                                                         break;
00256                                                                         case "processor":
00257                                                                                 $script = trim($v[$k2i."."]["submitToScript"]);
00258                                                                                 if (substr($script,0,4)!="http") $script = $this->siteUrl.$script;
00259                                                                                 if ($script)    {
00260                                                                                         $onClickEvent="processSelection(unescape('".rawurlencode($script)."'));";
00261                                                                                 }
00262                                                                         break;
00263                                                                         case "insert":
00264                                                                         default:
00265                                                                                 //$onClickEvent="insertHTML(unescape('".str_replace("%20"," ",rawurlencode($v[$k2i."."]["content"]))."'));";
00266                                                                                 $onClickEvent='insertHTML(' . $LANG->JScharCode($v[$k2i . '.']['content']) . ');';
00267                                                                         break;
00268                                                                 }
00269                                                                 $A=array('<a href="#" onClick="'.$onClickEvent.'return false;">','</a>');
00270                                                                 $subcats[$k2i]='<tr>
00271                                                                         <td><img src="clear.gif" width="18" height="1"></td>
00272                                                                         <td class="bgColor4" valign=top>'.$A[0].$logo.$A[1].'</td>
00273                                                                         <td class="bgColor4" valign=top>'.$A[0].'<strong>'.$title.'</strong><BR>'.$description.$A[1].'</td>
00274                                                                 </tr>';
00275                                                         }
00276                                                 }
00277                                                 ksort($subcats);
00278                                         }
00279                                         $categories[$ki]=implode("",$subcats);
00280                                 }
00281                         }
00282                         ksort($categories);
00283                         
00284                         # Render menu of the items:
00285                         $lines=array();
00286                         reset($categories);
00287                         while(list($k,$v)=each($categories))    {
00288                                 $title = trim($thisConfig["userElements."][$k]);
00289                                 $openK = $k;
00290                                 if (!$title)    {
00291                                         $title="[".$LANG->getLL("noTitle")."]";
00292                                 } else {
00293                                         $title=$LANG->sL($title,1);
00294                                 }
00295                                 $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>';
00296                                 $lines[]=$v;
00297                         }
00298                         
00299                         $content.='<table border=0 cellpadding=1 cellspacing=1>'.implode("",$lines).'</table>';
00300                 }
00301         
00302                 $content.= $this->doc->endPage();
00303                 return $content;
00304         }
00305 }
00306 
00307 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/mod5/user.php'])   {
00308         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/mod5/user.php']);
00309 }
00310 
00311 
00312 
00313 // Make instance:
00314 $SOBE = t3lib_div::makeInstance('tx_rtehtmlarea_user');
00315 $SOBE->init();
00316 $SOBE->main();
00317 $SOBE->printContent();
00318 ?>