/**
  * Adds an edit icon to the content string. The edit icon links to alt_doc.php with proper parameters for editing the table/fields of the context.
  * This implements TYPO3 context sensitive editing facilities. Only backend users will have access (if properly configured as well).
  *
  * @param	string		The content to which the edit icons should be appended
  * @param	string		The parameters defining which table and fields to edit. Syntax is [tablename]:[fieldname],[fieldname],[fieldname],... OR [fieldname],[fieldname],[fieldname],... (basically "[tablename]:" is optional, default table is the one of the "current record" used in the function). The fieldlist is sent as "&columnsOnly=" parameter to alt_doc.php
  * @param	array		TypoScript properties for configuring the edit icons.
  * @param	string		The "table:uid" of the record being shown. If empty string then $this->currentRecord is used. For new records (set by $conf['newRecordFromTable']) it's auto-generated to "[tablename]:NEW"
  * @param	array		Alternative data array to use. Default is $this->data
  * @param	string		Additional URL parameters for the link pointing to alt_doc.php
  * @return	string		The input content string, possibly with edit icons added (not necessarily in the end but just after the last string of normal content.
  */
 public function editIcons($content, $params, array $conf = array(), $currentRecord = '', array $dataArr = array(), $addUrlParamStr = '', $table, $editUid, $fieldList)
 {
     // Special content is about to be shown, so the cache must be disabled.
     $GLOBALS['TSFE']->set_no_cache();
     $style = $conf['styleAttribute'] ? ' style="' . htmlspecialchars($conf['styleAttribute']) . '"' : '';
     $iconTitle = $this->cObj->stdWrap($conf['iconTitle'], $conf['iconTitle.']);
     $iconImg = $conf['iconImg'] ? $conf['iconImg'] : '<img src="' . TYPO3_mainDir . 'gfx/edit_fe.gif" width="11" height="12" border="0" align="top" title="' . t3lib_div::deHSCentities(htmlspecialchars($iconTitle)) . '"' . $style . ' class="frontEndEditIcons" alt="" />';
     $nV = t3lib_div::_GP('ADMCMD_view') ? 1 : 0;
     $adminURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir;
     $icon = $this->editPanelLinkWrap_doWrap($iconImg, $adminURL . 'alt_doc.php?edit[' . $table . '][' . $editUid . ']=edit&columnsOnly=' . rawurlencode($fieldList) . '&noView=' . $nV . $addUrlParamStr, $currentRecord);
     if ($conf['beforeLastTag'] < 0) {
         $content = $icon . $content;
     } elseif ($conf['beforeLastTag'] > 0) {
         $cBuf = rtrim($content);
         $securCount = 30;
         while ($securCount && substr($cBuf, -1) == '>' && substr($cBuf, -4) != '</a>') {
             $cBuf = rtrim(preg_replace('/<[^<]*>$/', '', $cBuf));
             $securCount--;
         }
         $content = strlen($cBuf) && $securCount ? substr($content, 0, strlen($cBuf)) . $icon . substr($content, strlen($cBuf)) : ($content = $icon . $content);
     } else {
         $content .= $icon;
     }
     return $content;
 }
 /**
  * htmlSpecialChars
  * Transforms HTML tags to readable text by replacing special characters with their HTML entity
  * When preserveEntities returns true, existing entities will be left untouched
  *
  * @param	string		Input value undergoing processing in this function.
  * @param	array		stdWrap properties for htmlSpecalChars.
  * @return	string		The processed input value
  */
 public function stdWrap_htmlSpecialChars($content = '', $conf = array())
 {
     $content = htmlSpecialChars($content);
     if ($conf['htmlSpecialChars.']['preserveEntities']) {
         $content = t3lib_div::deHSCentities($content);
     }
     return $content;
 }
示例#3
0
    /**
     * Finding tree and offer setting of values recursively.
     *
     * @param	integer		Page id.
     * @param	string		Select clause
     * @return	string		Select form element for recursive levels (if any levels are found)
     */
    public function getRecursiveSelect($id, $perms_clause)
    {
        // Initialize tree object:
        $tree = t3lib_div::makeInstance('t3lib_pageTree');
        $tree->init('AND ' . $perms_clause);
        $tree->addField('perms_userid', 1);
        $tree->makeHTML = 0;
        $tree->setRecs = 1;
        // Make tree:
        $tree->getTree($id, $this->getLevels, '');
        // If there are a hierarchy of page ids, then...
        if ($GLOBALS['BE_USER']->user['uid'] && count($tree->orig_ids_hierarchy)) {
            // Init:
            $label_recur = $GLOBALS['LANG']->getLL('recursive');
            $label_levels = $GLOBALS['LANG']->getLL('levels');
            $label_pA = $GLOBALS['LANG']->getLL('pages_affected');
            $theIdListArr = array();
            $opts = '
						<option value=""></option>';
            // Traverse the number of levels we want to allow recursive setting of permissions for:
            for ($a = $this->getLevels; $a > 0; $a--) {
                if (is_array($tree->orig_ids_hierarchy[$a])) {
                    foreach ($tree->orig_ids_hierarchy[$a] as $theId) {
                        if ($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['BE_USER']->user['uid'] == $tree->recs[$theId]['perms_userid']) {
                            $theIdListArr[] = $theId;
                        }
                    }
                    $lKey = $this->getLevels - $a + 1;
                    $opts .= '
						<option value="' . htmlspecialchars(implode(',', $theIdListArr)) . '">' . t3lib_div::deHSCentities(htmlspecialchars($label_recur . ' ' . $lKey . ' ' . $label_levels)) . ' (' . count($theIdListArr) . ' ' . $label_pA . ')' . '</option>';
                }
            }
            // Put the selector box together:
            $theRecursiveSelect = '<br />
					<select name="mirror[pages][' . $id . ']">
						' . $opts . '
					</select>
				<br /><br />';
        } else {
            $theRecursiveSelect = '';
        }
        // Return selector box element:
        return $theRecursiveSelect;
    }
 /**
  * Creates a tab menu from an array definition
  *
  * Returns a tab menu for a module
  * Requires the JS function jumpToUrl() to be available
  *
  * @param	mixed		$id is the "&id=" parameter value to be sent to the module, but it can be also a parameter array which will be passed instead of the &id=...
  * @param	string		$elementName it the form elements name, probably something like "SET[...]"
  * @param	string		$currentValue is the value to be selected currently.
  * @param	array		$menuItems is an array with the menu items for the selector box
  * @param	string		$script is the script to send the &id to, if empty it's automatically found
  * @param	string		$addParams is additional parameters to pass to the script.
  * @return	string		HTML code for tab menu
  */
 function getTabMenu($mainParams, $elementName, $currentValue, $menuItems, $script = '', $addparams = '')
 {
     // read page TSconfig
     $useTabs = tx_dam::config_checkValueEnabled('mod.txdamM1_SHARED.useTabs');
     if ($useTabs && is_array($menuItems)) {
         if (!is_array($mainParams)) {
             $mainParams = array('id' => $mainParams);
         }
         $mainParams = t3lib_div::implodeArrayForUrl('', $mainParams);
         if (!$script) {
             $script = basename(PATH_thisScript);
         }
         $menuDef = array();
         foreach ($menuItems as $value => $label) {
             $menuDef[$value]['isActive'] = !strcmp($currentValue, $value);
             $menuDef[$value]['label'] = t3lib_div::deHSCentities(htmlspecialchars($label));
             // original: $menuDef[$value]['url'] = htmlspecialchars($script.'?'.$mainParams.$addparams.'&'.$elementName.'='.$value);
             $menuDef[$value]['url'] = $script . '?' . $mainParams . $addparams . '&' . $elementName . '=' . $value;
         }
         $this->content .= $this->doc->getTabMenuRaw($menuDef);
         return '';
     } else {
         return t3lib_BEfunc::getFuncMenu($this->id, $elementName, $currentValue, $menuItems);
     }
 }
示例#5
0
 /**
  * Creates a tab menu from an array definition
  *
  * Returns a tab menu for a module
  * Requires the JS function jumpToUrl() to be available
  *
  * @param	mixed		$id is the "&id=" parameter value to be sent to the module, but it can be also a parameter array which will be passed instead of the &id=...
  * @param	string		$elementName it the form elements name, probably something like "SET[...]"
  * @param	string		$currentValue is the value to be selected currently.
  * @param	array		$menuItems is an array with the menu items for the selector box
  * @param	string		$script is the script to send the &id to, if empty it's automatically found
  * @param	string		$addParams is additional parameters to pass to the script.
  * @return	string		HTML code for tab menu
  * @author	Rene Fritz <*****@*****.**>
  */
 function getTabMenu($mainParams, $elementName, $currentValue, $menuItems, $script = '', $addparams = '')
 {
     $content = '';
     if (is_array($menuItems)) {
         if (!is_array($mainParams)) {
             $mainParams = array('id' => $mainParams);
         }
         $mainParams = t3lib_div::implodeArrayForUrl('', $mainParams);
         if (!$script) {
             $script = basename(PATH_thisScript);
         }
         $menuDef = array();
         foreach ($menuItems as $value => $label) {
             $menuDef[$value]['isActive'] = !strcmp($currentValue, $value);
             $menuDef[$value]['label'] = t3lib_div::deHSCentities(htmlspecialchars($label));
             $menuDef[$value]['url'] = $script . '?' . $mainParams . $addparams . '&' . $elementName . '=' . $value;
         }
         $content = $this->getTabMenuRaw($menuDef);
     }
     return $content;
 }
 /**
  * Transforms a RTE Field to valid XML
  *
  *
  * @param	string		HTML String which should be transformed
  * @return	mixed		false if transformation failed, string with XML if all fine
  */
 function RTE2XML($content, $withStripBadUTF8 = 0)
 {
     //function RTE2XML($content,$withStripBadUTF8=$GLOBALS['BE_USER']->getModuleData('l10nmgr/cm1/checkUTF8', '')) {
     //if (!$withStripBadUTF8) {
     //	$withStripBadUTF8 = $GLOBALS['BE_USER']->getModuleData('l10nmgr/cm1/checkUTF8', '');
     //}
     //echo '###'.$withStripBadUTF8;
     $content_org = $content;
     // First call special transformations (registered using hooks)
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['l10nmgr']['transformation'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['l10nmgr']['transformation'] as $classReference) {
             $processingObject = t3lib_div::getUserObj($classReference);
             $content = $processingObject->transform_rte($content, $this->parseHTML);
         }
     }
     $content = $this->parseHTML->TS_images_rte($content);
     $content = $this->parseHTML->TS_links_rte($content);
     $content = $this->parseHTML->TS_transform_rte($content, 1);
     //substitute & with &amp;
     //$content=str_replace('&','&amp;',$content); Changed by DZ 2011-05-11
     $content = str_replace('<hr>', '<hr />', $content);
     $content = str_replace('<br>', '<br />', $content);
     $content = t3lib_div::deHSCentities($content);
     if ($withStripBadUTF8 == 1) {
         $content = tx_l10nmgr_utf8tools::utf8_bad_strip($content);
     }
     if ($this->isValidXMLString($content)) {
         return $content;
     } else {
         return false;
     }
 }
 /**
  * Converts htmlspecialchars forth ($dir=1) AND back ($dir=-1)
  *
  * @param	string		Input value
  * @param	integer		Direction: forth ($dir=1, dir=2 for preserving entities) AND back ($dir=-1)
  * @return	string		Output value
  */
 function bidir_htmlspecialchars($value, $dir)
 {
     if ($dir == 1) {
         $value = htmlspecialchars($value);
     } elseif ($dir == 2) {
         $value = t3lib_div::deHSCentities(htmlspecialchars($value));
     } elseif ($dir == -1) {
         $value = str_replace('&gt;', '>', $value);
         $value = str_replace('&lt;', '<', $value);
         $value = str_replace('&quot;', '"', $value);
         $value = str_replace('&amp;', '&', $value);
     }
     return $value;
 }
 /**
  * sendNotificationEmail
  *
  * sends the notification email, uses the TYPO3 mail functions
  *
  * @param string $toEMail
  * @param string $subject
  * @param string $html_body
  * @param int $sendAsHTML
  * @access public
  * @return void
  */
 public function sendNotificationEmail($toEMail, $subject, $html_body, $sendAsHTML = 1)
 {
     /*{{{*/
     // don't send a mail twice to the same user (for example if he is
     // responsible AND observer)
     if (in_array($toEMail, $this->alreadySentTo)) {
         return;
     }
     $this->alreadySentTo[] = $toEMail;
     // only send a mail to the current user (who actually made the changes)
     // if configured so
     if ($GLOBALS['TSFE']->fe_user->user['email'] == $toEMail && !$this->conf['sendNotificationsToSelf']) {
         return;
     }
     // Only ASCII is allowed in the header
     $subject = html_entity_decode(t3lib_div::deHSCentities($subject), ENT_QUOTES, $GLOBALS['TSFE']->renderCharset);
     $subject = t3lib_div::encodeHeader($subject, 'base64', $GLOBALS['TSFE']->renderCharset);
     // create the plain message body
     $message = html_entity_decode(strip_tags($html_body), ENT_QUOTES, $GLOBALS['TSFE']->renderCharset);
     // inspired by code from tt_products, thanks
     if ($this->getNumericTYPO3versionNumber() >= 4005000) {
         $Typo3_htmlmail = t3lib_div::makeInstance('t3lib_mail_Message');
         $Typo3_htmlmail->setSubject($subject);
         $Typo3_htmlmail->setFrom(array($this->conf['email_notifications.']['from_email'] => $this->conf['email_notifications.']['from_name']));
         // add Attachments
         if (is_array($files) && count($files) > 0) {
             foreach ($files as $attachment) {
                 $Typo3_htmlmail->attach(Swift_Attachment::fromPath($uploadPath . $attachment));
             }
         }
         if ($sendAsHTML) {
             $Typo3_htmlmail->setBody($html_body, 'text/html');
             if ($message && $this->conf['email_notifications.']['addPlainTextPart']) {
                 $Typo3_htmlmail->addPart($message, 'text/plain');
             }
         } else {
             $Typo3_htmlmail->addPart($message, 'text/plain');
         }
         $Typo3_htmlmail->setTo(explode(',', $toEMail));
         $Typo3_htmlmail->send();
     } else {
         $Typo3_htmlmail = t3lib_div::makeInstance('t3lib_htmlmail');
         $Typo3_htmlmail->start();
         $Typo3_htmlmail->subject = $subject;
         $Typo3_htmlmail->from_email = $this->conf['email_notifications.']['from_email'];
         $Typo3_htmlmail->from_name = $this->conf['email_notifications.']['from_name'];
         $Typo3_htmlmail->replyto_email = $Typo3_htmlmail->from_email;
         $Typo3_htmlmail->replyto_name = $Typo3_htmlmail->from_name;
         $Typo3_htmlmail->organisation = '';
         // add Attachments
         if (is_array($files) && count($files) > 0) {
             foreach ($files as $attachment) {
                 $Typo3_htmlmail->addAttachment($uploadPath . $attachment);
             }
         }
         if ($sendAsHTML) {
             $Typo3_htmlmail->theParts['html']['content'] = $html_body;
             $Typo3_htmlmail->theParts['html']['path'] = t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST') . '/';
             $Typo3_htmlmail->extractMediaLinks();
             $Typo3_htmlmail->extractHyperLinks();
             $Typo3_htmlmail->fetchHTMLMedia();
             $Typo3_htmlmail->substMediaNamesInHTML(0);
             // 0 = relative
             $Typo3_htmlmail->substHREFsInHTML();
             $Typo3_htmlmail->setHTML($Typo3_htmlmail->encodeMsg($Typo3_htmlmail->theParts['html']['content']));
             if ($message && $this->conf['email_notifications.']['addPlainTextPart']) {
                 $Typo3_htmlmail->addPlain($message);
             }
         } else {
             $Typo3_htmlmail->addPlain($message);
         }
         $Typo3_htmlmail->setHeaders();
         $Typo3_htmlmail->setContent();
         $Typo3_htmlmail->setRecipient(explode(',', $toEMail));
         $Typo3_htmlmail->sendTheMail();
     }
 }
示例#9
0
    function _getSelectField($elementName, $currentValue, $menuItems)
    {
        $options = array();
        foreach ($menuItems as $value => $label) {
            $options[] = '<option value="' . htmlspecialchars($value) . '"' . (!strcmp($currentValue, $value) ? ' selected="selected"' : '') . '>' . t3lib_div::deHSCentities(htmlspecialchars($label)) . '</option>';
        }
        if (count($options) > 0) {
            return '
				<select name="' . $elementName . '" >
					' . implode('
					', $options) . '
				</select>
						';
        }
    }
示例#10
0
 /**
  * splitLabel function
  * Historically labels were exploded by '|' and each part would correspond
  * to the translation of the language found at the same 'index' in the TYPO3_languages constant.
  * Today all translations are based on $LOCAL_LANG variables.
  * 'language-splitted' labels can therefore refer to a local-lang file + index instead!
  * It's highly recommended to use the 'local_lang' method
  * (and thereby it's highly deprecated to use 'language-splitted' label strings)
  * Refer to 'Inside TYPO3' for more details
  *
  * @param	string		Label key/reference
  * @param	boolean		If set, the return value is htmlspecialchar'ed
  * @return	string
  * @access	public
  */
 public function sL($input, $hsc = 0)
 {
     // Using obsolete 'language-splitted' labels:
     if (strcmp(substr($input, 0, 4), 'LLL:')) {
         $t = explode('|', $input);
         $out = $t[$this->langSplitIndex] ? $t[$this->langSplitIndex] : $t[0];
         return $this->hscAndCharConv($out, $hsc);
         // LOCAL_LANG:
     } else {
         // If cached label
         if (!isset($this->LL_labels_cache[$this->lang][$input])) {
             $restStr = trim(substr($input, 4));
             $extPrfx = '';
             // ll-file refered to is found in an extension.
             if (!strcmp(substr($restStr, 0, 4), 'EXT:')) {
                 $restStr = trim(substr($restStr, 4));
                 $extPrfx = 'EXT:';
             }
             $parts = explode(':', $restStr);
             $parts[0] = $extPrfx . $parts[0];
             // Getting data if not cached
             if (!isset($this->LL_files_cache[$parts[0]])) {
                 $this->LL_files_cache[$parts[0]] = $this->readLLfile($parts[0]);
                 // If the current language is found in another file, load that as well:
                 $lFileRef = $this->localizedFileRef($parts[0]);
                 if ($lFileRef && is_string($this->LL_files_cache[$parts[0]][$this->lang]) && $this->LL_files_cache[$parts[0]][$this->lang] == 'EXT') {
                     $tempLL = $this->readLLfile($lFileRef);
                     $this->LL_files_cache[$parts[0]][$this->lang] = $tempLL[$this->lang];
                 }
                 // Overriding file?
                 // @deprecated since TYPO3 4.3, remove in TYPO3 4.5, please use the generic method in
                 // t3lib_div::readLLfile and the global array $GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride']
                 if (isset($GLOBALS['TYPO3_CONF_VARS']['BE']['XLLfile'][$parts[0]])) {
                     t3lib_div::deprecationLog('Usage of $TYPO3_CONF_VARS[\'BE\'][\'XLLfile\'] is deprecated since TYPO3 4.3. Use $TYPO3_CONF_VARS[\'SYS\'][\'locallangXMLOverride\'][] to include the file ' . $fileRef . ' instead.');
                     $ORarray = $this->readLLfile($GLOBALS['TYPO3_CONF_VARS']['BE']['XLLfile'][$parts[0]]);
                     $this->LL_files_cache[$parts[0]] = t3lib_div::array_merge_recursive_overrule($this->LL_files_cache[$parts[0]], $ORarray);
                 }
             }
             $this->LL_labels_cache[$this->lang][$input] = $this->getLLL($parts[1], $this->LL_files_cache[$parts[0]]);
         }
         // For the cached output charset conversion has already happened!
         // So perform HSC right here.
         $output = $this->LL_labels_cache[$this->lang][$input];
         if ($hsc) {
             $output = t3lib_div::deHSCentities(htmlspecialchars($output));
         }
         return $output . ($this->debugKey ? ' [' . $input . ']' : '');
     }
 }
    /**
     * Returns a selector box "function menu" for a module
     * Requires the JS function jumpToUrl() to be available
     * See Inside TYPO3 for details about how to use / make Function menus
     * Usage: 50
     *
     * @param	mixed		$id is the "&id=" parameter value to be sent to the module, but it can be also a parameter array which will be passed instead of the &id=...
     * @param	string		$elementName it the form elements name, probably something like "SET[...]"
     * @param	string		$currentValue is the value to be selected currently.
     * @param	array		$menuItems is an array with the menu items for the selector box
     * @param	string		$script is the script to send the &id to, if empty it's automatically found
     * @param	string		$addParams is additional parameters to pass to the script.
     * @return	string		HTML code for selector box
     */
    public static function getFuncMenu($mainParams, $elementName, $currentValue, $menuItems, $script = '', $addparams = '')
    {
        if (is_array($menuItems)) {
            if (!is_array($mainParams)) {
                $mainParams = array('id' => $mainParams);
            }
            $mainParams = t3lib_div::implodeArrayForUrl('', $mainParams);
            if (!$script) {
                $script = basename(PATH_thisScript);
                $mainParams .= t3lib_div::_GET('M') ? '&M=' . rawurlencode(t3lib_div::_GET('M')) : '';
            }
            $options = array();
            foreach ($menuItems as $value => $label) {
                $options[] = '<option value="' . htmlspecialchars($value) . '"' . (!strcmp($currentValue, $value) ? ' selected="selected"' : '') . '>' . t3lib_div::deHSCentities(htmlspecialchars($label)) . '</option>';
            }
            if (count($options)) {
                $onChange = 'jumpToUrl(\'' . $script . '?' . $mainParams . $addparams . '&' . $elementName . '=\'+this.options[this.selectedIndex].value,this);';
                return '

					<!-- Function Menu of module -->
					<select name="' . $elementName . '" onchange="' . htmlspecialchars($onChange) . '">
						' . implode('
						', $options) . '
					</select>
							';
            }
        }
    }
    /**
     * Creates a selectorbox list (renderMode = "singlebox")
     * (Render function for getSingleField_typeSelect())
     *
     * @param	string		See getSingleField_typeSelect()
     * @param	string		See getSingleField_typeSelect()
     * @param	array		See getSingleField_typeSelect()
     * @param	array		See getSingleField_typeSelect()
     * @param	array		(Redundant) content of $PA['fieldConf']['config'] (for convenience)
     * @param	array		Items available for selection
     * @param	string		Label for no-matching-value
     * @return	string		The HTML code for the item
     * @see getSingleField_typeSelect()
     */
    function getSingleField_typeSelect_singlebox($table, $field, $row, &$PA, $config, $selItems, $nMV_label)
    {
        // Get values in an array (and make unique, which is fine because there can be no duplicates anyway):
        $itemArray = array_flip($this->extractValuesOnlyFromValueLabelList($PA['itemFormElValue']));
        $disabled = '';
        if ($this->renderReadonly || $config['readOnly']) {
            $disabled = ' disabled="disabled"';
        }
        // Traverse the Array of selector box items:
        $opt = array();
        $restoreCmd = array();
        // Used to accumulate the JS needed to restore the original selection.
        $c = 0;
        foreach ($selItems as $p) {
            // Selected or not by default:
            $sM = '';
            if (isset($itemArray[$p[1]])) {
                $sM = ' selected="selected"';
                $restoreCmd[] = $this->elName($PA['itemFormElName'] . '[]') . '.options[' . $c . '].selected=1;';
                unset($itemArray[$p[1]]);
            }
            // Non-selectable element:
            $nonSel = '';
            if (!strcmp($p[1], '--div--')) {
                $nonSel = ' onclick="this.selected=0;" class="c-divider"';
            }
            // Icon style for option tag:
            if ($config['iconsInOptionTags']) {
                $styleAttrValue = $this->optionTagStyle($p[2]);
            }
            // Compile <option> tag:
            $opt[] = '<option value="' . htmlspecialchars($p[1]) . '"' . $sM . $nonSel . ($styleAttrValue ? ' style="' . htmlspecialchars($styleAttrValue) . '"' : '') . '>' . t3lib_div::deHSCentities(htmlspecialchars($p[0])) . '</option>';
            $c++;
        }
        // Remaining values:
        if (count($itemArray) && !$PA['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
            foreach ($itemArray as $theNoMatchValue => $temp) {
                // Compile <option> tag:
                array_unshift($opt, '<option value="' . htmlspecialchars($theNoMatchValue) . '" selected="selected">' . t3lib_div::deHSCentities(htmlspecialchars(@sprintf($nMV_label, $theNoMatchValue))) . '</option>');
            }
        }
        // Compile selector box:
        $sOnChange = implode('', $PA['fieldChangeFunc']);
        $selector_itemListStyle = isset($config['itemListStyle']) ? ' style="' . htmlspecialchars($config['itemListStyle']) . '"' : ' style="' . $this->defaultMultipleSelectorStyle . '"';
        $size = intval($config['size']);
        $cssPrefix = $size === 1 ? 'tceforms-select' : 'tceforms-multiselect';
        $size = $config['autoSizeMax'] ? t3lib_div::intInRange(count($selItems) + 1, t3lib_div::intInRange($size, 1), $config['autoSizeMax']) : $size;
        $selectBox = '<select id="' . uniqid($cssPrefix) . '" name="' . $PA['itemFormElName'] . '[]"' . $this->insertDefStyle('select', $cssPrefix) . ($size ? ' size="' . $size . '"' : '') . ' multiple="multiple" onchange="' . htmlspecialchars($sOnChange) . '"' . $PA['onFocus'] . $selector_itemListStyle . $disabled . '>
						' . implode('
						', $opt) . '
					</select>';
        // Add an empty hidden field which will send a blank value if all items are unselected.
        if (!$disabled) {
            $item .= '<input type="hidden" name="' . htmlspecialchars($PA['itemFormElName']) . '" value="" />';
        }
        // Put it all into a table:
        $item .= '
			<table border="0" cellspacing="0" cellpadding="0" width="1" class="typo3-TCEforms-select-singlebox">
				<tr>
					<td>
					' . $selectBox . '
					<br/>
					<em>' . htmlspecialchars($this->getLL('l_holdDownCTRL')) . '</em>
					</td>
					<td valign="top">
					  <a href="#" onclick="' . htmlspecialchars($this->elName($PA['itemFormElName'] . '[]') . '.selectedIndex=-1;' . implode('', $restoreCmd) . ' return false;') . '" title="' . htmlspecialchars($this->getLL('l_revertSelection')) . '">' . t3lib_iconWorks::getSpriteIcon('actions-edit-undo') . '</a>
					</td>
				</tr>
			</table>
				';
        return $item;
    }
    /**
     * Returns a selector box with charset encodings
     *
     * @param	string		$elementName it the form elements name, probably something like "SET[...]"
     * @param	string		$currentKey is the key to be selected currently.
     * @param	string		$firstEntry is the key to be placed on top as first (default) entry.
     * @param	string		$unsetEntries List of keys that should be removed (comma list).
     * @return	string		HTML code for selector box
     */
    function getEncodingSelect($elementName, $currentKey, $firstEntry = '', $unsetEntries = '')
    {
        $menuItems = array('utf-8' => 'UTF-8', 'iso-8859-1' => 'ISO-8859-1 (Western Europe)', 'iso-8859-2' => 'ISO-8859-2 (Central Europe)', 'iso-8859-3' => 'ISO-8859-3 (Latin 3)', 'iso-8859-4' => 'ISO-8859-4 (Baltic)', 'iso-8859-5' => 'ISO-8859-5 (Cyrillic)', 'iso-8859-6' => 'ISO-8859-6 (Arabic)', 'iso-8859-7' => 'ISO-8859-7 (Greek)', 'iso-8859-7' => 'ISO-8859-8 (Hebrew)', 'iso-8859-9' => 'ISO-8859-9 (Turkish)', 'iso-8859-14' => 'ISO-8859-14 (Celtic)', 'iso-8859-15' => 'ISO-8859-15 (Latin 9)', 'windows-1250' => 'Windows 1250 (ANSI - Central Europe)', 'windows-1251' => 'Windows 1251 (ANSI - Cyrillic)', 'windows-1252' => 'Windows 1252 (ANSI - Western Europe)', 'windows-1253' => 'Windows 1253 (ANSI - Greek)', 'windows-1254' => 'Windows 1254 (ANSI - Turkish)', 'windows-1255' => 'Windows 1255 (ANSI - Hebrew)', 'windows-1256' => 'Windows 1256 (ANSI - Arabic)', 'windows-1257' => 'Windows 1257 (ANSI - Baltic)', 'windows-1258' => 'Windows 1258 (ANSI - Vietnamese)', 'koi-8r' => 'KOI-8R (Russian)', 'shift_jis' => 'Shift JIS (Japanese)', 'euc-jp' => 'EUC-JP (Japanese)', 'gb2312' => 'GB2312 / EUC-CN (Chinese Simplified)', 'big5' => 'Big5 (Chinese)', 'ascii' => 'ASCII');
        if ($firstEntry and $menuItems[$firstEntry]) {
            $entry = array($firstEntry => $menuItems[$firstEntry]);
            unset($menuItems[$firstEntry]);
            $menuItems = array_merge($entry, $menuItems);
        }
        $unsetEntries = explode(',', $unsetEntries);
        foreach ($unsetEntries as $entry) {
            unset($menuItems[$entry]);
        }
        $options = array();
        foreach ($menuItems as $value => $label) {
            $options[] = '<option value="' . htmlspecialchars($value) . '"' . (!strcmp($currentKey, $value) ? ' selected="selected"' : '') . '>' . t3lib_div::deHSCentities(htmlspecialchars($label)) . '</option>';
        }
        if (count($options)) {
            return '

					<!-- charset encoding menu -->
					<select name="' . $elementName . '">
						' . implode('
						', $options) . '
					</select>
						';
        }
    }
    /**
     * Draws the RTE as an iframe
     *
     * @param	object		Reference to parent object, which is an instance of the TCEforms.
     * @param	string		The table name
     * @param	string		The field name
     * @param	array		The current row from which field is being rendered
     * @param	array		Array of standard content for rendering form fields from TCEforms. See TCEforms for details on this. Includes for instance the value and the form field name, java script actions and more.
     * @param	array		"special" configuration - what is found at position 4 in the types configuration of a field from record, parsed into an array.
     * @param	array		Configuration for RTEs; A mix between TSconfig and otherwise. Contains configuration for display, which buttons are enabled, additional transformation information etc.
     * @param	string		Record "type" field value.
     * @param	string		Relative path for images/links in RTE; this is used when the RTE edits content from static files where the path of such media has to be transformed forth and back!
     * @param	integer		PID value of record (true parent page id)
     * @return	string		HTML code for RTE!
     */
    function drawRTE($parentObject, $table, $field, $row, $PA, $specConf, $thisConfig, $RTEtypeVal, $RTErelPath, $thePidValue)
    {
        global $BE_USER, $LANG, $TYPO3_DB, $TYPO3_CONF_VARS;
        $this->TCEform = $parentObject;
        $inline = $this->TCEform->inline;
        $LANG->includeLLFile('EXT:' . $this->ID . '/locallang.xml');
        $this->client = $this->clientInfo();
        $this->typoVersion = t3lib_div::int_from_ver(TYPO3_version);
        $this->userUid = 'BE_' . $BE_USER->user['uid'];
        // Draw form element:
        if ($this->debugMode) {
            // Draws regular text area (debug mode)
            $item = parent::drawRTE($this->TCEform, $table, $field, $row, $PA, $specConf, $thisConfig, $RTEtypeVal, $RTErelPath, $thePidValue);
        } else {
            // Draw real RTE
            /* =======================================
             * INIT THE EDITOR-SETTINGS
             * =======================================
             */
            // Set backPath
            $this->backPath = $this->TCEform->backPath;
            // Get the path to this extension:
            $this->extHttpPath = $this->backPath . t3lib_extMgm::extRelPath($this->ID);
            // Get the site URL
            $this->siteURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL');
            // Get the host URL
            $this->hostURL = $this->siteURL . TYPO3_mainDir;
            // Element ID + pid
            $this->elementId = $PA['itemFormElName'];
            // Form element name
            $this->elementParts = explode('][', preg_replace('/\\]$/', '', preg_replace('/^(TSFE_EDIT\\[data\\]\\[|data\\[)/', '', $this->elementId)));
            // Find the page PIDs:
            list($this->tscPID, $this->thePid) = t3lib_BEfunc::getTSCpid(trim($this->elementParts[0]), trim($this->elementParts[1]), $thePidValue);
            // Record "types" field value:
            $this->typeVal = $RTEtypeVal;
            // TCA "types" value for record
            // Find "thisConfig" for record/editor:
            unset($this->RTEsetup);
            $this->RTEsetup = $BE_USER->getTSConfig('RTE', t3lib_BEfunc::getPagesTSconfig($this->tscPID));
            $this->thisConfig = $thisConfig;
            // Special configuration and default extras:
            $this->specConf = $specConf;
            if ($this->thisConfig['forceHTTPS']) {
                $this->extHttpPath = preg_replace('/^(http|https)/', 'https', $this->extHttpPath);
                $this->siteURL = preg_replace('/^(http|https)/', 'https', $this->siteURL);
                $this->hostURL = preg_replace('/^(http|https)/', 'https', $this->hostURL);
            }
            /* =======================================
             * LANGUAGES & CHARACTER SETS
             * =======================================
             */
            // Languages: interface and content
            $this->language = $LANG->lang;
            if ($this->language == 'default' || !$this->language) {
                $this->language = 'en';
            }
            $this->contentTypo3Language = $this->language;
            $this->contentISOLanguage = 'en';
            $this->contentLanguageUid = $row['sys_language_uid'] > 0 ? $row['sys_language_uid'] : 0;
            if (t3lib_extMgm::isLoaded('static_info_tables')) {
                if ($this->contentLanguageUid) {
                    $tableA = 'sys_language';
                    $tableB = 'static_languages';
                    $languagesUidsList = $this->contentLanguageUid;
                    $selectFields = $tableA . '.uid,' . $tableB . '.lg_iso_2,' . $tableB . '.lg_country_iso_2,' . $tableB . '.lg_typo3';
                    $tableAB = $tableA . ' LEFT JOIN ' . $tableB . ' ON ' . $tableA . '.static_lang_isocode=' . $tableB . '.uid';
                    $whereClause = $tableA . '.uid IN (' . $languagesUidsList . ') ';
                    $whereClause .= t3lib_BEfunc::BEenableFields($tableA);
                    $whereClause .= t3lib_BEfunc::deleteClause($tableA);
                    $res = $TYPO3_DB->exec_SELECTquery($selectFields, $tableAB, $whereClause);
                    while ($languageRow = $TYPO3_DB->sql_fetch_assoc($res)) {
                        $this->contentISOLanguage = strtolower(trim($languageRow['lg_iso_2']) . (trim($languageRow['lg_country_iso_2']) ? '_' . trim($languageRow['lg_country_iso_2']) : ''));
                        $this->contentTypo3Language = strtolower(trim($languageRow['lg_typo3']));
                    }
                } else {
                    $this->contentISOLanguage = trim($this->thisConfig['defaultContentLanguage']) ? trim($this->thisConfig['defaultContentLanguage']) : 'en';
                    $selectFields = 'lg_iso_2, lg_typo3';
                    $tableAB = 'static_languages';
                    $whereClause = 'lg_iso_2 = ' . $TYPO3_DB->fullQuoteStr(strtoupper($this->contentISOLanguage), $tableAB);
                    $res = $TYPO3_DB->exec_SELECTquery($selectFields, $tableAB, $whereClause);
                    while ($languageRow = $TYPO3_DB->sql_fetch_assoc($res)) {
                        $this->contentTypo3Language = strtolower(trim($languageRow['lg_typo3']));
                    }
                }
            }
            // Character sets: interface and content
            $this->charset = $LANG->charSet;
            $this->OutputCharset = $this->charset;
            $this->contentCharset = $LANG->csConvObj->charSetArray[$this->contentTypo3Language];
            $this->contentCharset = $this->contentCharset ? $this->contentCharset : 'iso-8859-1';
            $this->origContentCharSet = $this->contentCharset;
            $this->contentCharset = trim($TYPO3_CONF_VARS['BE']['forceCharset']) ? trim($TYPO3_CONF_VARS['BE']['forceCharset']) : $this->contentCharset;
            /* =======================================
             * TOOLBAR CONFIGURATION
             * =======================================
             */
            $this->initializeToolbarConfiguration();
            /* =======================================
             * SET STYLES
             * =======================================
             */
            $RTEWidth = isset($BE_USER->userTS['options.']['RTESmallWidth']) ? $BE_USER->userTS['options.']['RTESmallWidth'] : '530';
            $RTEHeight = isset($BE_USER->userTS['options.']['RTESmallHeight']) ? $BE_USER->userTS['options.']['RTESmallHeight'] : '380';
            $RTEWidth = $RTEWidth + ($this->TCEform->docLarge ? isset($BE_USER->userTS['options.']['RTELargeWidthIncrement']) ? $BE_USER->userTS['options.']['RTELargeWidthIncrement'] : '150' : 0);
            $RTEWidth -= $inline->getStructureDepth() > 0 ? ($inline->getStructureDepth() + 1) * $inline->getLevelMargin() : 0;
            if (isset($this->thisConfig['RTEWidthOverride'])) {
                if (strstr($this->thisConfig['RTEWidthOverride'], '%')) {
                    if ($this->client['browser'] != 'msie') {
                        $RTEWidth = intval($this->thisConfig['RTEWidthOverride']) > 0 ? $this->thisConfig['RTEWidthOverride'] : '100%';
                    }
                } else {
                    $RTEWidth = intval($this->thisConfig['RTEWidthOverride']) > 0 ? intval($this->thisConfig['RTEWidthOverride']) : $RTEWidth;
                }
            }
            $RTEWidth = strstr($RTEWidth, '%') ? $RTEWidth : $RTEWidth . 'px';
            $RTEHeight = $RTEHeight + ($this->TCEform->docLarge ? isset($BE_USER->userTS['options.']['RTELargeHeightIncrement']) ? $BE_USER->userTS['options.']['RTELargeHeightIncrement'] : 0 : 0);
            $RTEHeightOverride = intval($this->thisConfig['RTEHeightOverride']);
            $RTEHeight = $RTEHeightOverride > 0 ? $RTEHeightOverride : $RTEHeight;
            $editorWrapWidth = '99%';
            $editorWrapHeight = '100%';
            $this->RTEdivStyle = 'position:relative; left:0px; top:0px; height:' . $RTEHeight . 'px; width:' . $RTEWidth . '; border: 1px solid black; padding: 2px 2px 2px 2px;';
            /* =======================================
             * LOAD CSS AND JAVASCRIPT
             * =======================================
             */
            // Preloading the pageStyle and including RTE skin stylesheets
            $this->addPageStyle();
            $this->addSkin();
            // Loading JavaScript files and code
            if ($this->TCEform->RTEcounter == 1) {
                $this->TCEform->additionalJS_pre['rtehtmlarea-loadJScode'] = $this->loadJScode($this->TCEform->RTEcounter);
            }
            $this->TCEform->additionalCode_pre['rtehtmlarea-loadJSfiles'] = $this->loadJSfiles($this->TCEform->RTEcounter);
            $pageRenderer = $GLOBALS['SOBE']->doc->getPageRenderer();
            $pageRenderer->enableExtJSQuickTips();
            if (!$GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->ID]['enableCompressedScripts']) {
                $pageRenderer->enableExtJsDebug();
            }
            /* =======================================
             * DRAW THE EDITOR
             * =======================================
             */
            // Transform value:
            $value = $this->transformContent('rte', $PA['itemFormElValue'], $table, $field, $row, $specConf, $thisConfig, $RTErelPath, $thePidValue);
            // Further content transformation by registered plugins
            foreach ($this->registeredPlugins as $pluginId => $plugin) {
                if ($this->isPluginEnabled($pluginId) && method_exists($plugin, "transformContent")) {
                    $value = $plugin->transformContent($value);
                }
            }
            // Register RTE windows
            $this->TCEform->RTEwindows[] = $PA['itemFormElName'];
            $textAreaId = htmlspecialchars($PA['itemFormElName']);
            // Check if wizard_rte called this for fullscreen edtition; if so, change the size of the RTE to fullscreen using JS
            if (basename(PATH_thisScript) == 'wizard_rte.php') {
                $this->fullScreen = true;
                $editorWrapWidth = '100%';
                $editorWrapHeight = '100%';
                $this->RTEdivStyle = 'position:relative; left:0px; top:0px; height:100%; width:100%; border: 1px solid black; padding: 2px 0px 2px 2px;';
            }
            // Register RTE in JS:
            $this->TCEform->additionalJS_post[] = $this->registerRTEinJS($this->TCEform->RTEcounter, $table, $row['uid'], $field, $textAreaId);
            // Set the save option for the RTE:
            $this->TCEform->additionalJS_submit[] = $this->setSaveRTE($this->TCEform->RTEcounter, $this->TCEform->formName, $textAreaId);
            $this->TCEform->additionalJS_delete[] = $this->setDeleteRTE($this->TCEform->RTEcounter, $this->TCEform->formName, $textAreaId);
            // Draw the textarea
            $visibility = 'hidden';
            $item = $this->triggerField($PA['itemFormElName']) . '
				<div id="pleasewait' . $textAreaId . '" class="pleasewait" style="display: block;" >' . $LANG->getLL('Please wait') . '</div>
				<div id="editorWrap' . $textAreaId . '" class="editorWrap" style="visibility: hidden; width:' . $editorWrapWidth . '; height:' . $editorWrapHeight . ';">
				<textarea id="RTEarea' . $textAreaId . '" name="' . htmlspecialchars($PA['itemFormElName']) . '" style="' . t3lib_div::deHSCentities(htmlspecialchars($this->RTEdivStyle)) . '">' . t3lib_div::formatForTextarea($value) . '</textarea>
				</div>' . ($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableDebugMode'] ? '<div id="HTMLAreaLog"></div>' : '') . '
				';
        }
        // Return form item:
        return $item;
    }
 /**
  * The "stdWrap" function. This is the implementation of what is known as "stdWrap properties" in TypoScript.
  * Basically "stdWrap" performs some processing of a value based on properties in the input $conf array (holding the TypoScript "stdWrap properties")
  * See the link below for a complete list of properties and what they do. The order of the table with properties found in TSref (the link) follows the actual order of implementation in this function.
  *
  * If $this->alternativeData is an array it's used instead of the $this->data array in ->getData
  *
  * @param	string		Input value undergoing processing in this function. Possibly substituted by other values fetched from another source.
  * @param	array		TypoScript "stdWrap properties".
  * @return	string		The processed input value
  * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=314&cHash=02ab044c7b
  */
 function stdWrap($content, $conf)
 {
     if (is_array($conf)) {
         foreach ($this->stdWrapHookObjects as $hookObject) {
             $content = $hookObject->stdWrapPreProcess($content, $conf, $this);
         }
         // Setting current value, if so
         if ($conf['setContentToCurrent']) {
             $this->data[$this->currentValKey] = $content;
         }
         if ($conf['setCurrent'] || $conf['setCurrent.']) {
             $this->data[$this->currentValKey] = $this->stdWrap($conf['setCurrent'], $conf['setCurrent.']);
         }
         // Getting data:
         if (isset($conf['lang.']) && $GLOBALS['TSFE']->config['config']['language'] && isset($conf['lang.'][$GLOBALS['TSFE']->config['config']['language']])) {
             $content = $conf['lang.'][$GLOBALS['TSFE']->config['config']['language']];
         }
         if ($conf['data']) {
             $content = $this->getData($conf['data'], is_array($this->alternativeData) ? $this->alternativeData : $this->data);
         }
         $this->alternativeData = '';
         // This must be unset directly after
         if ($conf['field']) {
             $content = $this->getFieldVal($conf['field']);
         }
         if ($conf['current']) {
             $content = $this->data[$this->currentValKey];
         }
         if ($conf['cObject']) {
             $content = $this->cObjGetSingle($conf['cObject'], $conf['cObject.'], '/stdWrap/.cObject');
         }
         if ($conf['numRows.']) {
             $content = $this->numRows($conf['numRows.']);
         }
         if ($conf['filelist'] || $conf['filelist.']) {
             $content = $this->filelist($this->stdWrap($conf['filelist'], $conf['filelist.']));
         }
         if ($conf['preUserFunc']) {
             $content = $this->callUserFunction($conf['preUserFunc'], $conf['preUserFunc.'], $content);
         }
         foreach ($this->stdWrapHookObjects as $hookObject) {
             $content = $hookObject->stdWrapOverride($content, $conf, $this);
         }
         // Overriding values, evaluating conditions
         if ($conf['override'] || $conf['override.']) {
             $override = $this->stdWrap($conf['override'], $conf['override.']);
             if (trim($override)) {
                 $content = $override;
             }
         }
         if (isset($conf['preIfEmptyListNum']) || isset($conf['preIfEmptyListNum.']['stdWrap.'])) {
             $preIfEmptyListNumber = isset($conf['preIfEmptyListNum.']['stdWrap.']) ? $this->stdWrap($conf['preIfEmptyListNum'], $conf['preIfEmptyListNum.']['stdWrap.']) : $conf['preIfEmptyListNum'];
             $content = $this->listNum($content, $preIfEmptyListNumber, $conf['preIfEmptyListNum.']['splitChar']);
         }
         if (!trim($content) && ($conf['ifEmpty'] || $conf['ifEmpty.'])) {
             $content = $this->stdWrap($conf['ifEmpty'], $conf['ifEmpty.']);
         }
         if (!strlen(trim($content)) && ($conf['ifBlank'] || $conf['ifBlank.'])) {
             $content = $this->stdWrap($conf['ifBlank'], $conf['ifBlank.']);
         }
         // values...
         if (isset($conf['listNum']) || isset($conf['listNum.']['stdWrap.'])) {
             $listNumber = isset($conf['listNum.']['stdWrap.']) ? $this->stdWrap($conf['listNum'], $conf['listNum.']['stdWrap.']) : $conf['listNum'];
             $content = $this->listNum($content, $listNumber, $conf['listNum.']['splitChar']);
         }
         if ($conf['trim']) {
             $content = trim($content);
         }
         // Call stdWrap recursively
         if ($conf['stdWrap.']) {
             $content = $this->stdWrap($content, $conf['stdWrap.']);
         }
         foreach ($this->stdWrapHookObjects as $hookObject) {
             $content = $hookObject->stdWrapProcess($content, $conf, $this);
         }
         if ($conf['required'] && (string) $content == '' || $conf['if.'] && !$this->checkIf($conf['if.']) || $conf['fieldRequired'] && !trim($this->data[$conf['fieldRequired']])) {
             $content = '';
         } else {
             // Perform data processing:
             if ($conf['csConv']) {
                 $content = $GLOBALS['TSFE']->csConv($content, $conf['csConv']);
             }
             if ($conf['parseFunc.'] || $conf['parseFunc']) {
                 $content = $this->parseFunc($content, $conf['parseFunc.'], $conf['parseFunc']);
             }
             if ($conf['HTMLparser'] && is_array($conf['HTMLparser.'])) {
                 $content = $this->HTMLparser_TSbridge($content, $conf['HTMLparser.']);
             }
             if ($conf['split.']) {
                 $content = $this->splitObj($content, $conf['split.']);
             }
             if ($conf['prioriCalc']) {
                 $content = t3lib_div::calcParenthesis($content);
                 if ($conf['prioriCalc'] == 'intval') {
                     $content = intval($content);
                 }
             }
             if ((string) $conf['char'] != '') {
                 $content = chr(intval($conf['char']));
             }
             if ($conf['intval']) {
                 $content = intval($content);
             }
             if ($conf['date']) {
                 $content = $conf['date.']['GMT'] ? gmdate($conf['date'], $content) : date($conf['date'], $content);
             }
             if ($conf['strftime']) {
                 $content = $conf['strftime.']['GMT'] ? gmstrftime($conf['strftime'], $content) : strftime($conf['strftime'], $content);
                 $tmp_charset = $conf['strftime.']['charset'] ? $conf['strftime.']['charset'] : $GLOBALS['TSFE']->localeCharset;
                 if ($tmp_charset) {
                     $content = $GLOBALS['TSFE']->csConv($content, $tmp_charset);
                 }
             }
             if ($conf['age']) {
                 $content = $this->calcAge($GLOBALS['EXEC_TIME'] - $content, $conf['age']);
             }
             if ($conf['case']) {
                 $content = $this->HTMLcaseshift($content, $conf['case']);
             }
             if ($conf['bytes']) {
                 $content = t3lib_div::formatSize($content, $conf['bytes.']['labels']);
             }
             if ($conf['substring']) {
                 $content = $this->substring($content, $conf['substring']);
             }
             if ($conf['removeBadHTML']) {
                 $content = $this->removeBadHTML($content, $conf['removeBadHTML.']);
             }
             if ($conf['cropHTML']) {
                 $content = $this->cropHTML($content, $conf['cropHTML']);
             }
             if ($conf['stripHtml']) {
                 $content = strip_tags($content);
             }
             if ($conf['crop']) {
                 $content = $this->crop($content, $conf['crop']);
             }
             if ($conf['rawUrlEncode']) {
                 $content = rawurlencode($content);
             }
             if ($conf['htmlSpecialChars']) {
                 $content = htmlSpecialChars($content);
                 if ($conf['htmlSpecialChars.']['preserveEntities']) {
                     $content = t3lib_div::deHSCentities($content);
                 }
             }
             if ($conf['doubleBrTag']) {
                 $content = preg_replace("/\r?\n[\t ]*\r?\n/", $conf['doubleBrTag'], $content);
             }
             if ($conf['br']) {
                 $content = nl2br($content);
             }
             if ($conf['brTag']) {
                 $content = str_replace(LF, $conf['brTag'], $content);
             }
             if ($conf['encapsLines.']) {
                 $content = $this->encaps_lineSplit($content, $conf['encapsLines.']);
             }
             if ($conf['keywords']) {
                 $content = $this->keywords($content);
             }
             if ($conf['innerWrap'] || $conf['innerWrap.']) {
                 $content = $this->wrap($content, $this->stdWrap($conf['innerWrap'], $conf['innerWrap.']));
             }
             if ($conf['innerWrap2'] || $conf['innerWrap2.']) {
                 $content = $this->wrap($content, $this->stdWrap($conf['innerWrap2'], $conf['innerWrap2.']));
             }
             if ($conf['fontTag']) {
                 $content = $this->wrap($content, $conf['fontTag']);
             }
             if ($conf['addParams.']) {
                 $content = $this->addParams($content, $conf['addParams.']);
             }
             if ($conf['textStyle.']) {
                 $content = $this->textStyle($content, $conf['textStyle.']);
             }
             if ($conf['tableStyle.']) {
                 $content = $this->tableStyle($content, $conf['tableStyle.']);
             }
             if ($conf['filelink.']) {
                 $content = $this->filelink($content, $conf['filelink.']);
             }
             if ($conf['preCObject']) {
                 $content = $this->cObjGetSingle($conf['preCObject'], $conf['preCObject.'], '/stdWrap/.preCObject') . $content;
             }
             if ($conf['postCObject']) {
                 $content .= $this->cObjGetSingle($conf['postCObject'], $conf['postCObject.'], '/stdWrap/.postCObject');
             }
             if ($conf['wrapAlign'] || $conf['wrapAlign.']) {
                 $wrapAlign = trim($this->stdWrap($conf['wrapAlign'], $conf['wrapAlign.']));
                 if ($wrapAlign) {
                     $content = $this->wrap($content, '<div style="text-align:' . $wrapAlign . ';">|</div>');
                 }
             }
             if ($conf['typolink.']) {
                 $content = $this->typolink($content, $conf['typolink.']);
             }
             if (is_array($conf['TCAselectItem.'])) {
                 $content = $this->TCAlookup($content, $conf['TCAselectItem.']);
             }
             // Spacing
             if ($conf['space'] || $conf['space.']) {
                 $space = trim($this->stdWrap($conf['space'], $conf['space.']));
                 $content = $this->wrapSpace($content, $space, $conf['space.']);
             }
             $spaceBefore = '';
             if ($conf['spaceBefore'] || $conf['spaceBefore.']) {
                 $spaceBefore = trim($this->stdWrap($conf['spaceBefore'], $conf['spaceBefore.']));
             }
             $spaceAfter = '';
             if ($conf['spaceAfter'] || $conf['spaceAfter.']) {
                 $spaceAfter = trim($this->stdWrap($conf['spaceAfter'], $conf['spaceAfter.']));
             }
             if ($spaceBefore || $spaceAfter) {
                 $content = $this->wrapSpace($content, $spaceBefore . '|' . $spaceAfter, $conf['space.']);
             }
             // Wraps
             if ($conf['wrap']) {
                 $content = $this->wrap($content, $conf['wrap'], $conf['wrap.']['splitChar'] ? $conf['wrap.']['splitChar'] : '|');
             }
             if ($conf['noTrimWrap']) {
                 $content = $this->noTrimWrap($content, $conf['noTrimWrap']);
             }
             if ($conf['wrap2']) {
                 $content = $this->wrap($content, $conf['wrap2'], $conf['wrap2.']['splitChar'] ? $conf['wrap2.']['splitChar'] : '|');
             }
             if ($conf['dataWrap']) {
                 $content = $this->dataWrap($content, $conf['dataWrap']);
             }
             if ($conf['prepend']) {
                 $content = $this->cObjGetSingle($conf['prepend'], $conf['prepend.'], '/stdWrap/.prepend') . $content;
             }
             if ($conf['append']) {
                 $content .= $this->cObjGetSingle($conf['append'], $conf['append.'], '/stdWrap/.append');
             }
             if ($conf['wrap3']) {
                 $content = $this->wrap($content, $conf['wrap3'], $conf['wrap3.']['splitChar'] ? $conf['wrap3.']['splitChar'] : '|');
             }
             if ($conf['outerWrap'] || $conf['outerWrap.']) {
                 $content = $this->wrap($content, $this->stdWrap($conf['outerWrap'], $conf['outerWrap.']));
             }
             if ($conf['insertData']) {
                 $content = $this->insertData($content);
             }
             if ($conf['offsetWrap']) {
                 $controlTable = t3lib_div::makeInstance('tslib_tableOffset');
                 if ($conf['offsetWrap.']['tableParams'] || $conf['offsetWrap.']['tableParams.']) {
                     $controlTable->tableParams = $this->stdWrap($conf['offsetWrap.']['tableParams'], $conf['offsetWrap.']['tableParams.']);
                 }
                 if ($conf['offsetWrap.']['tdParams'] || $conf['offsetWrap.']['tdParams.']) {
                     $controlTable->tdParams = ' ' . $this->stdWrap($conf['offsetWrap.']['tdParams'], $conf['offsetWrap.']['tdParams.']);
                 }
                 $content = $controlTable->start($content, $conf['offsetWrap']);
                 if ($conf['offsetWrap.']['stdWrap.']) {
                     $content = $this->stdWrap($content, $conf['offsetWrap.']['stdWrap.']);
                 }
             }
             if ($conf['postUserFunc']) {
                 $content = $this->callUserFunction($conf['postUserFunc'], $conf['postUserFunc.'], $content);
             }
             if ($conf['postUserFuncInt']) {
                 $substKey = 'INT_SCRIPT.' . $GLOBALS['TSFE']->uniqueHash();
                 $GLOBALS['TSFE']->config['INTincScript'][$substKey] = array('content' => $content, 'postUserFunc' => $conf['postUserFuncInt'], 'conf' => $conf['postUserFuncInt.'], 'type' => 'POSTUSERFUNC', 'cObj' => serialize($this));
                 $content = '<!--' . $substKey . '-->';
             }
             // Various:
             if ($conf['prefixComment'] && !$GLOBALS['TSFE']->config['config']['disablePrefixComment']) {
                 $content = $this->prefixComment($conf['prefixComment'], $conf['prefixComment.'], $content);
             }
             if ($conf['editIcons'] && $GLOBALS['TSFE']->beUserLogin) {
                 $content = $this->editIcons($content, $conf['editIcons'], $conf['editIcons.']);
             }
             if ($conf['editPanel'] && $GLOBALS['TSFE']->beUserLogin) {
                 $content = $this->editPanel($content, $conf['editPanel.']);
             }
         }
         foreach ($this->stdWrapHookObjects as $hookObject) {
             $content = $hookObject->stdWrapPostProcess($content, $conf, $this);
         }
         //Debug:
         if ($conf['debug']) {
             $content = '<pre>' . htmlspecialchars($content) . '</pre>';
         }
         if ($conf['debugFunc']) {
             debug($conf['debugFunc'] == 2 ? array($content) : $content);
         }
         if ($conf['debugData']) {
             echo '<strong>$cObj->data:</strong>';
             debug($this->data, '$cObj->data:');
             if (is_array($this->alternativeData)) {
                 echo '<strong>$cObj->alternativeData:</strong>';
                 debug($this->alternativeData, '$this->alternativeData');
             }
         }
     }
     return $content;
 }
 /**
  * Rendering the cObject, FORM
  *
  * Note on $formData:
  * In the optional $formData array each entry represents a line in the ordinary setup.
  * In those entries each entry (0,1,2...) represents a space normally divided by the '|' line.
  *
  * $formData [] = array('Name:', 'name=input, 25 ', 'Default value....');
  * $formData [] = array('Email:', 'email=input, 25 ', 'Default value for email....');
  *
  * - corresponds to the $conf['data'] value being :
  * Name:|name=input, 25 |Default value....||Email:|email=input, 25 |Default value for email....
  *
  * If $formData is an array the value of $conf['data'] is ignored.
  *
  * @param	array		Array of TypoScript properties
  * @param	array		Alternative formdata overriding whatever comes from TypoScript
  * @return	string		Output
  */
 public function render($conf = array(), $formData = '')
 {
     $content = '';
     if (is_array($formData)) {
         $dataArray = $formData;
     } else {
         $data = isset($conf['data.']) ? $this->cObj->stdWrap($conf['data'], $conf['data.']) : $conf['data'];
         // Clearing dataArr
         $dataArray = array();
         // Getting the original config
         if (trim($data)) {
             $data = str_replace(LF, '||', $data);
             $dataArray = explode('||', $data);
         }
         // Adding the new dataArray config form:
         if (is_array($conf['dataArray.'])) {
             // dataArray is supplied
             $sortedKeyArray = t3lib_TStemplate::sortedKeyList($conf['dataArray.'], TRUE);
             foreach ($sortedKeyArray as $theKey) {
                 $singleKeyArray = $conf['dataArray.'][$theKey . '.'];
                 if (is_array($singleKeyArray)) {
                     $temp = array();
                     $label = isset($singleKeyArray['label.']) ? $this->cObj->stdWrap($singleKeyArray['label'], $singleKeyArray['label.']) : $singleKeyArray['label'];
                     list($temp[0]) = explode('|', $label);
                     $type = isset($singleKeyArray['type.']) ? $this->cObj->stdWrap($singleKeyArray['type'], $singleKeyArray['type.']) : $singleKeyArray['type'];
                     list($temp[1]) = explode('|', $type);
                     $required = isset($singleKeyArray['required.']) ? $this->cObj->stdWrap($singleKeyArray['required'], $singleKeyArray['required.']) : $singleKeyArray['required'];
                     if ($required) {
                         $temp[1] = '*' . $temp[1];
                     }
                     $singleValue = isset($singleKeyArray['value.']) ? $this->cObj->stdWrap($singleKeyArray['value'], $singleKeyArray['value.']) : $singleKeyArray['value'];
                     list($temp[2]) = explode('|', $singleValue);
                     // If value array is set, then implode those values.
                     if (is_array($singleKeyArray['valueArray.'])) {
                         $temp_accumulated = array();
                         foreach ($singleKeyArray['valueArray.'] as $singleKey => $singleKey_valueArray) {
                             if (is_array($singleKey_valueArray) && !strcmp(intval($singleKey) . '.', $singleKey)) {
                                 $temp_valueArray = array();
                                 $valueArrayLabel = isset($singleKey_valueArray['label.']) ? $this->cObj->stdWrap($singleKey_valueArray['label'], $singleKey_valueArray['label.']) : $singleKey_valueArray['label'];
                                 list($temp_valueArray[0]) = explode('=', $valueArrayLabel);
                                 $selected = isset($singleKeyArray['selected.']) ? $this->cObj->stdWrap($singleKeyArray['selected'], $singleKeyArray['selected.']) : $singleKeyArray['selected'];
                                 if ($selected) {
                                     $temp_valueArray[0] = '*' . $temp_valueArray[0];
                                 }
                                 $singleKeyValue = isset($singleKey_valueArray['value.']) ? $this->cObj->stdWrap($singleKey_valueArray['value'], $singleKey_valueArray['value.']) : $singleKey_valueArray['value'];
                                 list($temp_valueArray[1]) = explode(',', $singleKeyValue);
                             }
                             $temp_accumulated[] = implode('=', $temp_valueArray);
                         }
                         $temp[2] = implode(',', $temp_accumulated);
                     }
                     $specialEval = isset($singleKeyArray['specialEval.']) ? $this->cObj->stdWrap($singleKeyArray['specialEval'], $singleKeyArray['specialEval.']) : $singleKeyArray['specialEval'];
                     list($temp[3]) = explode('|', $specialEval);
                     // adding the form entry to the dataArray
                     $dataArray[] = implode('|', $temp);
                 }
             }
         }
     }
     $attachmentCounter = '';
     $hiddenfields = '';
     $fieldlist = array();
     $propertyOverride = array();
     $fieldname_hashArray = array();
     $counter = 0;
     $xhtmlStrict = t3lib_div::inList('xhtml_strict,xhtml_11,xhtml_2', $GLOBALS['TSFE']->xhtmlDoctype);
     // Formname
     $formName = isset($conf['formName.']) ? $this->cObj->stdWrap($conf['formName'], $conf['formName.']) : $conf['formName'];
     if ($formName) {
         $formName = $this->cObj->cleanFormName($formName);
     } else {
         $formName = 'a' . $GLOBALS['TSFE']->uniqueHash();
         // form name has to start with a letter to reach XHTML compliance
     }
     $fieldPrefix = isset($conf['fieldPrefix.']) ? $this->cObj->stdWrap($conf['fieldPrefix'], $conf['fieldPrefix.']) : $conf['fieldPrefix'];
     if (isset($conf['fieldPrefix']) || isset($conf['fieldPrefix.'])) {
         if ($fieldPrefix) {
             $prefix = $this->cObj->cleanFormName($fieldPrefix);
         } else {
             $prefix = '';
         }
     } else {
         $prefix = $formName;
     }
     foreach ($dataArray as $dataValue) {
         $counter++;
         $confData = array();
         if (is_array($formData)) {
             $parts = $dataValue;
             $dataValue = 1;
             // TRUE...
         } else {
             $dataValue = trim($dataValue);
             $parts = explode('|', $dataValue);
         }
         if ($dataValue && strcspn($dataValue, '#/')) {
             // label:
             $confData['label'] = t3lib_div::removeXSS(trim($parts[0]));
             // field:
             $fParts = explode(',', $parts[1]);
             $fParts[0] = trim($fParts[0]);
             if (substr($fParts[0], 0, 1) == '*') {
                 $confData['required'] = 1;
                 $fParts[0] = substr($fParts[0], 1);
             }
             $typeParts = explode('=', $fParts[0]);
             $confData['type'] = trim(strtolower(end($typeParts)));
             if (count($typeParts) == 1) {
                 $confData['fieldname'] = $this->cObj->cleanFormName($parts[0]);
                 if (strtolower(preg_replace('/[^[:alnum:]]/', '', $confData['fieldname'])) == 'email') {
                     $confData['fieldname'] = 'email';
                 }
                 // Duplicate fieldnames resolved
                 if (isset($fieldname_hashArray[md5($confData['fieldname'])])) {
                     $confData['fieldname'] .= '_' . $counter;
                 }
                 $fieldname_hashArray[md5($confData['fieldname'])] = $confData['fieldname'];
                 // Attachment names...
                 if ($confData['type'] == 'file') {
                     $confData['fieldname'] = 'attachment' . $attachmentCounter;
                     $attachmentCounter = intval($attachmentCounter) + 1;
                 }
             } else {
                 $confData['fieldname'] = str_replace(' ', '_', trim($typeParts[0]));
             }
             $confData['fieldname'] = htmlspecialchars($confData['fieldname']);
             $fieldCode = '';
             $wrapFieldName = isset($conf['wrapFieldName']) ? $this->cObj->stdWrap($conf['wrapFieldName'], $conf['wrapFieldName.']) : $conf['wrapFieldName'];
             if ($wrapFieldName) {
                 $confData['fieldname'] = $this->cObj->wrap($confData['fieldname'], $wrapFieldName);
             }
             // Set field name as current:
             $this->cObj->setCurrentVal($confData['fieldname']);
             // Additional parameters
             if (trim($confData['type'])) {
                 if (isset($conf['params.'][$confData['type']])) {
                     $addParams = isset($conf['params.'][$confData['type'] . '.']) ? trim($this->cObj->stdWrap($conf['params.'][$confData['type']], $conf['params.'][$confData['type'] . '.'])) : trim($conf['params.'][$confData['type']]);
                 } else {
                     $addParams = isset($conf['params.']) ? trim($this->cObj->stdWrap($conf['params'], $conf['params.'])) : trim($conf['params']);
                 }
                 if (strcmp('', $addParams)) {
                     $addParams = ' ' . $addParams;
                 }
             } else {
                 $addParams = '';
             }
             $dontMd5FieldNames = isset($conf['dontMd5FieldNames.']) ? $this->cObj->stdWrap($conf['dontMd5FieldNames'], $conf['dontMd5FieldNames.']) : $conf['dontMd5FieldNames'];
             if ($dontMd5FieldNames) {
                 $fName = $confData['fieldname'];
             } else {
                 $fName = md5($confData['fieldname']);
             }
             // Accessibility: Set id = fieldname attribute:
             $accessibility = isset($conf['accessibility.']) ? $this->cObj->stdWrap($conf['accessibility'], $conf['accessibility.']) : $conf['accessibility'];
             if ($accessibility || $xhtmlStrict) {
                 $elementIdAttribute = ' id="' . $prefix . $fName . '"';
             } else {
                 $elementIdAttribute = '';
             }
             // Create form field based on configuration/type:
             switch ($confData['type']) {
                 case 'textarea':
                     $cols = trim($fParts[1]) ? intval($fParts[1]) : 20;
                     $compensateFieldWidth = isset($conf['compensateFieldWidth.']) ? $this->cObj->stdWrap($conf['compensateFieldWidth'], $conf['compensateFieldWidth.']) : $conf['compensateFieldWidth'];
                     $compWidth = doubleval($compensateFieldWidth ? $compensateFieldWidth : $GLOBALS['TSFE']->compensateFieldWidth);
                     $compWidth = $compWidth ? $compWidth : 1;
                     $cols = t3lib_div::intInRange($cols * $compWidth, 1, 120);
                     $rows = trim($fParts[2]) ? t3lib_div::intInRange($fParts[2], 1, 30) : 5;
                     $wrap = trim($fParts[3]);
                     $noWrapAttr = isset($conf['noWrapAttr.']) ? $this->cObj->stdWrap($conf['noWrapAttr'], $conf['noWrapAttr.']) : $conf['noWrapAttr'];
                     if ($noWrapAttr || $wrap === 'disabled') {
                         $wrap = '';
                     } else {
                         $wrap = $wrap ? ' wrap="' . $wrap . '"' : ' wrap="virtual"';
                     }
                     $noValueInsert = isset($conf['noValueInsert.']) ? $this->cObj->stdWrap($conf['noValueInsert'], $conf['noValueInsert.']) : $conf['noValueInsert'];
                     $default = $this->cObj->getFieldDefaultValue($noValueInsert, $confData['fieldname'], str_replace('\\n', LF, trim($parts[2])));
                     $fieldCode = sprintf('<textarea name="%s"%s cols="%s" rows="%s"%s%s>%s</textarea>', $confData['fieldname'], $elementIdAttribute, $cols, $rows, $wrap, $addParams, t3lib_div::formatForTextarea($default));
                     break;
                 case 'input':
                 case 'password':
                     $size = trim($fParts[1]) ? intval($fParts[1]) : 20;
                     $compensateFieldWidth = isset($conf['compensateFieldWidth.']) ? $this->cObj->stdWrap($conf['compensateFieldWidth'], $conf['compensateFieldWidth.']) : $conf['compensateFieldWidth'];
                     $compWidth = doubleval($compensateFieldWidth ? $compensateFieldWidth : $GLOBALS['TSFE']->compensateFieldWidth);
                     $compWidth = $compWidth ? $compWidth : 1;
                     $size = t3lib_div::intInRange($size * $compWidth, 1, 120);
                     $noValueInsert = isset($conf['noValueInsert.']) ? $this->cObj->stdWrap($conf['noValueInsert'], $conf['noValueInsert.']) : $conf['noValueInsert'];
                     $default = $this->cObj->getFieldDefaultValue($noValueInsert, $confData['fieldname'], trim($parts[2]));
                     if ($confData['type'] == 'password') {
                         $default = '';
                     }
                     $max = trim($fParts[2]) ? ' maxlength="' . t3lib_div::intInRange($fParts[2], 1, 1000) . '"' : "";
                     $theType = $confData['type'] == 'input' ? 'text' : 'password';
                     $fieldCode = sprintf('<input type="%s" name="%s"%s size="%s"%s value="%s"%s />', $theType, $confData['fieldname'], $elementIdAttribute, $size, $max, htmlspecialchars($default), $addParams);
                     break;
                 case 'file':
                     $size = trim($fParts[1]) ? t3lib_div::intInRange($fParts[1], 1, 60) : 20;
                     $fieldCode = sprintf('<input type="file" name="%s"%s size="%s"%s />', $confData['fieldname'], $elementIdAttribute, $size, $addParams);
                     break;
                 case 'check':
                     // alternative default value:
                     $noValueInsert = isset($conf['noValueInsert.']) ? $this->cObj->stdWrap($conf['noValueInsert'], $conf['noValueInsert.']) : $conf['noValueInsert'];
                     $default = $this->cObj->getFieldDefaultValue($noValueInsert, $confData['fieldname'], trim($parts[2]));
                     $checked = $default ? ' checked="checked"' : '';
                     $fieldCode = sprintf('<input type="checkbox" value="%s" name="%s"%s%s%s />', 1, $confData['fieldname'], $elementIdAttribute, $checked, $addParams);
                     break;
                 case 'select':
                     $option = '';
                     $valueParts = explode(',', $parts[2]);
                     // size
                     if (strtolower(trim($fParts[1])) == 'auto') {
                         $fParts[1] = count($valueParts);
                     }
                     // Auto size set here. Max 20
                     $size = trim($fParts[1]) ? t3lib_div::intInRange($fParts[1], 1, 20) : 1;
                     // multiple
                     $multiple = strtolower(trim($fParts[2])) == 'm' ? ' multiple="multiple"' : '';
                     $items = array();
                     // Where the items will be
                     $defaults = array();
                     //RTF
                     $pCount = count($valueParts);
                     for ($a = 0; $a < $pCount; $a++) {
                         $valueParts[$a] = trim($valueParts[$a]);
                         if (substr($valueParts[$a], 0, 1) == '*') {
                             // Finding default value
                             $sel = 'selected';
                             $valueParts[$a] = substr($valueParts[$a], 1);
                         } else {
                             $sel = '';
                         }
                         // Get value/label
                         $subParts = explode('=', $valueParts[$a]);
                         $subParts[1] = isset($subParts[1]) ? trim($subParts[1]) : trim($subParts[0]);
                         // Sets the value
                         $items[] = $subParts;
                         // Adds the value/label pair to the items-array
                         if ($sel) {
                             $defaults[] = $subParts[1];
                         }
                         // Sets the default value if value/label pair is marked as default.
                     }
                     // alternative default value:
                     $noValueInsert = isset($conf['noValueInsert.']) ? $this->cObj->stdWrap($conf['noValueInsert'], $conf['noValueInsert.']) : $conf['noValueInsert'];
                     $default = $this->cObj->getFieldDefaultValue($noValueInsert, $confData['fieldname'], $defaults);
                     if (!is_array($default)) {
                         $defaults = array();
                         $defaults[] = $default;
                     } else {
                         $defaults = $default;
                     }
                     // Create the select-box:
                     $iCount = count($items);
                     for ($a = 0; $a < $iCount; $a++) {
                         $option .= '<option value="' . $items[$a][1] . '"' . (in_array($items[$a][1], $defaults) ? ' selected="selected"' : '') . '>' . trim($items[$a][0]) . '</option>';
                         //RTF
                     }
                     if ($multiple) {
                         // The fieldname must be prepended '[]' if multiple select. And the reason why it's prepended is, because the required-field list later must also have [] prepended.
                         $confData['fieldname'] .= '[]';
                     }
                     $fieldCode = sprintf('<select name="%s"%s size="%s"%s%s>%s</select>', $confData['fieldname'], $elementIdAttribute, $size, $multiple, $addParams, $option);
                     //RTF
                     break;
                 case 'radio':
                     $option = '';
                     $valueParts = explode(',', $parts[2]);
                     $items = array();
                     // Where the items will be
                     $default = '';
                     $pCount = count($valueParts);
                     for ($a = 0; $a < $pCount; $a++) {
                         $valueParts[$a] = trim($valueParts[$a]);
                         if (substr($valueParts[$a], 0, 1) == '*') {
                             $sel = 'checked';
                             $valueParts[$a] = substr($valueParts[$a], 1);
                         } else {
                             $sel = '';
                         }
                         // Get value/label
                         $subParts = explode('=', $valueParts[$a]);
                         $subParts[1] = isset($subParts[1]) ? trim($subParts[1]) : trim($subParts[0]);
                         // Sets the value
                         $items[] = $subParts;
                         // Adds the value/label pair to the items-array
                         if ($sel) {
                             $default = $subParts[1];
                         }
                         // Sets the default value if value/label pair is marked as default.
                     }
                     // alternative default value:
                     $noValueInsert = isset($conf['noValueInsert.']) ? $this->cObj->stdWrap($conf['noValueInsert'], $conf['noValueInsert.']) : $conf['noValueInsert'];
                     $default = $this->cObj->getFieldDefaultValue($noValueInsert, $confData['fieldname'], $default);
                     // Create the select-box:
                     $iCount = count($items);
                     for ($a = 0; $a < $iCount; $a++) {
                         $optionParts = '';
                         $radioId = $prefix . $fName . $this->cObj->cleanFormName($items[$a][0]);
                         if ($accessibility) {
                             $radioLabelIdAttribute = ' id="' . $radioId . '"';
                         } else {
                             $radioLabelIdAttribute = '';
                         }
                         $optionParts .= '<input type="radio" name="' . $confData['fieldname'] . '"' . $radioLabelIdAttribute . ' value="' . $items[$a][1] . '"' . (!strcmp($items[$a][1], $default) ? ' checked="checked"' : '') . $addParams . ' />';
                         if ($accessibility) {
                             $label = isset($conf['radioWrap.']) ? $this->cObj->stdWrap(trim($items[$a][0]), $conf['radioWrap.']) : trim($items[$a][0]);
                             $optionParts .= '<label for="' . $radioId . '">' . $label . '</label>';
                         } else {
                             $optionParts .= isset($conf['radioWrap.']) ? $this->cObj->stdWrap(trim($items[$a][0]), $conf['radioWrap.']) : trim($items[$a][0]);
                         }
                         $option .= isset($conf['radioInputWrap.']) ? $this->cObj->stdWrap($optionParts, $conf['radioInputWrap.']) : $optionParts;
                     }
                     if ($accessibility) {
                         $accessibilityWrap = isset($conf['radioWrap.']['accessibilityWrap.']) ? $this->cObj->stdWrap($conf['radioWrap.']['accessibilityWrap'], $conf['radioWrap.']['accessibilityWrap.']) : $conf['radioWrap.']['accessibilityWrap.'];
                         if ($accessibilityWrap) {
                             $search = array('###RADIO_FIELD_ID###', '###RADIO_GROUP_LABEL###');
                             $replace = array($elementIdAttribute, $confData['label']);
                             $accessibilityWrap = str_replace($search, $replace, $accessibilityWrap);
                             $option = $this->cObj->wrap($option, $accessibilityWrap);
                         }
                     }
                     $fieldCode = $option;
                     break;
                 case 'hidden':
                     $value = trim($parts[2]);
                     // If this form includes an auto responder message, include a HMAC checksum field
                     // in order to verify potential abuse of this feature.
                     if (strlen($value) && t3lib_div::inList($confData['fieldname'], 'auto_respond_msg')) {
                         $hmacChecksum = t3lib_div::hmac($value);
                         $hiddenfields .= sprintf('<input type="hidden" name="auto_respond_checksum" id="%sauto_respond_checksum" value="%s" />', $prefix, $hmacChecksum);
                     }
                     if (strlen($value) && t3lib_div::inList('recipient_copy,recipient', $confData['fieldname']) && $GLOBALS['TYPO3_CONF_VARS']['FE']['secureFormmail']) {
                         break;
                     }
                     if (strlen($value) && t3lib_div::inList('recipient_copy,recipient', $confData['fieldname'])) {
                         $value = $GLOBALS['TSFE']->codeString($value);
                     }
                     $hiddenfields .= sprintf('<input type="hidden" name="%s"%s value="%s" />', $confData['fieldname'], $elementIdAttribute, htmlspecialchars($value));
                     break;
                 case 'property':
                     if (t3lib_div::inList('type,locationData,goodMess,badMess,emailMess', $confData['fieldname'])) {
                         $value = trim($parts[2]);
                         $propertyOverride[$confData['fieldname']] = $value;
                         $conf[$confData['fieldname']] = $value;
                     }
                     break;
                 case 'submit':
                     $value = trim($parts[2]);
                     if ($conf['image.']) {
                         $this->cObj->data[$this->cObj->currentValKey] = $value;
                         $image = $this->cObj->IMG_RESOURCE($conf['image.']);
                         $params = $conf['image.']['params'] ? ' ' . $conf['image.']['params'] : '';
                         $params .= $this->cObj->getAltParam($conf['image.'], FALSE);
                         $params .= $addParams;
                     } else {
                         $image = '';
                     }
                     if ($image) {
                         $fieldCode = sprintf('<input type="image" name="%s"%s src="%s"%s />', $confData['fieldname'], $elementIdAttribute, $image, $params);
                     } else {
                         $fieldCode = sprintf('<input type="submit" name="%s"%s value="%s"%s />', $confData['fieldname'], $elementIdAttribute, t3lib_div::deHSCentities(htmlspecialchars($value)), $addParams);
                     }
                     break;
                 case 'reset':
                     $value = trim($parts[2]);
                     $fieldCode = sprintf('<input type="reset" name="%s"%s value="%s"%s />', $confData['fieldname'], $elementIdAttribute, t3lib_div::deHSCentities(htmlspecialchars($value)), $addParams);
                     break;
                 case 'label':
                     $fieldCode = nl2br(htmlspecialchars(trim($parts[2])));
                     break;
                 default:
                     $confData['type'] = 'comment';
                     $fieldCode = trim($parts[2]) . '&nbsp;';
                     break;
             }
             if ($fieldCode) {
                 // Checking for special evaluation modes:
                 if (t3lib_div::inList('textarea,input,password', $confData['type']) && strlen(trim($parts[3]))) {
                     $modeParameters = t3lib_div::trimExplode(':', $parts[3]);
                 } else {
                     $modeParameters = array();
                 }
                 // Adding evaluation based on settings:
                 switch ((string) $modeParameters[0]) {
                     case 'EREG':
                         $fieldlist[] = '_EREG';
                         $fieldlist[] = $modeParameters[1];
                         $fieldlist[] = $modeParameters[2];
                         $fieldlist[] = $confData['fieldname'];
                         $fieldlist[] = $confData['label'];
                         $confData['required'] = 1;
                         // Setting this so "required" layout is used.
                         break;
                     case 'EMAIL':
                         $fieldlist[] = '_EMAIL';
                         $fieldlist[] = $confData['fieldname'];
                         $fieldlist[] = $confData['label'];
                         $confData['required'] = 1;
                         // Setting this so "required" layout is used.
                         break;
                     default:
                         if ($confData['required']) {
                             $fieldlist[] = $confData['fieldname'];
                             $fieldlist[] = $confData['label'];
                         }
                         break;
                 }
                 // Field:
                 $fieldLabel = $confData['label'];
                 if ($accessibility && trim($fieldLabel) && !preg_match('/^(label|hidden|comment)$/', $confData['type'])) {
                     $fieldLabel = '<label for="' . $prefix . $fName . '">' . $fieldLabel . '</label>';
                 }
                 // Getting template code:
                 if (isset($conf['fieldWrap.'])) {
                     $fieldCode = $this->cObj->stdWrap($fieldCode, $conf['fieldWrap.']);
                 }
                 $labelCode = isset($conf['labelWrap.']) ? $this->cObj->stdWrap($fieldLabel, $conf['labelWrap.']) : $fieldLabel;
                 $commentCode = isset($conf['commentWrap.']) ? $this->cObj->stdWrap($confData['label'], $conf['commentWrap.']) : $confData['label'];
                 $result = $conf['layout'];
                 $req = isset($conf['REQ.']) ? $this->cObj->stdWrap($conf['REQ'], $conf['REQ.']) : $conf['REQ'];
                 if ($req && $confData['required']) {
                     if (isset($conf['REQ.']['fieldWrap.'])) {
                         $fieldCode = $this->cObj->stdWrap($fieldCode, $conf['REQ.']['fieldWrap.']);
                     }
                     if (isset($conf['REQ.']['labelWrap.'])) {
                         $labelCode = $this->cObj->stdWrap($fieldLabel, $conf['REQ.']['labelWrap.']);
                     }
                     $reqLayout = isset($conf['REQ.']['layout.']) ? $this->cObj->stdWrap($conf['REQ.']['layout'], $conf['REQ.']['layout.']) : $conf['REQ.']['layout'];
                     if ($reqLayout) {
                         $result = $reqLayout;
                     }
                 }
                 if ($confData['type'] == 'comment') {
                     $commentLayout = isset($conf['COMMENT.']['layout.']) ? $this->cObj->stdWrap($conf['COMMENT.']['layout'], $conf['COMMENT.']['layout.']) : $conf['COMMENT.']['layout'];
                     if ($commentLayout) {
                         $result = $commentLayout;
                     }
                 }
                 if ($confData['type'] == 'check') {
                     $checkLayout = isset($conf['CHECK.']['layout.']) ? $this->cObj->stdWrap($conf['CHECK.']['layout'], $conf['CHECK.']['layout.']) : $conf['CHECK.']['layout'];
                     if ($checkLayout) {
                         $result = $checkLayout;
                     }
                 }
                 if ($confData['type'] == 'radio') {
                     $radioLayout = isset($conf['RADIO.']['layout.']) ? $this->cObj->stdWrap($conf['RADIO.']['layout'], $conf['RADIO.']['layout.']) : $conf['RADIO.']['layout'];
                     if ($radioLayout) {
                         $result = $radioLayout;
                     }
                 }
                 if ($confData['type'] == 'label') {
                     $labelLayout = isset($conf['LABEL.']['layout.']) ? $this->cObj->stdWrap($conf['LABEL.']['layout'], $conf['LABEL.']['layout.']) : $conf['CHECK.']['layout'];
                     if ($labelLayout) {
                         $result = $labelLayout;
                     }
                 }
                 $result = str_replace('###FIELD###', $fieldCode, $result);
                 $result = str_replace('###LABEL###', $labelCode, $result);
                 $result = str_replace('###COMMENT###', $commentCode, $result);
                 //RTF
                 $content .= $result;
             }
         }
     }
     if (isset($conf['stdWrap.'])) {
         $content = $this->cObj->stdWrap($content, $conf['stdWrap.']);
     }
     // redirect (external: where to go afterwards. internal: where to submit to)
     $theRedirect = isset($conf['redirect.']) ? $this->cObj->stdWrap($conf['redirect'], $conf['redirect.']) : $conf['redirect'];
     // redirect should be set to the page to redirect to after an external script has been used. If internal scripts is used, and if no 'type' is set that dictates otherwise, redirect is used as the url to jump to as long as it's an integer (page)
     $target = isset($conf['target.']) ? $this->cObj->stdWrap($conf['target'], $conf['target.']) : $conf['target'];
     // redirect should be set to the page to redirect to after an external script has been used. If internal scripts is used, and if no 'type' is set that dictates otherwise, redirect is used as the url to jump to as long as it's an integer (page)
     $noCache = isset($conf['no_cache.']) ? $this->cObj->stdWrap($conf['no_cache'], $conf['no_cache.']) : $conf['no_cache'];
     // redirect should be set to the page to redirect to after an external script has been used. If internal scripts is used, and if no 'type' is set that dictates otherwise, redirect is used as the url to jump to as long as it's an integer (page)
     $page = $GLOBALS['TSFE']->page;
     if (!$theRedirect) {
         // Internal: Just submit to current page
         $LD = $GLOBALS['TSFE']->tmpl->linkData($page, $target, $noCache, 'index.php', '', $this->cObj->getClosestMPvalueForPage($page['uid']));
     } elseif (t3lib_div::testInt($theRedirect)) {
         // Internal: Submit to page with ID $theRedirect
         $page = $GLOBALS['TSFE']->sys_page->getPage_noCheck($theRedirect);
         $LD = $GLOBALS['TSFE']->tmpl->linkData($page, $target, $noCache, 'index.php', '', $this->cObj->getClosestMPvalueForPage($page['uid']));
     } else {
         // External URL, redirect-hidden field is rendered!
         $LD = $GLOBALS['TSFE']->tmpl->linkData($page, $target, $noCache, '', '', $this->cObj->getClosestMPvalueForPage($page['uid']));
         $LD['totalURL'] = $theRedirect;
         $hiddenfields .= '<input type="hidden" name="redirect" value="' . htmlspecialchars($LD['totalURL']) . '" />';
         // 18-09-00 added
     }
     // Formtype (where to submit to!):
     if ($propertyOverride['type']) {
         $formtype = $propertyOverride['type'];
     } else {
         $formtype = isset($conf['type.']) ? $this->cObj->stdWrap($conf['type'], $conf['type.']) : $conf['type'];
     }
     if (t3lib_div::testInt($formtype)) {
         // Submit to a specific page
         $page = $GLOBALS['TSFE']->sys_page->getPage_noCheck($formtype);
         $LD_A = $GLOBALS['TSFE']->tmpl->linkData($page, $target, $noCache, '', '', $this->cObj->getClosestMPvalueForPage($page['uid']));
         $action = $LD_A['totalURL'];
     } elseif ($formtype) {
         // Submit to external script
         $LD_A = $LD;
         $action = $formtype;
     } elseif (t3lib_div::testInt($theRedirect)) {
         $LD_A = $LD;
         $action = $LD_A['totalURL'];
     } else {
         // Submit to "nothing" - which is current page
         $LD_A = $GLOBALS['TSFE']->tmpl->linkData($GLOBALS['TSFE']->page, $target, $noCache, '', '', $this->cObj->getClosestMPvalueForPage($page['uid']));
         $action = $LD_A['totalURL'];
     }
     // Recipient:
     $theEmail = isset($conf['recipient.']) ? $this->cObj->stdWrap($conf['recipient'], $conf['recipient.']) : $conf['recipient'];
     if ($theEmail && !$GLOBALS['TYPO3_CONF_VARS']['FE']['secureFormmail']) {
         $theEmail = $GLOBALS['TSFE']->codeString($theEmail);
         $hiddenfields .= '<input type="hidden" name="recipient" value="' . htmlspecialchars($theEmail) . '" />';
     }
     // location data:
     $location = isset($conf['locationData.']) ? $this->cObj->stdWrap($conf['locationData'], $conf['locationData.']) : $conf['locationData'];
     if ($location) {
         if ($location == 'HTTP_POST_VARS' && isset($_POST['locationData'])) {
             $locationData = t3lib_div::_POST('locationData');
         } else {
             // locationData is [hte page id]:[tablename]:[uid of record]. Indicates on which page the record (from tablename with uid) is shown. Used to check access.
             $locationData = $GLOBALS['TSFE']->id . ':' . $this->cObj->currentRecord;
         }
         $hiddenfields .= '<input type="hidden" name="locationData" value="' . htmlspecialchars($locationData) . '" />';
     }
     // hidden fields:
     if (is_array($conf['hiddenFields.'])) {
         foreach ($conf['hiddenFields.'] as $hF_key => $hF_conf) {
             if (substr($hF_key, -1) != '.') {
                 $hF_value = $this->cObj->cObjGetSingle($hF_conf, $conf['hiddenFields.'][$hF_key . '.'], 'hiddenfields');
                 if (strlen($hF_value) && t3lib_div::inList('recipient_copy,recipient', $hF_key)) {
                     if ($GLOBALS['TYPO3_CONF_VARS']['FE']['secureFormmail']) {
                         continue;
                     }
                     $hF_value = $GLOBALS['TSFE']->codeString($hF_value);
                 }
                 $hiddenfields .= '<input type="hidden" name="' . $hF_key . '" value="' . htmlspecialchars($hF_value) . '" />';
             }
         }
     }
     // Wrap all hidden fields in a div tag (see http://bugs.typo3.org/view.php?id=678)
     $hiddenfields = isset($conf['hiddenFields.']['stdWrap.']) ? $this->cObj->stdWrap($hiddenfields, $conf['hiddenFields.']['stdWrap.']) : '<div style="display:none;">' . $hiddenfields . '</div>';
     if ($conf['REQ']) {
         $goodMess = isset($conf['goodMess.']) ? $this->cObj->stdWrap($conf['goodMess'], $conf['goodMess.']) : $conf['goodMess'];
         $badMess = isset($conf['badMess.']) ? $this->cObj->stdWrap($conf['badMess'], $conf['badMess.']) : $conf['badMess'];
         $emailMess = isset($conf['emailMess.']) ? $this->cObj->stdWrap($conf['emailMess'], $conf['emailMess.']) : $conf['emailMess'];
         $validateForm = ' onsubmit="return validateForm(\'' . $formName . '\',\'' . implode(',', $fieldlist) . '\',' . t3lib_div::quoteJSvalue($goodMess) . ',' . t3lib_div::quoteJSvalue($badMess) . ',' . t3lib_div::quoteJSvalue($emailMess) . ')"';
         $GLOBALS['TSFE']->additionalHeaderData['JSFormValidate'] = '<script type="text/javascript" src="' . t3lib_div::createVersionNumberedFilename($GLOBALS['TSFE']->absRefPrefix . 't3lib/jsfunc.validateform.js') . '"></script>';
     } else {
         $validateForm = '';
     }
     // Create form tag:
     $theTarget = $theRedirect ? $LD['target'] : $LD_A['target'];
     $method = isset($conf['method.']) ? $this->cObj->stdWrap($conf['method'], $conf['method.']) : $conf['method'];
     $content = array('<form' . ' action="' . htmlspecialchars($action) . '"' . ' id="' . $formName . '"' . ($xhtmlStrict ? '' : ' name="' . $formName . '"') . ' enctype="' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'] . '"' . ' method="' . ($method ? $method : 'post') . '"' . ($theTarget ? ' target="' . $theTarget . '"' : '') . $validateForm . '>', $hiddenfields . $content, '</form>');
     $arrayReturnMode = isset($conf['arrayReturnMode.']) ? $this->cObj->stdWrap($conf['arrayReturnMode'], $conf['arrayReturnMode.']) : $conf['arrayReturnMode'];
     if ($arrayReturnMode) {
         $content['validateForm'] = $validateForm;
         $content['formname'] = $formName;
         return $content;
     } else {
         return implode('', $content);
     }
 }