<?php

$patterns = json_decode($this->tPattern,true);

// fills the sidewindow space
if(class_exists("QuerybuildingHelper")){
$this->placeholder('main.window.innerwindows')->append(
        $this->partial('partials/window.phtml', array(
                'headinglevel' => 2,
                'title'        => $this->_('Save Query'),
                'content'      => $this->partial('partials/savepartial.phtml'),
                'cssClasses'   => 'querybuilder',
                'cssId'        => 'savebox'
        ))
);
}
?>
<fieldset>
<fieldset id="debugquery" style="display: none">
<legend><?php echo $this->_('Debug Code') ?></legend>
<textarea style="min-height:3em;" class="width99" id='autocompletionquery' disabled></textarea>
</fieldset>

<fieldset>
<legend><?php echo $this->_('Graph Pattern') ?></legend>

<table class="separated-vertical">
    <tr>
        <th width="20%"><?php echo $this->_('Subject') ?></th>
        <th width="20%"><?php echo $this->_('Predicate') ?></th>
        <th width="20%"><?php echo $this->_('Object') ?></th>
        <th width="20%"><?php echo $this->_('Options') ?></th>
    </tr>
    <?php
    	foreach($patterns as $key=>$pattern): 
    	$in = 'id="'.$key.'"';
    	?>
        <tr <?php echo $in; ?> class="triplepattern">
            <td><input type="text" class="text width25 pattern" name="s"  value="<?php echo  $pattern['s']; ?>" /></td>
            <td><input type="text" class="text width25 pattern" name="p"  value="<?php echo $pattern['p']; ?>" /></td>
            <td><input type="text" class="text width25 pattern" name="o"  value="<?php echo $pattern['o']; ?>" /></td>
            <td>
                <img class="qb-addtp" src="<?php echo $this->themeUrlBase ?>/images/icon-add.png" title="<?php echo $this->_('Add triple pattern') ?>" />
                <img class="qb-deltp" src="<?php echo $this->themeUrlBase ?>/images/icon-delete.png" title="<?php echo $this->_('Remove this triple pattern') ?>" />
            </td>
        </tr>
    <?php endforeach; ?>
</table>
</fieldset>

<fieldset id="showquery" style="display: none">
<legend><?php echo $this->_('SPARQL Code') ?></legend>
<textarea style="min-height:8em;" class="width99" id='showquerytextarea' readonly></textarea>
</fieldset>


<fieldset >
<legend><?php echo $this->_('Query Results') ?></legend>
<form style="float:right; margin-right:5em;">Results:&nbsp;<select id="limit" ><option value="10">10</option><option value="50">50</option><option value="100">100</option></select></form>
</fieldset>

</fieldset>


<?php