Exemplo n.º 1
0
function parseEditField($def)
{
    global $jTips;
    if (isset($def['attributes']) and !empty($def['attributes'])) {
        $attribs = array();
        foreach ($def['attributes'] as $name => $value) {
            // BUG 393 - values with quotes cause invalid HTML
            $attribs[] = "{$name}=\"" . str_replace('"', "'", jTipsStripslashes($value)) . "\"";
        }
        $attributes = implode(" ", $attribs);
    } else {
        $attributes = '';
    }
    switch ($def['type']) {
        case 'label':
            $html = "<span class='help'>" . $def['attributes']['value'] . "</span>";
            break;
        case 'select':
            $html = jTipsHTML::selectList($def['options'], $def['attributes']['name'], $attributes, 'value', 'text', $def['selected']);
            break;
        case 'date':
            //BUG 263 - Date fields in J1.0 must be in YYYY-MM-DD format
            if (!isJoomla15()) {
                $def['attributes']['value'] = TimeDate::format($def['attributes']['value'], '%Y-%m-%d');
                $attributes = preg_replace("/value='[^']*'/i", "value='" . $def['attributes']['value'] . "'", $attributes);
            }
            $html = "<input {$attributes} />&nbsp;<img src='components/com_jtips/images/calendar.png' onclick='return showCalendar(\"{$def['attributes']['name']}\", \"{$jTips['DateFormat']}\");' border='0' alt='...' align='absmiddle' />";
            break;
        case 'bool':
            $html = jTipsHTML::yesnoRadioList($def['attributes']['name'], $attributes, $def['selected']);
            break;
        case 'img':
            $html = "<img {$attributes} />";
            break;
        case 'textarea':
            $html = "<textarea {$attributes}>" . jTipsStripslashes($def['text']) . "</textarea>";
            break;
        case 'editor':
            jTipsInitEditor();
            jTipsEditorArea($def['attributes']['name'], jTipsStripslashes($def['attributes']['value']), $def['attributes']['name'], '100%', '300px', 100, 25);
            jTipsHTML::keepAlive();
            return '';
            break;
        default:
            if (jTipsGetParam($def['attributes'], 'value')) {
                $def['attributes']['value'] = jTipsStripslashes($def['attributes']['value']);
            }
            $html = "<input {$attributes} />";
            break;
    }
    return $html;
}