Index: branches/0.4/web/addons/job_monarch/index.php
===================================================================
--- branches/0.4/web/addons/job_monarch/index.php	(revision 769)
+++ branches/0.4/web/addons/job_monarch/index.php	(revision 776)
@@ -236,5 +236,5 @@
     }
 
-    if (!count($metrics)) 
+    if (!count($metrics) && $view!='search') 
     {
         echo "<h4>Cannot find any metrics for selected cluster \"$clustername\", exiting.</h4>\n";
Index: branches/0.4/web/addons/job_monarch/search.php
===================================================================
--- branches/0.4/web/addons/job_monarch/search.php	(revision 769)
+++ branches/0.4/web/addons/job_monarch/search.php	(revision 776)
@@ -23,9 +23,13 @@
  */
 
-global $clustername, $tpl, $m, $metric;
+include_once "./dwoo/dwooAutoload.php";
+
+global $dwoo;
+
+global $clustername, $m, $metric;
 
 function validateFormInput() {
-    global $clustername, $tpl, $id, $owner, $name, $start_from_time, $start_to_time, $queue;
-    global $end_from_time, $end_to_time, $period_start, $period_stop;
+    global $clustername, $dwoo, $id, $owner, $name, $start_from_time, $start_to_time, $queue;
+    global $end_from_time, $end_to_time, $period_start, $period_stop, $tpl_data;
 
     $error = 0;
@@ -76,6 +80,6 @@
     // doe checks en set error en error_msg in case shit
 
-    if( $show_msg )
-        $tpl->assign( "form_error_msg", $error_msg );
+    //if( $show_msg )
+        //$tpl_data->assign( "form_error_msg", $error_msg );
 
     return ($error ? 0 : 1 );
@@ -229,5 +233,5 @@
 
 function makeSearchPage() {
-    global $clustername, $tpl, $id, $owner, $name, $start_from_time, $start_to_time, $queue;
+    global $clustername, $dwoo, $id, $owner, $name, $start_from_time, $start_to_time, $queue;
     global $end_from_time, $end_to_time, $filter, $default_showhosts, $m, $hosts_up, $hc;
     global $period_start, $period_stop, $sortby, $sortorder, $COLUMN_REQUESTED_MEMORY;
@@ -239,19 +243,22 @@
     makeHeader( 'search', $title, $longtitle );
 
-    $tpl->assign( "cluster", $clustername );
-    $tpl->assign( "id_value", $id );
-    $tpl->assign( "owner_value", $owner);
-    $tpl->assign( "queue_value", $queue );
-    $tpl->assign( "name_value", $name );
-    $tpl->assign( "start_from_value", rawurldecode( $start_from_time ) );
-    $tpl->assign( "start_to_value", rawurldecode( $start_to_time ) );
-    $tpl->assign( "end_from_value", rawurldecode( $end_from_time ) );
-    $tpl->assign( "end_to_value", rawurldecode( $end_to_time ) );
+    $tpl = new Dwoo_Template_File("templates/search.tpl");
+    $tpl_data = new Dwoo_Data();
+
+    $tpl_data->assign( "cluster", $clustername );
+    $tpl_data->assign( "id_value", $id );
+    $tpl_data->assign( "owner_value", $owner);
+    $tpl_data->assign( "queue_value", $queue );
+    $tpl_data->assign( "name_value", $name );
+    $tpl_data->assign( "start_from_value", rawurldecode( $start_from_time ) );
+    $tpl_data->assign( "start_to_value", rawurldecode( $start_to_time ) );
+    $tpl_data->assign( "end_from_value", rawurldecode( $end_from_time ) );
+    $tpl_data->assign( "end_to_value", rawurldecode( $end_to_time ) );
 
     if( validateFormInput() ) {
 
-        $tpl->newBlock( "search_results" );
-        $tpl->assign( "sortby", $sortby);
-        $tpl->assign( "sortorder", $sortorder);
+        $tpl_data->assign( "search_results", "yes" );
+        $tpl_data->assign( "sortby", $sortby);
+        $tpl_data->assign( "sortorder", $sortorder);
         $tdb = new TarchDbase( "127.0.0.1" );
         if( $start_from_time ) $start_from_time = datetimeToEpoch( $start_from_time );
@@ -262,8 +269,6 @@
 
         if( ($tdb->resultcount) > (int) $SEARCH_RESULT_LIMIT ) {
-            $tpl->gotoBlock( "_ROOT" );
         
-            $tpl->assign( "form_error_msg", "Got " . $tdb->resultcount . " search results, output limited to last " . $SEARCH_RESULT_LIMIT . " jobs." );
-            $tpl->gotoBlock( "search_results" );
+            $tpl_data->assign( "form_error_msg", "Got " . $tdb->resultcount . " search results, output limited to last " . $SEARCH_RESULT_LIMIT . " jobs." );
         }
 
@@ -280,12 +285,13 @@
 
         if( $COLUMN_REQUESTED_MEMORY ) {
-            $tpl->newBlock( "column_header_req_mem" );
+            $tpl_data->assign( "column_header_req_mem", "yes" );
         }
         if( $COLUMN_NODES ) {
-            $tpl->newBlock( "column_header_nodes" );
+            $tpl_data->assign( "column_header_nodes", "yes" );
         }
 
         $sorted_search = sortJobs( $jobs, $nodes, $sortby, $sortorder );
 
+        $node_loop = array();
         foreach( $sorted_search as $sortid ) {
 
@@ -293,16 +299,15 @@
             $foundid = $job['id'];
 
-            $tpl->newBlock( "node" );
-            $tpl->assign( "id", $job['id'] );
-            $tpl->assign( "state", $job['status'] );
-            $tpl->assign( "owner", $job['owner'] );
-            $tpl->assign( "queue", $job['queue'] );
-            $tpl->assign( "name", $job['name'] );
-            $tpl->assign( "req_cpu", makeTime( TimeToEpoch( $job['requested_time'] ) ) );
+            $node_list = array();
+            $node_list["id"]= $job['id'];
+            $node_list["state"]= $job['status'];
+            $node_list["owner"]= $job['owner'];
+            $node_list["queue"]= $job['queue'];
+            $node_list["name"]= $job['name'];
+            $node_list["req_cpu"]= makeTime( TimeToEpoch( $job['requested_time'] ) );
 
             if( $COLUMN_REQUESTED_MEMORY ) {
-                $tpl->newBlock( "column_req_mem" );
-                $tpl->assign( "req_memory", $job['requested_memory'] );
-                $tpl->gotoBlock( "node" );
+                $node_list["column_req_mem"] = "yes";
+                $node_list["req_memory"]= $job['requested_memory'];
             }
             if( $COLUMN_NODES) {
@@ -313,8 +318,7 @@
                     $job_nodes[] = $mynode['hostname'];
 
-                $tpl->newBlock( "column_nodes" );
+                $node_list["column_nodes"] = "yes";
                 $nodes_hostnames = implode( " ", $job_nodes );
-                $tpl->assign( "nodes_hostnames", $nodes_hostnames );
-                $tpl->gotoBlock( "node" );
+                $node_list["nodes_hostnames"]= $nodes_hostnames;
             }
 
@@ -323,9 +327,9 @@
             if( $even ) {
 
-                $tpl->assign("nodeclass", "even");
+                $node_list["nodeclass"]= "even";
                 $even = 0;
             } else {
 
-                $tpl->assign("nodeclass", "odd");
+                $node_list["nodeclass"]= "odd";
                 $even = 1;
             }
@@ -334,22 +338,24 @@
             $cpus = $nodes_nr * $ppn;
 
-            $tpl->assign( "nodes", $nodes_nr );
-            $tpl->assign( "cpus", $cpus );
+            $node_list["nodes"]= $nodes_nr;
+            $node_list["cpus"]= $cpus;
 
             $job_start = $job['start_timestamp'];
             $job_stop = $job['stop_timestamp'];
             $runningtime = intval( $job_stop - $job_start );
-            $tpl->assign( "started", makeDate( $job_start ) );
-            $tpl->assign( "finished", makeDate( $job_stop ) );
-            $tpl->assign( "runningtime", makeTime( $runningtime ) );
+            $node_list["started"]= makeDate( $job_start );
+            $node_list["finished"]= makeDate( $job_stop );
+            $node_list["runningtime"]= makeTime( $runningtime );
             
-        }
+            $node_loop[]=$node_list;
+        }
+        $tpl_data->assign("node_loop", $node_loop );
 
         if( count( $search_ids ) == 1 ) {
 
-            $tpl->newBlock( "showhosts" );
+            $tpl_data->assign( "showhosts", "yes" );
 
             $showhosts = isset($sh) ? $sh : $default_showhosts;
-            $tpl->assign("checked$showhosts", "checked");
+            $tpl_data->assign("checked$showhosts", "checked");
 
             # Present a width list
@@ -366,8 +372,8 @@
             $cols_menu .= "</SELECT>\n";
 
-            $tpl->assign("metric","$metricname $units");
-            $tpl->assign("id", $id);
+            $tpl_data->assign("metric","$metricname $units");
+            $tpl_data->assign("id", $id);
             # Host columns menu defined in header.php
-            $tpl->assign("cols_menu", $cols_menu);
+            $tpl_data->assign("cols_menu", $cols_menu);
 
             if( $showhosts ) {
@@ -383,10 +389,8 @@
                     $period_stop = datetimeToEpoch( $period_stop );
 
-                        $tpl->gotoBlock( "timeperiod" );
-
-                $tpl->assign("period_start", epochToDatetime( $period_start ) );
-                $tpl->assign("period_stop", epochToDatetime( $period_stop ) );
-
-                        $tpl->gotoBlock( "_ROOT" );
+                #        $tpl_data->gotoBlock( "timeperiod" );
+
+                #$tpl_data->assign("period_start", epochToDatetime( $period_start ) );
+                #$tpl_data->assign("period_stop", epochToDatetime( $period_stop ) );
 
                 $hosts_up = array();
@@ -427,8 +431,9 @@
                 list($min, $max) = find_limits($sorted_hosts, $metricname);
 
+                $sorted_loop = array();
                 # Second pass to output the graphs or metrics.
                 $i = 1;
                 foreach ( $sorted_hosts as $host=>$value  ) {
-                    $tpl->newBlock ("sorted_list");
+                    $sorted_list = array();
                     $host_url = rawurlencode($host);
                     $cluster_url = rawurlencode($clustername);
@@ -442,7 +447,7 @@
                         $textval = date("r", $val['VAL']);
                     } elseif ($val['TYPE']=="string" or $val['SLOPE']=="zero" or $always_constant[$metricname] or ($max_graphs > 0 and $i > $max_graphs )) {
-                        $textval = "$val['VAL'] $val['UNITS']";
+                        $textval = $val['VAL']." ".$val['UNITS'];
                     } else {
-                        $graphargs = "z=small&c=$cluster_url&m=$metricname&h=$host_url&v=$val['VAL']&x=$max&n=$min&job_start=$job_start&job_stop=$job_stop&period_start=$period_start&period_stop=$period_stop&min=$min&max=$max";
+                        $graphargs = "z=small&c=$cluster_url&m=$metricname&h=$host_url&v=".$val['VAL']."&x=$max&n=$min&job_start=$job_start&job_stop=$job_stop&period_start=$period_start&period_stop=$period_stop&min=$min&max=$max";
                     }
                     if ($textval) {
@@ -452,8 +457,11 @@
                     }
 
-                    $tpl->assign("metric_image", $cell);
+                    $sorted_list["metric_image"]= $cell;
                     if (! ($i++ % $hostcols) )
-                         $tpl->assign ("br", "</tr><tr>");
+                         $sorted_list["br"]= "</tr><tr>";
+
+                    $sorted_loop[]=$sorted_list;
                 }
+                $tpl_data->assign("sorted_loop", $sorted_loop );
 
             }
@@ -461,4 +469,5 @@
 
     }
+    $dwoo->output($tpl, $tpl_data);
 }
 ?>
Index: branches/0.4/web/addons/job_monarch/templates/header.tpl
===================================================================
--- branches/0.4/web/addons/job_monarch/templates/header.tpl	(revision 769)
+++ branches/0.4/web/addons/job_monarch/templates/header.tpl	(revision 776)
@@ -81,5 +81,5 @@
 {if "$search" == "yes"}
      <TD align="right"><CENTER>
-       <A HREF="./?c={$cluster_url}&view=search">
+       <A HREF="./?c={$cluster_url}&j_view=search">
        <B><I>Jobarchive</I></B><BR>
        <IMG SRC="./document_archive.jpg" HEIGHT=100 ALT="Search the archive for {$cluster}" TITLE="Search the archive for {$cluster}" BORDER=0></A></CENTER>
Index: branches/0.4/web/addons/job_monarch/templates/search.tpl
===================================================================
--- branches/0.4/web/addons/job_monarch/templates/search.tpl	(revision 769)
+++ branches/0.4/web/addons/job_monarch/templates/search.tpl	(revision 776)
@@ -86,5 +86,5 @@
   </TD>
   <TD>
-  <INPUT TYPE="TEXT" NAME="id" VALUE="{id_value}">
+  <INPUT TYPE="TEXT" NAME="id" VALUE="{$id_value}">
   </TD>
 
@@ -97,5 +97,5 @@
   </TD>
   <TD>
-  <INPUT TYPE="TEXT" NAME="owner" VALUE="{owner_value}">
+  <INPUT TYPE="TEXT" NAME="owner" VALUE="{$owner_value}">
   </TD>
 
@@ -104,5 +104,5 @@
   </TD>
   <TD>
-  <INPUT TYPE="TEXT" NAME="queue" VALUE="{queue_value}">
+  <INPUT TYPE="TEXT" NAME="queue" VALUE="{$queue_value}">
   </TD>
 
@@ -111,5 +111,5 @@
   </TD>
   <TD>
-  <INPUT TYPE="TEXT" NAME="name" VALUE="{name_value}">
+  <INPUT TYPE="TEXT" NAME="name" VALUE="{$name_value}">
   </TD>
 
@@ -127,6 +127,6 @@
   </TD>
   <TD>
-  <INPUT TYPE="HIDDEN" NAME="start_from_time" VALUE="{start_from_value}">
-  <INPUT TYPE="TEXT" NAME="start_from_pick" VALUE="{start_from_value}" DISABLED="TRUE"> 
+  <INPUT TYPE="HIDDEN" NAME="start_from_time" VALUE="{$start_from_value}">
+  <INPUT TYPE="TEXT" NAME="start_from_pick" VALUE="{$start_from_value}" DISABLED="TRUE"> 
   <A HREF="javascript:show_calendar('document.archive_search_form.start_from_pick', document.archive_search_form.start_from_pick.value );">
   <IMG SRC="cal.gif" width="16" height="16" border="0" title="Click to select a date/time" alt="Click to select a date/time"></a> 
@@ -138,6 +138,6 @@
   </TD>
   <TD>
-  <INPUT TYPE="HIDDEN" NAME="start_to_time" VALUE="{start_to_value}">
-  <INPUT TYPE="TEXT" NAME="start_to_pick" VALUE="{start_to_value}" DISABLED="TRUE">
+  <INPUT TYPE="HIDDEN" NAME="start_to_time" VALUE="{$start_to_value}">
+  <INPUT TYPE="TEXT" NAME="start_to_pick" VALUE="{$start_to_value}" DISABLED="TRUE">
   <a href="javascript:show_calendar('document.archive_search_form.start_to_pick', document.archive_search_form.start_to_pick.value );"> 
   <img src="cal.gif" width="16" height="16" border="0" title="Click to select a date/time" alt="Click to select a date/time"></a> 
@@ -159,6 +159,6 @@
   </TD>
   <TD>
-  <INPUT TYPE="HIDDEN" NAME="end_from_time" VALUE="{end_from_value}">
-  <INPUT TYPE="TEXT" NAME="end_from_pick" VALUE="{end_from_value}" DISABLED="TRUE"> 
+  <INPUT TYPE="HIDDEN" NAME="end_from_time" VALUE="{$end_from_value}">
+  <INPUT TYPE="TEXT" NAME="end_from_pick" VALUE="{$end_from_value}" DISABLED="TRUE"> 
   <A HREF="javascript:show_calendar('document.archive_search_form.end_from_pick', document.archive_search_form.end_from_pick.value );">
   <IMG SRC="cal.gif" width="16" height="16" border="0" title="Click to select a date/time" alt="Click to select a date/time"></a> 
@@ -171,6 +171,6 @@
   </TD>
   <TD>
-  <INPUT TYPE="HIDDEN" NAME="end_to_time" VALUE="{end_to_value}">
-  <INPUT TYPE="TEXT" NAME="end_to_pick" VALUE="{end_to_value}" DISABLED="TRUE">
+  <INPUT TYPE="HIDDEN" NAME="end_to_time" VALUE="{$end_to_value}">
+  <INPUT TYPE="TEXT" NAME="end_to_pick" VALUE="{$end_to_value}" DISABLED="TRUE">
   <a href="javascript:show_calendar('document.archive_search_form.end_to_pick', document.archive_search_form.end_to_pick.value );"> 
   <img src="cal.gif" width="16" height="16" border="0" title="Click to select a date/time" alt="Click to select a date/time"></a> 
@@ -195,10 +195,11 @@
 
 </TABLE>
-{form_error_msg}<BR><BR>
-<!-- START BLOCK : search_results -->
-
-<INPUT TYPE="HIDDEN" NAME="sortby" VALUE="{sortby}">
-<INPUT TYPE="HIDDEN" NAME="sortorder" VALUE="{sortorder}">
-<INPUT TYPE="HIDDEN" NAME="filterorder" VALUE="{order}">
+{$form_error_msg}<BR><BR>
+
+{if "$search_results" == " yes" }
+
+<INPUT TYPE="HIDDEN" NAME="sortby" VALUE="{$sortby}">
+<INPUT TYPE="HIDDEN" NAME="sortorder" VALUE="{$sortorder}">
+<INPUT TYPE="HIDDEN" NAME="filterorder" VALUE="{$order}">
 
 <TABLE WIDTH="100%" CELLPADDING="2" CELLSPACING="2" BORDER=0>
@@ -210,11 +211,11 @@
 <TH><B><A HREF="#" onClick="setSort( 'name' )" ALT="Jobname" TITLE="Jobname">Name</A></B></TH>
 <TH><B><A HREF="#" onClick="setSort( 'req_cpu' )" ALT="Requested CPU Time (walltime)" TITLE="Requested CPU Time (walltime)">Req. CPU time</A></B></TH>
-<!-- START BLOCK : column_header_req_mem -->
+{if "$column_header_req_mem" == "yes"}
 <TH><B><A HREF="#" onClick="setSort( 'req_mem' )" ALT="Requested Memory" TITLE="Requested Memory">Req. Memory</A></B></TH>
-<!-- END BLOCK : column_header_req_mem -->
+{/if}
 <TH><B><A HREF="#" onClick="setSort( 'nodes' )" ALT="Nodes" TITLE="Nodes">N</A>/<A HREF="#" onClick="setSort( 'cpus' )" ALT="Processors" TITLE="Processors">P</A></B></TH>
-<!-- START BLOCK : column_header_nodes -->
+{if "$column_header_nodes" == "yes"}
 <TH><B><A HREF="#" onClick="setSort( 'nodes' )" ALT="Nodes" TITLE="Nodes">Nodes</A></B></TH>
-<!-- END BLOCK : column_header_nodes -->
+{/if}
 <TH><B><A HREF="#" onClick="setSort( 'start' )">Started</A></B></TH>
 <TH><B><A HREF="#" onClick="setSort( 'finished' )">Finished</A></B></TH>
@@ -222,36 +223,36 @@
 </TR>
 
-<!-- START BLOCK : node -->
-  <TR CLASS="{nodeclass}">
-    <TD><A HREF="#" onClick="setFilter( 'id', '{id}' )">{id}</A></TD>
-    <TD><A HREF="#" onClick="setFilter( 'state', '{state}' )">{state}</A></TD>
-    <TD><A HREF="#" onClick="setFilter( 'owner', '{owner}' )">{owner}</A></TD>
-    <TD><A HREF="#" onClick="setFilter( 'queue', '{queue}' )">{queue}</A></TD>
-    <TD ALT="{fulljobname}" TITLE="{fulljobname}">
-<!-- START BLOCK : jobname_hint_start -->
+{loop $node}
+  <TR CLASS="{$nodeclass}">
+    <TD><A HREF="#" onClick="setFilter( 'id', '{$id}' )">{$id}</A></TD>
+    <TD><A HREF="#" onClick="setFilter( 'state', '{$state}' )">{$state}</A></TD>
+    <TD><A HREF="#" onClick="setFilter( 'owner', '{$owner}' )">{$owner}</A></TD>
+    <TD><A HREF="#" onClick="setFilter( 'queue', '{$queue}' )">{$queue}</A></TD>
+    <TD ALT="{$fulljobname}" TITLE="{$fulljobname}">
+{if "$jobname_hint_start" == "yes"}
     <FONT CLASS="jobname_hint">
-<!-- END BLOCK : jobname_hint_start -->
-    {name}
-<!-- START BLOCK : jobname_hint_end -->
+{/if}
+    {$name}
+{if "$jobname_hint_end" == "yes"}
     </FONT>
-<!-- END BLOCK : jobname_hint_end -->
+{/if}
     </TD>
-    <TD>{req_cpu}</TD>
-<!-- START BLOCK : column_req_mem -->
-    <TD>{req_memory}</TD>
-<!-- END BLOCK : column_req_mem -->
-    <TD>{nodes}/{cpus}</TD>
-<!-- START BLOCK : column_nodes -->
-    <TD>{nodes_hostnames}</TD>
-<!-- END BLOCK : column_nodes -->
-    <TD>{started}</TD>
-    <TD>{finished}</TD>
-    <TD>{runningtime}</TD>
+    <TD>{$req_cpu}</TD>
+{if "$column_req_mem" == "yes"}
+    <TD>{$req_memory}</TD>
+{/if}
+    <TD>{$nodes}/{$cpus}</TD>
+{if "$column_req_mem" == "yes"}
+    <TD>{$nodes_hostnames}</TD>
+{/if}
+    <TD>{$started}</TD>
+    <TD>{$finished}</TD>
+    <TD>{$runningtime}</TD>
   </TR>
-<!-- END BLOCK : node -->
+{/loop}
 </TABLE>
 </CENTER>
 
-<!-- START BLOCK : showhosts -->
+{if "$showhosts" == "yes" }
 <TABLE BORDER="0" WIDTH="100%">
 <TR>
@@ -259,12 +260,12 @@
   <FONT SIZE="-1">
   Show Hosts:
-  yes<INPUT type=radio name="sh" value="1" OnClick="archive_search_form.submit();" {checked1}>
-  no<INPUT type=radio name="sh" value="0" OnClick="archive_search_form.submit();" {checked0}>
+  yes<INPUT type=radio name="sh" value="1" OnClick="archive_search_form.submit();" {$checked1}>
+  no<INPUT type=radio name="sh" value="0" OnClick="archive_search_form.submit();" {$checked0}>
   </FONT>
   |
-  job <strong>{id}</strong> metric <strong>{metric}</strong>
+  job <strong>{$id}</strong> metric <strong>{$metric}</strong>
   |
    <FONT SIZE="-1">
-   Columns&nbsp;&nbsp;{cols_menu}
+   Columns&nbsp;&nbsp;{$cols_menu}
    </FONT><BR>
   </TD>
@@ -276,7 +277,7 @@
 <TABLE>
 <TR>
-<!-- START BLOCK : sorted_list -->
-{metric_image}{br}
-<!-- END BLOCK : sorted_list -->
+{loop $sorted_list}
+{$metric_image}{$br}
+{/loop}
 </TR>
 </TABLE>
@@ -284,5 +285,5 @@
 </CENTER>
 
-<!-- END BLOCK : showhosts -->
-<!-- END BLOCK : search_results -->
+{/if}
+{/if}
 </CENTER>
