Documentation TYPO3 par Ameos

class.tx_rtehtmlarea_dam_browse_media.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2004 Kasper Skaarhoj (kasper@typo3.com)
00006 *  (c) 2004-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 ***************************************************************/
00036 require_once(PATH_t3lib.'class.t3lib_stdgraphic.php');
00037 require_once(PATH_t3lib.'class.t3lib_basicfilefunc.php');
00038 require_once(t3lib_extMgm::extPath('dam').'class.tx_dam_browse_media.php');
00039 
00047 class tx_rtehtmlarea_dam_browse_media extends tx_dam_browse_media {
00048         var $extKey = 'rtehtmlarea';
00049         var $content;
00050         var $act;
00051         var $allowedItems;
00052         var $plainMaxWidth;
00053         var $plainMaxHeight;
00054         var $magicMaxWidth;
00055         var $magicMaxHeight;
00056         var $imgPath;
00057         var $imgTitleDAMColumn = '';
00058         var $classesImageJSOptions;
00059         var $editorNo;
00060         var $sys_language_content;
00061         var $buttonConfig = array();
00062         
00071         function isValid($type, &$pObj) {
00072                 $isValid = false;
00073                 
00074                 $pArr = explode('|', t3lib_div::_GP('bparams'));
00075                 
00076                 if ($type=='rte' && $pObj->button == 'image') {
00077                         $isValid = true;
00078                 }
00079                 
00080                 return $isValid;
00081         }
00082         
00092         function render($type, &$pObj)  {
00093                 global $LANG, $BE_USER, $BACK_PATH;
00094                 
00095                 $this->pObj = &$pObj;
00096                 
00097                         // init class browse_links
00098                 $this->init();
00099                 
00100                 switch((string)$this->mode)     {
00101                         case 'rte':
00102                                 $content = $this->main_rte();
00103                         break;
00104 //                      case 'wizard':
00105 //                              $content = $this->main_rte(1);
00106 //                      break;
00107                         default:
00108                                 $content = '';
00109                         break;
00110                 }
00111 
00112                 return $content;
00113         }
00114         
00120         function init() {
00121                 global $BE_USER,$BACK_PATH,$TYPO3_CONF_VARS;
00122                 
00123                         // Main GPvars:
00124                 $this->siteUrl = t3lib_div::getIndpEnv('TYPO3_SITE_URL');
00125                 $this->act = t3lib_div::_GP('act');
00126                 $this->expandPage = t3lib_div::_GP('expandPage');
00127                 $this->expandFolder = t3lib_div::_GP('expandFolder');
00128                 
00129                         // Find RTE parameters
00130                 $this->bparams = t3lib_div::_GP('bparams');
00131                 $this->editorNo = t3lib_div::_GP('editorNo');
00132                 $this->sys_language_content = t3lib_div::_GP('sys_language_content');
00133                 $this->RTEtsConfigParams = t3lib_div::_GP('RTEtsConfigParams');
00134                 if (!$this->editorNo) {
00135                         $pArr = explode('|', $this->bparams);
00136                         $pRteArr = explode(':', $pArr[1]);
00137                         $this->editorNo = $pRteArr[0];
00138                         $this->sys_language_content = $pRteArr[1];
00139                         $this->RTEtsConfigParams = $pArr[2];
00140                 }
00141                 
00142                         // Find "mode"
00143                 $this->mode = t3lib_div::_GP('mode');
00144                 if (!$this->mode)       {
00145                         $this->mode='rte';
00146                 }
00147                 
00148                         // Site URL
00149                 $this->siteURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL');       // Current site url
00150                 
00151                         // the script to link to
00152                 $this->thisScript = t3lib_div::getIndpEnv('SCRIPT_NAME');
00153                 
00154                 if (!$this->act)        {
00155                         $this->act='magic';
00156                 }
00157                 
00158                 $RTEtsConfigParts = explode(':', $this->RTEtsConfigParams);
00159                 $RTEsetup = $BE_USER->getTSConfig('RTE',t3lib_BEfunc::getPagesTSconfig($RTEtsConfigParts[5]));
00160                 $this->thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup['properties'],$RTEtsConfigParts[0],$RTEtsConfigParts[2],$RTEtsConfigParts[4]);
00161                 $this->imgPath = $RTEtsConfigParts[6];
00162                 
00163                 if (is_array($this->thisConfig['buttons.']) && is_array($this->thisConfig['buttons.']['image.'])) {
00164                         $this->buttonConfig = $this->thisConfig['buttons.']['image.'];
00165                 }
00166                 
00167                 $this->allowedItems = explode(',','magic,plain,dragdrop,image,upload');
00168                 if (is_array($this->buttonConfig['options.']) && $this->buttonConfig['options.']['removeItems']) {
00169                         $this->allowedItems = array_diff($this->allowedItems,t3lib_div::trimExplode(',',$this->buttonConfig['options.']['removeItems'],1));
00170                 } else {
00171                         $this->allowedItems = array_diff($this->allowedItems,t3lib_div::trimExplode(',',$this->thisConfig['blindImageOptions'],1));
00172                 }
00173                 
00174                 reset($this->allowedItems);
00175                 if (!in_array($this->act,$this->allowedItems))  {
00176                         $this->act = current($this->allowedItems);
00177                 }
00178 
00179                 if ($this->act == 'magic') {
00180                         if (is_array($this->buttonConfig['options.']) && is_array($this->buttonConfig['options.']['magic.'])) {
00181                                 if ($this->buttonConfig['options.']['magic.']['maxWidth']) $this->magicMaxWidth = $this->buttonConfig['options.']['magic.']['maxWidth'];
00182                                 if ($this->buttonConfig['options.']['magic.']['maxHeight']) $this->magicMaxHeight = $this->buttonConfig['options.']['magic.']['maxHeight'];
00183                         }
00184                                 // These defaults allow images to be based on their width - to a certain degree - by setting a high height. Then we're almost certain the image will be based on the width
00185                         if (!$this->magicMaxWidth) $this->magicMaxWidth = 300;
00186                         if (!$this->magicMaxHeight) $this->magicMaxHeight = 1000;
00187                 } elseif ($this->act == 'plain') {
00188                         if ($TYPO3_CONF_VARS['EXTCONF'][$this->extKey]['plainImageMaxWidth']) $this->plainMaxWidth = $TYPO3_CONF_VARS['EXTCONF'][$this->extKey]['plainImageMaxWidth'];
00189                         if ($TYPO3_CONF_VARS['EXTCONF'][$this->extKey]['plainImageMaxHeight']) $this->plainMaxHeight = $TYPO3_CONF_VARS['EXTCONF'][$this->extKey]['plainImageMaxHeight'];
00190                         if (is_array($this->buttonConfig['options.']) && is_array($this->buttonConfig['options.']['plain.'])) {
00191                                 if ($this->buttonConfig['options.']['plain.']['maxWidth']) $this->plainMaxWidth = $this->buttonConfig['options.']['plain.']['maxWidth'];
00192                                 if ($this->buttonConfig['options.']['plain.']['maxHeight']) $this->plainMaxHeight = $this->buttonConfig['options.']['plain.']['maxHeight'];
00193                         }
00194                         if (!$this->plainMaxWidth) $this->plainMaxWidth = 640;
00195                         if (!$this->plainMaxHeight) $this->plainMaxHeight = 680;
00196                 }
00197                 
00198                 if ($this->thisConfig['classesImage']) {
00199                         $classesImageArray = t3lib_div::trimExplode(',',$this->thisConfig['classesImage'],1);
00200                         $this->classesImageJSOptions = '<option value=""></option>';
00201                         reset($classesImageArray);
00202                         while(list(,$class)=each($classesImageArray)) {
00203                                 $this->classesImageJSOptions .= '<option value="' .$class . '">' . $class . '</option>';
00204                         }
00205                 }
00206                 
00207                         // init the DAM object
00208                 $this->initDAM();
00209                 
00210                 $this->getModSettings();
00211                 
00212                 $this->processParams();
00213                 
00214                         // Insert the image if we are done
00215                 $this->imageInsert();
00216                 
00217                         // Creating backend template object:
00218                 $this->doc = t3lib_div::makeInstance('template');
00219                 $this->doc->docType= 'xhtml_trans';
00220                 $this->doc->backPath = $BACK_PATH;
00221                 
00222                 $this->getJSCode();
00223         }
00224 
00230         function rteImageStorageDir()   {
00231                 $dir = $this->imgPath ? $this->imgPath : $GLOBALS['TYPO3_CONF_VARS']['BE']['RTE_imageStorageDir'];;
00232                 return $dir;
00233         }
00234 
00240         function imageInsert()  {
00241                 global $TCA,$TYPO3_CONF_VARS;
00242                 
00243                 if (t3lib_div::_GP('insertImage')) {
00244                         $filepath = t3lib_div::_GP('insertImage');
00245                         
00246                         $imgObj = t3lib_div::makeInstance('t3lib_stdGraphic');
00247                         $imgObj->init();
00248                         $imgObj->mayScaleUp=0;
00249                         $imgObj->tempPath=PATH_site.$imgObj->tempPath;
00250                         $imgInfo = $imgObj->getImageDimensions($filepath);
00251                         
00252                         t3lib_div::loadTCA('tx_dam');
00253                         if (is_array($this->buttonConfig['title.']) && is_array($TCA['tx_dam']['columns'][$this->buttonConfig['title.']['useDAMColumn']])) {
00254                                 $this->imgTitleDAMColumn = $this->buttonConfig['title.']['useDAMColumn'];
00255                         }
00256                         if (!$this->imgTitleDAMColumn) $this->imgTitleDAMColumn = 'caption';
00257                         $imgMetaData = tx_dam::meta_getDataForFile($filepath,'uid,pid,alt_text,hpixels,vpixels,'.$this->imgTitleDAMColumn.','.$TCA['tx_dam']['ctrl']['languageField']);
00258                         $imgMetaData = $this->getRecordOverlay('tx_dam',$imgMetaData,$this->sys_language_content);
00259                         
00260                         switch ($this->act) {
00261                                 case 'magic':
00262                                         if (is_array($imgInfo) && count($imgInfo)==4 && $this->rteImageStorageDir() && is_array($imgMetaData))  {
00263                                                 $fI=pathinfo($imgInfo[3]);
00264                                                 $fileFunc = t3lib_div::makeInstance('t3lib_basicFileFunctions');
00265                                                 $basename = $fileFunc->cleanFileName('RTEmagicP_'.$fI['basename']);
00266                                                 $destPath =PATH_site.$this->rteImageStorageDir();
00267                                                 if (@is_dir($destPath)) {
00268                                                         $destName = $fileFunc->getUniqueName($basename,$destPath);
00269                                                         @copy($imgInfo[3],$destName);
00270                                                         
00271                                                         $cWidth = t3lib_div::intInRange(t3lib_div::_GP('cWidth'),0,$this->magicMaxWidth);
00272                                                         $cHeight = t3lib_div::intInRange(t3lib_div::_GP('cHeight'),0,$this->magicMaxHeight);
00273                                                         if (!$cWidth)   $cWidth = $this->magicMaxWidth;
00274                                                         if (!$cHeight)  $cHeight = $this->magicMaxHeight;
00275                                                         
00276                                                         $imgI = $imgObj->imageMagickConvert($filepath,'WEB',$cWidth.'m',$cHeight.'m');  // ($imagefile,$newExt,$w,$h,$params,$frame,$options,$mustCreate=0)
00277                                                         if ($imgI[3])   {
00278                                                                 $fI=pathinfo($imgI[3]);
00279                                                                 $mainBase='RTEmagicC_'.substr(basename($destName),10).'.'.$fI['extension'];
00280                                                                 $destName = $fileFunc->getUniqueName($mainBase,$destPath);
00281                                                                 @copy($imgI[3],$destName);
00282                                                                 $iurl = $this->siteUrl.substr($destName,strlen(PATH_site));
00283                                                                 $this->imageInsertJS($iurl,$imgI[0],$imgI[1],$imgMetaData['alt_text'],$imgMetaData[$this->imgTitleDAMColumn],substr($imgInfo[3],strlen(PATH_site)));
00284                                                         }
00285                                                 }
00286                                         }
00287                                         exit;
00288                                         break;
00289                                 case 'plain':
00290                                         if (is_array($imgInfo) && count($imgInfo)==4 && is_array($imgMetaData)) {
00291                                                 $iurl = $this->siteUrl.substr($imgInfo[3],strlen(PATH_site));
00292                                                 $this->imageInsertJS($iurl,$imgMetaData['hpixels'],$imgMetaData['vpixels'],$imgMetaData['alt_text'],$imgMetaData[$this->imgTitleDAMColumn],substr($imgInfo[3],strlen(PATH_site)));
00293                                         }
00294                                         exit;
00295                                         break;
00296                         }
00297                 }
00298         }
00299         
00300         function imageInsertJS($url,$width,$height,$altText,$titleText,$origFile) {
00301                 global $TYPO3_CONF_VARS;
00302                 
00303                 echo'
00304 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
00305 <html>
00306 <head>
00307         <title>Untitled</title>
00308 </head>
00309 <script language="javascript" type="text/javascript">
00310 /*<![CDATA[*/
00311         var editor = window.opener.RTEarea[' . $this->editorNo . ']["editor"];
00312         var HTMLArea = window.opener.HTMLArea;
00313         function insertImage(file,width,height,alt,title,origFile)      {
00314                 var styleWidth, styleHeight;
00315                 styleWidth = parseInt(width);
00316                 if (isNaN(styleWidth) || styleWidth == 0) {
00317                         styleWidth = "auto";
00318                 } else {
00319                         styleWidth += "px";
00320                 }
00321                 styleHeight = parseInt(height);
00322                 if (isNaN(styleHeight) || styleHeight == 0) {
00323                         styleHeight = "auto";
00324                 } else {
00325                         styleHeight += "px";
00326                 }
00327                 editor.renderPopup_insertImage(\'<img src="\'+file+\'" alt="\'+alt+\'" title="\'+title+\'" style="width: \'+styleWidth+\'; height: \'+styleHeight+\';"'.(($TYPO3_CONF_VARS['EXTCONF'][$this->extKey]['enableClickEnlarge'] && !(is_array($this->buttonConfig['clickEnlarge.']) && $this->buttonConfig['clickEnlarge.']['disabled']))?' clickenlargesrc="\'+origFile+\'" clickenlarge="0"':'').' />\');
00328         }
00329 /*]]>*/
00330 </script>
00331 <body>
00332 <script type="text/javascript">
00333 /*<![CDATA[*/
00334         insertImage('.t3lib_div::quoteJSvalue($url,1).','.$width.','.$height.','.t3lib_div::quoteJSvalue($altText,1).','.t3lib_div::quoteJSvalue($titleText,1).','.t3lib_div::quoteJSvalue($origFile,1).');
00335 /*]]>*/
00336 </script>
00337 </body>
00338 </html>';
00339         }
00340 
00346         function getJSCode()    {
00347                 global $LANG,$BACK_PATH,$TYPO3_CONF_VARS;
00348 
00349                 $JScode='
00350                         var editor = window.opener.RTEarea[' . $this->editorNo . ']["editor"];
00351                         var HTMLArea = window.opener.HTMLArea;
00352                         function insertElement(table, uid, type, filename,fp,filetype,imagefile,action, close)  {
00353                                 return jumpToUrl(\''.$this->thisScript.'?act='.$this->act.'&mode='.$this->mode.'&bparams='.$this->bparams.'&insertImage='.'\'+fp);
00354                         }
00355                         function jumpToUrl(URL,anchor)  {       //
00356                                 var add_act = URL.indexOf("act=")==-1 ? "&act='.$this->act.'" : "";
00357                                 var add_editorNo = URL.indexOf("editorNo=")==-1 ? "&editorNo='.$this->editorNo.'" : "";
00358                                 var add_sys_language_content = URL.indexOf("sys_language_content=")==-1 ? "&sys_language_content='.$this->sys_language_content.'" : "";
00359                                 var RTEtsConfigParams = "&RTEtsConfigParams='.rawurlencode(t3lib_div::_GP('RTEtsConfigParams')).'";
00360                                 
00361                                 var cur_width = selectedImageRef ? "&cWidth="+selectedImageRef.style.width : "";
00362                                 var cur_height = selectedImageRef ? "&cHeight="+selectedImageRef.style.height : "";
00363                                 
00364                                 var theLocation = URL+add_act+add_editorNo+add_sys_language_content+RTEtsConfigParams+cur_width+cur_height+(anchor?anchor:"");
00365                                 window.location.href = theLocation;
00366                                 return false;
00367                         }
00368                         function launchView(url) {
00369                                 var thePreviewWindow="";
00370                                 thePreviewWindow = window.open("'.$this->siteUrl.TYPO3_mainDir.'show_item.php?table="+url,"ShowItem","height=300,width=410,status=0,menubar=0,resizable=0,location=0,directories=0,scrollbars=1,toolbar=0");
00371                                 if (thePreviewWindow && thePreviewWindow.focus) {
00372                                         thePreviewWindow.focus();
00373                                 }
00374                         }
00375                         function getCurrentImageRef() {
00376                                 if (editor._selectedImage) {
00377                                         return editor._selectedImage;
00378                                 } else {
00379                                         return null;
00380                                 }
00381                         }
00382                         function printCurrentImageOptions() {
00383                                 var classesImage = ' . ($this->thisConfig['classesImage']?'true':'false') . ';
00384                                 if(classesImage) var styleSelector=\'<select name="iClass" style="width:140px;">' . $this->classesImageJSOptions  . '</select>\';
00385                                 var floatSelector=\'<select name="iFloat" id="iFloat"><option value="">' . $LANG->getLL('notSet') . '</option><option value="none">' . $LANG->getLL('nonFloating') . '</option><option value="left">' . $LANG->getLL('left') . '</option><option value="right">' . $LANG->getLL('right') . '</option></select>\';
00386                                 var bgColor=\' class="bgColor4"\';
00387                                 var sz="";
00388                                 sz+=\'<table border=0 cellpadding=1 cellspacing=1><form action="" name="imageData">\';
00389                                 if(classesImage) {
00390                                         sz+=\'<tr><td\'+bgColor+\'>'.$LANG->getLL('class').': </td><td>\'+styleSelector+\'</td></tr>\';
00391                                 }
00392                                 sz+=\'<tr><td\'+bgColor+\'><label for="iWidth">'.$LANG->getLL('width').': </label></td><td><input type="text" name="iWidth" id="iWidth" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(4).' /></td></tr>\';
00393                                 sz+=\'<tr><td\'+bgColor+\'><label for="iHeight">'.$LANG->getLL('height').': </label></td><td><input type="text" name="iHeight" id="iHeight" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(4).' /></td></tr>\';
00394                                 sz+=\'<tr><td\'+bgColor+\'><label for="iBorder">'.$LANG->getLL('border').': </label></td><td><input type="checkbox" name="iBorder" id="iBorder" value="1" /></td></tr>\';
00395                                 sz+=\'<tr><td\'+bgColor+\'><label for="iFloat">'.$LANG->getLL('float').': </label></td><td>\'+floatSelector+\'</td></tr>\';
00396                                 sz+=\'<tr><td\'+bgColor+\'><label for="iHspace">'.$LANG->getLL('margin_lr').': </label></td><td><input type="text" name="iHspace" id="iHspace" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(4).'></td></tr>\';
00397                                 sz+=\'<tr><td\'+bgColor+\'><label for="iVspace">'.$LANG->getLL('margin_tb').': </label></td><td><input type="text" name="iVspace" id="iVspace" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(4).' /></td></tr>\';
00398                                 sz+=\'<tr><td\'+bgColor+\'><label for="iTitle">'.$LANG->getLL('title').': </label></td><td><input type="text" name="iTitle" id="iTitle"'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' /></td></tr>\';
00399                                 sz+=\'<tr><td\'+bgColor+\'><label for="iAlt">'.$LANG->getLL('alt').': </label></td><td><input type="text" name="iAlt" id="iAlt"'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' /></td></tr>\';
00400                                 '.(($TYPO3_CONF_VARS['EXTCONF'][$this->extKey]['enableClickEnlarge'] && !(is_array($this->buttonConfig['clickEnlarge.']) && $this->buttonConfig['clickEnlarge.']['disabled']))?'if (selectedImageRef && selectedImageRef.getAttribute("clickenlargesrc")) sz+=\'<tr><td\'+bgColor+\'><label for="iClickEnlarge">'.$LANG->sL('LLL:EXT:cms/locallang_ttc.php:image_zoom',1).' </label></td><td><input type="checkbox" name="iClickEnlarge" id="iClickEnlarge" value="1" /></td></tr>\';':'').'
00401                                 sz+=\'<tr><td><input type="submit" value="'.$LANG->getLL('update').'" onClick="return setImageProperties();"></td></tr>\';
00402                                 sz+=\'</form></table>\';
00403                                 return sz;
00404                         }
00405                         function setImageProperties() {
00406                                 var classesImage = ' . ($this->thisConfig['classesImage']?'true':'false') . ';
00407                                 if (selectedImageRef)   {
00408                                         if(document.imageData.iWidth.value && document.imageData.iWidth.value != "auto") {
00409                                                 selectedImageRef.style.width = document.imageData.iWidth.value + "px";
00410                                         } else {
00411                                                 selectedImageRef.style.width = "auto";
00412                                         }
00413                                         selectedImageRef.removeAttribute("width");
00414                                         if(document.imageData.iHeight.value && document.imageData.iHeight.value != "auto") {
00415                                                 selectedImageRef.style.height=document.imageData.iHeight.value + "px";
00416                                         } else {
00417                                                 selectedImageRef.style.height = "auto";
00418                                         }
00419                                         selectedImageRef.removeAttribute("height");
00420 
00421                                         selectedImageRef.style.paddingTop = "0px";
00422                                         selectedImageRef.style.paddingBottom = "0px";
00423                                         selectedImageRef.style.paddingRight = "0px";
00424                                         selectedImageRef.style.paddingLeft = "0px";
00425                                         selectedImageRef.style.padding = "";  // this statement ignored by Mozilla 1.3.1
00426                                         if(document.imageData.iVspace.value != "" && !isNaN(parseInt(document.imageData.iVspace.value))) {
00427                                                 selectedImageRef.style.paddingTop = parseInt(document.imageData.iVspace.value) + "px";
00428                                                 selectedImageRef.style.paddingBottom = selectedImageRef.style.paddingTop;
00429                                         }
00430                                         if(document.imageData.iHspace.value != "" && !isNaN(parseInt(document.imageData.iHspace.value))) {
00431                                                 selectedImageRef.style.paddingRight = parseInt(document.imageData.iHspace.value) + "px";
00432                                                 selectedImageRef.style.paddingLeft = selectedImageRef.style.paddingRight;
00433                                         }
00434                                         selectedImageRef.removeAttribute("vspace");
00435                                         selectedImageRef.removeAttribute("hspace");
00436 
00437                                         selectedImageRef.title=document.imageData.iTitle.value;
00438                                         selectedImageRef.alt=document.imageData.iAlt.value;
00439 
00440                                         selectedImageRef.style.borderStyle = "none";
00441                                         selectedImageRef.style.borderWidth = "0px";
00442                                         selectedImageRef.style.border = "";  // this statement ignored by Mozilla 1.3.1
00443                                         if(document.imageData.iBorder.checked) {
00444                                                 selectedImageRef.style.borderStyle = "solid";
00445                                                 selectedImageRef.style.borderWidth = "thin";
00446                                         }
00447                                         selectedImageRef.removeAttribute("border");
00448 
00449                                         var iFloat = document.imageData.iFloat.options[document.imageData.iFloat.selectedIndex].value;
00450                                         if (iFloat || selectedImageRef.style.cssFloat || selectedImageRef.style.styleFloat)     {
00451                                                 if(document.all) {
00452                                                         selectedImageRef.style.styleFloat = iFloat;
00453                                                 } else {
00454                                                         selectedImageRef.style.cssFloat = iFloat;
00455                                                 }
00456                                         }
00457                                         
00458                                         if(classesImage) {
00459                                                 var iClass = document.imageData.iClass.options[document.imageData.iClass.selectedIndex].value;
00460                                                 if (iClass || (selectedImageRef.attributes["class"] && selectedImageRef.attributes["class"].value))     {
00461                                                         selectedImageRef.className = iClass;
00462                                                 }
00463                                         }
00464                                         
00465                                         '.(($TYPO3_CONF_VARS['EXTCONF'][$this->extKey]['enableClickEnlarge'] && !(is_array($this->buttonConfig['clickEnlarge.']) && $this->buttonConfig['clickEnlarge.']['disabled']))?'
00466                                         if (document.imageData.iClickEnlarge && document.imageData.iClickEnlarge.checked) selectedImageRef.setAttribute("clickenlarge","1");
00467                                                 else selectedImageRef.setAttribute("clickenlarge","0");':'').'
00468                                         
00469                                         HTMLArea.edHidePopup();
00470                                 }
00471                                 return false;
00472                         }
00473                         function insertImagePropertiesInForm()  {
00474                                 var classesImage = ' . ($this->thisConfig['classesImage']?'true':'false') . ';
00475                                 if (selectedImageRef)   {
00476                                         var styleWidth, styleHeight, paddingTop, paddingRight;
00477                                         styleWidth = selectedImageRef.style.width ? selectedImageRef.style.width : selectedImageRef.width;
00478                                         styleWidth = parseInt(styleWidth);
00479                                         if (isNaN(styleWidth) || styleWidth == 0) { styleWidth = "auto"; }
00480                                         document.imageData.iWidth.value = styleWidth;
00481                                         styleHeight = selectedImageRef.style.height ? selectedImageRef.style.height : selectedImageRef.height;
00482                                         styleHeight = parseInt(styleHeight);
00483                                         if (isNaN(styleHeight) || styleHeight == 0) { styleHeight = "auto"; }
00484                                         document.imageData.iHeight.value = styleHeight;
00485 
00486                                         paddingTop = selectedImageRef.style.paddingTop ? selectedImageRef.style.paddingTop : selectedImageRef.vspace;
00487                                         paddingTop = parseInt(paddingTop);
00488                                         if (isNaN(paddingTop) || paddingTop < 0) { paddingTop = ""; }
00489                                         document.imageData.iVspace.value = paddingTop;
00490                                         paddingRight = selectedImageRef.style.paddingRight ? selectedImageRef.style.paddingRight : selectedImageRef.hspace;
00491                                         paddingRight = parseInt(paddingRight);
00492                                         if (isNaN(paddingRight) || paddingRight < 0) { paddingRight = ""; }
00493                                         document.imageData.iHspace.value = paddingRight;
00494 
00495                                         document.imageData.iTitle.value = selectedImageRef.title;
00496                                         document.imageData.iAlt.value = selectedImageRef.alt;
00497 
00498                                         if((selectedImageRef.style.borderStyle && selectedImageRef.style.borderStyle != "none" && selectedImageRef.style.borderStyle != "none none none none") || selectedImageRef.border) {
00499                                                 document.imageData.iBorder.checked = 1;
00500                                         }
00501 
00502                                         var fObj=document.imageData.iFloat;
00503                                         var value = (selectedImageRef.style.cssFloat ? selectedImageRef.style.cssFloat : selectedImageRef.style.styleFloat);
00504                                         var l=fObj.length;
00505                                         for (a=0;a<l;a++)       {
00506                                                 if (fObj.options[a].value == value)     {
00507                                                         fObj.selectedIndex = a;
00508                                                 }
00509                                         }
00510 
00511                                         if(classesImage) {
00512                                                 var fObj=document.imageData.iClass;
00513                                                 var value=selectedImageRef.className;
00514                                                 var l=fObj.length;
00515                                                 for (a=0;a<l;a++)       {
00516                                                         if (fObj.options[a].value == value)     {
00517                                                                 fObj.selectedIndex = a;
00518                                                         }
00519                                                 }
00520                                         }
00521                                         
00522                                         '.(($TYPO3_CONF_VARS['EXTCONF'][$this->extKey]['enableClickEnlarge'] && !(is_array($this->buttonConfig['clickEnlarge.']) && $this->buttonConfig['clickEnlarge.']['disabled']))?'if (selectedImageRef.getAttribute("clickenlargesrc")) {
00523                                                 if (selectedImageRef.getAttribute("clickenlarge") == "1") document.imageData.iClickEnlarge.checked = 1;
00524                                                         else document.imageData.iClickEnlarge.removeAttribute("checked");
00525                                         }':'').'
00526                                 }
00527                                 return false;
00528                         }
00529 
00530                         function openDragDrop() {
00531                                 var url = "' . $BACK_PATH . 'browse_links.php?mode=filedrag&editorNo='.$this->editorNo.'&bparams=|'.implode(':', array($this->editorNo,$this->sys_language_content)).'||"+escape("gif,jpg,jpeg,png");
00532                                 window.opener.browserWin = window.open(url,"Typo3WinBrowser","height=350,width=600,status=0,menubar=0,resizable=1,scrollbars=1");
00533                                 HTMLArea.edHidePopup();
00534                         }
00535 
00536                         var selectedImageRef = getCurrentImageRef();    // Setting this to a reference to the image object.
00537 
00538                         '.($this->act=='dragdrop'?'openDragDrop();':'');
00539 
00540                         // Finally, add the accumulated JavaScript to the template object:
00541                 $this->doc->JScode = $this->doc->wrapScriptTags($JScode);
00542         }
00543         
00544         function reinitParams() {
00545 // We need to pass along some RTE parameters
00546                 if ($this->editorNo) {
00547                         $pArr = explode('|', $this->bparams);
00548                         $pArr[1] = implode(':', array($this->editorNo, $this->sys_language_content));
00549                         $pArr[2] = $this->RTEtsConfigParams;
00550                         $this->bparams = implode('|', $pArr);
00551                         
00552                 }
00553 // We need to pass along some RTE parameters
00554                 parent::reinitParams();
00555         }
00556         
00562         function displayThumbs() {
00563                 global $BE_USER;
00564 // Honor options.noThumbsInRTEimageSelect               
00565                 return parent::displayThumbs() && !$BE_USER->getTSConfigVal('options.noThumbsInRTEimageSelect');
00566 // Honor options.noThumbsInRTEimageSelect
00567         }
00568         
00574         function addDisplayOptions() {
00575                 global $BE_USER;
00576                 
00577                         // Getting flag for showing/not showing thumbnails:
00578 // Honor options.noThumbsInRTEimageSelect
00579                 $noThumbs = $BE_USER->getTSConfigVal('options.noThumbsInEB') || ($this->mode == 'rte' && $BE_USER->getTSConfigVal('options.noThumbsInRTEimageSelect'));
00580 // Honor options.noThumbsInRTEimageSelect
00581                 if ($noThumbs)  {
00582                         $thumbNailCheckbox = '';
00583                 } else {
00584 
00585                         $thumbNailCheckbox = t3lib_BEfunc::getFuncCheck('', 'SET[displayThumbs]',$this->displayThumbs(), $this->thisScript, t3lib_div::implodeArrayForUrl('',$this->addParams));
00586                         $description = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:displayThumbs',1);
00587                         $id = 'l'.uniqid('tx_dam_scbase');
00588                         $idAttr = ' id="'.$id.'"';
00589                         $thumbNailCheckbox = str_replace('<input', '<input'.$idAttr, $thumbNailCheckbox);
00590                         $thumbNailCheckbox .= ' <label for="'.$id.'">'.$description.'</label>';
00591                         $this->damSC->addOption('html', 'thumbnailCheckbox', $thumbNailCheckbox);
00592                 }
00593                 $this->damSC->addOption('funcCheck', 'extendedInfo', $GLOBALS['LANG']->getLL('displayExtendedInfo',1));
00594         }
00595         
00603         function renderFileList($files, $mode='file') {
00604                 global $LANG;
00605 
00606                 $out = '';
00607 
00608                         // Listing the files:
00609                 if (is_array($files) AND count($files)) {
00610 
00611                         $displayThumbs = $this->displayThumbs();
00612 
00613                                 // Traverse the file list:
00614                         $lines=array();
00615                         foreach($files as $fI)  {
00616 
00617                                 if (!$fI['__exists']) {
00618                                         continue;
00619                                 }
00620 
00621                                         // Create file icon:
00622                                 $titleAttrib = tx_dam_guiFunc::icon_getTitleAttribute($fI);
00623                                 $iconFile = tx_dam::icon_getFileType($fI);
00624                                 $iconTag = tx_dam_guiFunc::icon_getFileTypeImgTag($fI);
00625                                 $iconAndFilename = $iconTag.htmlspecialchars(t3lib_div::fixed_lgd_cs($fI['file_title'], $GLOBALS['BE_USER']->uc['titleLen']));
00626 
00627 
00628                                         // Create links for adding the file:
00629                                 if (strstr($fI['file_name_absolute'], ',') || strstr($fI['file_name_absolute'], '|'))   {       // In case an invalid character is in the filepath, display error message:
00630                                         $eMsg = $LANG->JScharCode(sprintf($LANG->getLL('invalidChar'), ', |'));
00631                                         $ATag_insert = '<a href="#" onclick="alert('.$eMsg.');return false;">';
00632 
00633                                         // If filename is OK, just add it:
00634                                 } else {
00635 
00636                                                 // JS: insertElement(table, uid, type, filename, fpath, filetype, imagefile ,action, close)
00637                                         $onClick_params = implode (', ', array(
00638                                                 "'".$fI['_ref_table']."'",
00639                                                 "'".$fI['_ref_id']."'",
00640                                                 "'".$mode."'",
00641                                                 $this->quoteJSvalue($fI['file_name']),
00642                                                 $this->quoteJSvalue($fI['_ref_file_path']),
00643                                                 "'".$fI['file_type']."'",
00644                                                 "'".$iconFile."'")
00645                                                 );
00646                                         $onClick = 'return insertElement('.$onClick_params.');';
00647                                         $ATag_add = '<a href="#" onclick="'.htmlspecialchars($onClick).'"'.$titleAttrib.'>';
00648                                         $onClick = 'return insertElement('.$onClick_params.', \'\', 1);';
00649                                         $ATag_insert = '<a href="#" onclick="'.htmlspecialchars($onClick).'"'.$titleAttrib.'>';
00650                                 }
00651 
00652                                         // Create link to showing details about the file in a window:
00653                                 if ($fI['__exists']) {
00654                                         $Ahref = $GLOBALS['BACK_PATH'].'show_item.php?table='.rawurlencode($fI['file_name_absolute']).'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
00655                                         $ATag_info = '<a href="'.htmlspecialchars($Ahref).'">';
00656                                         $info = $ATag_info.'<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/zoom2.gif', 'width="12" height="12"').' title="'.$LANG->getLL('info',1).'" alt="" /> '.$LANG->getLL('info',1).'</a>';
00657 
00658                                 } else {
00659                                         $info = '&nbsp;';
00660                                 }
00661 
00662                                         // Thumbnail/size generation:
00663                                 $clickThumb = '';
00664                                 if (t3lib_div::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $fI['file_type']) AND $displayThumbs AND is_file($fI['file_name_absolute'])) {
00665 // adding $GLOBALS['BACK_PATH']
00666                                         $clickThumb = t3lib_BEfunc::getThumbNail($GLOBALS['BACK_PATH'].'thumbs.php', $fI['file_path_absolute'].$fI['file_name'], '');
00667 // adding $GLOBALS['BACK_PATH']
00668                                         $clickThumb = '<div style="width:56px; overflow:auto; padding: 5px; background-color:#fff; border:solid 1px #ccc;">'.$ATag_insert.$clickThumb.'</a>'.'</div>';
00669                                 } elseif ($displayThumbs) {
00670                                         $clickThumb = '<div style="width:68px"></div>';
00671                                 }
00672 
00673 
00674                                         // Show element:
00675                                 $lines[] = '
00676                                         <tr class="bgColor4">
00677                                                 <td valign="top" nowrap="nowrap" style="min-width:20em">'.$ATag_insert.$iconAndFilename.'</a>'.'&nbsp;</td>
00678                                                 <td valign="top" width="1%">'.$ATag_add.'<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/plusbullet2.gif', 'width="18" height="16"').' title="'.$LANG->getLL('addToList',1).'" alt="" /></a></td>
00679                                                 <td valign="top" nowrap="nowrap" width="1%">'.$info.'</td>
00680                                         </tr>';
00681 
00682 
00683                                 $infoText = '';
00684                                 if ($this->getModSettings('extendedInfo')) {
00685                                         $infoText = tx_dam_guiFunc::meta_compileInfoData ($fI, 'file_name, file_size:filesize, _dimensions, caption:truncate:50, instructions', 'table');
00686                                         $infoText = str_replace('<table>', '<table border="0" cellpadding="0" cellspacing="1">', $infoText);
00687                                         $infoText = str_replace('<strong>', '<strong style="font-weight:normal;">', $infoText);
00688                                         $infoText = str_replace('</td><td>', '</td><td class="bgColor-10">', $infoText);
00689                                 }
00690 
00691 
00692                                 if ($displayThumbs AND $infoText) {
00693                                         $lines[] = '
00694                                                 <tr class="bgColor">
00695                                                         <td valign="top" colspan="3">
00696                                                         <table border="0" cellpadding="0" cellspacing="0"><tr>
00697                                                                 <td valign="top">'.$clickThumb.'</td>
00698                                                                 <td valign="top" style="padding-left:1em">'.$infoText.'</td></tr>
00699                                                         </table>
00700                                                         <div style="height:0.5em;"></div>
00701                                                         </td>
00702                                                 </tr>';
00703                                 } elseif ($clickThumb OR $infoText) {
00704                                         $lines[] = '
00705                                                 <tr class="bgColor">
00706                                                         <td valign="top" colspan="3" style="padding-left:22px">
00707                                                         '.$clickThumb.$infoText.'
00708                                                         <div style="height:0.5em;"></div>
00709                                                         </td>
00710                                                 </tr>';
00711                                 }
00712 
00713                                 $lines[] = '
00714                                                 <tr>
00715                                                         <td colspan="3"><div style="height:0.5em;"></div></td>
00716                                                 </tr>';
00717                         }
00718 
00719                                 // Wrap all the rows in table tags:
00720                         $out .= '
00721 
00722 
00723 
00724                 <!--
00725                         File listing
00726                 -->
00727                                 <table border="0" cellpadding="1" cellspacing="1" id="typo3-fileList">
00728                                         '.implode('',$lines).'
00729                                 </table>';
00730                 }
00731 
00732                         // Return accumulated content for filelisting:
00733                 return $out;
00734         }
00735         
00744         function getFileListArr($allowedFileTypes, $disallowedFileTypes, $mode) {
00745                 global $TYPO3_CONF_VARS;
00746                 
00747                 $filearray = array();
00748 
00749                 //
00750                 // Use the current selection to create a query and count selected records
00751                 //
00752 
00753                 $this->damSC->selection->addSelectionToQuery();
00754                 $this->damSC->selection->qg->query['FROM']['tx_dam'] = tx_dam_db::getMetaInfoFieldList(true, array('hpixels','vpixels','caption'));
00755                 #$this->damSC->selection->qg->addSelectFields(...
00756                 if ($allowedFileTypes) {
00757                         $extList = '"'.implode ('","', explode(',',$allowedFileTypes)).'"';
00758                         $this->damSC->selection->qg->addWhere('AND tx_dam.file_type IN ('.$extList.')', 'WHERE', 'tx_dam.file_type');
00759                 }
00760                 if ($disallowedFileTypes) {
00761                         $extList = '"'.implode ('","', explode(',',$disallowedFileTypes)).'"';
00762                         $this->damSC->selection->qg->addWhere('AND NOT tx_dam.file_type IN ('.$extList.')', 'WHERE', 'NOT tx_dam.file_type');
00763                 }
00764 // selection with limited dimensions
00765                 if ($this->act == 'plain') {
00766                         $this->damSC->selection->qg->addWhere('AND tx_dam.hpixels <= '.intval($this->plainMaxWidth), 'WHERE', 'tx_dam.hpixels');
00767                         $this->damSC->selection->qg->addWhere('AND tx_dam.vpixels <= '.intval($this->plainMaxHeight), 'WHERE', 'tx_dam.vpixels');
00768                 }
00769 // selection with limited dimensions
00770                 
00771                 $this->damSC->selection->execSelectionQuery(TRUE);
00772 
00773                         // any records found?
00774                 if($this->damSC->selection->pointer->countTotal) {
00775 
00776                                 // limit query for browsing
00777                         $this->damSC->selection->addLimitToQuery();
00778                         $this->damSC->selection->execSelectionQuery();
00779 
00780                         if($this->damSC->selection->res) {
00781                                 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($this->damSC->selection->res)) {
00782 
00783                                         $row['file_title'] = $row['title'] ? $row['title'] : $row['file_name'];
00784                                         $row['file_path_absolute'] = tx_dam::path_makeAbsolute($row['file_path']);
00785                                         $row['file_name_absolute'] = $row['file_path_absolute'].$row['file_name'];
00786                                         $row['__exists'] = @is_file($row['file_name_absolute']);
00787 
00788                                         if ($mode=='db') {
00789                                                 $row['_ref_table'] = 'tx_dam';
00790                                                 $row['_ref_id'] = $row['uid'];
00791                                                 $row['_ref_file_path'] = '';
00792                                         } else {
00793                                                 $row['_ref_table'] = '';
00794                                                 $row['_ref_id'] = t3lib_div::shortMD5($row['file_name_absolute']);
00795                                                 $row['_ref_file_path'] = $row['file_name_absolute'];
00796                                         }
00797 
00798                                         $filearray[] = $row;
00799                                         if (count($filearray) >= $this->damSC->selection->pointer->itemsPerPage) {
00800                                                 break;
00801                                         }
00802                                 }
00803                         }
00804                 }
00805 
00806                 return $filearray;
00807         }
00808         
00814         function main_rte()     {
00815                 global $LANG, $TYPO3_CONF_VARS, $FILEMOUNTS, $BE_USER;
00816                 
00817                 $path = tx_dam::path_makeAbsolute($this->damSC->path);
00818                 if (!$path OR !@is_dir($path))  {
00819                         $fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
00820                         $fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
00821                         $path = $fileProcessor->findTempFolder().'/';   // The closest TEMP-path is found
00822                 }
00823                 $this->damSC->path = tx_dam::path_makeRelative($path); // mabe not needed
00824                 
00825                         // Starting content:
00826                 $this->content = $this->doc->startPage($LANG->getLL('Insert Image',1));
00827                 
00828                 $this->reinitParams();
00829                 
00830                         // Making menu in top:
00831                 $menuDef = array();
00832                 if (in_array('image',$this->allowedItems) && ($this->act=='image' || t3lib_div::_GP('cWidth'))) {
00833                         $menuDef['page']['isActive'] = $this->act=='image';
00834                         $menuDef['page']['label'] = $LANG->getLL('currentImage',1);
00835                         $menuDef['page']['url'] = '#';
00836                         $menuDef['page']['addParams'] = 'onClick="jumpToUrl(\''.htmlspecialchars($this->thisScript.'?act=image&mode='.$this->mode.'&bparams='.$this->bparams).'\');return false;"';
00837                 }
00838                 if (in_array('magic',$this->allowedItems)){
00839                         $menuDef['file']['isActive'] = $this->act=='magic';
00840                         $menuDef['file']['label'] = $LANG->getLL('magicImage',1);
00841                         $menuDef['file']['url'] = '#';
00842                         $menuDef['file']['addParams'] = 'onClick="jumpToUrl(\''.htmlspecialchars($this->thisScript.'?act=magic&mode='.$this->mode.'&bparams='.$this->bparams).'\');return false;"';
00843                 }
00844                 if (in_array('plain',$this->allowedItems)) {
00845                         $menuDef['url']['isActive'] = $this->act=='plain';
00846                         $menuDef['url']['label'] = $LANG->getLL('plainImage',1);
00847                         $menuDef['url']['url'] = '#';
00848                         $menuDef['url']['addParams'] = 'onClick="jumpToUrl(\''.htmlspecialchars($this->thisScript.'?act=plain&mode='.$this->mode.'&bparams='.$this->bparams).'\');return false;"';
00849                 }
00850                 if (in_array('dragdrop',$this->allowedItems)) {
00851                         $menuDef['mail']['isActive'] = $this->act=='dragdrop';
00852                         $menuDef['mail']['label'] = $LANG->getLL('dragDropImage',1);
00853                         $menuDef['mail']['url'] = '#';
00854                         $menuDef['mail']['addParams'] = 'onClick="openDragDrop();return false;"';
00855                 }
00856                 if (in_array('upload', $this->allowedItems)) {
00857                         $menuDef['upload']['isActive'] = ($this->act=='upload');
00858                         $menuDef['upload']['label'] = $LANG->getLL('tx_dam_file_upload.title',1);
00859                         $menuDef['upload']['url'] = '#';
00860                         $menuDef['upload']['addParams'] = 'onclick="jumpToUrl(\''.htmlspecialchars($this->thisScript.'?act=upload&mode='.$this->mode.'&bparams='.$this->bparams).'\');return false;"';
00861                 }
00862                 $this->content .= $this->doc->getTabMenuRaw($menuDef);
00863                 
00864                 switch($this->act)      {
00865                         case 'image':
00866                                 $JScode = '
00867                                 document.write(printCurrentImageOptions());
00868                                 insertImagePropertiesInForm();';
00869                                 $this->content.= '<br />'.$this->doc->wrapScriptTags($JScode);
00870                                 break;
00871                         case 'upload':
00872                                 $this->content.= $this->dam_upload($this->allowedFileTypes, $this->disallowedFileTypes);
00873                                 $this->content.= $this->damSC->getOptions();
00874                                 $this->content.='<br /><br />';
00875                                 if ($BE_USER->isAdmin() || $BE_USER->getTSConfigVal('options.createFoldersInEB'))       {
00876                                         $this->content.= $this->createFolder($path);
00877                                         $this->content.= '<br />';
00878                                 }
00879                                 break;
00880                         case 'plain':
00881                                 $this->allowedFileTypes = 'jpg,jpeg,gif,png';
00882                         case 'magic':
00883                                 $this->addDisplayOptions();
00884                                 $this->content.= $this->dam_select($this->allowedFileTypes, $this->disallowedFileTypes);
00885                                 $this->content.= $this->damSC->getOptions();
00886                         
00887                                 if ($this->act=='magic')        {
00888                                         $this->content .= $this->getMsgBox($LANG->getLL('magicImage_msg'));
00889                                 }
00890                                 if ($this->act=='plain')        {
00891                                         $this->content .= $this->getMsgBox(sprintf($LANG->getLL('plainImage_msg'), $this->plainMaxWidth, $this->plainMaxHeight));
00892                                 }
00893                                 break;
00894                         default:
00895                                 break;
00896                 }
00897                         // Ending page, returning content:
00898                 $this->content.= $this->doc->endPage();
00899                 $this->content = $this->damSC->doc->insertStylesAndJS($this->content);
00900                 return $this->content;
00901         }
00902         
00913         function getRecordOverlay($table,$row,$sys_language_content,$OLmode='') {
00914                 global $TCA, $TYPO3_DB;
00915                 if ($row['uid']>0 && $row['pid']>0)     {
00916                         if ($TCA[$table] && $TCA[$table]['ctrl']['languageField'] && $TCA[$table]['ctrl']['transOrigPointerField'])     {
00917                                 if (!$TCA[$table]['ctrl']['transOrigPointerTable'])     {
00918                                                 // Will try to overlay a record only if the sys_language_content value is larger that zero.
00919                                         if ($sys_language_content>0)    {
00920                                                         // Must be default language or [All], otherwise no overlaying:
00921                                                 if ($row[$TCA[$table]['ctrl']['languageField']]<=0)     {
00922                                                                 // Select overlay record:
00923                                                         $res = $TYPO3_DB->exec_SELECTquery(
00924                                                                 '*',
00925                                                                 $table,
00926                                                                 'pid='.intval($row['pid']).
00927                                                                         ' AND '.$TCA[$table]['ctrl']['languageField'].'='.intval($sys_language_content).
00928                                                                         ' AND '.$TCA[$table]['ctrl']['transOrigPointerField'].'='.intval($row['uid']).
00929                                                                         t3lib_BEfunc::BEenableFields($table).
00930                                                                         t3lib_BEfunc::deleteClause($table),
00931                                                                 '',
00932                                                                 '',
00933                                                                 '1'
00934                                                                 );
00935                                                         $olrow = $TYPO3_DB->sql_fetch_assoc($res);
00936                                                         //$this->versionOL($table,$olrow);
00937                                                         
00938                                                                 // Merge record content by traversing all fields:
00939                                                         if (is_array($olrow))   {
00940                                                                 foreach($row as $fN => $fV)     {
00941                                                                         if ($fN!='uid' && $fN!='pid' && isset($olrow[$fN]))     {
00942                                                                                 if ($TCA[$table]['l10n_mode'][$fN]!='exclude' && ($TCA[$table]['l10n_mode'][$fN]!='mergeIfNotBlank' || strcmp(trim($olrow[$fN]),'')))   {
00943                                                                                         $row[$fN] = $olrow[$fN];
00944                                                                                 }
00945                                                                         }
00946                                                                 }
00947                                                         } elseif ($OLmode==='hideNonTranslated' && $row[$TCA[$table]['ctrl']['languageField']]==0)      {       // Unset, if non-translated records should be hidden. ONLY done if the source record really is default language and not [All] in which case it is allowed.
00948                                                                 unset($row);
00949                                                         }
00950 
00951                                                         // Otherwise, check if sys_language_content is different from the value of the record - that means a japanese site might try to display french content.
00952                                                 } elseif ($sys_language_content!=$row[$TCA[$table]['ctrl']['languageField']])   {
00953                                                         unset($row);
00954                                                 }
00955                                         } else {
00956                                                         // When default language is displayed, we never want to return a record carrying another language!:
00957                                                 if ($row[$TCA[$table]['ctrl']['languageField']]>0)      {
00958                                                         unset($row);
00959                                                 }
00960                                         }
00961                                 }
00962                         }
00963                 }
00964 
00965                 return $row;
00966         }
00967 
00968 }
00969 
00970 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/mod4/class.tx_rtehtmlarea_dam_browse_media.php'])  {
00971         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/mod4/class.tx_rtehtmlarea_dam_browse_media.php']);
00972 }
00973 
00974 ?>


Généré par TYPO3 Ameos avec  doxygen 1.4.6