public function testBooleanOptions()
 {
     $this->assertDomEqual(check_box_tag('admin', 1, true, array('disabled' => true, 'readonly' => true)), '<input checked="checked" disabled="disabled" id="admin" name="admin" readonly="readonly" type="checkbox" value="1" />');
     $this->assertDomEqual(check_box_tag('admin', 1, true, array('disabled' => false, 'readonly' => null)), '<input checked="checked" id="admin" name="admin" type="checkbox" value="1" />');
     $this->assertDomEqual(select_tag('people', '<option>raph</option>', array('multiple' => true)), '<select id="people" name="people" multiple="multiple"><option>raph</option></select>');
     $this->assertDomEqual(select_tag('people', '<option>raph</option>', array('multiple' => null)), '<select id="people" name="people"><option>raph</option></select>');
 }
if (!isset($_REQUEST['input_format'])) {
    $_REQUEST['input_format'] = 'guess';
}
// Display the form, if raw option isn't set
if (!isset($_REQUEST['raw'])) {
    print "<html>\n";
    print "<head><title>EasyRdf Converter</title></head>\n";
    print "<body>\n";
    print "<h1>EasyRdf Converter</h1>\n";
    print "<div style='margin: 10px'>\n";
    print form_tag();
    print label_tag('data', 'Input Data: ') . '<br />' . text_area_tag('data', '', array('cols' => 80, 'rows' => 10)) . "<br />\n";
    print label_tag('uri', 'or Uri: ') . text_field_tag('uri', 'http://www.dajobe.org/foaf.rdf', array('size' => 80)) . "<br />\n";
    print label_tag('input_format', 'Input Format: ') . select_tag('input_format', $input_format_options) . "<br />\n";
    print label_tag('output_format', 'Output Format: ') . select_tag('output_format', $output_format_options) . "<br />\n";
    print label_tag('raw', 'Raw Output: ') . check_box_tag('raw') . "<br />\n";
    print reset_tag() . submit_tag();
    print form_end_tag();
    print "</div>\n";
}
if (isset($_REQUEST['uri']) or isset($_REQUEST['data'])) {
    // Parse the input
    $graph = new EasyRdf_Graph($_REQUEST['uri']);
    if (empty($_REQUEST['data'])) {
        $graph->load($_REQUEST['uri'], $_REQUEST['input_format']);
    } else {
        $graph->parse($_REQUEST['data'], $_REQUEST['input_format'], $_REQUEST['uri']);
    }
    // Lookup the output format
    $format = EasyRdf_Format::getFormat($_REQUEST['output_format']);
    // Serialise to the new output format
if (isset($_REQUEST['image'])) {
    header("Content-Type: " . $format->getDefaultMimeType());
    echo $gv->renderImage($graph, $format);
    exit;
}
?>
<html>
<head><title>EasyRdf GraphViz Example</title></head>
<body>
<h1>EasyRdf GraphViz Example</h1>

<form action='' method='get'>
<?php 
echo label_tag('format') . ' ' . select_tag('format', $formats) . tag('br');
echo label_tag('ul', 'Use labels:') . ' ' . check_box_tag('ul') . tag('br');
echo label_tag('ol', 'Only labelled:') . ' ' . check_box_tag('ol') . tag('br');
echo submit_tag();
?>
</form>

<div>
    <img src='?image&<?php 
echo $_SERVER["QUERY_STRING"];
?>
' />
</div>

<pre style="margin: 0.5em; padding:0.5em; background-color:#eee; border:dashed 1px grey;">
<?php 
print htmlspecialchars($gv->serialise($graph, 'dot'));
?>
<?php 
echo labeled_text_field_tag('person_3', '', array('size' => 40));
?>
<br />
<?php 
echo labeled_text_field_tag('person_4', '', array('size' => 40));
?>
<br />

<h2>Output</h2>
Enable Arc 2? <?php 
echo check_box_tag('enable_arc');
?>
<br />
Enable Rapper? <?php 
echo check_box_tag('enable_rapper');
?>
<br />
<?php 
echo label_tag('format') . select_tag('format', $format_options, 'rdfxml');
?>
<br />

<?php 
echo submit_tag();
echo form_end_tag();
?>


<?php 
if (isset($_REQUEST['uri'])) {
</head>
<body>
<h1>EasyRdf SPARQL Query Form</h1>

<div style="margin: 0.5em">
  <?php 
print form_tag();
print label_tag('endpoint');
print text_field_tag('endpoint', "http://dbpedia.org/sparql", array('size' => 80)) . '<br />';
print "<code>";
foreach (EasyRdf_Namespace::namespaces() as $prefix => $uri) {
    print "PREFIX {$prefix}: &lt;" . htmlspecialchars($uri) . "&gt;<br />\n";
}
print "</code>";
print text_area_tag('query', "SELECT * WHERE {\n  ?s ?p ?o\n}\nLIMIT 10", array('rows' => 10, 'cols' => 80)) . '<br />';
print check_box_tag('text') . label_tag('text', 'Plain text results') . '<br />';
print reset_tag() . submit_tag();
print form_end_tag();
?>
</div>

<?php 
if (isset($_REQUEST['endpoint']) and isset($_REQUEST['query'])) {
    $sparql = new EasyRdf_Sparql_Client($_REQUEST['endpoint']);
    try {
        $results = $sparql->query($_REQUEST['query']);
        if (isset($_REQUEST['text'])) {
            print "<pre>" . htmlspecialchars($results->dump(false)) . "</pre>";
        } else {
            print $results->dump(true);
        }
/**
 * Returns a checkbox tag.
 * 
 * The checkbox will be checked if <var>$method</var> returns true. The <var>$checkedValue</var> 
 * defaults to 1 while the default <var>$uncheckedValue</var> is set to 0 because this
 * value will be typecasted to a boolean by the Active Record. Due to the fact that 
 * usually unchecked checkboxes don’t post anything, a hidden value is added with 
 * the same name as the checkbox. 
 * Example :
 * <code>check_box('post', 'private', $this->post);
 *      <input checked="checked" id="post_private" name="post[private]" type="checkbox" value="1" />
 *      <input name="post[private]" type="hidden" value="0" /></code>  
 */
function check_box($objectName, $method, $object, $options = array(), $checkedValue = '1', $uncheckedValue = '0')
{
    list($name, $value, $options) = default_options($objectName, $method, $object, $options);
    if ($value) {
        $checked = True;
    } else {
        $checked = False;
    }
    return check_box_tag($name, $checkedValue, $checked, $options) . tag('input', array('type' => 'hidden', 'name' => $name, 'value' => $uncheckedValue));
}