00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00037 class tx_rtehtmlarea_user {
00038 var $content;
00039 var $modData;
00040 var $siteUrl;
00041 var $doc;
00042 var $editorNo;
00043
00047 function init() {
00048 global $BE_USER, $LANG, $BACK_PATH;
00049
00050 $this->editorNo = t3lib_div::_GP('editorNo');
00051
00052 $this->siteUrl = t3lib_div::getIndpEnv('TYPO3_SITE_URL');
00053 $this->doc = t3lib_div::makeInstance('template');
00054 $this->doc->backPath = $BACK_PATH;
00055
00056 $this->doc->bodyTagAdditions = 'onload="init();"';
00057 $this->doc->form = '
00058 <form action="" id="process" name="process" method="POST">
00059 <input type="hidden" name="processContent" value="" />
00060 <input type="hidden" name="returnUrl" value="'.htmlspecialchars(t3lib_div::getIndpEnv('REQUEST_URI')).'" />
00061 ';
00062
00063 $this->doc->JScode = '<script type="text/javascript" src="'. $BACK_PATH . t3lib_extMgm::extRelPath('rtehtmlarea') . 'htmlarea/popups/popup.js"></script>';
00064
00065 $JScode = '
00066 var editor = window.opener.RTEarea[' . $this->editorNo . ']["editor"];
00067 var HTMLArea = window.opener.HTMLArea;
00068
00069 function init() {
00070 document.body.onkeypress = __dlg_close_on_esc;
00071 };
00072 function insertHTML(content,noHide) {
00073 editor.insertHTML(content);
00074 if(!noHide) HTMLArea.edHidePopup();
00075 };
00076 function wrapHTML(wrap1,wrap2,noHide) {
00077 if(editor.hasSelectedText()) {
00078 editor.surroundHTML(wrap1,wrap2);
00079 } else {
00080 alert('.$LANG->JScharCode($LANG->getLL('noTextSelection')).');
00081 }
00082 if(!noHide) HTMLArea.edHidePopup();
00083 };
00084 function processSelection(script) {
00085 document.process.action = script;
00086 document.process.processContent.value = editor.getSelectedHTML();
00087 document.process.submit();
00088 };
00089 ';
00090
00091 $this->doc->JScode .= $this->doc->wrapScriptTags($JScode);
00092
00093 $this->modData = $BE_USER->getModuleData('user.php','ses');
00094 if (t3lib_div::_GP('OC_key')) {
00095 $parts = explode('|',t3lib_div::_GP('OC_key'));
00096 $this->modData['openKeys'][$parts[1]] = $parts[0]=='O' ? 1 : 0;
00097 $BE_USER->pushModuleData('user.php',$this->modData);
00098 }
00099 }
00100
00106 function main() {
00107
00108 $this->content='';
00109 $this->content.=$this->main_user($this->modData['openKeys']);
00110 }
00111
00117 function printContent() {
00118 echo $this->content;
00119 }
00120
00121
00122
00123
00124
00125
00126
00127
00128
00135 function calcWH($imgInfo,$maxW=380,$maxH=500) {
00136 $IW = $imgInfo[0];
00137 $IH = $imgInfo[1];
00138 if ($IW>$maxW) {
00139 $IH=ceil($IH/$IW*$maxW);
00140 $IW=$maxW;
00141 }
00142 if ($IH>$maxH) {
00143 $IW=ceil($IW/$IH*$maxH);
00144 $IH=$maxH;
00145 }
00146
00147 $imgInfo[3]='width="'.$IW.'" height="'.$IH.'"';
00148 return $imgInfo;
00149 }
00150
00157 function main_user($openKeys) {
00158 global $LANG, $BACK_PATH, $BE_USER;
00159
00160 $content.=$this->doc->startPage($LANG->getLL('Insert Custom Element',1));
00161
00162 $RTEtsConfigParts = explode(':',t3lib_div::_GP('RTEtsConfigParams'));
00163 $RTEsetup = $BE_USER->getTSConfig('RTE',t3lib_BEfunc::getPagesTSconfig($RTEtsConfigParts[5]));
00164 $thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup['properties'],$RTEtsConfigParts[0],$RTEtsConfigParts[2],$RTEtsConfigParts[4]);
00165
00166 if (is_array($thisConfig['userElements.'])) {
00167
00168 $categories=array();
00169 reset($thisConfig['userElements.']);
00170 while(list($k)=each($thisConfig['userElements.'])) {
00171 $ki=intval($k);
00172 $v = $thisConfig['userElements.'][$ki.'.'];
00173 if (substr($k,-1)=="." && is_array($v)) {
00174 $subcats=array();
00175 $openK = $ki;
00176 if ($openKeys[$openK]) {
00177
00178 $mArray = '';
00179 switch ((string)$v['load']) {
00180 case 'images_from_folder':
00181 $mArray=array();
00182 if ($v['path'] && @is_dir(PATH_site.$v['path'])) {
00183 $files = t3lib_div::getFilesInDir(PATH_site.$v['path'],'gif,jpg,jpeg,png',0,'');
00184 if (is_array($files)) {
00185 reset($files);
00186 $c=0;
00187 while(list(,$filename)=each($files)) {
00188 $iInfo = @getimagesize(PATH_site.$v['path'].$filename);
00189 $iInfo = $this->calcWH($iInfo,50,100);
00190
00191 $ks=(string)(100+$c);
00192 $mArray[$ks]=$filename;
00193 $mArray[$ks."."]=array(
00194 'content' => '<img src="'.$this->siteUrl.$v['path'].$filename.'" />',
00195 '_icon' => '<img src="'.$this->siteUrl.$v['path'].$filename.'" '.$iInfo[3].' />',
00196 'description' => $LANG->getLL('filesize').': '.str_replace(' ',' ',t3lib_div::formatSize(@filesize(PATH_site.$v['path'].$filename))).', '.$LANG->getLL('pixels',1).': '.$iInfo[0].'x'.$iInfo[1]
00197 );
00198 $c++;
00199 }
00200 }
00201 }
00202 break;
00203 }
00204 if (is_array($mArray)) {
00205 if ($v['merge']) {
00206 $v=t3lib_div::array_merge_recursive_overrule($mArray,$v);
00207 } else {
00208 $v=$mArray;
00209 }
00210 }
00211 reset($v);
00212 while(list($k2)=each($v)) {
00213 $k2i = intval($k2);
00214 if (substr($k2,-1)=='.' && is_array($v[$k2i.'.'])) {
00215 $title = trim($v[$k2i]);
00216 if (!$title) {
00217 $title='['.$LANG->getLL('noTitle',1).']';
00218 } else {
00219 $title=$LANG->sL($title,1);
00220 }
00221 $description = $LANG->sL($v[$k2i.'.']['description'],1).'<br />';
00222 if (!$v[$k2i.'.']['dontInsertSiteUrl']) $v[$k2i.'.']['content'] = str_replace('###_URL###',$this->siteUrl,$v[$k2i.'.']['content']);
00223
00224 $logo = $v[$k2i.'.']['_icon'] ? $v[$k2i.'.']['_icon'] : '';
00225
00226 $onClickEvent='';
00227 switch((string)$v[$k2i.'.']['mode']) {
00228 case 'wrap':
00229 $wrap = explode('|',$v[$k2i.'.']['content']);
00230 $onClickEvent='wrapHTML(' . $LANG->JScharCode($wrap[0]) . ',' . $LANG->JScharCode($wrap[1]) . ',false);';
00231 break;
00232 case 'processor':
00233 $script = trim($v[$k2i.'.']['submitToScript']);
00234 if (substr($script,0,4)!='http') $script = $this->siteUrl.$script;
00235 if ($script) {
00236 $onClickEvent='processSelection(' . $LANG->JScharCode($script) . ';';
00237 }
00238 break;
00239 case 'insert':
00240 default:
00241 $onClickEvent='insertHTML(' . $LANG->JScharCode($v[$k2i . '.']['content']) . ');';
00242 break;
00243 }
00244 $A=array('<a href="#" onClick="'.$onClickEvent.'return false;">','</a>');
00245 $subcats[$k2i]='<tr>
00246 <td><img src="clear.gif" width="18" height="1" /></td>
00247 <td class="bgColor4" valign="top">'.$A[0].$logo.$A[1].'</td>
00248 <td class="bgColor4" valign="top">'.$A[0].'<strong>'.$title.'</strong><br />'.$description.$A[1].'</td>
00249 </tr>';
00250 }
00251 }
00252 ksort($subcats);
00253 }
00254 $categories[$ki]=implode('',$subcats);
00255 }
00256 }
00257 ksort($categories);
00258
00259 # Render menu of the items:
00260 $lines=array();
00261 reset($categories);
00262 while(list($k,$v)=each($categories)) {
00263 $title = trim($thisConfig['userElements.'][$k]);
00264 $openK = $k;
00265 if (!$title) {
00266 $title='['.$LANG->getLL('noTitle',1).']';
00267 } else {
00268 $title=$LANG->sL($title,1);
00269 }
00270 $lines[]='<tr><td colspan="3" class="bgColor5"><a href="'.t3lib_div::linkThisScript(array('OC_key' => ($openKeys[$openK]?'C|':'O|').$openK, 'editorNo' => $this->editorNo)).'" title="'.$LANG->getLL('expand',1).'"><img' . t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/'.($openKeys[$openK]?'minus':'plus').'bullet.gif','width="18" height="16"').' title="'.$LANG->getLL('expand',1).'" /><strong>'.$title.'</strong></a></td></tr>';
00271 $lines[]=$v;
00272 }
00273
00274 $content.='<table border="0" cellpadding="1" cellspacing="1">'.implode('',$lines).'</table>';
00275 }
00276
00277 $content.= $this->doc->endPage();
00278 return $content;
00279 }
00280 }
00281
00282 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/mod5/class.tx_rtehtmlarea_user.php']) {
00283 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/mod5/class.tx_rtehtmlarea_user.php']);
00284 }
00285
00286 ?>