/**
  * Processing of the sheet/language data array
  * When it finds a field with a value the processing is done by ->checkValue_SW() by default but if a call back function name is given that method in this class will be called for the processing instead.
  *
  * @param	array		New values (those being processed): Multidimensional Data array for sheet/language, passed by reference!
  * @param	array		Current values: Multidimensional Data array. May be empty array() if not needed (for callBackFunctions)
  * @param	array		Uploaded files array for sheet/language. May be empty array() if not needed (for callBackFunctions)
  * @param	array		Data structure which fits the data array
  * @param	array		A set of parameters to pass through for the calling of the evaluation functions / call back function
  * @param	string		Call back function, default is checkValue_SW(). If $this->callBackObj is set to an object, the callback function in that object is called instead.
  * @param	[type]		$structurePath: ...
  * @return	void
  * @see checkValue_flex_procInData()
  */
 function checkValue_flex_procInData_travDS(&$dataValues, $dataValues_current, $uploadedFiles, $DSelements, $pParams, $callBackFunc, $structurePath)
 {
     if (is_array($DSelements)) {
         // For each DS element:
         foreach ($DSelements as $key => $dsConf) {
             // Array/Section:
             if ($DSelements[$key]['type'] == 'array') {
                 if (is_array($dataValues[$key]['el'])) {
                     if ($DSelements[$key]['section']) {
                         $newIndexCounter = 0;
                         foreach ($dataValues[$key]['el'] as $ik => $el) {
                             if (is_array($el)) {
                                 if (!is_array($dataValues_current[$key]['el'])) {
                                     $dataValues_current[$key]['el'] = array();
                                 }
                                 $theKey = key($el);
                                 if (is_array($dataValues[$key]['el'][$ik][$theKey]['el'])) {
                                     $this->checkValue_flex_procInData_travDS($dataValues[$key]['el'][$ik][$theKey]['el'], is_array($dataValues_current[$key]['el'][$ik]) ? $dataValues_current[$key]['el'][$ik][$theKey]['el'] : array(), $uploadedFiles[$key]['el'][$ik][$theKey]['el'], $DSelements[$key]['el'][$theKey]['el'], $pParams, $callBackFunc, $structurePath . $key . '/el/' . $ik . '/' . $theKey . '/el/');
                                     // If element is added dynamically in the flexform of TCEforms, we map the ID-string to the next numerical index we can have in that particular section of elements:
                                     // The fact that the order changes is not important since order is controlled by a separately submitted index.
                                     if (substr($ik, 0, 3) == "ID-") {
                                         $newIndexCounter++;
                                         $this->newIndexMap[$ik] = (is_array($dataValues_current[$key]['el']) && count($dataValues_current[$key]['el']) ? max(array_keys($dataValues_current[$key]['el'])) : 0) + $newIndexCounter;
                                         // Set mapping index
                                         $dataValues[$key]['el'][$this->newIndexMap[$ik]] = $dataValues[$key]['el'][$ik];
                                         // Transfer values
                                         unset($dataValues[$key]['el'][$ik]);
                                         // Unset original
                                     }
                                 }
                             }
                         }
                     } else {
                         if (!isset($dataValues[$key]['el'])) {
                             $dataValues[$key]['el'] = array();
                         }
                         $this->checkValue_flex_procInData_travDS($dataValues[$key]['el'], $dataValues_current[$key]['el'], $uploadedFiles[$key]['el'], $DSelements[$key]['el'], $pParams, $callBackFunc, $structurePath . $key . '/el/');
                     }
                 }
             } else {
                 if (is_array($dsConf['TCEforms']['config']) && is_array($dataValues[$key])) {
                     foreach ($dataValues[$key] as $vKey => $data) {
                         if ($callBackFunc) {
                             if (is_object($this->callBackObj)) {
                                 $res = $this->callBackObj->{$callBackFunc}($pParams, $dsConf['TCEforms']['config'], $dataValues[$key][$vKey], $dataValues_current[$key][$vKey], $uploadedFiles[$key][$vKey], $structurePath . $key . '/' . $vKey . '/');
                             } else {
                                 $res = $this->{$callBackFunc}($pParams, $dsConf['TCEforms']['config'], $dataValues[$key][$vKey], $dataValues_current[$key][$vKey], $uploadedFiles[$key][$vKey], $structurePath . $key . '/' . $vKey . '/');
                             }
                         } else {
                             // Default
                             list($CVtable, $CVid, $CVcurValue, $CVstatus, $CVrealPid, $CVrecFID, $CVtscPID) = $pParams;
                             $res = $this->checkValue_SW(array(), $dataValues[$key][$vKey], $dsConf['TCEforms']['config'], $CVtable, $CVid, $dataValues_current[$key][$vKey], $CVstatus, $CVrealPid, $CVrecFID, '', $uploadedFiles[$key][$vKey], array(), $CVtscPID);
                             // Look for RTE transformation of field:
                             if ($dataValues[$key]['_TRANSFORM_' . $vKey] == 'RTE' && !$this->dontProcessTransformations) {
                                 // Unsetting trigger field - we absolutely don't want that into the data storage!
                                 unset($dataValues[$key]['_TRANSFORM_' . $vKey]);
                                 if (isset($res['value'])) {
                                     // Calculating/Retrieving some values here:
                                     list(, , $recFieldName) = explode(':', $CVrecFID);
                                     $theTypeString = t3lib_BEfunc::getTCAtypeValue($CVtable, $this->checkValue_currentRecord);
                                     $specConf = t3lib_BEfunc::getSpecConfParts('', $dsConf['TCEforms']['defaultExtras']);
                                     // Find, thisConfig:
                                     $RTEsetup = $this->BE_USER->getTSConfig('RTE', t3lib_BEfunc::getPagesTSconfig($CVtscPID));
                                     $thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup['properties'], $CVtable, $recFieldName, $theTypeString);
                                     // Get RTE object, draw form and set flag:
                                     $RTEobj = t3lib_BEfunc::RTEgetObj();
                                     if (is_object($RTEobj)) {
                                         $res['value'] = $RTEobj->transformContent('db', $res['value'], $CVtable, $recFieldName, $this->checkValue_currentRecord, $specConf, $thisConfig, '', $CVrealPid);
                                     } else {
                                         debug('NO RTE OBJECT FOUND!');
                                     }
                                 }
                             }
                         }
                         // Adding the value:
                         if (isset($res['value'])) {
                             $dataValues[$key][$vKey] = $res['value'];
                         }
                         // Finally, check if new and old values are different (or no .vDEFbase value is found) and if so, we record the vDEF value for diff'ing.
                         // We do this after $dataValues has been updated since I expect that $dataValues_current holds evaluated values from database (so this must be the right value to compare with).
                         if (substr($vKey, -9) != '.vDEFbase') {
                             if ($this->clear_flexFormData_vDEFbase) {
                                 $dataValues[$key][$vKey . '.vDEFbase'] = '';
                             } elseif ($this->updateModeL10NdiffData && $GLOBALS['TYPO3_CONF_VARS']['BE']['flexFormXMLincludeDiffBase'] && $vKey !== 'vDEF' && (strcmp($dataValues[$key][$vKey], $dataValues_current[$key][$vKey]) || !isset($dataValues_current[$key][$vKey . '.vDEFbase']) || $this->updateModeL10NdiffData === 'FORCE_FFUPD')) {
                                 // Now, check if a vDEF value is submitted in the input data, if so we expect this has been processed prior to this operation (normally the case since those fields are higher in the form) and we can use that:
                                 if (isset($dataValues[$key]['vDEF'])) {
                                     $diffValue = $dataValues[$key]['vDEF'];
                                 } else {
                                     // If not found (for translators with no access to the default language) we use the one from the current-value data set:
                                     $diffValue = $dataValues_current[$key]['vDEF'];
                                 }
                                 // Setting the reference value for vDEF for this translation. This will be used for translation tools to make a diff between the vDEF and vDEFbase to see if an update would be fitting.
                                 $dataValues[$key][$vKey . '.vDEFbase'] = $this->updateModeL10NdiffDataClear ? '' : $diffValue;
                             }
                         }
                     }
                 }
             }
         }
     }
 }
 /**
  * Constructor:
  * Initializes a lot of variables, setting JavaScript functions in header etc.
  *
  * @return	void
  */
 function init()
 {
     global $BE_USER, $BACK_PATH, $LANG, $TYPO3_CONF_VARS;
     // Main GPvars:
     $this->siteUrl = t3lib_div::getIndpEnv('TYPO3_SITE_URL');
     $this->act = t3lib_div::_GP('act');
     $this->expandPage = t3lib_div::_GP('expandPage');
     $this->expandFolder = t3lib_div::_GP('expandFolder');
     $this->pointer = t3lib_div::_GP('pointer');
     $this->P = t3lib_div::_GP('P');
     $this->PM = t3lib_div::_GP('PM');
     // Find RTE parameters
     $this->bparams = t3lib_div::_GP('bparams');
     $this->contentTypo3Language = t3lib_div::_GP('contentTypo3Language');
     $this->contentTypo3Charset = t3lib_div::_GP('contentTypo3Charset');
     $this->editorNo = t3lib_div::_GP('editorNo');
     $this->RTEtsConfigParams = t3lib_div::_GP('RTEtsConfigParams');
     $pArr = explode('|', $this->bparams);
     $pRteArr = explode(':', $pArr[1]);
     $this->editorNo = $this->editorNo ? $this->editorNo : $pRteArr[0];
     $this->contentTypo3Language = $this->contentTypo3Language ? $this->contentTypo3Language : $pRteArr[1];
     $this->contentTypo3Charset = $this->contentTypo3Charset ? $this->contentTypo3Charset : $pRteArr[2];
     $this->RTEtsConfigParams = $this->RTEtsConfigParams ? $this->RTEtsConfigParams : $pArr[2];
     // Find "mode"
     $this->mode = t3lib_div::_GP('mode');
     if (!$this->mode) {
         $this->mode = 'rte';
     }
     // init fileProcessor
     $this->fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
     $this->fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
     // init hook objects:
     $this->hookObjects = array();
     if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.browse_links.php']['browseLinksHook'])) {
         foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.browse_links.php']['browseLinksHook'] as $classData) {
             $processObject = t3lib_div::getUserObj($classData);
             if (!$processObject instanceof t3lib_browseLinksHook) {
                 throw new UnexpectedValueException('$processObject must implement interface t3lib_browseLinksHook', 1195115652);
             }
             $parameters = array();
             $processObject->init($this, $parameters);
             $this->hookObjects[] = $processObject;
         }
     }
     // Site URL
     $this->siteURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL');
     // Current site url
     // the script to link to
     $this->thisScript = t3lib_div::getIndpEnv('SCRIPT_NAME');
     // CurrentUrl - the current link url must be passed around if it exists
     if ($this->mode == 'wizard') {
         $currentLinkParts = t3lib_div::trimExplode(' ', $this->P['currentValue']);
         $this->curUrlArray = array('target' => $currentLinkParts[1]);
         $this->curUrlInfo = $this->parseCurUrl($this->siteURL . '?id=' . $currentLinkParts[0], $this->siteURL);
     } else {
         $this->curUrlArray = t3lib_div::_GP('curUrl');
         if ($this->curUrlArray['all']) {
             $this->curUrlArray = t3lib_div::get_tag_attributes($this->curUrlArray['all']);
         }
         $this->curUrlInfo = $this->parseCurUrl($this->curUrlArray['href'], $this->siteURL);
     }
     // Determine nature of current url:
     $this->act = t3lib_div::_GP('act');
     if (!$this->act) {
         $this->act = $this->curUrlInfo['act'];
     }
     // Initializing the titlevalue
     $this->setTitle = $LANG->csConvObj->conv($this->curUrlArray['title'], 'utf-8', $LANG->charSet);
     // Rich Text Editor specific configuration:
     $addPassOnParams = '';
     $classSelected = array();
     if ((string) $this->mode == 'rte') {
         $RTEtsConfigParts = explode(':', $this->RTEtsConfigParams);
         $addPassOnParams .= '&RTEtsConfigParams=' . rawurlencode($this->RTEtsConfigParams);
         $addPassOnParams .= $this->contentTypo3Language ? '&contentTypo3Language=' . rawurlencode($this->contentTypo3Language) : '';
         $addPassOnParams .= $this->contentTypo3Charset ? '&contentTypo3Charset=' . rawurlencode($this->contentTypo3Charset) : '';
         $RTEsetup = $BE_USER->getTSConfig('RTE', t3lib_BEfunc::getPagesTSconfig($RTEtsConfigParts[5]));
         $this->thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup['properties'], $RTEtsConfigParts[0], $RTEtsConfigParts[2], $RTEtsConfigParts[4]);
         if (is_array($this->thisConfig['buttons.']) && is_array($this->thisConfig['buttons.']['link.'])) {
             $this->buttonConfig = $this->thisConfig['buttons.']['link.'];
         }
         if ($this->thisConfig['classesAnchor'] || $this->thisConfig['classesLinks']) {
             $this->setClass = $this->curUrlArray['class'];
             if ($this->thisConfig['classesAnchor']) {
                 $classesAnchorArray = t3lib_div::trimExplode(',', $this->thisConfig['classesAnchor'], 1);
             } else {
                 $classesAnchorArray = t3lib_div::trimExplode(',', $this->thisConfig['classesLinks'], 1);
             }
             $anchorTypes = array('page', 'url', 'file', 'mail', 'spec');
             $classesAnchor = array();
             $classesAnchor['all'] = array();
             if (is_array($RTEsetup['properties']['classesAnchor.'])) {
                 foreach ($RTEsetup['properties']['classesAnchor.'] as $label => $conf) {
                     if (in_array($conf['class'], $classesAnchorArray)) {
                         $classesAnchor['all'][] = $conf['class'];
                         if (in_array($conf['type'], $anchorTypes)) {
                             $classesAnchor[$conf['type']][] = $conf['class'];
                             if (is_array($this->thisConfig['classesAnchor.']) && is_array($this->thisConfig['classesAnchor.']['default.']) && $this->thisConfig['classesAnchor.']['default.'][$conf['type']] == $conf['class']) {
                                 $this->classesAnchorDefault[$conf['type']] = $conf['class'];
                                 if ($conf['titleText']) {
                                     $this->classesAnchorDefaultTitle[$conf['type']] = $this->getLLContent(trim($conf['titleText']));
                                 }
                                 if ($conf['target']) {
                                     $this->classesAnchorDefaultTarget[$conf['type']] = trim($conf['target']);
                                 }
                             }
                         }
                     }
                 }
             }
             foreach ($anchorTypes as $anchorType) {
                 foreach ($classesAnchorArray as $class) {
                     if (!in_array($class, $classesAnchor['all']) || in_array($class, $classesAnchor['all']) && is_array($classesAnchor[$anchorType]) && in_array($class, $classesAnchor[$anchorType])) {
                         $selected = '';
                         if ($this->setClass == $class || !$this->setClass && $this->classesAnchorDefault[$anchorType] == $class) {
                             $selected = 'selected="selected"';
                             $classSelected[$anchorType] = true;
                         }
                         $classLabel = is_array($RTEsetup['properties']['classes.']) && is_array($RTEsetup['properties']['classes.'][$class . '.']) && $RTEsetup['properties']['classes.'][$class . '.']['name'] ? $this->getPageConfigLabel($RTEsetup['properties']['classes.'][$class . '.']['name'], 0) : $class;
                         $classStyle = is_array($RTEsetup['properties']['classes.']) && is_array($RTEsetup['properties']['classes.'][$class . '.']) && $RTEsetup['properties']['classes.'][$class . '.']['value'] ? $RTEsetup['properties']['classes.'][$class . '.']['value'] : '';
                         $this->classesAnchorJSOptions[$anchorType] .= '<option ' . $selected . ' value="' . $class . '"' . ($classStyle ? ' style="' . $classStyle . '"' : '') . '>' . $classLabel . '</option>';
                     }
                 }
                 if ($this->classesAnchorJSOptions[$anchorType]) {
                     $selected = '';
                     if (!$this->setClass && !$this->classesAnchorDefault[$anchorType]) {
                         $selected = 'selected="selected"';
                     }
                     $this->classesAnchorJSOptions[$anchorType] = '<option ' . $selected . ' value=""></option>' . $this->classesAnchorJSOptions[$anchorType];
                 }
             }
         }
     }
     // Initializing the target value (RTE)
     // Unset the target if it is set to a value different than default and if no class is selected and the target field is not displayed
     // In other words, do not forward the target if we changed tab and the target field is not displayed
     $this->setTarget = isset($this->curUrlArray['target']) && !($this->curUrlArray['target'] != $this->thisConfig['defaultLinkTarget'] && !$classSelected[$this->act] && is_array($this->buttonConfig['targetSelector.']) && $this->buttonConfig['targetSelector.']['disabled'] && is_array($this->buttonConfig['popupSelector.']) && $this->buttonConfig['popupSelector.']['disabled']) ? $this->curUrlArray['target'] : '';
     if ($this->thisConfig['defaultLinkTarget'] && !isset($this->curUrlArray['target'])) {
         $this->setTarget = $this->thisConfig['defaultLinkTarget'];
     }
     // init the DAM object
     $this->initDAM();
     $this->getModSettings();
     $this->processParams();
     // Creating backend template object:
     $this->doc = t3lib_div::makeInstance('template');
     $this->doc->backPath = $BACK_PATH;
 }
 /**
  * Checking if the RTE is available/enabled for a certain table/field and if so, it returns true.
  * Used to determine if the RTE button should be displayed.
  *
  * @param	string		Table name
  * @param	array		Record row (needed, if there are RTE dependencies based on other fields in the record)
  * @param	string		Field name
  * @return	boolean		Returns true if the rich text editor would be enabled/available for the field name specified.
  */
 function isRTEforField($table, $row, $field)
 {
     $specConf = $this->getSpecConfForField($table, $row, $field);
     $p = t3lib_BEfunc::getSpecConfParametersFromArray($specConf['rte_transform']['parameters']);
     if (isset($specConf['richtext']) && (!$p['flag'] || !$row[$p['flag']])) {
         t3lib_BEfunc::fixVersioningPid($table, $row);
         list($tscPID, $thePidValue) = t3lib_BEfunc::getTSCpid($table, $row['uid'], $row['pid']);
         if ($thePidValue >= 0) {
             // If the pid-value is not negative (that is, a pid could NOT be fetched)
             $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE', t3lib_BEfunc::getPagesTSconfig($tscPID));
             $RTEtypeVal = t3lib_BEfunc::getTCAtypeValue($table, $row);
             $thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup['properties'], $table, $field, $RTEtypeVal);
             if (!$thisConfig['disabled']) {
                 return TRUE;
             }
         }
     }
     return FALSE;
 }
    /**
     * Constructor:
     * Initializes a lot of variables, setting JavaScript functions in header etc.
     *
     * @return	void
     */
    function init()
    {
        global $BE_USER, $BACK_PATH;
        // Main GPvars:
        $this->pointer = t3lib_div::_GP('pointer');
        $this->bparams = t3lib_div::_GP('bparams');
        $this->P = t3lib_div::_GP('P');
        $this->RTEtsConfigParams = t3lib_div::_GP('RTEtsConfigParams');
        $this->expandPage = t3lib_div::_GP('expandPage');
        $this->expandFolder = t3lib_div::_GP('expandFolder');
        $this->PM = t3lib_div::_GP('PM');
        // Find "mode"
        $this->mode = t3lib_div::_GP('mode');
        if (!$this->mode) {
            $this->mode = 'rte';
        }
        // Creating backend template object:
        $this->doc = t3lib_div::makeInstance('template');
        $this->doc->backPath = $GLOBALS['BACK_PATH'];
        // Load the Prototype library and browse_links.js
        $this->doc->getPageRenderer()->loadPrototype();
        $this->doc->loadJavascriptLib('js/browse_links.js');
        // init hook objects:
        $this->hookObjects = array();
        if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['browseLinksHook'])) {
            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['browseLinksHook'] as $classData) {
                $processObject = t3lib_div::getUserObj($classData);
                if (!$processObject instanceof t3lib_browseLinksHook) {
                    throw new UnexpectedValueException('$processObject must implement interface t3lib_browseLinksHook', 1195039394);
                }
                $parameters = array();
                $processObject->init($this, $parameters);
                $this->hookObjects[] = $processObject;
            }
        }
        // Site URL
        $this->siteURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL');
        // Current site url
        // the script to link to
        $this->thisScript = t3lib_div::getIndpEnv('SCRIPT_NAME');
        // init fileProcessor
        $this->fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
        $this->fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
        // CurrentUrl - the current link url must be passed around if it exists
        if ($this->mode == 'wizard') {
            $currentLinkParts = t3lib_div::unQuoteFilenames($this->P['currentValue'], TRUE);
            $initialCurUrlArray = array('href' => $currentLinkParts[0], 'target' => $currentLinkParts[1], 'class' => $currentLinkParts[2], 'title' => $currentLinkParts[3]);
            $this->curUrlArray = is_array(t3lib_div::_GP('curUrl')) ? array_merge($initialCurUrlArray, t3lib_div::_GP('curUrl')) : $initialCurUrlArray;
            $this->curUrlInfo = $this->parseCurUrl($this->siteURL . '?id=' . $this->curUrlArray['href'], $this->siteURL);
            if ($this->curUrlInfo['pageid'] == 0 && $this->curUrlArray['href']) {
                // pageid == 0 means that this is not an internal (page) link
                if (file_exists(PATH_site . rawurldecode($this->curUrlArray['href']))) {
                    // check if this is a link to a file
                    if (t3lib_div::isFirstPartOfStr($this->curUrlArray['href'], PATH_site)) {
                        $currentLinkParts[0] = substr($this->curUrlArray['href'], strlen(PATH_site));
                    }
                    $this->curUrlInfo = $this->parseCurUrl($this->siteURL . $this->curUrlArray['href'], $this->siteURL);
                } elseif (strstr($this->curUrlArray['href'], '@')) {
                    // check for email link
                    if (t3lib_div::isFirstPartOfStr($this->curUrlArray['href'], 'mailto:')) {
                        $currentLinkParts[0] = substr($this->curUrlArray['href'], 7);
                    }
                    $this->curUrlInfo = $this->parseCurUrl('mailto:' . $this->curUrlArray['href'], $this->siteURL);
                } else {
                    // nothing of the above. this is an external link
                    if (strpos($this->curUrlArray['href'], '://') === false) {
                        $currentLinkParts[0] = 'http://' . $this->curUrlArray['href'];
                    }
                    $this->curUrlInfo = $this->parseCurUrl($currentLinkParts[0], $this->siteURL);
                }
            } elseif (!$this->curUrlArray['href']) {
                $this->curUrlInfo = array();
                $this->act = 'page';
            } else {
                $this->curUrlInfo = $this->parseCurUrl($this->siteURL . '?id=' . $this->curUrlArray['href'], $this->siteURL);
            }
        } else {
            $this->curUrlArray = t3lib_div::_GP('curUrl');
            if ($this->curUrlArray['all']) {
                $this->curUrlArray = t3lib_div::get_tag_attributes($this->curUrlArray['all']);
            }
            $this->curUrlInfo = $this->parseCurUrl($this->curUrlArray['href'], $this->siteURL);
        }
        // Determine nature of current url:
        $this->act = t3lib_div::_GP('act');
        if (!$this->act) {
            $this->act = $this->curUrlInfo['act'];
        }
        // Rich Text Editor specific configuration:
        $addPassOnParams = '';
        if ((string) $this->mode == 'rte') {
            $RTEtsConfigParts = explode(':', $this->RTEtsConfigParams);
            $addPassOnParams .= '&RTEtsConfigParams=' . rawurlencode($this->RTEtsConfigParams);
            $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE', t3lib_BEfunc::getPagesTSconfig($RTEtsConfigParts[5]));
            $this->thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup['properties'], $RTEtsConfigParts[0], $RTEtsConfigParts[2], $RTEtsConfigParts[4]);
        }
        // Initializing the target value (RTE)
        $this->setTarget = $this->curUrlArray['target'] != '-' ? $this->curUrlArray['target'] : '';
        if ($this->thisConfig['defaultLinkTarget'] && !isset($this->curUrlArray['target'])) {
            $this->setTarget = $this->thisConfig['defaultLinkTarget'];
        }
        // Initializing the class value (RTE)
        $this->setClass = $this->curUrlArray['class'] != '-' ? $this->curUrlArray['class'] : '';
        // Initializing the title value (RTE)
        $this->setTitle = $this->curUrlArray['title'] != '-' ? $this->curUrlArray['title'] : '';
        // BEGIN accumulation of header JavaScript:
        $JScode = '
				// This JavaScript is primarily for RTE/Link. jumpToUrl is used in the other cases as well...
			var add_href="' . ($this->curUrlArray['href'] ? '&curUrl[href]=' . rawurlencode($this->curUrlArray['href']) : '') . '";
			var add_target="' . ($this->setTarget ? '&curUrl[target]=' . rawurlencode($this->setTarget) : '') . '";
			var add_class="' . ($this->setClass ? '&curUrl[class]=' . rawurlencode($this->setClass) : '') . '";
			var add_title="' . ($this->setTitle ? '&curUrl[title]=' . rawurlencode($this->setTitle) : '') . '";
			var add_params="' . ($this->bparams ? '&bparams=' . rawurlencode($this->bparams) : '') . '";

			var cur_href="' . ($this->curUrlArray['href'] ? $this->curUrlArray['href'] : '') . '";
			var cur_target="' . ($this->setTarget ? $this->setTarget : '') . '";
			var cur_class = "' . ($this->setClass ? $this->setClass : '-') . '";
			var cur_title="' . ($this->setTitle ? $this->setTitle : '') . '";

			function browse_links_setTarget(target)	{	//
				cur_target=target;
				add_target="&curUrl[target]="+escape(target);
			}
			function browse_links_setClass(cssClass) {   //
				cur_class = cssClass;
				add_class = "&curUrl[class]=" + escape(cssClass);
			}
			function browse_links_setTitle(title)	{	//
				cur_title=title;
				add_title="&curUrl[title]="+escape(title);
			}
			function browse_links_setValue(value) {	//
				cur_href=value;
				add_href="&curUrl[href]="+value;
			}
		';
        if ($this->mode == 'wizard') {
            // Functions used, if the link selector is in wizard mode (= TCEforms fields)
            unset($this->P['fieldChangeFunc']['alert']);
            $update = '';
            foreach ($this->P['fieldChangeFunc'] as $k => $v) {
                $update .= '
				window.opener.' . $v;
            }
            $P2 = array();
            $P2['itemName'] = $this->P['itemName'];
            $P2['formName'] = $this->P['formName'];
            $P2['fieldChangeFunc'] = $this->P['fieldChangeFunc'];
            $P2['params']['allowedExtensions'] = $this->P['params']['allowedExtensions'];
            $P2['params']['blindLinkOptions'] = $this->P['params']['blindLinkOptions'];
            $addPassOnParams .= t3lib_div::implodeArrayForUrl('P', $P2);
            $JScode .= '
				function link_typo3Page(id,anchor)	{	//
					updateValueInMainForm(id + (anchor ? anchor : ""));
					close();
					return false;
				}
				function link_folder(folder)	{	//
					updateValueInMainForm(folder);
					close();
					return false;
				}
				function link_current()	{	//
					if (cur_href!="http://" && cur_href!="mailto:")	{
						returnBeforeCleaned = cur_href;
						if (returnBeforeCleaned.substr(0, 7) == "http://") {
							returnToMainFormValue = returnBeforeCleaned.substr(7);
						} else if (returnBeforeCleaned.substr(0, 7) == "mailto:") {
							if (returnBeforeCleaned.substr(0, 14) == "mailto:mailto:") {
								returnToMainFormValue = returnBeforeCleaned.substr(14);
							} else {
								returnToMainFormValue = returnBeforeCleaned.substr(7);
							}
						} else {
							returnToMainFormValue = returnBeforeCleaned;
						}
						updateValueInMainForm(returnToMainFormValue);
						close();
					}
					return false;
				}
				function checkReference()	{	//
					if (window.opener && window.opener.document && window.opener.document.' . $this->P['formName'] . ' && window.opener.document.' . $this->P['formName'] . '["' . $this->P['itemName'] . '"] )	{
						return window.opener.document.' . $this->P['formName'] . '["' . $this->P['itemName'] . '"];
					} else {
						close();
					}
				}
				function updateValueInMainForm(input)	{	//
					var field = checkReference();
					if (field)	{
						if (cur_target == "" && (cur_title != "" || cur_class != "-")) {
							cur_target = "-";
						}
						if (cur_title == "" && cur_class == "-") {
							cur_class = "";
						}
						cur_class = cur_class.replace(/[\'\\"]/g, "");
						if (cur_class.indexOf(" ") != -1) {
							cur_class = "\\"" + cur_class + "\\"";
						}
						cur_title = cur_title.replace(/(^\\")|(\\"$)/g, "");
						if (cur_title.indexOf(" ") != -1) {
							cur_title = "\\"" + cur_title + "\\"";
						}
						input = input + " " + cur_target + " " + cur_class + " " + cur_title;
						field.value = input;
						' . $update . '
					}
				}
			';
        } else {
            // Functions used, if the link selector is in RTE mode:
            $JScode .= '
				function link_typo3Page(id,anchor)	{	//
					var theLink = \'' . $this->siteURL . '?id=\'+id+(anchor?anchor:"");
					self.parent.parent.renderPopup_addLink(theLink, cur_target, cur_class, cur_title);
					return false;
				}
				function link_folder(folder)	{	//
					var theLink = \'' . $this->siteURL . '\'+folder;
					self.parent.parent.renderPopup_addLink(theLink, cur_target, cur_class, cur_title);
					return false;
				}
				function link_spec(theLink)	{	//
					self.parent.parent.renderPopup_addLink(theLink, cur_target, cur_class, cur_title);
					return false;
				}
				function link_current()	{	//
					if (cur_href!="http://" && cur_href!="mailto:")	{
						self.parent.parent.renderPopup_addLink(cur_href, cur_target, cur_class, cur_title);
					}
					return false;
				}
			';
        }
        // General "jumpToUrl" function:
        $JScode .= '
			function jumpToUrl(URL,anchor)	{	//
				var add_act = URL.indexOf("act=")==-1 ? "&act=' . $this->act . '" : "";
				var add_mode = URL.indexOf("mode=")==-1 ? "&mode=' . $this->mode . '" : "";
				var theLocation = URL + add_act + add_mode + add_href + add_target + add_class + add_title + add_params' . ($addPassOnParams ? '+"' . $addPassOnParams . '"' : '') . '+(anchor?anchor:"");
				window.location.href = theLocation;
				return false;
			}
		';
        /**
         * Splits parts of $this->bparams
         * @see $bparams
         */
        $pArr = explode('|', $this->bparams);
        // This is JavaScript especially for the TBE Element Browser!
        $formFieldName = 'data[' . $pArr[0] . '][' . $pArr[1] . '][' . $pArr[2] . ']';
        // insertElement - Call check function (e.g. for uniqueness handling):
        if ($pArr[4] && $pArr[5]) {
            $JScodeCheck = '
					// Call a check function in the opener window (e.g. for uniqueness handling):
				if (parent.window.opener) {
					var res = parent.window.opener.' . $pArr[5] . '("' . addslashes($pArr[4]) . '",table,uid,type);
					if (!res.passed) {
						if (res.message) alert(res.message);
						performAction = false;
					}
				} else {
					alert("Error - reference to main window is not set properly!");
					parent.close();
				}
			';
        }
        // insertElement - Call helper function:
        if ($pArr[4] && $pArr[6]) {
            $JScodeHelper = '
						// Call helper function to manage data in the opener window:
					if (parent.window.opener) {
						parent.window.opener.' . $pArr[6] . '("' . addslashes($pArr[4]) . '",table,uid,type,"' . addslashes($pArr[0]) . '");
					} else {
						alert("Error - reference to main window is not set properly!");
						parent.close();
					}
			';
        }
        // insertElement - perform action commands:
        if ($pArr[4] && $pArr[7]) {
            // Call user defined action function:
            $JScodeAction = '
					if (parent.window.opener) {
						parent.window.opener.' . $pArr[7] . '("' . addslashes($pArr[4]) . '",table,uid,type);
						focusOpenerAndClose(close);
					} else {
						alert("Error - reference to main window is not set properly!");
						parent.close();
					}
			';
        } else {
            if ($pArr[0] && !$pArr[1] && !$pArr[2]) {
                $JScodeAction = '
					addElement(filename,table+"_"+uid,fp,close);
			';
            } else {
                $JScodeAction = '
					if (setReferences()) {
						parent.window.opener.group_change("add","' . $pArr[0] . '","' . $pArr[1] . '","' . $pArr[2] . '",elRef,targetDoc);
					} else {
						alert("Error - reference to main window is not set properly!");
					}
					focusOpenerAndClose(close);
			';
            }
        }
        $JScode .= '
			var elRef="";
			var targetDoc="";

			function launchView(url)	{	//
				var thePreviewWindow="";
				thePreviewWindow = window.open("' . $BACK_PATH . 'show_item.php?table="+url,"ShowItem","height=300,width=410,status=0,menubar=0,resizable=0,location=0,directories=0,scrollbars=1,toolbar=0");
				if (thePreviewWindow && thePreviewWindow.focus)	{
					thePreviewWindow.focus();
				}
			}
			function setReferences()	{	//
				if (parent.window.opener && parent.window.opener.content && parent.window.opener.content.document.editform && parent.window.opener.content.document.editform["' . $formFieldName . '"]) {
					targetDoc = parent.window.opener.content.document;
					elRef = targetDoc.editform["' . $formFieldName . '"];
					return true;
				} else {
					return false;
				}
			}
			function insertElement(table, uid, type, filename,fp,filetype,imagefile,action, close)	{	//
				var performAction = true;
				' . $JScodeCheck . '
					// Call performing function and finish this action:
				if (performAction) {
						' . $JScodeHelper . $JScodeAction . '
				}
				return false;
			}
			function addElement(elName,elValue,altElValue,close)	{	//
				if (parent.window.opener && parent.window.opener.setFormValueFromBrowseWin)	{
					parent.window.opener.setFormValueFromBrowseWin("' . $pArr[0] . '",altElValue?altElValue:elValue,elName);
					focusOpenerAndClose(close);
				} else {
					alert("Error - reference to main window is not set properly!");
					parent.close();
				}
			}
			function focusOpenerAndClose(close)	{	//
				BrowseLinks.focusOpenerAndClose(close);
			}
		';
        // Finally, add the accumulated JavaScript to the template object:
        $this->doc->JScode .= $this->doc->wrapScriptTags($JScode);
        // Debugging:
        if (FALSE) {
            debug(array('pointer' => $this->pointer, 'act' => $this->act, 'mode' => $this->mode, 'curUrlInfo' => $this->curUrlInfo, 'curUrlArray' => $this->curUrlArray, 'P' => $this->P, 'bparams' => $this->bparams, 'RTEtsConfigParams' => $this->RTEtsConfigParams, 'expandPage' => $this->expandPage, 'expandFolder' => $this->expandFolder, 'PM' => $this->PM), 'Internal variables of Script Class:');
        }
    }
    /**
     * Generation of TCEform elements of the type "text"
     * This will render a <textarea> OR RTE area form field, possibly with various control/validation features
     *
     * @param	string		The table name of the record
     * @param	string		The field name which this element is supposed to edit
     * @param	array		The record data array where the value(s) for the field can be found
     * @param	array		An array with additional configuration options.
     * @return	string		The HTML code for the TCEform field
     */
    function getSingleField_typeText($table, $field, $row, &$PA)
    {
        // Init config:
        $config = $PA['fieldConf']['config'];
        $evalList = t3lib_div::trimExplode(',', $config['eval'], 1);
        if ($this->renderReadonly || $config['readOnly']) {
            return $this->getSingleField_typeNone_render($config, $PA['itemFormElValue']);
        }
        // Setting columns number:
        $cols = t3lib_div::intInRange($config['cols'] ? $config['cols'] : 30, 5, $this->maxTextareaWidth);
        // Setting number of rows:
        $origRows = $rows = t3lib_div::intInRange($config['rows'] ? $config['rows'] : 5, 1, 20);
        if (strlen($PA['itemFormElValue']) > $this->charsPerRow * 2) {
            $cols = $this->maxTextareaWidth;
            $rows = t3lib_div::intInRange(round(strlen($PA['itemFormElValue']) / $this->charsPerRow), count(explode(LF, $PA['itemFormElValue'])), 20);
            if ($rows < $origRows) {
                $rows = $origRows;
            }
        }
        if (in_array('required', $evalList)) {
            $this->requiredFields[$table . '_' . $row['uid'] . '_' . $field] = $PA['itemFormElName'];
        }
        // Init RTE vars:
        $RTEwasLoaded = 0;
        // Set true, if the RTE is loaded; If not a normal textarea is shown.
        $RTEwouldHaveBeenLoaded = 0;
        // Set true, if the RTE would have been loaded if it wasn't for the disable-RTE flag in the bottom of the page...
        // "Extra" configuration; Returns configuration for the field based on settings found in the "types" fieldlist. Traditionally, this is where RTE configuration has been found.
        $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
        // Setting up the altItem form field, which is a hidden field containing the value
        $altItem = '<input type="hidden" name="' . htmlspecialchars($PA['itemFormElName']) . '" value="' . htmlspecialchars($PA['itemFormElValue']) . '" />';
        // If RTE is generally enabled (TYPO3_CONF_VARS and user settings)
        if ($this->RTEenabled) {
            $p = t3lib_BEfunc::getSpecConfParametersFromArray($specConf['rte_transform']['parameters']);
            if (isset($specConf['richtext']) && (!$p['flag'] || !$row[$p['flag']])) {
                // If the field is configured for RTE and if any flag-field is not set to disable it.
                t3lib_BEfunc::fixVersioningPid($table, $row);
                list($tscPID, $thePidValue) = $this->getTSCpid($table, $row['uid'], $row['pid']);
                // If the pid-value is not negative (that is, a pid could NOT be fetched)
                if ($thePidValue >= 0) {
                    $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE', t3lib_BEfunc::getPagesTSconfig($tscPID));
                    $RTEtypeVal = t3lib_BEfunc::getTCAtypeValue($table, $row);
                    $thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup['properties'], $table, $field, $RTEtypeVal);
                    if (!$thisConfig['disabled']) {
                        if (!$this->disableRTE) {
                            $this->RTEcounter++;
                            // Find alternative relative path for RTE images/links:
                            $eFile = t3lib_parsehtml_proc::evalWriteFile($specConf['static_write'], $row);
                            $RTErelPath = is_array($eFile) ? dirname($eFile['relEditFile']) : '';
                            // Get RTE object, draw form and set flag:
                            $RTEobj = t3lib_BEfunc::RTEgetObj();
                            $item = $RTEobj->drawRTE($this, $table, $field, $row, $PA, $specConf, $thisConfig, $RTEtypeVal, $RTErelPath, $thePidValue);
                            // Wizard:
                            $item = $this->renderWizards(array($item, $altItem), $config['wizards'], $table, $row, $field, $PA, $PA['itemFormElName'], $specConf, 1);
                            $RTEwasLoaded = 1;
                        } else {
                            $RTEwouldHaveBeenLoaded = 1;
                            $this->commentMessages[] = $PA['itemFormElName'] . ': RTE is disabled by the on-page RTE-flag (probably you can enable it by the check-box in the bottom of this page!)';
                        }
                    } else {
                        $this->commentMessages[] = $PA['itemFormElName'] . ': RTE is disabled by the Page TSconfig, "RTE"-key (eg. by RTE.default.disabled=0 or such)';
                    }
                } else {
                    $this->commentMessages[] = $PA['itemFormElName'] . ': PID value could NOT be fetched. Rare error, normally with new records.';
                }
            } else {
                if (!isset($specConf['richtext'])) {
                    $this->commentMessages[] = $PA['itemFormElName'] . ': RTE was not configured for this field in TCA-types';
                }
                if (!(!$p['flag'] || !$row[$p['flag']])) {
                    $this->commentMessages[] = $PA['itemFormElName'] . ': Field-flag (' . $PA['flag'] . ') has been set to disable RTE!';
                }
            }
        }
        // Display ordinary field if RTE was not loaded.
        if (!$RTEwasLoaded) {
            if ($specConf['rte_only']) {
                // Show message, if no RTE (field can only be edited with RTE!)
                $item = '<p><em>' . htmlspecialchars($this->getLL('l_noRTEfound')) . '</em></p>';
            } else {
                if ($specConf['nowrap']) {
                    $wrap = 'off';
                } else {
                    $wrap = $config['wrap'] ? $config['wrap'] : 'virtual';
                }
                $classes = array();
                if ($specConf['fixed-font']) {
                    $classes[] = 'fixed-font';
                }
                if ($specConf['enable-tab']) {
                    $classes[] = 'enable-tab';
                }
                $formWidthText = $this->formWidthText($cols, $wrap);
                // Extract class attributes from $formWidthText (otherwise it would be added twice to the output)
                $res = array();
                if (preg_match('/ class="(.+?)"/', $formWidthText, $res)) {
                    $formWidthText = str_replace(' class="' . $res[1] . '"', '', $formWidthText);
                    $classes = array_merge($classes, explode(' ', $res[1]));
                }
                if (count($classes)) {
                    $class = ' class="tceforms-textarea ' . implode(' ', $classes) . '"';
                } else {
                    $class = 'tceforms-textarea';
                }
                $evalList = t3lib_div::trimExplode(',', $config['eval'], 1);
                foreach ($evalList as $func) {
                    switch ($func) {
                        case 'required':
                            $this->registerRequiredProperty('field', $table . '_' . $row['uid'] . '_' . $field, $PA['itemFormElName']);
                            break;
                        default:
                            if (substr($func, 0, 3) == 'tx_') {
                                // Pair hook to the one in t3lib_TCEmain::checkValue_input_Eval() and t3lib_TCEmain::checkValue_text_Eval()
                                $evalObj = t3lib_div::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$func] . ':&' . $func);
                                if (is_object($evalObj) && method_exists($evalObj, 'deevaluateFieldValue')) {
                                    $_params = array('value' => $PA['itemFormElValue']);
                                    $PA['itemFormElValue'] = $evalObj->deevaluateFieldValue($_params);
                                }
                            }
                            break;
                    }
                }
                $iOnChange = implode('', $PA['fieldChangeFunc']);
                $item .= '
							<textarea id="' . uniqid('tceforms-textarea-') . '" name="' . $PA['itemFormElName'] . '"' . $formWidthText . $class . ' rows="' . $rows . '" wrap="' . $wrap . '" onchange="' . htmlspecialchars($iOnChange) . '"' . $PA['onFocus'] . '>' . t3lib_div::formatForTextarea($PA['itemFormElValue']) . '</textarea>';
                $item = $this->renderWizards(array($item, $altItem), $config['wizards'], $table, $row, $field, $PA, $PA['itemFormElName'], $specConf, $RTEwouldHaveBeenLoaded);
            }
        }
        // Return field HTML:
        return $item;
    }
 /**
  * Get the RTE configuration from Page TSConfig
  *
  * @return	array		RTE configuration array
  */
 protected function getRTEConfig()
 {
     global $BE_USER;
     $RTEtsConfigParts = explode(':', t3lib_div::_GP('RTEtsConfigParams'));
     $RTEsetup = $BE_USER->getTSConfig('RTE', t3lib_BEfunc::getPagesTSconfig($RTEtsConfigParts[5]));
     return t3lib_BEfunc::RTEsetup($RTEsetup['properties'], $RTEtsConfigParts[0], $RTEtsConfigParts[2], $RTEtsConfigParts[4]);
 }
    /**
     * Rich Text Editor (RTE) user element selector
     *
     * @param	[type]		$openKeys: ...
     * @return	[type]		...
     */
    function main_user($openKeys)
    {
        global $LANG, $BACK_PATH, $BE_USER;
        // Starting content:
        $content .= $this->doc->startPage($LANG->getLL('Insert Custom Element', 1));
        $RTEtsConfigParts = explode(':', t3lib_div::_GP('RTEtsConfigParams'));
        $RTEsetup = $BE_USER->getTSConfig('RTE', t3lib_BEfunc::getPagesTSconfig($RTEtsConfigParts[5]));
        $thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup['properties'], $RTEtsConfigParts[0], $RTEtsConfigParts[2], $RTEtsConfigParts[4]);
        if (is_array($thisConfig['userElements.'])) {
            $categories = array();
            foreach ($thisConfig['userElements.'] as $k => $value) {
                $ki = intval($k);
                $v = $thisConfig['userElements.'][$ki . '.'];
                if (substr($k, -1) == "." && is_array($v)) {
                    $subcats = array();
                    $openK = $ki;
                    if ($openKeys[$openK]) {
                        $mArray = '';
                        switch ((string) $v['load']) {
                            case 'images_from_folder':
                                $mArray = array();
                                if ($v['path'] && @is_dir(PATH_site . $v['path'])) {
                                    $files = t3lib_div::getFilesInDir(PATH_site . $v['path'], 'gif,jpg,jpeg,png', 0, '');
                                    if (is_array($files)) {
                                        $c = 0;
                                        foreach ($files as $filename) {
                                            $iInfo = @getimagesize(PATH_site . $v['path'] . $filename);
                                            $iInfo = $this->calcWH($iInfo, 50, 100);
                                            $ks = (string) (100 + $c);
                                            $mArray[$ks] = $filename;
                                            $mArray[$ks . "."] = array('content' => '<img src="' . $this->siteUrl . $v['path'] . $filename . '" />', '_icon' => '<img src="' . $this->siteUrl . $v['path'] . $filename . '" ' . $iInfo[3] . ' />', 'description' => $LANG->getLL('filesize') . ': ' . str_replace('&nbsp;', ' ', t3lib_div::formatSize(@filesize(PATH_site . $v['path'] . $filename))) . ', ' . $LANG->getLL('pixels', 1) . ': ' . $iInfo[0] . 'x' . $iInfo[1]);
                                            $c++;
                                        }
                                    }
                                }
                                break;
                        }
                        if (is_array($mArray)) {
                            if ($v['merge']) {
                                $v = t3lib_div::array_merge_recursive_overrule($mArray, $v);
                            } else {
                                $v = $mArray;
                            }
                        }
                        foreach ($v as $k2 => $dummyValue) {
                            $k2i = intval($k2);
                            if (substr($k2, -1) == '.' && is_array($v[$k2i . '.'])) {
                                $title = trim($v[$k2i]);
                                if (!$title) {
                                    $title = '[' . $LANG->getLL('noTitle', 1) . ']';
                                } else {
                                    $title = $LANG->sL($title, 1);
                                }
                                $description = $LANG->sL($v[$k2i . '.']['description'], 1) . '<br />';
                                if (!$v[$k2i . '.']['dontInsertSiteUrl']) {
                                    $v[$k2i . '.']['content'] = str_replace('###_URL###', $this->siteUrl, $v[$k2i . '.']['content']);
                                }
                                $logo = $v[$k2i . '.']['_icon'] ? $v[$k2i . '.']['_icon'] : '';
                                $onClickEvent = '';
                                switch ((string) $v[$k2i . '.']['mode']) {
                                    case 'wrap':
                                        $wrap = explode('|', $v[$k2i . '.']['content']);
                                        $onClickEvent = 'wrapHTML(' . $LANG->JScharCode($wrap[0]) . ',' . $LANG->JScharCode($wrap[1]) . ',false);';
                                        break;
                                    case 'processor':
                                        $script = trim($v[$k2i . '.']['submitToScript']);
                                        if (substr($script, 0, 4) != 'http') {
                                            $script = $this->siteUrl . $script;
                                        }
                                        if ($script) {
                                            $onClickEvent = 'processSelection(' . $LANG->JScharCode($script) . ');';
                                        }
                                        break;
                                    case 'insert':
                                    default:
                                        $onClickEvent = 'insertHTML(' . $LANG->JScharCode($v[$k2i . '.']['content']) . ');';
                                        break;
                                }
                                $A = array('<a href="#" onClick="' . $onClickEvent . 'return false;">', '</a>');
                                $subcats[$k2i] = '<tr>
									<td><img src="clear.gif" width="18" height="1" /></td>
									<td class="bgColor4" valign="top">' . $A[0] . $logo . $A[1] . '</td>
									<td class="bgColor4" valign="top">' . $A[0] . '<strong>' . $title . '</strong><br />' . $description . $A[1] . '</td>
								</tr>';
                            }
                        }
                        ksort($subcats);
                    }
                    $categories[$ki] = implode('', $subcats);
                }
            }
            ksort($categories);
            # Render menu of the items:
            $lines = array();
            foreach ($categories as $k => $v) {
                $title = trim($thisConfig['userElements.'][$k]);
                $openK = $k;
                if (!$title) {
                    $title = '[' . $LANG->getLL('noTitle', 1) . ']';
                } else {
                    $title = $LANG->sL($title, 1);
                }
                //$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>';
                $lines[] = '<tr><td colspan="3" class="bgColor5"><a href="#" title="' . $LANG->getLL('expand', 1) . '" onClick="jumpToUrl(\'?OC_key=' . ($openKeys[$openK] ? 'C|' : 'O|') . $openK . '\');return false;"><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>';
                $lines[] = $v;
            }
            $content .= '<table border="0" cellpadding="1" cellspacing="1">' . implode('', $lines) . '</table>';
        }
        $content .= $this->doc->endPage();
        return $content;
    }
 /**
  * Pre-initialization - the point is to do some processing before the actual init() function; In between we might have some magic-image processing going on...
  *
  * @return	[type]		...
  */
 function preinit()
 {
     global $BE_USER;
     // Current site url:
     $this->siteUrl = t3lib_div::getIndpEnv("TYPO3_SITE_URL");
     // Determine nature of current url:
     $this->act = t3lib_div::_GP("act");
     $this->modData = $BE_USER->getModuleData("rte_select_image.php", "ses");
     if ($this->act != "image") {
         if (isset($this->act)) {
             $this->modData["act"] = $this->act;
             $BE_USER->pushModuleData("rte_select_image.php", $this->modData);
         } else {
             $this->act = $this->modData["act"];
         }
     }
     $expandPage = t3lib_div::_GP("expandFolder");
     if (isset($expandPage)) {
         $this->modData["expandFolder"] = $expandPage;
         $BE_USER->pushModuleData("rte_select_image.php", $this->modData);
     } else {
         t3lib_div::_GETset($this->modData["expandFolder"], 'expandFolder');
     }
     if (!$this->act) {
         $this->act = "magic";
     }
     $RTEtsConfigParts = explode(":", t3lib_div::_GP("RTEtsConfigParams"));
     if (count($RTEtsConfigParts) < 2) {
         die("Error: The GET parameter 'RTEtsConfigParams' was missing. Close the window.");
     }
     $RTEsetup = $GLOBALS["BE_USER"]->getTSConfig("RTE", t3lib_BEfunc::getPagesTSconfig($RTEtsConfigParts[5]));
     $this->thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup["properties"], $RTEtsConfigParts[0], $RTEtsConfigParts[2], $RTEtsConfigParts[4]);
     $this->imgPath = $RTEtsConfigParts[6];
     $this->allowedItems = array_diff(explode(",", "magic,plain,upload"), t3lib_div::trimExplode(",", $this->thisConfig["blindImageOptions"], 1));
     reset($this->allowedItems);
     if (!in_array($this->act, $this->allowedItems)) {
         $this->act = current($this->allowedItems);
     }
 }
Esempio n. 9
0
    function init()
    {
        global $BE_USER, $BACK_PATH;
        // Main GPvars:
        $this->pointer = t3lib_div::_GP('pointer');
        $this->bparams = t3lib_div::_GP('bparams');
        $this->P = t3lib_div::_GP('P');
        $this->RTEtsConfigParams = t3lib_div::_GP('RTEtsConfigParams');
        $this->expandPage = t3lib_div::_GP('expandPage');
        $this->expandFolder = t3lib_div::_GP('expandFolder');
        $this->PM = t3lib_div::_GP('PM');
        // Find "mode"
        $this->mode = t3lib_div::_GP('mode');
        if (!$this->mode) {
            $this->mode = 'rte';
        }
        // init hook objects:
        $this->hookObjects = array();
        if (intval(phpversion()) >= 5 && TYPO3_branch > 4.1) {
            include_once 'include_php5.inc';
        } else {
            include_once 'include_php4.inc';
        }
        // Site URL
        $this->siteURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL');
        // Current site url
        // Rich Text Editor specific configuration:
        $addPassOnParams = '';
        if ((string) $this->mode == 'wizard') {
            $RTEtsConfigParts = explode(':', $this->RTEtsConfigParams);
            $addPassOnParams .= '&RTEtsConfigParams=' . rawurlencode($this->RTEtsConfigParams);
            $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE', t3lib_BEfunc::getPagesTSconfig($RTEtsConfigParts[5]));
            $this->thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup['properties'], $RTEtsConfigParts[0], $RTEtsConfigParts[2], $RTEtsConfigParts[4]);
        }
        // the script to link to
        $this->thisScript = t3lib_div::getIndpEnv('SCRIPT_NAME');
        // init fileProcessor
        $this->fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
        $this->fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
        // CurrentUrl - the current link url must be passed around if it exists
        if ($this->mode == 'wizard') {
            $currentLinkParts = t3lib_div::trimExplode(' ', $this->P['currentValue']);
            $initialCurUrlArray = array('href' => $currentLinkParts[0], 'target' => $currentLinkParts[1], 'class' => $currentLinkParts[2], 'title' => $currentLinkParts[3]);
            $this->curUrlArray = is_array(t3lib_div::_GP('curUrl')) ? array_merge($initialCurUrlArray, t3lib_div::_GP('curUrl')) : $initialCurUrlArray;
            $this->curUrlInfo = $this->parseCurUrl($this->siteURL . '?id=' . $this->curUrlArray['href'], $this->siteURL);
            if ($this->curUrlInfo['pageid'] == 0 && $this->curUrlArray['href']) {
                // pageid == 0 means that this is not an internal (page) link
                if (@file_exists(PATH_site . rawurldecode($this->curUrlArray['href']))) {
                    // check if this is a link to a file
                    if (t3lib_div::isFirstPartOfStr($this->curUrlArray['href'], PATH_site)) {
                        $currentLinkParts[0] = substr($this->curUrlArray['href'], strlen(PATH_site));
                    }
                    $this->curUrlInfo = $this->parseCurUrl($this->siteURL . $this->curUrlArray['href'], $this->siteURL);
                } elseif (strstr($this->curUrlArray['href'], '@')) {
                    // check for email link
                    if (t3lib_div::isFirstPartOfStr($this->curUrlArray['href'], 'mailto:')) {
                        $currentLinkParts[0] = substr($this->curUrlArray['href'], 7);
                    }
                    $this->curUrlInfo = $this->parseCurUrl('mailto:' . $currentLinkParts[0], $this->siteURL);
                } elseif (strstr($this->curUrlArray['href'], 'record:')) {
                    $handel = t3lib_div::trimExplode(':', $this->curUrlArray['href']);
                    if (is_array($this->thisConfig['linkhandler.'][$handel[1] . '.'])) {
                        $row = t3lib_BEfunc::getRecord($handel[1], $handel[2]);
                        if (is_array($this->thisConfig['linkhandler.'][$handel[1] . '.'][$row['pid'] . '.'])) {
                            $this->curUrlInfo['info'] = $row['pid'];
                            $this->curUrlInfo['pageid'] = $this->curUrlInfo['info'];
                            $this->expandPage();
                        } else {
                            $this->curUrlInfo = array();
                        }
                        $this->curUrlInfo['cElement'] = $handel[2];
                    } else {
                        echo "in PageTSconfig you should define RTE.default.linkhandler." . $handel[1];
                        echo "<br /> Example Config tt_news:";
                        echo "<pre>\nRTE.default.linkhandler {\n\ttt_news {\n\t\tdefault {\n\t\t\t# instead of default you could write the id of the storage folder\n\t\t\t# id of the Single News Page\n\t\t\tparameter = 27\n\t\t\tadditionalParams = &tx_ttnews[tt_news]={field:uid}\n\t\t\tadditionalParams.insertData = 1\n\t\t\t# you need: uid, hidden, header [this is the displayed title] (use xx as header to select other properties)\n\t\t\t# you can provide: bodytext [alternative title], starttime, endtime [to display the current status]\n\t\t\tselect = uid,title as header,hidden,starttime,endtime,bodytext\n\t\t\tsorting = crdate\n\t\t}\n\t}\n}\n</pre>";
                        die;
                        //message to user; wrong config
                    }
                } else {
                    // nothing of the above. this is an external link
                    if (strpos($this->curUrlArray['href'], '://') === false) {
                        $currentLinkParts[0] = 'http://' . $this->curUrlArray['href'];
                    }
                    $this->curUrlInfo = $this->parseCurUrl($currentLinkParts[0], $this->siteURL);
                }
            } elseif (!$this->curUrlArray['href']) {
                $this->curUrlInfo = array();
                $this->act = 'page';
            } else {
                $this->curUrlInfo = $this->parseCurUrl($this->siteURL . '?id=' . $this->curUrlArray['href'], $this->siteURL);
                $this->curUrlInfo['info'] = $this->curUrlInfo['pageid'];
            }
        } else {
            $this->curUrlArray = t3lib_div::_GP('curUrl');
            if ($this->curUrlArray['all']) {
                $this->curUrlArray = t3lib_div::get_tag_attributes($this->curUrlArray['all']);
            }
            $this->curUrlInfo = $this->parseCurUrl($this->curUrlArray['href'], $this->siteURL);
        }
        // Determine nature of current url:
        $this->act = t3lib_div::_GP('act');
        if (!$this->act) {
            $this->act = $this->curUrlInfo['act'];
        }
        // Initializing the target value (RTE)
        $this->setTarget = $this->curUrlArray['target'];
        if ($this->thisConfig['defaultLinkTarget'] && !isset($this->curUrlArray['target'])) {
            $this->setTarget = $this->thisConfig['defaultLinkTarget'];
        }
        // Initializing the class value (RTE)
        $this->setClass = $this->curUrlArray['class'] != '-' ? $this->curUrlArray['class'] : '';
        // Initializing the title value (RTE)
        $this->setTitle = $this->curUrlArray['title'] != '-' ? $this->curUrlArray['title'] : '';
        // Creating backend template object:
        $this->doc = t3lib_div::makeInstance('template');
        $this->doc->docType = 'xhtml_trans';
        $this->doc->backPath = $BACK_PATH;
        // BEGIN accumulation of header JavaScript:
        $JScode = '';
        $JScode .= '
				// This JavaScript is primarily for RTE/Link. jumpToUrl is used in the other cases as well...
			var add_href="' . ($this->curUrlArray['href'] ? '&curUrl[href]=' . rawurlencode($this->curUrlArray['href']) : '') . '";
			var add_target="' . ($this->setTarget ? '&curUrl[target]=' . rawurlencode($this->setTarget) : '') . '";
			var add_params="' . ($this->bparams ? '&bparams=' . rawurlencode($this->bparams) : '') . '";

			var cur_href="' . ($this->curUrlArray['href'] ? $this->curUrlArray['href'] : '') . '";
			var cur_target="' . ($this->setTarget ? $this->setTarget : '') . '";
			var bm=tinyMCEPopup.editor.selection.getBookmark();
		';
        if ($this->mode == 'wizard') {
            // Functions used, if the link selector is in wizard mode (= TCEforms fields)
            unset($this->P['fieldChangeFunc']['alert']);
            reset($this->P['fieldChangeFunc']);
            $update = '';
            while (list($k, $v) = each($this->P['fieldChangeFunc'])) {
                $update .= '
						popWin.' . $v;
            }
            $update .= '
						tinyMCEPopup.close();';
            $P2 = array();
            $P2['itemName'] = $this->P['itemName'];
            $P2['formName'] = $this->P['formName'];
            $P2['fieldChangeFunc'] = $this->P['fieldChangeFunc'];
            $P2['init'] = $this->P['init'];
            $P2['ext'] = $this->P['ext'];
            $P2['params']['allowedExtensions'] = $this->P['params']['allowedExtensions'];
            $P2['params']['blindLinkOptions'] = $this->P['params']['blindLinkOptions'];
            $addPassOnParams .= t3lib_div::implodeArrayForUrl('P', $P2);
            $JScode .= '
			  function directSetHref(value) {
					// called directly from withint the content area
					tinyMCEPopup.execCommand("mceBeginUndoLevel");
					
					var inst = tinyMCE.activeEditor;
					var elm = inst.selection.getNode();
					elm = inst.dom.getParent(elm, "A");
					// Create new anchor elements
					if (elm == null) {
						tinyMCEPopup.execCommand("CreateLink", false, "#mce_temp_url#", {skip_undo : 1});
						var elementArray = tinymce.grep(inst.dom.select("a"), function(n) {return inst.dom.getAttrib(n, "href") == "#mce_temp_url#";});
						for (var i=0; i<elementArray.length; i++)
							tinyMCE.activeEditor.dom.setAttrib(elm = elementArray[i], "href", value);
					} else
						tinyMCE.activeEditor.dom.setAttrib(elm, "href", value);
						
					// Don t move caret if selection was image
					if (elm.childNodes.length != 1 || elm.firstChild.nodeName != "IMG") {
						inst.focus();
						inst.selection.select(elm);
						inst.selection.collapse(0);
						tinyMCEPopup.storeSelection();
					}

					tinyMCEPopup.execCommand("mceEndUndoLevel");
					return true;
				}
				
				function link_insert(value,anchor)	{
					if (!anchor) anchor = "";
					var win = tinyMCEPopup.getWindowArg("window");
					if (win)
						win.document.getElementById(tinyMCEPopup.getWindowArg("input")).value = value + anchor;
					else
						directSetHref( value + anchor );
					  
			';
            //miss use bparams
            if (t3lib_div::_GP('bparams') == 'media') {
                $JScode .= '
					// for media browsers: update media preview
					win.updatePreview();
				';
            }
            $JScode .= '
					tinyMCEPopup.close(); 
					return false;
				}
				
				function record_insert(type,value) {
					var win = tinyMCEPopup.getWindowArg("window");
					if (win)
						win.document.getElementById(tinyMCEPopup.getWindowArg("input")).value = "record:" + type + ":" + value;
					else 
						directSetHref( "record:" + type + ":" + value );
					
					tinyMCEPopup.close();
					return false;
				}
				
			';
        } else {
            // Functions used, if the link selector is in RTE mode:
            $JScode .= '
			';
        }
        // General "jumpToUrl" function:
        $JScode .= '
			function jumpToUrl(URL,anchor)	{	//
				tinyMCEPopup.editor.selection.moveToBookmark(bm);
				var add_act = URL.indexOf("act=")==-1 ? "&act=' . $this->act . '" : "";
				var add_mode = URL.indexOf("mode=")==-1 ? "&mode=' . $this->mode . '" : "";
				//var theLocation = URL+add_act+add_mode+add_href+add_target+add_params' . ($addPassOnParams ? '+"' . $addPassOnParams . '"' : '') . '+(anchor?anchor:"");
				var theLocation = URL+add_act+add_mode+add_href+add_target+add_params' . ($addPassOnParams ? '+"' . $addPassOnParams . '"' : '') . ';
				document.location = theLocation;
				return false;
			}
		';
        // Finally, add the accumulated JavaScript to the template object:
        $this->doc->JScode .= '<script language="javascript" type="text/javascript" src="../res/tiny_mce/tiny_mce_popup.js"></script>';
        $this->doc->JScode .= $this->doc->wrapScriptTags($JScode);
        // Debugging:
        if (FALSE) {
            debug(array('pointer' => $this->pointer, 'act' => $this->act, 'mode' => $this->mode, 'curUrlInfo' => $this->curUrlInfo, 'curUrlArray' => $this->curUrlArray, 'P' => $this->P, 'bparams' => $this->bparams, 'RTEtsConfigParams' => $this->RTEtsConfigParams, 'expandPage' => $this->expandPage, 'expandFolder' => $this->expandFolder, 'PM' => $this->PM), 'Internal variables of Script Class:');
        }
    }
 /**
  * Rich Text Editor (RTE) html parser
  *
  * @param	[type]		$openKeys: ...
  * @return	[type]		...
  */
 function main_parse_html($openKeys)
 {
     global $BE_USER, $TYPO3_CONF_VARS;
     $editorNo = t3lib_div::_GP('editorNo');
     $html = t3lib_div::_GP('content');
     $RTEtsConfigParts = explode(':', t3lib_div::_GP('RTEtsConfigParams'));
     $RTEsetup = $BE_USER->getTSConfig('RTE', t3lib_BEfunc::getPagesTSconfig($RTEtsConfigParts[5]));
     $thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup['properties'], $RTEtsConfigParts[0], $RTEtsConfigParts[2], $RTEtsConfigParts[4]);
     $HTMLParser = t3lib_div::makeInstance('t3lib_parsehtml');
     if (is_array($thisConfig['enableWordClean.'])) {
         $HTMLparserConfig = $thisConfig['enableWordClean.']['HTMLparser.'];
         if (is_array($HTMLparserConfig)) {
             $this->keepSpanTagsWithId($HTMLparserConfig);
             $HTMLparserConfig = $HTMLParser->HTMLparserConfig($HTMLparserConfig);
         }
     }
     if (is_array($HTMLparserConfig)) {
         $html = $HTMLParser->HTMLcleaner($html, $HTMLparserConfig[0], $HTMLparserConfig[1], $HTMLparserConfig[2], $HTMLparserConfig[3]);
     }
     if (is_array($TYPO3_CONF_VARS['EXTCONF'][$this->extKey][$this->prefixId]['cleanPastedContent'])) {
         foreach ($TYPO3_CONF_VARS['EXTCONF'][$this->extKey][$this->prefixId]['cleanPastedContent'] as $classRef) {
             $hookObj = t3lib_div::getUserObj($classRef);
             if (method_exists($hookObj, 'cleanPastedContent_afterCleanWord')) {
                 $html = $hookObj->cleanPastedContent_afterCleanWord($html, $thisConfig);
             }
         }
     }
     return $html;
 }
 /**
  * Initialisation
  *
  * @return	[type]		...
  */
 function init()
 {
     global $BE_USER, $BACK_PATH, $TYPO3_CONF_VARS;
     // Main GPvars:
     $this->siteUrl = t3lib_div::getIndpEnv('TYPO3_SITE_URL');
     $this->act = t3lib_div::_GP('act');
     $this->expandPage = t3lib_div::_GP('expandPage');
     $this->expandFolder = t3lib_div::_GP('expandFolder');
     // Find RTE parameters
     $this->bparams = t3lib_div::_GP('bparams');
     $this->editorNo = t3lib_div::_GP('editorNo');
     $this->sys_language_content = t3lib_div::_GP('sys_language_content');
     $this->RTEtsConfigParams = t3lib_div::_GP('RTEtsConfigParams');
     if (!$this->editorNo) {
         $pArr = explode('|', $this->bparams);
         $pRteArr = explode(':', $pArr[1]);
         $this->editorNo = $pRteArr[0];
         $this->sys_language_content = $pRteArr[1];
         $this->RTEtsConfigParams = $pArr[2];
     }
     // Find "mode"
     $this->mode = t3lib_div::_GP('mode');
     if (!$this->mode) {
         $this->mode = 'rte';
     }
     // Site URL
     $this->siteURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL');
     // Current site url
     // the script to link to
     $this->thisScript = t3lib_div::getIndpEnv('SCRIPT_NAME');
     if (!$this->act) {
         $this->act = 'magic';
     }
     // init fileProcessor
     $this->fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
     $this->fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
     $RTEtsConfigParts = explode(':', $this->RTEtsConfigParams);
     $RTEsetup = $BE_USER->getTSConfig('RTE', t3lib_BEfunc::getPagesTSconfig($RTEtsConfigParts[5]));
     $this->thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup['properties'], $RTEtsConfigParts[0], $RTEtsConfigParts[2], $RTEtsConfigParts[4]);
     $this->imgPath = $RTEtsConfigParts[6];
     if (is_array($this->thisConfig['buttons.']) && is_array($this->thisConfig['buttons.']['image.'])) {
         $this->buttonConfig = $this->thisConfig['buttons.']['image.'];
         t3lib_div::loadTCA('tx_dam');
         if (is_array($this->buttonConfig['title.']) && is_array($TCA['tx_dam']['columns'][$this->buttonConfig['title.']['useDAMColumn']])) {
             $this->imgTitleDAMColumn = $this->buttonConfig['title.']['useDAMColumn'];
         }
         if (is_array($this->buttonConfig['properties.'])) {
             if ($this->buttonConfig['properties.']['removeItems']) {
                 $this->removedProperties = t3lib_div::trimExplode(',', $this->buttonConfig['properties.']['removeItems'], 1);
             }
             if (is_array($this->buttonConfig['properties.']['class.']) && trim($this->buttonConfig['properties.']['class.']['default'])) {
                 $this->defaultClass = trim($this->buttonConfig['properties.']['class.']['default']);
             }
         }
     }
     if (is_array($this->thisConfig['proc.']) && $this->thisConfig['proc.']['plainImageMode']) {
         $plainImageMode = $this->thisConfig['proc.']['plainImageMode'];
         $this->lockPlainWidth = $plainImageMode == 'lockDimensions' ? 'true' : 'false';
         $this->lockPlainHeight = $this->lockPlainWidth || $plainImageMode == 'lockRatio' || $plainImageMode == 'lockRatioWhenSmaller' ? 'true' : 'false';
     }
     if (!$this->imgTitleDAMColumn) {
         $this->imgTitleDAMColumn = 'caption';
     }
     $this->allowedItems = explode(',', 'magic,plain,image,upload');
     $clientInfo = t3lib_div::clientInfo();
     if ($clientInfo['BROWSER'] !== 'opera') {
         $this->allowedItems[] = 'dragdrop';
     }
     if (is_array($this->buttonConfig['options.']) && $this->buttonConfig['options.']['removeItems']) {
         $this->allowedItems = array_diff($this->allowedItems, t3lib_div::trimExplode(',', $this->buttonConfig['options.']['removeItems'], 1));
     } else {
         $this->allowedItems = array_diff($this->allowedItems, t3lib_div::trimExplode(',', $this->thisConfig['blindImageOptions'], 1));
     }
     reset($this->allowedItems);
     if (!in_array($this->act, $this->allowedItems)) {
         $this->act = current($this->allowedItems);
     }
     if ($this->act == 'magic') {
         if (is_array($this->buttonConfig['options.']) && is_array($this->buttonConfig['options.']['magic.'])) {
             if ($this->buttonConfig['options.']['magic.']['maxWidth']) {
                 $this->magicMaxWidth = $this->buttonConfig['options.']['magic.']['maxWidth'];
             }
             if ($this->buttonConfig['options.']['magic.']['maxHeight']) {
                 $this->magicMaxHeight = $this->buttonConfig['options.']['magic.']['maxHeight'];
             }
         }
         // 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
         if (!$this->magicMaxWidth) {
             $this->magicMaxWidth = 300;
         }
         if (!$this->magicMaxHeight) {
             $this->magicMaxHeight = 1000;
         }
     } elseif ($this->act == 'plain') {
         if (is_array($this->buttonConfig['options.']) && is_array($this->buttonConfig['options.']['plain.'])) {
             if ($this->buttonConfig['options.']['plain.']['maxWidth']) {
                 $this->plainMaxWidth = $this->buttonConfig['options.']['plain.']['maxWidth'];
             }
             if ($this->buttonConfig['options.']['plain.']['maxHeight']) {
                 $this->plainMaxHeight = $this->buttonConfig['options.']['plain.']['maxHeight'];
             }
         }
         if (!$this->plainMaxWidth) {
             $this->plainMaxWidth = 640;
         }
         if (!$this->plainMaxHeight) {
             $this->plainMaxHeight = 680;
         }
     }
     if ($this->thisConfig['classesImage']) {
         $classesImageArray = t3lib_div::trimExplode(',', $this->thisConfig['classesImage'], 1);
         $this->classesImageJSOptions = '<option value=""></option>';
         foreach ($classesImageArray as $class) {
             $this->classesImageJSOptions .= '<option value="' . $class . '">' . $class . '</option>';
         }
     }
     // init the DAM object
     $this->initDAM();
     $this->getModSettings();
     $this->processParams();
     // Insert the image if we are done
     $this->imageInsert();
     // Creating backend template object:
     $this->doc = t3lib_div::makeInstance('template');
     $this->doc->backPath = $BACK_PATH;
 }