/**
  * 	 * Adds the tinymce_rte to a textarea
  *
  * @param	object		$parentObject 	Reference to parent object, which is an instance of the TCEforms.
  * @param	string		$table 			The table name
  * @param	string		$field			The field name
  * @param	array		$row			The current row from which field is being rendered
  * @param	array		$PA				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		$specConf		"special" configuration - what is found at position 4 in the types configuration of a field from record, parsed into an array.
  * @param	array		$thisConfig		Configuration for RTEs; A mix between TSconfig and otherwise. Contains configuration for display, which buttons are enabled, additional transformation information etc.
  * @param	string		$RTEtypeVal		Record "type" field value.
  * @param	string		$RTErelPath		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		$thePidValue	PID value of record (true parent page id)
  * @return	string		HTML code for tinymce_rte
  */
 function drawRTE($parentObject, $table, $field, $row, $PA, $specConf, $thisConfig, $RTEtypeVal, $RTErelPath, $thePidValue)
 {
     $pageTSConfig = $GLOBALS['TSFE']->getPagesTSconfig($GLOBALS['TSFE']->id);
     $localRteId = $parentObject->RTEcounter . '.';
     $rteConfig = $pageTSConfig['RTE.']['default.']['FE.'];
     if (is_array($parentObject->conf['tinymce_rte.'][$localRteId])) {
         $tmpConf = $this->array_merge_recursive_override($rteConfig, $parentObject->conf['tinymce_rte.'][$localRteId]);
     } elseif (is_array($parentObject->conf['tinymce_rte.']['1.'])) {
         $tmpConf = $this->array_merge_recursive_override($rteConfig, $parentObject->conf['tinymce_rte.']['1.']);
     } else {
         $tmpConf = $rteConfig;
     }
     // set a uniq rte id.
     $this->rteId = $parentObject->cObj->data['uid'] . $parentObject->RTEcounter;
     $config = $this->init($tmpConf, $this->rteId);
     $row = array('pid' => $GLOBALS['TSFE']->page['uid'], 'ISOcode' => $this->language);
     $config = $this->fixTinyMCETemplates($config, $row);
     if ($parentObject->RTEcounter == 1) {
         $GLOBALS['TSFE']->additionalHeaderData['tinymce_rte'] = $this->getCoreScript($config);
     }
     $code .= $this->getInitScript($config['init.']);
     //loads the current Value and create the textarea
     $value = $this->transformContent('rte', $PA['itemFormElValue'], $table, $field, $row, $specConf, $thisConfig, $RTErelPath, $thePidValue);
     $code .= $this->triggerField($PA['itemFormElName']);
     $code .= '<textarea id="RTEarea' . $this->rteId . '" class="tinymce_rte" name="' . htmlspecialchars($PA['itemFormElName']) . '" rows="30" cols="100">' . t3lib_div::formatForTextarea($value) . '</textarea>';
     return $code;
 }
 /**
  * The main function in the class
  *
  * @return	string		HTML content
  */
 function main()
 {
     $output = 'Enter [table]:[uid]:[fieldlist (optional)] <input name="table_uid" value="' . htmlspecialchars(t3lib_div::_POST('table_uid')) . '" />';
     $output .= '<input type="submit" name="_" value="REFRESH" /><br/>';
     // Show record:
     if (t3lib_div::_POST('table_uid')) {
         list($table, $uid, $fieldName) = t3lib_div::trimExplode(':', t3lib_div::_POST('table_uid'), 1);
         if ($GLOBALS['TCA'][$table]) {
             $rec = t3lib_BEfunc::getRecordRaw($table, 'uid=' . intval($uid), $fieldName ? $fieldName : '*');
             if (count($rec)) {
                 $pidOfRecord = $rec['pid'];
                 $output .= '<input type="checkbox" name="show_path" value="1"' . (t3lib_div::_POST('show_path') ? ' checked="checked"' : '') . '/> Show path and rootline of record<br/>';
                 if (t3lib_div::_POST('show_path')) {
                     $output .= '<br/>Path of PID ' . $pidOfRecord . ': <em>' . t3lib_BEfunc::getRecordPath($pidOfRecord, '', 30) . '</em><br/>';
                     $output .= 'RL:' . Tx_Extdeveval_Compatibility::viewArray(t3lib_BEfunc::BEgetRootLine($pidOfRecord)) . '<br/>';
                     $output .= 'FLAGS:' . ($rec['deleted'] ? ' <b>DELETED</b>' : '') . ($rec['pid'] == -1 ? ' <b>OFFLINE VERSION of ' . $rec['t3ver_oid'] . '</b>' : '') . '<br/><hr/>';
                 }
                 if (t3lib_div::_POST('_EDIT')) {
                     $output .= '<hr/>Edit:<br/><br/>';
                     $output .= '<input type="submit" name="_SAVE" value="SAVE" /><br/>';
                     foreach ($rec as $field => $value) {
                         $output .= '<b>' . htmlspecialchars($field) . ':</b><br/>';
                         if (count(explode(chr(10), $value)) > 1) {
                             $output .= '<textarea name="record[' . $table . '][' . $uid . '][' . $field . ']" cols="100" rows="10">' . t3lib_div::formatForTextarea($value) . '</textarea><br/>';
                         } else {
                             $output .= '<input name="record[' . $table . '][' . $uid . '][' . $field . ']" value="' . htmlspecialchars($value) . '" size="100" /><br/>';
                         }
                     }
                 } elseif (t3lib_div::_POST('_SAVE')) {
                     $incomingData = t3lib_div::_POST('record');
                     $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid=' . intval($uid), $incomingData[$table][$uid]);
                     $output .= '<br/>Updated ' . $table . ':' . $uid . '...';
                     $this->updateRefIndex($table, $uid);
                 } else {
                     if (t3lib_div::_POST('_DELETE')) {
                         $GLOBALS['TYPO3_DB']->exec_DELETEquery($table, 'uid=' . intval($uid));
                         $output .= '<br/>Deleted ' . $table . ':' . $uid . '...';
                         $this->updateRefIndex($table, $uid);
                     } else {
                         $output .= '<input type="submit" name="_EDIT" value="EDIT" />';
                         $output .= '<input type="submit" name="_DELETE" value="DELETE" onclick="return confirm(\'Are you sure you wish to delete?\');" />';
                         $output .= '<br/>' . md5(implode($rec));
                         $output .= Tx_Extdeveval_Compatibility::viewArray($rec);
                     }
                 }
             } else {
                 $output .= 'No record existed!';
             }
         }
     }
     return $output;
 }
    function getTextarea($parentObject, $PA, $value, $config)
    {
        $code = $this->triggerField($PA['itemFormElName']);
        $code .= '<textarea id="RTEarea' . $parentObject->RTEcounter . '" class="tinymce_rte" name="' . htmlspecialchars($PA['itemFormElName']) . '" rows="30" cols="100">' . t3lib_div::formatForTextarea($value) . '</textarea>';
        if (!$config['useFEediting']) {
            $config['init.']['window'] = 'self';
            $config['init.']['element_id'] = 'RTEarea' . $parentObject->RTEcounter;
            $config['init.']['reAddCss'] = 'true';
            $code .= '
				<script type="text/javascript">
					top.tinyMCE.execCommand("mceAddFrameControl", false, ' . $this->parseConfig($config['init.']) . ');
				</script>
			';
        } else {
            $code .= $this->getCoreScript($config);
            $code .= $this->getInitScript($config['init.']);
        }
        return $code;
    }
 /**
  * renders a textarea with default value
  *
  * @param	string		field prefix
  * @param	string		default value
  * @return	string		the complete textarea
  */
 function renderTextareaBox($prefix, $value)
 {
     $onCP = $this->getOnChangeParts($prefix);
     return $this->wopText($prefix) . $onCP[0] . '<textarea name="' . $this->piFieldName('wizArray_upd') . $prefix . '" style="width:600px;" rows="10" wrap="off" onchange="' . $onCP[1] . '" title="' . htmlspecialchars('WOP:' . $prefix) . '"' . $this->wop($prefix) . '>' . t3lib_div::formatForTextarea($value) . '</textarea>';
 }
示例#5
0
    /**
     * Step 5: Create dynamic menu
     *
     * @param	string		Type of menu (main or sub), values: "field_menu" or "field_submenu"
     * @return	void
     */
    function wizard_step5($menuField)
    {
        $menuPart = $this->getMenuDefaultCode($menuField);
        $menuType = $menuField === 'field_menu' ? 'mainMenu' : 'subMenu';
        $menuTypeText = $menuField === 'field_menu' ? 'main menu' : 'sub menu';
        $menuTypeLetter = $menuField === 'field_menu' ? 'a' : 'b';
        $menuTypeNextStep = $menuField === 'field_menu' ? 5.1 : 6;
        $menuTypeEntryLevel = $menuField === 'field_menu' ? 0 : 1;
        $this->saveMenuCode();
        if (strlen($menuPart)) {
            // Main message:
            $outputString .= '
				The basics of your website should be working now. However the ' . $menuTypeText . ' still needs to be configured so that TYPO3 automatically generates a menu reflecting the pages in the page tree. This process involves configuration of the TypoScript object path, "lib.' . $menuType . '". This is a technical job which requires that you know about TypoScript if you want it 100% customized.<br/>
				To assist you getting started with the ' . $menuTypeText . ' this wizard will try to analyse the menu found inside the template file. If the menu was created of a series of repetitive block tags containing A-tags then there is a good chance this will succeed. You can see the result below.
			';
            // Start up HTML parser:
            require_once PATH_t3lib . 'class.t3lib_parsehtml.php';
            $htmlParser = t3lib_div::makeinstance('t3lib_parsehtml');
            // Parse into blocks
            $parts = $htmlParser->splitIntoBlock('td,tr,table,a,div,span,ol,ul,li,p,h1,h2,h3,h4,h5', $menuPart, 1);
            // If it turns out to be only a single large block we expect it to be a container for the menu item. Therefore we will parse the next level and expect that to be menu items:
            if (count($parts) == 3) {
                $totalWrap = array();
                $totalWrap['before'] = $parts[0] . $htmlParser->getFirstTag($parts[1]);
                $totalWrap['after'] = '</' . strtolower($htmlParser->getFirstTagName($parts[1])) . '>' . $parts[2];
                $parts = $htmlParser->splitIntoBlock('td,tr,table,a,div,span,ol,ul,li,p,h1,h2,h3,h4,h5', $htmlParser->removeFirstAndLastTag($parts[1]), 1);
            } else {
                $totalWrap = array();
            }
            $menuPart_HTML = trim($totalWrap['before']) . chr(10) . implode(chr(10), $parts) . chr(10) . trim($totalWrap['after']);
            // Traverse expected menu items:
            $menuWraps = array();
            $GMENU = FALSE;
            $mouseOver = FALSE;
            $key = '';
            foreach ($parts as $k => $value) {
                if ($k % 2) {
                    // Only expecting inner elements to be of use:
                    $linkTag = $htmlParser->splitIntoBlock('a', $value, 1);
                    if ($linkTag[1]) {
                        $newValue = array();
                        $attribs = $htmlParser->get_tag_attributes($htmlParser->getFirstTag($linkTag[1]), 1);
                        $newValue['A-class'] = $attribs[0]['class'];
                        if ($attribs[0]['onmouseover'] && $attribs[0]['onmouseout']) {
                            $mouseOver = TRUE;
                        }
                        // Check if the complete content is an image - then make GMENU!
                        $linkContent = trim($htmlParser->removeFirstAndLastTag($linkTag[1]));
                        if (eregi('^<img[^>]*>$', $linkContent)) {
                            $GMENU = TRUE;
                            $attribs = $htmlParser->get_tag_attributes($linkContent, 1);
                            $newValue['I-class'] = $attribs[0]['class'];
                            $newValue['I-width'] = $attribs[0]['width'];
                            $newValue['I-height'] = $attribs[0]['height'];
                            $filePath = t3lib_div::getFileAbsFileName(t3lib_div::resolveBackPath(PATH_site . $attribs[0]['src']));
                            if (@is_file($filePath)) {
                                $newValue['backColorGuess'] = $this->getBackgroundColor($filePath);
                            } else {
                                $newValue['backColorGuess'] = '';
                            }
                            if ($attribs[0]['onmouseover'] && $attribs[0]['onmouseout']) {
                                $mouseOver = TRUE;
                            }
                        }
                        $linkTag[1] = '|';
                        $newValue['wrap'] = ereg_replace('[' . chr(10) . chr(13) . ']*', '', implode('', $linkTag));
                        $md5Base = $newValue;
                        unset($md5Base['I-width']);
                        unset($md5Base['I-height']);
                        $md5Base = serialize($md5Base);
                        $md5Base = ereg_replace('name=["\'][^"\']*["\']', '', $md5Base);
                        $md5Base = ereg_replace('id=["\'][^"\']*["\']', '', $md5Base);
                        $md5Base = ereg_replace('[:space:]', '', $md5Base);
                        $key = md5($md5Base);
                        if (!isset($menuWraps[$key])) {
                            // Only if not yet set, set it (so it only gets set once and the first time!)
                            $menuWraps[$key] = $newValue;
                        } else {
                            // To prevent from writing values in the "} elseif ($key) {" below, we clear the key:
                            $key = '';
                        }
                    } elseif ($key) {
                        // Add this to the previous wrap:
                        $menuWraps[$key]['bulletwrap'] .= str_replace('|', '&#' . ord('|') . ';', ereg_replace('[' . chr(10) . chr(13) . ']*', '', $value));
                    }
                }
            }
            // Construct TypoScript for the menu:
            reset($menuWraps);
            if (count($menuWraps) == 1) {
                $menu_normal = current($menuWraps);
                $menu_active = next($menuWraps);
            } else {
                // If more than two, then the first is the active one.
                $menu_active = current($menuWraps);
                $menu_normal = next($menuWraps);
            }
            #debug($menuWraps);
            #debug($mouseOver);
            if ($GMENU) {
                $typoScript = '
lib.' . $menuType . ' = HMENU
lib.' . $menuType . '.entryLevel = ' . $menuTypeEntryLevel . '
' . (count($totalWrap) ? 'lib.' . $menuType . '.wrap = ' . ereg_replace('[' . chr(10) . chr(13) . ']', '', implode('|', $totalWrap)) : '') . '
lib.' . $menuType . '.1 = GMENU
lib.' . $menuType . '.1.NO.wrap = ' . $this->makeWrap($menu_normal) . ($menu_normal['I-class'] ? '
lib.' . $menuType . '.1.NO.imgParams = class="' . htmlspecialchars($menu_normal['I-class']) . '" ' : '') . '
lib.' . $menuType . '.1.NO {
	XY = ' . ($menu_normal['I-width'] ? $menu_normal['I-width'] : 150) . ',' . ($menu_normal['I-height'] ? $menu_normal['I-height'] : 25) . '
	backColor = ' . ($menu_normal['backColorGuess'] ? $menu_normal['backColorGuess'] : '#FFFFFF') . '
	10 = TEXT
	10.text.field = title // nav_title
	10.fontColor = #333333
	10.fontSize = 12
	10.offset = 15,15
	10.fontFace = t3lib/fonts/nimbus.ttf
}
	';
                if ($mouseOver) {
                    $typoScript .= '
lib.' . $menuType . '.1.RO < lib.' . $menuType . '.1.NO
lib.' . $menuType . '.1.RO = 1
lib.' . $menuType . '.1.RO {
	backColor = ' . t3lib_div::modifyHTMLColorAll($menu_normal['backColorGuess'] ? $menu_normal['backColorGuess'] : '#FFFFFF', -20) . '
	10.fontColor = red
}
			';
                }
                if (is_array($menu_active)) {
                    $typoScript .= '
lib.' . $menuType . '.1.ACT < lib.' . $menuType . '.1.NO
lib.' . $menuType . '.1.ACT = 1
lib.' . $menuType . '.1.ACT.wrap = ' . $this->makeWrap($menu_active) . ($menu_active['I-class'] ? '
lib.' . $menuType . '.1.ACT.imgParams = class="' . htmlspecialchars($menu_active['I-class']) . '" ' : '') . '
lib.' . $menuType . '.1.ACT {
	backColor = ' . ($menu_active['backColorGuess'] ? $menu_active['backColorGuess'] : '#FFFFFF') . '
}
			';
                }
            } else {
                $typoScript = '
lib.' . $menuType . ' = HMENU
lib.' . $menuType . '.entryLevel = ' . $menuTypeEntryLevel . '
' . (count($totalWrap) ? 'lib.' . $menuType . '.wrap = ' . ereg_replace('[' . chr(10) . chr(13) . ']', '', implode('|', $totalWrap)) : '') . '
lib.' . $menuType . '.1 = TMENU
lib.' . $menuType . '.1.NO {
	allWrap = ' . $this->makeWrap($menu_normal) . ($menu_normal['A-class'] ? '
	ATagParams = class="' . htmlspecialchars($menu_normal['A-class']) . '"' : '') . '
}
	';
                if (is_array($menu_active)) {
                    $typoScript .= '
lib.' . $menuType . '.1.ACT = 1
lib.' . $menuType . '.1.ACT {
	allWrap = ' . $this->makeWrap($menu_active) . ($menu_active['A-class'] ? '
	ATagParams = class="' . htmlspecialchars($menu_active['A-class']) . '"' : '') . '
}
			';
                }
            }
            // Output:
            // HTML defaults:
            $outputString .= '
			<br/>
			<br/>
			Here is the HTML code from the Template that encapsulated the menu:
			<hr/>
			<pre>' . htmlspecialchars($menuPart_HTML) . '</pre>
			<hr/>
			<br/>';
            if (trim($menu_normal['wrap']) != '|') {
                $outputString .= 'It seems that the menu consists of menu items encapsulated with "' . htmlspecialchars(str_replace('|', ' ... ', $menu_normal['wrap'])) . '". ';
            } else {
                $outputString .= 'It seems that the menu consists of menu items not wrapped in any block tags except A-tags. ';
            }
            if (count($totalWrap)) {
                $outputString .= 'It also seems that the whole menu is wrapped in this tag: "' . htmlspecialchars(str_replace('|', ' ... ', implode('|', $totalWrap))) . '". ';
            }
            if ($menu_normal['bulletwrap']) {
                $outputString .= 'Between the menu elements there seems to be a visual division element with this HTML code: "' . htmlspecialchars($menu_normal['bulletwrap']) . '". That will be added between each element as well. ';
            }
            if ($GMENU) {
                $outputString .= 'The menu items were detected to be images - TYPO3 will try to generate graphical menu items automatically (GMENU). You will need to customize the look of these before it will match the originals! ';
            }
            if ($mouseOver) {
                $outputString .= 'It seems like a mouseover functionality has been applied previously, so roll-over effect has been applied as well.  ';
            }
            $outputString .= '<br/><br/>';
            $outputString .= 'Based on this analysis, this TypoScript configuration for the menu is suggested:
			<br/><br/>';
            $outputString .= '<hr/>' . $this->syntaxHLTypoScript($typoScript) . '<hr/><br/>';
            $outputString .= 'You can fine tune the configuration here before it is saved:<br/>';
            $outputString .= '<textarea name="CFG[menuCode]"' . $GLOBALS['TBE_TEMPLATE']->formWidthText() . ' rows="10">' . t3lib_div::formatForTextarea($typoScript) . '</textarea><br/><br/>';
            $outputString .= '<input type="hidden" name="SET[wiz_step]" value="' . $menuTypeNextStep . '" />';
            $outputString .= '<input type="submit" name="_" value="Write ' . $menuTypeText . ' TypoScript code" />';
        } else {
            $outputString .= '
				The basics of your website should be working now. It seems like you did not map the ' . $menuTypeText . ' to any element, so the menu configuration process will be skipped.<br/>
			';
            $outputString .= '<input type="hidden" name="SET[wiz_step]" value="' . $menuTypeNextStep . '" />';
            $outputString .= '<input type="submit" name="_" value="Next..." />';
        }
        // Add output:
        $this->content .= $this->doc->section('Step 5' . $menuTypeLetter . ': Trying to create dynamic menu', $outputString, 0, 1);
    }
示例#6
0
    /**
     * Create configuration form
     *
     * @param	array		Form configurat data
     * @param	array		Table row accumulation variable. This is filled with table rows.
     * @return	void		Sets content in $this->content
     */
    function makeSaveForm($inData, &$row)
    {
        global $LANG;
        // Presets:
        $row[] = '
			<tr class="tableheader bgColor5">
				<td colspan="2">' . $LANG->getLL('makesavefo_presets', 1) . '</td>
			</tr>';
        $opt = array('');
        $presets = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'tx_impexp_presets', '(public>0 OR user_uid=' . intval($GLOBALS['BE_USER']->user['uid']) . ')' . ($inData['pagetree']['id'] ? ' AND (item_uid=' . intval($inData['pagetree']['id']) . ' OR item_uid=0)' : ''));
        if (is_array($presets)) {
            foreach ($presets as $presetCfg) {
                $opt[$presetCfg['uid']] = $presetCfg['title'] . ' [' . $presetCfg['uid'] . ']' . ($presetCfg['public'] ? ' [Public]' : '') . ($presetCfg['user_uid'] === $GLOBALS['BE_USER']->user['uid'] ? ' [Own]' : '');
            }
        }
        $row[] = '
				<tr class="bgColor4">
					<td><strong>' . $LANG->getLL('makesavefo_presets', 1) . '</strong>' . t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'presets', $GLOBALS['BACK_PATH'], '') . '</td>
					<td>
						' . $LANG->getLL('makesavefo_selectPreset', 1) . '<br/>
						' . $this->renderSelectBox('preset[select]', '', $opt) . '
						<br/>
						<input type="submit" value="' . $LANG->getLL('makesavefo_load', 1) . '" name="preset[load]" />
						<input type="submit" value="' . $LANG->getLL('makesavefo_save', 1) . '" name="preset[save]" onclick="return confirm(\'' . $LANG->getLL('makesavefo_areYouSure', 1) . '\');" />
						<input type="submit" value="' . $LANG->getLL('makesavefo_delete', 1) . '" name="preset[delete]" onclick="return confirm(\'' . $LANG->getLL('makesavefo_areYouSure', 1) . '\');" />
						<input type="submit" value="' . $LANG->getLL('makesavefo_merge', 1) . '" name="preset[merge]" onclick="return confirm(\'' . $LANG->getLL('makesavefo_areYouSure', 1) . '\');" />
						<br/>
						' . $LANG->getLL('makesavefo_titleOfNewPreset', 1) . '
						<input type="text" name="tx_impexp[preset][title]" value="' . htmlspecialchars($inData['preset']['title']) . '"' . $this->doc->formWidth(30) . ' /><br/>
						<label for="checkPresetPublic">' . $LANG->getLL('makesavefo_public', 1) . '</label>
						<input type="checkbox" name="tx_impexp[preset][public]" id="checkPresetPublic" value="1"' . ($inData['preset']['public'] ? ' checked="checked"' : '') . ' /><br/>
					</td>
				</tr>';
        // Output options:
        $row[] = '
			<tr class="tableheader bgColor5">
				<td colspan="2">' . $LANG->getLL('makesavefo_outputOptions', 1) . '</td>
			</tr>';
        // Meta data:
        $tempDir = $this->userTempFolder();
        if ($tempDir) {
            $thumbnails = t3lib_div::getFilesInDir($tempDir, 'png,gif,jpg');
            array_unshift($thumbnails, '');
        } else {
            $thumbnails = FALSE;
        }
        $row[] = '
				<tr class="bgColor4">
					<td><strong>' . $LANG->getLL('makesavefo_metaData', 1) . '</strong>' . t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'metadata', $GLOBALS['BACK_PATH'], '') . '</td>
					<td>
							' . $LANG->getLL('makesavefo_title', 1) . ' <br/>
							<input type="text" name="tx_impexp[meta][title]" value="' . htmlspecialchars($inData['meta']['title']) . '"' . $this->doc->formWidth(30) . ' /><br/>
							' . $LANG->getLL('makesavefo_description', 1) . ' <br/>
							<input type="text" name="tx_impexp[meta][description]" value="' . htmlspecialchars($inData['meta']['description']) . '"' . $this->doc->formWidth(30) . ' /><br/>
							' . $LANG->getLL('makesavefo_notes', 1) . ' <br/>
							<textarea name="tx_impexp[meta][notes]"' . $this->doc->formWidth(30, 1) . '>' . t3lib_div::formatForTextarea($inData['meta']['notes']) . '</textarea><br/>
							' . (is_array($thumbnails) ? '
							' . $LANG->getLL('makesavefo_thumbnail', 1) . '<br/>
							' . $this->renderSelectBox('tx_impexp[meta][thumbnail]', $inData['meta']['thumbnail'], $thumbnails) . '<br/>
							' . ($inData['meta']['thumbnail'] ? '<img src="' . $this->doc->backPath . '../' . substr($tempDir, strlen(PATH_site)) . $thumbnails[$inData['meta']['thumbnail']] . '" vspace="5" style="border: solid black 1px;" alt="" /><br/>' : '') . '
							' . $LANG->getLL('makesavefo_uploadThumbnail', 1) . '<br/>
							<input type="file" name="upload_1" ' . $this->doc->formWidth(30) . ' size="30" /><br/>
								<input type="hidden" name="file[upload][1][target]" value="' . htmlspecialchars($tempDir) . '" />
								<input type="hidden" name="file[upload][1][data]" value="1" /><br />
							' : '') . '
						</td>
				</tr>';
        // Add file options:
        $savePath = $this->userSaveFolder();
        $opt = array();
        if ($this->export->compress) {
            $opt['t3d_compressed'] = $LANG->getLL('makesavefo_t3dFileCompressed');
        }
        $opt['t3d'] = $LANG->getLL('makesavefo_t3dFile');
        $opt['xml'] = $LANG->getLL('makesavefo_xml');
        $row[] = '
				<tr class="bgColor4">
					<td><strong>' . $LANG->getLL('makesavefo_fileFormat', 1) . '</strong>' . t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'fileFormat', $GLOBALS['BACK_PATH'], '') . '</td>
					<td>' . $this->renderSelectBox('tx_impexp[filetype]', $inData['filetype'], $opt) . '<br/>
						' . $LANG->getLL('makesavefo_maxSizeOfFiles', 1) . '<br/>
						<input type="text" name="tx_impexp[maxFileSize]" value="' . htmlspecialchars($inData['maxFileSize']) . '"' . $this->doc->formWidth(10) . ' /><br/>
						' . ($savePath ? sprintf($LANG->getLL('makesavefo_filenameSavedInS', 1), substr($savePath, strlen(PATH_site))) . '<br/>
						<input type="text" name="tx_impexp[filename]" value="' . htmlspecialchars($inData['filename']) . '"' . $this->doc->formWidth(30) . ' /><br/>' : '') . '
					</td>
				</tr>';
        // Add buttons:
        $row[] = '
				<tr class="bgColor4">
					<td>&nbsp;</td>
					<td><input type="submit" value="' . $LANG->getLL('makesavefo_update', 1) . '" /> - <input type="submit" value="' . $LANG->getLL('makesavefo_downloadExport', 1) . '" name="tx_impexp[download_export]" />' . ($savePath ? ' - <input type="submit" value="' . $LANG->getLL('importdata_saveToFilename', 1) . '" name="tx_impexp[save_export]" />' : '') . '</td>
				</tr>';
    }
    /**
     * Render the personal note including the form to save it again
     *
     * @return	string		The note
     */
    public function renderNote()
    {
        $content = '';
        $incoming = t3lib_div::_GP('data');
        // Saving / creating note:
        if (isset($incoming['note'])) {
            $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $GLOBALS['LANG']->getLL('success.message'));
            $content .= $flashMessage->render();
            $this->setQuickNote($incoming);
        }
        // get the note
        $note = $this->getQuickNote();
        // if encrypten is used, a password is required
        if ($this->confArr['encrypt'] == 1 && empty($incoming['password'])) {
            $content .= '<form method="post">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_tca.xml:be_users.password') . '<input type="text" name="data[password]" /><br /><br />
							<input type="submit" value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:save', 1) . '" />
						</form>';
        } else {
            $passwordField = $passwordPrompt = '';
            // if encrypten is used, decrypt the note
            if ($this->confArr['encrypt'] == 1) {
                // decrypt only if there is a note available
                if ($note['note'] != '') {
                    $this->secure->setIV(base64_decode($note['securecode']));
                    $note['note'] = $this->secure->decrypt($incoming['password'], base64_decode($note['note']));
                }
                // additional password field if encryption is used
                $passwordField = $GLOBALS['LANG']->sL('LLL:EXT:setup/mod/locallang.xml:newPassword') . ': ' . '<input type="text" name="data[password]" /><br /><br />';
                $passwordPrompt = ' onclick="return confirm(\'' . $GLOBALS['LANG']->getLL('remember_password') . '\')" ';
            }
            // Render textarea
            $styles = is_array($this->confArr) ? ' style="' . htmlspecialchars($this->confArr['styles']) . '" ' : '';
            $content .= '<form method="post">
					<textarea rows="30" cols="48"  name="data[note]"' . $styles . '>' . t3lib_div::formatForTextarea($note['note']) . '</textarea>
					<br /><br />
					' . $passwordField . '
					<input type="submit" ' . $passwordPrompt . 'value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:save', 1) . '" />
					<input type="reset" value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:cancel', 1) . '" />
				</form>';
        }
        return $content;
    }
    /**
     * Draws the RTE as a form field or whatever is needed (inserts JavaApplet, creates iframe, renders ....)
     * Default is to output the transformed content in a plain textarea field. This mode is great for debugging transformations!
     *
     * @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(&$pObj, $table, $field, $row, $PA, $specConf, $thisConfig, $RTEtypeVal, $RTErelPath, $thePidValue)
    {
        // Transform value:
        $value = $this->transformContent('rte', $PA['itemFormElValue'], $table, $field, $row, $specConf, $thisConfig, $RTErelPath, $thePidValue);
        // Create item:
        $item = '
			' . $this->triggerField($PA['itemFormElName']) . '
			<textarea name="' . htmlspecialchars($PA['itemFormElName']) . '"' . $pObj->formWidthText('48', 'off') . ' rows="20" wrap="off" style="background-color: #99eebb;">' . t3lib_div::formatForTextarea($value) . '</textarea>';
        // Return form item:
        return $item;
    }
    /**
     * 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 $TSFE, $TYPO3_CONF_VARS, $TYPO3_DB;
        $this->TCEform = $parentObject;
        $this->client = $this->clientInfo();
        $this->typoVersion = t3lib_div::int_from_ver(TYPO3_version);
        /* =======================================
         * INIT THE EDITOR-SETTINGS
         * =======================================
         */
        // Get the path to this extension:
        $this->extHttpPath = t3lib_extMgm::siteRelPath($this->ID);
        // Get the site URL
        $this->siteURL = $GLOBALS['TSFE']->absRefPrefix ? $GLOBALS['TSFE']->absRefPrefix : '';
        // Get the host URL
        $this->hostURL = '';
        // Element ID + pid
        $this->elementId = $PA['itemFormElName'];
        $this->elementParts[0] = $table;
        $this->elementParts[1] = $row['uid'];
        $this->tscPID = $thePidValue;
        $this->thePid = $thePidValue;
        // Record "type" field value:
        $this->typeVal = $RTEtypeVal;
        // TCA "type" value for record
        // RTE configuration
        $pageTSConfig = $TSFE->getPagesTSconfig();
        if (is_array($pageTSConfig) && is_array($pageTSConfig['RTE.'])) {
            $this->RTEsetup = $pageTSConfig['RTE.'];
        }
        if (is_array($thisConfig) && !empty($thisConfig)) {
            $this->thisConfig = $thisConfig;
        } else {
            if (is_array($this->RTEsetup['default.']) && is_array($this->RTEsetup['default.']['FE.'])) {
                $this->thisConfig = $this->RTEsetup['default.']['FE.'];
            }
        }
        // Special configuration (line) 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);
        }
        // Register RTE windows:
        $this->TCEform->RTEwindows[] = $PA['itemFormElName'];
        $textAreaId = preg_replace('/[^a-zA-Z0-9_:.-]/', '_', $PA['itemFormElName']);
        $textAreaId = htmlspecialchars(preg_replace('/^[^a-zA-Z]/', 'x', $textAreaId)) . '_' . strval($this->TCEform->RTEcounter);
        /* =======================================
         * LANGUAGES & CHARACTER SETS
         * =======================================
         */
        // Language
        $TSFE->initLLvars();
        $this->language = $TSFE->lang;
        $this->LOCAL_LANG = t3lib_div::readLLfile('EXT:' . $this->ID . '/locallang.xml', $this->language);
        if ($this->language == 'default' || !$this->language) {
            $this->language = '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 = $GLOBALS['TSFE']->sys_language_isocode ? $GLOBALS['TSFE']->sys_language_isocode : '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']));
                }
            }
        }
        $this->contentISOLanguage = $this->contentISOLanguage ? $this->contentISOLanguage : ($GLOBALS['TSFE']->sys_language_isocode ? $GLOBALS['TSFE']->sys_language_isocode : 'en');
        $this->contentTypo3Language = $this->contentTypo3Language ? $this->contentTypo3Language : $GLOBALS['TSFE']->lang;
        if ($this->contentTypo3Language == 'default') {
            $this->contentTypo3Language = 'en';
        }
        // Character set
        $this->charset = $TSFE->renderCharset;
        $this->OutputCharset = $TSFE->metaCharset ? $TSFE->metaCharset : $TSFE->renderCharset;
        // Set the charset of the content
        $this->contentCharset = $TSFE->csConvObj->charSetArray[$this->contentTypo3Language];
        $this->contentCharset = $this->contentCharset ? $this->contentCharset : 'iso-8859-1';
        $this->contentCharset = trim($TSFE->config['config']['metaCharset']) ? trim($TSFE->config['config']['metaCharset']) : $this->contentCharset;
        /* =======================================
         * TOOLBAR CONFIGURATION
         * =======================================
         */
        $this->initializeToolbarConfiguration();
        /* =======================================
         * SET STYLES
         * =======================================
         */
        $width = 460 + ($this->TCEform->docLarge ? 150 : 0);
        if (isset($this->thisConfig['RTEWidthOverride'])) {
            if (strstr($this->thisConfig['RTEWidthOverride'], '%')) {
                if ($this->client['browser'] != 'msie') {
                    $width = intval($this->thisConfig['RTEWidthOverride']) > 0 ? $this->thisConfig['RTEWidthOverride'] : '100%';
                }
            } else {
                $width = intval($this->thisConfig['RTEWidthOverride']) > 0 ? intval($this->thisConfig['RTEWidthOverride']) : $width;
            }
        }
        $RTEWidth = strstr($width, '%') ? $width : $width . 'px';
        $editorWrapWidth = strstr($width, '%') ? $width : $width + 2 . 'px';
        $height = 380;
        $RTEHeightOverride = intval($this->thisConfig['RTEHeightOverride']);
        $height = $RTEHeightOverride > 0 ? $RTEHeightOverride : $height;
        $RTEHeight = $height . 'px';
        $editorWrapHeight = $height + 2 . 'px';
        $this->RTEWrapStyle = $this->RTEWrapStyle ? $this->RTEWrapStyle : ($this->RTEdivStyle ? $this->RTEdivStyle : 'height:' . $editorWrapHeight . '; width:' . $editorWrapWidth . ';');
        $this->RTEdivStyle = $this->RTEdivStyle ? $this->RTEdivStyle : 'position:relative; left:0px; top:0px; height:' . $RTEHeight . '; width:' . $RTEWidth . '; border: 1px solid black;';
        /* =======================================
         * LOAD JS, CSS and more
         * =======================================
         */
        $pageRenderer = $this->getPageRenderer();
        // Preloading the pageStyle and including RTE skin stylesheets
        $this->addPageStyle();
        $this->addSkin();
        // Re-initialize the scripts array so that only the cumulative set of plugins of the last RTE on the page is used
        $this->cumulativeScripts[$this->TCEform->RTEcounter] = array();
        $this->includeScriptFiles($this->TCEform->RTEcounter);
        $this->buildJSMainLangFile($this->TCEform->RTEcounter);
        // Register RTE in JS:
        $this->TCEform->additionalJS_post[] = $this->wrapCDATA($this->registerRTEinJS($this->TCEform->RTEcounter, '', '', '', $textAreaId));
        // Set the save option for the RTE:
        $this->TCEform->additionalJS_submit[] = $this->setSaveRTE($this->TCEform->RTEcounter, $this->TCEform->formName, $textAreaId);
        // Loading ExtJs JavaScript files and inline code, if not configured in TS setup
        if (!$GLOBALS['TSFE']->isINTincScript() || !is_array($GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs.'])) {
            $pageRenderer->loadExtJs();
            $pageRenderer->enableExtJSQuickTips();
            if (!$GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->ID]['enableCompressedScripts']) {
                $pageRenderer->enableExtJsDebug();
            }
        }
        $pageRenderer->addCssFile($this->siteURL . 't3lib/js/extjs/ux/resize.css');
        $pageRenderer->addJsFile($this->siteURL . 't3lib/js/extjs/ux/ext.resizable.js');
        $pageRenderer->addJsFile($this->siteURL . '/t3lib/js/extjs/notifications.js');
        if ($this->TCEform->RTEcounter == 1) {
            $this->TCEform->additionalJS_pre['rtehtmlarea-loadJScode'] = $this->wrapCDATA($this->loadJScode($this->TCEform->RTEcounter));
        }
        $this->TCEform->additionalJS_initial = $this->loadJSfiles($this->TCEform->RTEcounter);
        if ($GLOBALS['TSFE']->isINTincScript()) {
            $GLOBALS['TSFE']->additionalHeaderData['rtehtmlarea'] = $pageRenderer->render();
        }
        /* =======================================
         * 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);
            }
        }
        // draw the textarea
        $item = $this->triggerField($PA['itemFormElName']) . '
			<div id="pleasewait' . $textAreaId . '" class="pleasewait" style="display: block;" >' . $TSFE->csConvObj->conv($TSFE->getLLL('Please wait', $this->LOCAL_LANG), $this->charset, $TSFE->renderCharset) . '</div>
			<div id="editorWrap' . $textAreaId . '" class="editorWrap" style="visibility: hidden; ' . htmlspecialchars($this->RTEWrapStyle) . '">
			<textarea id="RTEarea' . $textAreaId . '" name="' . htmlspecialchars($PA['itemFormElName']) . '" rows="0" cols="0" style="' . htmlspecialchars($this->RTEdivStyle) . '">' . t3lib_div::formatForTextarea($value) . '</textarea>
			</div>' . ($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['enableDebugMode'] ? '<div id="HTMLAreaLog"></div>' : '') . '
			';
        return $item;
    }
 /**
  * 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
  * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=367&cHash=bbc518d930
  */
 function FORM($conf, $formData = '')
 {
     $content = '';
     if (is_array($formData)) {
         $dataArr = $formData;
     } else {
         $data = $this->stdWrap($conf['data'], $conf['data.']);
         // Clearing dataArr
         $dataArr = array();
         // Getting the original config
         if (trim($data)) {
             $data = str_replace(LF, '||', $data);
             $dataArr = explode('||', $data);
         }
         // Adding the new dataArray config form:
         if (is_array($conf['dataArray.'])) {
             // dataArray is supplied
             $sKeyArray = t3lib_TStemplate::sortedKeyList($conf['dataArray.'], TRUE);
             foreach ($sKeyArray as $theKey) {
                 $dAA = $conf['dataArray.'][$theKey . '.'];
                 if (is_array($dAA)) {
                     $temp = array();
                     list($temp[0]) = explode('|', $dAA['label.'] ? $this->stdWrap($dAA['label'], $dAA['label.']) : $dAA['label']);
                     list($temp[1]) = explode('|', $dAA['type']);
                     if ($dAA['required']) {
                         $temp[1] = '*' . $temp[1];
                     }
                     list($temp[2]) = explode('|', $dAA['value.'] ? $this->stdWrap($dAA['value'], $dAA['value.']) : $dAA['value']);
                     // If value Array is set, then implode those values.
                     if (is_array($dAA['valueArray.'])) {
                         $temp_accum = array();
                         foreach ($dAA['valueArray.'] as $dAKey_vA => $dAA_vA) {
                             if (is_array($dAA_vA) && !strcmp(intval($dAKey_vA) . '.', $dAKey_vA)) {
                                 $temp_vA = array();
                                 list($temp_vA[0]) = explode('=', $dAA_vA['label.'] ? $this->stdWrap($dAA_vA['label'], $dAA_vA['label.']) : $dAA_vA['label']);
                                 if ($dAA_vA['selected']) {
                                     $temp_vA[0] = '*' . $temp_vA[0];
                                 }
                                 list($temp_vA[1]) = explode(',', $dAA_vA['value']);
                             }
                             $temp_accum[] = implode('=', $temp_vA);
                         }
                         $temp[2] = implode(',', $temp_accum);
                     }
                     list($temp[3]) = explode('|', $dAA['specialEval.'] ? $this->stdWrap($dAA['specialEval'], $dAA['specialEval.']) : $dAA['specialEval']);
                     // adding the form entry to the dataArray
                     $dataArr[] = implode('|', $temp);
                 }
             }
         }
     }
     $attachmentCounter = '';
     $hiddenfields = '';
     $fieldlist = array();
     $propertyOverride = array();
     $fieldname_hashArray = array();
     $cc = 0;
     $xhtmlStrict = t3lib_div::inList('xhtml_strict,xhtml_11,xhtml_2', $GLOBALS['TSFE']->xhtmlDoctype);
     // Formname
     if ($conf['formName']) {
         $formname = $this->cleanFormName($conf['formName']);
     } else {
         $formname = $GLOBALS['TSFE']->uniqueHash();
         $formname = 'a' . $formname;
         // form name has to start with a letter to reach XHTML compliance
     }
     if (isset($conf['fieldPrefix'])) {
         if ($conf['fieldPrefix']) {
             $prefix = $this->cleanFormName($conf['fieldPrefix']);
         } else {
             $prefix = '';
         }
     } else {
         $prefix = $formname;
     }
     foreach ($dataArr as $val) {
         $cc++;
         $confData = array();
         if (is_array($formData)) {
             $parts = $val;
             $val = 1;
             // true...
         } else {
             $val = trim($val);
             $parts = explode('|', $val);
         }
         if ($val && strcspn($val, '#/')) {
             // label:
             $confData['label'] = 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->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'] .= '_' . $cc;
                 }
                 $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]));
             }
             $fieldCode = '';
             if ($conf['wrapFieldName']) {
                 $confData['fieldname'] = $this->wrap($confData['fieldname'], $conf['wrapFieldName']);
             }
             // Set field name as current:
             $this->setCurrentVal($confData['fieldname']);
             // Additional parameters
             if (trim($confData['type'])) {
                 $addParams = trim($conf['params']);
                 if (is_array($conf['params.']) && isset($conf['params.'][$confData['type']])) {
                     $addParams = trim($conf['params.'][$confData['type']]);
                 }
                 if (strcmp('', $addParams)) {
                     $addParams = ' ' . $addParams;
                 }
             } else {
                 $addParams = '';
             }
             if ($conf['dontMd5FieldNames']) {
                 $fName = $confData['fieldname'];
             } else {
                 $fName = md5($confData['fieldname']);
             }
             // Accessibility: Set id = fieldname attribute:
             if ($conf['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;
                     $compWidth = doubleval($conf['compensateFieldWidth'] ? $conf['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]);
                     if ($conf['noWrapAttr'] || $wrap === 'disabled') {
                         $wrap = '';
                     } else {
                         $wrap = $wrap ? ' wrap="' . $wrap . '"' : ' wrap="virtual"';
                     }
                     $default = $this->getFieldDefaultValue($conf['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;
                     $compWidth = doubleval($conf['compensateFieldWidth'] ? $conf['compensateFieldWidth'] : $GLOBALS['TSFE']->compensateFieldWidth);
                     $compWidth = $compWidth ? $compWidth : 1;
                     $size = t3lib_div::intInRange($size * $compWidth, 1, 120);
                     $default = $this->getFieldDefaultValue($conf['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:
                     $default = $this->getFieldDefaultValue($conf['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:
                     $default = $this->getFieldDefaultValue($conf['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) {
                         $confData['fieldname'] .= '[]';
                     }
                     // 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.
                     $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:
                     $default = $this->getFieldDefaultValue($conf['noValueInsert'], $confData['fieldname'], $default);
                     // Create the select-box:
                     $iCount = count($items);
                     for ($a = 0; $a < $iCount; $a++) {
                         $radioId = $prefix . $fName . $this->cleanFormName($items[$a][0]);
                         if ($conf['accessibility']) {
                             $radioLabelIdAttribute = ' id="' . $radioId . '"';
                         } else {
                             $radioLabelIdAttribute = '';
                         }
                         $option .= '<input type="radio" name="' . $confData['fieldname'] . '"' . $radioLabelIdAttribute . ' value="' . $items[$a][1] . '"' . (!strcmp($items[$a][1], $default) ? ' checked="checked"' : '') . $addParams . ' />';
                         if ($conf['accessibility']) {
                             $option .= '<label for="' . $radioId . '">' . $this->stdWrap(trim($items[$a][0]), $conf['radioWrap.']) . '</label>';
                         } else {
                             $option .= $this->stdWrap(trim($items[$a][0]), $conf['radioWrap.']);
                         }
                     }
                     if ($conf['accessibility']) {
                         $accessibilityWrap = $conf['radioWrap.']['accessibilityWrap'];
                         $search = array('###RADIO_FIELD_ID###', '###RADIO_GROUP_LABEL###');
                         $replace = array($elementIdAttribute, $confData['label']);
                         $accessibilityWrap = str_replace($search, $replace, $accessibilityWrap);
                         $option = $this->wrap($option, $accessibilityWrap);
                     }
                     $fieldCode = $option;
                     break;
                 case 'hidden':
                     $value = trim($parts[2]);
                     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->data[$this->currentValKey] = $value;
                         $image = $this->IMG_RESOURCE($conf['image.']);
                         $params = $conf['image.']['params'] ? ' ' . $conf['image.']['params'] : '';
                         $params .= $this->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 ($conf['accessibility'] && trim($fieldLabel) && !preg_match('/^(label|hidden|comment)$/', $confData['type'])) {
                     $fieldLabel = '<label for="' . $prefix . $fName . '">' . $fieldLabel . '</label>';
                 }
                 // Getting template code:
                 $fieldCode = $this->stdWrap($fieldCode, $conf['fieldWrap.']);
                 $labelCode = $this->stdWrap($fieldLabel, $conf['labelWrap.']);
                 $commentCode = $this->stdWrap($confData['label'], $conf['commentWrap.']);
                 // RTF
                 $result = $conf['layout'];
                 if ($conf['REQ'] && $confData['required']) {
                     if (is_array($conf['REQ.']['fieldWrap.'])) {
                         $fieldCode = $this->stdWrap($fieldCode, $conf['REQ.']['fieldWrap.']);
                     }
                     if (is_array($conf['REQ.']['labelWrap.'])) {
                         $labelCode = $this->stdWrap($fieldLabel, $conf['REQ.']['labelWrap.']);
                     }
                     if ($conf['REQ.']['layout']) {
                         $result = $conf['REQ.']['layout'];
                     }
                 }
                 if ($confData['type'] == 'comment' && $conf['COMMENT.']['layout']) {
                     $result = $conf['COMMENT.']['layout'];
                 }
                 if ($confData['type'] == 'check' && $conf['CHECK.']['layout']) {
                     $result = $conf['CHECK.']['layout'];
                 }
                 if ($confData['type'] == 'radio' && $conf['RADIO.']['layout']) {
                     $result = $conf['RADIO.']['layout'];
                 }
                 if ($confData['type'] == 'label' && $conf['LABEL.']['layout']) {
                     $result = $conf['LABEL.']['layout'];
                 }
                 $result = str_replace('###FIELD###', $fieldCode, $result);
                 $result = str_replace('###LABEL###', $labelCode, $result);
                 $result = str_replace('###COMMENT###', $commentCode, $result);
                 //RTF
                 $content .= $result;
             }
         }
     }
     if ($conf['stdWrap.']) {
         $content = $this->stdWrap($content, $conf['stdWrap.']);
     }
     // redirect (external: where to go afterwards. internal: where to submit to)
     $theRedirect = $this->stdWrap($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)
     $page = $GLOBALS['TSFE']->page;
     if (!$theRedirect) {
         // Internal: Just submit to current page
         $LD = $GLOBALS['TSFE']->tmpl->linkData($page, $conf['target'], $conf['no_cache'], 'index.php', '', $this->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, $conf['target'], $conf['no_cache'], 'index.php', '', $this->getClosestMPvalueForPage($page['uid']));
     } else {
         // External URL, redirect-hidden field is rendered!
         $LD = $GLOBALS['TSFE']->tmpl->linkData($page, $conf['target'], $conf['no_cache'], '', '', $this->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!):
     $formtype = $propertyOverride['type'] ? $propertyOverride['type'] : $this->stdWrap($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, $conf['target'], $conf['no_cache'], '', '', $this->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, $conf['target'], $conf['no_cache'], '', '', $this->getClosestMPvalueForPage($page['uid']));
         $action = $LD_A['totalURL'];
     }
     // Recipient:
     $theEmail = $this->stdWrap($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:
     if ($conf['locationData']) {
         if ($conf['locationData'] == 'HTTP_POST_VARS' && isset($_POST['locationData'])) {
             $locationData = t3lib_div::_POST('locationData');
         } else {
             $locationData = $GLOBALS['TSFE']->id . ':' . $this->currentRecord;
             // 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.
         }
         $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->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 = '<div style="display:none;">' . $hiddenfields . '</div>';
     if ($conf['REQ']) {
         $validateForm = ' onsubmit="return validateForm(\'' . $formname . '\',\'' . implode(',', $fieldlist) . '\',' . t3lib_div::quoteJSvalue($conf['goodMess']) . ',' . t3lib_div::quoteJSvalue($conf['badMess']) . ',' . t3lib_div::quoteJSvalue($conf['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'];
     $content = array('<form' . ' action="' . htmlspecialchars($action) . '"' . ' id="' . $formname . '"' . ($xhtmlStrict ? '' : ' name="' . $formname . '"') . ' enctype="' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'] . '"' . ' method="' . ($conf['method'] ? $conf['method'] : 'post') . '"' . ($theTarget ? ' target="' . $theTarget . '"' : '') . $validateForm . '>', $hiddenfields . $content, '</form>');
     if ($conf['arrayReturnMode']) {
         $content['validateForm'] = $validateForm;
         $content['formname'] = $formname;
         return $content;
     } else {
         return implode('', $content);
     }
 }
    /**
     * Creates an interface where there user can select which "class." files to include in the ext_php_api.dat file which the function can create/update by a single click.
     *
     * @param	string		$extDir: Extension Directory, absolute path
     * @param	array		$extPhpFiles: Array with PHP files (rel. paths) from the extension directory
     * @param	string		The local/global/system extension main directory relative to PATH_site - normally set to "typo3conf/ext/" for local extensions. Used to pass on to analyseFile()
     * @return	string		HTML output
     */
    function updateDat($extDir, $extPhpFiles, $passOn_extDir)
    {
        if (is_array($extPhpFiles)) {
            // GPvars:
            $doWrite = t3lib_div::_GP('WRITE');
            $gp_options = t3lib_div::_GP('options');
            // Find current dat file:
            $datArray = '';
            if (@is_file($extDir . 'ext_php_api.dat')) {
                $datArray = unserialize(t3lib_div::getUrl($extDir . 'ext_php_api.dat'));
                if (!is_array($datArray)) {
                    $content .= '<br /><br /><p><strong>ERROR:</strong> "ext_php_api.dat" file did not contain a valid serialized array!</p>';
                } else {
                    $content .= '<br /><br /><p> "ext_php_api.dat" has been detected (' . t3lib_div::formatSize(filesize($extDir . 'ext_php_api.dat')) . 'bytes) and read.</p>';
                }
            } else {
                $content = '<br /><br /><p><strong>INFO:</strong> No "ext_php_api.dat" file found.</p>';
            }
            if (!is_array($datArray)) {
                $datArray = array();
            }
            // Show files:
            $newDatArray = array();
            $newDatArray['meta']['title'] = $datArray['meta']['title'];
            $newDatArray['meta']['descr'] = $datArray['meta']['descr'];
            $inCheck = t3lib_div::_GP('selectThisFile');
            $lines = array();
            foreach ($extPhpFiles as $lFile) {
                // Make MD5 hash of filepath:
                $lFile_MD5 = 'MD5_' . t3lib_div::shortMD5($lFile);
                // disable check for "class." by "1"
                if (1 || t3lib_div::isFirstPartOfStr(basename($lFile), 'class.')) {
                    // Get API information about class-file:
                    $newAnalyser = t3lib_div::makeInstance('tx_extdeveval_phpdoc');
                    $newAnalyser->analyseFile($extDir . $lFile, $passOn_extDir, $gp_options['includeCodeAbstract'] ? 1 : 0);
                    if (!is_array($inCheck) && isset($datArray['files'][$lFile_MD5]) || is_array($inCheck) && in_array($lFile, $inCheck)) {
                        $newDatArray['files'][$lFile_MD5] = array('filename' => $lFile, 'filesize' => filesize($extDir . $lFile), 'header' => $newAnalyser->headerInfo, 'DAT' => $newAnalyser->fileInfo);
                    }
                    // Format that information:
                    $clines = array();
                    $cc = 0;
                    foreach ($newAnalyser->fileInfo as $part) {
                        // Adding the function/class name to list:
                        if (is_array($part['sectionText']) && count($part['sectionText'])) {
                            $clines[] = '';
                            $clines[] = str_replace(' ', '&nbsp;', htmlspecialchars('      SECTION: ' . $part['sectionText'][0]));
                        }
                        if ($part['class']) {
                            $clines[] = '';
                            $clines[] = '';
                        }
                        // Add function / class header:
                        $line = $part['parentClass'] && !$part['class'] ? '    ' : '';
                        $line .= preg_replace('#\\{$#', '', trim($part['header']));
                        $line = str_replace(' ', '&nbsp;', htmlspecialchars($line));
                        // Only selected files can be analysed:
                        if (is_array($newDatArray['files'][$lFile_MD5])) {
                            // This will analyse the comment applied to the function and create a status of quality.
                            $status = $this->checkCommentQuality($part['cDat'], $part['class'] ? 1 : 0);
                            // Wrap in color if a warning applies!
                            $color = '';
                            switch ($status[2]) {
                                case 1:
                                    $color = '#666666';
                                    break;
                                case 2:
                                    $color = '#ff6600';
                                    break;
                                case 3:
                                    $color = 'red';
                                    break;
                            }
                            if ($color) {
                                $line = '<span style="color:' . $color . '; font-weight: bold;">' . $line . '</span><div style="margin-left: 50px; background-color: ' . $color . '; padding: 2px 2px 2px 2px;">' . htmlspecialchars(implode(chr(10), $status[0])) . '</div>';
                            }
                            // Another analysis to do is usage count for functions:
                            $uCountKey = 'H_' . t3lib_div::shortMD5($part['header']);
                            if ($doWrite && $gp_options['usageCount'] && is_array($newDatArray['files'][$lFile_MD5])) {
                                $newDatArray['files'][$lFile_MD5]['usageCount'][$uCountKey] = $this->countFunctionUsage($part['header'], $extPhpFiles, $extDir);
                            }
                            // If any usage is detected:
                            if (is_array($datArray['files'][$lFile_MD5]['usageCount'])) {
                                if ($datArray['files'][$lFile_MD5]['usageCount'][$uCountKey]['ALL']['TOTAL']) {
                                    $line .= '<div style="margin-left: 50px; background-color: #cccccc; padding: 2px 2px 2px 2px; font-weight: bold; ">Usage: ' . $datArray['files'][$lFile_MD5]['usageCount'][$uCountKey]['ALL']['TOTAL'] . '</div>';
                                    foreach ($datArray['files'][$lFile_MD5]['usageCount'][$uCountKey] as $fileKey => $fileStat) {
                                        if (substr($fileKey, 0, 4) == 'MD5_') {
                                            $line .= '<div style="margin-left: 75px; background-color: #999999; padding: 1px 2px 1px 2px;">File: ' . htmlspecialchars($fileStat['TOTAL'] . ' - ' . $fileStat['fileName']) . '</div>';
                                        }
                                    }
                                } else {
                                    $line .= '<div style="margin-left: 50px; background-color: red; padding: 2px 2px 2px 2px; font-weight: bold; ">NO USAGE COUNT!</div>';
                                }
                            }
                        }
                        $clines[] = $line;
                    }
                    // Make HTML table row:
                    $lines[] = '<tr' . (is_array($datArray['files'][$lFile_MD5]) ? ' class="bgColor5"' : ' class="nonSelectedRows"') . '>
						<td><input type="checkbox" name="selectThisFile[]" value="' . htmlspecialchars($lFile) . '"' . (is_array($datArray['files'][$lFile_MD5]) ? ' checked="checked"' : '') . ' /></td>
						<td nowrap="nowrap" valign="top">' . htmlspecialchars($lFile) . '</td>
						<td nowrap="nowrap" valign="top">' . t3lib_div::formatSize(filesize($extDir . $lFile)) . '</td>
						<td nowrap="nowrap">' . nl2br(implode(chr(10), $clines)) . '</td>
					</tr>';
                }
            }
            $content .= '
			<br /><br /><p><strong>PHP/INC files from extension:</strong></p>
			<table border="0" cellspacing="1" cellpadding="0">' . implode('', $lines) . '</table>';
            $content .= '
				<br />
				<strong>Package Title:</strong><br />
				<input type="text" name="title_of_collection" value="' . htmlspecialchars($datArray['meta']['title']) . '"' . $GLOBALS['TBE_TEMPLATE']->formWidth() . ' /><br />
				<strong>Package Description:</strong><br />
				<textarea name="descr_of_collection"' . $GLOBALS['TBE_TEMPLATE']->formWidthText() . ' rows="5">' . t3lib_div::formatForTextarea($datArray['meta']['descr']) . '</textarea><br />

				<input type="checkbox" name="options[usageCount]" value="1"' . ($datArray['meta']['options']['usageCount'] ? ' checked="checked"' : '') . ' /> Perform an internal usage count of functions and classes (can be VERY time consuming!)<br />
				<input type="checkbox" name="options[includeCodeAbstract]" value="1"' . ($datArray['meta']['options']['includeCodeAbstract'] ? ' checked="checked"' : '') . ' /> Include ' . $this->includeContent . ' bytes abstraction of functions (can be VERY space consuming)<br />

				<input type="submit" value="' . htmlspecialchars('Write/Update "ext_php_api.dat" file') . '" name="WRITE" />
			';
            #			$content.='<p>'.md5(serialize($datArray)).' MD5 - from current ext_php_api.dat file</p>';
            #			$content.='<p>'.md5(serialize($newDatArray)).' MD5 - new, from the selected files</p>';
            if ($doWrite) {
                $newDatArray['meta']['title'] = t3lib_div::_GP('title_of_collection');
                $newDatArray['meta']['descr'] = t3lib_div::_GP('descr_of_collection');
                $newDatArray['meta']['options']['usageCount'] = $gp_options['usageCount'];
                $newDatArray['meta']['options']['includeCodeAbstract'] = $gp_options['includeCodeAbstract'];
                t3lib_div::writeFile($extDir . 'ext_php_api.dat', serialize($newDatArray));
                $content = '<hr />';
                $content .= '<p><strong>ext_php_api.dat file written to extension directory, "' . $extDir . '"</strong></p>';
                $content .= '
					<input type="submit" value="Return..." name="_" />
				';
            }
        } else {
            $content = '<p>No PHP/INC files found extension directory.</p>';
        }
        return $content;
    }
    /**
     * The main function in the class
     *
     * @return	string		HTML content
     */
    function main()
    {
        $inputCode = t3lib_div::_GP('input_code');
        $content = '';
        $content .= '
		<textarea rows="15" name="input_code" wrap="off"' . $GLOBALS['TBE_TEMPLATE']->formWidthText(48, 'width:98%;', 'off') . '>' . t3lib_div::formatForTextarea($inputCode) . '</textarea>
		<br />
		<input type="submit" name="highlight_php" value="PHP" />
		<input type="submit" name="highlight_ts" value="TypoScript" />
		<input type="submit" name="highlight_xml" value="XML" />
		<input type="submit" name="highlight_xml2array" value="xml2array()" />
		<br />
		<input type="checkbox" name="option_linenumbers" value="1"' . (t3lib_div::_GP('option_linenumbers') ? ' checked="checked"' : '') . ' /> Linenumbers (TS/PHP)<br />
		<input type="checkbox" name="option_blockmode" value="1"' . (t3lib_div::_GP('option_blockmode') ? ' checked="checked"' : '') . ' /> Blockmode (TS)<br />
		<input type="checkbox" name="option_analytic" value="1"' . (t3lib_div::_GP('option_analytic') ? ' checked="checked"' : '') . ' /> Analytic style (TS/XML)<br />
		<input type="checkbox" name="option_showparsed" value="1"' . (t3lib_div::_GP('option_showparsed') ? ' checked="checked"' : '') . ' /> Show parsed structure (TS/XML)<br />

		';
        if (trim($inputCode)) {
            // Highlight PHP
            if (t3lib_div::_GP('highlight_php')) {
                if (substr(trim($inputCode), 0, 2) != '<?') {
                    $inputCode = '<?php' . chr(10) . chr(10) . chr(10) . $inputCode . chr(10) . chr(10) . chr(10) . '?>';
                }
                $formattedContent = highlight_string($inputCode, 1);
                if (t3lib_div::_GP('option_linenumbers')) {
                    $lines = explode('<br />', $formattedContent);
                    foreach ($lines as $k => $v) {
                        $lines[$k] = '<font color="black">' . str_pad($k - 2, 4, ' ', STR_PAD_LEFT) . ':</font> ' . $v;
                    }
                    $formattedContent = implode('<br />', $lines);
                }
                // Remove regular linebreaks
                $formattedContent = preg_replace('#[' . chr(10) . chr(13) . ']#', '', $formattedContent);
                // Wrap in <pre> tags
                $content .= '<hr /><pre class="ts-hl">' . $formattedContent . '</pre>';
            }
            // Highlight TypoScript
            if (t3lib_div::_GP('highlight_ts')) {
                $tsparser = t3lib_div::makeInstance("t3lib_TSparser");
                if (t3lib_div::_GP('option_analytic')) {
                    $tsparser->highLightStyles = $this->highLightStyles_analytic;
                    $tsparser->highLightBlockStyles_basecolor = '';
                    $tsparser->highLightBlockStyles = $this->highLightBlockStyles;
                } else {
                    $tsparser->highLightStyles = $this->highLightStyles;
                }
                $tsparser->lineNumberOffset = 0;
                $formattedContent = $tsparser->doSyntaxHighlight($inputCode, t3lib_div::_GP('option_linenumbers') ? array($tsparser->lineNumberOffset) : '', t3lib_div::_GP('option_blockmode'));
                $content .= '<hr />' . $formattedContent;
                #debug($inputCode);
                #$tsparser->xmlToTypoScriptStruct($inputCode);
                if (t3lib_div::_GP('option_showparsed')) {
                    $content .= '<hr />' . Tx_Extdeveval_Compatibility::viewArray($tsparser->setup);
                    /*
                    ob_start();
                    print_r($tsparser->setup);
                    $content.='<hr /><pre>'.ob_get_contents().'</pre>';
                    ob_end_clean();
                    */
                }
            }
            // Highlight XML
            if (t3lib_div::_GP('highlight_xml')) {
                $formattedContent = $this->xmlHighLight($inputCode, t3lib_div::_GP('option_analytic') ? $this->highLightStyles_analytic : $this->highLightStyles);
                $content .= '<hr /><em>Notice: This highlighted version of the above XML data is parsed and then re-formatted. Therefore comments are not included and a 100% similarity with the source is not guaranteed. However the content should be just as valid XML as the source (except CDATA which is not detected as such!!!).</em><br><br>' . $formattedContent;
                if (t3lib_div::_GP('option_showparsed')) {
                    $treeDat = t3lib_div::xml2tree($inputCode);
                    $content .= '<hr />';
                    $content .= 'MD5: ' . md5(serialize($treeDat));
                    $content .= Tx_Extdeveval_Compatibility::viewArray($treeDat);
                }
            }
            // Highlight XML content parsable with xml2array()
            if (t3lib_div::_GP('highlight_xml2array')) {
                $formattedContent = $this->xml2arrayHighLight($inputCode);
                $content .= '<hr /><br>' . $formattedContent;
                if (t3lib_div::_GP('option_showparsed')) {
                    $treeDat = t3lib_div::xml2array($inputCode);
                    $content .= '<hr />';
                    $content .= 'MD5: ' . md5(serialize($treeDat));
                    $content .= Tx_Extdeveval_Compatibility::viewArray($treeDat);
                }
            }
        }
        return $content;
    }
	function main($dir,$item,&$pObj) {

		global $LANG;


		if(!t3quixplorer_div::get_is_file($dir, $item)) t3quixplorer_div::showError($item.": ".$LANG->getLL("error.fileexists"));
		if(!t3quixplorer_div::get_show_item($dir, $item)) t3quixplorer_div::showError($item.": ".$LANG->getLL("error.accessfile"));
		$fname = t3quixplorer_div::get_abs_item($dir, $item);
		$fileinfo = t3lib_div::split_fileref($fname);
		$ext = $fileinfo['fileext'];
		$theight = ($GLOBALS["T3Q_VARS"]["textarea_height"] && is_numeric($GLOBALS["T3Q_VARS"]["textarea_height"]))?$GLOBALS["T3Q_VARS"]["textarea_height"]:20;


		$pObj->doc->JScode = '
<script id="prototype-script" type="text/javascript" src="../../t3scodehighlight/contrib/prototype/prototype.js">
</script>
<script src="../../t3scodehighlight/contrib/codepress/codepress.js" type="text/javascript" id="cp-script" lang="en-us"></script>
<link type="text/css" rel="stylesheet" href="../../t3scodehighlight/contrib/codepress/t3codepress.css">
</link>
<script src="../../t3scodehighlight/contrib/codepress/content/en-us.js" type="text/javascript" id="cp-script" lang="en-us"></script>
<script src="../../t3scodehighlight/contrib/codepress/t3codepress_t3lib_tceforms.js" type="text/javascript" id="t3codepress-t3libtceforms-script"></script>

				<script type="text/javascript">

					function closeDoc(){
						window.location=\''.t3quixplorer_div::make_link("list",$dir,NULL).'\';
					}
				</script>

			';

		$content= array();

		if(t3lib_div::_POST("dosave") && t3lib_div::_POST("dosave")=="yes") {
			// Save / Save As
			$item=basename(stripslashes(t3lib_div::_POST("fname")));
			$fname2=t3quixplorer_div::get_abs_item($dir, $item);
			if(!isset($item) || $item=="") t3quixplorer_div::showError($LANG->getLL("error.miscnoname"));
			if($fname!=$fname2 && @file_exists($fname2)) t3quixplorer_div::showError($item.": ".$LANG->getLL("error.itemdoesexist"));
			$this->savefile($fname2);
			$fname=$fname2;
		}

		// open file
		$fp = @fopen($fname, "r");
		if($fp===false) t3quixplorer_div::showError($item.": ".$LANG->getLL("error.openfile"));
		@fclose($fp);

		$fileContent = t3lib_div::getUrl($fname);

		// header
		$s_item=t3quixplorer_div::get_rel_item($dir,$item);	if(strlen($s_item)>50) $s_item="...".substr($s_item,-47);



		//$content[]=$s_item;

		//changed to absolute filename as of version 1.7 ... any complaints?
		$content[] = $fname;

		//$onkeydown = $GLOBALS['T3Q_VARS']['disable_tab'] ? '' : ' onkeydown="return catchTab(this,event)" ';

		$fileinfo = t3lib_div::split_fileref(t3quixplorer_div::get_abs_item($dir,$item));
		$lang = t3lib_div::_GP("highlight_lang");
		$ext = $fileinfo['fileext'];


        $readme = $this->getReadme($dir);
        if(strlen(trim($readme))){
        	$readme = '<div style="border: 1px solid red; background-color: yellow; padding: 10px; display:block;">'.$readme.'</div>';
        }else{
        	$readme = '';
        }
		if(!$lang){
			$lang = $ext;
		}
     if($item == 'setup.txt' || $item == 'config.txt'|| $item == 'constants.txt'){
		$content[]= $readme.'
		  <br />
		    <form id="editform" name="editform" method="post" action="'.t3quixplorer_div::make_link("edit",$dir,$item).'" >
		    <input type="hidden" name="dosave" value="yes"> '.
          '<code id="content" wrap="off" title=".ts" class="cp hideLanguage" style="height: 500px; color: silver; visibility: visible;">'.t3lib_div::formatForTextarea($fileContent).'</code>'
			.'<textarea id="content_ta" name="content_ta" rows="'.$theight.'" wrap="off" style="width: 460px; display: none;" class="cp fixed-font enable-tab">'.t3lib_div::formatForTextarea($fileContent).'</textarea>';

      }else{
		$content[]= $readme.'
		  <br />
		    <form id="editform" name="editform" method="post" action="'.t3quixplorer_div::make_link("edit",$dir,$item).'" >
		    <input type="hidden" name="dosave" value="yes"> '.
          '<code id="content" wrap="off" title=".'.$lang.'" class="cp hideLanguage" style="height: 500px; color: silver; visibility: visible;">'.t3lib_div::formatForTextarea($fileContent).'</code>'
			.'<textarea id="content_ta" name="content_ta" rows="'.$theight.'" wrap="off" style="width: 460px; display: none;" class="cp fixed-font enable-tab">'.t3lib_div::formatForTextarea($fileContent).'</textarea>';

      }



		$content[]= '
			  <br />
		      <table>
			    	<tr>
				  		<td>
				    		<input type="hidden" name="fname" value="'.$item.'">
				  		</td>
		          		<td>
				    		<input type="submit" name="savenow" value="'.$LANG->getLL("message.btnsave").'" >
				  		</td>
				  		<td>
		            <input type="button" value="'.$LANG->getLL("message.btnclose").'" onclick="closeDoc()">
				  		</td></tr></table><br />';





			$fileT3s = $fname;
			if(@is_file($fileT3s)){
			require_once (t3lib_extMgm::extPath("t3quixplorer")."mod1/geshi.php");

			  $inputCode = file_get_contents($fileT3s);



				switch($ext){
					case 'php':
					case 'php3':
					case 'inc':
						$hl = 'php';
						break;

					case 'html':
					case 'htm':
					case 'tmpl':
						$hl = 'html4strict';
						break;

					case 'js':
						$hl = 'javascript';
						break;

					case 'pl':
						$hl = 'perl';
						break;

					default:
						$hl = $ext;
						break;
				}

            if($item == 'setup.txt' || $item == 'config.txt'|| $item == 'constants.txt'){
            	$hl = 'ts';
            }
			switch($hl){
				case 'php':
				case 'xml':
				case 'sql':
				case 'html4strict':
				case 'javascript':
				case 'perl':
				case 'css':
				case 'smarty':
					$geshi = new GeSHi($inputCode,$hl,'geshi/');
					$geshi->use_classes = true;
					$geshi->set_tab_width(4);
					$geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
					$geshi->set_link_target('_blank');
					$geshi->set_line_style("font-family:'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font-size:12px;");

					$content[] = '
					<style type="text/css">

					.'.$hl.' *{font-size:11px;}

					'.$geshi->get_stylesheet().'
					</style>
					';

					$content[] = '<strong>T3S-File: '.$fileT3s.'</strong></br><hr />'.$geshi->parse_code();

					break;
				case 'ts':
					require_once(PATH_t3lib.'class.t3lib_tsparser.php');
					$tsparser = t3lib_div::makeInstance("t3lib_TSparser");
					$tsparser->lineNumberOffset=1;
					$formattedContent = $tsparser->doSyntaxHighlight($inputCode, array($tsparser->lineNumberOffset), 0);
					$content[]='<strong>T3S-File: '.$fileT3s.'</strong></br><hr />'.$formattedContent;
					break;
				default:
					break;
			}
			}

		return implode("",$content);
	}
    /**
     * userfunc to call from flexform and init t3editor field or textarea with tab support
     *
     * @param array $PA
     * @param t3lib_TCEforms $fobj
     * @return string
     */
    public function drawCodeText($PA, &$fobj)
    {
        $this->_parameters['defaultExtras'] = $PA['fieldConf']['defaultExtras'];
        $extensionConfiguration = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['typoscript_code']);
        $outCode = '';
        if ($extensionConfiguration['enable_t3editor'] && t3lib_extMgm::isLoaded('t3editor')) {
            $outCode = $this->_buildT3EditorCode($GLOBALS['SOBE'], $PA['itemFormElName'], $PA['itemFormElValue']);
        }
        if ($outCode == '') {
            $outCode = '<textarea
				name="' . $PA['itemFormElName'] . '"
				rows="' . $this->_parameters['numberOfRows'] . '"
				cols="' . $this->_parameters['numberOfCols'] . '"
				wrap="off"
				class="' . $this->_parameters['defaultExtras'] . '"
				style="width: 98%; height: 60%;"
				onchange="' . htmlspecialchars(implode('', $PA['fieldChangeFunc'])) . '"' . $PA['onFocus'] . '>' . t3lib_div::formatForTextarea($PA['itemFormElValue']) . '</textarea>';
        }
        return $outCode;
    }
    /**
     * Render the module content in HTML
     *
     * @param	array		Translation data for configuration
     * @param	integer		Sys language uid
     * @param	array		Configuration record
     * @return	string		HTML content
     */
    function renderOverview()
    {
        global $LANG;
        $sysLang = $this->sysLang;
        $accumObj = $this->l10ncfgObj->getL10nAccumulatedInformationsObjectForLanguage($sysLang);
        $accum = $accumObj->getInfoArray();
        $l10ncfg = $this->l10ncfg;
        $output = '';
        $showSingle = t3lib_div::_GET('showSingle');
        if ($l10ncfg['displaymode'] > 0) {
            $showSingle = $showSingle ? $showSingle : 'NONE';
            if ($l10ncfg['displaymode'] == 2) {
                $noAnalysis = TRUE;
            }
        } else {
            $noAnalysis = FALSE;
        }
        // Traverse the structure and generate HTML output:
        foreach ($accum as $pId => $page) {
            $output .= '<h3>' . $page['header']['icon'] . htmlspecialchars($page['header']['title']) . ' [' . $pId . ']</h3>';
            $tableRows = array();
            foreach ($accum[$pId]['items'] as $table => $elements) {
                foreach ($elements as $elementUid => $data) {
                    if (is_array($data['fields'])) {
                        $FtableRows = array();
                        $flags = array();
                        if (!$noAnalysis || $showSingle === $table . ':' . $elementUid) {
                            foreach ($data['fields'] as $key => $tData) {
                                if (is_array($tData)) {
                                    list(, $uidString, $fieldName) = explode(':', $key);
                                    list($uidValue) = explode('/', $uidString);
                                    $diff = '';
                                    $edit = TRUE;
                                    $noChangeFlag = !strcmp(trim($tData['diffDefaultValue']), trim($tData['defaultValue']));
                                    if ($uidValue === 'NEW') {
                                        $diff = '<em>' . $LANG->getLL('render_overview.new.message') . '</em>';
                                        $flags['new']++;
                                    } elseif (!isset($tData['diffDefaultValue'])) {
                                        $diff = '<em>' . $LANG->getLL('render_overview.nodiff.message') . '</em>';
                                        $flags['unknown']++;
                                    } elseif ($noChangeFlag) {
                                        $diff = $LANG->getLL('render_overview.nochange.message');
                                        $edit = TRUE;
                                        $flags['noChange']++;
                                    } else {
                                        $diff = $this->diffCMP($tData['diffDefaultValue'], $tData['defaultValue']);
                                        $flags['update']++;
                                    }
                                    if (!$this->modeOnlyChanged || !$noChangeFlag) {
                                        $fieldCells = array();
                                        $fieldCells[] = '<b>' . htmlspecialchars($fieldName) . '</b>' . ($tData['msg'] ? '<br/><em>' . htmlspecialchars($tData['msg']) . '</em>' : '');
                                        $fieldCells[] = nl2br(htmlspecialchars($tData['defaultValue']));
                                        $fieldCells[] = $edit && $this->modeWithInlineEdit ? $tData['fieldType'] === 'text' ? '<textarea name="' . htmlspecialchars('translation[' . $table . '][' . $elementUid . '][' . $key . ']') . '" cols="60" rows="5">' . t3lib_div::formatForTextarea($tData['translationValue']) . '</textarea>' : '<input name="' . htmlspecialchars('translation[' . $table . '][' . $elementUid . '][' . $key . ']') . '" value="' . htmlspecialchars($tData['translationValue']) . '" size="60" />' : nl2br(htmlspecialchars($tData['translationValue']));
                                        $fieldCells[] = $diff;
                                        if ($page['header']['prevLang']) {
                                            reset($tData['previewLanguageValues']);
                                            $fieldCells[] = nl2br(htmlspecialchars(current($tData['previewLanguageValues'])));
                                        }
                                        $FtableRows[] = '<tr class="db_list_normal"><td>' . implode('</td><td>', $fieldCells) . '</td></tr>';
                                    }
                                }
                            }
                        }
                        if (count($FtableRows) || $noAnalysis) {
                            // Link:
                            if ($this->modeShowEditLinks) {
                                reset($data['fields']);
                                list(, $uidString) = explode(':', key($data['fields']));
                                if (substr($uidString, 0, 3) !== 'NEW') {
                                    $editId = is_array($data['translationInfo']['translations'][$sysLang]) ? $data['translationInfo']['translations'][$sysLang]['uid'] : $data['translationInfo']['uid'];
                                    $editLink = ' - <a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::editOnClick('&edit[' . $data['translationInfo']['translation_table'] . '][' . $editId . ']=edit', $this->doc->backPath)) . '"><em>[' . $LANG->getLL('render_overview.clickedit.message') . ']</em></a>';
                                } else {
                                    $editLink = ' - <a href="' . htmlspecialchars($this->doc->issueCommand('&cmd[' . $table . '][' . $data['translationInfo']['uid'] . '][localize]=' . $sysLang)) . '"><em>[' . $LANG->getLL('render_overview.clicklocalize.message') . ']</em></a>';
                                }
                            } else {
                                $editLink = '';
                            }
                            $tableRows[] = '<tr class="t3-row-header">
								<td colspan="2" style="width:300px;"><a href="' . htmlspecialchars('index.php?id=' . t3lib_div::_GET('id') . '&showSingle=' . rawurlencode($table . ':' . $elementUid)) . '">' . htmlspecialchars($table . ':' . $elementUid) . '</a>' . $editLink . '</td>
								<td colspan="3" style="width:200px;">' . htmlspecialchars(t3lib_div::arrayToLogString($flags)) . '</td>
							</tr>';
                            if (!$showSingle || $showSingle === $table . ':' . $elementUid) {
                                $tableRows[] = '<tr class="bgColor-20 tableheader">
									<td>Fieldname:</td>
									<td width="25%">Default:</td>
									<td width="25%">Translation:</td>
									<td width="25%">Diff:</td>
									' . ($page['header']['prevLang'] ? '<td width="25%">PrevLang:</td>' : '') . '
								</tr>';
                                $tableRows = array_merge($tableRows, $FtableRows);
                            }
                        }
                    }
                }
            }
            if (count($tableRows)) {
                $output .= '<table class="typo3-dblist" border="0" cellpadding="0" cellspacing="0">' . implode('', $tableRows) . '</table>';
            }
        }
        return $output;
    }
示例#16
0
    /**
     * Display extensions details.
     *
     * @param	string		Extension key
     * @return	void		Writes content to $this->content
     */
    function showExtDetails($extKey)
    {
        global $TYPO3_LOADED_EXT;
        list($list, ) = $this->extensionList->getInstalledExtensions();
        $absPath = tx_em_Tools::getExtPath($extKey, $list[$extKey]['type']);
        // Check updateModule:
        if (isset($list[$extKey]) && @is_file($absPath . 'class.ext_update.php')) {
            require_once $absPath . 'class.ext_update.php';
            $updateObj = new ext_update();
            if (!$updateObj->access()) {
                unset($this->MOD_MENU['singleDetails']['updateModule']);
            }
        } else {
            unset($this->MOD_MENU['singleDetails']['updateModule']);
        }
        if ($this->CMD['doDelete']) {
            $this->MOD_MENU['singleDetails'] = array();
        }
        // Function menu here:
        if (!$this->CMD['standAlone'] && !t3lib_div::_GP('standAlone')) {
            $content = $GLOBALS['LANG']->getLL('ext_details_ext') . '&nbsp;<strong>' . $this->extensionTitleIconHeader($extKey, $list[$extKey]) . '</strong> (' . htmlspecialchars($extKey) . ')';
            $this->content .= $this->doc->section('', $content);
        }
        // Show extension details:
        if ($list[$extKey]) {
            // Checking if a command for install/uninstall is executed:
            if (($this->CMD['remove'] || $this->CMD['load']) && !in_array($extKey, $this->requiredExt)) {
                // Install / Uninstall extension here:
                if (t3lib_extMgm::isLocalconfWritable()) {
                    // Check dependencies:
                    $depStatus = $this->install->checkDependencies($extKey, $list[$extKey]['EM_CONF'], $list);
                    if (!$this->CMD['remove'] && !$depStatus['returnCode']) {
                        $this->content .= $depStatus['html'];
                        $newExtList = -1;
                    } elseif ($this->CMD['remove']) {
                        $newExtList = $this->extensionList->removeExtFromList($extKey, $list);
                    } else {
                        $newExtList = $this->extensionList->addExtToList($extKey, $list);
                    }
                    // Successful installation:
                    if ($newExtList != -1) {
                        $updates = '';
                        if ($this->CMD['load']) {
                            if ($_SERVER['REQUEST_METHOD'] == 'POST') {
                                $script = t3lib_div::linkThisScript(array('CMD[showExt]' => $extKey, 'CMD[load]' => 1, 'CMD[clrCmd]' => $this->CMD['clrCmd'], 'SET[singleDetails]' => 'info'));
                            } else {
                                $script = '';
                            }
                            $standaloneUpdates = '';
                            if ($this->CMD['standAlone']) {
                                $standaloneUpdates .= '<input type="hidden" name="standAlone" value="1" />';
                            }
                            if ($this->CMD['silendMode']) {
                                $standaloneUpdates .= '<input type="hidden" name="silendMode" value="1" />';
                            }
                            $depsolver = t3lib_div::_POST('depsolver');
                            if (is_array($depsolver['ignore'])) {
                                foreach ($depsolver['ignore'] as $depK => $depV) {
                                    $dependencyUpdates .= '<input type="hidden" name="depsolver[ignore][' . $depK . ']" value="1" />';
                                }
                            }
                            $updatesForm = $this->install->updatesForm($extKey, $list[$extKey], 1, $script, $dependencyUpdates . $standaloneUpdates . '<input type="hidden" name="_do_install" value="1" /><input type="hidden" name="_clrCmd" value="' . $this->CMD['clrCmd'] . '" />', TRUE);
                            if ($updatesForm) {
                                $updates = $GLOBALS['LANG']->getLL('ext_details_new_tables_fields') . '<br />' . $GLOBALS['LANG']->getLL('ext_details_new_tables_fields_select') . $updatesForm;
                                $labelDBUpdate = $GLOBALS['LANG']->csConvObj->conv_case($GLOBALS['LANG']->charSet, $GLOBALS['LANG']->getLL('ext_details_db_needs_update'), 'toUpper');
                                $this->content .= $this->doc->section(sprintf($GLOBALS['LANG']->getLL('ext_details_installing') . ' ', $this->extensionTitleIconHeader($extKey, $list[$extKey])) . ' ' . $labelDBUpdate, $updates, 1, 1, 1, 1);
                            }
                        } elseif ($this->CMD['remove']) {
                            $updates .= $this->install->checkClearCache($list[$extKey]);
                            if ($updates) {
                                $updates = '
								<form action="' . $this->script . '" method="post">' . $updates . '
								<br /><input type="submit" name="write" value="' . $GLOBALS['LANG']->getLL('ext_details_remove_ext') . '" />
								<input type="hidden" name="_do_install" value="1" />
								<input type="hidden" name="_clrCmd" value="' . $this->CMD['clrCmd'] . '" />
								<input type="hidden" name="CMD[showExt]" value="' . $this->CMD['showExt'] . '" />
								<input type="hidden" name="CMD[remove]" value="' . $this->CMD['remove'] . '" />
								<input type="hidden" name="standAlone" value="' . $this->CMD['standAlone'] . '" />
								<input type="hidden" name="silentMode" value="' . $this->CMD['silentMode'] . '" />
								' . ($this->noDocHeader ? '<input type="hidden" name="nodoc" value="1" />' : '') . '
								</form>';
                                $labelDBUpdate = $GLOBALS['LANG']->csConvObj->conv_case($GLOBALS['LANG']->charSet, $GLOBALS['LANG']->getLL('ext_details_db_needs_update'), 'toUpper');
                                $this->content .= $this->doc->section(sprintf($GLOBALS['LANG']->getLL('ext_details_removing') . ' ', $this->extensionTitleIconHeader($extKey, $list[$extKey])) . ' ' . $labelDBUpdate, $updates, 1, 1, 1, 1);
                            }
                        }
                        if (!$updates || t3lib_div::_GP('_do_install') || $this->noDocHeader && $this->CMD['remove']) {
                            $this->install->writeNewExtensionList($newExtList);
                            $action = $this->CMD['load'] ? 'installed' : 'removed';
                            $GLOBALS['BE_USER']->writelog(5, 1, 0, 0, 'Extension list has been changed, extension %s has been %s', array($extKey, $action));
                            if (!t3lib_div::_GP('silentMode') && !$this->CMD['standAlone']) {
                                $messageLabel = 'ext_details_ext_' . $action . '_with_key';
                                $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', sprintf($GLOBALS['LANG']->getLL($messageLabel), $extKey), '', t3lib_FlashMessage::OK, TRUE);
                                t3lib_FlashMessageQueue::addMessage($flashMessage);
                            }
                            if ($this->CMD['clrCmd'] || t3lib_div::_GP('_clrCmd')) {
                                if ($this->CMD['load'] && @is_file($absPath . 'ext_conf_template.txt')) {
                                    $vA = array('CMD' => array('showExt' => $extKey));
                                } else {
                                    $vA = array('CMD' => '');
                                }
                            } else {
                                $vA = array('CMD' => array('showExt' => $extKey));
                            }
                            if ($this->CMD['standAlone'] || t3lib_div::_GP('standAlone')) {
                                $this->content .= sprintf($GLOBALS['LANG']->getLL('ext_details_ext_installed_removed'), $this->CMD['load'] ? $GLOBALS['LANG']->getLL('ext_details_installed') : $GLOBALS['LANG']->getLL('ext_details_removed')) . '<br /><br />' . $this->getSubmitAndOpenerCloseLink();
                            } else {
                                // Determine if new modules were installed:
                                $techInfo = $this->install->makeDetailedExtensionAnalysis($extKey, $list[$extKey]);
                                if (($this->CMD['load'] || $this->CMD['remove']) && is_array($techInfo['flags']) && in_array('Module', $techInfo['flags'], true)) {
                                    $vA['CMD']['refreshMenu'] = 1;
                                }
                                t3lib_utility_Http::redirect(t3lib_div::linkThisScript($vA));
                                exit;
                            }
                        }
                    }
                } else {
                    $writeAccessError = $GLOBALS['LANG']->csConvObj->conv_case($GLOBALS['LANG']->charSet, $GLOBALS['LANG']->getLL('ext_details_write_access_error'), 'toUpper');
                    $this->content .= $this->doc->section(sprintf($GLOBALS['LANG']->getLL('ext_details_installing') . ' ', $this->extensionTitleIconHeader($extKey, $list[$extKey])) . ' ' . $writeAccessError, $GLOBALS['LANG']->getLL('ext_details_write_error_localconf'), 1, 1, 2, 1);
                }
            } elseif ($this->CMD['downloadFile'] && !in_array($extKey, $this->requiredExt)) {
                // Link for downloading extension has been clicked - deliver content stream:
                $dlFile = $this->CMD['downloadFile'];
                if (t3lib_div::isAllowedAbsPath($dlFile) && t3lib_div::isFirstPartOfStr($dlFile, PATH_site) && t3lib_div::isFirstPartOfStr($dlFile, $absPath) && @is_file($dlFile)) {
                    $mimeType = 'application/octet-stream';
                    Header('Content-Type: ' . $mimeType);
                    Header('Content-Disposition: attachment; filename=' . basename($dlFile));
                    echo t3lib_div::getUrl($dlFile);
                    exit;
                } else {
                    throw new RuntimeException('TYPO3 Fatal Error: ' . $GLOBALS['LANG']->getLL('ext_details_error_downloading'), 1270853980);
                }
            } elseif ($this->CMD['editFile'] && !in_array($extKey, $this->requiredExt)) {
                // Editing extension file:
                $editFile = rawurldecode($this->CMD['editFile']);
                if (t3lib_div::isAllowedAbsPath($editFile) && t3lib_div::isFirstPartOfStr($editFile, $absPath)) {
                    $fI = t3lib_div::split_fileref($editFile);
                    if (@is_file($editFile) && t3lib_div::inList($this->editTextExtensions, $fI['fileext'] ? $fI['fileext'] : $fI['filebody'])) {
                        if (filesize($editFile) < $this->kbMax * 1024) {
                            $outCode = '<form action="' . $this->script . ' method="post" name="editfileform">';
                            $info = '';
                            $submittedContent = t3lib_div::_POST('edit');
                            $saveFlag = 0;
                            if (isset($submittedContent['file']) && !$GLOBALS['TYPO3_CONF_VARS']['EXT']['noEdit']) {
                                // Check referer here?
                                $oldFileContent = t3lib_div::getUrl($editFile);
                                if ($oldFileContent != $submittedContent['file']) {
                                    $oldMD5 = md5(str_replace(CR, '', $oldFileContent));
                                    $info .= sprintf($GLOBALS['LANG']->getLL('ext_details_md5_previous'), '<strong>' . $oldMD5 . '</strong>') . '<br />';
                                    t3lib_div::writeFile($editFile, $submittedContent['file']);
                                    $saveFlag = 1;
                                } else {
                                    $info .= $GLOBALS['LANG']->getLL('ext_details_no_changes') . '<br />';
                                }
                            }
                            $fileContent = t3lib_div::getUrl($editFile);
                            $outCode .= sprintf($GLOBALS['LANG']->getLL('ext_details_file'), '<strong>' . substr($editFile, strlen($absPath)) . '</strong> (' . t3lib_div::formatSize(filesize($editFile)) . ')<br />');
                            $fileMD5 = md5(str_replace(CR, '', $fileContent));
                            $info .= sprintf($GLOBALS['LANG']->getLL('ext_details_md5_current'), '<strong>' . $fileMD5 . '</strong>') . '<br />';
                            if ($saveFlag) {
                                $saveMD5 = md5(str_replace(CR, '', $submittedContent['file']));
                                $info .= sprintf($GLOBALS['LANG']->getLL('ext_details_md5_submitted'), '<strong>' . $saveMD5 . '</strong>') . '<br />';
                                if ($fileMD5 != $saveMD5) {
                                    $info .= tx_em_Tools::rfw('<br /><strong>' . $GLOBALS['LANG']->getLL('ext_details_saving_failed_changes_lost') . '</strong>') . '<br />';
                                } else {
                                    $info .= tx_em_Tools::rfw('<br /><strong>' . $GLOBALS['LANG']->getLL('ext_details_file_saved') . '</strong>') . '<br />';
                                }
                            }
                            $outCode .= '<textarea name="edit[file]" rows="35" wrap="off"' . $this->doc->formWidthText(48, 'width:98%;height:70%', 'off') . ' class="fixed-font enable-tab">' . t3lib_div::formatForTextarea($fileContent) . '</textarea>';
                            $outCode .= '<input type="hidden" name="edit[filename]" value="' . $editFile . '" />';
                            $outCode .= '<input type="hidden" name="CMD[editFile]" value="' . htmlspecialchars($editFile) . '" />';
                            $outCode .= '<input type="hidden" name="CMD[showExt]" value="' . $extKey . '" />';
                            $outCode .= $info;
                            if (!$GLOBALS['TYPO3_CONF_VARS']['EXT']['noEdit']) {
                                $outCode .= '<br /><input type="submit" name="save_file" value="' . $GLOBALS['LANG']->getLL('ext_details_file_save_button') . '" />';
                            } else {
                                $outCode .= tx_em_Tools::rfw('<br />' . $GLOBALS['LANG']->getLL('ext_details_saving_disabled') . ' ');
                            }
                            $onClick = 'window.location.href="' . t3lib_div::linkThisScript(array('CMD[showExt]' => $extKey)) . '";return false;';
                            $outCode .= '<input type="submit" name="cancel" value="' . $GLOBALS['LANG']->getLL('ext_details_cancel_button') . '" onclick="' . htmlspecialchars($onClick) . '" /></form>';
                            $theOutput .= $this->doc->spacer(15);
                            $theOutput .= $this->doc->section($GLOBALS['LANG']->getLL('ext_details_edit_file'), '', 0, 1);
                            $theOutput .= $this->doc->sectionEnd() . $outCode;
                            $this->content .= $theOutput;
                        } else {
                            $theOutput .= $this->doc->spacer(15);
                            $theOutput .= $this->doc->section(sprintf($GLOBALS['LANG']->getLL('ext_details_filesize_exceeded_kb'), $this->kbMax), sprintf($GLOBALS['LANG']->getLL('ext_details_file_too_large'), $this->kbMax));
                        }
                    }
                } else {
                    die(sprintf($GLOBALS['LANG']->getLL('ext_details_fatal_edit_error'), htmlspecialchars($editFile)));
                }
            } else {
                // MAIN:
                switch ((string) $this->MOD_SETTINGS['singleDetails']) {
                    case 'info':
                        // Loaded / Not loaded:
                        if (!in_array($extKey, $this->requiredExt)) {
                            if ($TYPO3_LOADED_EXT[$extKey]) {
                                $content = '<strong>' . $GLOBALS['LANG']->getLL('ext_details_loaded_and_running') . '</strong><br />' . '<a href="' . htmlspecialchars(t3lib_div::linkThisScript(array('CMD[showExt]' => $extKey, 'CMD[remove]' => 1))) . '">' . $GLOBALS['LANG']->getLL('ext_details_remove_button') . ' ' . tx_em_Tools::removeButton() . '</a>';
                            } else {
                                $content = $GLOBALS['LANG']->getLL('ext_details_not_loaded') . '<br />' . '<a href="' . htmlspecialchars(t3lib_div::linkThisScript(array('CMD[showExt]' => $extKey, 'CMD[load]' => 1))) . '">' . $GLOBALS['LANG']->getLL('ext_details_install_button') . ' ' . tx_em_Tools::installButton() . '</a>';
                            }
                        } else {
                            $content = $GLOBALS['LANG']->getLL('ext_details_always_loaded');
                        }
                        $this->content .= $this->doc->spacer(10);
                        $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('ext_details_current_status'), $content, 0, 1);
                        if (t3lib_extMgm::isLoaded($extKey)) {
                            $updates = $this->install->updatesForm($extKey, $list[$extKey]);
                            if ($updates) {
                                $this->content .= $this->doc->spacer(10);
                                $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('ext_details_update_needed'), $updates . '<br /><br />' . $GLOBALS['LANG']->getLL('ext_details_notice_static_data'), 0, 1);
                            }
                        }
                        // Config:
                        if (@is_file($absPath . 'ext_conf_template.txt')) {
                            $this->content .= $this->doc->spacer(10);
                            $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('ext_details_configuration'), $GLOBALS['LANG']->getLL('ext_details_notice_clear_cache') . '<br /><br />', 0, 1);
                            $this->content .= $this->install->tsStyleConfigForm($extKey, $list[$extKey]);
                        }
                        // Show details:
                        $headline = $GLOBALS['LANG']->getLL('ext_details_details');
                        $headline = t3lib_BEfunc::wrapInHelp('_MOD_tools_em', 'info', $headline);
                        $content = $this->extensionDetails->extInformationarray($extKey, $list[$extKey]);
                        $this->content .= $this->doc->spacer(10);
                        $this->content .= $this->doc->section($headline, $content, FALSE, TRUE, FALSE, TRUE);
                        break;
                    case 'upload':
                        $em = t3lib_div::_POST('em');
                        if ($em['action'] == 'doUpload') {
                            $em['extKey'] = $extKey;
                            $em['extInfo'] = $list[$extKey];
                            $content = $this->extensionDetails->uploadExtensionToTER($em);
                            $content .= $this->doc->spacer(10);
                            // Must reload this, because EM_CONF information has been updated!
                            list($list, ) = $this->extensionList->getInstalledExtensions();
                        } else {
                            // headline and CSH
                            $headline = $GLOBALS['LANG']->getLL('ext_details_upload_to_ter');
                            $headline = t3lib_BEfunc::wrapInHelp('_MOD_tools_em', 'upload', $headline);
                            // Upload:
                            if (substr($extKey, 0, 5) != 'user_') {
                                $content = $this->getRepositoryUploadForm($extKey, $list[$extKey]);
                                $eC = 0;
                            } else {
                                $content = $GLOBALS['LANG']->getLL('ext_details_no_unique_ext');
                                $eC = 2;
                            }
                            if (!$this->fe_user['username']) {
                                $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', sprintf($GLOBALS['LANG']->getLL('ext_details_no_username'), '<a href="' . t3lib_div::linkThisScript(array('SET[function]' => 3)) . '">', '</a>'), '', t3lib_FlashMessage::INFO);
                                $content .= '<br />' . $flashMessage->render();
                            }
                        }
                        $this->content .= $this->doc->section($headline, $content, 0, 1, $eC, TRUE);
                        break;
                    case 'backup':
                        if ($this->CMD['doDelete']) {
                            $content = $this->install->extDelete($extKey, $list[$extKey], $this->CMD);
                            $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('ext_details_delete'), $GLOBALS['LANG']->getLL('ext_details_delete'), $content, 0, 1);
                        } else {
                            // headline and CSH
                            $headline = $GLOBALS['LANG']->getLL('ext_details_backup');
                            $headline = t3lib_BEfunc::wrapInHelp('_MOD_tools_em', 'backup_delete', $headline);
                            $content = $this->extBackup($extKey, $list[$extKey]);
                            $this->content .= $this->doc->section($headline, $content, 0, 1, 0, 1);
                            $content = $this->install->extDelete($extKey, $list[$extKey], $this->CMD);
                            $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('ext_details_delete'), $content, 0, 1);
                            $content = $this->extUpdateEMCONF($extKey, $list[$extKey]);
                            $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('ext_details_update_em_conf'), $content, 0, 1);
                        }
                        break;
                    case 'dump':
                        $this->extDumpTables($extKey, $list[$extKey]);
                        break;
                    case 'edit':
                        // headline and CSH
                        $headline = $GLOBALS['LANG']->getLL('ext_details_ext_files');
                        $headline = t3lib_BEfunc::wrapInHelp('_MOD_tools_em', 'editfiles', $headline);
                        $content = $this->getFileListOfExtension($extKey, $list[$extKey]);
                        $this->content .= $this->doc->section($headline, $content, FALSE, TRUE, FALSE, TRUE);
                        break;
                    case 'updateModule':
                        $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('ext_details_update'), is_object($updateObj) ? $updateObj->main() : $GLOBALS['LANG']->getLL('ext_details_no_update_object'), 0, 1);
                        break;
                    default:
                        $this->extObjContent();
                        break;
                }
            }
        }
    }
    /**
     * Creates the HTML for the Table Wizard:
     *
     * @param	array		Table config array
     * @param	array		Current parent record array
     * @return	string		HTML for the table wizard
     * @access private
     */
    function getTableHTML($cfgArr, $row)
    {
        global $LANG;
        // Traverse the rows:
        $tRows = array();
        $k = 0;
        foreach ($cfgArr as $cellArr) {
            if (is_array($cellArr)) {
                // Initialize:
                $cells = array();
                $a = 0;
                // Traverse the columns:
                foreach ($cellArr as $cellContent) {
                    if ($this->inputStyle) {
                        $cells[] = '<input type="text"' . $this->doc->formWidth(20) . ' name="TABLE[c][' . ($k + 1) * 2 . '][' . ($a + 1) * 2 . ']" value="' . htmlspecialchars($cellContent) . '" />';
                    } else {
                        $cellContent = preg_replace('/<br[ ]?[\\/]?>/i', LF, $cellContent);
                        $cells[] = '<textarea ' . $this->doc->formWidth(20) . ' rows="5" name="TABLE[c][' . ($k + 1) * 2 . '][' . ($a + 1) * 2 . ']">' . t3lib_div::formatForTextarea($cellContent) . '</textarea>';
                    }
                    // Increment counter:
                    $a++;
                }
                // CTRL panel for a table row (move up/down/around):
                $onClick = "document.wizardForm.action+='#ANC_" . (($k + 1) * 2 - 2) . "';";
                $onClick = ' onclick="' . htmlspecialchars($onClick) . '"';
                $ctrl = '';
                $brTag = $this->inputStyle ? '' : '<br />';
                if ($k != 0) {
                    $ctrl .= '<input type="image" name="TABLE[row_up][' . ($k + 1) * 2 . ']"' . t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/pil2up.gif', '') . $onClick . ' title="' . $LANG->getLL('table_up', 1) . '" />' . $brTag;
                } else {
                    $ctrl .= '<input type="image" name="TABLE[row_bottom][' . ($k + 1) * 2 . ']"' . t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/turn_up.gif', '') . $onClick . ' title="' . $LANG->getLL('table_bottom', 1) . '" />' . $brTag;
                }
                $ctrl .= '<input type="image" name="TABLE[row_remove][' . ($k + 1) * 2 . ']"' . t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/garbage.gif', '') . $onClick . ' title="' . $LANG->getLL('table_removeRow', 1) . '" />' . $brTag;
                // FIXME what is $tLines? See wizard_forms.php for the same.
                if ($k + 1 != count($tLines)) {
                    $ctrl .= '<input type="image" name="TABLE[row_down][' . ($k + 1) * 2 . ']"' . t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/pil2down.gif', '') . $onClick . ' title="' . $LANG->getLL('table_down', 1) . '" />' . $brTag;
                } else {
                    $ctrl .= '<input type="image" name="TABLE[row_top][' . ($k + 1) * 2 . ']"' . t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/turn_down.gif', '') . $onClick . ' title="' . $LANG->getLL('table_top', 1) . '" />' . $brTag;
                }
                $ctrl .= '<input type="image" name="TABLE[row_add][' . ($k + 1) * 2 . ']"' . t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/add.gif', '') . $onClick . ' title="' . $LANG->getLL('table_addRow', 1) . '" />' . $brTag;
                $tRows[] = '
					<tr class="bgColor4">
						<td class="bgColor5"><a name="ANC_' . ($k + 1) * 2 . '"></a><span class="c-wizButtonsV">' . $ctrl . '</span></td>
						<td>' . implode('</td>
						<td>', $cells) . '</td>
					</tr>';
                // Increment counter:
                $k++;
            }
        }
        // CTRL panel for a table column (move left/right/around/delete)
        $cells = array();
        $cells[] = '';
        // Finding first row:
        reset($cfgArr);
        $firstRow = current($cfgArr);
        if (is_array($firstRow)) {
            // Init:
            $a = 0;
            $cols = count($firstRow);
            // Traverse first row:
            foreach ($firstRow as $temp) {
                $ctrl = '';
                if ($a != 0) {
                    $ctrl .= '<input type="image" name="TABLE[col_left][' . ($a + 1) * 2 . ']"' . t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/pil2left.gif', '') . ' title="' . $LANG->getLL('table_left', 1) . '" />';
                } else {
                    $ctrl .= '<input type="image" name="TABLE[col_end][' . ($a + 1) * 2 . ']"' . t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/turn_left.gif', '') . ' title="' . $LANG->getLL('table_end', 1) . '" />';
                }
                $ctrl .= '<input type="image" name="TABLE[col_remove][' . ($a + 1) * 2 . ']"' . t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/garbage.gif', '') . ' title="' . $LANG->getLL('table_removeColumn', 1) . '" />';
                if ($a + 1 != $cols) {
                    $ctrl .= '<input type="image" name="TABLE[col_right][' . ($a + 1) * 2 . ']"' . t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/pil2right.gif', '') . ' title="' . $LANG->getLL('table_right', 1) . '" />';
                } else {
                    $ctrl .= '<input type="image" name="TABLE[col_start][' . ($a + 1) * 2 . ']"' . t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/turn_right.gif', '') . ' title="' . $LANG->getLL('table_start', 1) . '" />';
                }
                $ctrl .= '<input type="image" name="TABLE[col_add][' . ($a + 1) * 2 . ']"' . t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/add.gif', '') . ' title="' . $LANG->getLL('table_addColumn', 1) . '" />';
                $cells[] = '<span class="c-wizButtonsH">' . $ctrl . '</span>';
                // Incr. counter:
                $a++;
            }
            $tRows[] = '
				<tr class="bgColor5">
					<td align="center">' . implode('</td>
					<td align="center">', $cells) . '</td>
				</tr>';
        }
        $content = '';
        // Implode all table rows into a string, wrapped in table tags.
        $content .= '


			<!--
				Table wizard
			-->
			<table border="0" cellpadding="0" cellspacing="1" id="typo3-tablewizard">
				' . implode('', $tRows) . '
			</table>';
        // Input type checkbox:
        $content .= '

			<!--
				Input mode check box:
			-->
			<div id="c-inputMode">
				' . '<input type="hidden" name="TABLE[textFields]" value="0" />' . '<input type="checkbox" name="TABLE[textFields]" id="textFields" value="1"' . ($this->inputStyle ? ' checked="checked"' : '') . ' /> <label for="textFields">' . $LANG->getLL('table_smallFields') . '</label>
			</div>

			<br /><br />
			';
        // Return content:
        return $content;
    }
    /**
     * 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;
    }
    /**
     * Creates the HTML for the Form Wizard:
     *
     * @param	string		Form config array
     * @param	array		Current parent record array
     * @return	string		HTML for the form wizard
     * @access private
     */
    function getFormHTML($formCfgArray, $row)
    {
        global $LANG;
        // Initialize variables:
        $specParts = array();
        $hiddenFields = array();
        $tRows = array();
        // Set header row:
        $cells = array($LANG->getLL('forms_preview', 1) . ':', $LANG->getLL('forms_element', 1) . ':', $LANG->getLL('forms_config', 1) . ':');
        $tRows[] = '
			<tr class="bgColor2" id="typo3-formWizardHeader">
				<td>&nbsp;</td>
				<td>' . implode('</td>
				<td>', $cells) . '</td>
			</tr>';
        // Traverse the number of form elements:
        $k = 0;
        foreach ($formCfgArray as $confData) {
            // Initialize:
            $cells = array();
            // If there is a configuration line which is active, then render it:
            if (!isset($confData['comment'])) {
                // Special parts:
                if ($this->special == 'formtype_mail' && t3lib_div::inList('formtype_mail,subject,html_enabled', $confData['fieldname'])) {
                    $specParts[$confData['fieldname']] = $confData['default'];
                } else {
                    // Render title/field preview COLUMN
                    $cells[] = $confData['type'] != 'hidden' ? '<strong>' . htmlspecialchars($confData['label']) . '</strong>' : '';
                    // Render general type/title COLUMN:
                    $temp_cells = array();
                    // Field type selector:
                    $opt = array();
                    $opt[] = '<option value=""></option>';
                    $types = explode(',', 'input,textarea,select,check,radio,password,file,hidden,submit,property,label');
                    foreach ($types as $t) {
                        $opt[] = '
								<option value="' . $t . '"' . ($confData['type'] == $t ? ' selected="selected"' : '') . '>' . $LANG->getLL('forms_type_' . $t, 1) . '</option>';
                    }
                    $temp_cells[$LANG->getLL('forms_type')] = '
							<select name="FORMCFG[c][' . ($k + 1) * 2 . '][type]">
								' . implode('
								', $opt) . '
							</select>';
                    // Title field:
                    if (!t3lib_div::inList('hidden,submit', $confData['type'])) {
                        $temp_cells[$LANG->getLL('forms_label')] = '<input type="text"' . $this->doc->formWidth(15) . ' name="FORMCFG[c][' . ($k + 1) * 2 . '][label]" value="' . htmlspecialchars($confData['label']) . '" />';
                    }
                    // Required checkbox:
                    if (!t3lib_div::inList('check,hidden,submit,label', $confData['type'])) {
                        $temp_cells[$LANG->getLL('forms_required')] = '<input type="checkbox" name="FORMCFG[c][' . ($k + 1) * 2 . '][required]" value="1"' . ($confData['required'] ? ' checked="checked"' : '') . ' title="' . $LANG->getLL('forms_required', 1) . '" />';
                    }
                    // Put sub-items together into table cell:
                    $cells[] = $this->formatCells($temp_cells);
                    // Render specific field configuration COLUMN:
                    $temp_cells = array();
                    // Fieldname
                    if ($this->special == 'formtype_mail' && $confData['type'] == 'file') {
                        $confData['fieldname'] = 'attachment' . ++$this->attachmentCounter;
                    }
                    if (!t3lib_div::inList('label', $confData['type'])) {
                        $temp_cells[$LANG->getLL('forms_fieldName')] = '<input type="text"' . $this->doc->formWidth(10) . ' name="FORMCFG[c][' . ($k + 1) * 2 . '][fieldname]" value="' . htmlspecialchars($confData['fieldname']) . '" title="' . $LANG->getLL('forms_fieldName', 1) . '" />';
                    }
                    // Field configuration depending on the fields type:
                    switch ((string) $confData['type']) {
                        case 'textarea':
                            $temp_cells[$LANG->getLL('forms_cols')] = '<input type="text"' . $this->doc->formWidth(5) . ' name="FORMCFG[c][' . ($k + 1) * 2 . '][cols]" value="' . htmlspecialchars($confData['cols']) . '" title="' . $LANG->getLL('forms_cols', 1) . '" />';
                            $temp_cells[$LANG->getLL('forms_rows')] = '<input type="text"' . $this->doc->formWidth(5) . ' name="FORMCFG[c][' . ($k + 1) * 2 . '][rows]" value="' . htmlspecialchars($confData['rows']) . '" title="' . $LANG->getLL('forms_rows', 1) . '" />';
                            $temp_cells[$LANG->getLL('forms_extra')] = '<input type="checkbox" name="FORMCFG[c][' . ($k + 1) * 2 . '][extra]" value="OFF"' . ($confData['extra'] == 'OFF' ? ' checked="checked"' : '') . ' title="' . $LANG->getLL('forms_extra', 1) . '" />';
                            break;
                        case 'input':
                        case 'password':
                            $temp_cells[$LANG->getLL('forms_size')] = '<input type="text"' . $this->doc->formWidth(5) . ' name="FORMCFG[c][' . ($k + 1) * 2 . '][size]" value="' . htmlspecialchars($confData['size']) . '" title="' . $LANG->getLL('forms_size', 1) . '" />';
                            $temp_cells[$LANG->getLL('forms_max')] = '<input type="text"' . $this->doc->formWidth(5) . ' name="FORMCFG[c][' . ($k + 1) * 2 . '][max]" value="' . htmlspecialchars($confData['max']) . '" title="' . $LANG->getLL('forms_max', 1) . '" />';
                            break;
                        case 'file':
                            $temp_cells[$LANG->getLL('forms_size')] = '<input type="text"' . $this->doc->formWidth(5) . ' name="FORMCFG[c][' . ($k + 1) * 2 . '][size]" value="' . htmlspecialchars($confData['size']) . '" title="' . $LANG->getLL('forms_size', 1) . '" />';
                            break;
                        case 'select':
                            $temp_cells[$LANG->getLL('forms_size')] = '<input type="text"' . $this->doc->formWidth(5) . ' name="FORMCFG[c][' . ($k + 1) * 2 . '][size]" value="' . htmlspecialchars($confData['size']) . '" title="' . $LANG->getLL('forms_size', 1) . '" />';
                            $temp_cells[$LANG->getLL('forms_autosize')] = '<input type="checkbox" name="FORMCFG[c][' . ($k + 1) * 2 . '][autosize]" value="1"' . ($confData['autosize'] ? ' checked="checked"' : '') . ' title="' . $LANG->getLL('forms_autosize', 1) . '" />';
                            $temp_cells[$LANG->getLL('forms_multiple')] = '<input type="checkbox" name="FORMCFG[c][' . ($k + 1) * 2 . '][multiple]" value="1"' . ($confData['multiple'] ? ' checked="checked"' : '') . ' title="' . $LANG->getLL('forms_multiple', 1) . '" />';
                            break;
                    }
                    // Field configuration depending on the fields type:
                    switch ((string) $confData['type']) {
                        case 'textarea':
                        case 'input':
                        case 'password':
                            if (strlen(trim($confData['specialEval']))) {
                                $hiddenFields[] = '<input type="hidden" name="FORMCFG[c][' . ($k + 1) * 2 . '][specialEval]" value="' . htmlspecialchars($confData['specialEval']) . '" />';
                            }
                            break;
                    }
                    // Default data
                    if ($confData['type'] == 'select' || $confData['type'] == 'radio') {
                        $temp_cells[$LANG->getLL('forms_options')] = '<textarea ' . $this->doc->formWidthText(15) . ' rows="4" name="FORMCFG[c][' . ($k + 1) * 2 . '][options]" title="' . $LANG->getLL('forms_options', 1) . '">' . t3lib_div::formatForTextarea($confData['default']) . '</textarea>';
                    } elseif ($confData['type'] == 'check') {
                        $temp_cells[$LANG->getLL('forms_checked')] = '<input type="checkbox" name="FORMCFG[c][' . ($k + 1) * 2 . '][default]" value="1"' . (trim($confData['default']) ? ' checked="checked"' : '') . ' title="' . $LANG->getLL('forms_checked', 1) . '" />';
                    } elseif ($confData['type'] && $confData['type'] != 'file') {
                        $temp_cells[$LANG->getLL('forms_default')] = '<input type="text"' . $this->doc->formWidth(15) . ' name="FORMCFG[c][' . ($k + 1) * 2 . '][default]" value="' . htmlspecialchars($confData['default']) . '" title="' . $LANG->getLL('forms_default', 1) . '" />';
                    }
                    $cells[] = $confData['type'] ? $this->formatCells($temp_cells) : '';
                    // CTRL panel for an item (move up/down/around):
                    $ctrl = '';
                    $onClick = "document.wizardForm.action+='#ANC_" . (($k + 1) * 2 - 2) . "';";
                    $onClick = ' onclick="' . htmlspecialchars($onClick) . '"';
                    // FIXME $inputStyle undefined
                    $brTag = $inputStyle ? '' : '<br />';
                    if ($k != 0) {
                        $ctrl .= '<input type="image" name="FORMCFG[row_up][' . ($k + 1) * 2 . ']"' . t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/pil2up.gif', '') . $onClick . ' title="' . $LANG->getLL('table_up', 1) . '" />' . $brTag;
                    } else {
                        $ctrl .= '<input type="image" name="FORMCFG[row_bottom][' . ($k + 1) * 2 . ']"' . t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/turn_up.gif', '') . $onClick . ' title="' . $LANG->getLL('table_bottom', 1) . '" />' . $brTag;
                    }
                    $ctrl .= '<input type="image" name="FORMCFG[row_remove][' . ($k + 1) * 2 . ']"' . t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/garbage.gif', '') . $onClick . ' title="' . $LANG->getLL('table_removeRow', 1) . '" />' . $brTag;
                    // FIXME $tLines undefined
                    if ($k + 1 != count($tLines)) {
                        $ctrl .= '<input type="image" name="FORMCFG[row_down][' . ($k + 1) * 2 . ']"' . t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/pil2down.gif', '') . $onClick . ' title="' . $LANG->getLL('table_down', 1) . '" />' . $brTag;
                    } else {
                        $ctrl .= '<input type="image" name="FORMCFG[row_top][' . ($k + 1) * 2 . ']"' . t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/turn_down.gif', '') . $onClick . ' title="' . $LANG->getLL('table_top', 1) . '" />' . $brTag;
                    }
                    $ctrl .= '<input type="image" name="FORMCFG[row_add][' . ($k + 1) * 2 . ']"' . t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/add.gif', '') . $onClick . ' title="' . $LANG->getLL('table_addRow', 1) . '" />' . $brTag;
                    $ctrl = '<span class="c-wizButtonsV">' . $ctrl . '</span>';
                    // Finally, put together the full row from the generated content above:
                    $bgC = $confData['type'] ? ' class="bgColor5"' : '';
                    $tRows[] = '
						<tr' . $bgC . '>
							<td><a name="ANC_' . ($k + 1) * 2 . '"></a>' . $ctrl . '</td>
							<td class="bgColor4">' . implode('</td>
							<td valign="top">', $cells) . '</td>
						</tr>';
                }
            } else {
                $hiddenFields[] = '<input type="hidden" name="FORMCFG[c][' . ($k + 1) * 2 . '][comment]" value="' . htmlspecialchars($confData['comment']) . '" />';
            }
            // Increment counter:
            $k++;
        }
        // If the form is of the special type "formtype_mail" (used for tt_content elements):
        if ($this->special == 'formtype_mail') {
            // Blank spacer:
            $tRows[] = '
				<tr>
					<td colspan="4">&nbsp;</td>
				</tr>';
            // Header:
            $tRows[] = '
				<tr>
					<td colspan="2" class="bgColor2">&nbsp;</td>
					<td colspan="2" class="bgColor2"><strong>' . $LANG->getLL('forms_special_eform', 1) . ':</strong>' . t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'wizard_forms_wiz_formmail_info', $GLOBALS['BACK_PATH'], '') . '</td>
				</tr>';
            // "FORM type":
            $tRows[] = '
				<tr class="bgColor5">
					<td>&nbsp;</td>
					<td class="bgColor4">&nbsp;</td>
					<td>' . $LANG->getLL('forms_eform_formtype_mail', 1) . ':</td>
					<td>
						<input type="hidden" name="FORMCFG[c][' . 1000 * 2 . '][fieldname]" value="formtype_mail" />
						<input type="hidden" name="FORMCFG[c][' . 1000 * 2 . '][type]" value="submit" />
						<input type="text"' . $this->doc->formWidth(15) . ' name="FORMCFG[c][' . 1000 * 2 . '][default]" value="' . htmlspecialchars($specParts['formtype_mail']) . '" />
					</td>
				</tr>';
            // "Send HTML mail":
            $tRows[] = '
				<tr class="bgColor5">
					<td>&nbsp;</td>
					<td class="bgColor4">&nbsp;</td>
					<td>' . $LANG->getLL('forms_eform_html_enabled', 1) . ':</td>
					<td>
						<input type="hidden" name="FORMCFG[c][' . 1001 * 2 . '][fieldname]" value="html_enabled" />
						<input type="hidden" name="FORMCFG[c][' . 1001 * 2 . '][type]" value="hidden" />
						<input type="checkbox" name="FORMCFG[c][' . 1001 * 2 . '][default]" value="1"' . ($specParts['html_enabled'] ? ' checked="checked"' : '') . ' />
					</td>
				</tr>';
            // "Subject":
            $tRows[] = '
				<tr class="bgColor5">
					<td>&nbsp;</td>
					<td class="bgColor4">&nbsp;</td>
					<td>' . $LANG->getLL('forms_eform_subject', 1) . ':</td>
					<td>
						<input type="hidden" name="FORMCFG[c][' . 1002 * 2 . '][fieldname]" value="subject" />
						<input type="hidden" name="FORMCFG[c][' . 1002 * 2 . '][type]" value="hidden" />
						<input type="text"' . $this->doc->formWidth(15) . ' name="FORMCFG[c][' . 1002 * 2 . '][default]" value="' . htmlspecialchars($specParts['subject']) . '" />
					</td>
				</tr>';
            // Recipient:
            $tRows[] = '
				<tr class="bgColor5">
					<td>&nbsp;</td>
					<td class="bgColor4">&nbsp;</td>
					<td>' . $LANG->getLL('forms_eform_recipient', 1) . ':</td>
					<td>
						<input type="text"' . $this->doc->formWidth(15) . ' name="FORMCFG[recipient]" value="' . htmlspecialchars($row['subheader']) . '" />
					</td>
				</tr>';
        }
        $content = '';
        // Implode all table rows into a string, wrapped in table tags.
        $content .= '

			<!--
				Form wizard
			-->
			<table border="0" cellpadding="1" cellspacing="1" id="typo3-formwizard">
				' . implode('', $tRows) . '
			</table>';
        // Add hidden fields:
        $content .= implode('', $hiddenFields);
        // Return content:
        return $content;
    }
    /**
     * Main function, branching out to rendering functions
     *
     * @return	string		HTML content for the module.
     */
    function main()
    {
        // Set GPvar:
        $this->inputHTML = t3lib_div::_GP('inputHTML');
        $this->removePrefix = trim(t3lib_div::_GP('rmPre'));
        $this->useLimit = t3lib_div::_GP('uselimit');
        // Render input form:
        $content .= '
			<p>Input HTML source here:</p>

			<textarea rows="15" name="inputHTML" wrap="off"' . $GLOBALS['TBE_TEMPLATE']->formWidthText(48, 'width:98%;', 'off') . '>' . t3lib_div::formatForTextarea($this->inputHTML) . '</textarea>

			<br />
			<p>Enter selector prefix to remove: </p>
				<input type="text" name="rmPre" value="' . htmlspecialchars($this->removePrefix) . '" size="50" />
			<p>Enter default filter prefix (or click a selector in table below): </p>
				<input type="text" name="uselimit" value="' . htmlspecialchars($this->useLimit) . '" size="50" />

			<br />
			<input type="submit" name="_submit" value="Analyze" />
		';
        // Parse input content:
        if ($this->inputHTML) {
            $this->parseHTML = t3lib_div::makeInstance('t3lib_parsehtml');
            $bodyParts = $this->parseHTML->splitIntoBlock('body', $this->inputHTML, 1);
            list($analysedResult, $thisSelectors) = $this->getHierarchy($bodyParts[1]);
            $this->foundSelectors = array_keys(array_flip($this->foundSelectors));
            $rows = array();
            $textarea = array();
            foreach ($this->foundSelectors as $v) {
                if (!$this->useLimit || t3lib_div::isFirstPartOfStr($v, $this->useLimit)) {
                    $v_orig = $v;
                    if ($this->removePrefix) {
                        if (t3lib_div::isFirstPartOfStr(trim($v), $this->removePrefix)) {
                            $v = trim(substr(trim($v), strlen($this->removePrefix)));
                        }
                    }
                    if (trim($v)) {
                        $rows[] = '
							<tr class="bgColor4">
								<td nowrap="nowrap">' . htmlspecialchars($v) . '</td>
								<td><a href="#" onclick="' . htmlspecialchars('document.forms[0].uselimit.value=unescape(\'' . rawurlencode(trim($v_orig)) . '\'); document.forms[0].submit(); return false;') . '">[LIMIT]</a></td>
								<td><a href="#" onclick="' . htmlspecialchars('document.forms[0].rmPre.value=unescape(\'' . rawurlencode(trim($v_orig)) . '\'); document.forms[0].submit(); return false;') . '">[REM. PREFIX]</a></td>
							</tr>';
                        $textarea[] = trim($v) . ' {}';
                    }
                }
            }
            $content .= '<hr />

				<!--
					Listing of selectors (in table):
				-->
				<table border="0" cellpadding="2" cellspacing="2">
					' . implode(chr(10), $rows) . '
				</table>
				<br />

				<!--
					Listing of selectors (in textarea field):
				-->
				<textarea rows="' . t3lib_div::intInRange(count($textarea) + 2, 5, 30) . '" name="" wrap="off"' . $GLOBALS['TBE_TEMPLATE']->formWidthText(48, 'width:98%;', 'off') . '>' . t3lib_div::formatForTextarea(implode(chr(10), $textarea)) . '
				</textarea>
				<hr />
				';
        }
        // Return content:
        return $content;
    }
示例#21
0
	/**
	 * Step 5: Create dynamic menu
	 *
	 * @param	string		Type of menu (main or sub), values: "field_menu" or "field_submenu"
	 * @return	void
	 */
	function wizard_step5($menuField)	{

		$menuPart = $this->getMenuDefaultCode($menuField);
		$menuType = $menuField === 'field_menu' ? 'mainMenu' : 'subMenu';
		$menuTypeText = $menuField === 'field_menu' ? 'main menu' : 'sub menu';
		$menuTypeLetter = $menuField === 'field_menu' ? 'a' : 'b';
		$menuTypeNextStep = $menuField === 'field_menu' ? 5.1 : 6;
		$menuTypeEntryLevel = $menuField === 'field_menu' ? 0 : 1;

		$this->saveMenuCode();

		if (strlen($menuPart))	{

				// Main message:
			$outputString.=  sprintf($GLOBALS['LANG']->getLL('newsitewizard_basicsshouldwork', 1), $menuTypeText, $menuType, $menuTypeText);

				// Start up HTML parser:
			require_once(PATH_t3lib.'class.t3lib_parsehtml.php');
			$htmlParser = t3lib_div::makeinstance('t3lib_parsehtml');

				// Parse into blocks
			$parts = $htmlParser->splitIntoBlock('td,tr,table,a,div,span,ol,ul,li,p,h1,h2,h3,h4,h5',$menuPart,1);

				// If it turns out to be only a single large block we expect it to be a container for the menu item. Therefore we will parse the next level and expect that to be menu items:
			if (count($parts)==3)	{
				$totalWrap = array();
				$totalWrap['before'] = $parts[0].$htmlParser->getFirstTag($parts[1]);
				$totalWrap['after'] = '</'.strtolower($htmlParser->getFirstTagName($parts[1])).'>'.$parts[2];

				$parts = $htmlParser->splitIntoBlock('td,tr,table,a,div,span,ol,ul,li,p,h1,h2,h3,h4,h5',$htmlParser->removeFirstAndLastTag($parts[1]),1);
			} else {
				$totalWrap = array();
			}

			$menuPart_HTML = trim($totalWrap['before']).chr(10).implode(chr(10),$parts).chr(10).trim($totalWrap['after']);

				// Traverse expected menu items:
			$menuWraps = array();
			$GMENU = FALSE;
			$mouseOver = FALSE;
			$key = '';

			foreach($parts as $k => $value)	{
				if ($k%2)	{	// Only expecting inner elements to be of use:

					$linkTag = $htmlParser->splitIntoBlock('a',$value,1);
					if ($linkTag[1])	{
						$newValue = array();
						$attribs = $htmlParser->get_tag_attributes($htmlParser->getFirstTag($linkTag[1]),1);
						$newValue['A-class'] = $attribs[0]['class'];
						if ($attribs[0]['onmouseover'] && $attribs[0]['onmouseout'])	$mouseOver = TRUE;

							// Check if the complete content is an image - then make GMENU!
						$linkContent = trim($htmlParser->removeFirstAndLastTag($linkTag[1]));
						if (preg_match('/^<img[^>]*>$/i',$linkContent))	{
							$GMENU = TRUE;
							$attribs = $htmlParser->get_tag_attributes($linkContent,1);
							$newValue['I-class'] = $attribs[0]['class'];
							$newValue['I-width'] = $attribs[0]['width'];
							$newValue['I-height'] = $attribs[0]['height'];

							$filePath = t3lib_div::getFileAbsFileName(t3lib_div::resolveBackPath(PATH_site.$attribs[0]['src']));
							if (@is_file($filePath))	{
								$newValue['backColorGuess'] = $this->getBackgroundColor($filePath);
							} else $newValue['backColorGuess'] = '';

							if ($attribs[0]['onmouseover'] && $attribs[0]['onmouseout'])	$mouseOver = TRUE;
						}

						$linkTag[1] = '|';
						$newValue['wrap'] = preg_replace('/['.chr(10).chr(13).']*/','',implode('',$linkTag));

						$md5Base = $newValue;
						unset($md5Base['I-width']);
						unset($md5Base['I-height']);
						$md5Base = serialize($md5Base);
						$md5Base = preg_replace('/name=["\'][^"\']*["\']/','',$md5Base);
						$md5Base = preg_replace('/id=["\'][^"\']*["\']/','',$md5Base);
						$md5Base = preg_replace('/\s/','',$md5Base);
						$key = md5($md5Base);

						if (!isset($menuWraps[$key]))	{	// Only if not yet set, set it (so it only gets set once and the first time!)
							$menuWraps[$key] = $newValue;
						} else {	// To prevent from writing values in the "} elseif ($key) {" below, we clear the key:
							$key = '';
						}
					} elseif ($key) {

							// Add this to the previous wrap:
						$menuWraps[$key]['bulletwrap'].= str_replace('|','&#'.ord('|').';',preg_replace('/['.chr(10).chr(13).']*/','',$value));
					}
				}
			}

				// Construct TypoScript for the menu:
			reset($menuWraps);
			if (count($menuWraps)==1)	{
				$menu_normal = current($menuWraps);
				$menu_active = next($menuWraps);
			} else { 	// If more than two, then the first is the active one.
				$menu_active = current($menuWraps);
				$menu_normal = next($menuWraps);
			}

#debug($menuWraps);
#debug($mouseOver);
			if ($GMENU)	{
				$typoScript = '
lib.'.$menuType.' = HMENU
lib.'.$menuType.'.entryLevel = '.$menuTypeEntryLevel.'
'.(count($totalWrap) ? 'lib.'.$menuType.'.wrap = '.preg_replace('/['.chr(10).chr(13).']/','',implode('|',$totalWrap)) : '').'
lib.'.$menuType.'.1 = GMENU
lib.'.$menuType.'.1.NO.wrap = '.$this->makeWrap($menu_normal).
	($menu_normal['I-class'] ? '
lib.'.$menuType.'.1.NO.imgParams = class="'.htmlspecialchars($menu_normal['I-class']).'" ' : '').'
lib.'.$menuType.'.1.NO {
	XY = '.($menu_normal['I-width']?$menu_normal['I-width']:150).','.($menu_normal['I-height']?$menu_normal['I-height']:25).'
	backColor = '.($menu_normal['backColorGuess'] ? $menu_normal['backColorGuess'] : '#FFFFFF').'
	10 = TEXT
	10.text.field = title // nav_title
	10.fontColor = #333333
	10.fontSize = 12
	10.offset = 15,15
	10.fontFace = t3lib/fonts/nimbus.ttf
}
	';

				if ($mouseOver)	{
					$typoScript.= '
lib.'.$menuType.'.1.RO < lib.'.$menuType.'.1.NO
lib.'.$menuType.'.1.RO = 1
lib.'.$menuType.'.1.RO {
	backColor = '.t3lib_div::modifyHTMLColorAll(($menu_normal['backColorGuess'] ? $menu_normal['backColorGuess'] : '#FFFFFF'),-20).'
	10.fontColor = red
}
			';

				}
				if (is_array($menu_active))	{
					$typoScript.= '
lib.'.$menuType.'.1.ACT < lib.'.$menuType.'.1.NO
lib.'.$menuType.'.1.ACT = 1
lib.'.$menuType.'.1.ACT.wrap = '.$this->makeWrap($menu_active).
	($menu_active['I-class'] ? '
lib.'.$menuType.'.1.ACT.imgParams = class="'.htmlspecialchars($menu_active['I-class']).'" ' : '').'
lib.'.$menuType.'.1.ACT {
	backColor = '.($menu_active['backColorGuess'] ? $menu_active['backColorGuess'] : '#FFFFFF').'
}
			';
				}

			} else {
				$typoScript = '
lib.'.$menuType.' = HMENU
lib.'.$menuType.'.entryLevel = '.$menuTypeEntryLevel.'
'.(count($totalWrap) ? 'lib.'.$menuType.'.wrap = '.preg_replace('/['.chr(10).chr(13).']/','',implode('|',$totalWrap)) : '').'
lib.'.$menuType.'.1 = TMENU
lib.'.$menuType.'.1.NO {
	allWrap = '.$this->makeWrap($menu_normal).
	($menu_normal['A-class'] ? '
	ATagParams = class="'.htmlspecialchars($menu_normal['A-class']).'"' : '').'
}
	';

				if (is_array($menu_active))	{
					$typoScript.= '
lib.'.$menuType.'.1.ACT = 1
lib.'.$menuType.'.1.ACT {
	allWrap = '.$this->makeWrap($menu_active).
	($menu_active['A-class'] ? '
	ATagParams = class="'.htmlspecialchars($menu_active['A-class']).'"' : '').'
}
			';
				}
			}


				// Output:

				// HTML defaults:
			$outputString.='
			<br/>
			<br/>
			' . $GLOBALS['LANG']->getLL('newsitewizard_menuhtmlcode', 1) . '
			<hr/>
			<pre>'.htmlspecialchars($menuPart_HTML).'</pre>
			<hr/>
			<br/>';


			if (trim($menu_normal['wrap']) != '|')	{
				$outputString .= sprintf($GLOBALS['LANG']->getLL('newsitewizard_menuenc', 1), htmlspecialchars(str_replace('|', ' ... ', $menu_normal['wrap'])));
			} else {
				$outputString .= $GLOBALS['LANG']->getLL('newsitewizard_menunoa', 1);
			}
			if (count($totalWrap))	{
				$outputString .= sprintf($GLOBALS['LANG']->getLL('newsitewizard_menuwrap', 1), htmlspecialchars(str_replace('|', ' ... ', implode('|', $totalWrap))));
			}
			if ($menu_normal['bulletwrap'])	{
				$outputString .= sprintf($GLOBALS['LANG']->getLL('newsitewizard_menudiv', 1), htmlspecialchars($menu_normal['bulletwrap']));
			}
			if ($GMENU)	{
				$outputString .= $GLOBALS['LANG']->getLL('newsitewizard_menuimg', 1);
			}
			if ($mouseOver)	{
				$outputString .= $GLOBALS['LANG']->getLL('newsitewizard_menumouseover', 1);
			}

			$outputString .= '<br/><br/>';
			$outputString .= $GLOBALS['LANG']->getLL('newsitewizard_menuts', 1) . '
			<br/><br/>';
			$outputString.='<hr/>'.$this->syntaxHLTypoScript($typoScript).'<hr/><br/>';


			$outputString .= $GLOBALS['LANG']->getLL('newsitewizard_menufinetune', 1);
			$outputString .= '<textarea name="CFG[menuCode]"'.$GLOBALS['TBE_TEMPLATE']->formWidthText().' rows="10">'.t3lib_div::formatForTextarea($typoScript).'</textarea><br/><br/>';
			$outputString .= '<input type="hidden" name="SET[wiz_step]" value="'.$menuTypeNextStep.'" />';
			$outputString .= '<input type="submit" name="_" value="' . sprintf($GLOBALS['LANG']->getLL('newsitewizard_menuwritets', 1), $menuTypeText) . '" />';
		} else {
			$outputString.= sprintf($GLOBALS['LANG']->getLL('newsitewizard_menufinished', 1), $menuTypeText) . '<br />';
			$outputString.='<input type="hidden" name="SET[wiz_step]" value="'.$menuTypeNextStep.'" />';
			$outputString.='<input type="submit" name="_" value="' . $GLOBALS['LANG']->getLL('newsitewizard_menunext', 1) . '" />';
		}

			// Add output:
		$this->content.= $this->doc->section(sprintf($GLOBALS['LANG']->getLL('newsitewizard_step5', 1), $menuTypeLetter), $outputString, 0, 1);

	}
    /**
     * Generation of TCEform elements of the type "text"
     * This will render a <textarea> OR RTE area form field, possibly with various control/validation features
     *
     * @param	string		The table name of the record
     * @param	string		The field name which this element is supposed to edit
     * @param	array		The record data array where the value(s) for the field can be found
     * @param	array		An array with additional configuration options.
     * @return	string		The HTML code for the TCEform field
     */
    function getSingleField_typeText($table, $field, $row, &$PA)
    {
        // Init config:
        $config = $PA['fieldConf']['config'];
        $evalList = t3lib_div::trimExplode(',', $config['eval'], 1);
        if ($this->renderReadonly || $config['readOnly']) {
            return $this->getSingleField_typeNone_render($config, $PA['itemFormElValue']);
        }
        // Setting columns number:
        $cols = t3lib_div::intInRange($config['cols'] ? $config['cols'] : 30, 5, $this->maxTextareaWidth);
        // Setting number of rows:
        $origRows = $rows = t3lib_div::intInRange($config['rows'] ? $config['rows'] : 5, 1, 20);
        if (strlen($PA['itemFormElValue']) > $this->charsPerRow * 2) {
            $cols = $this->maxTextareaWidth;
            $rows = t3lib_div::intInRange(round(strlen($PA['itemFormElValue']) / $this->charsPerRow), count(explode(LF, $PA['itemFormElValue'])), 20);
            if ($rows < $origRows) {
                $rows = $origRows;
            }
        }
        if (in_array('required', $evalList)) {
            $this->requiredFields[$table . '_' . $row['uid'] . '_' . $field] = $PA['itemFormElName'];
        }
        // Init RTE vars:
        $RTEwasLoaded = 0;
        // Set true, if the RTE is loaded; If not a normal textarea is shown.
        $RTEwouldHaveBeenLoaded = 0;
        // Set true, if the RTE would have been loaded if it wasn't for the disable-RTE flag in the bottom of the page...
        // "Extra" configuration; Returns configuration for the field based on settings found in the "types" fieldlist. Traditionally, this is where RTE configuration has been found.
        $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
        // Setting up the altItem form field, which is a hidden field containing the value
        $altItem = '<input type="hidden" name="' . htmlspecialchars($PA['itemFormElName']) . '" value="' . htmlspecialchars($PA['itemFormElValue']) . '" />';
        // If RTE is generally enabled (TYPO3_CONF_VARS and user settings)
        if ($this->RTEenabled) {
            $p = t3lib_BEfunc::getSpecConfParametersFromArray($specConf['rte_transform']['parameters']);
            if (isset($specConf['richtext']) && (!$p['flag'] || !$row[$p['flag']])) {
                // If the field is configured for RTE and if any flag-field is not set to disable it.
                t3lib_BEfunc::fixVersioningPid($table, $row);
                list($tscPID, $thePidValue) = $this->getTSCpid($table, $row['uid'], $row['pid']);
                // If the pid-value is not negative (that is, a pid could NOT be fetched)
                if ($thePidValue >= 0) {
                    $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE', t3lib_BEfunc::getPagesTSconfig($tscPID));
                    $RTEtypeVal = t3lib_BEfunc::getTCAtypeValue($table, $row);
                    $thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup['properties'], $table, $field, $RTEtypeVal);
                    if (!$thisConfig['disabled']) {
                        if (!$this->disableRTE) {
                            $this->RTEcounter++;
                            // Find alternative relative path for RTE images/links:
                            $eFile = t3lib_parsehtml_proc::evalWriteFile($specConf['static_write'], $row);
                            $RTErelPath = is_array($eFile) ? dirname($eFile['relEditFile']) : '';
                            // Get RTE object, draw form and set flag:
                            $RTEobj = t3lib_BEfunc::RTEgetObj();
                            $item = $RTEobj->drawRTE($this, $table, $field, $row, $PA, $specConf, $thisConfig, $RTEtypeVal, $RTErelPath, $thePidValue);
                            // Wizard:
                            $item = $this->renderWizards(array($item, $altItem), $config['wizards'], $table, $row, $field, $PA, $PA['itemFormElName'], $specConf, 1);
                            $RTEwasLoaded = 1;
                        } else {
                            $RTEwouldHaveBeenLoaded = 1;
                            $this->commentMessages[] = $PA['itemFormElName'] . ': RTE is disabled by the on-page RTE-flag (probably you can enable it by the check-box in the bottom of this page!)';
                        }
                    } else {
                        $this->commentMessages[] = $PA['itemFormElName'] . ': RTE is disabled by the Page TSconfig, "RTE"-key (eg. by RTE.default.disabled=0 or such)';
                    }
                } else {
                    $this->commentMessages[] = $PA['itemFormElName'] . ': PID value could NOT be fetched. Rare error, normally with new records.';
                }
            } else {
                if (!isset($specConf['richtext'])) {
                    $this->commentMessages[] = $PA['itemFormElName'] . ': RTE was not configured for this field in TCA-types';
                }
                if (!(!$p['flag'] || !$row[$p['flag']])) {
                    $this->commentMessages[] = $PA['itemFormElName'] . ': Field-flag (' . $PA['flag'] . ') has been set to disable RTE!';
                }
            }
        }
        // Display ordinary field if RTE was not loaded.
        if (!$RTEwasLoaded) {
            if ($specConf['rte_only']) {
                // Show message, if no RTE (field can only be edited with RTE!)
                $item = '<p><em>' . htmlspecialchars($this->getLL('l_noRTEfound')) . '</em></p>';
            } else {
                if ($specConf['nowrap']) {
                    $wrap = 'off';
                } else {
                    $wrap = $config['wrap'] ? $config['wrap'] : 'virtual';
                }
                $classes = array();
                if ($specConf['fixed-font']) {
                    $classes[] = 'fixed-font';
                }
                if ($specConf['enable-tab']) {
                    $classes[] = 'enable-tab';
                }
                $formWidthText = $this->formWidthText($cols, $wrap);
                // Extract class attributes from $formWidthText (otherwise it would be added twice to the output)
                $res = array();
                if (preg_match('/ class="(.+?)"/', $formWidthText, $res)) {
                    $formWidthText = str_replace(' class="' . $res[1] . '"', '', $formWidthText);
                    $classes = array_merge($classes, explode(' ', $res[1]));
                }
                if (count($classes)) {
                    $class = ' class="tceforms-textarea ' . implode(' ', $classes) . '"';
                } else {
                    $class = 'tceforms-textarea';
                }
                $evalList = t3lib_div::trimExplode(',', $config['eval'], 1);
                foreach ($evalList as $func) {
                    switch ($func) {
                        case 'required':
                            $this->registerRequiredProperty('field', $table . '_' . $row['uid'] . '_' . $field, $PA['itemFormElName']);
                            break;
                        default:
                            if (substr($func, 0, 3) == 'tx_') {
                                // Pair hook to the one in t3lib_TCEmain::checkValue_input_Eval() and t3lib_TCEmain::checkValue_text_Eval()
                                $evalObj = t3lib_div::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$func] . ':&' . $func);
                                if (is_object($evalObj) && method_exists($evalObj, 'deevaluateFieldValue')) {
                                    $_params = array('value' => $PA['itemFormElValue']);
                                    $PA['itemFormElValue'] = $evalObj->deevaluateFieldValue($_params);
                                }
                            }
                            break;
                    }
                }
                $iOnChange = implode('', $PA['fieldChangeFunc']);
                $item .= '
							<textarea id="' . uniqid('tceforms-textarea-') . '" name="' . $PA['itemFormElName'] . '"' . $formWidthText . $class . ' rows="' . $rows . '" wrap="' . $wrap . '" onchange="' . htmlspecialchars($iOnChange) . '"' . $PA['onFocus'] . '>' . t3lib_div::formatForTextarea($PA['itemFormElValue']) . '</textarea>';
                $item = $this->renderWizards(array($item, $altItem), $config['wizards'], $table, $row, $field, $PA, $PA['itemFormElName'], $specConf, $RTEwouldHaveBeenLoaded);
            }
        }
        // Return field HTML:
        return $item;
    }
    /**
     * The main processing method if this class
     *
     * @return	string		Information of the template status or the taken actions as HTML string
     */
    function main()
    {
        global $SOBE, $BE_USER, $LANG, $BACK_PATH, $TCA_DESCR, $TCA, $CLIENT, $TYPO3_CONF_VARS;
        global $tmpl, $tplRow, $theConstants;
        $edit = $this->pObj->edit;
        $e = $this->pObj->e;
        t3lib_div::loadTCA('sys_template');
        // **************************
        // Checking for more than one template an if, set a menu...
        // **************************
        $manyTemplatesMenu = $this->pObj->templateMenu();
        $template_uid = 0;
        if ($manyTemplatesMenu) {
            $template_uid = $this->pObj->MOD_SETTINGS['templatesOnPage'];
        }
        // **************************
        // Initialize
        // **************************
        $existTemplate = $this->initialize_editor($this->pObj->id, $template_uid);
        // initialize
        if ($existTemplate) {
            $saveId = $tplRow['_ORIG_uid'] ? $tplRow['_ORIG_uid'] : $tplRow['uid'];
        }
        // **************************
        // Create extension template
        // **************************
        $newId = $this->pObj->createTemplate($this->pObj->id, $saveId);
        if ($newId) {
            // switch to new template
            t3lib_utility_Http::redirect('index.php?id=' . $this->pObj->id . '&SET[templatesOnPage]=' . $newId);
        }
        if ($existTemplate) {
            // Update template ?
            $POST = t3lib_div::_POST();
            if ($POST['submit'] || t3lib_div::testInt($POST['submit_x']) && t3lib_div::testInt($POST['submit_y']) || $POST['saveclose'] || t3lib_div::testInt($POST['saveclose_x']) && t3lib_div::testInt($POST['saveclose_y'])) {
                // Set the data to be saved
                $recData = array();
                $alternativeFileName = array();
                $resList = $tplRow['resources'];
                $tmp_upload_name = '';
                $tmp_newresource_name = '';
                // Set this to blank
                if (is_array($POST['data'])) {
                    foreach ($POST['data'] as $field => $val) {
                        switch ($field) {
                            case 'constants':
                            case 'config':
                            case 'title':
                            case 'sitetitle':
                            case 'description':
                                $recData['sys_template'][$saveId][$field] = $val;
                                break;
                            case 'resources':
                                $tmp_upload_name = t3lib_div::upload_to_tempfile($_FILES['resources']['tmp_name']);
                                // If there is an uploaded file, move it for the sake of safe_mode.
                                if ($tmp_upload_name) {
                                    if ($tmp_upload_name != 'none' && $_FILES['resources']['name']) {
                                        $alternativeFileName[$tmp_upload_name] = trim($_FILES['resources']['name']);
                                        $resList = $tmp_upload_name . ',' . $resList;
                                    }
                                }
                                break;
                            case 'new_resource':
                                $newName = trim(t3lib_div::_GP('new_resource'));
                                if ($newName) {
                                    $newName .= '.' . t3lib_div::_GP('new_resource_ext');
                                    $tmp_newresource_name = t3lib_div::tempnam('new_resource_');
                                    $alternativeFileName[$tmp_newresource_name] = $newName;
                                    $resList = $tmp_newresource_name . ',' . $resList;
                                }
                                break;
                            case 'makecopy_resource':
                                if (is_array($val)) {
                                    $resList = ',' . $resList . ',';
                                    foreach ($val as $k => $file) {
                                        $tmp_name = PATH_site . $TCA['sys_template']['columns']['resources']['config']['uploadfolder'] . '/' . $file;
                                        $resList = $tmp_name . ',' . $resList;
                                    }
                                }
                                break;
                            case 'remove_resource':
                                if (is_array($val)) {
                                    $resList = ',' . $resList . ',';
                                    foreach ($val as $k => $file) {
                                        $resList = str_replace(',' . $file . ',', ',', $resList);
                                    }
                                }
                                break;
                            case 'totop_resource':
                                if (is_array($val)) {
                                    $resList = ',' . $resList . ',';
                                    foreach ($val as $k => $file) {
                                        $resList = str_replace(',' . $file . ',', ',', $resList);
                                        $resList = ',' . $file . $resList;
                                    }
                                }
                                break;
                        }
                    }
                }
                $resList = implode(',', t3lib_div::trimExplode(',', $resList, 1));
                if (strcmp($resList, $tplRow['resources'])) {
                    $recData['sys_template'][$saveId]['resources'] = $resList;
                }
                if (count($recData)) {
                    // Create new  tce-object
                    $tce = t3lib_div::makeInstance('t3lib_TCEmain');
                    $tce->stripslashes_values = 0;
                    $tce->alternativeFileName = $alternativeFileName;
                    // Initialize
                    $tce->start($recData, array());
                    // Saved the stuff
                    $tce->process_datamap();
                    // Clear the cache (note: currently only admin-users can clear the cache in tce_main.php)
                    $tce->clear_cacheCmd('all');
                    // tce were processed successfully
                    $this->tce_processed = true;
                    // re-read the template ...
                    $this->initialize_editor($this->pObj->id, $template_uid);
                }
                // Unlink any uploaded/new temp files there was:
                t3lib_div::unlink_tempfile($tmp_upload_name);
                t3lib_div::unlink_tempfile($tmp_newresource_name);
                // If files has been edited:
                if (is_array($edit)) {
                    if ($edit['filename'] && $tplRow['resources'] && t3lib_div::inList($tplRow['resources'], $edit['filename'])) {
                        // Check if there are resources, and that the file is in the resourcelist.
                        $path = PATH_site . $TCA['sys_template']['columns']['resources']['config']['uploadfolder'] . '/' . $edit['filename'];
                        $fI = t3lib_div::split_fileref($edit['filename']);
                        if (@is_file($path) && t3lib_div::getFileAbsFileName($path) && t3lib_div::inList($this->pObj->textExtensions, $fI['fileext'])) {
                            // checks that have already been done.. Just to make sure
                            // @TODO: Check if the hardcorded value already has a config member, otherwise create one
                            if (filesize($path) < 30720) {
                                // checks that have already been done.. Just to make sure
                                t3lib_div::writeFile($path, $edit['file']);
                                $theOutput .= $this->pObj->doc->spacer(10);
                                $theOutput .= $this->pObj->doc->section('<font color=red>' . $GLOBALS['LANG']->getLL('fileChanged') . '</font>', sprintf($GLOBALS['LANG']->getLL('resourceUpdated'), $edit['filename']), 0, 0, 0, 1);
                                // Clear cache - the file has probably affected the template setup
                                // @TODO: Check if the edited file really had something to do with cached data and prevent this clearing if possible!
                                $tce = t3lib_div::makeInstance('t3lib_TCEmain');
                                $tce->stripslashes_values = 0;
                                $tce->start(array(), array());
                                $tce->clear_cacheCmd('all');
                            }
                        }
                    }
                }
            }
            // hook	Post updating template/TCE processing
            if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postTCEProcessingHook'])) {
                $postTCEProcessingHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postTCEProcessingHook'];
                if (is_array($postTCEProcessingHook)) {
                    $hookParameters = array('POST' => $POST, 'tce' => $tce);
                    foreach ($postTCEProcessingHook as $hookFunction) {
                        t3lib_div::callUserFunction($hookFunction, $hookParameters, $this);
                    }
                }
            }
            $theOutput .= $this->pObj->doc->spacer(5);
            $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('templateInformation'), t3lib_iconWorks::getSpriteIconForRecord('sys_template', $tplRow) . '<strong>' . htmlspecialchars($tplRow['title']) . '</strong>' . htmlspecialchars(trim($tplRow['sitetitle']) ? ' - (' . $tplRow['sitetitle'] . ')' : ''), 0, 1);
            if ($manyTemplatesMenu) {
                $theOutput .= $this->pObj->doc->section('', $manyTemplatesMenu);
                $theOutput .= $this->pObj->doc->divider(5);
            }
            #$numberOfRows= t3lib_div::intInRange($this->pObj->MOD_SETTINGS["ts_template_editor_TArows"],0,150);
            #if (!$numberOfRows)
            $numberOfRows = 35;
            // If abort pressed, nothing should be edited:
            if ($POST['abort'] || t3lib_div::testInt($POST['abort_x']) && t3lib_div::testInt($POST['abort_y']) || $POST['saveclose'] || t3lib_div::testInt($POST['saveclose_x']) && t3lib_div::testInt($POST['saveclose_y'])) {
                unset($e);
            }
            if ($e['title']) {
                $outCode = '<input type="Text" name="data[title]" value="' . htmlspecialchars($tplRow['title']) . '"' . $this->pObj->doc->formWidth() . '>';
                $outCode .= '<input type="Hidden" name="e[title]" value="1">';
                $theOutput .= $this->pObj->doc->spacer(15);
                $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('title'), $outCode);
            }
            if ($e['sitetitle']) {
                $outCode = '<input type="Text" name="data[sitetitle]" value="' . htmlspecialchars($tplRow['sitetitle']) . '"' . $this->pObj->doc->formWidth() . '>';
                $outCode .= '<input type="Hidden" name="e[sitetitle]" value="1">';
                $theOutput .= $this->pObj->doc->spacer(15);
                $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('sitetitle'), $outCode);
            }
            if ($e['description']) {
                $outCode = '<textarea name="data[description]" rows="5" class="fixed-font enable-tab"' . $this->pObj->doc->formWidthText(48, '', '') . '>' . t3lib_div::formatForTextarea($tplRow['description']) . '</textarea>';
                $outCode .= '<input type="Hidden" name="e[description]" value="1">';
                $theOutput .= $this->pObj->doc->spacer(15);
                $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('description'), $outCode);
            }
            if ($e['resources']) {
                // Upload
                $outCode = '<input type="File" name="resources"' . $this->pObj->doc->formWidth() . ' size="50">';
                $outCode .= '<input type="Hidden" name="data[resources]" value="1">';
                $outCode .= '<input type="Hidden" name="e[resources]" value="1">';
                $outCode .= '<BR>' . $GLOBALS['LANG']->getLL('allowedExtensions') . ' <strong>' . $TCA['sys_template']['columns']['resources']['config']['allowed'] . '</strong>';
                $outCode .= '<BR>' . $GLOBALS['LANG']->getLL('maxFilesize') . ' <strong>' . t3lib_div::formatSize($TCA['sys_template']['columns']['resources']['config']['max_size'] * 1024) . '</strong>';
                $theOutput .= $this->pObj->doc->spacer(15);
                $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('uploadResource'), $outCode);
                // New
                $opt = explode(',', $this->pObj->textExtensions);
                $optTags = '';
                foreach ($opt as $extVal) {
                    $optTags .= '<option value="' . $extVal . '">.' . $extVal . '</option>';
                }
                $outCode = '<input type="text" name="new_resource"' . $this->pObj->doc->formWidth(20) . '>
					<select name="new_resource_ext">' . $optTags . '</select>';
                $outCode .= '<input type="Hidden" name="data[new_resource]" value="1">';
                $theOutput .= $this->pObj->doc->spacer(15);
                $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('newTextResource'), $outCode);
                // Make copy
                $rL = $this->resourceListForCopy($this->pObj->id, $template_uid);
                if ($rL) {
                    $theOutput .= $this->pObj->doc->spacer(20);
                    $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('copyResource'), $rL);
                }
                // Update resource list
                $rL = $this->procesResources($tplRow['resources'], 1);
                if ($rL) {
                    $theOutput .= $this->pObj->doc->spacer(20);
                    $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('updateResourceList'), $rL);
                }
            }
            if ($e['constants']) {
                $outCode = '<textarea name="data[constants]" rows="' . $numberOfRows . '" wrap="off" class="fixed-font enable-tab"' . $this->pObj->doc->formWidthText(48, 'width:98%;height:70%', 'off') . ' class="fixed-font">' . t3lib_div::formatForTextarea($tplRow['constants']) . '</textarea>';
                $outCode .= '<input type="Hidden" name="e[constants]" value="1">';
                $theOutput .= $this->pObj->doc->spacer(15);
                $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('constants'), '');
                $theOutput .= $this->pObj->doc->sectionEnd() . $outCode;
            }
            if ($e['file']) {
                $path = PATH_site . $TCA['sys_template']['columns']['resources']['config']['uploadfolder'] . '/' . $e[file];
                $fI = t3lib_div::split_fileref($e[file]);
                if (@is_file($path) && t3lib_div::inList($this->pObj->textExtensions, $fI['fileext'])) {
                    if (filesize($path) < $TCA['sys_template']['columns']['resources']['config']['max_size'] * 1024) {
                        $fileContent = t3lib_div::getUrl($path);
                        $outCode = $GLOBALS['LANG']->getLL('file') . ' <strong>' . $e[file] . '</strong><BR>';
                        $outCode .= '<textarea name="edit[file]" rows="' . $numberOfRows . '" wrap="off" class="fixed-font enable-tab"' . $this->pObj->doc->formWidthText(48, 'width:98%;height:70%', 'off') . ' class="fixed-font">' . t3lib_div::formatForTextarea($fileContent) . '</textarea>';
                        $outCode .= '<input type="Hidden" name="edit[filename]" value="' . $e[file] . '">';
                        $outCode .= '<input type="Hidden" name="e[file]" value="' . htmlspecialchars($e[file]) . '">';
                        $theOutput .= $this->pObj->doc->spacer(15);
                        $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('editResource'), '');
                        $theOutput .= $this->pObj->doc->sectionEnd() . $outCode;
                    } else {
                        $theOutput .= $this->pObj->doc->spacer(15);
                        $fileToBig = sprintf($GLOBALS['LANG']->getLL('filesizeExceeded'), $TCA['sys_template']['columns']['resources']['config']['max_size']);
                        $filesizeNotAllowed = sprintf($GLOBALS['LANG']->getLL('notAllowed'), $TCA['sys_template']['columns']['resources']['config']['max_size']);
                        $theOutput .= $this->pObj->doc->section('<font color=red>' . $fileToBig . '</font>', $filesizeNotAllowed, 0, 0, 0, 1);
                    }
                }
            }
            if ($e['config']) {
                $outCode = '<textarea name="data[config]" rows="' . $numberOfRows . '" wrap="off" class="fixed-font enable-tab"' . $this->pObj->doc->formWidthText(48, "width:98%;height:70%", "off") . ' class="fixed-font">' . t3lib_div::formatForTextarea($tplRow["config"]) . '</textarea>';
                if (t3lib_extMgm::isLoaded('tsconfig_help')) {
                    $url = $BACK_PATH . 'wizard_tsconfig.php?mode=tsref';
                    $params = array('formName' => 'editForm', 'itemName' => 'data[config]');
                    $outCode .= '<a href="#" onClick="vHWin=window.open(\'' . $url . t3lib_div::implodeArrayForUrl('', array('P' => $params)) . '\',\'popUp' . $md5ID . '\',\'height=500,width=780,status=0,menubar=0,scrollbars=1\');vHWin.focus();return false;">' . t3lib_iconWorks::getSpriteIcon('actions-system-typoscript-documentation-open', array('title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:tsRef', true))) . '</a>';
                }
                $outCode .= '<input type="Hidden" name="e[config]" value="1">';
                $theOutput .= $this->pObj->doc->spacer(15);
                $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('setup'), '');
                $theOutput .= $this->pObj->doc->sectionEnd() . $outCode;
            }
            // Processing:
            $outCode = '';
            $outCode .= $this->tableRow($GLOBALS['LANG']->getLL('title'), htmlspecialchars($tplRow['title']), 'title');
            $outCode .= $this->tableRow($GLOBALS['LANG']->getLL('sitetitle'), htmlspecialchars($tplRow['sitetitle']), 'sitetitle');
            $outCode .= $this->tableRow($GLOBALS['LANG']->getLL('description'), nl2br(htmlspecialchars($tplRow['description'])), 'description');
            $outCode .= $this->tableRow($GLOBALS['LANG']->getLL('resources'), $this->procesResources($tplRow['resources']), 'resources');
            $outCode .= $this->tableRow($GLOBALS['LANG']->getLL('constants'), sprintf($GLOBALS['LANG']->getLL('editToView'), trim($tplRow[constants]) ? count(explode(LF, $tplRow[constants])) : 0), 'constants');
            $outCode .= $this->tableRow($GLOBALS['LANG']->getLL('setup'), sprintf($GLOBALS['LANG']->getLL('editToView'), trim($tplRow[config]) ? count(explode(LF, $tplRow[config])) : 0), 'config');
            $outCode = '<br /><br /><table class="t3-table-info">' . $outCode . '</table>';
            // Edit all icon:
            $outCode .= '<br /><a href="#" onClick="' . t3lib_BEfunc::editOnClick(rawurlencode('&createExtension=0') . '&amp;edit[sys_template][' . $tplRow['uid'] . ']=edit', $BACK_PATH, '') . '"><strong>' . t3lib_iconWorks::getSpriteIcon('actions-document-open', array('title' => $GLOBALS['LANG']->getLL('editTemplateRecord'))) . $GLOBALS['LANG']->getLL('editTemplateRecord') . '</strong></a>';
            $theOutput .= $this->pObj->doc->section('', $outCode);
            // hook	after compiling the output
            if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postOutputProcessingHook'])) {
                $postOutputProcessingHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postOutputProcessingHook'];
                if (is_array($postOutputProcessingHook)) {
                    $hookParameters = array('theOutput' => &$theOutput, 'POST' => $POST, 'e' => $e, 'tplRow' => $tplRow, 'numberOfRows' => $numberOfRows);
                    foreach ($postOutputProcessingHook as $hookFunction) {
                        t3lib_div::callUserFunction($hookFunction, $hookParameters, $this);
                    }
                }
            }
        } else {
            $theOutput .= $this->pObj->noTemplate(1);
        }
        return $theOutput;
    }
    /**
     * Creating TYPO3 Glossary XML file
     *
     * @return	string		HTML content
     */
    function calc_wiki2llxml()
    {
        // Render input form:
        $content = '
			<h3>Input Wiki code for TYPO3 glossary to form a locallang-XML file out of it:</h3>
				<textarea rows="10" name="inputCalc[wiki2llxml][input]" wrap="off"' . $GLOBALS['TBE_TEMPLATE']->formWidthText(48, 'width:98%;', 'off') . '>' . t3lib_div::formatForTextarea($this->inputCalc['wiki2llxml']['input']) . '</textarea>
				<input type="submit" name="cmd[wiki2llxml]" value="Convert" />
		';
        if ($this->cmd == 'wiki2llxml' && trim($this->inputCalc['wiki2llxml']['input'])) {
            $inputValue = $this->inputCalc['wiki2llxml']['input'];
            // Clean out super-headers:
            $inputValue = preg_replace('#([^=])===[[:space:]]*[[:alnum:]]*[[:space:]]*===([^=])#', '${1}${2}', $inputValue);
            // Split by term header:
            $rawTerms = explode('=====', $inputValue);
            $organizedTerms = array();
            $termKey = '';
            foreach ($rawTerms as $k => $v) {
                if ($k % 2 == 0) {
                    if ($termKey) {
                        $tK = $this->calc_wiki2llxml_termkey($termKey);
                        if ($tK) {
                            $organizedTerms[$tK] = array();
                            $rawdata = trim($v);
                            list($description, $moreInfo) = explode("''More info:''", $rawdata, 2);
                            if ($moreInfo) {
                                list($moreInfo, $otherTerms) = explode("''Other matching terms:''", $moreInfo, 2);
                            } else {
                                list($description, $otherTerms) = explode("''Other matching terms:''", $description, 2);
                            }
                            $description = trim(strip_tags($description));
                            $moreInfo = trim(strip_tags($moreInfo));
                            $otherTerms = trim(strip_tags($otherTerms));
                            $organizedTerms[$tK] = array('term' => $termKey, 'RAWDATA' => trim($rawdata), 'description' => $description, 'moreInfo' => $moreInfo, 'otherTerms' => $otherTerms);
                        }
                    }
                } else {
                    $termKey = trim($v);
                }
            }
            // Traverse terms to clean up moreInfo and otherTerms:
            foreach ($organizedTerms as $key => $termData) {
                // Other Terms fixing.
                $oT = t3lib_div::trimExplode(',', $termData['otherTerms'], 1);
                $organizedTerms[$key]['otherTerms'] = array();
                foreach ($oT as $t) {
                    $tK = $this->calc_wiki2llxml_termkey($t);
                    if (isset($organizedTerms[$tK])) {
                        $organizedTerms[$key]['otherTerms'][$tK] = array('type' => 'existing');
                    } elseif ($tK) {
                        $organizedTerms[$tK] = array('RAWDATA' => '[alias for "' . $key . '"]', 'term' => $t, 'description' => 'See "' . $organizedTerms[$key]['term'] . '"', 'otherTerms' => array($key => array('type' => 'existing')));
                        $organizedTerms[$key]['otherTerms'][$tK] = array('type' => 'alias');
                    }
                }
                // More information splitted:
                $termData['moreInfo'] = preg_replace('#\\[\\[([^]]+)\\]\\]#', '[http://wiki.typo3.org/index.php/${1}]', $termData['moreInfo']);
                $parts = preg_split('#(\\[)([^\\]]+)(\\])#', $termData['moreInfo'], 10000, PREG_SPLIT_DELIM_CAPTURE);
                $organizedTerms[$key]['moreInfo'] = array();
                foreach ($parts as $kk => $vv) {
                    if ($kk % 2 == 0) {
                        $link = trim($vv);
                        if ($link && $link != ',') {
                            list($link, $title) = preg_split('#[ |]#', $link, 2);
                            $organizedTerms[$key]['moreInfo'][] = array('url' => $link, 'title' => $title);
                        }
                    }
                }
                // Removal of the RAW data which is not so interesting for us:
                unset($organizedTerms[$key]['RAWDATA']);
            }
            $content .= Tx_Extdeveval_Compatibility::viewArray($organizedTerms);
            ksort($organizedTerms);
            $content .= '
			<textarea rows="10" name="_" wrap="off"' . $GLOBALS['TBE_TEMPLATE']->formWidthText(48, 'width:98%;', 'off') . '>' . t3lib_div::formatForTextarea($this->calc_wiki2llxml_createXML($organizedTerms)) . '</textarea>';
        }
        return $content;
    }
 /**
  * [Describe function...]
  *
  * @param	[type]		$mQ: ...
  * @param	[type]		$res: ...
  * @param	[type]		$table: ...
  * @return	[type]		...
  */
 function getQueryResultCode($mQ, $res, $table)
 {
     global $TCA;
     $output = '';
     $cPR = array();
     switch ($mQ) {
         case 'count':
             $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
             $cPR['header'] = 'Count';
             $cPR['content'] = '<BR><strong>' . $row[0] . '</strong> records selected.';
             break;
         case 'all':
             $rowArr = array();
             while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                 $rowArr[] = $this->resultRowDisplay($row, $TCA[$table], $table);
                 $lrow = $row;
             }
             if (is_array($this->hookArray['beforeResultTable'])) {
                 foreach ($this->hookArray['beforeResultTable'] as $_funcRef) {
                     $out .= t3lib_div::callUserFunction($_funcRef, $GLOBALS['SOBE']->MOD_SETTINGS, $this);
                 }
             }
             if (count($rowArr)) {
                 $out .= '<table border="0" cellpadding="2" cellspacing="1" width="100%">' . $this->resultRowTitles($lrow, $TCA[$table], $table) . implode(LF, $rowArr) . '</table>';
             }
             if (!$out) {
                 $out = '<em>No rows selected!</em>';
             }
             $cPR['header'] = 'Result';
             $cPR['content'] = $out;
             break;
         case 'csv':
             $rowArr = array();
             $first = 1;
             while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                 if ($first) {
                     $rowArr[] = $this->csvValues(array_keys($row), ',', '');
                     $first = 0;
                 }
                 $rowArr[] = $this->csvValues($row, ',', '"', $TCA[$table], $table);
             }
             if (count($rowArr)) {
                 $out .= '<textarea name="whatever" rows="20" wrap="off"' . $GLOBALS['SOBE']->doc->formWidthText($this->formW, '', 'off') . ' class="fixed-font">' . t3lib_div::formatForTextarea(implode(LF, $rowArr)) . '</textarea>';
                 if (!$this->noDownloadB) {
                     $out .= '<BR><input type="submit" name="download_file" value="Click to download file" onClick="window.location.href=\'' . $this->downloadScript . '\';">';
                     // document.forms[0].target=\'_blank\';
                 }
                 // Downloads file:
                 if (t3lib_div::_GP('download_file')) {
                     $filename = 'TYPO3_' . $table . '_export_' . date('dmy-Hi') . '.csv';
                     $mimeType = 'application/octet-stream';
                     header('Content-Type: ' . $mimeType);
                     header('Content-Disposition: attachment; filename=' . $filename);
                     echo implode(CRLF, $rowArr);
                     exit;
                 }
             }
             if (!$out) {
                 $out = '<em>No rows selected!</em>';
             }
             $cPR['header'] = 'Result';
             $cPR['content'] = $out;
             break;
         case 'xml':
             $xmlObj = t3lib_div::makeInstance('t3lib_xml', 'typo3_export');
             $xmlObj->includeNonEmptyValues = 1;
             $xmlObj->renderHeader();
             $first = 1;
             while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                 if ($first) {
                     $xmlObj->setRecFields($table, implode(',', array_keys($row)));
                     $first = 0;
                 }
                 $valueArray = $row;
                 if ($GLOBALS['SOBE']->MOD_SETTINGS['search_result_labels']) {
                     foreach ($valueArray as $key => $val) {
                         $valueArray[$key] = $this->getProcessedValueExtra($table, $key, $val, array(), ',');
                     }
                 }
                 $xmlObj->addRecord($table, $valueArray);
             }
             $xmlObj->renderFooter();
             if ($GLOBALS['TYPO3_DB']->sql_num_rows($res)) {
                 $xmlData = $xmlObj->getResult();
                 $out .= '<textarea name="whatever" rows="20" wrap="off"' . $GLOBALS['SOBE']->doc->formWidthText($this->formW, '', 'off') . ' class="fixed-font">' . t3lib_div::formatForTextarea($xmlData) . '</textarea>';
                 if (!$this->noDownloadB) {
                     $out .= '<BR><input type="submit" name="download_file" value="Click to download file" onClick="window.location.href=\'' . $this->downloadScript . '\';">';
                     // document.forms[0].target=\'_blank\';
                 }
                 // Downloads file:
                 if (t3lib_div::_GP('download_file')) {
                     $filename = 'TYPO3_' . $table . '_export_' . date('dmy-Hi') . '.xml';
                     $mimeType = 'application/octet-stream';
                     header('Content-Type: ' . $mimeType);
                     header('Content-Disposition: attachment; filename=' . $filename);
                     echo $xmlData;
                     exit;
                 }
             }
             if (!$out) {
                 $out = '<em>No rows selected!</em>';
             }
             $cPR['header'] = 'Result';
             $cPR['content'] = $out;
             break;
         case 'explain':
         default:
             while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                 $out .= '<br />' . t3lib_utility_Debug::viewArray($row);
             }
             $cPR['header'] = 'Explain SQL query';
             $cPR['content'] = $out;
             break;
     }
     return $cPR;
 }
示例#26
0
    /**
     * Main function, redering the actual content of the editing page
     *
     * @return	void
     */
    function main()
    {
        //TODO remove global, change $LANG into $GLOBALS['LANG'], change locallang*.php to locallang*.xml
        global $BE_USER, $LANG, $TYPO3_CONF_VARS;
        $docHeaderButtons = $this->getButtons();
        $this->content = $this->doc->startPage($LANG->sL('LLL:EXT:lang/locallang_core.php:file_edit.php.pagetitle'));
        // hook	before compiling the output
        if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/file_edit.php']['preOutputProcessingHook'])) {
            $preOutputProcessingHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/file_edit.php']['preOutputProcessingHook'];
            if (is_array($preOutputProcessingHook)) {
                $hookParameters = array('content' => &$this->content, 'target' => &$this->target);
                foreach ($preOutputProcessingHook as $hookFunction) {
                    t3lib_div::callUserFunction($hookFunction, $hookParameters, $this);
                }
            }
        }
        $pageContent = $this->doc->header($LANG->sL('LLL:EXT:lang/locallang_core.php:file_edit.php.pagetitle'));
        $pageContent .= $this->doc->spacer(2);
        $fI = pathinfo($this->target);
        $extList = $TYPO3_CONF_VARS['SYS']['textfile_ext'];
        if ($extList && t3lib_div::inList($extList, strtolower($fI['extension']))) {
            // Read file content to edit:
            $fileContent = t3lib_div::getUrl($this->target);
            // making the formfields
            $hValue = 'file_edit.php?target=' . rawurlencode($this->origTarget) . '&returnUrl=' . rawurlencode($this->returnUrl);
            // Edit textarea:
            $code .= '
				<div id="c-edit">
					<textarea rows="30" name="file[editfile][0][data]" wrap="off"' . $this->doc->formWidthText(48, 'width:98%;height:80%', 'off') . ' class="fixed-font enable-tab">' . t3lib_div::formatForTextarea($fileContent) . '</textarea>
					<input type="hidden" name="file[editfile][0][target]" value="' . $this->target . '" />
					<input type="hidden" name="redirect" value="' . htmlspecialchars($hValue) . '" />
				</div>
				<br />';
            // Make shortcut:
            if ($BE_USER->mayMakeShortcut()) {
                $this->MCONF['name'] = 'xMOD_file_edit.php';
                $docHeaderButtons['shortcut'] = $this->doc->makeShortcutIcon('target', '', $this->MCONF['name'], 1);
            }
        } else {
            $code .= sprintf($LANG->sL('LLL:EXT:lang/locallang_core.php:file_edit.php.coundNot'), $extList);
        }
        // Ending of section and outputting editing form:
        $pageContent .= $this->doc->sectionEnd();
        $pageContent .= $code;
        // hook	after compiling the output
        if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/file_edit.php']['postOutputProcessingHook'])) {
            $postOutputProcessingHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/file_edit.php']['postOutputProcessingHook'];
            if (is_array($postOutputProcessingHook)) {
                $hookParameters = array('pageContent' => &$pageContent, 'target' => &$this->target);
                foreach ($postOutputProcessingHook as $hookFunction) {
                    t3lib_div::callUserFunction($hookFunction, $hookParameters, $this);
                }
            }
        }
        // Add the HTML as a section:
        $markerArray = array('CSH' => $docHeaderButtons['csh'], 'FUNC_MENU' => t3lib_BEfunc::getFuncMenu($this->id, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']), 'BUTTONS' => $docHeaderButtons, 'PATH' => $this->title, 'CONTENT' => $pageContent);
        $this->content .= $this->doc->moduleBody(array(), $docHeaderButtons, $markerArray);
        $this->content .= $this->doc->endPage();
        $this->content = $this->doc->insertStylesAndJS($this->content);
    }
    /**
     * Making the form for create file
     *
     * @return	string		HTML content
     */
    function renderForm($fileContent = '')
    {
        global $BE_USER, $LANG, $TYPO3_CONF_VARS;
        $content = '';
        $msg = array();
        $this->pObj->markers['FOLDER_INFO'] = tx_dam_guiFunc::getFolderInfoBar(tx_dam::path_compileInfo($this->pObj->media->pathAbsolute));
        $msg[] = '&nbsp;';
        $this->pObj->markers['FILE_INFO'] = $GLOBALS['LANG']->sL('LLL:EXT:dam/locallang_db.xml:tx_dam_item.file_name', 1) . ' <strong>' . htmlspecialchars($this->pObj->media->filename) . '</strong>';
        $msg[] = '&nbsp;';
        $msg[] = $GLOBALS['LANG']->getLL('tx_dam_cmd_filenew.text_content', 1);
        $msg[] = '<textarea rows="30" name="data[file_content]" wrap="off"' . $this->pObj->doc->formWidthText(48, 'width:99%;height:65%', 'off') . ' class="fixed-font enable-tab">' . t3lib_div::formatForTextarea($fileContent) . '</textarea>';
        $this->pObj->docHeaderButtons['SAVE'] = '<input class="c-inputButton" name="_savedok"' . t3lib_iconWorks::skinImg($this->pObj->doc->backPath, 'gfx/savedok.gif') . ' title="' . $GLOBALS['LANG']->getLL('labelCmdSave', 1) . '" height="16" type="image" width="16">';
        $this->pObj->docHeaderButtons['SAVE_CLOSE'] = '<input class="c-inputButton" name="_saveandclosedok"' . t3lib_iconWorks::skinImg($this->pObj->doc->backPath, 'gfx/saveandclosedok.gif') . ' title="' . $GLOBALS['LANG']->getLL('labelCmdSaveClose', 1) . '" height="16" type="image" width="16">';
        $this->pObj->docHeaderButtons['CLOSE'] = '<a href="#" onclick="jumpBack(); return false;"><img' . t3lib_iconWorks::skinImg($this->pObj->doc->backPath, 'gfx/closedok.gif') . ' class="c-inputButton" title="' . $LANG->sL('LLL:EXT:lang/locallang_core.xml:labels.cancel', 1) . '" alt="" height="16" width="16"></a>';
        if (tx_dam::config_checkValueEnabled('mod.txdamM1_SHARED.displayExtraButtons', 1)) {
            $buttons = '
				<input type="submit" name="save" value="' . $GLOBALS['LANG']->getLL('labelCmdSave', 1) . '" />
				<input type="submit" name="_saveandclosedok_x" value="' . $GLOBALS['LANG']->getLL('labelCmdSaveClose', 1) . '" />
				<input type="submit" value="' . $LANG->sL('LLL:EXT:lang/locallang_core.xml:labels.cancel', 1) . '" onclick="jumpBack(); return false;" />';
        }
        $content .= $GLOBALS['SOBE']->getMessageBox($GLOBALS['SOBE']->pageTitle, $msg, $buttons, 1);
        return $content;
    }
    /**
     * Outputs system information
     *
     * @return void
     */
    function phpinformation()
    {
        $headCode = 'PHP information';
        $sVar = t3lib_div::getIndpEnv('_ARRAY');
        $sVar['CONST: PHP_OS'] = PHP_OS;
        $sVar['CONST: TYPO3_OS'] = TYPO3_OS;
        $sVar['CONST: PATH_thisScript'] = PATH_thisScript;
        $sVar['CONST: php_sapi_name()'] = PHP_SAPI;
        $sVar['OTHER: TYPO3_VERSION'] = TYPO3_version;
        $sVar['OTHER: PHP_VERSION'] = phpversion();
        $sVar['imagecreatefromgif()'] = function_exists('imagecreatefromgif');
        $sVar['imagecreatefrompng()'] = function_exists('imagecreatefrompng');
        $sVar['imagecreatefromjpeg()'] = function_exists('imagecreatefromjpeg');
        $sVar['imagegif()'] = function_exists('imagegif');
        $sVar['imagepng()'] = function_exists('imagepng');
        $sVar['imagejpeg()'] = function_exists('imagejpeg');
        $sVar['imagettftext()'] = function_exists('imagettftext');
        $sVar['OTHER: IMAGE_TYPES'] = function_exists('imagetypes') ? imagetypes() : 0;
        $sVar['OTHER: memory_limit'] = ini_get('memory_limit');
        $gE_keys = explode(',', 'SERVER_PORT,SERVER_SOFTWARE,GATEWAY_INTERFACE,SCRIPT_NAME,PATH_TRANSLATED');
        foreach ($gE_keys as $k) {
            $sVar['SERVER: ' . $k] = $_SERVER[$k];
        }
        $gE_keys = explode(',', 'image_processing,gdlib,gdlib_png,im,im_path,im_path_lzw,im_version_5,im_negate_mask,im_imvMaskState,im_combine_filename');
        foreach ($gE_keys as $k) {
            $sVar['T3CV_GFX: ' . $k] = $GLOBALS['TYPO3_CONF_VARS']['GFX'][$k];
        }
        $debugInfo = array('### DEBUG SYSTEM INFORMATION - START ###');
        foreach ($sVar as $kkk => $vvv) {
            $debugInfo[] = str_pad(substr($kkk, 0, 20), 20) . ': ' . $vvv;
        }
        $debugInfo[] = '### DEBUG SYSTEM INFORMATION - END ###';
        // Get the template file
        $templateFile = @file_get_contents(PATH_site . $this->templateFilePath . 'PhpInformation.html');
        // Get the template part from the file
        $template = t3lib_parsehtml::getSubpart($templateFile, '###TEMPLATE###');
        // Define the markers content
        $markers = array('explanation' => 'Please copy/paste the information from this text field into an email or bug-report as "Debug System Information" whenever you wish to get support or report problems. This information helps others to check if your system has some obvious misconfiguration and you\'ll get your help faster!', 'debugInfo' => t3lib_div::formatForTextarea(implode(chr(10), $debugInfo)));
        // Fill the markers
        $content = t3lib_parsehtml::substituteMarkerArray($template, $markers, '###|###', TRUE, FALSE);
        // Add the content to the message array
        $this->message($headCode, 'DEBUG information', $content);
        // Start with various server information
        $getEnvArray = array();
        $gE_keys = explode(',', 'QUERY_STRING,HTTP_ACCEPT,HTTP_ACCEPT_ENCODING,HTTP_ACCEPT_LANGUAGE,HTTP_CONNECTION,HTTP_COOKIE,HTTP_HOST,HTTP_USER_AGENT,REMOTE_ADDR,REMOTE_HOST,REMOTE_PORT,SERVER_ADDR,SERVER_ADMIN,SERVER_NAME,SERVER_PORT,SERVER_SIGNATURE,SERVER_SOFTWARE,GATEWAY_INTERFACE,SERVER_PROTOCOL,REQUEST_METHOD,SCRIPT_NAME,PATH_TRANSLATED,HTTP_REFERER,PATH_INFO');
        foreach ($gE_keys as $k) {
            $getEnvArray[$k] = getenv($k);
        }
        $this->message($headCode, 't3lib_div::getIndpEnv()', $this->viewArray(t3lib_div::getIndpEnv('_ARRAY')));
        $this->message($headCode, 'getenv()', $this->viewArray($getEnvArray));
        $this->message($headCode, '_ENV', $this->viewArray($_ENV));
        $this->message($headCode, '_SERVER', $this->viewArray($_SERVER));
        $this->message($headCode, '_COOKIE', $this->viewArray($_COOKIE));
        $this->message($headCode, '_GET', $this->viewArray($_GET));
        // Start with the phpinfo() part
        ob_start();
        phpinfo();
        $contents = explode('<body>', ob_get_contents());
        ob_end_clean();
        $contents = explode('</body>', $contents[1]);
        // Do code cleaning: phpinfo() is not XHTML1.1 compliant
        $phpinfo = str_replace('<font', '<span', $contents[0]);
        $phpinfo = str_replace('</font', '</span', $phpinfo);
        $phpinfo = str_replace('<img border="0"', '<img', $phpinfo);
        $phpinfo = str_replace('<a name=', '<a id=', $phpinfo);
        // Add phpinfo() to the message array
        $this->message($headCode, 'phpinfo()', '
			<div class="phpinfo">
				' . $phpinfo . '
			</div>
		');
        // Output the page
        $this->output($this->outputWrapper($this->printAll()));
    }