<?php

define('SEARCH_OPTIONS', 'search_options');


/*
 *  taken from page.php
 */ 
function get_POST_var($var)
{   
    global $_POST;

    if (isset($_POST[$var]))
        return trim($_POST[$var]);
    else
        return '';
}

class SearchOptions
{
    var $text;

    function SearchOptions($name = SEARCH_OPTIONS)
    {
        global $_POST;
        $this->name = $name;
        $this->text = get_POST_var($name);

        // hmmmm I wonder if we have to sanitise?
    }

    function get() { return $this->text; }

    function input($type, $name, $value = '')
    {
        return "<input type=\"$type\" name=\"$name\" value=\"$value\">";
    }

    function toTable(&$lines, $tab = '   ')
    {
        $lines[] = "$tab<table> <td>";
        $this->to3TD($lines, $tab . '  ');
        $lines[] = "$tab</td> </table>";
    }

    function to3TD(&$lines, $tab = '    ')
    {
        $lines[] = "$tab<td> " . 
                      "Term:" .
                    " <td>";
        $lines[] = "$tab<td> " . 
                       $this->input('text', $this->name, $this->get()) .
                    " <td>";
        $lines[] = "$tab<td> " . 
                      "<input type=\"submit\" value=\"Go\">";
                    " <td>";
    }


}
?>