Пример #1
0
    /**
     * 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;
    }
Пример #2
0
    /**
     * 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;
    }