function select_tag($name, $options, $default = null, $html_options = array())
{
    $opts = '';
    foreach ($options as $key => $value) {
        $arr = array('value' => $value);
        if (isset($_REQUEST[$name]) and $_REQUEST[$name] == $value or !isset($_REQUEST[$name]) and $default == $value) {
            $arr = array_merge(array('selected' => 'selected'), $arr);
        }
        $opts .= content_tag('option', $key, $arr);
    }
    $html_options = array_merge(array('name' => $name, 'id' => $name), $html_options);
    return "<select" . tag_options($html_options) . ">{$opts}</select>";
}
Exemplo n.º 2
0
function tag($name, $options = array(), $open = False)
{
    return "<{$name}" . tag_options($options) . ($open ? ">" : " />");
}
Exemplo n.º 3
0
/**
 * Creates opening and closing html tags with content in between.
 *
 * Parameters:
 *   $name - the name of the tag
 *   $content - the content that will be wrapped
 *              by the opening and closing tags
 *   $options - associative array of key-value pairs used for the attributes of the html tag
 */
function content_tag($name, $content, $options = null)
{
    $tag_options = exists($options) ? tag_options($options) : '';
    return '<' . $name . $tag_options . '>' . $content . '</' . $name . '>' . "\n";
}
Exemplo n.º 4
0
function content_tag($name, $content, array $options = array())
{
    $tagOptions = $options ? tag_options($options) : '';
    return "<{$name}{$tagOptions}>{$content}</{$name}>";
}