Index: /branches/0.4/web/addons/job_monarch/dwoo/Dwoo.compiled.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/Dwoo.compiled.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/Dwoo.compiled.php	(revision 755)
@@ -0,0 +1,1 @@
+<?php  define('DWOO_DIRECTORY', dirname(__FILE__) . DIRECTORY_SEPARATOR); class Dwoo_Core { const VERSION = '1.1.1'; const RELEASE_TAG = 17; const CLASS_PLUGIN = 1; const FUNC_PLUGIN = 2; const NATIVE_PLUGIN = 4; const BLOCK_PLUGIN = 8; const COMPILABLE_PLUGIN = 16; const CUSTOM_PLUGIN = 32; const SMARTY_MODIFIER = 64; const SMARTY_BLOCK = 128; const SMARTY_FUNCTION = 256; const PROXY_PLUGIN = 512; const TEMPLATE_PLUGIN = 1024; protected $charset = 'utf-8'; public $globals; protected $compileDir; protected $cacheDir; protected $cacheTime = 0; protected $securityPolicy = null; protected $plugins = array(); protected $filters = array(); protected $resources = array ( 'file' => array ( 'class' => 'Dwoo_Template_File', 'compiler' => null ), 'string' => array ( 'class' => 'Dwoo_Template_String', 'compiler' => null ) ); protected $loader = null; protected $template = null; protected $runtimePlugins; protected $returnData; public $data; public $scope; protected $scopeTree; protected $stack; protected $curBlock; protected $buffer; protected $pluginProxy; public function __construct($compileDir = null, $cacheDir = null) { if ($compileDir !== null) { $this->setCompileDir($compileDir); } if ($cacheDir !== null) { $this->setCacheDir($cacheDir); } $this->initGlobals(); } public function __clone() { $this->template = null; unset($this->data); unset($this->returnData); } public function output($tpl, $data = array(), Dwoo_ICompiler $compiler = null) { return $this->get($tpl, $data, $compiler, true); } public function get($_tpl, $data = array(), $_compiler = null, $_output = false) { if ($this->template instanceof Dwoo_ITemplate) { return clone $this; } if ($_tpl instanceof Dwoo_ITemplate) { } elseif (is_string($_tpl) && file_exists($_tpl)) { $_tpl = new Dwoo_Template_File($_tpl); } else { throw new Dwoo_Exception('Dwoo->get/Dwoo->output\'s first argument must be a Dwoo_ITemplate (i.e. Dwoo_Template_File) or a valid path to a template file', E_USER_NOTICE); } $this->template = $_tpl; if ($data instanceof Dwoo_IDataProvider) { $this->data = $data->getData(); } elseif (is_array($data)) { $this->data = $data; } else { throw new Dwoo_Exception('Dwoo->get/Dwoo->output\'s data argument must be a Dwoo_IDataProvider object (i.e. Dwoo_Data) or an associative array', E_USER_NOTICE); } $this->globals['template'] = $_tpl->getName(); $this->initRuntimeVars($_tpl); $file = $_tpl->getCachedTemplate($this); $doCache = $file === true; $cacheLoaded = is_string($file); if ($cacheLoaded === true) { if ($_output === true) { include $file; $this->template = null; } else { ob_start(); include $file; $this->template = null; return ob_get_clean(); } } else { if ($doCache === true) { $dynamicId = uniqid(); } $compiledTemplate = $_tpl->getCompiledTemplate($this, $_compiler); $out = include $compiledTemplate; if ($out === false) { $_tpl->forceCompilation(); $compiledTemplate = $_tpl->getCompiledTemplate($this, $_compiler); $out = include $compiledTemplate; } if ($doCache === true) { $out = preg_replace('/(<%|%>|<\?php|<\?|\?>)/', '<?php /*'.$dynamicId.'*/ echo \'$1\'; ?>', $out); if (!class_exists('Dwoo_plugin_dynamic', false)) { $this->getLoader()->loadPlugin('dynamic'); } $out = Dwoo_Plugin_dynamic::unescape($out, $dynamicId, $compiledTemplate); } foreach ($this->filters as $filter) { if (is_array($filter) && $filter[0] instanceof Dwoo_Filter) { $out = call_user_func($filter, $out); } else { $out = call_user_func($filter, $this, $out); } } if ($doCache === true) { $file = $_tpl->cache($this, $out); if ($_output === true) { include $file; $this->template = null; } else { ob_start(); include $file; $this->template = null; return ob_get_clean(); } } else { $this->template = null; if ($_output === true) { echo $out; } return $out; } } } protected function initGlobals() { $this->globals = array ( 'version' => self::VERSION, 'ad' => '<a href="http://dwoo.org/">Powered by Dwoo</a>', 'now' => $_SERVER['REQUEST_TIME'], 'charset' => $this->charset, ); } protected function initRuntimeVars(Dwoo_ITemplate $tpl) { $this->runtimePlugins = array(); $this->scope =& $this->data; $this->scopeTree = array(); $this->stack = array(); $this->curBlock = null; $this->buffer = ''; $this->returnData = array(); } public function addPlugin($name, $callback, $compilable = false) { $compilable = $compilable ? self::COMPILABLE_PLUGIN : 0; if (is_array($callback)) { if (is_subclass_of(is_object($callback[0]) ? get_class($callback[0]) : $callback[0], 'Dwoo_Block_Plugin')) { $this->plugins[$name] = array('type'=>self::BLOCK_PLUGIN | $compilable, 'callback'=>$callback, 'class'=>(is_object($callback[0]) ? get_class($callback[0]) : $callback[0])); } else { $this->plugins[$name] = array('type'=>self::CLASS_PLUGIN | $compilable, 'callback'=>$callback, 'class'=>(is_object($callback[0]) ? get_class($callback[0]) : $callback[0]), 'function'=>$callback[1]); } } elseif (class_exists($callback, false)) { if (is_subclass_of($callback, 'Dwoo_Block_Plugin')) { $this->plugins[$name] = array('type'=>self::BLOCK_PLUGIN | $compilable, 'callback'=>$callback, 'class'=>$callback); } else { $this->plugins[$name] = array('type'=>self::CLASS_PLUGIN | $compilable, 'callback'=>$callback, 'class'=>$callback, 'function'=>'process'); } } elseif (function_exists($callback)) { $this->plugins[$name] = array('type'=>self::FUNC_PLUGIN | $compilable, 'callback'=>$callback); } else { throw new Dwoo_Exception('Callback could not be processed correctly, please check that the function/class you used exists'); } } public function removePlugin($name) { if (isset($this->plugins[$name])) { unset($this->plugins[$name]); } } public function addFilter($callback, $autoload = false) { if ($autoload) { $class = 'Dwoo_Filter_'.$callback; if (!class_exists($class, false) && !function_exists($class)) { try { $this->getLoader()->loadPlugin($callback); } catch (Dwoo_Exception $e) { if (strstr($callback, 'Dwoo_Filter_')) { throw new Dwoo_Exception('Wrong filter name : '.$callback.', the "Dwoo_Filter_" prefix should not be used, please only use "'.str_replace('Dwoo_Filter_', '', $callback).'"'); } else { throw new Dwoo_Exception('Wrong filter name : '.$callback.', when using autoload the filter must be in one of your plugin dir as "name.php" containg a class or function named "Dwoo_Filter_name"'); } } } if (class_exists($class, false)) { $callback = array(new $class($this), 'process'); } elseif (function_exists($class)) { $callback = $class; } else { throw new Dwoo_Exception('Wrong filter name : '.$callback.', when using autoload the filter must be in one of your plugin dir as "name.php" containg a class or function named "Dwoo_Filter_name"'); } $this->filters[] = $callback; } else { $this->filters[] = $callback; } } public function removeFilter($callback) { if (($index = array_search('Dwoo_Filter_'.$callback, $this->filters, true)) !== false) { unset($this->filters[$index]); } elseif (($index = array_search($callback, $this->filters, true)) !== false) { unset($this->filters[$index]); } else { $class = 'Dwoo_Filter_' . $callback; foreach ($this->filters as $index=>$filter) { if (is_array($filter) && $filter[0] instanceof $class) { unset($this->filters[$index]); break; } } } } public function addResource($name, $class, $compilerFactory = null) { if (strlen($name) < 2) { throw new Dwoo_Exception('Resource names must be at least two-character long to avoid conflicts with Windows paths'); } if (!class_exists($class)) { throw new Dwoo_Exception('Resource class does not exist'); } $interfaces = class_implements($class); if (in_array('Dwoo_ITemplate', $interfaces) === false) { throw new Dwoo_Exception('Resource class must implement Dwoo_ITemplate'); } $this->resources[$name] = array('class'=>$class, 'compiler'=>$compilerFactory); } public function removeResource($name) { unset($this->resources[$name]); if ($name==='file') { $this->resources['file'] = array('class'=>'Dwoo_Template_File', 'compiler'=>null); } } public function setLoader(Dwoo_ILoader $loader) { $this->loader = $loader; } public function getLoader() { if ($this->loader === null) { $this->loader = new Dwoo_Loader($this->getCompileDir()); } return $this->loader; } public function getCustomPlugins() { return $this->plugins; } public function getCacheDir() { if ($this->cacheDir === null) { $this->setCacheDir(DWOO_DIRECTORY.'cache'.DIRECTORY_SEPARATOR); } return $this->cacheDir; } public function setCacheDir($dir) { $this->cacheDir = rtrim($dir, '/\\').DIRECTORY_SEPARATOR; if (is_writable($this->cacheDir) === false) { throw new Dwoo_Exception('The cache directory must be writable, chmod "'.$this->cacheDir.'" to make it writable'); } } public function getCompileDir() { if ($this->compileDir === null) { $this->setCompileDir(DWOO_DIRECTORY.'compiled'.DIRECTORY_SEPARATOR); } return $this->compileDir; } public function setCompileDir($dir) { $this->compileDir = rtrim($dir, '/\\').DIRECTORY_SEPARATOR; if (is_writable($this->compileDir) === false) { throw new Dwoo_Exception('The compile directory must be writable, chmod "'.$this->compileDir.'" to make it writable'); } } public function getCacheTime() { return $this->cacheTime; } public function setCacheTime($seconds) { $this->cacheTime = (int) $seconds; } public function getCharset() { return $this->charset; } public function setCharset($charset) { $this->charset = strtolower((string) $charset); } public function getTemplate() { return $this->template; } public function setTemplate(Dwoo_ITemplate $tpl) { $this->template = $tpl; } public function setDefaultCompilerFactory($resourceName, $compilerFactory) { $this->resources[$resourceName]['compiler'] = $compilerFactory; } public function getDefaultCompilerFactory($resourceName) { return $this->resources[$resourceName]['compiler']; } public function setSecurityPolicy(Dwoo_Security_Policy $policy = null) { $this->securityPolicy = $policy; } public function getSecurityPolicy() { return $this->securityPolicy; } public function setPluginProxy(Dwoo_IPluginProxy $pluginProxy) { $this->pluginProxy = $pluginProxy; } public function getPluginProxy() { return $this->pluginProxy; } public function isCached(Dwoo_ITemplate $tpl) { return is_string($tpl->getCachedTemplate($this)); } public function clearCache($olderThan=-1) { $cacheDirs = new RecursiveDirectoryIterator($this->getCacheDir()); $cache = new RecursiveIteratorIterator($cacheDirs); $expired = time() - $olderThan; $count = 0; foreach ($cache as $file) { if ($cache->isDot() || $cache->isDir() || substr($file, -5) !== '.html') { continue; } if ($cache->getCTime() < $expired) { $count += unlink((string) $file) ? 1 : 0; } } return $count; } public function templateFactory($resourceName, $resourceId, $cacheTime = null, $cacheId = null, $compileId = null, Dwoo_ITemplate $parentTemplate = null) { if (isset($this->resources[$resourceName])) { return call_user_func(array($this->resources[$resourceName]['class'], 'templateFactory'), $this, $resourceId, $cacheTime, $cacheId, $compileId, $parentTemplate); } else { throw new Dwoo_Exception('Unknown resource type : '.$resourceName); } } public function isArray($value, $checkIsEmpty=false) { if (is_array($value) === true || $value instanceof ArrayAccess) { if ($checkIsEmpty === false) { return true; } else { return $this->count($value); } } } public function isTraversable($value, $checkIsEmpty=false) { if (is_array($value) === true) { if ($checkIsEmpty === false) { return true; } else { return count($value) > 0; } } elseif ($value instanceof Traversable) { if ($checkIsEmpty === false) { return true; } else { return $this->count($value); } } return false; } public function count($value) { if (is_array($value) === true || $value instanceof Countable) { return count($value); } elseif ($value instanceof ArrayAccess) { if ($value->offsetExists(0)) { return true; } } elseif ($value instanceof Iterator) { $value->rewind(); if ($value->valid()) { return true; } } elseif ($value instanceof Traversable) { foreach ($value as $dummy) { return true; } } return 0; } public function triggerError($message, $level=E_USER_NOTICE) { if (!($tplIdentifier = $this->template->getResourceIdentifier())) { $tplIdentifier = $this->template->getResourceName(); } trigger_error('Dwoo error (in '.$tplIdentifier.') : '.$message, $level); } public function addStack($blockName, array $args=array()) { if (isset($this->plugins[$blockName])) { $class = $this->plugins[$blockName]['class']; } else { $class = 'Dwoo_Plugin_'.$blockName; } if ($this->curBlock !== null) { $this->curBlock->buffer(ob_get_contents()); ob_clean(); } else { $this->buffer .= ob_get_contents(); ob_clean(); } $block = new $class($this); $cnt = count($args); if ($cnt===0) { $block->init(); } elseif ($cnt===1) { $block->init($args[0]); } elseif ($cnt===2) { $block->init($args[0], $args[1]); } elseif ($cnt===3) { $block->init($args[0], $args[1], $args[2]); } elseif ($cnt===4) { $block->init($args[0], $args[1], $args[2], $args[3]); } else { call_user_func_array(array($block,'init'), $args); } $this->stack[] = $this->curBlock = $block; return $block; } public function delStack() { $args = func_get_args(); $this->curBlock->buffer(ob_get_contents()); ob_clean(); $cnt = count($args); if ($cnt===0) { $this->curBlock->end(); } elseif ($cnt===1) { $this->curBlock->end($args[0]); } elseif ($cnt===2) { $this->curBlock->end($args[0], $args[1]); } elseif ($cnt===3) { $this->curBlock->end($args[0], $args[1], $args[2]); } elseif ($cnt===4) { $this->curBlock->end($args[0], $args[1], $args[2], $args[3]); } else { call_user_func_array(array($this->curBlock, 'end'), $args); } $tmp = array_pop($this->stack); if (count($this->stack) > 0) { $this->curBlock = end($this->stack); $this->curBlock->buffer($tmp->process()); } else { $this->curBlock = null; echo $tmp->process(); } unset($tmp); } public function getParentBlock(Dwoo_Block_Plugin $block) { $index = array_search($block, $this->stack, true); if ($index !== false && $index > 0) { return $this->stack[$index-1]; } return false; } public function findBlock($type) { if (isset($this->plugins[$type])) { $type = $this->plugins[$type]['class']; } else { $type = 'Dwoo_Plugin_'.str_replace('Dwoo_Plugin_', '', $type); } $keys = array_keys($this->stack); while (($key = array_pop($keys)) !== false) { if ($this->stack[$key] instanceof $type) { return $this->stack[$key]; } } return false; } public function getObjectPlugin($class) { if (isset($this->runtimePlugins[$class])) { return $this->runtimePlugins[$class]; } return $this->runtimePlugins[$class] = new $class($this); } public function classCall($plugName, array $params = array()) { $class = 'Dwoo_Plugin_'.$plugName; $plugin = $this->getObjectPlugin($class); $cnt = count($params); if ($cnt===0) { return $plugin->process(); } elseif ($cnt===1) { return $plugin->process($params[0]); } elseif ($cnt===2) { return $plugin->process($params[0], $params[1]); } elseif ($cnt===3) { return $plugin->process($params[0], $params[1], $params[2]); } elseif ($cnt===4) { return $plugin->process($params[0], $params[1], $params[2], $params[3]); } else { return call_user_func_array(array($plugin, 'process'), $params); } } public function arrayMap($callback, array $params) { if ($params[0] === $this) { $addThis = true; array_shift($params); } if ((is_array($params[0]) || ($params[0] instanceof Iterator && $params[0] instanceof ArrayAccess))) { if (empty($params[0])) { return $params[0]; } $out = array(); $cnt = count($params); if (isset($addThis)) { array_unshift($params, $this); $items = $params[1]; $keys = array_keys($items); if (is_string($callback) === false) { while (($i = array_shift($keys)) !== null) { $out[] = call_user_func_array($callback, array(1=>$items[$i]) + $params); } } elseif ($cnt===1) { while (($i = array_shift($keys)) !== null) { $out[] = $callback($this, $items[$i]); } } elseif ($cnt===2) { while (($i = array_shift($keys)) !== null) { $out[] = $callback($this, $items[$i], $params[2]); } } elseif ($cnt===3) { while (($i = array_shift($keys)) !== null) { $out[] = $callback($this, $items[$i], $params[2], $params[3]); } } else { while (($i = array_shift($keys)) !== null) { $out[] = call_user_func_array($callback, array(1=>$items[$i]) + $params); } } } else { $items = $params[0]; $keys = array_keys($items); if (is_string($callback) === false) { while (($i = array_shift($keys)) !== null) { $out[] = call_user_func_array($callback, array($items[$i]) + $params); } } elseif ($cnt===1) { while (($i = array_shift($keys)) !== null) { $out[] = $callback($items[$i]); } } elseif ($cnt===2) { while (($i = array_shift($keys)) !== null) { $out[] = $callback($items[$i], $params[1]); } } elseif ($cnt===3) { while (($i = array_shift($keys)) !== null) { $out[] = $callback($items[$i], $params[1], $params[2]); } } elseif ($cnt===4) { while (($i = array_shift($keys)) !== null) { $out[] = $callback($items[$i], $params[1], $params[2], $params[3]); } } else { while (($i = array_shift($keys)) !== null) { $out[] = call_user_func_array($callback, array($items[$i]) + $params); } } } return $out; } else { return $params[0]; } } public function readVarInto($varstr, $data, $safeRead = false) { if ($data === null) { return null; } if (is_array($varstr) === false) { preg_match_all('#(\[|->|\.)?((?:[^.[\]-]|-(?!>))+)\]?#i', $varstr, $m); } else { $m = $varstr; } unset($varstr); while (list($k, $sep) = each($m[1])) { if ($sep === '.' || $sep === '[' || $sep === '') { if ((is_array($data) || $data instanceof ArrayAccess) && ($safeRead === false || isset($data[$m[2][$k]]))) { $data = $data[$m[2][$k]]; } else { return null; } } else { if (is_object($data) && ($safeRead === false || isset($data->$m[2][$k]) || is_callable(array($data, '__get')))) { $data = $data->$m[2][$k]; } else { return null; } } } return $data; } public function readParentVar($parentLevels, $varstr = null) { $tree = $this->scopeTree; $cur = $this->data; while ($parentLevels--!==0) { array_pop($tree); } while (($i = array_shift($tree)) !== null) { if (is_object($cur)) { $cur = $cur->$i; } else { $cur = $cur[$i]; } } if ($varstr!==null) { return $this->readVarInto($varstr, $cur); } else { return $cur; } } public function readVar($varstr) { if (is_array($varstr)===true) { $m = $varstr; unset($varstr); } else { if (strstr($varstr, '.') === false && strstr($varstr, '[') === false && strstr($varstr, '->') === false) { if ($varstr === 'dwoo') { return $this->globals; } elseif ($varstr === '__' || $varstr === '_root' ) { return $this->data; $varstr = substr($varstr, 6); } elseif ($varstr === '_' || $varstr === '_parent') { $varstr = '.'.$varstr; $tree = $this->scopeTree; $cur = $this->data; array_pop($tree); while (($i = array_shift($tree)) !== null) { if (is_object($cur)) { $cur = $cur->$i; } else { $cur = $cur[$i]; } } return $cur; } $cur = $this->scope; if (isset($cur[$varstr])) { return $cur[$varstr]; } else { return null; } } if (substr($varstr, 0, 1) === '.') { $varstr = 'dwoo'.$varstr; } preg_match_all('#(\[|->|\.)?((?:[^.[\]-]|-(?!>))+)\]?#i', $varstr, $m); } $i = $m[2][0]; if ($i === 'dwoo') { $cur = $this->globals; array_shift($m[2]); array_shift($m[1]); switch ($m[2][0]) { case 'get': $cur = $_GET; break; case 'post': $cur = $_POST; break; case 'session': $cur = $_SESSION; break; case 'cookies': case 'cookie': $cur = $_COOKIE; break; case 'server': $cur = $_SERVER; break; case 'env': $cur = $_ENV; break; case 'request': $cur = $_REQUEST; break; case 'const': array_shift($m[2]); if (defined($m[2][0])) { return constant($m[2][0]); } else { return null; } } if ($cur !== $this->globals) { array_shift($m[2]); array_shift($m[1]); } } elseif ($i === '__' || $i === '_root') { $cur = $this->data; array_shift($m[2]); array_shift($m[1]); } elseif ($i === '_' || $i === '_parent') { $tree = $this->scopeTree; $cur = $this->data; while (true) { array_pop($tree); array_shift($m[2]); array_shift($m[1]); if (current($m[2]) === '_' || current($m[2]) === '_parent') { continue; } while (($i = array_shift($tree)) !== null) { if (is_object($cur)) { $cur = $cur->$i; } else { $cur = $cur[$i]; } } break; } } else { $cur = $this->scope; } while (list($k, $sep) = each($m[1])) { if ($sep === '.' || $sep === '[' || $sep === '') { if ((is_array($cur) || $cur instanceof ArrayAccess) && isset($cur[$m[2][$k]])) { $cur = $cur[$m[2][$k]]; } else { return null; } } elseif ($sep === '->') { if (is_object($cur)) { $cur = $cur->$m[2][$k]; } else { return null; } } else { return null; } } return $cur; } public function assignInScope($value, $scope) { $tree =& $this->scopeTree; $data =& $this->data; if (!is_string($scope)) { return $this->triggerError('Assignments must be done into strings, ('.gettype($scope).') '.var_export($scope, true).' given', E_USER_ERROR); } if (strstr($scope, '.') === false && strstr($scope, '->') === false) { $this->scope[$scope] = $value; } else { preg_match_all('#(\[|->|\.)?([^.[\]-]+)\]?#i', $scope, $m); $cur =& $this->scope; $last = array(array_pop($m[1]), array_pop($m[2])); while (list($k, $sep) = each($m[1])) { if ($sep === '.' || $sep === '[' || $sep === '') { if (is_array($cur) === false) { $cur = array(); } $cur =& $cur[$m[2][$k]]; } elseif ($sep === '->') { if (is_object($cur) === false) { $cur = new stdClass; } $cur =& $cur->$m[2][$k]; } else { return false; } } if ($last[0] === '.' || $last[0] === '[' || $last[0] === '') { if (is_array($cur) === false) { $cur = array(); } $cur[$last[1]] = $value; } elseif ($last[0] === '->') { if (is_object($cur) === false) { $cur = new stdClass; } $cur->$last[1] = $value; } else { return false; } } } public function setScope($scope, $absolute = false) { $old = $this->scopeTree; if (is_string($scope)===true) { $scope = explode('.', $scope); } if ($absolute===true) { $this->scope =& $this->data; $this->scopeTree = array(); } while (($bit = array_shift($scope)) !== null) { if ($bit === '_' || $bit === '_parent') { array_pop($this->scopeTree); $this->scope =& $this->data; $cnt = count($this->scopeTree); for ($i=0;$i<$cnt;$i++) $this->scope =& $this->scope[$this->scopeTree[$i]]; } elseif ($bit === '__' || $bit === '_root') { $this->scope =& $this->data; $this->scopeTree = array(); } elseif (isset($this->scope[$bit])) { $this->scope =& $this->scope[$bit]; $this->scopeTree[] = $bit; } else { unset($this->scope); $this->scope = null; } } return $old; } public function getData() { return $this->data; } public function setReturnValue($name, $value) { $this->returnData[$name] = $value; } public function getReturnValues() { return $this->returnData; } public function &getScope() { return $this->scope; } public function __call($method, $args) { $proxy = $this->getPluginProxy(); if (!$proxy) { throw new Dwoo_Exception('Call to undefined method '.__CLASS__.'::'.$method.'()'); } return call_user_func_array($proxy->getCallback($method), $args); } } class Dwoo extends Dwoo_Core { } interface Dwoo_IPluginProxy { public function handles($name); public function getCode($name, $params); public function getCallback($name); public function getLoader($name); } interface Dwoo_IElseable { } interface Dwoo_ILoader { public function loadPlugin($class, $forceRehash = true); } class Dwoo_Loader implements Dwoo_ILoader { protected $paths = array(); protected $classPath = array(); protected $cacheDir; protected $corePluginDir; public function __construct($cacheDir) { $this->corePluginDir = DWOO_DIRECTORY . 'plugins'; $this->cacheDir = rtrim($cacheDir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; $cacheFile = $this->cacheDir.'classpath.cache.d'.Dwoo_Core::RELEASE_TAG.'.php'; if (file_exists($cacheFile)) { $classpath = file_get_contents($cacheFile); $this->classPath = unserialize($classpath) + $this->classPath; } else { $this->rebuildClassPathCache($this->corePluginDir, $cacheFile); } } protected function rebuildClassPathCache($path, $cacheFile) { if ($cacheFile!==false) { $tmp = $this->classPath; $this->classPath = array(); } $list = glob(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*'); if (is_array($list)) { foreach ($list as $f) { if (is_dir($f)) { $this->rebuildClassPathCache($f, false); } else { $this->classPath[str_replace(array('function.','block.','modifier.','outputfilter.','filter.','prefilter.','postfilter.','pre.','post.','output.','shared.','helper.'), '', basename($f, '.php'))] = $f; } } } if ($cacheFile!==false) { if (!file_put_contents($cacheFile, serialize($this->classPath))) { throw new Dwoo_Exception('Could not write into '.$cacheFile.', either because the folder is not there (create it) or because of the chmod configuration (please ensure this directory is writable by php), alternatively you can change the directory used with $dwoo->setCompileDir() or provide a custom loader object with $dwoo->setLoader()'); } $this->classPath += $tmp; } } public function loadPlugin($class, $forceRehash = true) { if (!isset($this->classPath[$class]) || !(include $this->classPath[$class])) { if ($forceRehash) { $this->rebuildClassPathCache($this->corePluginDir, $this->cacheDir . 'classpath.cache.d'.Dwoo_Core::RELEASE_TAG.'.php'); foreach ($this->paths as $path=>$file) { $this->rebuildClassPathCache($path, $file); } if (isset($this->classPath[$class])) { include $this->classPath[$class]; } else { throw new Dwoo_Exception('Plugin <em>'.$class.'</em> can not be found, maybe you forgot to bind it if it\'s a custom plugin ?', E_USER_NOTICE); } } else { throw new Dwoo_Exception('Plugin <em>'.$class.'</em> can not be found, maybe you forgot to bind it if it\'s a custom plugin ?', E_USER_NOTICE); } } } public function addDirectory($pluginDirectory) { $pluginDir = realpath($pluginDirectory); if (!$pluginDir) { throw new Dwoo_Exception('Plugin directory does not exist or can not be read : '.$pluginDirectory); } $cacheFile = $this->cacheDir . 'classpath-'.substr(strtr($pluginDir, '/\\:'.PATH_SEPARATOR, '----'), strlen($pluginDir) > 80 ? -80 : 0).'.d'.Dwoo_Core::RELEASE_TAG.'.php'; $this->paths[$pluginDir] = $cacheFile; if (file_exists($cacheFile)) { $classpath = file_get_contents($cacheFile); $this->classPath = unserialize($classpath) + $this->classPath; } else { $this->rebuildClassPathCache($pluginDir, $cacheFile); } } } class Dwoo_Exception extends Exception { } class Dwoo_Security_Policy { const PHP_ENCODE = 1; const PHP_REMOVE = 2; const PHP_ALLOW = 3; const CONST_DISALLOW = false; const CONST_ALLOW = true; protected $allowedPhpFunctions = array ( 'str_repeat' => true, 'number_format' => true, 'htmlentities' => true, 'htmlspecialchars' => true, 'long2ip' => true, 'strlen' => true, 'list' => true, 'empty' => true, 'count' => true, 'sizeof' => true, 'in_array' => true, 'is_array' => true, ); protected $allowedMethods = array(); protected $allowedDirectories = array(); protected $phpHandling = self::PHP_REMOVE; protected $constHandling = self::CONST_DISALLOW; public function allowPhpFunction($func) { if (is_array($func)) foreach ($func as $fname) $this->allowedPhpFunctions[strtolower($fname)] = true; else $this->allowedPhpFunctions[strtolower($func)] = true; } public function disallowPhpFunction($func) { if (is_array($func)) foreach ($func as $fname) unset($this->allowedPhpFunctions[strtolower($fname)]); else unset($this->allowedPhpFunctions[strtolower($func)]); } public function getAllowedPhpFunctions() { return $this->allowedPhpFunctions; } public function allowMethod($class, $method = null) { if (is_array($class)) foreach ($class as $elem) $this->allowedMethods[strtolower($elem[0])][strtolower($elem[1])] = true; else $this->allowedMethods[strtolower($class)][strtolower($method)] = true; } public function disallowMethod($class, $method = null) { if (is_array($class)) foreach ($class as $elem) unset($this->allowedMethods[strtolower($elem[0])][strtolower($elem[1])]); else unset($this->allowedMethods[strtolower($class)][strtolower($method)]); } public function getAllowedMethods() { return $this->allowedMethods; } public function allowDirectory($path) { if (is_array($path)) foreach ($path as $dir) $this->allowedDirectories[realpath($dir)] = true; else $this->allowedDirectories[realpath($path)] = true; } public function disallowDirectory($path) { if (is_array($path)) foreach ($path as $dir) unset($this->allowedDirectories[realpath($dir)]); else unset($this->allowedDirectories[realpath($path)]); } public function getAllowedDirectories() { return $this->allowedDirectories; } public function setPhpHandling($level = self::PHP_REMOVE) { $this->phpHandling = $level; } public function getPhpHandling() { return $this->phpHandling; } public function setConstantHandling($level = self::CONST_DISALLOW) { $this->constHandling = $level; } public function getConstantHandling() { return $this->constHandling; } public function callMethod(Dwoo_Core $dwoo, $obj, $method, $args) { foreach ($this->allowedMethods as $class => $methods) { if (!isset($methods[$method])) { continue; } if ($obj instanceof $class) { return call_user_func_array(array($obj, $method), $args); } } $dwoo->triggerError('The current security policy prevents you from calling '.get_class($obj).'::'.$method.'()'); return null; } public function isMethodAllowed($class, $method = null) { if (is_array($class)) { list($class, $method) = $class; } foreach ($this->allowedMethods as $allowedClass => $methods) { if (!isset($methods[$method])) { continue; } if ($class === $allowedClass || is_subclass_of($class, $allowedClass)) { return true; } } return false; } } class Dwoo_Security_Exception extends Dwoo_Exception { } interface Dwoo_ICompilable { } interface Dwoo_ICompiler { public function compile(Dwoo_Core $dwoo, Dwoo_ITemplate $template); public function setCustomPlugins(array $customPlugins); public function setSecurityPolicy(Dwoo_Security_Policy $policy = null); } interface Dwoo_IDataProvider { public function getData(); } interface Dwoo_ITemplate { public function getCacheTime(); public function setCacheTime($seconds = null); public function getCachedTemplate(Dwoo_Core $dwoo); public function cache(Dwoo_Core $dwoo, $output); public function clearCache(Dwoo_Core $dwoo, $olderThan = -1); public function getCompiledTemplate(Dwoo_Core $dwoo, Dwoo_ICompiler $compiler = null); public function getName(); public function getResourceName(); public function getResourceIdentifier(); public function getSource(); public function getUid(); public function getCompiler(); public function getIsModifiedCode(); public static function templateFactory(Dwoo_Core $dwoo, $resourceId, $cacheTime = null, $cacheId = null, $compileId = null, Dwoo_ITemplate $parentTemplate = null); } interface Dwoo_ICompilable_Block { } abstract class Dwoo_Plugin { protected $dwoo; public function __construct(Dwoo_Core $dwoo) { $this->dwoo = $dwoo; } public static function paramsToAttributes(array $params, $delim = '\'') { if (isset($params['*'])) { $params = array_merge($params, $params['*']); unset($params['*']); } $out = ''; foreach ($params as $attr=>$val) { $out .= ' '.$attr.'='; if (trim($val, '"\'')=='' || $val=='null') { $out .= str_replace($delim, '\\'.$delim, '""'); } elseif (substr($val, 0, 1) === $delim && substr($val, -1) === $delim) { $out .= str_replace($delim, '\\'.$delim, '"'.substr($val, 1, -1).'"'); } else { $out .= str_replace($delim, '\\'.$delim, '"') . $delim . '.'.$val.'.' . $delim . str_replace($delim, '\\'.$delim, '"'); } } return ltrim($out); } } abstract class Dwoo_Block_Plugin extends Dwoo_Plugin { protected $buffer = ''; public function buffer($input) { $this->buffer .= $input; } public function end() { } public function process() { return $this->buffer; } public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type) { return Dwoo_Compiler::PHP_OPEN.$prepend.'$this->addStack("'.$type.'", array('.Dwoo_Compiler::implode_r($compiler->getCompiledParams($params)).'));'.$append.Dwoo_Compiler::PHP_CLOSE; } public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content) { return $content . Dwoo_Compiler::PHP_OPEN.$prepend.'$this->delStack();'.$append.Dwoo_Compiler::PHP_CLOSE; } } abstract class Dwoo_Filter { protected $dwoo; public function __construct(Dwoo_Core $dwoo) { $this->dwoo = $dwoo; } abstract public function process($input); } abstract class Dwoo_Processor { protected $compiler; public function __construct(Dwoo_Compiler $compiler) { $this->compiler = $compiler; } abstract public function process($input); } class Dwoo_Template_String implements Dwoo_ITemplate { protected $name; protected $compileId; protected $cacheId; protected $cacheTime; protected $compilationEnforced; protected static $cache = array('cached'=>array(), 'compiled'=>array()); protected $compiler; protected $chmod = 0777; public function __construct($templateString, $cacheTime = null, $cacheId = null, $compileId = null) { $this->template = $templateString; if (function_exists('hash')) { $this->name = hash('md4', $templateString); } else { $this->name = md5($templateString); } $this->cacheTime = $cacheTime; if ($compileId !== null) { $this->compileId = str_replace('../', '__', strtr($compileId, '\\%?=!:;'.PATH_SEPARATOR, '/-------')); } if ($cacheId !== null) { $this->cacheId = str_replace('../', '__', strtr($cacheId, '\\%?=!:;'.PATH_SEPARATOR, '/-------')); } } public function getCacheTime() { return $this->cacheTime; } public function setCacheTime($seconds = null) { $this->cacheTime = $seconds; } public function getChmod() { return $this->chmod; } public function setChmod($mask = null) { $this->chmod = $mask; } public function getName() { return $this->name; } public function getResourceName() { return 'string'; } public function getResourceIdentifier() { return false; } public function getSource() { return $this->template; } public function getUid() { return $this->name; } public function getCompiler() { return $this->compiler; } public function forceCompilation() { $this->compilationEnforced = true; } public function getCachedTemplate(Dwoo_Core $dwoo) { if ($this->cacheTime !== null) { $cacheLength = $this->cacheTime; } else { $cacheLength = $dwoo->getCacheTime(); } if ($cacheLength === 0) { return false; } $cachedFile = $this->getCacheFilename($dwoo); if (isset(self::$cache['cached'][$this->cacheId]) === true && file_exists($cachedFile)) { return $cachedFile; } elseif ($this->compilationEnforced !== true && file_exists($cachedFile) && ($cacheLength === -1 || filemtime($cachedFile) > ($_SERVER['REQUEST_TIME'] - $cacheLength)) && $this->isValidCompiledFile($this->getCompiledFilename($dwoo))) { self::$cache['cached'][$this->cacheId] = true; return $cachedFile; } else { return true; } } public function cache(Dwoo_Core $dwoo, $output) { $cacheDir = $dwoo->getCacheDir(); $cachedFile = $this->getCacheFilename($dwoo); $temp = tempnam($cacheDir, 'temp'); if (!($file = @fopen($temp, 'wb'))) { $temp = $cacheDir . uniqid('temp'); if (!($file = @fopen($temp, 'wb'))) { trigger_error('Error writing temporary file \''.$temp.'\'', E_USER_WARNING); return false; } } fwrite($file, $output); fclose($file); $this->makeDirectory(dirname($cachedFile), $cacheDir); if (!@rename($temp, $cachedFile)) { @unlink($cachedFile); @rename($temp, $cachedFile); } if ($this->chmod !== null) { chmod($cachedFile, $this->chmod); } self::$cache['cached'][$this->cacheId] = true; return $cachedFile; } public function clearCache(Dwoo_Core $dwoo, $olderThan = -1) { $cachedFile = $this->getCacheFilename($dwoo); return !file_exists($cachedFile) || (filectime($cachedFile) < (time() - $olderThan) && unlink($cachedFile)); } public function getCompiledTemplate(Dwoo_Core $dwoo, Dwoo_ICompiler $compiler = null) { $compiledFile = $this->getCompiledFilename($dwoo); if ($this->compilationEnforced !== true && isset(self::$cache['compiled'][$this->compileId]) === true) { } elseif ($this->compilationEnforced !== true && $this->isValidCompiledFile($compiledFile)) { self::$cache['compiled'][$this->compileId] = true; } else { $this->compilationEnforced = false; if ($compiler === null) { $compiler = $dwoo->getDefaultCompilerFactory($this->getResourceName()); if ($compiler === null || $compiler === array('Dwoo_Compiler', 'compilerFactory')) { if (class_exists('Dwoo_Compiler', false) === false) { include DWOO_DIRECTORY . 'Dwoo/Compiler.php'; } $compiler = Dwoo_Compiler::compilerFactory(); } else { $compiler = call_user_func($compiler); } } $this->compiler = $compiler; $compiler->setCustomPlugins($dwoo->getCustomPlugins()); $compiler->setSecurityPolicy($dwoo->getSecurityPolicy()); $this->makeDirectory(dirname($compiledFile), $dwoo->getCompileDir()); file_put_contents($compiledFile, $compiler->compile($dwoo, $this)); if ($this->chmod !== null) { chmod($compiledFile, $this->chmod); } self::$cache['compiled'][$this->compileId] = true; } return $compiledFile; } protected function isValidCompiledFile($file) { return file_exists($file); } public static function templateFactory(Dwoo_Core $dwoo, $resourceId, $cacheTime = null, $cacheId = null, $compileId = null, Dwoo_ITemplate $parentTemplate = null) { return new self($resourceId, $cacheTime, $cacheId, $compileId); } protected function getCompiledFilename(Dwoo_Core $dwoo) { if ($this->compileId===null) { $this->compileId = $this->name; } return $dwoo->getCompileDir() . $this->compileId.'.d'.Dwoo_Core::RELEASE_TAG.'.php'; } protected function getCacheFilename(Dwoo_Core $dwoo) { if ($this->cacheId === null) { if (isset($_SERVER['REQUEST_URI']) === true) { $cacheId = $_SERVER['REQUEST_URI']; } elseif (isset($_SERVER['SCRIPT_FILENAME']) && isset($_SERVER['argv'])) { $cacheId = $_SERVER['SCRIPT_FILENAME'].'-'.implode('-', $_SERVER['argv']); } else { $cacheId = ''; } $this->getCompiledFilename($dwoo); $this->cacheId = str_replace('../', '__', $this->compileId . strtr($cacheId, '\\%?=!:;'.PATH_SEPARATOR, '/-------')); } return $dwoo->getCacheDir() . $this->cacheId.'.html'; } public function getIsModifiedCode() { return null; } protected function makeDirectory($path, $baseDir = null) { if (is_dir($path) === true) { return; } if ($this->chmod === null) { $chmod = 0777; } else { $chmod = $this->chmod; } mkdir($path, $chmod, true); if (strpos(PHP_OS, 'WIN') !== 0 && $baseDir !== null) { $path = strtr(str_replace($baseDir, '', $path), '\\', '/'); $folders = explode('/', trim($path, '/')); foreach ($folders as $folder) { $baseDir .= $folder . DIRECTORY_SEPARATOR; chmod($baseDir, $chmod); } } } } class Dwoo_Template_File extends Dwoo_Template_String { protected $file; protected $includePath = null; protected $resolvedPath = null; public function __construct($file, $cacheTime = null, $cacheId = null, $compileId = null, $includePath = null) { $this->file = $file; $this->name = basename($file); $this->cacheTime = $cacheTime; if ($compileId !== null) { $this->compileId = str_replace('../', '__', strtr($compileId, '\\%?=!:;'.PATH_SEPARATOR, '/-------')); } if ($cacheId !== null) { $this->cacheId = str_replace('../', '__', strtr($cacheId, '\\%?=!:;'.PATH_SEPARATOR, '/-------')); } if (is_string($includePath)) { $this->includePath = array($includePath); } elseif (is_array($includePath)) { $this->includePath = $includePath; } } public function setIncludePath($paths) { if (is_array($paths) === false) { $paths = array($paths); } $this->includePath = $paths; $this->resolvedPath = null; } public function getIncludePath() { return $this->includePath; } protected function isValidCompiledFile($file) { return parent::isValidCompiledFile($file) && (int)$this->getUid() <= filemtime($file); } public function getSource() { return file_get_contents($this->getResourceIdentifier()); } public function getResourceName() { return 'file'; } public function getResourceIdentifier() { if ($this->resolvedPath !== null) { return $this->resolvedPath; } elseif ($this->includePath === null) { return $this->file; } else { foreach ($this->includePath as $path) { $path = rtrim($path, DIRECTORY_SEPARATOR); if (file_exists($path.DIRECTORY_SEPARATOR.$this->file) === true) { $this->resolvedPath = $path . DIRECTORY_SEPARATOR . $this->file; return $this->resolvedPath; } } throw new Dwoo_Exception('Template "'.$this->file.'" could not be found in any of your include path(s)'); } } public function getUid() { return (string) filemtime($this->getResourceIdentifier()); } public static function templateFactory(Dwoo_Core $dwoo, $resourceId, $cacheTime = null, $cacheId = null, $compileId = null, Dwoo_ITemplate $parentTemplate = null) { if (DIRECTORY_SEPARATOR === '\\') { $resourceId = str_replace(array("\t", "\n", "\r", "\f", "\v"), array('\\t', '\\n', '\\r', '\\f', '\\v'), $resourceId); } $resourceId = strtr($resourceId, '\\', '/'); $includePath = null; if (file_exists($resourceId) === false) { if ($parentTemplate === null) { $parentTemplate = $dwoo->getTemplate(); } if ($parentTemplate instanceof Dwoo_Template_File) { if ($includePath = $parentTemplate->getIncludePath()) { if (strstr($resourceId, '../')) { throw new Dwoo_Exception('When using an include path you can not reference a template into a parent directory (using ../)'); } } else { $resourceId = dirname($parentTemplate->getResourceIdentifier()).DIRECTORY_SEPARATOR.$resourceId; if (file_exists($resourceId) === false) { return null; } } } else { return null; } } if ($policy = $dwoo->getSecurityPolicy()) { while (true) { if (preg_match('{^([a-z]+?)://}i', $resourceId)) { throw new Dwoo_Security_Exception('The security policy prevents you to read files from external sources : <em>'.$resourceId.'</em>.'); } if ($includePath) { break; } $resourceId = realpath($resourceId); $dirs = $policy->getAllowedDirectories(); foreach ($dirs as $dir=>$dummy) { if (strpos($resourceId, $dir) === 0) { break 2; } } throw new Dwoo_Security_Exception('The security policy prevents you to read <em>'.$resourceId.'</em>'); } } $class = 'Dwoo_Template_File'; if ($parentTemplate) { $class = get_class($parentTemplate); } return new $class($resourceId, $cacheTime, $cacheId, $compileId, $includePath); } protected function getCompiledFilename(Dwoo_Core $dwoo) { if ($this->compileId===null) { $this->compileId = str_replace('../', '__', strtr($this->getResourceIdentifier(), '\\:', '/-')); } return $dwoo->getCompileDir() . $this->compileId.'.d'.Dwoo_Core::RELEASE_TAG.'.php'; } public function getIsModifiedCode() { return '"'.$this->getUid().'" == filemtime('.var_export($this->getResourceIdentifier(), true).')'; } } class Dwoo_Data implements Dwoo_IDataProvider { protected $data = array(); public function getData() { return $this->data; } public function clear($name = null) { if ($name === null) { $this->data = array(); } elseif (is_array($name)) { foreach ($name as $index) unset($this->data[$index]); } else { unset($this->data[$name]); } } public function setData(array $data) { $this->data = $data; } public function mergeData(array $data) { $args = func_get_args(); while (list(,$v) = each($args)) { if (is_array($v)) { $this->data = array_merge($this->data, $v); } } } public function assign($name, $val = null) { if (is_array($name)) { reset($name); while (list($k,$v) = each($name)) $this->data[$k] = $v; } else { $this->data[$name] = $val; } } public function __set($name, $value) { $this->assign($name, $value); } public function assignByRef($name, &$val) { $this->data[$name] =& $val; } public function append($name, $val = null, $merge = false) { if (is_array($name)) { foreach ($name as $key=>$val) { if (isset($this->data[$key]) && !is_array($this->data[$key])) { settype($this->data[$key], 'array'); } if ($merge === true && is_array($val)) { $this->data[$key] = $val + $this->data[$key]; } else { $this->data[$key][] = $val; } } } elseif ($val !== null) { if (isset($this->data[$name]) && !is_array($this->data[$name])) { settype($this->data[$name], 'array'); } elseif (!isset($this->data[$name])) { $this->data[$name] = array(); } if ($merge === true && is_array($val)) { $this->data[$name] = $val + $this->data[$name]; } else { $this->data[$name][] = $val; } } } public function appendByRef($name, &$val, $merge = false) { if (isset($this->data[$name]) && !is_array($this->data[$name])) { settype($this->data[$name], 'array'); } if ($merge === true && is_array($val)) { foreach ($val as $key => &$val) { $this->data[$name][$key] =& $val; } } else { $this->data[$name][] =& $val; } } public function isAssigned($name) { return isset($this->data[$name]); } public function __isset($name) { return isset($this->data[$name]); } public function unassign($name) { unset($this->data[$name]); } public function __unset($name) { unset($this->data[$name]); } public function get($name) { return $this->__get($name); } public function __get($name) { if (isset($this->data[$name])) { return $this->data[$name]; } else { throw new Dwoo_Exception('Tried to read a value that was not assigned yet : "'.$name.'"'); } } } 
Index: /branches/0.4/web/addons/job_monarch/dwoo/Dwoo.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/Dwoo.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/Dwoo.php	(revision 755)
@@ -0,0 +1,20 @@
+<?php
+
+/**
+ * micro-class that extends Dwoo_Core for compatibility purposes
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.1.0
+ * @date       2010-02-28
+ * @package    Dwoo
+ * @see Dwoo_Core
+ */
+class Dwoo extends Dwoo_Core
+{
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/Agavi/DwooRenderer.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/Agavi/DwooRenderer.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/Agavi/DwooRenderer.php	(revision 755)
@@ -0,0 +1,204 @@
+<?php
+
+/**
+ * Dwoo adapter for Agavi
+ *
+ * Install instructions :
+ *  - download dwoo from dwoo.org and unzip it somewhere in your agavi app
+ *  - add a renderer to your output_types.xml as such :
+ *     <renderer name="dwoo" class="DwooRenderer">
+ *        <parameter name="assigns">
+ *           <parameter name="routing">ro</parameter>
+ *           <parameter name="request">rq</parameter>
+ *           <parameter name="controller">ct</parameter>
+ *           <parameter name="user">us</parameter>
+ *           <parameter name="translation_manager">tm</parameter>
+ *           <parameter name="request_data">rd</parameter>
+ *        </parameter>
+ *        <parameter name="extract_vars">true</parameter>
+ *        <parameters name="plugin_dir">
+ *           <parameter>%core.lib_dir%/dwoo_plugins</parameter>
+ *           <parameter>%core.lib_dir%/other_dwoo_plugins</parameter>
+ *        </parameters>
+ *     </renderer>
+ *
+ *  - add dwoo's directory to your include path or include dwooAutoload.php yourself
+ *    either through agavi's autoload.xml (with name="Dwoo") or through your index.php
+ *
+ * Notes:
+ *  - you can copy the /Dwoo/Adapters/Agavi/dwoo_plugins directory to your agavi app's
+ *    lib directory, or change the plugin_dir parameter in the output_types.xml file.
+ *    these plugins are agavi-specific helpers that shortens the syntax to call common
+ *    agavi helpers (i18n, routing, ..)
+ *  - in the previous versions of this adapter, only a single value could be passed to
+ *    plugin_dir parameter; now you can pass several plugin directories (see example)
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the
+ * use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.1.1
+ * @date       2010-04-06
+ * @package    Dwoo
+ */
+class DwooRenderer extends AgaviRenderer implements AgaviIReusableRenderer
+{
+	/**
+	 * @constant   string The directory inside the cache dir where templates will
+	 *                    be stored in compiled form.
+	 */
+	const COMPILE_DIR = 'templates';
+
+	/**
+	 * @constant   string The subdirectory inside the compile dir where templates
+	 *                    will be stored in compiled form.
+	 */
+	const COMPILE_SUBDIR = 'dwoo';
+
+	/**
+	 * @constant   string The directory inside the cache dir where cached content
+	 *                    will be stored.
+	 */
+	const CACHE_DIR = 'dwoo';
+
+	/**
+	 * @var        Dwoo Dwoo template engine.
+	 */
+	protected $dwoo = null;
+
+	/**
+	 * @var        string A string with the default template file extension,
+	 *                    including the dot.
+	 */
+	protected $defaultExtension = '.html';
+
+	/**
+	 * stores the (optional) plugin directories to add to the Dwoo_Loader
+	 */
+	protected $plugin_dir = null;
+
+	/**
+	 * Pre-serialization callback.
+	 *
+	 * Excludes the Dwoo instance to prevent excessive serialization load.
+	 */
+	public function __sleep()
+	{
+		$keys = parent::__sleep();
+		unset($keys[array_search('dwoo', $keys)]);
+		return $keys;
+	}
+
+	/**
+	 * Initialize this Renderer.
+	 *
+	 * @param      AgaviContext The current application context.
+	 * @param      array        An associative array of initialization parameters.
+	 */
+	public function initialize(AgaviContext $context, array $parameters = array())
+	{
+		parent::initialize($context, $parameters);
+
+		$this->plugin_dir = $this->getParameter('plugin_dir', $this->plugin_dir);
+	}
+
+	/**
+	 * provides a custom compiler to the dwoo renderer with optional settings
+	 * you can set in the agavi output_types.xml config file
+	 *
+	 * @return Dwoo_Compiler
+	 */
+	public function compilerFactory()
+	{
+		if (class_exists('Dwoo_Compiler', false) === false) {
+			include DWOO_DIRECTORY . 'Dwoo/Compiler.php';
+		}
+		$compiler = Dwoo_Compiler::compilerFactory();
+		$compiler->setAutoEscape((bool) $this->getParameter('auto_escape', false));
+		return $compiler;
+	}
+
+	/**
+	 * Grab a cleaned up dwoo instance.
+	 *
+	 * @return     Dwoo A Dwoo instance.
+	 */
+	protected function getEngine()
+	{
+		if($this->dwoo) {
+			return $this->dwoo;
+		}
+
+		// this triggers Agavi autoload
+		if(!class_exists('Dwoo')) {
+			if (file_exists(dirname(__FILE__).'/../../../dwooAutoload.php')) {
+				// file was dropped with the entire dwoo package
+				require dirname(__FILE__).'/../../../dwooAutoload.php';
+			} else {
+				// assume the dwoo package is in the include path
+				require 'dwooAutoload.php';
+			}
+		}
+
+		$parentMode = fileperms(AgaviConfig::get('core.cache_dir'));
+
+		$compileDir = AgaviConfig::get('core.cache_dir') . DIRECTORY_SEPARATOR . self::COMPILE_DIR . DIRECTORY_SEPARATOR . self::COMPILE_SUBDIR;
+		AgaviToolkit::mkdir($compileDir, $parentMode, true);
+
+		$cacheDir = AgaviConfig::get('core.cache_dir') . DIRECTORY_SEPARATOR . self::CACHE_DIR;
+		AgaviToolkit::mkdir($cacheDir, $parentMode, true);
+
+		$this->dwoo = new Dwoo_Core($compileDir, $cacheDir);
+
+		if (!empty($this->plugin_dir)) {
+			foreach ((array) $this->plugin_dir as $dir) {
+				$this->dwoo->getLoader()->addDirectory($dir);
+			}
+		}
+
+		$this->dwoo->setDefaultCompilerFactory('file', array($this, 'compilerFactory'));
+
+		return $this->dwoo;
+	}
+
+	/**
+	 * Render the presentation and return the result.
+	 *
+	 * @param      AgaviTemplateLayer The template layer to render.
+	 * @param      array              The template variables.
+	 * @param      array              The slots.
+	 * @param      array              Associative array of additional assigns.
+	 *
+	 * @return     string A rendered result.
+	 */
+	public function render(AgaviTemplateLayer $layer, array &$attributes = array(), array &$slots = array(), array &$moreAssigns = array())
+	{
+		$engine = $this->getEngine();
+
+		$data = array();
+		if($this->extractVars) {
+			$data = $attributes;
+		} else {
+			$data[$this->varName] = &$attributes;
+		}
+
+		$data[$this->slotsVarName] =& $slots;
+
+		foreach($this->assigns as $key => $getter) {
+			$data[$key] = $this->getContext()->$getter();
+		}
+
+		foreach($moreAssigns as $key => &$value) {
+			if(isset($this->moreAssignNames[$key])) {
+				$key = $this->moreAssignNames[$key];
+			}
+			$data[$key] =& $value;
+		}
+
+		return $engine->get($layer->getResourceStreamIdentifier(), $data);
+	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/Agavi/README
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/Agavi/README	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/Agavi/README	(revision 755)
@@ -0,0 +1,27 @@
+// ------------------------
+// Install notes :
+// ------------------------
+
+ - drop dwoo's directory in app/lib/renderer (create if needed)
+
+ - add a renderer to app/config/output_types.xml as such :
+    <renderer name="dwoo" class="DwooRenderer">
+       <parameter name="assigns">
+          <parameter name="routing">ro</parameter>
+          <parameter name="request">rq</parameter>
+          <parameter name="controller">ct</parameter>
+          <parameter name="user">us</parameter>
+          <parameter name="translation_manager">tm</parameter>
+          <parameter name="request_data">rd</parameter>
+       </parameter>
+       <parameter name="extract_vars">true</parameter>
+       <parameter name="plugin_dir">%core.lib_dir%/dwoo_plugins</parameter>
+    </renderer>
+
+ - add the renderer to app/config/autoload.xml as such :
+    <autoload name="DwooRenderer">%core.lib_dir%/renderer/dwoo/Dwoo/Adapter/Agavi/DwooRenderer.php</autoload>
+
+ - you can copy the /Dwoo/Adapters/Agavi/dwoo_plugins directory to your agavi app's
+   lib directory, or change the plugin_dir parameter in the output_types.xml file.
+   these plugins are agavi-specific helpers that shortens the syntax to call common
+   agavi helpers (i18n, routing, ..)
Index: /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/Agavi/dwoo_plugins/t.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/Agavi/dwoo_plugins/t.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/Agavi/dwoo_plugins/t.php	(revision 755)
@@ -0,0 +1,32 @@
+<?php
+
+/**
+ * <strong>Agavi specific plugin</strong>
+ *
+ * uses AgaviTranslationManager to localize a string
+ *
+ * <pre>
+ *  * string : the string to localize
+ * </pre>
+ *
+ * Examples:
+ * <code>
+ * {t "Hello"}
+ * {t $header}
+ * </code>
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+function Dwoo_Plugin_t_compile(Dwoo_Compiler $compiler, $string)
+{
+	return '$this->data[\'tm\']->_('.$string.')';
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/Agavi/dwoo_plugins/url.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/Agavi/dwoo_plugins/url.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/Agavi/dwoo_plugins/url.php	(revision 755)
@@ -0,0 +1,54 @@
+<?php
+
+/**
+ * <strong>Agavi specific plugin</strong>
+ *
+ * uses AgaviRouting to create an url
+ *
+ * <pre>
+ *  * route : the route name, optional (by default the current url is returned)
+ *  * params : an array with variables to build the route, optional
+ *  * options : an array of options to pass to the routing object, optional
+ *  * rest : for convenience, you can just pass named parameters that will be used as
+ *           the params array, but you must not provide the params array in this case
+ * </pre>
+ *
+ * Examples:
+ * <code>
+ * {a url("route.name" array(param="Value", param2=$otherVal))}Here is a link{/a}
+ * <form action="{url}"> {* without any parameter it just returns the current url *}
+ * </code>
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+function Dwoo_Plugin_url_compile(Dwoo_Compiler $compiler, $route = null, $params = null, $options = null, array $rest = array())
+{
+	if ($params == 'null') {
+		if (count($rest)) {
+			$params = array();
+			foreach ($rest as $k=>$v) {
+				if (is_numeric($k)) {
+					$params[] = $k.'=>'.$v;
+				} else {
+					$params[] = '"'.$k.'"=>'.$v;
+				}
+			}
+			$params = 'array('.implode(', ', $params).')';
+		} else {
+			$params = 'array()';
+		}
+	}
+	if ($options == 'null') {
+		$options = 'array()';
+	}
+	return '$this->data[\'ro\']->gen('.$route.', '.$params.', '.$options.')';
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/CakePHP/README
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/CakePHP/README	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/CakePHP/README	(revision 755)
@@ -0,0 +1,33 @@
+// CakePHP Dwoo bridge  -  v0.2 
+// ------------------------
+// Installation :
+// ------------------------
+// 1. Download and install the dwoo library, preferably on the
+// 'vendors' directory of CakePHP. However you can place it
+// anywhere you want; if you do, make sure to change the App::import
+// line in dwoo.php to include the dwoo library properly.
+//
+// 2. Place this file in the  app/views directory, or on cake/libs/view.
+// 
+// 3. Create the app/tmp/dwoo/cache and app/tmp/dwoo/compile directories 
+// and make sure they are writable.
+// ------------------------
+// Usage example :
+// ------------------------
+
+// In your controller class you need to change the view property to
+// use Dwoo at some point in the execution using :
+
+$this->view = 'Dwoo';
+
+// Or you can also override the view property in your AppController class as such :
+
+class AppController extends Controller {
+    public $view = 'Dwoo';
+}
+
+// If you want another template extension (default is .tpl) you must
+// edit the dwoo.php file at line 44 and change it to :
+$this->ext = ".html";
+
+//{include $templatedir."index.tpl"}
Index: /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/CakePHP/dwoo.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/CakePHP/dwoo.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/CakePHP/dwoo.php	(revision 755)
@@ -0,0 +1,143 @@
+<?php
+
+App::import('vendor', 'dwoo', array("file" => 'dwoo/dwooAutoload.php'));
+
+/**
+ * Dwoo adapter for CakePHP
+ *
+ * Based on SmartyView by Mark John S. Buenconsejo <mjwork@simpleteq.com>
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * This file is released under the LGPL
+ * "GNU Lesser General Public License"
+ * More information can be found here:
+ * {@link http://www.gnu.org/copyleft/lesser.html}
+ *
+ * @author     Mark John S. Buenconsejo <mjwork@simpleteq.com>
+ * @author     Giangi <giangi@qwerg.com>
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://www.gnu.org/copyleft/lesser.html  GNU Lesser General Public License
+ * @link       http://dwoo.org/
+ * @version    1.1.0
+ * @date       2009-07-18
+ * @package    Dwoo
+ */
+class DwooView extends View
+{
+	protected $_sv_template_dir;
+	protected $_sv_layout_dir;
+	protected $_sv_compile_dir;
+	protected $_sv_cache_dir;
+	protected $_sv_compile_id;
+
+	protected $_dwoo;
+
+	public $sv_processedTpl;
+
+ 	public function __construct(&$controller)
+	{
+		parent::__construct($controller);
+
+		$this->ext = '.tpl';
+
+		$this->_sv_template_dir = array
+		(
+			VIEWS . $this->viewPath . DS . $this->subDir,
+			VIEWS . $this->viewPath,
+			VIEWS
+		);
+
+		$this->_sv_layout_dir = array
+		(
+			LAYOUTS . $this->subDir,
+			VIEWS
+		);
+
+		$this->_sv_compile_dir = TMP . 'dwoo' . DS . 'compile';
+		$this->_sv_cache_dir = TMP . 'dwoo' . DS . 'cache';
+
+		$this->_dwoo = new Dwoo_Core($this->_sv_compile_dir, $this->_sv_cache_dir);
+
+		$this->_sv_compile_id = $controller->name;
+
+		$this->_dwoo->sv_this = $this;
+        $this->_dwoo->setSecurityPolicy();
+
+		return;
+	}
+
+	/**
+	 * changes the template directory
+	 */
+	public function setTemplateDir($path = VIEW) {
+		$old = $this->_sv_template_dir;
+		$this->_sv_template_dir  = $path;
+
+		return $old;
+	}
+
+	public function getTemplateDir() {
+		return $this->_sv_template_dir ;
+	}
+
+	public function _render($___viewFn, $___data_for_view, $___play_safe = true, $loadHelpers = true)
+	{
+		// let's determine if this is a layout call or a template call
+		// and change the template dir accordingly
+		$layout = false;
+		if(isset($___data_for_view['content_for_layout'])) {
+			$this->_sv_template_dir = $this->_sv_layout_dir;
+			$layout = true;
+		}
+
+		$tpl  = new Dwoo_Template_File($___viewFn);
+		$data = $___data_for_view;
+
+		$data['view'] = $this;
+
+		if ($this->helpers != false && $loadHelpers === true) {
+			$loadedHelpers = array();
+			$loadedHelpers = $this->_loadHelpers($loadedHelpers, $this->helpers);
+
+			foreach (array_keys($loadedHelpers) as $helper) {
+				$camelBackedHelper = strtolower(substr($helper, 0, 1)) . substr($helper, 1);
+
+				${$camelBackedHelper} = $loadedHelpers[$helper];
+
+				if (is_array(${$camelBackedHelper}->helpers) && !empty(${$camelBackedHelper}->helpers)) {
+					$subHelpers = ${$camelBackedHelper}->helpers;
+					foreach ($subHelpers as $subHelper) {
+						${$camelBackedHelper}->{$subHelper} = $loadedHelpers[$subHelper];
+					}
+				}
+
+				if(isset($this->passedArgs)) {
+					${$camelBackedHelper}->passedArgs = $this->passedArgs;
+				}
+
+				$this->loaded[$camelBackedHelper] = ${$camelBackedHelper};
+
+				$data[$camelBackedHelper] = ${$camelBackedHelper};
+			}
+		}
+
+		if ($this->helpers != false && $loadHelpers === true) {
+			foreach ($loadedHelpers as $helper) {
+				if (is_object($helper)) {
+					if (is_subclass_of($helper, 'Helper') || is_subclass_of($helper, 'helper')) {
+						$helper->beforeRender();
+					}
+				}
+			}
+		}
+
+		return $this->_dwoo->get($tpl, $data);
+	}
+
+	public function get(){
+		return $this->_dwoo;
+	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/CodeIgniter/README
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/CodeIgniter/README	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/CodeIgniter/README	(revision 755)
@@ -0,0 +1,36 @@
+CodeIgniter/Dwoo adapater
+-------------------------
+Integration of Dwoo into Codeigniter (1.7.0 >)
+
+Links:
+Dwoo - http://dwoo.org
+CodeIgniter - http://codeigniter.com
+
+Installation:
+1) Extract package into your application directory (i.e. $webroot/application or 
+   $webroot/system/application)
+2) Change the parameters in config/dwootemplate.php
+3) Create the compile and cache directory you set in your config file in step 2
+   and give it the correct rights (chmod 777 when on *nix)
+4) Extract/copy the Dwoo package into application/libraries/dwoo
+5) Browse to : http://[yoururl]/dwoowelcome
+
+
+Version info
+1.0.2 [11-03-2009] Fixed a problem with $data attribute (which Dwoo also used)
+1.0.1 [12-11-2008] Removed some & in the dwootemplate
+                   Changed licencse
+                   Changed 'output' in 'get' in the dwootemplate (line 122)
+1.0.0 [11-11-2008] Initial release
+
+
+Questions/Remarks?
+mail to:        stefan.verstege@newmedia.nl
+IM me on GTALK: verstege@gmail.com
+Contact me on the Dwoo forums: stefanv
+
+---------[ copyright notice ]-----------------------------------------------------------------------
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from the use of this software.
+
+License    http://dwoo.org/LICENSE   Modified BSD License
Index: /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/CodeIgniter/config/dwootemplate.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/CodeIgniter/config/dwootemplate.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/CodeIgniter/config/dwootemplate.php	(revision 755)
@@ -0,0 +1,12 @@
+<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');
+
+// The name of the directory where templates are located.
+$config['template_dir'] = dirname(FCPATH) . '/../application/views/';
+
+// The directory where compiled templates are located
+$config['compileDir']   = dirname(FCPATH) . '/../compile/';
+
+//This tells Dwoo whether or not to cache the output of the templates to the $cache_dir.
+$config['caching']      = 0;
+$config['cacheDir']     = dirname(FCPATH) . '/../cache/';
+$config['cacheTime']    = 0;
Index: /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/CodeIgniter/controllers/dwoowelcome.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/CodeIgniter/controllers/dwoowelcome.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/CodeIgniter/controllers/dwoowelcome.php	(revision 755)
@@ -0,0 +1,16 @@
+<?php
+
+class Dwoowelcome extends Controller {
+
+    function __construct()
+    {
+        parent::Controller();
+    }
+
+    function index()
+    {
+    	$this->load->library('Dwootemplate');
+    	$this->dwootemplate->assign('itshowlate', date('H:i:s'));
+    	$this->dwootemplate->display('dwoowelcome.tpl');
+    }
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/CodeIgniter/libraries/Dwootemplate.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/CodeIgniter/libraries/Dwootemplate.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/CodeIgniter/libraries/Dwootemplate.php	(revision 755)
@@ -0,0 +1,172 @@
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+
+require "dwoo/dwooAutoload.php";
+
+/**
+ * Creates an template interface from Codeigniter to DWOO.
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ *
+ * @author     Stefan Verstege <stefan.verstege@newmedia.nl>
+ * @copyright  Copyright (c) 2008, Stefan Verstege
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://www.newmedia.nl/
+ * @version    1.1.0
+ * @date       2009-07-18
+ * @package    Dwoo
+ *
+ * @uses the dwoo package from http://dwoo.org
+ */
+class Dwootemplate extends Dwoo_Core {
+    protected $dwoo_data = array();
+
+    /**
+     * Constructor for the DwooTemplate engine
+     *
+     */
+    public function __construct() {
+        // Call parents constructor
+        parent::__construct();
+
+        // Set the config settings
+        $this->initialize();
+
+        // Assign some defaults to dwoo
+        $CI                         = get_instance();
+        $this->dwoo_data            = new Dwoo_Data();
+        $this->dwoo_data->js_files  = array();
+        $this->dwoo_data->css_files = array();
+        $this->dwoo_data->CI        = $CI;
+        $this->dwoo_data->site_url  = $CI->config->site_url(); // so we can get the full path to CI easily
+        $this->dwoo_data->uniqid    = uniqid();
+        $this->dwoo_data->timestamp = mktime();
+
+        log_message('debug', "Dwoo Template Class Initialized");
+    }
+
+
+    /**
+     * Assign data to dwoo data object
+     *
+     * @param string $key
+     * @param mixed $value
+     */
+    public function assign($key, $value) {
+        $this->dwoo_data->$key = $value;
+    }
+
+
+    /**
+     * Add Javascript files to template
+     *
+     * @param string $js
+     */
+    public function add_js($js) {
+        $current   = $this->dwoo_data->js_files;
+        $current[] = $js;
+        $this->dwoo_data->js_files = $current;
+    }
+
+
+    /**
+     * Add Css stylesheets to template
+     *
+     * @param string $css
+     */
+    public function add_css($css) {
+        $current   = $this->dwoo_data->css_files;
+        $current[] = $css;
+        $this->dwoo_data->css_files = $current;
+    }
+
+
+    /**
+     * Display or return the compiled template
+     * Since we assign the results to the standard CI output module
+     * you can also use the helper from CI in your templates!!
+     *
+     * @param string $sTemplate
+     * @param boolean $return
+     * @return mixed
+     */
+    public function display($sTemplate, $return = FALSE) {
+        // Start benchmark
+        $CI = get_instance();
+        $CI->benchmark->mark('dwoo_parse_start');
+
+        // Check if file exists
+        if ( !file_exists($this->template_dir . $sTemplate ) ) {
+            $message = sprintf('Template file \'%s\' not found.', $sTemplate);
+            show_error($message);
+            log_message('error', $message);
+        }
+
+        // Create new template
+        $tpl = new Dwoo_Template_File($this->template_dir . $sTemplate);
+
+        // render the template
+        $template = $this->get($tpl, $this->dwoo_data);
+
+        // Finish benchmark
+        $CI->benchmark->mark('dwoo_parse_end');
+
+        // Return results or not ?
+        if ($return == FALSE) {
+            $CI->output->final_output = $template;
+        } else {
+            return $template;
+        }
+    }
+
+
+    /**
+     * Toggle Codeigniter profiler on/off
+     *
+     */
+    public function enable_profiler($toggle = TRUE) {
+        $CI = get_instance();
+        $CI->output->enable_profiler($toggle);
+    }
+
+
+    /**
+     * Set http header
+     *
+     * @example $this->output->set_header("HTTP/1.1 200 OK");
+     * @example $this->output->set_header('Last-Modified: '.gmdate('D, d M Y H:i:s', $last_update).' GMT');
+     * @param string $header
+     */
+    public function set_header($header) {
+        $CI = get_instance();
+        $CI->output->set_header($header);
+    }
+
+
+    /**
+     * Set status header
+     *
+     * @example $this->output->set_status_header('401');
+     * @example // Sets the header as: Unauthorized
+     * @param string $header
+     */
+    public function set_status_header($header) {
+        $CI = get_instance();
+        $CI->output->set_status_header($header);
+    }
+
+
+    /**
+     * Assign the dwootemplate config items to the instance
+     *
+     */
+    private function initialize() {
+        $CI = get_instance();
+        $CI->config->load('dwootemplate', TRUE);
+        $config = $CI->config->item('dwootemplate');
+        foreach ($config as $key => $val) {
+                $this->$key = $val;
+        }
+    }
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/CodeIgniter/views/dwoowelcome.tpl
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/CodeIgniter/views/dwoowelcome.tpl	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/CodeIgniter/views/dwoowelcome.tpl	(revision 755)
@@ -0,0 +1,31 @@
+{extends "page.tpl"}
+
+{block "title"}
+Welcome to Dwoo-ed CodeIgniter
+{/block}
+
+{block "content"}
+<h1>Welcome to Dwoo-ed CodeIgniter!</h1>
+
+<p>The page you are looking at is being generated dynamically by <b>CodeIgniter</b> in combination with the 'Smarty-killer' <b>Dwoo</b> template engine.
+The page is rendered at {$itshowlate} by the Dwoo_compiler.</p>
+
+<p>If you would like to edit this page you'll find it located at:</p>
+<code>application/views/dwoowelcome.tpl</code>
+
+<p>The corresponding controller for this page is found at:</p>
+<code>application/controllers/dwoowelcome.php</code>
+
+<p>The library for Dwoo integration can be found at:</p>
+<code>application/libraries/Dwootemplate.php</code>
+
+<p>If you are exploring Dwoo for the very first time, you should start by reading the {anchor uri='http://dwoo.org/' title='Dwoo website'}.</p>
+<p>If you are exploring CodeIgniter for the very first time, you should start by reading the {anchor uri='http://codeigniter.com/user_guide/' title='User Guide'}.</p>
+
+<pre>
+<b>Usage</b>:
+$this->load->library('Dwootemplate');
+$this->dwootemplate->assign('test', 'test');
+$this->dwootemplate->display('dwoowelcome.tpl');
+</pre>
+{/block}
Index: /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/CodeIgniter/views/page.tpl
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/CodeIgniter/views/page.tpl	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/CodeIgniter/views/page.tpl	(revision 755)
@@ -0,0 +1,57 @@
+<html>
+<head>
+<title>{block "title"}Here come the title{/block}</title>
+
+<style type="text/css">
+
+body {
+ background-color: #fff;
+ margin: 40px;
+ font-family: Lucida Grande, Verdana, Sans-serif;
+ font-size: 14px;
+ color: #4F5155;
+}
+
+a {
+ color: #003399;
+ background-color: transparent;
+ font-weight: normal;
+}
+
+h1 {
+ color: #444;
+ background-color: transparent;
+ border-bottom: 1px solid #D0D0D0;
+ font-size: 16px;
+ font-weight: bold;
+ margin: 24px 0 2px 0;
+ padding: 5px 0 6px 0;
+}
+
+code {
+ font-family: Monaco, Verdana, Sans-serif;
+ font-size: 12px;
+ background-color: #f9f9f9;
+ border: 1px solid #D0D0D0;
+ color: #002166;
+ display: block;
+ margin: 14px 0 14px 0;
+ padding: 12px 10px 12px 10px;
+}
+
+pre {
+ font-family: Monaco, Verdana, Sans-serif;
+ font-size: 12px;
+ background-color: #f9f9f9;
+ border: 1px solid #D0D0D0;
+ color: #B9BAA4;
+ display: block;
+ margin: 14px 0 14px 0;
+ padding: 12px 10px 12px 10px;
+}
+</style>
+</head>
+<body>
+{block "content"}Here comes the content{/block}
+</body>
+</html>
Index: /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/ZendFramework/Dwoo.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/ZendFramework/Dwoo.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/ZendFramework/Dwoo.php	(revision 755)
@@ -0,0 +1,39 @@
+<?php
+
+/**
+ * Dwoo base class for ZendFramework
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the
+ * use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @author     Marc Hodgins <mjh@hodginsmedia.com>
+ * @copyright  Copyright (c) 2010, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.2.0
+ * @date       2010-02-28
+ * @package    Dwoo
+ */
+class Dwoo_Adapters_ZendFramework_Dwoo extends Dwoo_Core
+{
+	/**
+	 * Redirects all unknown properties to plugin proxy
+	 * to support $this->viewVariable from within templates
+	 *
+	 * @param string $name Property name
+	 * @return mixed
+	 */
+	public function __get($name)
+	{
+		if (isset($this->getPluginProxy()->view->$name)) {
+			return $this->getPluginProxy()->view->$name;
+		}
+		$trace = debug_backtrace();
+		trigger_error('Undefined property via __get(): ' . $name .
+					  ' in ' . $trace[0]['file'] .
+					  ' on line ' . $trace[0]['line'], E_USER_NOTICE);
+		return null;
+	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/ZendFramework/PluginProxy.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/ZendFramework/PluginProxy.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/ZendFramework/PluginProxy.php	(revision 755)
@@ -0,0 +1,96 @@
+<?php
+
+/**
+ * PluginProxy class for Zend View
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the
+ * use of this software.
+ *
+ * @author	   Denis Arh <denis@arh.cc>
+ * @author	   Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Denis Arh, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+class Dwoo_Adapters_ZendFramework_PluginProxy implements Dwoo_IPluginProxy
+{
+	/**
+	 * reference to the zend view owning this proxy
+	 *
+	 * @var Zend_View_Interface
+	 */
+	public $view;
+
+	/**
+	 * Dwoo_Adapters_ZendFramework_PluginProxy's constructor.
+	 *
+	 * @param Zend_View_Interface $view
+	 */
+	public function __construct(Zend_View_Interface $view) {
+		$this->view = $view;
+	}
+
+	/**
+	 * Called from Dwoo_Compiler to check if the requested plugin is available
+	 *
+	 * @param string $name
+	 * @return bool
+	 */
+	public function handles($name) {
+		try {
+			$this->view->getHelper($name);
+		} catch (Zend_Loader_PluginLoader_Exception $e) {
+			return false;
+		}
+
+		return true;
+	}
+
+	/**
+	 * returns the code (as a string) to call the plugin
+	 * (this will be executed at runtime inside the Dwoo class)
+	 *
+	 * @param string $name the plugin name
+	 * @param array $params a parameter array, array key "*" is the rest array
+	 * @return string
+	 */
+	public function getCode($name, $params) {
+		return '$this->getPluginProxy()->view->'. $name .'('.Dwoo_Compiler::implode_r($params).')';
+	}
+
+	/**
+	 * returns a callback to the plugin, this is used with the reflection API to
+	 * find out about the plugin's parameter names etc.
+	 *
+	 * should you need a rest array (i.e. for ZendFramework helpers) without the
+	 * possibility to edit the plugin's code, you can provide a callback to some
+	 * other function with the correct parameter signature, i.e. :
+	 * <code>
+	 * return array($this, "callbackHelper");
+	 * // and callbackHelper would be as such:
+	 * public function callbackHelper(array $rest=array()){}
+	 * </code>
+	 *
+	 * @param string $name the plugin name
+	 * @return callback
+	 */
+	public function getCallback($name) {
+		return array($this->view->getHelper($name), $name);
+	}
+
+	/**
+	 * returns some code that will check if the plugin is loaded and if not load it
+	 * this is optional, if your plugins are autoloaded or whatever, just return an
+	 * empty string
+	 *
+	 * @param string $name the plugin name
+	 * @return string
+	 */
+	public function getLoader($name) {
+		return '';
+	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/ZendFramework/README
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/ZendFramework/README	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/ZendFramework/README	(revision 755)
@@ -0,0 +1,34 @@
+// ------------------------
+// Usage example :
+// ------------------------
+// Note that you might need to manually include 'lib/Dwoo.php',
+// 'lib/Dwoo/Adapters/ZendFramework/View.php',
+// 'lib/Dwoo/Adapters/ZendFramework/Dwoo.php', and
+// 'lib/Dwoo/Adapters/ZendFramework/PluginProxy.php' for this to
+// work as expected, depending on your ZF setup
+//
+// If anyone writes a more advanced how-to please let me know
+// ------------------------
+
+$view = new Dwoo_Adapters_ZendFramework_View(array(
+       'compileDir' => 'path/to/compile_dir' // set to null or remove this line to use defaults
+       'cacheDir'   => 'path/to/cache_dir' // set to null or remove this line to use defaults
+));
+
+// This allows you to use ZF's helpers as if they were Dwoo plugins (i.e. {doctype} will call the doctype helper)
+// This also allows you to use $this->variable to access view variables from within templates
+
+$view->setPluginProxy(new Dwoo_Adapters_ZendFramework_PluginProxy(new Zend_View()));
+
+
+// 1. example - used with the Zend Controller
+
+$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer($view);
+
+Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
+
+
+// 2. example - used manually
+
+$view->assign('foo', 'bar');
+$view->display('foobar.phtml');
Index: /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/ZendFramework/View.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/ZendFramework/View.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Adapters/ZendFramework/View.php	(revision 755)
@@ -0,0 +1,501 @@
+<?php
+
+/**
+ * Dwoo adapter for ZendFramework
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the
+ * use of this software.
+ *
+ * @author	   Denis Arh <denis@arh.cc>
+ * @author     Stephan Wentz <stephan@wentz.it>
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.1.0
+ * @date       2009-07-18
+ * @package    Dwoo
+ */
+class Dwoo_Adapters_ZendFramework_View extends Zend_View_Abstract
+{
+	/**
+	 * @var Dwoo
+	 */
+	protected $_engine = null;
+
+	/**
+	 * @var Dwoo_Data
+	 */
+	protected $_dataProvider = null;
+
+	/**
+	 * @var Dwoo_Compiler
+	 */
+	protected $_compiler = null;
+
+	/**
+	 * Changing Filter's scope to play nicely
+	 *
+	 * @var array
+	 */
+	protected $_filter = array();
+
+
+	/**
+	 * @var string
+	 */
+	protected $_templateFileClass = 'Dwoo_Template_File';
+
+	/**
+	 * @var array
+	 */
+	protected $_templateFileSettings = array();
+
+	/**
+	 * @var Dwoo_IPluginProxy
+	 */
+	protected $_pluginProxy = null;
+
+	/**
+	 * Constructor method.
+	 * See setOptions for $opt details
+	 *
+	 * @see setOptions
+	 * @param array|Zend_Config List of options or Zend_Config instance
+	 */
+	public function __construct($opt = array())
+	{
+
+		if (is_array($opt)) {
+			$this->setOptions($opt);
+		} elseif ($opt instanceof Zend_Config) {
+			$this->setConfig($opt);
+		}
+
+		$this->init();
+	}
+
+	/**
+	 * Set object state from options array
+	 *  - engine        = engine class name|engine object|array of options for engine
+	 *  - dataProvider  = data provider class name|data provider object|array of options for data provider
+	 *  - compiler      = compiler class name|compiler object|array of options for compiler
+	 *  - templateFile  =
+	 *
+	 *  Array of options:
+	 *  - type class name or object for engine, dataProvider or compiler
+	 *  - any set* method (compileDir for setCompileDir ...)
+	 *
+	 * @param  array $options
+	 * @return Dwoo_Adapters_ZendFramework_View
+	 */
+	public function setOptions(array $opt = array())
+	{
+		// Making sure that everything is loaded.
+		$classes = array('engine', 'dataProvider', 'compiler');
+
+		// Setting options to Dwoo objects...
+		foreach ($opt as $type => $settings) {
+			if (!method_exists($this, 'set' . $type)) {
+				throw new Dwoo_Exception("Unknown type $type");
+			}
+
+			if (is_string($settings) || is_object($settings)) {
+				call_user_func(array($this, 'set' . $type), $settings);
+			} elseif (is_array($settings)) {
+				// Set requested class
+				if (array_key_exists('type', $settings)) {
+					call_user_func(array($this, 'set' . $type), $settings['type']);
+				}
+
+				if (in_array($type, $classes)) {
+					// Call get so that the class is initialized
+					$rel = call_user_func(array($this, 'get' . $type));
+
+					// Call set*() methods so that all the settings are set.
+					foreach ($settings as $method => $value) {
+						if (method_exists($rel, 'set' . $method)) {
+							call_user_func(array($rel, 'set' . $method), $value);
+						}
+					}
+				} elseif ('templateFile' == $type) {
+					// Remember the settings for the templateFile
+					$this->_templateFileSettings = $settings;
+				}
+			}
+		}
+	}
+
+	/**
+	 * Set object state from Zend_Config object
+	 *
+	 * @param  Zend_Config $config
+	 * @return Dwoo_Adapters_ZendFramework_View
+	 */
+	public function setConfig(Zend_Config $config)
+	{
+		return $this->setOptions($config->toArray());
+	}
+
+	/**
+	 * Called before template rendering
+	 *
+	 * Binds plugin proxy to the Dwoo.
+	 *
+	 * @see Dwoo_Adapters_ZendFramework_View::getPluginProxy();
+	 * @see Dwoo_Core::setPluginProxy();
+	 */
+	protected function preRender()
+	{
+		$this->getEngine()->setPluginProxy($this->getPluginProxy());
+	}
+
+	/**
+	 * Wraper for Dwoo_Data::__set()
+	 * allows to assign variables using the object syntax
+	 *
+	 * @see Dwoo_Data::__set()
+	 * @param string $name the variable name
+	 * @param string $value the value to assign to it
+	 */
+	public function __set($name, $value)
+	{
+		$this->getDataProvider()->__set($name, $value);
+	}
+
+	/**
+	 * Sraper for Dwoo_Data::__get() allows to read variables using the object
+	 * syntax
+	 *
+	 * @see Dwoo_Data::__get()
+	 * @param string $name the variable name
+	 * @return mixed
+	 */
+	public function __get($name)
+	{
+		 return $this->getDataProvider()->__get($name);
+	}
+
+	/**
+	 * Wraper for Dwoo_Data::__isset()
+	 * supports calls to isset($dwooData->var)
+	 *
+	 * @see Dwoo_Data::__isset()
+	 * @param string $name the variable name
+	 */
+	public function __isset($name)
+	{
+		return $this->getDataProvider()->__isset($name);
+	}
+
+	/**
+	 * Wraper for Dwoo_Data::_unset()
+	 * supports unsetting variables using the object syntax
+	 *
+	 * @see Dwoo_Data::__unset()
+	 * @param string $name the variable name
+	 */
+	public function __unset($name)
+	{
+		$this->getDataProvider()->__unset($name);
+	}
+
+	/**
+	 * Catches clone request and clones data provider
+	 */
+	public function __clone() {
+		$this->setDataProvider(clone $this->getDataProvider());
+	}
+
+	/**
+	 * Returns plugin proxy interface
+	 *
+	 * @return Dwoo_IPluginProxy
+	 */
+	public function getPluginProxy()
+	{
+		if (!$this->_pluginProxy) {
+			$this->_pluginProxy = new Dwoo_Adapters_ZendFramework_PluginProxy($this);
+		}
+
+		return $this->_pluginProxy;
+	}
+
+	/**
+	 * Sets plugin proxy
+	 *
+	 * @param Dwoo_IPluginProxy
+	 * @return Dwoo_Adapters_ZendFramework_View
+	 */
+	public function setPluginProxy(Dwoo_IPluginProxy $pluginProxy)
+	{
+		$this->_pluginProxy = $pluginProxy;
+		return $this;
+	}
+
+	/**
+	 * Sets template engine
+	 *
+	 * @param string|Dwoo Object or name of the class
+	 */
+	public function setEngine($engine)
+	{
+		// if param given as an object
+		if ($engine instanceof Dwoo) {
+			$this->_engine = $engine;
+		}
+		//
+		elseif (is_subclass_of($engine, 'Dwoo') || 'Dwoo' === $engine) {
+			$this->_engine = new $engine();
+		}
+		else {
+			throw new Dwoo_Exception("Custom engine must be a subclass of Dwoo");
+		}
+	}
+
+	/**
+	 * Return the Dwoo template engine object
+	 *
+	 * @return Dwoo
+	 */
+	public function getEngine()
+	{
+		if (null === $this->_engine) {
+			$this->_engine = new Dwoo_Adapters_ZendFramework_Dwoo();
+		}
+
+		return $this->_engine;
+	}
+
+	/**
+	 * Sets Dwoo data object
+	 *
+	 * @param string|Dwoo_Data Object or name of the class
+	 */
+	public function setDataProvider($data)
+	{
+		if ($data instanceof Dwoo_IDataProvider) {
+			$this->_dataProvider = $data;
+		}
+		elseif (is_subclass_of($data, 'Dwoo_Data') || 'Dwoo_Data' == $data) {
+			$this->_dataProvider = new $data();
+		}
+		else {
+			throw new Dwoo_Exception("Custom data provider must be a subclass of Dwoo_Data or instance of Dwoo_IDataProvider");
+		}
+	}
+
+	/**
+	 * Return the Dwoo data object
+	 *
+	 * @return Dwoo_Data
+	 */
+	public function getDataProvider()
+	{
+		if (null === $this->_dataProvider) {
+			$this->_dataProvider = new Dwoo_Data;
+		}
+
+		return $this->_dataProvider;
+	}
+
+
+	/**
+	 * Sets Dwoo compiler
+	 *
+	 * @param string|Dwoo_Compiler Object or name of the class
+	 */
+	public function setCompiler($compiler)
+	{
+
+		// if param given as an object
+		if ($compiler instanceof Dwoo_ICompiler) {
+			$this->_compiler = $compiler;
+		}
+		// if param given as a string
+		elseif (is_subclass_of($compiler, 'Dwoo_Compiler') || 'Dwoo_Compiler' == $compiler) {
+			$this->_compiler = new $compiler;
+		}
+		else {
+			throw new Dwoo_Exception("Custom compiler must be a subclass of Dwoo_Compiler or instance of Dwoo_ICompiler");
+		}
+	}
+
+	/**
+	 * Return the Dwoo compiler object
+	 *
+	 * @return Dwoo_Data
+	 */
+	public function getCompiler()
+	{
+		if (null === $this->_compiler) {
+			$this->_compiler = Dwoo_Compiler::compilerFactory();
+		}
+
+		return $this->_compiler;
+	}
+
+	/**
+	 * Initializes Dwoo_ITemplate type of class and sets properties from _templateFileSettings
+	 *
+	 * @param  string Template location
+	 * @return Dwoo_ITemplate
+	 */
+	public function getTemplateFile($template) {
+		$templateFileClass = $this->_templateFileClass;
+
+		$dwooTemplateFile = new $templateFileClass($template);
+
+		if (!($dwooTemplateFile instanceof Dwoo_ITemplate)) {
+			throw new Dwoo_Exception("Custom templateFile class must be a subclass of Dwoo_ITemplate");
+		}
+
+		foreach ($this->_templateFileSettings as $method => $value) {
+			if (method_exists($dwooTemplateFile, 'set' . $method)) {
+				call_user_func(array($dwooTemplateFile, 'set' . $method), $value);
+			}
+		}
+
+		return $dwooTemplateFile;
+	}
+
+	/**
+	 * Dwoo_ITemplate type of class
+	 *
+	 * @param string Name of the class
+	 * @return void
+	 */
+	public function setTemplateFile($tempateFileClass) {
+		$this->_templateFileClass = $tempateFileClass;
+	}
+
+	/**
+	 * Passes data to Dwoo_Data object
+	 *
+	 * @see Dwoo_Data::assign()
+	 * @param array|string $name
+	 * @param mixed $val
+	 * @return Dwoo_Adapters_ZendFramework_View
+	 */
+	public function assign($name, $val = null)
+	{
+		$this->getDataProvider()->assign($name, $val);
+		return $this;
+	}
+
+	/**
+	 * Return list of all assigned variables
+	 *
+	 * @return array
+	 */
+	public function getVars()
+	{
+		return $this->getDataProvider()->getData();
+	}
+
+	/**
+	 * Clear all assigned variables
+	 *
+	 * Clears all variables assigned to Zend_View either via {@link assign()} or
+	 * property overloading ({@link __get()}/{@link __set()}).
+	 *
+	 * @return void
+	 * @return Dwoo_Adapters_ZendFramework_View
+	 */
+	public function clearVars()
+	{
+		$this->getDataProvider()->clear();
+		return $this;
+	}
+
+	/**
+	 * Wraper for parent's render method so preRender method
+	 * can be called (that will bind the plugin proxy to the
+	 * engine.
+	 *
+	 * @see Zend_View_Abstract::render
+	 * @return string The script output.
+	 */
+	public function render($name)
+	{
+		$this->preRender();
+		return parent::render($name);
+	}
+
+	/**
+	 * Processes a view script and outputs it. Output is then
+	 * passed through filters.
+	 *
+	 * @param string $name The script script name to process.
+	 * @return string The script output.
+	 */
+	public function _run()
+	{
+		echo $this->_engine->get(
+			$this->getTemplateFile(func_get_arg(0)),
+			$this->getDataProvider(),
+			$this->getCompiler()
+		);
+	}
+
+	/**
+	 * Add plugin path
+	 *
+	 * @param string $dir Directory
+	 * @return Dwoo_Adapters_ZendFramework_View
+	 */
+	public function addPluginDir($dir)
+	{
+		$this->getEngine()->getLoader()->addDirectory($dir);
+		return $this;
+	}
+
+	/**
+	 * Set compile path
+	 *
+	 * @param string $dir Directory
+	 * @return Dwoo_Adapters_ZendFramework_View
+	 */
+	public function setCompileDir($dir)
+	{
+		$this->getEngine()->setCompileDir($dir);
+		return $this;
+	}
+
+	/**
+	 * Set cache path
+	 *
+	 * @param string $dir Directory
+	 * @return Dwoo_Adapters_ZendFramework_View
+	 */
+	public function setCacheDir($dir)
+	{
+		$this->getEngine()->setCacheDir($dir);
+		return $this;
+	}
+
+	/**
+	 * Set cache lifetime
+	 *
+	 * @param string $seconds Lifetime in seconds
+	 * @return Dwoo_Adapters_ZendFramework_View
+	 */
+	public function setCacheLifetime($seconds)
+	{
+		$this->getEngine()->setCacheTime($seconds);
+		return $this;
+	}
+
+	/**
+	 * Set charset
+	 *
+	 * @param string $charset
+	 * @return Dwoo_Adapters_ZendFramework_View
+	 */
+	public function setCharset($charset)
+	{
+		$this->_engine->setCharset($charset);
+		return $this;
+	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Block/Plugin.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Block/Plugin.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Block/Plugin.php	(revision 755)
@@ -0,0 +1,103 @@
+<?php
+
+/**
+ * base class for block plugins
+ *
+ * you have to implement the <em>init()</em> method, it will receive the parameters that
+ * are in the template code and is called when the block starts
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+abstract class Dwoo_Block_Plugin extends Dwoo_Plugin
+{
+	/**
+	 * stores the contents of the block while it runs
+	 *
+	 * @var string
+	 */
+	protected $buffer = '';
+
+	/**
+	 * buffers input, override only if necessary
+	 *
+	 * @var string $input the content that must be buffered
+	 */
+	public function buffer($input)
+	{
+		$this->buffer .= $input;
+	}
+
+	// initialization code, receives the parameters from {block param1 param2}
+	// public function init($arg, $arg, ...);
+
+	/**
+	 * called when the block ends, this is most of the time followed right away by a call
+	 * of <em>process()</em> but not always, so this should be used to do any shutdown operations on the
+	 * block object, if required.
+	 */
+	public function end()
+	{
+	}
+
+	/**
+	 * called when the block output is required by a parent block
+	 *
+	 * this must read $this->buffer and return it processed
+	 *
+	 * @return string
+	 */
+	public function process()
+	{
+		return $this->buffer;
+	}
+
+	/**
+	 * called at compile time to define what the block should output in the compiled template code, happens when the block is declared
+	 *
+	 * basically this will replace the {block arg arg arg} tag in the template
+	 *
+	 * @param Dwoo_Compiler $compiler the compiler instance that calls this function
+	 * @param array $params an array containing original and compiled parameters
+	 * @param string $prepend that is just meant to allow a child class to call
+	 * 						  parent::postProcessing($compiler, $params, "foo();") to add a command before the
+	 * 						  default commands are executed
+	 * @param string $append that is just meant to allow a child class to call
+	 * 						 parent::postProcessing($compiler, $params, null, "foo();") to add a command after the
+	 * 						 default commands are executed
+	 * @param string $type the type is the plugin class name used
+	 */
+	public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type)
+	{
+		return Dwoo_Compiler::PHP_OPEN.$prepend.'$this->addStack("'.$type.'", array('.Dwoo_Compiler::implode_r($compiler->getCompiledParams($params)).'));'.$append.Dwoo_Compiler::PHP_CLOSE;
+	}
+
+	/**
+	 * called at compile time to define what the block should output in the compiled template code, happens when the block is ended
+	 *
+	 * basically this will replace the {/block} tag in the template
+	 *
+	 * @see preProcessing
+	 * @param Dwoo_Compiler $compiler the compiler instance that calls this function
+	 * @param array $params an array containing original and compiled parameters, see preProcessing() for more details
+	 * @param string $prepend that is just meant to allow a child class to call
+	 * 						  parent::postProcessing($compiler, $params, "foo();") to add a command before the
+	 * 						  default commands are executed
+	 * @param string $append that is just meant to allow a child class to call
+	 * 						 parent::postProcessing($compiler, $params, null, "foo();") to add a command after the
+	 * 						 default commands are executed
+	 * @param string $content the entire content of the block being closed
+	 */
+	public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content)
+	{
+		return $content . Dwoo_Compiler::PHP_OPEN.$prepend.'$this->delStack();'.$append.Dwoo_Compiler::PHP_CLOSE;
+	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Compilation/Exception.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Compilation/Exception.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Compilation/Exception.php	(revision 755)
@@ -0,0 +1,38 @@
+<?php
+
+/**
+ * dwoo compilation exception class
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+class Dwoo_Compilation_Exception extends Dwoo_Exception
+{
+	protected $compiler;
+	protected $template;
+
+	public function __construct(Dwoo_Compiler $compiler, $message)
+	{
+		$this->compiler = $compiler;
+		$this->template = $compiler->getDwoo()->getTemplate();
+		parent::__construct('Compilation error at line '.$compiler->getLine().' in "'.$this->template->getResourceName().':'.$this->template->getResourceIdentifier().'" : '.$message);
+	}
+
+	public function getCompiler()
+	{
+		return $this->compiler;
+	}
+
+	public function getTemplate()
+	{
+		return $this->template;
+	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Compiler.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Compiler.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Compiler.php	(revision 755)
@@ -0,0 +1,3154 @@
+<?php
+
+include dirname(__FILE__) . '/Compilation/Exception.php';
+
+/**
+ * default dwoo compiler class, compiles dwoo templates into php
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.1.0
+ * @date       2009-07-18
+ * @package    Dwoo
+ */
+class Dwoo_Compiler implements Dwoo_ICompiler
+{
+	/**
+	 * constant that represents a php opening tag
+	 *
+	 * use it in case it needs to be adjusted
+	 *
+	 * @var string
+	 */
+	const PHP_OPEN = "<?php ";
+
+	/**
+	 * constant that represents a php closing tag
+	 *
+	 * use it in case it needs to be adjusted
+	 *
+	 * @var string
+	 */
+	const PHP_CLOSE = "?>";
+
+	/**
+	 * boolean flag to enable or disable debugging output
+	 *
+	 * @var bool
+	 */
+	public $debug = false;
+
+	/**
+	 * left script delimiter
+	 *
+	 * @var string
+	 */
+	protected $ld = '{';
+
+	/**
+	 * left script delimiter with escaped regex meta characters
+	 *
+	 * @var string
+	 */
+	protected $ldr = '\\{';
+
+	/**
+	 * right script delimiter
+	 *
+	 * @var string
+	 */
+	protected $rd = '}';
+
+	/**
+	 * right script delimiter with escaped regex meta characters
+	 *
+	 * @var string
+	 */
+	protected $rdr = '\\}';
+
+	/**
+	 * defines whether the nested comments should be parsed as nested or not
+	 *
+	 * defaults to false (classic block comment parsing as in all languages)
+	 *
+	 * @var bool
+	 */
+	protected $allowNestedComments = false;
+
+	/**
+	 * defines whether opening and closing tags can contain spaces before valid data or not
+	 *
+	 * turn to true if you want to be sloppy with the syntax, but when set to false it allows
+	 * to skip javascript and css tags as long as they are in the form "{ something", which is
+	 * nice. default is false.
+	 *
+	 * @var bool
+	 */
+	protected $allowLooseOpenings = false;
+
+	/**
+	 * defines whether the compiler will automatically html-escape variables or not
+	 *
+	 * default is false
+	 *
+	 * @var bool
+	 */
+	protected $autoEscape = false;
+
+	/**
+	 * security policy object
+	 *
+	 * @var Dwoo_Security_Policy
+	 */
+	protected $securityPolicy;
+
+	/**
+	 * stores the custom plugins registered with this compiler
+	 *
+	 * @var array
+	 */
+	protected $customPlugins = array();
+
+	/**
+	 * stores the template plugins registered with this compiler
+	 *
+	 * @var array
+	 */
+	protected $templatePlugins = array();
+
+	/**
+	 * stores the pre- and post-processors callbacks
+	 *
+	 * @var array
+	 */
+	protected $processors = array('pre'=>array(), 'post'=>array());
+
+	/**
+	 * stores a list of plugins that are used in the currently compiled
+	 * template, and that are not compilable. these plugins will be loaded
+	 * during the template's runtime if required.
+	 *
+	 * it is a 1D array formatted as key:pluginName value:pluginType
+	 *
+	 * @var array
+	 */
+	protected $usedPlugins;
+
+	/**
+	 * stores the template undergoing compilation
+	 *
+	 * @var string
+	 */
+	protected $template;
+
+	/**
+	 * stores the current pointer position inside the template
+	 *
+	 * @var int
+	 */
+	protected $pointer;
+
+	/**
+	 * stores the current line count inside the template for debugging purposes
+	 *
+	 * @var int
+	 */
+	protected $line;
+
+	/**
+	 * stores the current template source while compiling it
+	 *
+	 * @var string
+	 */
+	protected $templateSource;
+
+	/**
+	 * stores the data within which the scope moves
+	 *
+	 * @var array
+	 */
+	protected $data;
+
+	/**
+	 * variable scope of the compiler, set to null if
+	 * it can not be resolved to a static string (i.e. if some
+	 * plugin defines a new scope based on a variable array key)
+	 *
+	 * @var mixed
+	 */
+	protected $scope;
+
+	/**
+	 * variable scope tree, that allows to rebuild the current
+	 * scope if required, i.e. when going to a parent level
+	 *
+	 * @var array
+	 */
+	protected $scopeTree;
+
+	/**
+	 * block plugins stack, accessible through some methods
+	 *
+	 * @see findBlock
+	 * @see getCurrentBlock
+	 * @see addBlock
+	 * @see addCustomBlock
+	 * @see injectBlock
+	 * @see removeBlock
+	 * @see removeTopBlock
+	 *
+	 * @var array
+	 */
+	protected $stack = array();
+
+	/**
+	 * current block at the top of the block plugins stack,
+	 * accessible through getCurrentBlock
+	 *
+	 * @see getCurrentBlock
+	 *
+	 * @var Dwoo_Block_Plugin
+	 */
+	protected $curBlock;
+
+	/**
+	 * current dwoo object that uses this compiler, or null
+	 *
+	 * @var Dwoo
+	 */
+	protected $dwoo;
+
+	/**
+	 * holds an instance of this class, used by getInstance when you don't
+	 * provide a custom compiler in order to save resources
+	 *
+	 * @var Dwoo_Compiler
+	 */
+	protected static $instance;
+
+	/**
+	 * token types
+	 * @var int
+	 */
+	const T_UNQUOTED_STRING = 1;
+	const T_NUMERIC = 2;
+	const T_NULL = 4;
+	const T_BOOL = 8;
+	const T_MATH = 16;
+	const T_BREAKCHAR = 32;
+
+	/**
+	 * constructor
+	 *
+	 * saves the created instance so that child templates get the same one
+	 */
+	public function __construct()
+	{
+		self::$instance = $this;
+	}
+
+	/**
+	 * sets the delimiters to use in the templates
+	 *
+	 * delimiters can be multi-character strings but should not be one of those as they will
+	 * make it very hard to work with templates or might even break the compiler entirely : "\", "$", "|", ":" and finally "#" only if you intend to use config-vars with the #var# syntax.
+	 *
+	 * @param string $left left delimiter
+	 * @param string $right right delimiter
+	 */
+	public function setDelimiters($left, $right)
+	{
+		$this->ld = $left;
+		$this->rd = $right;
+		$this->ldr = preg_quote($left, '/');
+		$this->rdr = preg_quote($right, '/');
+	}
+
+	/**
+	 * returns the left and right template delimiters
+	 *
+	 * @return array containing the left and the right delimiters
+	 */
+	public function getDelimiters()
+	{
+		return array($this->ld, $this->rd);
+	}
+
+	/**
+	 * sets the way to handle nested comments, if set to true
+	 * {* foo {* some other *} comment *} will be stripped correctly.
+	 *
+	 * if false it will remove {* foo {* some other *} and leave "comment *}" alone,
+	 * this is the default behavior
+	 *
+	 * @param bool $allow allow nested comments or not, defaults to true (but the default internal value is false)
+	 */
+	public function setNestedCommentsHandling($allow = true) {
+		$this->allowNestedComments = (bool) $allow;
+	}
+
+	/**
+	 * returns the nested comments handling setting
+	 *
+	 * @see setNestedCommentsHandling
+	 * @return bool true if nested comments are allowed
+	 */
+	public function getNestedCommentsHandling() {
+		return $this->allowNestedComments;
+	}
+
+	/**
+	 * sets the tag openings handling strictness, if set to true, template tags can
+	 * contain spaces before the first function/string/variable such as { $foo} is valid.
+	 *
+	 * if set to false (default setting), { $foo} is invalid but that is however a good thing
+	 * as it allows css (i.e. #foo { color:red; }) to be parsed silently without triggering
+	 * an error, same goes for javascript.
+	 *
+	 * @param bool $allow true to allow loose handling, false to restore default setting
+	 */
+	public function setLooseOpeningHandling($allow = false)
+	{
+		$this->allowLooseOpenings = (bool) $allow;
+	}
+
+	/**
+	 * returns the tag openings handling strictness setting
+	 *
+	 * @see setLooseOpeningHandling
+	 * @return bool true if loose tags are allowed
+	 */
+	public function getLooseOpeningHandling()
+	{
+		return $this->allowLooseOpenings;
+	}
+
+	/**
+	 * changes the auto escape setting
+	 *
+	 * if enabled, the compiler will automatically html-escape variables,
+	 * unless they are passed through the safe function such as {$var|safe}
+	 * or {safe $var}
+	 *
+	 * default setting is disabled/false
+	 *
+	 * @param bool $enabled set to true to enable, false to disable
+	 */
+	public function setAutoEscape($enabled)
+	{
+		$this->autoEscape = (bool) $enabled;
+	}
+
+	/**
+	 * returns the auto escape setting
+	 *
+	 * default setting is disabled/false
+	 *
+	 * @return bool
+	 */
+	public function getAutoEscape()
+	{
+		return $this->autoEscape;
+	}
+
+	/**
+	 * adds a preprocessor to the compiler, it will be called
+	 * before the template is compiled
+	 *
+	 * @param mixed $callback either a valid callback to the preprocessor or a simple name if the autoload is set to true
+	 * @param bool $autoload if set to true, the preprocessor is auto-loaded from one of the plugin directories, else you must provide a valid callback
+	 */
+	public function addPreProcessor($callback, $autoload = false)
+	{
+		if ($autoload) {
+			$name = str_replace('Dwoo_Processor_', '', $callback);
+			$class = 'Dwoo_Processor_'.$name;
+
+			if (class_exists($class, false)) {
+				$callback = array(new $class($this), 'process');
+			} elseif (function_exists($class)) {
+				$callback = $class;
+			} else {
+				$callback = array('autoload'=>true, 'class'=>$class, 'name'=>$name);
+			}
+
+			$this->processors['pre'][] = $callback;
+		} else {
+			$this->processors['pre'][] = $callback;
+		}
+	}
+
+	/**
+	 * removes a preprocessor from the compiler
+	 *
+	 * @param mixed $callback either a valid callback to the preprocessor or a simple name if it was autoloaded
+	 */
+	public function removePreProcessor($callback)
+	{
+		if (($index = array_search($callback, $this->processors['pre'], true)) !== false) {
+			unset($this->processors['pre'][$index]);
+		} elseif (($index = array_search('Dwoo_Processor_'.str_replace('Dwoo_Processor_', '', $callback), $this->processors['pre'], true)) !== false) {
+			unset($this->processors['pre'][$index]);
+		} else {
+			$class = 'Dwoo_Processor_' . str_replace('Dwoo_Processor_', '', $callback);
+			foreach ($this->processors['pre'] as $index=>$proc) {
+				if (is_array($proc) && ($proc[0] instanceof $class) || (isset($proc['class']) && $proc['class'] == $class)) {
+					unset($this->processors['pre'][$index]);
+					break;
+				}
+			}
+		}
+	}
+
+	/**
+	 * adds a postprocessor to the compiler, it will be called
+	 * before the template is compiled
+	 *
+	 * @param mixed $callback either a valid callback to the postprocessor or a simple name if the autoload is set to true
+	 * @param bool $autoload if set to true, the postprocessor is auto-loaded from one of the plugin directories, else you must provide a valid callback
+	 */
+	public function addPostProcessor($callback, $autoload = false)
+	{
+		if ($autoload) {
+			$name = str_replace('Dwoo_Processor_', '', $callback);
+			$class = 'Dwoo_Processor_'.$name;
+
+			if (class_exists($class, false)) {
+				$callback = array(new $class($this), 'process');
+			} elseif (function_exists($class)) {
+				$callback = $class;
+			} else {
+				$callback = array('autoload'=>true, 'class'=>$class, 'name'=>$name);
+			}
+
+			$this->processors['post'][] = $callback;
+		} else {
+			$this->processors['post'][] = $callback;
+		}
+	}
+
+	/**
+	 * removes a postprocessor from the compiler
+	 *
+	 * @param mixed $callback either a valid callback to the postprocessor or a simple name if it was autoloaded
+	 */
+	public function removePostProcessor($callback)
+	{
+		if (($index = array_search($callback, $this->processors['post'], true)) !== false) {
+			unset($this->processors['post'][$index]);
+		} elseif (($index = array_search('Dwoo_Processor_'.str_replace('Dwoo_Processor_', '', $callback), $this->processors['post'], true)) !== false) {
+			unset($this->processors['post'][$index]);
+		} else	{
+			$class = 'Dwoo_Processor_' . str_replace('Dwoo_Processor_', '', $callback);
+			foreach ($this->processors['post'] as $index=>$proc) {
+				if (is_array($proc) && ($proc[0] instanceof $class) || (isset($proc['class']) && $proc['class'] == $class)) {
+					unset($this->processors['post'][$index]);
+					break;
+				}
+			}
+		}
+	}
+
+	/**
+	 * internal function to autoload processors at runtime if required
+	 *
+	 * @param string $class the class/function name
+	 * @param string $name the plugin name (without Dwoo_Plugin_ prefix)
+	 */
+	protected function loadProcessor($class, $name)
+	{
+		if (!class_exists($class, false) && !function_exists($class)) {
+			try {
+				$this->dwoo->getLoader()->loadPlugin($name);
+			} catch (Dwoo_Exception $e) {
+				throw new Dwoo_Exception('Processor '.$name.' could not be found in your plugin directories, please ensure it is in a file named '.$name.'.php in the plugin directory');
+			}
+		}
+
+		if (class_exists($class, false)) {
+			return array(new $class($this), 'process');
+		}
+
+		if (function_exists($class)) {
+			return $class;
+		}
+
+		throw new Dwoo_Exception('Wrong processor name, when using autoload the processor must be in one of your plugin dir as "name.php" containg a class or function named "Dwoo_Processor_name"');
+	}
+
+	/**
+	 * adds an used plugin, this is reserved for use by the {template} plugin
+	 *
+	 * this is required so that plugin loading bubbles up from loaded
+	 * template files to the current one
+	 *
+	 * @private
+	 * @param string $name function name
+	 * @param int $type plugin type (Dwoo_Core::*_PLUGIN)
+	 */
+	public function addUsedPlugin($name, $type)
+	{
+		$this->usedPlugins[$name] = $type;
+	}
+
+	/**
+	 * returns all the plugins this template uses
+	 *
+	 * @private
+	 * @return array the list of used plugins in the parsed template
+	 */
+	public function getUsedPlugins()
+	{
+		return $this->usedPlugins;
+	}
+
+	/**
+	 * adds a template plugin, this is reserved for use by the {template} plugin
+	 *
+	 * this is required because the template functions are not declared yet
+	 * during compilation, so we must have a way of validating their argument
+	 * signature without using the reflection api
+	 *
+	 * @private
+	 * @param string $name function name
+	 * @param array $params parameter array to help validate the function call
+	 * @param string $uuid unique id of the function
+	 * @param string $body function php code
+	 */
+	public function addTemplatePlugin($name, array $params, $uuid, $body = null)
+	{
+		$this->templatePlugins[$name] = array('params'=> $params, 'body' => $body, 'uuid' => $uuid);
+	}
+
+	/**
+	 * returns all the parsed sub-templates
+	 *
+	 * @private
+	 * @return array the parsed sub-templates
+	 */
+	public function getTemplatePlugins()
+	{
+		return $this->templatePlugins;
+	}
+
+	/**
+	 * marks a template plugin as being called, which means its source must be included in the compiled template
+	 *
+	 * @param string $name function name
+	 */
+	public function useTemplatePlugin($name)
+	{
+		$this->templatePlugins[$name]['called'] = true;
+	}
+
+	/**
+	 * adds the custom plugins loaded into Dwoo to the compiler so it can load them
+	 *
+	 * @see Dwoo_Core::addPlugin
+	 * @param array $customPlugins an array of custom plugins
+	 */
+	public function setCustomPlugins(array $customPlugins)
+	{
+		$this->customPlugins = $customPlugins;
+	}
+
+	/**
+	 * sets the security policy object to enforce some php security settings
+	 *
+	 * use this if untrusted persons can modify templates,
+	 * set it on the Dwoo object as it will be passed onto the compiler automatically
+	 *
+	 * @param Dwoo_Security_Policy $policy the security policy object
+	 */
+	public function setSecurityPolicy(Dwoo_Security_Policy $policy = null)
+	{
+		$this->securityPolicy = $policy;
+	}
+
+	/**
+	 * returns the current security policy object or null by default
+	 *
+	 * @return Dwoo_Security_Policy|null the security policy object if any
+	 */
+	public function getSecurityPolicy()
+	{
+		return $this->securityPolicy;
+	}
+
+	/**
+	 * sets the pointer position
+	 *
+	 * @param int $position the new pointer position
+	 * @param bool $isOffset if set to true, the position acts as an offset and not an absolute position
+	 */
+	public function setPointer($position, $isOffset = false)
+	{
+		if ($isOffset) {
+			$this->pointer += $position;
+		} else {
+			$this->pointer = $position;
+		}
+	}
+
+	/**
+	 * returns the current pointer position, only available during compilation of a template
+	 *
+	 * @return int
+	 */
+	public function getPointer()
+	{
+		return $this->pointer;
+	}
+
+	/**
+	 * sets the line number
+	 *
+	 * @param int $number the new line number
+	 * @param bool $isOffset if set to true, the position acts as an offset and not an absolute position
+	 */
+	public function setLine($number, $isOffset = false)
+	{
+		if ($isOffset) {
+			$this->line += $number;
+		} else {
+			$this->line = $number;
+		}
+	}
+
+	/**
+	 * returns the current line number, only available during compilation of a template
+	 *
+	 * @return int
+	 */
+	public function getLine()
+	{
+		return $this->line;
+	}
+
+	/**
+	 * returns the dwoo object that initiated this template compilation, only available during compilation of a template
+	 *
+	 * @return Dwoo
+	 */
+	public function getDwoo()
+	{
+		return $this->dwoo;
+	}
+
+	/**
+	 * overwrites the template that is being compiled
+	 *
+	 * @param string $newSource the template source that must replace the current one
+	 * @param bool $fromPointer if set to true, only the source from the current pointer position is replaced
+	 * @return string the template or partial template
+	 */
+	public function setTemplateSource($newSource, $fromPointer = false)
+	{
+		if ($fromPointer === true) {
+			$this->templateSource = substr($this->templateSource, 0, $this->pointer) . $newSource;
+		} else {
+			$this->templateSource = $newSource;
+		}
+	}
+
+	/**
+	 * returns the template that is being compiled
+	 *
+	 * @param mixed $fromPointer if set to true, only the source from the current pointer
+	 * 							  position is returned, if a number is given it overrides the current pointer
+	 * @return string the template or partial template
+	 */
+	public function getTemplateSource($fromPointer = false)
+	{
+		if ($fromPointer === true) {
+			return substr($this->templateSource, $this->pointer);
+		} elseif (is_numeric($fromPointer)) {
+			return substr($this->templateSource, $fromPointer);
+		} else {
+			return $this->templateSource;
+		}
+	}
+
+	/**
+	 * resets the compilation pointer, effectively restarting the compilation process
+	 *
+	 * this is useful if a plugin modifies the template source since it might need to be recompiled
+	 */
+	public function recompile()
+	{
+		$this->setPointer(0);
+	}
+
+	/**
+	 * compiles the provided string down to php code
+	 *
+	 * @param string $tpl the template to compile
+	 * @return string a compiled php string
+	 */
+	public function compile(Dwoo_Core $dwoo, Dwoo_ITemplate $template)
+	{
+		// init vars
+		$tpl = $template->getSource();
+		$ptr = 0;
+		$this->dwoo = $dwoo;
+		$this->template = $template;
+		$this->templateSource =& $tpl;
+		$this->pointer =& $ptr;
+
+		while (true) {
+			// if pointer is at the beginning, reset everything, that allows a plugin to externally reset the compiler if everything must be reparsed
+			if ($ptr===0) {
+				// resets variables
+				$this->usedPlugins = array();
+				$this->data = array();
+				$this->scope =& $this->data;
+				$this->scopeTree = array();
+				$this->stack = array();
+				$this->line = 1;
+				$this->templatePlugins = array();
+				// add top level block
+				$compiled = $this->addBlock('topLevelBlock', array(), 0);
+				$this->stack[0]['buffer'] = '';
+
+				if ($this->debug) echo 'COMPILER INIT<br />';
+
+				if ($this->debug) echo 'PROCESSING PREPROCESSORS ('.count($this->processors['pre']).')<br>';
+
+				// runs preprocessors
+				foreach ($this->processors['pre'] as $preProc) {
+					if (is_array($preProc) && isset($preProc['autoload'])) {
+						$preProc = $this->loadProcessor($preProc['class'], $preProc['name']);
+					}
+					if (is_array($preProc) && $preProc[0] instanceof Dwoo_Processor) {
+						$tpl = call_user_func($preProc, $tpl);
+					} else {
+						$tpl = call_user_func($preProc, $this, $tpl);
+					}
+				}
+				unset($preProc);
+
+				// show template source if debug
+				if ($this->debug) echo '<pre>'.print_r(htmlentities($tpl), true).'</pre><hr />';
+
+				// strips php tags if required by the security policy
+				if ($this->securityPolicy !== null) {
+					$search = array('{<\?php.*?\?>}');
+					if (ini_get('short_open_tags')) {
+						$search = array('{<\?.*?\?>}', '{<%.*?%>}');
+					}
+					switch($this->securityPolicy->getPhpHandling()) {
+
+					case Dwoo_Security_Policy::PHP_ALLOW:
+						break;
+					case Dwoo_Security_Policy::PHP_ENCODE:
+						$tpl = preg_replace_callback($search, array($this, 'phpTagEncodingHelper'), $tpl);
+						break;
+					case Dwoo_Security_Policy::PHP_REMOVE:
+						$tpl = preg_replace($search, '', $tpl);
+
+					}
+				}
+			}
+
+			$pos = strpos($tpl, $this->ld, $ptr);
+
+			if ($pos === false) {
+				$this->push(substr($tpl, $ptr), 0);
+				break;
+			} elseif (substr($tpl, $pos-1, 1) === '\\' && substr($tpl, $pos-2, 1) !== '\\') {
+				$this->push(substr($tpl, $ptr, $pos-$ptr-1) . $this->ld);
+				$ptr = $pos+strlen($this->ld);
+			} elseif (preg_match('/^'.$this->ldr . ($this->allowLooseOpenings ? '\s*' : '') . 'literal' . ($this->allowLooseOpenings ? '\s*' : '') . $this->rdr.'/s', substr($tpl, $pos), $litOpen)) {
+				if (!preg_match('/'.$this->ldr . ($this->allowLooseOpenings ? '\s*' : '') . '\/literal' . ($this->allowLooseOpenings ? '\s*' : '') . $this->rdr.'/s', $tpl, $litClose, PREG_OFFSET_CAPTURE, $pos)) {
+					throw new Dwoo_Compilation_Exception($this, 'The {literal} blocks must be closed explicitly with {/literal}');
+				}
+				$endpos = $litClose[0][1];
+				$this->push(substr($tpl, $ptr, $pos-$ptr) . substr($tpl, $pos + strlen($litOpen[0]), $endpos-$pos-strlen($litOpen[0])));
+				$ptr = $endpos+strlen($litClose[0][0]);
+			} else {
+				if (substr($tpl, $pos-2, 1) === '\\' && substr($tpl, $pos-1, 1) === '\\') {
+					$this->push(substr($tpl, $ptr, $pos-$ptr-1));
+					$ptr = $pos;
+				}
+
+				$this->push(substr($tpl, $ptr, $pos-$ptr));
+				$ptr = $pos;
+
+				$pos += strlen($this->ld);
+				if ($this->allowLooseOpenings) {
+					while (substr($tpl, $pos, 1) === ' ') {
+						$pos+=1;
+					}
+				} else {
+					if (substr($tpl, $pos, 1) === ' ' || substr($tpl, $pos, 1) === "\r" || substr($tpl, $pos, 1) === "\n" || substr($tpl, $pos, 1) === "\t") {
+						$ptr = $pos;
+						$this->push($this->ld);
+						continue;
+					}
+				}
+
+				// check that there is an end tag present
+				if (strpos($tpl, $this->rd, $pos) === false) {
+					throw new Dwoo_Compilation_Exception($this, 'A template tag was not closed, started with "'.substr($tpl, $ptr, 30).'"');
+				}
+
+
+				$ptr += strlen($this->ld);
+				$subptr = $ptr;
+
+				while (true) {
+					$parsed = $this->parse($tpl, $subptr, null, false, 'root', $subptr);
+
+					// reload loop if the compiler was reset
+					if ($ptr === 0) {
+						continue 2;
+					}
+
+					$len = $subptr - $ptr;
+					$this->push($parsed, substr_count(substr($tpl, $ptr, $len), "\n"));
+					$ptr += $len;
+
+					if ($parsed === false) {
+						break;
+					}
+				}
+
+				// adds additional line breaks between php closing and opening tags because the php parser removes those if there is just a single line break
+				if (substr($this->curBlock['buffer'], -2) === '?>' && preg_match('{^(([\r\n])([\r\n]?))}', substr($tpl, $ptr, 3), $m)) {
+					if ($m[3] === '') {
+						$ptr+=1;
+						$this->push($m[1].$m[1], 1);
+					} else {
+						$ptr+=2;
+						$this->push($m[1]."\n", 2);
+					}
+				}
+			}
+		}
+
+		$compiled .= $this->removeBlock('topLevelBlock');
+
+		if ($this->debug) echo 'PROCESSING POSTPROCESSORS<br>';
+
+		foreach ($this->processors['post'] as $postProc) {
+			if (is_array($postProc) && isset($postProc['autoload'])) {
+				$postProc = $this->loadProcessor($postProc['class'], $postProc['name']);
+			}
+			if (is_array($postProc) && $postProc[0] instanceof Dwoo_Processor) {
+				$compiled = call_user_func($postProc, $compiled);
+			} else {
+				$compiled = call_user_func($postProc, $this, $compiled);
+			}
+		}
+		unset($postProc);
+
+		if ($this->debug) echo 'COMPILATION COMPLETE : MEM USAGE : '.memory_get_usage().'<br>';
+
+		$output = "<?php\n/* template head */\n";
+
+		// build plugin preloader
+		foreach ($this->usedPlugins as $plugin=>$type) {
+			if ($type & Dwoo_Core::CUSTOM_PLUGIN) {
+				continue;
+			}
+
+			switch($type) {
+
+			case Dwoo_Core::BLOCK_PLUGIN:
+			case Dwoo_Core::CLASS_PLUGIN:
+				$output .= "if (class_exists('Dwoo_Plugin_$plugin', false)===false)\n\t\$this->getLoader()->loadPlugin('$plugin');\n";
+				break;
+			case Dwoo_Core::FUNC_PLUGIN:
+				$output .= "if (function_exists('Dwoo_Plugin_$plugin')===false)\n\t\$this->getLoader()->loadPlugin('$plugin');\n";
+				break;
+			case Dwoo_Core::SMARTY_MODIFIER:
+				$output .= "if (function_exists('smarty_modifier_$plugin')===false)\n\t\$this->getLoader()->loadPlugin('$plugin');\n";
+				break;
+			case Dwoo_Core::SMARTY_FUNCTION:
+				$output .= "if (function_exists('smarty_function_$plugin')===false)\n\t\$this->getLoader()->loadPlugin('$plugin');\n";
+				break;
+			case Dwoo_Core::SMARTY_BLOCK:
+				$output .= "if (function_exists('smarty_block_$plugin')===false)\n\t\$this->getLoader()->loadPlugin('$plugin');\n";
+				break;
+			case Dwoo_Core::PROXY_PLUGIN:
+				$output .= $this->getDwoo()->getPluginProxy()->getPreloader($plugin);
+				break;
+			default:
+				throw new Dwoo_Compilation_Exception($this, 'Type error for '.$plugin.' with type'.$type);
+
+			}
+		}
+
+		foreach ($this->templatePlugins as $function => $attr) {
+			if (isset($attr['called']) && $attr['called'] === true && !isset($attr['checked'])) {
+				$this->resolveSubTemplateDependencies($function);
+			}
+		}
+		foreach ($this->templatePlugins as $function) {
+			if (isset($function['called']) && $function['called'] === true) {
+				$output .= $function['body'].PHP_EOL;
+			}
+		}
+
+		$output .= $compiled."\n?>";
+
+		$output = preg_replace('/(?<!;|\}|\*\/|\n|\{)(\s*'.preg_quote(self::PHP_CLOSE, '/') . preg_quote(self::PHP_OPEN, '/').')/', ";\n", $output);
+		$output = str_replace(self::PHP_CLOSE . self::PHP_OPEN, "\n", $output);
+
+		// handle <?xml tag at the beginning
+		$output = preg_replace('#(/\* template body \*/ \?>\s*)<\?xml#is', '$1<?php echo \'<?xml\'; ?>', $output);
+
+		if ($this->debug) {
+			echo '<hr><pre>';
+			$lines = preg_split('{\r\n|\n|<br />}', highlight_string(($output), true));
+			array_shift($lines);
+			foreach ($lines as $i=>$line) {
+				echo ($i+1).'. '.$line."\r\n";
+			}
+		}
+		if ($this->debug) echo '<hr></pre></pre>';
+
+		$this->template = $this->dwoo = null;
+		$tpl = null;
+
+		return $output;
+	}
+
+	/**
+	 * checks what sub-templates are used in every sub-template so that we're sure they are all compiled
+	 *
+	 * @param string $function the sub-template name
+	 */
+	protected function resolveSubTemplateDependencies($function)
+	{
+		$body = $this->templatePlugins[$function]['body'];
+		foreach ($this->templatePlugins as $func => $attr) {
+			if ($func !== $function && !isset($attr['called']) && strpos($body, 'Dwoo_Plugin_'.$func) !== false) {
+				$this->templatePlugins[$func]['called'] = true;
+				$this->resolveSubTemplateDependencies($func);
+			}
+		}
+		$this->templatePlugins[$function]['checked'] = true;
+	}
+
+	/**
+	 * adds compiled content to the current block
+	 *
+	 * @param string $content the content to push
+	 * @param int $lineCount newlines count in content, optional
+	 */
+	public function push($content, $lineCount = null)
+	{
+		if ($lineCount === null) {
+			$lineCount = substr_count($content, "\n");
+		}
+
+		if ($this->curBlock['buffer'] === null && count($this->stack) > 1) {
+			// buffer is not initialized yet (the block has just been created)
+			$this->stack[count($this->stack)-2]['buffer'] .= (string) $content;
+			$this->curBlock['buffer'] = '';
+		} else {
+			if (!isset($this->curBlock['buffer'])) {
+				throw new Dwoo_Compilation_Exception($this, 'The template has been closed too early, you probably have an extra block-closing tag somewhere');
+			}
+			// append current content to current block's buffer
+			$this->curBlock['buffer'] .= (string) $content;
+		}
+		$this->line += $lineCount;
+	}
+
+	/**
+	 * sets the scope
+	 *
+	 * set to null if the scope becomes "unstable" (i.e. too variable or unknown) so that
+	 * variables are compiled in a more evaluative way than just $this->scope['key']
+	 *
+	 * @param mixed $scope a string i.e. "level1.level2" or an array i.e. array("level1", "level2")
+	 * @param bool $absolute if true, the scope is set from the top level scope and not from the current scope
+	 * @return array the current scope tree
+	 */
+	public function setScope($scope, $absolute = false)
+	{
+		$old = $this->scopeTree;
+
+		if ($scope===null) {
+			unset($this->scope);
+			$this->scope = null;
+		}
+
+		if (is_array($scope)===false) {
+			$scope = explode('.', $scope);
+		}
+
+		if ($absolute===true) {
+			$this->scope =& $this->data;
+			$this->scopeTree = array();
+		}
+
+		while (($bit = array_shift($scope)) !== null) {
+			if ($bit === '_parent' || $bit === '_') {
+				array_pop($this->scopeTree);
+				reset($this->scopeTree);
+				$this->scope =& $this->data;
+				$cnt = count($this->scopeTree);
+				for ($i=0;$i<$cnt;$i++)
+					$this->scope =& $this->scope[$this->scopeTree[$i]];
+			} elseif ($bit === '_root' || $bit === '__') {
+				$this->scope =& $this->data;
+				$this->scopeTree = array();
+			} elseif (isset($this->scope[$bit])) {
+				$this->scope =& $this->scope[$bit];
+				$this->scopeTree[] = $bit;
+			} else {
+				$this->scope[$bit] = array();
+				$this->scope =& $this->scope[$bit];
+				$this->scopeTree[] = $bit;
+			}
+		}
+
+		return $old;
+	}
+
+	/**
+	 * adds a block to the top of the block stack
+	 *
+	 * @param string $type block type (name)
+	 * @param array $params the parameters array
+	 * @param int $paramtype the parameters type (see mapParams), 0, 1 or 2
+	 * @return string the preProcessing() method's output
+	 */
+	public function addBlock($type, array $params, $paramtype)
+	{
+		$class = 'Dwoo_Plugin_'.$type;
+		if (class_exists($class, false) === false) {
+			$this->dwoo->getLoader()->loadPlugin($type);
+		}
+
+		$params = $this->mapParams($params, array($class, 'init'), $paramtype);
+
+		$this->stack[] = array('type' => $type, 'params' => $params, 'custom' => false, 'class' => $class, 'buffer' => null);
+		$this->curBlock =& $this->stack[count($this->stack)-1];
+		return call_user_func(array($class,'preProcessing'), $this, $params, '', '', $type);
+	}
+
+	/**
+	 * adds a custom block to the top of the block stack
+	 *
+	 * @param string $type block type (name)
+	 * @param array $params the parameters array
+	 * @param int $paramtype the parameters type (see mapParams), 0, 1 or 2
+	 * @return string the preProcessing() method's output
+	 */
+	public function addCustomBlock($type, array $params, $paramtype)
+	{
+		$callback = $this->customPlugins[$type]['callback'];
+		if (is_array($callback)) {
+			$class = is_object($callback[0]) ? get_class($callback[0]) : $callback[0];
+		} else {
+			$class = $callback;
+		}
+
+		$params = $this->mapParams($params, array($class, 'init'), $paramtype);
+
+		$this->stack[] = array('type' => $type, 'params' => $params, 'custom' => true, 'class' => $class, 'buffer' => null);
+		$this->curBlock =& $this->stack[count($this->stack)-1];
+		return call_user_func(array($class,'preProcessing'), $this, $params, '', '', $type);
+	}
+
+	/**
+	 * injects a block at the top of the plugin stack without calling its preProcessing method
+	 *
+	 * used by {else} blocks to re-add themselves after having closed everything up to their parent
+	 *
+	 * @param string $type block type (name)
+	 * @param array $params parameters array
+	 */
+	public function injectBlock($type, array $params)
+	{
+		$class = 'Dwoo_Plugin_'.$type;
+		if (class_exists($class, false) === false) {
+			$this->dwoo->getLoader()->loadPlugin($type);
+		}
+		$this->stack[] = array('type' => $type, 'params' => $params, 'custom' => false, 'class' => $class, 'buffer' => null);
+		$this->curBlock =& $this->stack[count($this->stack)-1];
+	}
+
+	/**
+	 * removes the closest-to-top block of the given type and all other
+	 * blocks encountered while going down the block stack
+	 *
+	 * @param string $type block type (name)
+	 * @return string the output of all postProcessing() method's return values of the closed blocks
+	 */
+	public function removeBlock($type)
+	{
+		$output = '';
+
+		$pluginType = $this->getPluginType($type);
+		if ($pluginType & Dwoo_Core::SMARTY_BLOCK) {
+			$type = 'smartyinterface';
+		}
+		while (true) {
+			while ($top = array_pop($this->stack)) {
+				if ($top['custom']) {
+					$class = $top['class'];
+				} else {
+					$class = 'Dwoo_Plugin_'.$top['type'];
+				}
+				if (count($this->stack)) {
+					$this->curBlock =& $this->stack[count($this->stack)-1];
+					$this->push(call_user_func(array($class, 'postProcessing'), $this, $top['params'], '', '', $top['buffer']), 0);
+				} else {
+					$null = null;
+					$this->curBlock =& $null;
+					$output = call_user_func(array($class, 'postProcessing'), $this, $top['params'], '', '', $top['buffer']);
+				}
+
+				if ($top['type'] === $type) {
+					break 2;
+				}
+			}
+
+			throw new Dwoo_Compilation_Exception($this, 'Syntax malformation, a block of type "'.$type.'" was closed but was not opened');
+			break;
+		}
+
+		return $output;
+	}
+
+	/**
+	 * returns a reference to the first block of the given type encountered and
+	 * optionally closes all blocks until it finds it
+	 *
+	 * this is mainly used by {else} plugins to close everything that was opened
+	 * between their parent and themselves
+	 *
+	 * @param string $type the block type (name)
+	 * @param bool $closeAlong whether to close all blocks encountered while going down the block stack or not
+	 * @return &array the array is as such: array('type'=>pluginName, 'params'=>parameter array,
+	 * 				  'custom'=>bool defining whether it's a custom plugin or not, for internal use)
+	 */
+	public function &findBlock($type, $closeAlong = false)
+	{
+		if ($closeAlong===true) {
+			while ($b = end($this->stack)) {
+				if ($b['type']===$type) {
+					return $this->stack[key($this->stack)];
+				}
+				$this->push($this->removeTopBlock(), 0);
+			}
+		} else {
+			end($this->stack);
+			while ($b = current($this->stack)) {
+				if ($b['type']===$type) {
+					return $this->stack[key($this->stack)];
+				}
+				prev($this->stack);
+			}
+		}
+
+		throw new Dwoo_Compilation_Exception($this, 'A parent block of type "'.$type.'" is required and can not be found');
+	}
+
+	/**
+	 * returns a reference to the current block array
+	 *
+	 * @return &array the array is as such: array('type'=>pluginName, 'params'=>parameter array,
+	 * 				  'custom'=>bool defining whether it's a custom plugin or not, for internal use)
+	 */
+	public function &getCurrentBlock()
+	{
+		return $this->curBlock;
+	}
+
+	/**
+	 * removes the block at the top of the stack and calls its postProcessing() method
+	 *
+	 * @return string the postProcessing() method's output
+	 */
+	public function removeTopBlock()
+	{
+		$o = array_pop($this->stack);
+		if ($o === null) {
+			throw new Dwoo_Compilation_Exception($this, 'Syntax malformation, a block of unknown type was closed but was not opened.');
+		}
+		if ($o['custom']) {
+			$class = $o['class'];
+		} else {
+			$class = 'Dwoo_Plugin_'.$o['type'];
+		}
+
+		$this->curBlock =& $this->stack[count($this->stack)-1];
+
+		return call_user_func(array($class, 'postProcessing'), $this, $o['params'], '', '', $o['buffer']);
+	}
+
+	/**
+	 * returns the compiled parameters (for example a variable's compiled parameter will be "$this->scope['key']") out of the given parameter array
+	 *
+	 * @param array $params parameter array
+	 * @return array filtered parameters
+	 */
+	public function getCompiledParams(array $params)
+	{
+		foreach ($params as $k=>$p) {
+			if (is_array($p)) {
+				$params[$k] = $p[0];
+			}
+		}
+		return $params;
+	}
+
+	/**
+	 * returns the real parameters (for example a variable's real parameter will be its key, etc) out of the given parameter array
+	 *
+	 * @param array $params parameter array
+	 * @return array filtered parameters
+	 */
+	public function getRealParams(array $params)
+	{
+		foreach ($params as $k=>$p) {
+			if (is_array($p)) {
+				$params[$k] = $p[1];
+			}
+		}
+		return $params;
+	}
+
+	/**
+	 * returns the token of each parameter out of the given parameter array
+	 *
+	 * @param array $params parameter array
+	 * @return array tokens
+	 */
+	public function getParamTokens(array $params)
+	{
+		foreach ($params as $k=>$p) {
+			if (is_array($p)) {
+				$params[$k] = isset($p[2]) ? $p[2] : 0;
+			}
+		}
+		return $params;
+	}
+
+	/**
+	 * entry point of the parser, it redirects calls to other parse* functions
+	 *
+	 * @param string $in the string within which we must parse something
+	 * @param int $from the starting offset of the parsed area
+	 * @param int $to the ending offset of the parsed area
+	 * @param mixed $parsingParams must be an array if we are parsing a function or modifier's parameters, or false by default
+	 * @param string $curBlock the current parser-block being processed
+	 * @param mixed $pointer a reference to a pointer that will be increased by the amount of characters parsed, or null by default
+	 * @return string parsed values
+	 */
+	protected function parse($in, $from, $to, $parsingParams = false, $curBlock='', &$pointer = null)
+	{
+		if ($to === null) {
+			$to = strlen($in);
+		}
+		$first = substr($in, $from, 1);
+
+		if ($first === false) {
+			throw new Dwoo_Compilation_Exception($this, 'Unexpected EOF, a template tag was not closed');
+		}
+
+		while ($first===" " || $first==="\n" || $first==="\t" || $first==="\r") {
+			if ($curBlock === 'root' && substr($in, $from, strlen($this->rd)) === $this->rd) {
+				// end template tag
+				$pointer += strlen($this->rd);
+				if ($this->debug) echo 'TEMPLATE PARSING ENDED<br />';
+				return false;
+			}
+			$from++;
+			if ($pointer !== null) {
+				$pointer++;
+			}
+			if ($from >= $to) {
+				if (is_array($parsingParams)) {
+					return $parsingParams;
+				} else {
+					return '';
+				}
+			}
+			$first = $in[$from];
+		}
+
+		$substr = substr($in, $from, $to-$from);
+
+		if ($this->debug) echo '<br />PARSE CALL : PARSING "<b>'.htmlentities(substr($in, $from, min($to-$from, 50))).(($to-$from) > 50 ? '...':'').'</b>" @ '.$from.':'.$to.' in '.$curBlock.' : pointer='.$pointer.'<br/>';
+		$parsed = "";
+
+		if ($curBlock === 'root' && $first === '*') {
+			$src = $this->getTemplateSource();
+			$startpos = $this->getPointer() - strlen($this->ld);
+			if (substr($src, $startpos, strlen($this->ld)) === $this->ld) {
+				if ($startpos > 0) {
+					do {
+						$char = substr($src, --$startpos, 1);
+						if ($char == "\n") {
+							$startpos++;
+							$whitespaceStart = true;
+							break;
+						}
+					} while ($startpos > 0 && ($char == ' ' || $char == "\t"));
+				}
+
+				if (!isset($whitespaceStart)) {
+					$startpos = $this->getPointer();
+				} else {
+					$pointer -= $this->getPointer() - $startpos;
+				}
+
+				if ($this->allowNestedComments && strpos($src, $this->ld.'*', $this->getPointer()) !== false) {
+					$comOpen = $this->ld.'*';
+					$comClose = '*'.$this->rd;
+					$level = 1;
+					$start = $startpos;
+					$ptr = $this->getPointer() + '*';
+
+					while ($level > 0 && $ptr < strlen($src)) {
+						$open = strpos($src, $comOpen, $ptr);
+						$close = strpos($src, $comClose, $ptr);
+
+						if ($open !== false && $close !== false) {
+							if ($open < $close) {
+								$ptr = $open + strlen($comOpen);
+								$level++;
+							} else {
+								$ptr = $close + strlen($comClose);
+								$level--;
+							}
+						} elseif ($open !== false) {
+							$ptr = $open + strlen($comOpen);
+							$level++;
+						} elseif ($close !== false) {
+							$ptr = $close + strlen($comClose);
+							$level--;
+						} else {
+							$ptr = strlen($src);
+						}
+					}
+					$endpos = $ptr - strlen('*'.$this->rd);
+				} else {
+					$endpos = strpos($src, '*'.$this->rd, $startpos);
+					if ($endpos == false) {
+						throw new Dwoo_Compilation_Exception($this, 'Un-ended comment');
+					}
+				}
+				$pointer += $endpos - $startpos + strlen('*'.$this->rd);
+				if (isset($whitespaceStart) && preg_match('#^[\t ]*\r?\n#', substr($src, $endpos+strlen('*'.$this->rd)), $m)) {
+					$pointer += strlen($m[0]);
+					$this->curBlock['buffer'] = substr($this->curBlock['buffer'], 0, strlen($this->curBlock['buffer']) - ($this->getPointer() - $startpos - strlen($this->ld)));
+				}
+				return false;
+			}
+		}
+
+		if ($first==='$') {
+			// var
+			$out = $this->parseVar($in, $from, $to, $parsingParams, $curBlock, $pointer);
+			$parsed = 'var';
+		} elseif ($first==='%' && preg_match('#^%[a-z_]#i', $substr)) {
+			// const
+			$out = $this->parseConst($in, $from, $to, $parsingParams, $curBlock, $pointer);
+		} elseif (($first==='"' || $first==="'") && !(is_array($parsingParams) && preg_match('#^([\'"])[a-z0-9_]+\1\s*=>?(?:\s+|[^=])#i', $substr))) {
+			// string
+			$out = $this->parseString($in, $from, $to, $parsingParams, $curBlock, $pointer);
+		} elseif (preg_match('/^\\\\?[a-z_](?:\\\\?[a-z0-9_]+)*(?:::[a-z_][a-z0-9_]*)?('.(is_array($parsingParams)||$curBlock!='root'?'':'\s+[^(]|').'\s*\(|\s*'.$this->rdr.'|\s*;)/i', $substr)) {
+			// func
+			$out = $this->parseFunction($in, $from, $to, $parsingParams, $curBlock, $pointer);
+			$parsed = 'func';
+		} elseif ($first === ';') {
+			// instruction end
+			if ($this->debug) echo 'END OF INSTRUCTION<br />';
+			if ($pointer !== null) {
+				$pointer++;
+			}
+			return $this->parse($in, $from+1, $to, false, 'root', $pointer);
+		} elseif ($curBlock === 'root' && preg_match('#^/([a-z_][a-z0-9_]*)?#i', $substr, $match)) {
+			// close block
+			if (!empty($match[1]) && $match[1] == 'else') {
+				throw new Dwoo_Compilation_Exception($this, 'Else blocks must not be closed explicitly, they are automatically closed when their parent block is closed');
+			}
+			if (!empty($match[1]) && $match[1] == 'elseif') {
+				throw new Dwoo_Compilation_Exception($this, 'Elseif blocks must not be closed explicitly, they are automatically closed when their parent block is closed or a new else/elseif block is declared after them');
+			}
+			if ($pointer !== null) {
+				$pointer += strlen($match[0]);
+			}
+			if (empty($match[1])) {
+				if ($this->curBlock['type'] == 'else' || $this->curBlock['type'] == 'elseif') {
+					$pointer -= strlen($match[0]);
+				}
+				if ($this->debug) echo 'TOP BLOCK CLOSED<br />';
+				return $this->removeTopBlock();
+			} else {
+				if ($this->debug) echo 'BLOCK OF TYPE '.$match[1].' CLOSED<br />';
+				return $this->removeBlock($match[1]);
+			}
+		} elseif ($curBlock === 'root' && substr($substr, 0, strlen($this->rd)) === $this->rd) {
+			// end template tag
+			if ($this->debug) echo 'TAG PARSING ENDED<br />';
+			$pointer += strlen($this->rd);
+			return false;
+		} elseif (is_array($parsingParams) && preg_match('#^(([\'"]?)[a-z0-9_]+\2\s*='.($curBlock === 'array' ? '>?':'').')(?:\s+|[^=]).*#i', $substr, $match)) {
+			// named parameter
+			if ($this->debug) echo 'NAMED PARAM FOUND<br />';
+			$len = strlen($match[1]);
+			while (substr($in, $from+$len, 1)===' ') {
+				$len++;
+			}
+			if ($pointer !== null) {
+				$pointer += $len;
+			}
+
+			$output = array(trim($match[1], " \t\r\n=>'\""), $this->parse($in, $from+$len, $to, false, 'namedparam', $pointer));
+
+			$parsingParams[] = $output;
+			return $parsingParams;
+		} elseif (preg_match('#^(\\\\?[a-z_](?:\\\\?[a-z0-9_]+)*::\$[a-z0-9_]+)#i', $substr, $match)) {
+			// static member access
+			$parsed = 'var';
+			if (is_array($parsingParams)) {
+				$parsingParams[] = array($match[1], $match[1]);
+				$out = $parsingParams;
+			} else {
+				$out = $match[1];
+			}
+			$pointer += strlen($match[1]);
+		} elseif ($substr!=='' && (is_array($parsingParams) || $curBlock === 'namedparam' || $curBlock === 'condition' || $curBlock === 'expression')) {
+			// unquoted string, bool or number
+			$out = $this->parseOthers($in, $from, $to, $parsingParams, $curBlock, $pointer);
+		} else {
+			// parse error
+			throw new Dwoo_Compilation_Exception($this, 'Parse error in "'.substr($in, $from, $to-$from).'"');
+		}
+
+		if (empty($out)) {
+			return '';
+		}
+
+		$substr = substr($in, $pointer, $to-$pointer);
+
+		// var parsed, check if any var-extension applies
+		if ($parsed==='var') {
+			if (preg_match('#^\s*([/%+*-])\s*([a-z0-9]|\$)#i', $substr, $match)) {
+				if($this->debug) echo 'PARSING POST-VAR EXPRESSION '.$substr.'<br />';
+				// parse expressions
+				$pointer += strlen($match[0]) - 1;
+				if (is_array($parsingParams)) {
+					if ($match[2] == '$') {
+						$expr = $this->parseVar($in, $pointer, $to, array(), $curBlock, $pointer);
+					} else {
+						$expr = $this->parse($in, $pointer, $to, array(), 'expression', $pointer);
+					}
+					$out[count($out)-1][0] .= $match[1] . $expr[0][0];
+					$out[count($out)-1][1] .= $match[1] . $expr[0][1];
+				} else {
+					if ($match[2] == '$') {
+						$expr = $this->parseVar($in, $pointer, $to, false, $curBlock, $pointer);
+					} else {
+						$expr = $this->parse($in, $pointer, $to, false, 'expression', $pointer);
+					}
+					if (is_array($out) && is_array($expr)) {
+						$out[0] .= $match[1] . $expr[0];
+						$out[1] .= $match[1] . $expr[1];
+					} elseif (is_array($out)) {
+						$out[0] .= $match[1] . $expr;
+						$out[1] .= $match[1] . $expr;
+					} elseif (is_array($expr)) {
+						$out .= $match[1] . $expr[0];
+					} else {
+						$out .= $match[1] . $expr;
+					}
+				}
+			} else if ($curBlock === 'root' && preg_match('#^(\s*(?:[+/*%-.]=|=|\+\+|--)\s*)(.*)#s', $substr, $match)) {
+				if($this->debug) echo 'PARSING POST-VAR ASSIGNMENT '.$substr.'<br />';
+				// parse assignment
+				$value = $match[2];
+				$operator = trim($match[1]);
+				if (substr($value, 0, 1) == '=') {
+					throw new Dwoo_Compilation_Exception($this, 'Unexpected "=" in <em>'.$substr.'</em>');
+				}
+
+				if ($pointer !== null) {
+					$pointer += strlen($match[1]);
+				}
+
+				if ($operator !== '++' && $operator !== '--') {
+					$parts = array();
+					$ptr = 0;
+					$parts = $this->parse($value, 0, strlen($value), $parts, 'condition', $ptr);
+					$pointer += $ptr;
+
+					// load if plugin
+					try {
+						$this->getPluginType('if');
+					} catch (Dwoo_Exception $e) {
+						throw new Dwoo_Compilation_Exception($this, 'Assignments require the "if" plugin to be accessible');
+					}
+
+					$parts = $this->mapParams($parts, array('Dwoo_Plugin_if', 'init'), 1);
+					$tokens = $this->getParamTokens($parts);
+					$parts = $this->getCompiledParams($parts);
+
+					$value = Dwoo_Plugin_if::replaceKeywords($parts['*'], $tokens['*'], $this);
+					$echo = '';
+				} else {
+					$value = array();
+					$echo = 'echo ';
+				}
+
+				if ($this->autoEscape) {
+					$out = preg_replace('#\(is_string\(\$tmp=(.+?)\) \? htmlspecialchars\(\$tmp, ENT_QUOTES, \$this->charset\) : \$tmp\)#', '$1', $out);
+				}
+				$out = Dwoo_Compiler::PHP_OPEN. $echo . $out . $operator . implode(' ', $value) . Dwoo_Compiler::PHP_CLOSE;
+			} else if ($curBlock === 'array' && is_array($parsingParams) && preg_match('#^(\s*=>?\s*)#', $substr, $match)) {
+				// parse namedparam with var as name (only for array)
+				if ($this->debug) echo 'VARIABLE NAMED PARAM (FOR ARRAY) FOUND<br />';
+				$len = strlen($match[1]);
+				$var = $out[count($out)-1];
+				$pointer += $len;
+
+				$output = array($var[0], $this->parse($substr, $len, null, false, 'namedparam', $pointer));
+
+				$parsingParams[] = $output;
+				return $parsingParams;
+			}
+		}
+
+		if ($curBlock !== 'modifier' && ($parsed === 'func' || $parsed === 'var') && preg_match('#^\|@?[a-z0-9_]+(:.*)?#i', $substr, $match)) {
+			// parse modifier on funcs or vars
+			$srcPointer = $pointer;
+			if (is_array($parsingParams)) {
+				$tmp = $this->replaceModifiers(array(null, null, $out[count($out)-1][0], $match[0]), 'var', $pointer);
+				$out[count($out)-1][0] = $tmp;
+				$out[count($out)-1][1] .= substr($substr, $srcPointer, $srcPointer - $pointer);
+			} else {
+				$out = $this->replaceModifiers(array(null, null, $out, $match[0]), 'var', $pointer);
+			}
+		}
+
+		// func parsed, check if any func-extension applies
+		if ($parsed==='func' && preg_match('#^->[a-z0-9_]+(\s*\(.+|->[a-z_].*)?#is', $substr, $match)) {
+			// parse method call or property read
+			$ptr = 0;
+
+			if (is_array($parsingParams)) {
+				$output = $this->parseMethodCall($out[count($out)-1][1], $match[0], $curBlock, $ptr);
+
+				$out[count($out)-1][0] = $output;
+				$out[count($out)-1][1] .= substr($match[0], 0, $ptr);
+			} else {
+				$out = $this->parseMethodCall($out, $match[0], $curBlock, $ptr);
+			}
+
+			$pointer += $ptr;
+		}
+
+		if ($curBlock === 'root' && substr($out, 0, strlen(self::PHP_OPEN)) !== self::PHP_OPEN) {
+			return self::PHP_OPEN .'echo '.$out.';'. self::PHP_CLOSE;
+		} else {
+			return $out;
+		}
+	}
+
+	/**
+	 * parses a function call
+	 *
+	 * @param string $in the string within which we must parse something
+	 * @param int $from the starting offset of the parsed area
+	 * @param int $to the ending offset of the parsed area
+	 * @param mixed $parsingParams must be an array if we are parsing a function or modifier's parameters, or false by default
+	 * @param string $curBlock the current parser-block being processed
+	 * @param mixed $pointer a reference to a pointer that will be increased by the amount of characters parsed, or null by default
+	 * @return string parsed values
+	 */
+	protected function parseFunction($in, $from, $to, $parsingParams = false, $curBlock='', &$pointer = null)
+	{
+		$cmdstr = substr($in, $from, $to-$from);
+		preg_match('/^(\\\\?[a-z_](?:\\\\?[a-z0-9_]+)*(?:::[a-z_][a-z0-9_]*)?)(\s*'.$this->rdr.'|\s*;)?/i', $cmdstr, $match);
+
+		if (empty($match[1])) {
+			throw new Dwoo_Compilation_Exception($this, 'Parse error, invalid function name : '.substr($cmdstr, 0, 15));
+		}
+
+		$func = $match[1];
+
+		if (!empty($match[2])) {
+			$cmdstr = $match[1];
+		}
+
+		if ($this->debug) echo 'FUNC FOUND ('.$func.')<br />';
+
+		$paramsep = '';
+
+		if (is_array($parsingParams) || $curBlock != 'root') {
+			$paramspos = strpos($cmdstr, '(');
+			$paramsep = ')';
+		} elseif(preg_match_all('#^\s*[\\\\:a-z0-9_]+(\s*\(|\s+[^(])#i', $cmdstr, $match, PREG_OFFSET_CAPTURE)) {
+			$paramspos = $match[1][0][1];
+			$paramsep = substr($match[1][0][0], -1) === '(' ? ')':'';
+			if($paramsep === ')') {
+				$paramspos += strlen($match[1][0][0]) - 1;
+				if(substr($cmdstr, 0, 2) === 'if' || substr($cmdstr, 0, 6) === 'elseif') {
+					$paramsep = '';
+					if(strlen($match[1][0][0]) > 1) {
+						$paramspos--;
+					}
+				}
+			}
+		} else {
+			$paramspos = false;
+		}
+
+		$state = 0;
+
+		if ($paramspos === false) {
+			$params = array();
+
+			if ($curBlock !== 'root') {
+				return $this->parseOthers($in, $from, $to, $parsingParams, $curBlock, $pointer);
+			}
+		} else {
+			if ($curBlock === 'condition') {
+				// load if plugin
+				$this->getPluginType('if');
+
+				if (Dwoo_Plugin_if::replaceKeywords(array($func), array(self::T_UNQUOTED_STRING), $this) !== array($func)) {
+					return $this->parseOthers($in, $from, $to, $parsingParams, $curBlock, $pointer);
+				}
+			}
+			$whitespace = strlen(substr($cmdstr, strlen($func), $paramspos-strlen($func)));
+			$paramstr = substr($cmdstr, $paramspos+1);
+			if (substr($paramstr, -1, 1) === $paramsep) {
+				$paramstr = substr($paramstr, 0, -1);
+			}
+
+			if (strlen($paramstr)===0) {
+				$params = array();
+				$paramstr = '';
+			} else {
+				$ptr = 0;
+				$params = array();
+				if ($func === 'empty') {
+					$params = $this->parseVar($paramstr, $ptr, strlen($paramstr), $params, 'root', $ptr);
+				} else {
+					while ($ptr < strlen($paramstr)) {
+						while (true) {
+							if ($ptr >= strlen($paramstr)) {
+								break 2;
+							}
+
+							if ($func !== 'if' && $func !== 'elseif' && $paramstr[$ptr] === ')') {
+								if ($this->debug) echo 'PARAM PARSING ENDED, ")" FOUND, POINTER AT '.$ptr.'<br/>';
+								break 2;
+							} elseif ($paramstr[$ptr] === ';') {
+								$ptr++;
+								if ($this->debug) echo 'PARAM PARSING ENDED, ";" FOUND, POINTER AT '.$ptr.'<br/>';
+								break 2;
+							} elseif ($func !== 'if' && $func !== 'elseif' && $paramstr[$ptr] === '/') {
+								if ($this->debug) echo 'PARAM PARSING ENDED, "/" FOUND, POINTER AT '.$ptr.'<br/>';
+								break 2;
+							} elseif (substr($paramstr, $ptr, strlen($this->rd)) === $this->rd) {
+								if ($this->debug) echo 'PARAM PARSING ENDED, RIGHT DELIMITER FOUND, POINTER AT '.$ptr.'<br/>';
+								break 2;
+							}
+
+							if ($paramstr[$ptr] === ' ' || $paramstr[$ptr] === ',' || $paramstr[$ptr] === "\r" || $paramstr[$ptr] === "\n" || $paramstr[$ptr] === "\t") {
+								$ptr++;
+							} else {
+								break;
+							}
+						}
+
+						if ($this->debug) echo 'FUNC START PARAM PARSING WITH POINTER AT '.$ptr.'<br/>';
+
+						if ($func === 'if' || $func === 'elseif' || $func === 'tif') {
+							$params = $this->parse($paramstr, $ptr, strlen($paramstr), $params, 'condition', $ptr);
+						} elseif ($func === 'array') {
+							$params = $this->parse($paramstr, $ptr, strlen($paramstr), $params, 'array', $ptr);
+						} else {
+							$params = $this->parse($paramstr, $ptr, strlen($paramstr), $params, 'function', $ptr);
+						}
+
+						if ($this->debug) echo 'PARAM PARSED, POINTER AT '.$ptr.' ('.substr($paramstr, $ptr-1, 3).')<br/>';
+					}
+				}
+				$paramstr = substr($paramstr, 0, $ptr);
+				$state = 0;
+				foreach ($params as $k=>$p) {
+					if (is_array($p) && is_array($p[1])) {
+						$state |= 2;
+					} else {
+						if (($state & 2) && preg_match('#^(["\'])(.+?)\1$#', $p[0], $m) && $func !== 'array') {
+							$params[$k] = array($m[2], array('true', 'true'));
+						} else {
+							if ($state & 2 && $func !== 'array') {
+								throw new Dwoo_Compilation_Exception($this, 'You can not use an unnamed parameter after a named one');
+							}
+							$state |= 1;
+						}
+					}
+				}
+			}
+		}
+
+		if ($pointer !== null) {
+			$pointer += (isset($paramstr) ? strlen($paramstr) : 0) + (')' === $paramsep ? 2 : ($paramspos === false ? 0 : 1)) + strlen($func) + (isset($whitespace) ? $whitespace : 0);
+			if ($this->debug) echo 'FUNC ADDS '.((isset($paramstr) ? strlen($paramstr) : 0) + (')' === $paramsep ? 2 : ($paramspos === false ? 0 : 1)) + strlen($func)).' TO POINTER<br/>';
+		}
+
+		if ($curBlock === 'method' || $func === 'do' || strstr($func, '::') !== false) {
+			// handle static method calls with security policy
+			if (strstr($func, '::') !== false && $this->securityPolicy !== null && $this->securityPolicy->isMethodAllowed(explode('::', strtolower($func))) !== true) {
+				throw new Dwoo_Security_Exception('Call to a disallowed php function : '.$func);
+			}
+			$pluginType = Dwoo::NATIVE_PLUGIN;
+		} else {
+			$pluginType = $this->getPluginType($func);
+		}
+
+		// blocks
+		if ($pluginType & Dwoo_Core::BLOCK_PLUGIN) {
+			if ($curBlock !== 'root' || is_array($parsingParams)) {
+				throw new Dwoo_Compilation_Exception($this, 'Block plugins can not be used as other plugin\'s arguments');
+			}
+			if ($pluginType & Dwoo_Core::CUSTOM_PLUGIN) {
+				return $this->addCustomBlock($func, $params, $state);
+			} else {
+				return $this->addBlock($func, $params, $state);
+			}
+		} elseif ($pluginType & Dwoo_Core::SMARTY_BLOCK) {
+			if ($curBlock !== 'root' || is_array($parsingParams)) {
+				throw new Dwoo_Compilation_Exception($this, 'Block plugins can not be used as other plugin\'s arguments');
+			}
+
+			if ($state & 2) {
+				array_unshift($params, array('__functype', array($pluginType, $pluginType)));
+				array_unshift($params, array('__funcname', array($func, $func)));
+			} else {
+				array_unshift($params, array($pluginType, $pluginType));
+				array_unshift($params, array($func, $func));
+			}
+
+			return $this->addBlock('smartyinterface', $params, $state);
+		}
+
+		// funcs
+		if ($pluginType & Dwoo_Core::NATIVE_PLUGIN || $pluginType & Dwoo_Core::SMARTY_FUNCTION || $pluginType & Dwoo_Core::SMARTY_BLOCK) {
+			$params = $this->mapParams($params, null, $state);
+		} elseif ($pluginType & Dwoo_Core::CLASS_PLUGIN) {
+			if ($pluginType & Dwoo_Core::CUSTOM_PLUGIN) {
+				$params = $this->mapParams($params, array($this->customPlugins[$func]['class'], $this->customPlugins[$func]['function']), $state);
+			} else {
+				$params = $this->mapParams($params, array('Dwoo_Plugin_'.$func, ($pluginType & Dwoo_Core::COMPILABLE_PLUGIN) ? 'compile' : 'process'), $state);
+			}
+		} elseif ($pluginType & Dwoo_Core::FUNC_PLUGIN) {
+			if ($pluginType & Dwoo_Core::CUSTOM_PLUGIN) {
+				$params = $this->mapParams($params, $this->customPlugins[$func]['callback'], $state);
+			} else {
+				$params = $this->mapParams($params, 'Dwoo_Plugin_'.$func.(($pluginType & Dwoo_Core::COMPILABLE_PLUGIN) ? '_compile' : ''), $state);
+			}
+		} elseif ($pluginType & Dwoo_Core::SMARTY_MODIFIER) {
+			$output = 'smarty_modifier_'.$func.'('.implode(', ', $params).')';
+		} elseif ($pluginType & Dwoo_Core::PROXY_PLUGIN) {
+			$params = $this->mapParams($params, $this->getDwoo()->getPluginProxy()->getCallback($func), $state);
+		} elseif ($pluginType & Dwoo_Core::TEMPLATE_PLUGIN) {
+			// transforms the parameter array from (x=>array('paramname'=>array(values))) to (paramname=>array(values))
+			$map = array();
+			foreach ($this->templatePlugins[$func]['params'] as $param=>$defValue) {
+				if ($param == 'rest') {
+					$param = '*';
+				}
+				$hasDefault = $defValue !== null;
+				if ($defValue === 'null') {
+					$defValue = null;
+				} elseif ($defValue === 'false') {
+					$defValue = false;
+				} elseif ($defValue === 'true') {
+					$defValue = true;
+				} elseif (preg_match('#^([\'"]).*?\1$#', $defValue)) {
+					$defValue = substr($defValue, 1, -1);
+				}
+				$map[] = array($param, $hasDefault, $defValue);
+			}
+
+			$params = $this->mapParams($params, null, $state, $map);
+		}
+
+		// only keep php-syntax-safe values for non-block plugins
+		$tokens = array();
+		foreach ($params as $k => $p) {
+			$tokens[$k] = isset($p[2]) ? $p[2] : 0;
+			$params[$k] = $p[0];
+		}
+		if ($pluginType & Dwoo_Core::NATIVE_PLUGIN) {
+			if ($func === 'do') {
+				if (isset($params['*'])) {
+					$output = implode(';', $params['*']).';';
+				} else {
+					$output = '';
+				}
+
+				if (is_array($parsingParams) || $curBlock !== 'root') {
+					throw new Dwoo_Compilation_Exception($this, 'Do can not be used inside another function or block');
+				} else {
+					return self::PHP_OPEN.$output.self::PHP_CLOSE;
+				}
+			} else {
+				if (isset($params['*'])) {
+					$output = $func.'('.implode(', ', $params['*']).')';
+				} else {
+					$output = $func.'()';
+				}
+			}
+		} elseif ($pluginType & Dwoo_Core::FUNC_PLUGIN) {
+			if ($pluginType & Dwoo_Core::COMPILABLE_PLUGIN) {
+				if ($pluginType & Dwoo_Core::CUSTOM_PLUGIN) {
+					$funcCompiler = $this->customPlugins[$func]['callback'];
+				} else {
+					$funcCompiler = 'Dwoo_Plugin_'.$func.'_compile';
+				}
+				array_unshift($params, $this);
+				if ($func === 'tif') {
+					$params[] = $tokens;
+				}
+				$output = call_user_func_array($funcCompiler, $params);
+			} else {
+				array_unshift($params, '$this');
+				$params = self::implode_r($params);
+
+				if ($pluginType & Dwoo_Core::CUSTOM_PLUGIN) {
+					$callback = $this->customPlugins[$func]['callback'];
+					$output = 'call_user_func(\''.$callback.'\', '.$params.')';
+				} else {
+					$output = 'Dwoo_Plugin_'.$func.'('.$params.')';
+				}
+			}
+		} elseif ($pluginType & Dwoo_Core::CLASS_PLUGIN) {
+			if ($pluginType & Dwoo_Core::COMPILABLE_PLUGIN) {
+				if ($pluginType & Dwoo_Core::CUSTOM_PLUGIN) {
+					$callback = $this->customPlugins[$func]['callback'];
+					if (!is_array($callback)) {
+						if (!method_exists($callback, 'compile')) {
+							throw new Dwoo_Exception('Custom plugin '.$func.' must implement the "compile" method to be compilable, or you should provide a full callback to the method to use');
+						}
+						if (($ref = new ReflectionMethod($callback, 'compile')) && $ref->isStatic()) {
+							$funcCompiler = array($callback, 'compile');
+						} else {
+							$funcCompiler = array(new $callback, 'compile');
+						}
+					} else {
+						$funcCompiler = $callback;
+					}
+				} else {
+					$funcCompiler = array('Dwoo_Plugin_'.$func, 'compile');
+					array_unshift($params, $this);
+				}
+				$output = call_user_func_array($funcCompiler, $params);
+			} else {
+				$params = self::implode_r($params);
+				if ($pluginType & Dwoo_Core::CUSTOM_PLUGIN) {
+					$callback = $this->customPlugins[$func]['callback'];
+					if (!is_array($callback)) {
+						if (!method_exists($callback, 'process')) {
+							throw new Dwoo_Exception('Custom plugin '.$func.' must implement the "process" method to be usable, or you should provide a full callback to the method to use');
+						}
+						if (($ref = new ReflectionMethod($callback, 'process')) && $ref->isStatic()) {
+							$output = 'call_user_func(array(\''.$callback.'\', \'process\'), '.$params.')';
+						} else {
+							$output = 'call_user_func(array($this->getObjectPlugin(\''.$callback.'\'), \'process\'), '.$params.')';
+						}
+					} elseif (is_object($callback[0])) {
+						$output = 'call_user_func(array($this->plugins[\''.$func.'\'][\'callback\'][0], \''.$callback[1].'\'), '.$params.')';
+					} elseif (($ref = new ReflectionMethod($callback[0], $callback[1])) && $ref->isStatic()) {
+						$output = 'call_user_func(array(\''.$callback[0].'\', \''.$callback[1].'\'), '.$params.')';
+					} else {
+						$output = 'call_user_func(array($this->getObjectPlugin(\''.$callback[0].'\'), \''.$callback[1].'\'), '.$params.')';
+					}
+					if (empty($params)) {
+						$output = substr($output, 0, -3).')';
+					}
+				} else {
+					$output = '$this->classCall(\''.$func.'\', array('.$params.'))';
+				}
+			}
+		} elseif ($pluginType & Dwoo_Core::PROXY_PLUGIN) {
+			$output = call_user_func(array($this->dwoo->getPluginProxy(), 'getCode'), $func, $params);
+		} elseif ($pluginType & Dwoo_Core::SMARTY_FUNCTION) {
+			if (isset($params['*'])) {
+				$params = self::implode_r($params['*'], true);
+			} else {
+				$params = '';
+			}
+
+			if ($pluginType & Dwoo_Core::CUSTOM_PLUGIN) {
+				$callback = $this->customPlugins[$func]['callback'];
+				if (is_array($callback)) {
+					if (is_object($callback[0])) {
+						$output = 'call_user_func_array(array($this->plugins[\''.$func.'\'][\'callback\'][0], \''.$callback[1].'\'), array(array('.$params.'), $this))';
+					} else {
+						$output = 'call_user_func_array(array(\''.$callback[0].'\', \''.$callback[1].'\'), array(array('.$params.'), $this))';
+					}
+				} else {
+					$output = $callback.'(array('.$params.'), $this)';
+				}
+			} else {
+				$output = 'smarty_function_'.$func.'(array('.$params.'), $this)';
+			}
+		} elseif ($pluginType & Dwoo_Core::TEMPLATE_PLUGIN) {
+			array_unshift($params, '$this');
+			$params = self::implode_r($params);
+			$output = 'Dwoo_Plugin_'.$func.'_'.$this->templatePlugins[$func]['uuid'].'('.$params.')';
+			$this->templatePlugins[$func]['called'] = true;
+		}
+
+		if (is_array($parsingParams)) {
+			$parsingParams[] = array($output, $output);
+			return $parsingParams;
+		} elseif ($curBlock === 'namedparam') {
+			return array($output, $output);
+		} else {
+			return $output;
+		}
+	}
+
+	/**
+	 * parses a string
+	 *
+	 * @param string $in the string within which we must parse something
+	 * @param int $from the starting offset of the parsed area
+	 * @param int $to the ending offset of the parsed area
+	 * @param mixed $parsingParams must be an array if we are parsing a function or modifier's parameters, or false by default
+	 * @param string $curBlock the current parser-block being processed
+	 * @param mixed $pointer a reference to a pointer that will be increased by the amount of characters parsed, or null by default
+	 * @return string parsed values
+	 */
+	protected function parseString($in, $from, $to, $parsingParams = false, $curBlock='', &$pointer = null)
+	{
+		$substr = substr($in, $from, $to-$from);
+		$first = $substr[0];
+
+		if ($this->debug) echo 'STRING FOUND (in '.htmlentities(substr($in, $from, min($to-$from, 50))).(($to-$from) > 50 ? '...':'').')<br />';
+		$strend = false;
+		$o = $from+1;
+		while ($strend === false) {
+			$strend = strpos($in, $first, $o);
+			if ($strend === false) {
+				throw new Dwoo_Compilation_Exception($this, 'Unfinished string, started with '.substr($in, $from, $to-$from));
+			}
+			if (substr($in, $strend-1, 1) === '\\') {
+				$o = $strend+1;
+				$strend = false;
+			}
+		}
+		if ($this->debug) echo 'STRING DELIMITED: '.substr($in, $from, $strend+1-$from).'<br/>';
+
+		$srcOutput = substr($in, $from, $strend+1-$from);
+
+		if ($pointer !== null) {
+			$pointer += strlen($srcOutput);
+		}
+
+		$output = $this->replaceStringVars($srcOutput, $first);
+
+		// handle modifiers
+		if ($curBlock !== 'modifier' && preg_match('#^((?:\|(?:@?[a-z0-9_]+(?::.*)*))+)#i', substr($substr, $strend+1-$from), $match)) {
+			$modstr = $match[1];
+
+			if ($curBlock === 'root' && substr($modstr, -1) === '}') {
+				$modstr = substr($modstr, 0, -1);
+			}
+			$modstr = str_replace('\\'.$first, $first, $modstr);
+			$ptr = 0;
+			$output = $this->replaceModifiers(array(null, null, $output, $modstr), 'string', $ptr);
+
+			$strend += $ptr;
+			if ($pointer !== null) {
+				$pointer += $ptr;
+			}
+			$srcOutput .= substr($substr, $strend+1-$from, $ptr);
+		}
+
+		if (is_array($parsingParams)) {
+			$parsingParams[] = array($output, substr($srcOutput, 1, -1));
+			return $parsingParams;
+		} elseif ($curBlock === 'namedparam') {
+			return array($output, substr($srcOutput, 1, -1));
+		} else {
+			return $output;
+		}
+	}
+
+	/**
+	 * parses a constant
+	 *
+	 * @param string $in the string within which we must parse something
+	 * @param int $from the starting offset of the parsed area
+	 * @param int $to the ending offset of the parsed area
+	 * @param mixed $parsingParams must be an array if we are parsing a function or modifier's parameters, or false by default
+	 * @param string $curBlock the current parser-block being processed
+	 * @param mixed $pointer a reference to a pointer that will be increased by the amount of characters parsed, or null by default
+	 * @return string parsed values
+	 */
+	protected function parseConst($in, $from, $to, $parsingParams = false, $curBlock='', &$pointer = null)
+	{
+		$substr = substr($in, $from, $to-$from);
+
+		if ($this->debug) {
+			echo 'CONST FOUND : '.$substr.'<br />';
+		}
+
+		if (!preg_match('#^%([a-z0-9_:]+)#i', $substr, $m)) {
+			throw new Dwoo_Compilation_Exception($this, 'Invalid constant');
+		}
+
+		if ($pointer !== null) {
+			$pointer += strlen($m[0]);
+		}
+
+		$output = $this->parseConstKey($m[1], $curBlock);
+
+		if (is_array($parsingParams)) {
+			$parsingParams[] = array($output, $m[1]);
+			return $parsingParams;
+		} elseif ($curBlock === 'namedparam') {
+			return array($output, $m[1]);
+		} else {
+			return $output;
+		}
+	}
+
+	/**
+	 * parses a constant
+	 *
+	 * @param string $key the constant to parse
+	 * @param string $curBlock the current parser-block being processed
+	 * @return string parsed constant
+	 */
+	protected function parseConstKey($key, $curBlock)
+	{
+		if ($this->securityPolicy !== null && $this->securityPolicy->getConstantHandling() === Dwoo_Security_Policy::CONST_DISALLOW) {
+			return 'null';
+		}
+
+		if ($curBlock !== 'root') {
+			$output = '(defined("'.$key.'") ? '.$key.' : null)';
+		} else {
+			$output = $key;
+		}
+
+		return $output;
+	}
+
+	/**
+	 * parses a variable
+	 *
+	 * @param string $in the string within which we must parse something
+	 * @param int $from the starting offset of the parsed area
+	 * @param int $to the ending offset of the parsed area
+	 * @param mixed $parsingParams must be an array if we are parsing a function or modifier's parameters, or false by default
+	 * @param string $curBlock the current parser-block being processed
+	 * @param mixed $pointer a reference to a pointer that will be increased by the amount of characters parsed, or null by default
+	 * @return string parsed values
+	 */
+	protected function parseVar($in, $from, $to, $parsingParams = false, $curBlock='', &$pointer = null)
+	{
+		$substr = substr($in, $from, $to-$from);
+
+		if (preg_match('#(\$?\.?[a-z0-9_:]*(?:(?:(?:\.|->)(?:[a-z0-9_:]+|(?R))|\[(?:[a-z0-9_:]+|(?R)|(["\'])[^\2]*?\2)\]))*)' . // var key
+			($curBlock==='root' || $curBlock==='function' || $curBlock==='namedparam' || $curBlock==='condition' || $curBlock==='variable' || $curBlock==='expression' ? '(\(.*)?' : '()') . // method call
+			($curBlock==='root' || $curBlock==='function' || $curBlock==='namedparam' || $curBlock==='condition' || $curBlock==='variable' || $curBlock==='delimited_string' ? '((?:(?:[+/*%=-])(?:(?<!=)=?-?[$%][a-z0-9.[\]>_:-]+(?:\([^)]*\))?|(?<!=)=?-?[0-9.,]*|[+-]))*)':'()') . // simple math expressions
+			($curBlock!=='modifier' ? '((?:\|(?:@?[a-z0-9_]+(?:(?::("|\').*?\5|:[^`]*))*))+)?':'(())') . // modifiers
+			'#i', $substr, $match)) {
+			$key = substr($match[1], 1);
+
+			$matchedLength = strlen($match[0]);
+			$hasModifiers = !empty($match[5]);
+			$hasExpression = !empty($match[4]);
+			$hasMethodCall = !empty($match[3]);
+
+			if (substr($key, -1) == ".") {
+				$key = substr($key, 0, -1);
+				$matchedLength--;
+			}
+
+			if ($hasMethodCall) {
+				$matchedLength -= strlen($match[3]) + strlen(substr($match[1], strrpos($match[1], '->')));
+				$key = substr($match[1], 1, strrpos($match[1], '->')-1);
+				$methodCall = substr($match[1], strrpos($match[1], '->')) . $match[3];
+			}
+
+			if ($hasModifiers) {
+				$matchedLength -= strlen($match[5]);
+			}
+
+			if ($pointer !== null) {
+				$pointer += $matchedLength;
+			}
+
+			// replace useless brackets by dot accessed vars and strip enclosing quotes if present
+			$key = preg_replace('#\[(["\']?)([^$%\[.>-]+)\1\]#', '.$2', $key);
+
+			if ($this->debug) {
+				if ($hasMethodCall) {
+					echo 'METHOD CALL FOUND : $'.$key.substr($methodCall, 0, 30).'<br />';
+				} else {
+					echo 'VAR FOUND : $'.$key.'<br />';
+				}
+			}
+
+			$key = str_replace('"', '\\"', $key);
+
+			$cnt=substr_count($key, '$');
+			if ($cnt > 0) {
+				$uid = 0;
+				$parsed = array($uid => '');
+				$current =& $parsed;
+				$curTxt =& $parsed[$uid++];
+				$tree = array();
+				$chars = str_split($key, 1);
+				$inSplittedVar = false;
+				$bracketCount = 0;
+
+				while (($char = array_shift($chars)) !== null) {
+					if ($char === '[') {
+						if (count($tree) > 0) {
+							$bracketCount++;
+						} else {
+							$tree[] =& $current;
+							$current[$uid] = array($uid+1 => '');
+							$current =& $current[$uid++];
+							$curTxt =& $current[$uid++];
+							continue;
+						}
+					} elseif ($char === ']') {
+						if ($bracketCount > 0) {
+							$bracketCount--;
+						} else {
+							$current =& $tree[count($tree)-1];
+							array_pop($tree);
+							if (current($chars) !== '[' && current($chars) !== false && current($chars) !== ']') {
+								$current[$uid] = '';
+								$curTxt =& $current[$uid++];
+							}
+							continue;
+						}
+					} elseif ($char === '$') {
+						if (count($tree) == 0) {
+							$curTxt =& $current[$uid++];
+							$inSplittedVar = true;
+						}
+					} elseif (($char === '.' || $char === '-') && count($tree) == 0 && $inSplittedVar) {
+						$curTxt =& $current[$uid++];
+						$inSplittedVar = false;
+					}
+
+					$curTxt .= $char;
+				}
+				unset($uid, $current, $curTxt, $tree, $chars);
+
+				if ($this->debug) echo 'RECURSIVE VAR REPLACEMENT : '.$key.'<br>';
+
+				$key = $this->flattenVarTree($parsed);
+
+				if ($this->debug) echo 'RECURSIVE VAR REPLACEMENT DONE : '.$key.'<br>';
+
+				$output = preg_replace('#(^""\.|""\.|\.""$|(\()""\.|\.""(\)))#', '$2$3', '$this->readVar("'.$key.'")');
+			} else {
+				$output = $this->parseVarKey($key, $hasModifiers ? 'modifier' : $curBlock);
+			}
+
+			// methods
+			if ($hasMethodCall) {
+				$ptr = 0;
+
+				$output = $this->parseMethodCall($output, $methodCall, $curBlock, $ptr);
+
+				if ($pointer !== null) {
+					$pointer += $ptr;
+				}
+				$matchedLength += $ptr;
+			}
+
+			if ($hasExpression) {
+				// expressions
+				preg_match_all('#(?:([+/*%=-])(=?-?[%$][a-z0-9.[\]>_:-]+(?:\([^)]*\))?|=?-?[0-9.,]+|\1))#i', $match[4], $expMatch);
+
+				foreach ($expMatch[1] as $k=>$operator) {
+					if (substr($expMatch[2][$k], 0, 1)==='=') {
+						$assign = true;
+						if ($operator === '=') {
+							throw new Dwoo_Compilation_Exception($this, 'Invalid expression <em>'.$substr.'</em>, can not use "==" in expressions');
+						}
+						if ($curBlock !== 'root') {
+							throw new Dwoo_Compilation_Exception($this, 'Invalid expression <em>'.$substr.'</em>, assignments can only be used in top level expressions like {$foo+=3} or {$foo="bar"}');
+						}
+						$operator .= '=';
+						$expMatch[2][$k] = substr($expMatch[2][$k], 1);
+					}
+
+					if (substr($expMatch[2][$k], 0, 1)==='-' && strlen($expMatch[2][$k]) > 1) {
+						$operator .= '-';
+						$expMatch[2][$k] = substr($expMatch[2][$k], 1);
+					}
+					if (($operator==='+'||$operator==='-') && $expMatch[2][$k]===$operator) {
+						$output = '('.$output.$operator.$operator.')';
+						break;
+					} elseif (substr($expMatch[2][$k], 0, 1) === '$') {
+						$output = '('.$output.' '.$operator.' '.$this->parseVar($expMatch[2][$k], 0, strlen($expMatch[2][$k]), false, 'expression').')';
+					} elseif (substr($expMatch[2][$k], 0, 1) === '%') {
+						$output = '('.$output.' '.$operator.' '.$this->parseConst($expMatch[2][$k], 0, strlen($expMatch[2][$k]), false, 'expression').')';
+					} elseif (!empty($expMatch[2][$k])) {
+						$output = '('.$output.' '.$operator.' '.str_replace(',', '.', $expMatch[2][$k]).')';
+					} else {
+						throw new Dwoo_Compilation_Exception($this, 'Unfinished expression <em>'.$substr.'</em>, missing var or number after math operator');
+					}
+				}
+			}
+
+			if ($this->autoEscape === true && $curBlock !== 'condition') {
+				$output = '(is_string($tmp='.$output.') ? htmlspecialchars($tmp, ENT_QUOTES, $this->charset) : $tmp)';
+			}
+
+			// handle modifiers
+			if ($curBlock !== 'modifier' && $hasModifiers) {
+				$ptr = 0;
+				$output = $this->replaceModifiers(array(null, null, $output, $match[5]), 'var', $ptr);
+				if ($pointer !== null) {
+					$pointer += $ptr;
+				}
+				$matchedLength += $ptr;
+			}
+
+			if (is_array($parsingParams)) {
+				$parsingParams[] = array($output, $key);
+				return $parsingParams;
+			} elseif ($curBlock === 'namedparam') {
+				return array($output, $key);
+			} elseif ($curBlock === 'string' || $curBlock === 'delimited_string') {
+				return array($matchedLength, $output);
+			} elseif ($curBlock === 'expression' || $curBlock === 'variable') {
+				return $output;
+			} elseif (isset($assign)) {
+				return self::PHP_OPEN.$output.';'.self::PHP_CLOSE;
+			} else {
+				return $output;
+			}
+		} else {
+			if ($curBlock === 'string' || $curBlock === 'delimited_string') {
+				return array(0, '');
+			} else {
+				throw new Dwoo_Compilation_Exception($this, 'Invalid variable name <em>'.$substr.'</em>');
+			}
+		}
+	}
+
+	/**
+	 * parses any number of chained method calls/property reads
+	 *
+	 * @param string $output the variable or whatever upon which the method are called
+	 * @param string $methodCall method call source, starting at "->"
+	 * @param string $curBlock the current parser-block being processed
+	 * @param int $pointer a reference to a pointer that will be increased by the amount of characters parsed
+	 * @return string parsed call(s)/read(s)
+	 */
+	protected function parseMethodCall($output, $methodCall, $curBlock, &$pointer)
+	{
+		$ptr = 0;
+		$len = strlen($methodCall);
+
+		while ($ptr < $len) {
+			if (strpos($methodCall, '->', $ptr) === $ptr) {
+				$ptr += 2;
+			}
+
+			if (in_array($methodCall[$ptr], array(';', ',', '/', ' ', "\t", "\r", "\n", ')', '+', '*', '%', '=', '-', '|')) || substr($methodCall, $ptr, strlen($this->rd)) === $this->rd) {
+				// break char found
+				break;
+			}
+
+			if(!preg_match('/^([a-z0-9_]+)(\(.*?\))?/i', substr($methodCall, $ptr), $methMatch)) {
+				throw new Dwoo_Compilation_Exception($this, 'Invalid method name : '.substr($methodCall, $ptr, 20));
+			}
+
+			if (empty($methMatch[2])) {
+				// property
+				if ($curBlock === 'root') {
+					$output .= '->'.$methMatch[1];
+				} else {
+					$output = '(($tmp = '.$output.') ? $tmp->'.$methMatch[1].' : null)';
+				}
+				$ptr += strlen($methMatch[1]);
+			} else {
+				// method
+				if (substr($methMatch[2], 0, 2) === '()') {
+					$parsedCall = $methMatch[1].'()';
+					$ptr += strlen($methMatch[1]) + 2;
+				} else {
+					$parsedCall = $this->parseFunction($methodCall, $ptr, strlen($methodCall), false, 'method', $ptr);
+				}
+				if ($this->securityPolicy !== null) {
+					$argPos = strpos($parsedCall, '(');
+					$method = strtolower(substr($parsedCall, 0, $argPos));
+					$args = substr($parsedCall, $argPos);
+					if ($curBlock === 'root') {
+						$output = '$this->getSecurityPolicy()->callMethod($this, '.$output.', '.var_export($method, true).', array'.$args.')';
+					} else {
+						$output = '(($tmp = '.$output.') ? $this->getSecurityPolicy()->callMethod($this, $tmp, '.var_export($method, true).', array'.$args.') : null)';
+					}
+				} else {
+					if ($curBlock === 'root') {
+						$output .= '->'.$parsedCall;
+					} else {
+						$output = '(($tmp = '.$output.') ? $tmp->'.$parsedCall.' : null)';
+					}
+				}
+			}
+		}
+
+		$pointer += $ptr;
+		return $output;
+	}
+
+	/**
+	 * parses a constant variable (a variable that doesn't contain another variable) and preprocesses it to save runtime processing time
+	 *
+	 * @param string $key the variable to parse
+	 * @param string $curBlock the current parser-block being processed
+	 * @return string parsed variable
+	 */
+	protected function parseVarKey($key, $curBlock)
+	{
+		if ($key === '') {
+			return '$this->scope';
+		}
+		if (substr($key, 0, 1) === '.') {
+			$key = 'dwoo'.$key;
+		}
+		if (preg_match('#dwoo\.(get|post|server|cookies|session|env|request)((?:\.[a-z0-9_-]+)+)#i', $key, $m)) {
+			$global = strtoupper($m[1]);
+			if ($global === 'COOKIES') {
+				$global = 'COOKIE';
+			}
+			$key = '$_'.$global;
+			foreach (explode('.', ltrim($m[2], '.')) as $part)
+				$key .= '['.var_export($part, true).']';
+			if ($curBlock === 'root') {
+				$output = $key;
+			} else {
+				$output = '(isset('.$key.')?'.$key.':null)';
+			}
+		} elseif (preg_match('#dwoo\.const\.([a-z0-9_:]+)#i', $key, $m)) {
+			return $this->parseConstKey($m[1], $curBlock);
+		} elseif ($this->scope !== null) {
+			if (strstr($key, '.') === false && strstr($key, '[') === false && strstr($key, '->') === false) {
+				if ($key === 'dwoo') {
+					$output = '$this->globals';
+				} elseif ($key === '_root' || $key === '__') {
+					$output = '$this->data';
+				} elseif ($key === '_parent' || $key === '_') {
+					$output = '$this->readParentVar(1)';
+				} elseif ($key === '_key') {
+					$output = '$tmp_key';
+				} else {
+					if ($curBlock === 'root') {
+						$output = '$this->scope["'.$key.'"]';
+					} else {
+						$output = '(isset($this->scope["'.$key.'"]) ? $this->scope["'.$key.'"] : null)';
+					}
+				}
+			} else {
+				preg_match_all('#(\[|->|\.)?((?:[a-z0-9_]|-(?!>))+|(\\\?[\'"])[^\3]*?\3)\]?#i', $key, $m);
+
+				$i = $m[2][0];
+				if ($i === '_parent' || $i === '_') {
+					$parentCnt = 0;
+
+					while (true) {
+						$parentCnt++;
+						array_shift($m[2]);
+						array_shift($m[1]);
+						if (current($m[2]) === '_parent') {
+							continue;
+						}
+						break;
+					}
+
+					$output = '$this->readParentVar('.$parentCnt.')';
+				} else {
+					if ($i === 'dwoo') {
+						$output = '$this->globals';
+						array_shift($m[2]);
+						array_shift($m[1]);
+					} elseif ($i === '_root' || $i === '__') {
+						$output = '$this->data';
+						array_shift($m[2]);
+						array_shift($m[1]);
+					} elseif ($i === '_key') {
+						$output = '$tmp_key';
+					} else {
+						$output = '$this->scope';
+					}
+
+					while (count($m[1]) && $m[1][0] !== '->') {
+						$m[2][0] = preg_replace('/(^\\\([\'"])|\\\([\'"])$)/x', '$2$3', $m[2][0]);
+						if(substr($m[2][0], 0, 1) == '"' || substr($m[2][0], 0, 1) == "'") {
+							$output .= '['.$m[2][0].']';
+						} else {
+							$output .= '["'.$m[2][0].'"]';
+						}
+						array_shift($m[2]);
+						array_shift($m[1]);
+					}
+
+					if ($curBlock !== 'root') {
+						$output = '(isset('.$output.') ? '.$output.':null)';
+					}
+				}
+
+				if (count($m[2])) {
+					unset($m[0]);
+					$output = '$this->readVarInto('.str_replace("\n", '', var_export($m, true)).', '.$output.', '.($curBlock == 'root' ? 'false': 'true').')';
+				}
+			}
+		} else {
+			preg_match_all('#(\[|->|\.)?((?:[a-z0-9_]|-(?!>))+)\]?#i', $key, $m);
+			unset($m[0]);
+			$output = '$this->readVar('.str_replace("\n", '', var_export($m, true)).')';
+		}
+
+		return $output;
+	}
+
+	/**
+	 * flattens a variable tree, this helps in parsing very complex variables such as $var.foo[$foo.bar->baz].baz,
+	 * it computes the contents of the brackets first and works out from there
+	 *
+	 * @param array $tree the variable tree parsed by he parseVar() method that must be flattened
+	 * @param bool $recursed leave that to false by default, it is only for internal use
+	 * @return string flattened tree
+	 */
+	protected function flattenVarTree(array $tree, $recursed=false)
+	{
+		$out = $recursed ?  '".$this->readVarInto(' : '';
+		foreach ($tree as $bit) {
+			if (is_array($bit)) {
+				$out.='.'.$this->flattenVarTree($bit, false);
+			} else {
+				$key = str_replace('"', '\\"', $bit);
+
+				if (substr($key, 0, 1)==='$') {
+					$out .= '".'.$this->parseVar($key, 0, strlen($key), false, 'variable').'."';
+				} else {
+					$cnt = substr_count($key, '$');
+
+					if ($this->debug) echo 'PARSING SUBVARS IN : '.$key.'<br>';
+					if ($cnt > 0) {
+						while (--$cnt >= 0) {
+							if (isset($last)) {
+								$last = strrpos($key, '$', - (strlen($key) - $last + 1));
+							} else {
+								$last = strrpos($key, '$');
+							}
+							preg_match('#\$[a-z0-9_]+((?:(?:\.|->)(?:[a-z0-9_]+|(?R))|\[(?:[a-z0-9_]+|(?R))\]))*'.
+									  '((?:(?:[+/*%-])(?:\$[a-z0-9.[\]>_:-]+(?:\([^)]*\))?|[0-9.,]*))*)#i', substr($key, $last), $submatch);
+
+							$len = strlen($submatch[0]);
+							$key = substr_replace(
+								$key,
+								preg_replace_callback(
+									'#(\$[a-z0-9_]+((?:(?:\.|->)(?:[a-z0-9_]+|(?R))|\[(?:[a-z0-9_]+|(?R))\]))*)'.
+									'((?:(?:[+/*%-])(?:\$[a-z0-9.[\]>_:-]+(?:\([^)]*\))?|[0-9.,]*))*)#i',
+									array($this, 'replaceVarKeyHelper'), substr($key, $last, $len)
+								),
+								$last,
+								$len
+							);
+							if ($this->debug) echo 'RECURSIVE VAR REPLACEMENT DONE : '.$key.'<br>';
+						}
+						unset($last);
+
+						$out .= $key;
+					} else {
+						$out .= $key;
+					}
+				}
+			}
+		}
+		$out .= $recursed ? ', true)."' : '';
+		return $out;
+	}
+
+	/**
+	 * helper function that parses a variable
+	 *
+	 * @param array $match the matched variable, array(1=>"string match")
+	 * @return string parsed variable
+	 */
+	protected function replaceVarKeyHelper($match)
+	{
+		return '".'.$this->parseVar($match[0], 0, strlen($match[0]), false, 'variable').'."';
+	}
+
+	/**
+	 * parses various constants, operators or non-quoted strings
+	 *
+	 * @param string $in the string within which we must parse something
+	 * @param int $from the starting offset of the parsed area
+	 * @param int $to the ending offset of the parsed area
+	 * @param mixed $parsingParams must be an array if we are parsing a function or modifier's parameters, or false by default
+	 * @param string $curBlock the current parser-block being processed
+	 * @param mixed $pointer a reference to a pointer that will be increased by the amount of characters parsed, or null by default
+	 * @return string parsed values
+	 */
+	protected function parseOthers($in, $from, $to, $parsingParams = false, $curBlock='', &$pointer = null)
+	{
+		$first = $in[$from];
+		$substr = substr($in, $from, $to-$from);
+
+		$end = strlen($substr);
+
+		if ($curBlock === 'condition') {
+			$breakChars = array('(', ')', ' ', '||', '&&', '|', '&', '>=', '<=', '===', '==', '=', '!==', '!=', '<<', '<', '>>', '>', '^', '~', ',', '+', '-', '*', '/', '%', '!', '?', ':', $this->rd, ';');
+		} elseif ($curBlock === 'modifier') {
+			$breakChars = array(' ', ',', ')', ':', '|', "\r", "\n", "\t", ";", $this->rd);
+		} elseif ($curBlock === 'expression') {
+			$breakChars = array('/', '%', '+', '-', '*', ' ', ',', ')', "\r", "\n", "\t", ";", $this->rd);
+		} else {
+			$breakChars = array(' ', ',', ')', "\r", "\n", "\t", ";", $this->rd);
+		}
+
+		$breaker = false;
+		while (list($k,$char) = each($breakChars)) {
+			$test = strpos($substr, $char);
+			if ($test !== false && $test < $end) {
+				$end = $test;
+				$breaker = $k;
+			}
+		}
+
+		if ($curBlock === 'condition') {
+			if ($end === 0 && $breaker !== false) {
+				$end = strlen($breakChars[$breaker]);
+			}
+		}
+
+		if ($end !== false) {
+			$substr = substr($substr, 0, $end);
+		}
+
+		if ($pointer !== null) {
+			$pointer += strlen($substr);
+		}
+
+		$src = $substr;
+		$substr = trim($substr);
+
+		if (strtolower($substr) === 'false' || strtolower($substr) === 'no' || strtolower($substr) === 'off') {
+			if ($this->debug) echo 'BOOLEAN(FALSE) PARSED<br />';
+			$substr = 'false';
+			$type = self::T_BOOL;
+		} elseif (strtolower($substr) === 'true' || strtolower($substr) === 'yes' || strtolower($substr) === 'on') {
+			if ($this->debug) echo 'BOOLEAN(TRUE) PARSED<br />';
+			$substr = 'true';
+			$type = self::T_BOOL;
+		} elseif ($substr === 'null' || $substr === 'NULL') {
+			if ($this->debug) echo 'NULL PARSED<br />';
+			$substr = 'null';
+			$type = self::T_NULL;
+		} elseif (is_numeric($substr)) {
+			$substr = (float) $substr;
+			if ((int) $substr == $substr) {
+				$substr = (int) $substr;
+			}
+			$type = self::T_NUMERIC;
+			if ($this->debug) echo 'NUMBER ('.$substr.') PARSED<br />';
+		} elseif (preg_match('{^-?(\d+|\d*(\.\d+))\s*([/*%+-]\s*-?(\d+|\d*(\.\d+)))+$}', $substr)) {
+			if ($this->debug) echo 'SIMPLE MATH PARSED<br />';
+			$type = self::T_MATH;
+			$substr = '('.$substr.')';
+		} elseif ($curBlock === 'condition' && array_search($substr, $breakChars, true) !== false) {
+			if ($this->debug) echo 'BREAKCHAR ('.$substr.') PARSED<br />';
+			$type = self::T_BREAKCHAR;
+			//$substr = '"'.$substr.'"';
+		} else {
+			$substr = $this->replaceStringVars('\''.str_replace('\'', '\\\'', $substr).'\'', '\'', $curBlock);
+			$type = self::T_UNQUOTED_STRING;
+			if ($this->debug) echo 'BLABBER ('.$substr.') CASTED AS STRING<br />';
+		}
+
+		if (is_array($parsingParams)) {
+			$parsingParams[] = array($substr, $src, $type);
+			return $parsingParams;
+		} elseif ($curBlock === 'namedparam') {
+			return array($substr, $src, $type);
+		} elseif ($curBlock === 'expression') {
+			return $substr;
+		} else {
+			throw new Exception('Something went wrong');
+		}
+	}
+
+	/**
+	 * replaces variables within a parsed string
+	 *
+	 * @param string $string the parsed string
+	 * @param string $first the first character parsed in the string, which is the string delimiter (' or ")
+	 * @param string $curBlock the current parser-block being processed
+	 * @return string the original string with variables replaced
+	 */
+	protected function replaceStringVars($string, $first, $curBlock='')
+	{
+		$pos = 0;
+		if ($this->debug) echo 'STRING VAR REPLACEMENT : '.$string.'<br>';
+		// replace vars
+		while (($pos = strpos($string, '$', $pos)) !== false) {
+			$prev = substr($string, $pos-1, 1);
+			if ($prev === '\\') {
+				$pos++;
+				continue;
+			}
+
+			$var = $this->parse($string, $pos, null, false, ($curBlock === 'modifier' ? 'modifier' : ($prev === '`' ? 'delimited_string':'string')));
+			$len = $var[0];
+			$var = $this->parse(str_replace('\\'.$first, $first, $string), $pos, null, false, ($curBlock === 'modifier' ? 'modifier' : ($prev === '`' ? 'delimited_string':'string')));
+
+			if ($prev === '`' && substr($string, $pos+$len, 1) === '`') {
+				$string = substr_replace($string, $first.'.'.$var[1].'.'.$first, $pos-1, $len+2);
+			} else {
+				$string = substr_replace($string, $first.'.'.$var[1].'.'.$first, $pos, $len);
+			}
+			$pos += strlen($var[1]) + 2;
+			if ($this->debug) echo 'STRING VAR REPLACEMENT DONE : '.$string.'<br>';
+		}
+
+		// handle modifiers
+		// TODO Obsolete?
+		$string = preg_replace_callback('#("|\')\.(.+?)\.\1((?:\|(?:@?[a-z0-9_]+(?:(?::("|\').+?\4|:[^`]*))*))+)#i', array($this, 'replaceModifiers'), $string);
+
+		// replace escaped dollar operators by unescaped ones if required
+		if ($first==="'") {
+			$string = str_replace('\\$', '$', $string);
+		}
+
+		return $string;
+	}
+
+	/**
+	 * replaces the modifiers applied to a string or a variable
+	 *
+	 * @param array $m the regex matches that must be array(1=>"double or single quotes enclosing a string, when applicable", 2=>"the string or var", 3=>"the modifiers matched")
+	 * @param string $curBlock the current parser-block being processed
+	 * @return string the input enclosed with various function calls according to the modifiers found
+	 */
+	protected function replaceModifiers(array $m, $curBlock = null, &$pointer = null)
+	{
+		if ($this->debug) echo 'PARSING MODIFIERS : '.$m[3].'<br />';
+
+		if ($pointer !== null) {
+			$pointer += strlen($m[3]);
+		}
+		// remove first pipe
+		$cmdstrsrc = substr($m[3], 1);
+		// remove last quote if present
+		if (substr($cmdstrsrc, -1, 1) === $m[1]) {
+			$cmdstrsrc = substr($cmdstrsrc, 0, -1);
+			$add = $m[1];
+		}
+
+		$output = $m[2];
+
+		$continue = true;
+		while (strlen($cmdstrsrc) > 0 && $continue) {
+			if ($cmdstrsrc[0] === '|') {
+				$cmdstrsrc = substr($cmdstrsrc, 1);
+				continue;
+			}
+			if ($cmdstrsrc[0] === ' ' || $cmdstrsrc[0] === ';' || substr($cmdstrsrc, 0, strlen($this->rd)) === $this->rd) {
+				if ($this->debug) echo 'MODIFIER PARSING ENDED, RIGHT DELIMITER or ";" FOUND<br/>';
+				$continue = false;
+				if ($pointer !== null) {
+					$pointer -= strlen($cmdstrsrc);
+				}
+				break;
+			}
+			$cmdstr = $cmdstrsrc;
+			$paramsep = ':';
+			if (!preg_match('/^(@{0,2}[a-z_][a-z0-9_]*)(:)?/i', $cmdstr, $match)) {
+				throw new Dwoo_Compilation_Exception($this, 'Invalid modifier name, started with : '.substr($cmdstr, 0, 10));
+			}
+			$paramspos = !empty($match[2]) ? strlen($match[1]) : false;
+			$func = $match[1];
+
+			$state = 0;
+			if ($paramspos === false) {
+				$cmdstrsrc = substr($cmdstrsrc, strlen($func));
+				$params = array();
+				if ($this->debug) echo 'MODIFIER ('.$func.') CALLED WITH NO PARAMS<br/>';
+			} else {
+				$paramstr = substr($cmdstr, $paramspos+1);
+				if (substr($paramstr, -1, 1) === $paramsep) {
+					$paramstr = substr($paramstr, 0, -1);
+				}
+
+				$ptr = 0;
+				$params = array();
+				while ($ptr < strlen($paramstr)) {
+					if ($this->debug) echo 'MODIFIER ('.$func.') START PARAM PARSING WITH POINTER AT '.$ptr.'<br/>';
+					if ($this->debug) echo $paramstr.'--'.$ptr.'--'.strlen($paramstr).'--modifier<br/>';
+					$params = $this->parse($paramstr, $ptr, strlen($paramstr), $params, 'modifier', $ptr);
+					if ($this->debug) echo 'PARAM PARSED, POINTER AT '.$ptr.'<br/>';
+
+					if ($ptr >= strlen($paramstr)) {
+						if ($this->debug) echo 'PARAM PARSING ENDED, PARAM STRING CONSUMED<br/>';
+						break;
+					}
+
+					if ($paramstr[$ptr] === ' ' || $paramstr[$ptr] === '|' || $paramstr[$ptr] === ';' || substr($paramstr, $ptr, strlen($this->rd)) === $this->rd) {
+						if ($this->debug) echo 'PARAM PARSING ENDED, " ", "|", RIGHT DELIMITER or ";" FOUND, POINTER AT '.$ptr.'<br/>';
+						if ($paramstr[$ptr] !== '|') {
+							$continue = false;
+							if ($pointer !== null) {
+								$pointer -= strlen($paramstr) - $ptr;
+							}
+						}
+						$ptr++;
+						break;
+					}
+					if ($ptr < strlen($paramstr) && $paramstr[$ptr] === ':') {
+						$ptr++;
+					}
+				}
+				$cmdstrsrc = substr($cmdstrsrc, strlen($func)+1+$ptr);
+				$paramstr = substr($paramstr, 0, $ptr);
+				foreach ($params as $k=>$p) {
+					if (is_array($p) && is_array($p[1])) {
+						$state |= 2;
+					} else {
+						if (($state & 2) && preg_match('#^(["\'])(.+?)\1$#', $p[0], $m)) {
+							$params[$k] = array($m[2], array('true', 'true'));
+						} else {
+							if ($state & 2) {
+								throw new Dwoo_Compilation_Exception($this, 'You can not use an unnamed parameter after a named one');
+							}
+							$state |= 1;
+						}
+					}
+				}
+			}
+
+			// check if we must use array_map with this plugin or not
+			$mapped = false;
+			if (substr($func, 0, 1) === '@') {
+				$func = substr($func, 1);
+				$mapped = true;
+			}
+
+			$pluginType = $this->getPluginType($func);
+
+			if ($state & 2) {
+				array_unshift($params, array('value', array($output, $output)));
+			} else {
+				array_unshift($params, array($output, $output));
+			}
+
+			if ($pluginType & Dwoo_Core::NATIVE_PLUGIN) {
+				$params = $this->mapParams($params, null, $state);
+
+				$params = $params['*'][0];
+
+				$params = self::implode_r($params);
+
+				if ($mapped) {
+					$output = '$this->arrayMap(\''.$func.'\', array('.$params.'))';
+				} else {
+					$output = $func.'('.$params.')';
+				}
+			} elseif ($pluginType & Dwoo_Core::PROXY_PLUGIN) {
+				$params = $this->mapParams($params, $this->getDwoo()->getPluginProxy()->getCallback($func), $state);
+				foreach ($params as &$p)
+					$p = $p[0];
+				$output = call_user_func(array($this->dwoo->getPluginProxy(), 'getCode'), $func, $params);
+			} elseif ($pluginType & Dwoo_Core::SMARTY_MODIFIER) {
+				$params = $this->mapParams($params, null, $state);
+				$params = $params['*'][0];
+
+				$params = self::implode_r($params);
+
+				if ($pluginType & Dwoo_Core::CUSTOM_PLUGIN) {
+					$callback = $this->customPlugins[$func]['callback'];
+					if (is_array($callback)) {
+						if (is_object($callback[0])) {
+							$output = ($mapped ? '$this->arrayMap' : 'call_user_func_array').'(array($this->plugins[\''.$func.'\'][\'callback\'][0], \''.$callback[1].'\'), array('.$params.'))';
+						} else {
+							$output = ($mapped ? '$this->arrayMap' : 'call_user_func_array').'(array(\''.$callback[0].'\', \''.$callback[1].'\'), array('.$params.'))';
+						}
+					} elseif ($mapped) {
+						$output = '$this->arrayMap(\''.$callback.'\', array('.$params.'))';
+					} else {
+						$output = $callback.'('.$params.')';
+					}
+				} elseif ($mapped) {
+					$output = '$this->arrayMap(\'smarty_modifier_'.$func.'\', array('.$params.'))';
+				} else {
+					$output = 'smarty_modifier_'.$func.'('.$params.')';
+				}
+			} else {
+				if ($pluginType & Dwoo_Core::CUSTOM_PLUGIN) {
+					$callback = $this->customPlugins[$func]['callback'];
+					$pluginName = $callback;
+				} else {
+					$pluginName = 'Dwoo_Plugin_'.$func;
+
+					if ($pluginType & Dwoo_Core::CLASS_PLUGIN) {
+						$callback = array($pluginName, ($pluginType & Dwoo_Core::COMPILABLE_PLUGIN) ? 'compile' : 'process');
+					} else {
+						$callback = $pluginName . (($pluginType & Dwoo_Core::COMPILABLE_PLUGIN) ? '_compile' : '');
+					}
+				}
+
+				$params = $this->mapParams($params, $callback, $state);
+
+				foreach ($params as &$p)
+					$p = $p[0];
+
+				if ($pluginType & Dwoo_Core::FUNC_PLUGIN) {
+					if ($pluginType & Dwoo_Core::COMPILABLE_PLUGIN) {
+						if ($mapped) {
+							throw new Dwoo_Compilation_Exception($this, 'The @ operator can not be used on compiled plugins.');
+						}
+						if ($pluginType & Dwoo_Core::CUSTOM_PLUGIN) {
+							$funcCompiler = $this->customPlugins[$func]['callback'];
+						} else {
+							$funcCompiler = 'Dwoo_Plugin_'.$func.'_compile';
+						}
+						array_unshift($params, $this);
+						$output = call_user_func_array($funcCompiler, $params);
+					} else {
+						array_unshift($params, '$this');
+
+						$params = self::implode_r($params);
+						if ($mapped) {
+							$output = '$this->arrayMap(\''.$pluginName.'\', array('.$params.'))';
+						} else {
+							$output = $pluginName.'('.$params.')';
+						}
+					}
+				} else {
+					if ($pluginType & Dwoo_Core::COMPILABLE_PLUGIN) {
+						if ($mapped) {
+							throw new Dwoo_Compilation_Exception($this, 'The @ operator can not be used on compiled plugins.');
+						}
+						if ($pluginType & Dwoo_Core::CUSTOM_PLUGIN) {
+							$callback = $this->customPlugins[$func]['callback'];
+							if (!is_array($callback)) {
+								if (!method_exists($callback, 'compile')) {
+									throw new Dwoo_Exception('Custom plugin '.$func.' must implement the "compile" method to be compilable, or you should provide a full callback to the method to use');
+								}
+								if (($ref = new ReflectionMethod($callback, 'compile')) && $ref->isStatic()) {
+									$funcCompiler = array($callback, 'compile');
+								} else {
+									$funcCompiler = array(new $callback, 'compile');
+								}
+							} else {
+								$funcCompiler = $callback;
+							}
+						} else {
+							$funcCompiler = array('Dwoo_Plugin_'.$func, 'compile');
+							array_unshift($params, $this);
+						}
+						$output = call_user_func_array($funcCompiler, $params);
+					} else {
+						$params = self::implode_r($params);
+
+						if ($pluginType & Dwoo_Core::CUSTOM_PLUGIN) {
+							if (is_object($callback[0])) {
+								$output = ($mapped ? '$this->arrayMap' : 'call_user_func_array').'(array($this->plugins[\''.$func.'\'][\'callback\'][0], \''.$callback[1].'\'), array('.$params.'))';
+							} else {
+								$output = ($mapped ? '$this->arrayMap' : 'call_user_func_array').'(array(\''.$callback[0].'\', \''.$callback[1].'\'), array('.$params.'))';
+							}
+						} elseif ($mapped) {
+							$output = '$this->arrayMap(array($this->getObjectPlugin(\'Dwoo_Plugin_'.$func.'\'), \'process\'), array('.$params.'))';
+						} else {
+							$output = '$this->classCall(\''.$func.'\', array('.$params.'))';
+						}
+					}
+				}
+			}
+		}
+
+		if ($curBlock === 'var' || $m[1] === null) {
+			return $output;
+		} elseif ($curBlock === 'string' || $curBlock === 'root') {
+			return $m[1].'.'.$output.'.'.$m[1].(isset($add)?$add:null);
+		}
+	}
+
+	/**
+	 * recursively implodes an array in a similar manner as var_export() does but with some tweaks
+	 * to handle pre-compiled values and the fact that we do not need to enclose everything with
+	 * "array" and do not require top-level keys to be displayed
+	 *
+	 * @param array $params the array to implode
+	 * @param bool $recursiveCall if set to true, the function outputs key names for the top level
+	 * @return string the imploded array
+	 */
+	public static function implode_r(array $params, $recursiveCall = false)
+	{
+		$out = '';
+		foreach ($params as $k=>$p) {
+			if (is_array($p)) {
+				$out2 = 'array(';
+				foreach ($p as $k2=>$v)
+					$out2 .= var_export($k2, true).' => '.(is_array($v) ? 'array('.self::implode_r($v, true).')' : $v).', ';
+				$p = rtrim($out2, ', ').')';
+			}
+			if ($recursiveCall) {
+				$out .= var_export($k, true).' => '.$p.', ';
+			} else {
+				$out .= $p.', ';
+			}
+		}
+		return rtrim($out, ', ');
+	}
+
+	/**
+	 * returns the plugin type of a plugin and adds it to the used plugins array if required
+	 *
+	 * @param string $name plugin name, as found in the template
+	 * @return int type as a multi bit flag composed of the Dwoo plugin types constants
+	 */
+	protected function getPluginType($name)
+	{
+		$pluginType = -1;
+
+		if (($this->securityPolicy === null && (function_exists($name) || strtolower($name) === 'isset' || strtolower($name) === 'empty')) ||
+			($this->securityPolicy !== null && array_key_exists(strtolower($name), $this->securityPolicy->getAllowedPhpFunctions()) !== false)) {
+			$phpFunc = true;
+		} elseif ($this->securityPolicy !== null && function_exists($name) && array_key_exists(strtolower($name), $this->securityPolicy->getAllowedPhpFunctions()) === false) {
+			throw new Dwoo_Security_Exception('Call to a disallowed php function : '.$name);
+		}
+
+		while ($pluginType <= 0) {
+			if (isset($this->templatePlugins[$name])) {
+				$pluginType = Dwoo_Core::TEMPLATE_PLUGIN | Dwoo_Core::COMPILABLE_PLUGIN;
+			} elseif (isset($this->customPlugins[$name])) {
+				$pluginType = $this->customPlugins[$name]['type'] | Dwoo_Core::CUSTOM_PLUGIN;
+			} elseif (class_exists('Dwoo_Plugin_'.$name, false) !== false) {
+				if (is_subclass_of('Dwoo_Plugin_'.$name, 'Dwoo_Block_Plugin')) {
+					$pluginType = Dwoo_Core::BLOCK_PLUGIN;
+				} else {
+					$pluginType = Dwoo_Core::CLASS_PLUGIN;
+				}
+				$interfaces = class_implements('Dwoo_Plugin_'.$name, false);
+				if (in_array('Dwoo_ICompilable', $interfaces) !== false || in_array('Dwoo_ICompilable_Block', $interfaces) !== false) {
+					$pluginType |= Dwoo_Core::COMPILABLE_PLUGIN;
+				}
+			} elseif (function_exists('Dwoo_Plugin_'.$name) !== false) {
+				$pluginType = Dwoo_Core::FUNC_PLUGIN;
+			} elseif (function_exists('Dwoo_Plugin_'.$name.'_compile')) {
+				$pluginType = Dwoo_Core::FUNC_PLUGIN | Dwoo_Core::COMPILABLE_PLUGIN;
+			} elseif (function_exists('smarty_modifier_'.$name) !== false) {
+				$pluginType = Dwoo_Core::SMARTY_MODIFIER;
+			} elseif (function_exists('smarty_function_'.$name) !== false) {
+				$pluginType = Dwoo_Core::SMARTY_FUNCTION;
+			} elseif (function_exists('smarty_block_'.$name) !== false) {
+				$pluginType = Dwoo_Core::SMARTY_BLOCK;
+			} else {
+				if ($pluginType===-1) {
+					try {
+						$this->dwoo->getLoader()->loadPlugin($name, isset($phpFunc)===false);
+					} catch (Exception $e) {
+						if (isset($phpFunc)) {
+							$pluginType = Dwoo_Core::NATIVE_PLUGIN;
+						} elseif (is_object($this->dwoo->getPluginProxy()) && $this->dwoo->getPluginProxy()->handles($name)) {
+							$pluginType = Dwoo_Core::PROXY_PLUGIN;
+							break;
+						} else {
+							throw $e;
+						}
+					}
+				} else {
+					throw new Dwoo_Exception('Plugin "'.$name.'" could not be found');
+				}
+				$pluginType++;
+			}
+		}
+
+		if (($pluginType & Dwoo_Core::COMPILABLE_PLUGIN) === 0 && ($pluginType & Dwoo_Core::NATIVE_PLUGIN) === 0 && ($pluginType & Dwoo_Core::PROXY_PLUGIN) === 0) {
+			$this->addUsedPlugin($name, $pluginType);
+		}
+
+		return $pluginType;
+	}
+
+	/**
+	 * allows a plugin to load another one at compile time, this will also mark
+	 * it as used by this template so it will be loaded at runtime (which can be
+	 * useful for compiled plugins that rely on another plugin when their compiled
+	 * code runs)
+	 *
+	 * @param string $name the plugin name
+	 */
+	public function loadPlugin($name) {
+		$this->getPluginType($name);
+	}
+
+	/**
+	 * runs htmlentities over the matched <?php ?> blocks when the security policy enforces that
+	 *
+	 * @param array $match matched php block
+	 * @return string the htmlentities-converted string
+	 */
+	protected function phpTagEncodingHelper($match)
+	{
+		return htmlspecialchars($match[0]);
+	}
+
+	/**
+	 * maps the parameters received from the template onto the parameters required by the given callback
+	 *
+	 * @param array $params the array of parameters
+	 * @param callback $callback the function or method to reflect on to find out the required parameters
+	 * @param int $callType the type of call in the template, 0 = no params, 1 = php-style call, 2 = named parameters call
+	 * @param array $map the parameter map to use, if not provided it will be built from the callback
+	 * @return array parameters sorted in the correct order with missing optional parameters filled
+	 */
+	protected function mapParams(array $params, $callback, $callType=2, $map = null)
+	{
+		if (!$map) {
+			$map = $this->getParamMap($callback);
+		}
+
+		$paramlist = array();
+
+		// transforms the parameter array from (x=>array('paramname'=>array(values))) to (paramname=>array(values))
+		$ps = array();
+		foreach ($params as $p) {
+			if (is_array($p[1])) {
+				$ps[$p[0]] = $p[1];
+			} else {
+				$ps[] = $p;
+			}
+		}
+
+		// loops over the param map and assigns values from the template or default value for unset optional params
+		while (list($k,$v) = each($map)) {
+			if ($v[0] === '*') {
+				// "rest" array parameter, fill every remaining params in it and then break
+				if (count($ps) === 0) {
+					if ($v[1]===false) {
+						throw new Dwoo_Compilation_Exception($this, 'Rest argument missing for '.str_replace(array('Dwoo_Plugin_', '_compile'), '', (is_array($callback) ? $callback[0] : $callback)));
+					} else {
+						break;
+					}
+				}
+				$tmp = array();
+				$tmp2 = array();
+				$tmp3 = array();
+				foreach ($ps as $i=>$p) {
+					$tmp[$i] = $p[0];
+					$tmp2[$i] = $p[1];
+					$tmp3[$i] = isset($p[2]) ? $p[2] : 0;
+					unset($ps[$i]);
+				}
+				$paramlist[$v[0]] = array($tmp, $tmp2, $tmp3);
+				unset($tmp, $tmp2, $i, $p);
+				break;
+			} elseif (isset($ps[$v[0]])) {
+				// parameter is defined as named param
+				$paramlist[$v[0]] = $ps[$v[0]];
+				unset($ps[$v[0]]);
+			} elseif (isset($ps[$k])) {
+				// parameter is defined as ordered param
+				$paramlist[$v[0]] = $ps[$k];
+				unset($ps[$k]);
+			} elseif ($v[1]===false) {
+				// parameter is not defined and not optional, throw error
+				if (is_array($callback)) {
+					if (is_object($callback[0])) {
+						$name = get_class($callback[0]) . '::' . $callback[1];
+					} else {
+						$name = $callback[0];
+					}
+				} else {
+					$name = $callback;
+				}
+
+				throw new Dwoo_Compilation_Exception($this, 'Argument '.$k.'/'.$v[0].' missing for '.str_replace(array('Dwoo_Plugin_', '_compile'), '', $name));
+			} elseif ($v[2]===null) {
+				// enforce lowercased null if default value is null (php outputs NULL with var export)
+				$paramlist[$v[0]] = array('null', null, self::T_NULL);
+			} else {
+				// outputs default value with var_export
+				$paramlist[$v[0]] = array(var_export($v[2], true), $v[2]);
+			}
+		}
+
+		if (count($ps)) {
+			foreach ($ps as $i=>$p) {
+				array_push($paramlist, $p);
+			}
+		}
+
+		return $paramlist;
+	}
+
+	/**
+	 * returns the parameter map of the given callback, it filters out entries typed as Dwoo and Dwoo_Compiler and turns the rest parameter into a "*"
+	 *
+	 * @param callback $callback the function/method to reflect on
+	 * @return array processed parameter map
+	 */
+	protected function getParamMap($callback)
+	{
+		if (is_null($callback)) {
+			return array(array('*', true));
+		}
+		if (is_array($callback)) {
+			$ref = new ReflectionMethod($callback[0], $callback[1]);
+		} else {
+			$ref = new ReflectionFunction($callback);
+		}
+
+		$out = array();
+		foreach ($ref->getParameters() as $param) {
+			if (($class = $param->getClass()) !== null && ($class->name === 'Dwoo' || $class->name === 'Dwoo_Core')) {
+				continue;
+			}
+			if (($class = $param->getClass()) !== null && $class->name === 'Dwoo_Compiler') {
+				continue;
+			}
+			if ($param->getName() === 'rest' && $param->isArray() === true) {
+				$out[] = array('*', $param->isOptional(), null);
+				continue;
+			}
+			$out[] = array($param->getName(), $param->isOptional(), $param->isOptional() ? $param->getDefaultValue() : null);
+		}
+
+		return $out;
+	}
+
+	/**
+	 * returns a default instance of this compiler, used by default by all Dwoo templates that do not have a
+	 * specific compiler assigned and when you do not override the default compiler factory function
+	 *
+	 * @see Dwoo_Core::setDefaultCompilerFactory()
+	 * @return Dwoo_Compiler
+	 */
+	public static function compilerFactory()
+	{
+		if (self::$instance === null) {
+			new self;
+		}
+		return self::$instance;
+	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Core.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Core.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Core.php	(revision 755)
@@ -0,0 +1,1607 @@
+<?php
+
+define('DWOO_DIRECTORY', dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR);
+
+/**
+ * main dwoo class, allows communication between the compiler, template and data classes
+ *
+ * <pre>
+ * requirements :
+ *  php 5.2.0 or above (might work below, it's a rough estimate)
+ *  SPL and PCRE extensions (for php versions prior to 5.3.0)
+ *  mbstring extension for some string manipulation plugins (especially if you intend to use UTF-8)
+ * recommended :
+ *  hash extension (for Dwoo_Template_String - minor performance boost)
+ *
+ * project created :
+ *  2008-01-05
+ * </pre>
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.1.0
+ * @date       2009-07-18
+ * @package    Dwoo
+ */
+class Dwoo_Core
+{
+    /**
+     * current version number
+     *
+     * @var string
+     */
+    const VERSION = '1.1.1';
+
+    /**
+     * unique number of this dwoo release
+     *
+     * this can be used by templates classes to check whether the compiled template
+     * has been compiled before this release or not, so that old templates are
+     * recompiled automatically when Dwoo is updated
+     */
+    const RELEASE_TAG = 17;
+
+    /**#@+
+     * constants that represents all plugin types
+     *
+     * these are bitwise-operation-safe values to allow multiple types
+     * on a single plugin
+     *
+     * @var int
+     */
+    const CLASS_PLUGIN = 1;
+    const FUNC_PLUGIN = 2;
+    const NATIVE_PLUGIN = 4;
+    const BLOCK_PLUGIN = 8;
+    const COMPILABLE_PLUGIN = 16;
+    const CUSTOM_PLUGIN = 32;
+    const SMARTY_MODIFIER = 64;
+    const SMARTY_BLOCK = 128;
+    const SMARTY_FUNCTION = 256;
+    const PROXY_PLUGIN = 512;
+    const TEMPLATE_PLUGIN = 1024;
+    /**#@-*/
+
+    /**
+     * character set of the template, used by string manipulation plugins
+     *
+     * it must be lowercase, but setCharset() will take care of that
+     *
+     * @see setCharset
+     * @see getCharset
+     * @var string
+     */
+    protected $charset = 'utf-8';
+
+    /**
+     * global variables that are accessible through $dwoo.* in the templates
+     *
+     * default values include:
+     *
+     * $dwoo.version - current version number
+     * $dwoo.ad - a Powered by Dwoo link pointing to dwoo.org
+     * $dwoo.now - the current time
+     * $dwoo.template - the current template filename
+     * $dwoo.charset - the character set used by the template
+     *
+     * on top of that, foreach and other plugins can store special values in there,
+     * see their documentation for more details.
+     *
+     * @private
+     * @var array
+     */
+    public $globals;
+
+    /**
+     * directory where the compiled templates are stored
+     *
+     * defaults to DWOO_COMPILEDIR (= dwoo_dir/compiled by default)
+     *
+     * @var string
+     */
+    protected $compileDir;
+
+    /**
+     * directory where the cached templates are stored
+     *
+     * defaults to DWOO_CACHEDIR (= dwoo_dir/cache by default)
+     *
+     * @var string
+     */
+    protected $cacheDir;
+
+    /**
+     * defines how long (in seconds) the cached files must remain valid
+     *
+     * can be overriden on a per-template basis
+     *
+     * -1 = never delete
+     * 0 = disabled
+     * >0 = duration in seconds
+     *
+     * @var int
+     */
+    protected $cacheTime = 0;
+
+    /**
+     * security policy object
+     *
+     * @var Dwoo_Security_Policy
+     */
+    protected $securityPolicy = null;
+
+    /**
+     * stores the custom plugins callbacks
+     *
+     * @see addPlugin
+     * @see removePlugin
+     * @var array
+     */
+    protected $plugins = array();
+
+    /**
+     * stores the filter callbacks
+     *
+     * @see addFilter
+     * @see removeFilter
+     * @var array
+     */
+    protected $filters = array();
+
+    /**
+     * stores the resource types and associated
+     * classes / compiler classes
+     *
+     * @var array
+     */
+    protected $resources = array
+    (
+        'file'      =>  array
+        (
+            'class'     =>  'Dwoo_Template_File',
+            'compiler'  =>  null
+        ),
+        'string'    =>  array
+        (
+            'class'     =>  'Dwoo_Template_String',
+            'compiler'  =>  null
+        )
+    );
+
+    /**
+     * the dwoo loader object used to load plugins by this dwoo instance
+     *
+     * @var Dwoo_ILoader
+     */
+    protected $loader = null;
+
+    /**
+     * currently rendered template, set to null when not-rendering
+     *
+     * @var Dwoo_ITemplate
+     */
+    protected $template = null;
+
+    /**
+     * stores the instances of the class plugins during template runtime
+     *
+     * @var array
+     */
+    protected $runtimePlugins;
+
+    /**
+     * stores the returned values during template runtime
+     *
+     * @var array
+     */
+    protected $returnData;
+
+    /**
+     * stores the data during template runtime
+     *
+     * @var array
+     * @private
+     */
+    public $data;
+
+    /**
+     * stores the current scope during template runtime
+     *
+     * this should ideally not be accessed directly from outside template code
+     *
+     * @var mixed
+     * @private
+     */
+    public $scope;
+
+    /**
+     * stores the scope tree during template runtime
+     *
+     * @var array
+     */
+    protected $scopeTree;
+
+    /**
+     * stores the block plugins stack during template runtime
+     *
+     * @var array
+     */
+    protected $stack;
+
+    /**
+     * stores the current block plugin at the top of the stack during template runtime
+     *
+     * @var Dwoo_Block_Plugin
+     */
+    protected $curBlock;
+
+    /**
+     * stores the output buffer during template runtime
+     *
+     * @var string
+     */
+    protected $buffer;
+
+    /**
+     * stores plugin proxy
+     *
+     * @var Dwoo_IPluginProxy
+     */
+    protected $pluginProxy;
+
+    /**
+     * constructor, sets the cache and compile dir to the default values if not provided
+     *
+     * @param string $compileDir path to the compiled directory, defaults to lib/compiled
+     * @param string $cacheDir path to the cache directory, defaults to lib/cache
+     */
+    public function __construct($compileDir = null, $cacheDir = null)
+    {
+        if ($compileDir !== null) {
+            $this->setCompileDir($compileDir);
+        }
+        if ($cacheDir !== null) {
+            $this->setCacheDir($cacheDir);
+        }
+        $this->initGlobals();
+    }
+
+    /**
+     * resets some runtime variables to allow a cloned object to be used to render sub-templates
+     */
+    public function __clone()
+    {
+        $this->template = null;
+        unset($this->data);
+        unset($this->returnData);
+    }
+
+    /**
+     * outputs the template instead of returning it, this is basically a shortcut for get(*, *, *, true)
+     *
+     * @see get
+     * @param mixed $tpl template, can either be a Dwoo_ITemplate object (i.e. Dwoo_Template_File), a valid path to a template, or
+     *                   a template as a string it is recommended to provide a Dwoo_ITemplate as it will probably make things faster,
+     *                   especially if you render a template multiple times
+     * @param mixed $data the data to use, can either be a Dwoo_IDataProvider object (i.e. Dwoo_Data) or an associative array. if you're
+     *                    rendering the template from cache, it can be left null
+     * @param Dwoo_ICompiler $compiler the compiler that must be used to compile the template, if left empty a default
+     *                                Dwoo_Compiler will be used.
+     * @return string nothing or the template output if $output is true
+     */
+    public function output($tpl, $data = array(), Dwoo_ICompiler $compiler = null)
+    {
+        return $this->get($tpl, $data, $compiler, true);
+    }
+
+    /**
+     * returns the given template rendered using the provided data and optional compiler
+     *
+     * @param mixed $tpl template, can either be a Dwoo_ITemplate object (i.e. Dwoo_Template_File), a valid path to a template, or
+     *                   a template as a string it is recommended to provide a Dwoo_ITemplate as it will probably make things faster,
+     *                   especially if you render a template multiple times
+     * @param mixed $data the data to use, can either be a Dwoo_IDataProvider object (i.e. Dwoo_Data) or an associative array. if you're
+     *                    rendering the template from cache, it can be left null
+     * @param Dwoo_ICompiler $compiler the compiler that must be used to compile the template, if left empty a default
+     *                                Dwoo_Compiler will be used.
+     * @param bool $output flag that defines whether the function returns the output of the template (false, default) or echoes it directly (true)
+     * @return string nothing or the template output if $output is false
+     */
+    public function get($_tpl, $data = array(), $_compiler = null, $_output = false)
+    {
+        // a render call came from within a template, so we need a new dwoo instance in order to avoid breaking this one
+        if ($this->template instanceof Dwoo_ITemplate) {
+            $clone = clone $this;
+            return $clone->get($_tpl, $data, $_compiler, $_output);
+        }
+
+        // auto-create template if required
+        if ($_tpl instanceof Dwoo_ITemplate) {
+            // valid, skip
+        } elseif (is_string($_tpl) && file_exists($_tpl)) {
+            $_tpl = new Dwoo_Template_File($_tpl);
+        } else {
+            throw new Dwoo_Exception('Dwoo->get/Dwoo->output\'s first argument must be a Dwoo_ITemplate (i.e. Dwoo_Template_File) or a valid path to a template file', E_USER_NOTICE);
+        }
+
+        // save the current template, enters render mode at the same time
+        // if another rendering is requested it will be proxied to a new Dwoo_Core(instance
+        $this->template = $_tpl;
+
+        // load data
+        if ($data instanceof Dwoo_IDataProvider) {
+            $this->data = $data->getData();
+        } elseif (is_array($data)) {
+            $this->data = $data;
+        } elseif ($data instanceof ArrayAccess) {
+            $this->data = $data;
+        } else {
+            throw new Dwoo_Exception('Dwoo->get/Dwoo->output\'s data argument must be a Dwoo_IDataProvider object (i.e. Dwoo_Data) or an associative array', E_USER_NOTICE);
+        }
+
+        $this->globals['template'] = $_tpl->getName();
+        $this->initRuntimeVars($_tpl);
+
+        // try to get cached template
+        $file = $_tpl->getCachedTemplate($this);
+        $doCache = $file === true;
+        $cacheLoaded = is_string($file);
+
+        if ($cacheLoaded === true) {
+            // cache is present, run it
+            if ($_output === true) {
+                include $file;
+                $this->template = null;
+            } else {
+                ob_start();
+                include $file;
+                $this->template = null;
+                return ob_get_clean();
+            }
+        } else {
+            // no cache present
+            if ($doCache === true) {
+                $dynamicId = uniqid();
+            }
+
+            // render template
+            $compiledTemplate = $_tpl->getCompiledTemplate($this, $_compiler);
+            $out = include $compiledTemplate;
+
+            // template returned false so it needs to be recompiled
+            if ($out === false) {
+                $_tpl->forceCompilation();
+                $compiledTemplate = $_tpl->getCompiledTemplate($this, $_compiler);
+                $out = include $compiledTemplate;
+            }
+
+            if ($doCache === true) {
+                $out = preg_replace('/(<%|%>|<\?php|<\?|\?>)/', '<?php /*'.$dynamicId.'*/ echo \'$1\'; ?>', $out);
+                if (!class_exists('Dwoo_plugin_dynamic', false)) {
+                    $this->getLoader()->loadPlugin('dynamic');
+                }
+                $out = Dwoo_Plugin_dynamic::unescape($out, $dynamicId, $compiledTemplate);
+            }
+
+            // process filters
+            foreach ($this->filters as $filter) {
+                if (is_array($filter) && $filter[0] instanceof Dwoo_Filter) {
+                    $out = call_user_func($filter, $out);
+                } else {
+                    $out = call_user_func($filter, $this, $out);
+                }
+            }
+
+            if ($doCache === true) {
+                // building cache
+                $file = $_tpl->cache($this, $out);
+
+                // run it from the cache to be sure dynamics are rendered
+                if ($_output === true) {
+                    include $file;
+                    // exit render mode
+                    $this->template = null;
+                } else {
+                    ob_start();
+                    include $file;
+                    // exit render mode
+                    $this->template = null;
+                    return ob_get_clean();
+                }
+            } else {
+                // no need to build cache
+                // exit render mode
+                $this->template = null;
+                // output
+                if ($_output === true) {
+                    echo $out;
+                }
+                return $out;
+            }
+        }
+    }
+
+    /**
+     * re-initializes the globals array before each template run
+     *
+     * this method is only callede once when the Dwoo object is created
+     */
+    protected function initGlobals()
+    {
+        $this->globals = array
+        (
+            'version'   =>  self::VERSION,
+            'ad'        =>  '<a href="http://dwoo.org/">Powered by Dwoo</a>',
+            'now'       =>  $_SERVER['REQUEST_TIME'],
+            'charset'   =>  $this->charset,
+        );
+    }
+
+    /**
+     * re-initializes the runtime variables before each template run
+     *
+     * override this method to inject data in the globals array if needed, this
+     * method is called before each template execution
+     *
+     * @param Dwoo_ITemplate $tpl the template that is going to be rendered
+     */
+    protected function initRuntimeVars(Dwoo_ITemplate $tpl)
+    {
+        $this->runtimePlugins = array();
+        $this->scope =& $this->data;
+        $this->scopeTree = array();
+        $this->stack = array();
+        $this->curBlock = null;
+        $this->buffer = '';
+        $this->returnData = array();
+    }
+
+    /*
+     * --------- settings functions ---------
+     */
+
+    /**
+     * adds a custom plugin that is not in one of the plugin directories
+     *
+     * @param string $name the plugin name to be used in the templates
+     * @param callback $callback the plugin callback, either a function name,
+     *                           a class name or an array containing an object
+     *                           or class name and a method name
+     * @param bool $compilable if set to true, the plugin is assumed to be compilable
+     */
+    public function addPlugin($name, $callback, $compilable = false)
+    {
+        $compilable = $compilable ? self::COMPILABLE_PLUGIN : 0;
+        if (is_array($callback)) {
+            if (is_subclass_of(is_object($callback[0]) ? get_class($callback[0]) : $callback[0], 'Dwoo_Block_Plugin')) {
+                $this->plugins[$name] = array('type'=>self::BLOCK_PLUGIN | $compilable, 'callback'=>$callback, 'class'=>(is_object($callback[0]) ? get_class($callback[0]) : $callback[0]));
+            } else {
+                $this->plugins[$name] = array('type'=>self::CLASS_PLUGIN | $compilable, 'callback'=>$callback, 'class'=>(is_object($callback[0]) ? get_class($callback[0]) : $callback[0]), 'function'=>$callback[1]);
+            }
+        } elseif (class_exists($callback, false)) {
+            if (is_subclass_of($callback, 'Dwoo_Block_Plugin')) {
+                $this->plugins[$name] = array('type'=>self::BLOCK_PLUGIN | $compilable, 'callback'=>$callback, 'class'=>$callback);
+            } else {
+                $this->plugins[$name] = array('type'=>self::CLASS_PLUGIN | $compilable, 'callback'=>$callback, 'class'=>$callback, 'function'=>($compilable ? 'compile' : 'process'));
+            }
+        } elseif (function_exists($callback)) {
+            $this->plugins[$name] = array('type'=>self::FUNC_PLUGIN | $compilable, 'callback'=>$callback);
+        } else {
+            throw new Dwoo_Exception('Callback could not be processed correctly, please check that the function/class you used exists');
+        }
+    }
+
+    /**
+     * removes a custom plugin
+     *
+     * @param string $name the plugin name
+     */
+    public function removePlugin($name)
+    {
+        if (isset($this->plugins[$name])) {
+            unset($this->plugins[$name]);
+        }
+    }
+
+    /**
+     * adds a filter to this Dwoo instance, it will be used to filter the output of all the templates rendered by this instance
+     *
+     * @param mixed $callback a callback or a filter name if it is autoloaded from a plugin directory
+     * @param bool $autoload if true, the first parameter must be a filter name from one of the plugin directories
+     */
+    public function addFilter($callback, $autoload = false)
+    {
+        if ($autoload) {
+            $class = 'Dwoo_Filter_'.$callback;
+
+            if (!class_exists($class, false) && !function_exists($class)) {
+                try {
+                    $this->getLoader()->loadPlugin($callback);
+                } catch (Dwoo_Exception $e) {
+                    if (strstr($callback, 'Dwoo_Filter_')) {
+                        throw new Dwoo_Exception('Wrong filter name : '.$callback.', the "Dwoo_Filter_" prefix should not be used, please only use "'.str_replace('Dwoo_Filter_', '', $callback).'"');
+                    } else {
+                        throw new Dwoo_Exception('Wrong filter name : '.$callback.', when using autoload the filter must be in one of your plugin dir as "name.php" containg a class or function named "Dwoo_Filter_name"');
+                    }
+                }
+            }
+
+            if (class_exists($class, false)) {
+                $callback = array(new $class($this), 'process');
+            } elseif (function_exists($class)) {
+                $callback = $class;
+            } else {
+                throw new Dwoo_Exception('Wrong filter name : '.$callback.', when using autoload the filter must be in one of your plugin dir as "name.php" containg a class or function named "Dwoo_Filter_name"');
+            }
+
+            $this->filters[] = $callback;
+        } else {
+            $this->filters[] = $callback;
+        }
+    }
+
+    /**
+     * removes a filter
+     *
+     * @param mixed $callback callback or filter name if it was autoloaded
+     */
+    public function removeFilter($callback)
+    {
+        if (($index = array_search('Dwoo_Filter_'.$callback, $this->filters, true)) !== false) {
+            unset($this->filters[$index]);
+        } elseif (($index = array_search($callback, $this->filters, true)) !== false) {
+            unset($this->filters[$index]);
+        } else  {
+            $class = 'Dwoo_Filter_' . $callback;
+            foreach ($this->filters as $index=>$filter) {
+                if (is_array($filter) && $filter[0] instanceof $class) {
+                    unset($this->filters[$index]);
+                    break;
+                }
+            }
+        }
+    }
+
+    /**
+     * adds a resource or overrides a default one
+     *
+     * @param string $name the resource name
+     * @param string $class the resource class (which must implement Dwoo_ITemplate)
+     * @param callback $compilerFactory the compiler factory callback, a function that must return a compiler instance used to compile this resource, if none is provided. by default it will produce a Dwoo_Compiler object
+     */
+    public function addResource($name, $class, $compilerFactory = null)
+    {
+        if (strlen($name) < 2) {
+            throw new Dwoo_Exception('Resource names must be at least two-character long to avoid conflicts with Windows paths');
+        }
+
+        if (!class_exists($class)) {
+            throw new Dwoo_Exception('Resource class does not exist');
+        }
+
+        $interfaces = class_implements($class);
+        if (in_array('Dwoo_ITemplate', $interfaces) === false) {
+            throw new Dwoo_Exception('Resource class must implement Dwoo_ITemplate');
+        }
+
+        $this->resources[$name] = array('class'=>$class, 'compiler'=>$compilerFactory);
+    }
+
+    /**
+     * removes a custom resource
+     *
+     * @param string $name the resource name
+     */
+    public function removeResource($name)
+    {
+        unset($this->resources[$name]);
+        if ($name==='file') {
+            $this->resources['file'] = array('class'=>'Dwoo_Template_File', 'compiler'=>null);
+        }
+    }
+
+    /*
+     * --------- getters and setters ---------
+     */
+
+    /**
+     * sets the loader object to use to load plugins
+     *
+     * @param Dwoo_ILoader $loader loader object
+     */
+    public function setLoader(Dwoo_ILoader $loader)
+    {
+        $this->loader = $loader;
+    }
+
+    /**
+     * returns the current loader object or a default one if none is currently found
+     *
+     * @param Dwoo_ILoader
+     */
+    public function getLoader()
+    {
+        if ($this->loader === null) {
+            $this->loader = new Dwoo_Loader($this->getCompileDir());
+        }
+
+        return $this->loader;
+    }
+
+    /**
+     * returns the custom plugins loaded
+     *
+     * used by the Dwoo_ITemplate classes to pass the custom plugins to their Dwoo_ICompiler instance
+     *
+     * @return array
+     */
+    public function getCustomPlugins()
+    {
+        return $this->plugins;
+    }
+
+    /**
+     * returns the cache directory with a trailing DIRECTORY_SEPARATOR
+     *
+     * @return string
+     */
+    public function getCacheDir()
+    {
+        if ($this->cacheDir === null) {
+            $this->setCacheDir(DWOO_DIRECTORY.'cache'.DIRECTORY_SEPARATOR);
+        }
+
+        return $this->cacheDir;
+    }
+
+    /**
+     * sets the cache directory and automatically appends a DIRECTORY_SEPARATOR
+     *
+     * @param string $dir the cache directory
+     */
+    public function setCacheDir($dir)
+    {
+        $this->cacheDir = rtrim($dir, '/\\').DIRECTORY_SEPARATOR;
+        if (is_writable($this->cacheDir) === false) {
+            throw new Dwoo_Exception('The cache directory must be writable, chmod "'.$this->cacheDir.'" to make it writable');
+        }
+    }
+
+    /**
+     * returns the compile directory with a trailing DIRECTORY_SEPARATOR
+     *
+     * @return string
+     */
+    public function getCompileDir()
+    {
+        if ($this->compileDir === null) {
+            $this->setCompileDir(DWOO_DIRECTORY.'compiled'.DIRECTORY_SEPARATOR);
+        }
+
+        return $this->compileDir;
+    }
+
+    /**
+     * sets the compile directory and automatically appends a DIRECTORY_SEPARATOR
+     *
+     * @param string $dir the compile directory
+     */
+    public function setCompileDir($dir)
+    {
+        $this->compileDir = rtrim($dir, '/\\').DIRECTORY_SEPARATOR;
+        if (is_writable($this->compileDir) === false) {
+            throw new Dwoo_Exception('The compile directory must be writable, chmod "'.$this->compileDir.'" to make it writable');
+        }
+    }
+
+    /**
+     * returns the default cache time that is used with templates that do not have a cache time set
+     *
+     * @return int the duration in seconds
+     */
+    public function getCacheTime()
+    {
+        return $this->cacheTime;
+    }
+
+    /**
+     * sets the default cache time to use with templates that do not have a cache time set
+     *
+     * @param int $seconds the duration in seconds
+     */
+    public function setCacheTime($seconds)
+    {
+        $this->cacheTime = (int) $seconds;
+    }
+
+    /**
+     * returns the character set used by the string manipulation plugins
+     *
+     * the charset is automatically lowercased
+     *
+     * @return string
+     */
+    public function getCharset()
+    {
+        return $this->charset;
+    }
+
+    /**
+     * sets the character set used by the string manipulation plugins
+     *
+     * the charset will be automatically lowercased
+     *
+     * @param string $charset the character set
+     */
+    public function setCharset($charset)
+    {
+        $this->charset = strtolower((string) $charset);
+    }
+
+    /**
+     * returns the current template being rendered, when applicable, or null
+     *
+     * @return Dwoo_ITemplate|null
+     */
+    public function getTemplate()
+    {
+        return $this->template;
+    }
+
+    /**
+     * sets the current template being rendered
+     *
+     * @param Dwoo_ITemplate $tpl template object
+     */
+    public function setTemplate(Dwoo_ITemplate $tpl)
+    {
+        $this->template = $tpl;
+    }
+
+    /**
+     * sets the default compiler factory function for the given resource name
+     *
+     * a compiler factory must return a Dwoo_ICompiler object pre-configured to fit your needs
+     *
+     * @param string $resourceName the resource name (i.e. file, string)
+     * @param callback $compilerFactory the compiler factory callback
+     */
+    public function setDefaultCompilerFactory($resourceName, $compilerFactory)
+    {
+        $this->resources[$resourceName]['compiler'] = $compilerFactory;
+    }
+
+    /**
+     * returns the default compiler factory function for the given resource name
+     *
+     * @param string $resourceName the resource name
+     * @return callback the compiler factory callback
+     */
+    public function getDefaultCompilerFactory($resourceName)
+    {
+        return $this->resources[$resourceName]['compiler'];
+    }
+
+    /**
+     * sets the security policy object to enforce some php security settings
+     *
+     * use this if untrusted persons can modify templates
+     *
+     * @param Dwoo_Security_Policy $policy the security policy object
+     */
+    public function setSecurityPolicy(Dwoo_Security_Policy $policy = null)
+    {
+        $this->securityPolicy = $policy;
+    }
+
+    /**
+     * returns the current security policy object or null by default
+     *
+     * @return Dwoo_Security_Policy|null the security policy object if any
+     */
+    public function getSecurityPolicy()
+    {
+        return $this->securityPolicy;
+    }
+
+    /**
+     * sets the object that must be used as a plugin proxy when plugin can't be found
+     * by dwoo's loader
+     *
+     * @param Dwoo_IPluginProxy $pluginProxy the proxy object
+     */
+    public function setPluginProxy(Dwoo_IPluginProxy $pluginProxy) {
+        $this->pluginProxy = $pluginProxy;
+    }
+
+    /**
+     * returns the current plugin proxy object or null by default
+     *
+     * @param Dwoo_IPluginProxy|null the proxy object if any
+     */
+    public function getPluginProxy() {
+        return $this->pluginProxy;
+    }
+
+    /*
+     * --------- util functions ---------
+     */
+
+    /**
+     * [util function] checks whether the given template is cached or not
+     *
+     * @param Dwoo_ITemplate $tpl the template object
+     * @return bool
+     */
+    public function isCached(Dwoo_ITemplate $tpl)
+    {
+        return is_string($tpl->getCachedTemplate($this));
+    }
+
+    /**
+     * [util function] clears the cached templates if they are older than the given time
+     *
+     * @param int $olderThan minimum time (in seconds) required for a cached template to be cleared
+     * @return int the amount of templates cleared
+     */
+    public function clearCache($olderThan=-1)
+    {
+        $cacheDirs = new RecursiveDirectoryIterator($this->getCacheDir());
+        $cache = new RecursiveIteratorIterator($cacheDirs);
+        $expired = time() - $olderThan;
+        $count = 0;
+        foreach ($cache as $file) {
+            if ($cache->isDot() || $cache->isDir() || substr($file, -5) !== '.html') {
+                continue;
+            }
+            if ($cache->getCTime() < $expired) {
+                $count += unlink((string) $file) ? 1 : 0;
+            }
+        }
+        return $count;
+    }
+
+    /**
+     * [util function] fetches a template object of the given resource
+     *
+     * @param string $resourceName the resource name (i.e. file, string)
+     * @param string $resourceId the resource identifier (i.e. file path)
+     * @param int $cacheTime the cache time setting for this resource
+     * @param string $cacheId the unique cache identifier
+     * @param string $compileId the unique compiler identifier
+     * @return Dwoo_ITemplate
+     */
+    public function templateFactory($resourceName, $resourceId, $cacheTime = null, $cacheId = null, $compileId = null, Dwoo_ITemplate $parentTemplate = null)
+    {
+        if (isset($this->resources[$resourceName])) {
+            // TODO could be changed to $this->resources[$resourceName]['class']::templateFactory(..) in 5.3 maybe
+            return call_user_func(array($this->resources[$resourceName]['class'], 'templateFactory'), $this, $resourceId, $cacheTime, $cacheId, $compileId, $parentTemplate);
+        } else {
+            throw new Dwoo_Exception('Unknown resource type : '.$resourceName);
+        }
+    }
+
+    /**
+     * [util function] checks if the input is an array or arrayaccess object, optionally it can also check if it's empty
+     *
+     * @param mixed $value the variable to check
+     * @param bool $checkIsEmpty if true, the function will also check if the array|arrayaccess is empty,
+     *                              and return true only if it's not empty
+     * @return int|bool true if it's an array|arrayaccess (or the item count if $checkIsEmpty is true) or false if it's not an array|arrayaccess (or 0 if $checkIsEmpty is true)
+     */
+    public function isArray($value, $checkIsEmpty=false)
+    {
+        if (is_array($value) === true || $value instanceof ArrayAccess) {
+            if ($checkIsEmpty === false) {
+                return true;
+            } else {
+                return $this->count($value);
+            }
+        }
+    }
+
+    /**
+     * [util function] checks if the input is an array or a traversable object, optionally it can also check if it's empty
+     *
+     * @param mixed $value the variable to check
+     * @param bool $checkIsEmpty if true, the function will also check if the array|traversable is empty,
+     *                              and return true only if it's not empty
+     * @return int|bool true if it's an array|traversable (or the item count if $checkIsEmpty is true) or false if it's not an array|traversable (or 0 if $checkIsEmpty is true)
+     */
+    public function isTraversable($value, $checkIsEmpty=false)
+    {
+        if (is_array($value) === true) {
+            if ($checkIsEmpty === false) {
+                return true;
+            } else {
+                return count($value) > 0;
+            }
+        } elseif ($value instanceof Traversable) {
+            if ($checkIsEmpty === false) {
+                return true;
+            } else {
+                return $this->count($value);
+            }
+        }
+        return false;
+    }
+
+    /**
+     * [util function] counts an array or arrayaccess/traversable object
+     * @param mixed $value
+     * @return int|bool the count for arrays and objects that implement countable, true for other objects that don't, and 0 for empty elements
+     */
+    public function count($value)
+    {
+        if (is_array($value) === true || $value instanceof Countable) {
+            return count($value);
+        } elseif ($value instanceof ArrayAccess) {
+            if ($value->offsetExists(0)) {
+                return true;
+            }
+        } elseif ($value instanceof Iterator) {
+            $value->rewind();
+            if ($value->valid()) {
+                return true;
+            }
+        } elseif ($value instanceof Traversable) {
+            foreach ($value as $dummy) {
+                return true;
+            }
+        }
+        return 0;
+    }
+
+    /**
+     * [util function] triggers a dwoo error
+     *
+     * @param string $message the error message
+     * @param int $level the error level, one of the PHP's E_* constants
+     */
+    public function triggerError($message, $level=E_USER_NOTICE)
+    {
+        if (!($tplIdentifier = $this->template->getResourceIdentifier())) {
+            $tplIdentifier = $this->template->getResourceName();
+        }
+        trigger_error('Dwoo error (in '.$tplIdentifier.') : '.$message, $level);
+    }
+
+    /*
+     * --------- runtime functions ---------
+     */
+
+    /**
+     * [runtime function] adds a block to the block stack
+     *
+     * @param string $blockName the block name (without Dwoo_Plugin_ prefix)
+     * @param array $args the arguments to be passed to the block's init() function
+     * @return Dwoo_Block_Plugin the newly created block
+     */
+    public function addStack($blockName, array $args=array())
+    {
+        if (isset($this->plugins[$blockName])) {
+            $class = $this->plugins[$blockName]['class'];
+        } else {
+            $class = 'Dwoo_Plugin_'.$blockName;
+        }
+
+        if ($this->curBlock !== null) {
+            $this->curBlock->buffer(ob_get_contents());
+            ob_clean();
+        } else {
+            $this->buffer .= ob_get_contents();
+            ob_clean();
+        }
+
+        $block = new $class($this);
+
+        $cnt = count($args);
+        if ($cnt===0) {
+            $block->init();
+        } elseif ($cnt===1) {
+            $block->init($args[0]);
+        } elseif ($cnt===2) {
+            $block->init($args[0], $args[1]);
+        } elseif ($cnt===3) {
+            $block->init($args[0], $args[1], $args[2]);
+        } elseif ($cnt===4) {
+            $block->init($args[0], $args[1], $args[2], $args[3]);
+        } else {
+            call_user_func_array(array($block,'init'), $args);
+        }
+
+        $this->stack[] = $this->curBlock = $block;
+        return $block;
+    }
+
+    /**
+     * [runtime function] removes the plugin at the top of the block stack
+     *
+     * calls the block buffer() function, followed by a call to end()
+     * and finally a call to process()
+     */
+    public function delStack()
+    {
+        $args = func_get_args();
+
+        $this->curBlock->buffer(ob_get_contents());
+        ob_clean();
+
+        $cnt = count($args);
+        if ($cnt===0) {
+            $this->curBlock->end();
+        } elseif ($cnt===1) {
+            $this->curBlock->end($args[0]);
+        } elseif ($cnt===2) {
+            $this->curBlock->end($args[0], $args[1]);
+        } elseif ($cnt===3) {
+            $this->curBlock->end($args[0], $args[1], $args[2]);
+        } elseif ($cnt===4) {
+            $this->curBlock->end($args[0], $args[1], $args[2], $args[3]);
+        } else {
+            call_user_func_array(array($this->curBlock, 'end'), $args);
+        }
+
+        $tmp = array_pop($this->stack);
+
+        if (count($this->stack) > 0) {
+            $this->curBlock = end($this->stack);
+            $this->curBlock->buffer($tmp->process());
+        } else {
+            $this->curBlock = null;
+            echo $tmp->process();
+        }
+
+        unset($tmp);
+    }
+
+    /**
+     * [runtime function] returns the parent block of the given block
+     *
+     * @param Dwoo_Block_Plugin $block
+     * @return Dwoo_Block_Plugin or false if the given block isn't in the stack
+     */
+    public function getParentBlock(Dwoo_Block_Plugin $block)
+    {
+        $index = array_search($block, $this->stack, true);
+        if ($index !== false && $index > 0) {
+            return $this->stack[$index-1];
+        }
+        return false;
+    }
+
+    /**
+     * [runtime function] finds the closest block of the given type, starting at the top of the stack
+     *
+     * @param string $type the type of plugin you want to find
+     * @return Dwoo_Block_Plugin or false if no plugin of such type is in the stack
+     */
+    public function findBlock($type)
+    {
+        if (isset($this->plugins[$type])) {
+            $type = $this->plugins[$type]['class'];
+        } else {
+            $type = 'Dwoo_Plugin_'.str_replace('Dwoo_Plugin_', '', $type);
+        }
+
+        $keys = array_keys($this->stack);
+        while (($key = array_pop($keys)) !== false) {
+            if ($this->stack[$key] instanceof $type) {
+                return $this->stack[$key];
+            }
+        }
+        return false;
+    }
+
+    /**
+     * [runtime function] returns a Dwoo_Plugin of the given class
+     *
+     * this is so a single instance of every class plugin is created at each template run,
+     * allowing class plugins to have "per-template-run" static variables
+     *
+     * @private
+     * @param string $class the class name
+     * @return mixed an object of the given class
+     */
+    public function getObjectPlugin($class)
+    {
+        if (isset($this->runtimePlugins[$class])) {
+            return $this->runtimePlugins[$class];
+        }
+        return $this->runtimePlugins[$class] = new $class($this);
+    }
+
+    /**
+     * [runtime function] calls the process() method of the given class-plugin name
+     *
+     * @param string $plugName the class plugin name (without Dwoo_Plugin_ prefix)
+     * @param array $params an array of parameters to send to the process() method
+     * @return string the process() return value
+     */
+    public function classCall($plugName, array $params = array())
+    {
+        $class = 'Dwoo_Plugin_'.$plugName;
+
+        $plugin = $this->getObjectPlugin($class);
+
+        $cnt = count($params);
+        if ($cnt===0) {
+            return $plugin->process();
+        } elseif ($cnt===1) {
+            return $plugin->process($params[0]);
+        } elseif ($cnt===2) {
+            return $plugin->process($params[0], $params[1]);
+        } elseif ($cnt===3) {
+            return $plugin->process($params[0], $params[1], $params[2]);
+        } elseif ($cnt===4) {
+            return $plugin->process($params[0], $params[1], $params[2], $params[3]);
+        } else {
+            return call_user_func_array(array($plugin, 'process'), $params);
+        }
+    }
+
+    /**
+     * [runtime function] calls a php function
+     *
+     * @param string $callback the function to call
+     * @param array $params an array of parameters to send to the function
+     * @return mixed the return value of the called function
+     */
+    public function arrayMap($callback, array $params)
+    {
+        if ($params[0] === $this) {
+            $addThis = true;
+            array_shift($params);
+        }
+        if ((is_array($params[0]) || ($params[0] instanceof Iterator && $params[0] instanceof ArrayAccess))) {
+            if (empty($params[0])) {
+                return $params[0];
+            }
+
+            // array map
+            $out = array();
+            $cnt = count($params);
+
+            if (isset($addThis)) {
+                array_unshift($params, $this);
+                $items = $params[1];
+                $keys = array_keys($items);
+
+                if (is_string($callback) === false) {
+                    while (($i = array_shift($keys)) !== null) {
+                        $out[] = call_user_func_array($callback, array(1=>$items[$i]) + $params);
+                    }
+                } elseif ($cnt===1) {
+                    while (($i = array_shift($keys)) !== null) {
+                        $out[] = $callback($this, $items[$i]);
+                    }
+                } elseif ($cnt===2) {
+                    while (($i = array_shift($keys)) !== null) {
+                        $out[] = $callback($this, $items[$i], $params[2]);
+                    }
+                } elseif ($cnt===3) {
+                    while (($i = array_shift($keys)) !== null) {
+                        $out[] = $callback($this, $items[$i], $params[2], $params[3]);
+                    }
+                } else {
+                    while (($i = array_shift($keys)) !== null) {
+                        $out[] = call_user_func_array($callback, array(1=>$items[$i]) + $params);
+                    }
+                }
+            } else {
+                $items = $params[0];
+                $keys = array_keys($items);
+
+                if (is_string($callback) === false) {
+                    while (($i = array_shift($keys)) !== null) {
+                        $out[] = call_user_func_array($callback, array($items[$i]) + $params);
+                    }
+                } elseif ($cnt===1) {
+                    while (($i = array_shift($keys)) !== null) {
+                        $out[] = $callback($items[$i]);
+                    }
+                } elseif ($cnt===2) {
+                    while (($i = array_shift($keys)) !== null) {
+                        $out[] = $callback($items[$i], $params[1]);
+                    }
+                } elseif ($cnt===3) {
+                    while (($i = array_shift($keys)) !== null) {
+                        $out[] = $callback($items[$i], $params[1], $params[2]);
+                    }
+                } elseif ($cnt===4) {
+                    while (($i = array_shift($keys)) !== null) {
+                        $out[] = $callback($items[$i], $params[1], $params[2], $params[3]);
+                    }
+                } else {
+                    while (($i = array_shift($keys)) !== null) {
+                        $out[] = call_user_func_array($callback, array($items[$i]) + $params);
+                    }
+                }
+            }
+            return $out;
+        } else {
+            return $params[0];
+        }
+    }
+
+    /**
+     * [runtime function] reads a variable into the given data array
+     *
+     * @param string $varstr the variable string, using dwoo variable syntax (i.e. "var.subvar[subsubvar]->property")
+     * @param mixed $data the data array or object to read from
+     * @param bool $safeRead if true, the function will check whether the index exists to prevent any notices from being output
+     * @return mixed
+     */
+    public function readVarInto($varstr, $data, $safeRead = false)
+    {
+        if ($data === null) {
+            return null;
+        }
+
+        if (is_array($varstr) === false) {
+            preg_match_all('#(\[|->|\.)?((?:[^.[\]-]|-(?!>))+)\]?#i', $varstr, $m);
+        } else {
+            $m = $varstr;
+        }
+        unset($varstr);
+
+        while (list($k, $sep) = each($m[1])) {
+            if ($sep === '.' || $sep === '[' || $sep === '') {
+                // strip enclosing quotes if present
+                $m[2][$k] = preg_replace('#^(["\']?)(.*?)\1$#', '$2', $m[2][$k]);
+
+                if ((is_array($data) || $data instanceof ArrayAccess) && ($safeRead === false || isset($data[$m[2][$k]]))) {
+                    $data = $data[$m[2][$k]];
+                } else {
+                    return null;
+                }
+            } else {
+                if (is_object($data) && ($safeRead === false || isset($data->$m[2][$k]))) {
+                    $data = $data->$m[2][$k];
+                } else {
+                    return null;
+                }
+            }
+        }
+
+        return $data;
+    }
+
+    /**
+     * [runtime function] reads a variable into the parent scope
+     *
+     * @param int $parentLevels the amount of parent levels to go from the current scope
+     * @param string $varstr the variable string, using dwoo variable syntax (i.e. "var.subvar[subsubvar]->property")
+     * @return mixed
+     */
+    public function readParentVar($parentLevels, $varstr = null)
+    {
+        $tree = $this->scopeTree;
+        $cur = $this->data;
+
+        while ($parentLevels--!==0) {
+            array_pop($tree);
+        }
+
+        while (($i = array_shift($tree)) !== null) {
+            if (is_object($cur)) {
+                $cur = $cur->$i;
+            } else {
+                $cur = $cur[$i];
+            }
+        }
+
+        if ($varstr!==null) {
+            return $this->readVarInto($varstr, $cur);
+        } else {
+            return $cur;
+        }
+    }
+
+    /**
+     * [runtime function] reads a variable into the current scope
+     *
+     * @param string $varstr the variable string, using dwoo variable syntax (i.e. "var.subvar[subsubvar]->property")
+     * @return mixed
+     */
+    public function readVar($varstr)
+    {
+        if (is_array($varstr)===true) {
+            $m = $varstr;
+            unset($varstr);
+        } else {
+            if (strstr($varstr, '.') === false && strstr($varstr, '[') === false && strstr($varstr, '->') === false) {
+                if ($varstr === 'dwoo') {
+                    return $this->globals;
+                } elseif ($varstr === '__' || $varstr === '_root' ) {
+                    return $this->data;
+                    $varstr = substr($varstr, 6);
+                } elseif ($varstr === '_' || $varstr === '_parent') {
+                    $varstr = '.'.$varstr;
+                    $tree = $this->scopeTree;
+                    $cur = $this->data;
+                    array_pop($tree);
+
+                    while (($i = array_shift($tree)) !== null) {
+                        if (is_object($cur)) {
+                            $cur = $cur->$i;
+                        } else {
+                            $cur = $cur[$i];
+                        }
+                    }
+
+                    return $cur;
+                }
+
+                $cur = $this->scope;
+
+                if (isset($cur[$varstr])) {
+                    return $cur[$varstr];
+                } else {
+                    return null;
+                }
+            }
+
+            if (substr($varstr, 0, 1) === '.') {
+                $varstr = 'dwoo'.$varstr;
+            }
+
+            preg_match_all('#(\[|->|\.)?((?:[^.[\]-]|-(?!>))+)\]?#i', $varstr, $m);
+        }
+
+        $i = $m[2][0];
+        if ($i === 'dwoo') {
+            $cur = $this->globals;
+            array_shift($m[2]);
+            array_shift($m[1]);
+            switch ($m[2][0]) {
+
+            case 'get':
+                $cur = $_GET;
+                break;
+            case 'post':
+                $cur = $_POST;
+                break;
+            case 'session':
+                $cur = $_SESSION;
+                break;
+            case 'cookies':
+            case 'cookie':
+                $cur = $_COOKIE;
+                break;
+            case 'server':
+                $cur = $_SERVER;
+                break;
+            case 'env':
+                $cur = $_ENV;
+                break;
+            case 'request':
+                $cur = $_REQUEST;
+                break;
+            case 'const':
+                array_shift($m[2]);
+                if (defined($m[2][0])) {
+                    return constant($m[2][0]);
+                } else {
+                    return null;
+                }
+
+            }
+            if ($cur !== $this->globals) {
+                array_shift($m[2]);
+                array_shift($m[1]);
+            }
+        } elseif ($i === '__' || $i === '_root') {
+            $cur = $this->data;
+            array_shift($m[2]);
+            array_shift($m[1]);
+        } elseif ($i === '_' || $i === '_parent') {
+            $tree = $this->scopeTree;
+            $cur = $this->data;
+
+            while (true) {
+                array_pop($tree);
+                array_shift($m[2]);
+                array_shift($m[1]);
+                if (current($m[2]) === '_' || current($m[2]) === '_parent') {
+                    continue;
+                }
+
+                while (($i = array_shift($tree)) !== null) {
+                    if (is_object($cur)) {
+                        $cur = $cur->$i;
+                    } else {
+                        $cur = $cur[$i];
+                    }
+                }
+                break;
+            }
+        } else {
+            $cur = $this->scope;
+        }
+
+        while (list($k, $sep) = each($m[1])) {
+            if ($sep === '.' || $sep === '[' || $sep === '') {
+                if ((is_array($cur) || $cur instanceof ArrayAccess) && isset($cur[$m[2][$k]])) {
+                    $cur = $cur[$m[2][$k]];
+                } else {
+                    return null;
+                }
+            } elseif ($sep === '->') {
+                if (is_object($cur)) {
+                    $cur = $cur->$m[2][$k];
+                } else {
+                    return null;
+                }
+            } else {
+                return null;
+            }
+        }
+
+        return $cur;
+    }
+
+    /**
+     * [runtime function] assign the value to the given variable
+     *
+     * @param mixed $value the value to assign
+     * @param string $scope the variable string, using dwoo variable syntax (i.e. "var.subvar[subsubvar]->property")
+     * @return bool true if assigned correctly or false if a problem occured while parsing the var string
+     */
+    public function assignInScope($value, $scope)
+    {
+        $tree =& $this->scopeTree;
+        $data =& $this->data;
+
+        if (!is_string($scope)) {
+            return $this->triggerError('Assignments must be done into strings, ('.gettype($scope).') '.var_export($scope, true).' given', E_USER_ERROR);
+        }
+        if (strstr($scope, '.') === false && strstr($scope, '->') === false) {
+            $this->scope[$scope] = $value;
+        } else {
+            // TODO handle _root/_parent scopes ?
+            preg_match_all('#(\[|->|\.)?([^.[\]-]+)\]?#i', $scope, $m);
+
+            $cur =& $this->scope;
+            $last = array(array_pop($m[1]), array_pop($m[2]));
+
+            while (list($k, $sep) = each($m[1])) {
+                if ($sep === '.' || $sep === '[' || $sep === '') {
+                    if (is_array($cur) === false) {
+                        $cur = array();
+                    }
+                    $cur =& $cur[$m[2][$k]];
+                } elseif ($sep === '->') {
+                    if (is_object($cur) === false) {
+                        $cur = new stdClass;
+                    }
+                    $cur =& $cur->$m[2][$k];
+                } else {
+                    return false;
+                }
+            }
+
+            if ($last[0] === '.' || $last[0] === '[' || $last[0] === '') {
+                if (is_array($cur) === false) {
+                    $cur = array();
+                }
+                $cur[$last[1]] = $value;
+            } elseif ($last[0] === '->') {
+                if (is_object($cur) === false) {
+                    $cur = new stdClass;
+                }
+                $cur->$last[1] = $value;
+            } else {
+                return false;
+            }
+        }
+    }
+
+    /**
+     * [runtime function] sets the scope to the given scope string or array
+     *
+     * @param mixed $scope a string i.e. "level1.level2" or an array i.e. array("level1", "level2")
+     * @param bool $absolute if true, the scope is set from the top level scope and not from the current scope
+     * @return array the current scope tree
+     */
+    public function setScope($scope, $absolute = false)
+    {
+        $old = $this->scopeTree;
+
+        if (is_string($scope)===true) {
+            $scope = explode('.', $scope);
+        }
+
+        if ($absolute===true) {
+            $this->scope =& $this->data;
+            $this->scopeTree = array();
+        }
+
+        while (($bit = array_shift($scope)) !== null) {
+            if ($bit === '_' || $bit === '_parent') {
+                array_pop($this->scopeTree);
+                $this->scope =& $this->data;
+                $cnt = count($this->scopeTree);
+                for ($i=0;$i<$cnt;$i++)
+                    $this->scope =& $this->scope[$this->scopeTree[$i]];
+            } elseif ($bit === '__' || $bit === '_root') {
+                $this->scope =& $this->data;
+                $this->scopeTree = array();
+            } elseif (isset($this->scope[$bit])) {
+                if($this->scope instanceof ArrayAccess) {
+                    $tmp = $this->scope[$bit];
+                    $this->scope =& $tmp;
+                } else {
+                    $this->scope =& $this->scope[$bit];
+                }
+                $this->scopeTree[] = $bit;
+            } else {
+                unset($this->scope);
+                $this->scope = null;
+            }
+        }
+
+        return $old;
+    }
+
+    /**
+     * [runtime function] returns the entire data array
+     *
+     * @return array
+     */
+    public function getData()
+    {
+        return $this->data;
+    }
+
+    /**
+     * [runtime function] sets a return value for the currently running template
+     *
+     * @param string $name var name
+     * @param mixed $value var value
+     */
+    public function setReturnValue($name, $value)
+    {
+        $this->returnData[$name] = $value;
+    }
+
+    /**
+     * [runtime function] retrieves the return values set by the template
+     *
+     * @return array
+     */
+    public function getReturnValues()
+    {
+        return $this->returnData;
+    }
+
+    /**
+     * [runtime function] returns a reference to the current scope
+     *
+     * @return &mixed
+     */
+    public function &getScope()
+    {
+        return $this->scope;
+    }
+
+    /**
+     * Redirects all calls to unexisting to plugin proxy.
+     *
+     * @param string Method name
+     * @param array  List of arguments
+     * @return mixed
+     */
+    public function __call($method, $args) {
+        $proxy = $this->getPluginProxy();
+        if (!$proxy) {
+            throw new Dwoo_Exception('Call to undefined method '.__CLASS__.'::'.$method.'()');
+        }
+        return call_user_func_array($proxy->getCallback($method), $args);
+    }
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Data.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Data.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Data.php	(revision 755)
@@ -0,0 +1,250 @@
+<?php
+
+/**
+ * dwoo data object, use it for complex data assignments or if you want to easily pass it
+ * around multiple functions to avoid passing an array by reference
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+class Dwoo_Data implements Dwoo_IDataProvider
+{
+	/**
+	 * data array
+	 *
+	 * @var array
+	 */
+	protected $data = array();
+
+	/**
+	 * returns the data array
+	 *
+	 * @return array
+	 */
+	public function getData()
+	{
+		return $this->data;
+	}
+
+	/**
+	 * clears a the entire data or only the given key
+	 *
+	 * @param array|string $name clears only one value if you give a name, multiple values if
+	 * 							  you give an array of names, or the entire data if left null
+	 */
+	public function clear($name = null)
+	{
+		if ($name === null) {
+			$this->data = array();
+		} elseif (is_array($name)) {
+			foreach ($name as $index)
+				unset($this->data[$index]);
+		} else {
+			unset($this->data[$name]);
+		}
+	}
+
+	/**
+	 * overwrites the entire data with the given array
+	 *
+	 * @param array $data the new data array to use
+	 */
+	public function setData(array $data)
+	{
+		$this->data = $data;
+	}
+
+	/**
+	 * merges the given array(s) with the current data with array_merge
+	 *
+	 * @param array $data the array to merge
+	 * @param array $data2 $data3 ... other arrays to merge, optional, etc.
+	 */
+	public function mergeData(array $data)
+	{
+		$args = func_get_args();
+		while (list(,$v) = each($args)) {
+			if (is_array($v)) {
+				$this->data = array_merge($this->data, $v);
+			}
+		}
+	}
+
+	/**
+	 * assigns a value or an array of values to the data object
+	 *
+	 * @param array|string $name an associative array of multiple (index=>value) or a string
+	 * 					   that is the index to use, i.e. a value assigned to "foo" will be
+	 * 					   accessible in the template through {$foo}
+	 * @param mixed $val the value to assign, or null if $name was an array
+	 */
+	public function assign($name, $val = null)
+	{
+		if (is_array($name)) {
+			reset($name);
+			while (list($k,$v) = each($name))
+				$this->data[$k] = $v;
+		} else {
+			$this->data[$name] = $val;
+		}
+	}
+   	
+   	/**
+   	 * allows to assign variables using the object syntax
+   	 * 
+   	 * @param string $name the variable name
+   	 * @param string $value the value to assign to it
+   	 */
+   	public function __set($name, $value)
+   	{
+   		$this->assign($name, $value);
+   	}
+
+	/**
+	 * assigns a value by reference to the data object
+	 *
+	 * @param string $name the index to use, i.e. a value assigned to "foo" will be
+	 * 					   accessible in the template through {$foo}
+	 * @param mixed $val the value to assign by reference
+	 */
+	public function assignByRef($name, &$val)
+	{
+		$this->data[$name] =& $val;
+	}
+
+	/**
+	 * appends values or an array of values to the data object
+	 *
+	 * @param array|string $name an associative array of multiple (index=>value) or a string
+	 * 					   that is the index to use, i.e. a value assigned to "foo" will be
+	 * 					   accessible in the template through {$foo}
+	 * @param mixed $val the value to assign, or null if $name was an array
+	 * @param bool $merge true to merge data or false to append, defaults to false
+	 */
+   	public function append($name, $val = null, $merge = false)
+   	{
+   		if (is_array($name)) {
+			foreach ($name as $key=>$val) {
+				if (isset($this->data[$key]) && !is_array($this->data[$key])) {
+					settype($this->data[$key], 'array');
+				}
+
+				if ($merge === true && is_array($val)) {
+					$this->data[$key] = $val + $this->data[$key];
+				} else {
+					$this->data[$key][] = $val;
+				}
+			}
+   		} elseif ($val !== null) {
+			if (isset($this->data[$name]) && !is_array($this->data[$name])) {
+				settype($this->data[$name], 'array');
+			} elseif (!isset($this->data[$name])) {
+				$this->data[$name] = array();
+			}
+
+			if ($merge === true && is_array($val)) {
+				$this->data[$name] = $val + $this->data[$name];
+			} else {
+				$this->data[$name][] = $val;
+			}
+   		}
+   	}
+
+	/**
+	 * appends a value by reference to the data object
+	 *
+	 * @param string $name the index to use, i.e. a value assigned to "foo" will be
+	 * 					   accessible in the template through {$foo}
+	 * @param mixed $val the value to append by reference
+	 * @param bool $merge true to merge data or false to append, defaults to false
+	 */
+   	public function appendByRef($name, &$val, $merge = false)
+   	{
+   		if (isset($this->data[$name]) && !is_array($this->data[$name])) {
+			settype($this->data[$name], 'array');
+		}
+
+   		if ($merge === true && is_array($val)) {
+   			foreach ($val as $key => &$val) {
+   				$this->data[$name][$key] =& $val;
+   			}
+   		} else {
+   			$this->data[$name][] =& $val;
+   		}
+   	}
+   	
+   	/**
+   	 * returns true if the variable has been assigned already, false otherwise
+   	 * 
+   	 * @param string $name the variable name
+   	 * @return bool 
+   	 */
+   	public function isAssigned($name)
+   	{
+   		return isset($this->data[$name]);
+   	}
+   	
+   	/**
+   	 * supports calls to isset($dwooData->var)
+   	 * 
+   	 * @param string $name the variable name
+   	 */
+   	public function __isset($name)
+   	{
+   		return isset($this->data[$name]);
+   	}
+   	
+   	/**
+   	 * unassigns/removes a variable
+   	 * 
+   	 * @param string $name the variable name
+   	 */
+   	public function unassign($name)
+   	{
+   		unset($this->data[$name]);
+   	}
+   	
+   	/**
+   	 * supports unsetting variables using the object syntax
+   	 * 
+   	 * @param string $name the variable name
+   	 */
+   	public function __unset($name)
+   	{
+   		unset($this->data[$name]);
+   	}
+   	
+   	/**
+   	 * returns a variable if it was assigned
+   	 * 
+   	 * @param string $name the variable name
+   	 * @return mixed
+   	 */
+   	public function get($name)
+   	{
+   		return $this->__get($name);
+   	}
+
+   	/**
+   	 * allows to read variables using the object syntax
+   	 * 
+   	 * @param string $name the variable name
+   	 * @return mixed
+   	 */
+   	public function __get($name)
+   	{
+   		if (isset($this->data[$name])) {
+   			return $this->data[$name];
+   		} else {
+   			throw new Dwoo_Exception('Tried to read a value that was not assigned yet : "'.$name.'"');
+   		}
+   	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Exception.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Exception.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Exception.php	(revision 755)
@@ -0,0 +1,19 @@
+<?php
+
+/**
+ * main dwoo exception class
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+class Dwoo_Exception extends Exception
+{
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Filter.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Filter.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Filter.php	(revision 755)
@@ -0,0 +1,44 @@
+<?php
+
+/**
+ * base class for filters
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+abstract class Dwoo_Filter
+{
+	/**
+	 * the dwoo instance that runs this filter
+	 *
+	 * @var Dwoo
+	 */
+	protected $dwoo;
+
+	/**
+	 * constructor, if you override it, call parent::__construct($dwoo); or assign
+	 * the dwoo instance yourself if you need it
+	 *
+	 * @param Dwoo_Core $dwoo the dwoo instance that runs this plugin
+	 */
+	public function __construct(Dwoo_Core $dwoo)
+	{
+		$this->dwoo = $dwoo;
+	}
+
+	/**
+	 * processes the input and returns it filtered
+	 *
+	 * @param string $input the template to process
+	 * @return string
+	 */
+	abstract public function process($input);
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/ICompilable.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/ICompilable.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/ICompilable.php	(revision 755)
@@ -0,0 +1,26 @@
+<?php
+
+/**
+ * interface that represents a compilable plugin
+ *
+ * implement this to notify the compiler that this plugin does not need to be loaded at runtime.
+ *
+ * to implement it right, you must implement <em>public static function compile(Dwoo_Compiler $compiler, $arg, $arg, ...)</em>,
+ * which replaces the <em>process()</em> method (that means <em>compile()</em> should have all arguments it requires).
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+interface Dwoo_ICompilable
+{
+	// this replaces the process function
+	//public static function compile(Dwoo_Compiler $compiler, $arg, $arg, ...);
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/ICompilable/Block.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/ICompilable/Block.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/ICompilable/Block.php	(revision 755)
@@ -0,0 +1,21 @@
+<?php
+
+/**
+ * interface that represents a compilable block plugin
+ *
+ * implement this to notify the compiler that this plugin does not need to be loaded at runtime.
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+interface Dwoo_ICompilable_Block
+{
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/ICompiler.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/ICompiler.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/ICompiler.php	(revision 755)
@@ -0,0 +1,49 @@
+<?php
+
+/**
+ * interface that represents a dwoo compiler
+ *
+ * while implementing this is enough to interact with Dwoo/Dwoo_Templates, it is not
+ * sufficient to interact with Dwoo_Plugins, however the main purpose of creating a
+ * new compiler would be to interact with other/different plugins, that is why this
+ * interface has been left with the minimum requirements.
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+interface Dwoo_ICompiler
+{
+	/**
+	 * compiles the provided string down to php code
+	 *
+	 * @param string $templateStr the template to compile
+	 * @return string a compiled php code string
+	 */
+	public function compile(Dwoo_Core $dwoo, Dwoo_ITemplate $template);
+
+	/**
+	 * adds the custom plugins loaded into Dwoo to the compiler so it can load them
+	 *
+	 * @see Dwoo_Core::addPlugin
+	 * @param array $customPlugins an array of custom plugins
+	 */
+	public function setCustomPlugins(array $customPlugins);
+
+	/**
+	 * sets the security policy object to enforce some php security settings
+	 *
+	 * use this if untrusted persons can modify templates,
+	 * set it on the Dwoo object as it will be passed onto the compiler automatically
+	 *
+	 * @param Dwoo_Security_Policy $policy the security policy object
+	 */
+	public function setSecurityPolicy(Dwoo_Security_Policy $policy = null);
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/IDataProvider.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/IDataProvider.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/IDataProvider.php	(revision 755)
@@ -0,0 +1,25 @@
+<?php
+
+/**
+ * interface that represents a dwoo data object
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+interface Dwoo_IDataProvider
+{
+	/**
+	 * returns the data as an associative array that will be used in the template
+	 *
+	 * @return array
+	 */
+	public function getData();
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/IElseable.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/IElseable.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/IElseable.php	(revision 755)
@@ -0,0 +1,24 @@
+<?php
+
+/**
+ * interface that represents a block plugin that supports the else functionality
+ *
+ * the else block will enter an "hasElse" parameter inside the parameters array
+ * of the closest parent implementing this interface, the hasElse parameter contains
+ * the else output that should be appended to the block's content (see foreach or other
+ * block for examples)
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+interface Dwoo_IElseable
+{
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/ILoader.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/ILoader.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/ILoader.php	(revision 755)
@@ -0,0 +1,30 @@
+<?php
+
+/**
+ * interface for dwoo plugin loaders
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+interface Dwoo_ILoader
+{
+	/**
+	 * loads a plugin file
+	 *
+	 * the second parameter is used to avoid permanent rehashing when using php functions,
+	 * however this means that if you have add a plugin that overrides a php function you have
+	 * to delete the classpath.cache file(s) by hand to force a rehash of the plugins
+	 *
+	 * @param string $class the plugin name, without the Dwoo_Plugin_ prefix
+	 * @param bool $forceRehash if true, the class path caches will be rebuilt if the plugin is not found, in case it has just been added, defaults to true
+	 */
+	public function loadPlugin($class, $forceRehash = true);
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/IPluginProxy.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/IPluginProxy.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/IPluginProxy.php	(revision 755)
@@ -0,0 +1,65 @@
+<?php
+
+/**
+ * interface that represents a dwoo plugin proxy
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Denis Arh <denis@arh.cc>
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Denis Arh, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+interface Dwoo_IPluginProxy
+{
+	/**
+	 * returns true or false to say whether the given plugin is handled by this proxy or not
+	 *
+	 * @param string $name the plugin name
+	 * @return bool true if the plugin is known and usable, otherwise false
+	 */
+	public function handles($name);
+
+	/**
+	 * returns the code (as a string) to call the plugin
+	 * (this will be executed at runtime inside the Dwoo class)
+	 *
+	 * @param string $name the plugin name
+	 * @param array $params a parameter array, array key "*" is the rest array
+	 * @return string
+	 */
+	public function getCode($name, $params);
+
+	/**
+	 * returns a callback to the plugin, this is used with the reflection API to
+	 * find out about the plugin's parameter names etc.
+	 *
+	 * should you need a rest array without the possibility to edit the
+	 * plugin's code, you can provide a callback to some
+	 * other function with the correct parameter signature, i.e. :
+	 * <code>
+	 * return array($this, "callbackHelper");
+	 * // and callbackHelper would be as such:
+	 * public function callbackHelper(array $rest=array()){}
+	 * </code>
+	 *
+	 * @param string $name the plugin name
+	 * @return callback
+	 */
+	public function getCallback($name);
+
+	/**
+	 * returns some code that will check if the plugin is loaded and if not load it
+	 * this is optional, if your plugins are autoloaded or whatever, just return an
+	 * empty string
+	 *
+	 * @param string $name the plugin name
+	 * @return string
+	 */
+	public function getLoader($name);
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/ITemplate.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/ITemplate.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/ITemplate.php	(revision 755)
@@ -0,0 +1,150 @@
+<?php
+
+/**
+ * interface that represents a dwoo template
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.1.0
+ * @date       2009-07-18
+ * @package    Dwoo
+ */
+interface Dwoo_ITemplate
+{
+	/**
+	 * returns the cache duration for this template
+	 *
+	 * defaults to null if it was not provided
+	 *
+	 * @return int|null
+	 */
+	public function getCacheTime();
+
+	/**
+	 * sets the cache duration for this template
+	 *
+	 * can be used to set it after the object is created if you did not provide
+	 * it in the constructor
+	 *
+	 * @param int $seconds duration of the cache validity for this template, if
+	 * null it defaults to the Dwoo instance's cache time. 0 = disable and
+	 * -1 = infinite cache
+	 */
+	public function setCacheTime($seconds = null);
+
+	/**
+	 * returns the cached template output file name, true if it's cache-able but not cached
+	 * or false if it's not cached
+	 *
+	 * @param Dwoo_Core $dwoo the dwoo instance that requests it
+	 * @return string|bool
+	 */
+	public function getCachedTemplate(Dwoo_Core $dwoo);
+
+	/**
+	 * caches the provided output into the cache file
+	 *
+	 * @param Dwoo_Core $dwoo the dwoo instance that requests it
+	 * @param string $output the template output
+	 * @return mixed full path of the cached file or false upon failure
+	 */
+	public function cache(Dwoo_Core $dwoo, $output);
+
+	/**
+	 * clears the cached template if it's older than the given time
+	 *
+	 * @param Dwoo_Core $dwoo the dwoo instance that was used to cache that template
+	 * @param int $olderThan minimum time (in seconds) required for the cache to be cleared
+	 * @return bool true if the cache was not present or if it was deleted, false if it remains there
+	 */
+	public function clearCache(Dwoo_Core $dwoo, $olderThan = -1);
+
+	/**
+	 * returns the compiled template file name
+	 *
+	 * @param Dwoo_Core $dwoo the dwoo instance that requests it
+	 * @param Dwoo_ICompiler $compiler the compiler that must be used
+	 * @return string
+	 */
+	public function getCompiledTemplate(Dwoo_Core $dwoo, Dwoo_ICompiler $compiler = null);
+
+	/**
+	 * returns the template name
+	 *
+	 * @return string
+	 */
+	public function getName();
+
+	/**
+	 * returns the resource name for this template class
+	 *
+	 * @return string
+	 */
+	public function getResourceName();
+
+	/**
+	 * returns the resource identifier for this template or false if it has no identifier
+	 *
+	 * @return string|false
+	 */
+	public function getResourceIdentifier();
+
+	/**
+	 * returns the template source of this template
+	 *
+	 * @return string
+	 */
+	public function getSource();
+
+	/**
+	 * returns an unique string identifying the current version of this template,
+	 * for example a timestamp of the last modified date or a hash of the template source
+	 *
+	 * @return string
+	 */
+	public function getUid();
+
+	/**
+	 * returns the compiler used by this template, if it was just compiled, or null
+	 *
+	 * @return Dwoo_ICompiler
+	 */
+	public function getCompiler();
+
+	/**
+	 * returns some php code that will check if this template has been modified or not
+	 * 
+	 * if the function returns null, the template will be instanciated and then the Uid checked
+	 * 
+	 * @return string
+	 */
+	public function getIsModifiedCode();
+
+	/**
+	 * returns a new template object from the given resource identifier, null if no include is
+	 * possible (resource not found), or false if include is not permitted by this resource type
+	 *
+	 * this method should also check if $dwoo->getSecurityPolicy() is null or not and do the
+	 * necessary permission checks if required, if the security policy prevents the template
+	 * generation it should throw a new Dwoo_Security_Exception with a relevant message
+	 *
+	 * @param mixed $resourceId the resource identifier
+	 * @param int $cacheTime duration of the cache validity for this template,
+	 * 						 if null it defaults to the Dwoo instance that will
+	 * 						 render this template
+	 * @param string $cacheId the unique cache identifier of this page or anything else that
+	 * 						  makes this template's content unique, if null it defaults
+	 * 						  to the current url
+	 * @param string $compileId the unique compiled identifier, which is used to distinguish this
+	 * 							template from others, if null it defaults to the filename+bits of the path
+	 * @param Dwoo_ITemplate $parentTemplate the template that is requesting a new template object (through
+	 * 											an include, extends or any other plugin)
+	 * @return Dwoo_ITemplate|null|false
+	 */
+	public static function templateFactory(Dwoo_Core $dwoo, $resourceId, $cacheTime = null, $cacheId = null, $compileId = null, Dwoo_ITemplate $parentTemplate = null);
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Loader.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Loader.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Loader.php	(revision 755)
@@ -0,0 +1,147 @@
+<?php
+
+/**
+ * handles plugin loading and caching of plugins names/paths relationships
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.1.0
+ * @date       2009-07-18
+ * @package    Dwoo
+ */
+class Dwoo_Loader implements Dwoo_ILoader
+{
+	/**
+	 * stores the plugin directories
+	 *
+	 * @see addDirectory
+	 * @var array
+	 */
+	protected $paths = array();
+
+	/**
+	 * stores the plugins names/paths relationships
+	 * don't edit this on your own, use addDirectory
+	 *
+	 * @see addDirectory
+	 * @var array
+	 */
+	protected $classPath = array();
+
+	/**
+	 * path where class paths cache files are written
+	 *
+	 * @var string
+	 */
+	protected $cacheDir;
+
+	protected $corePluginDir;
+
+	public function __construct($cacheDir)
+	{
+		$this->corePluginDir = DWOO_DIRECTORY . 'plugins';
+		$this->cacheDir = rtrim($cacheDir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
+
+		// include class paths or rebuild paths if the cache file isn't there
+		$cacheFile = $this->cacheDir.'classpath.cache.d'.Dwoo_Core::RELEASE_TAG.'.php';
+		if (file_exists($cacheFile)) {
+			$classpath = file_get_contents($cacheFile);
+			$this->classPath = unserialize($classpath) + $this->classPath;
+		} else {
+			$this->rebuildClassPathCache($this->corePluginDir, $cacheFile);
+		}
+	}
+
+	/**
+	 * rebuilds class paths, scans the given directory recursively and saves all paths in the given file
+	 *
+	 * @param string $path the plugin path to scan
+	 * @param string $cacheFile the file where to store the plugin paths cache, it will be overwritten
+	 */
+	protected function rebuildClassPathCache($path, $cacheFile)
+	{
+		if ($cacheFile!==false) {
+			$tmp = $this->classPath;
+			$this->classPath = array();
+		}
+
+		// iterates over all files/folders
+		$list = glob(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*');
+		if (is_array($list)) {
+			foreach ($list as $f) {
+				if (is_dir($f)) {
+					$this->rebuildClassPathCache($f, false);
+				} else {
+					$this->classPath[str_replace(array('function.','block.','modifier.','outputfilter.','filter.','prefilter.','postfilter.','pre.','post.','output.','shared.','helper.'), '', basename($f, '.php'))] = $f;
+				}
+			}
+		}
+
+		// save in file if it's the first call (not recursed)
+		if ($cacheFile!==false) {
+			if (!file_put_contents($cacheFile, serialize($this->classPath))) {
+				throw new Dwoo_Exception('Could not write into '.$cacheFile.', either because the folder is not there (create it) or because of the chmod configuration (please ensure this directory is writable by php), alternatively you can change the directory used with $dwoo->setCompileDir() or provide a custom loader object with $dwoo->setLoader()');
+			}
+			$this->classPath += $tmp;
+		}
+	}
+
+	/**
+	 * loads a plugin file
+	 *
+	 * @param string $class the plugin name, without the Dwoo_Plugin_ prefix
+	 * @param bool $forceRehash if true, the class path caches will be rebuilt if the plugin is not found, in case it has just been added, defaults to true
+	 */
+	public function loadPlugin($class, $forceRehash = true)
+	{
+		// a new class was added or the include failed so we rebuild the cache
+		if (!isset($this->classPath[$class]) || !(include $this->classPath[$class])) {
+			if ($forceRehash) {
+				$this->rebuildClassPathCache($this->corePluginDir, $this->cacheDir . 'classpath.cache.d'.Dwoo_Core::RELEASE_TAG.'.php');
+				foreach ($this->paths as $path=>$file) {
+					$this->rebuildClassPathCache($path, $file);
+				}
+				if (isset($this->classPath[$class])) {
+					include $this->classPath[$class];
+				} else {
+					throw new Dwoo_Exception('Plugin <em>'.$class.'</em> can not be found, maybe you forgot to bind it if it\'s a custom plugin ?', E_USER_NOTICE);
+				}
+			} else {
+				throw new Dwoo_Exception('Plugin <em>'.$class.'</em> can not be found, maybe you forgot to bind it if it\'s a custom plugin ?', E_USER_NOTICE);
+			}
+		}
+	}
+
+	/**
+	 * adds a plugin directory, the plugins found in the new plugin directory
+	 * will take precedence over the other directories (including the default
+	 * dwoo plugin directory), you can use this for example to override plugins
+	 * in a specific directory for a specific application while keeping all your
+	 * usual plugins in the same place for all applications.
+	 *
+	 * TOCOM don't forget that php functions overrides are not rehashed so you
+	 * need to clear the classpath caches by hand when adding those
+	 *
+	 * @param string $pluginDirectory the plugin path to scan
+	 */
+	public function addDirectory($pluginDirectory)
+	{
+		$pluginDir = realpath($pluginDirectory);
+		if (!$pluginDir) {
+			throw new Dwoo_Exception('Plugin directory does not exist or can not be read : '.$pluginDirectory);
+		}
+		$cacheFile = $this->cacheDir . 'classpath-'.substr(strtr($pluginDir, '/\\:'.PATH_SEPARATOR, '----'), strlen($pluginDir) > 80 ? -80 : 0).'.d'.Dwoo_Core::RELEASE_TAG.'.php';
+		$this->paths[$pluginDir] = $cacheFile;
+		if (file_exists($cacheFile)) {
+			$classpath = file_get_contents($cacheFile);
+			$this->classPath = unserialize($classpath) + $this->classPath;
+		} else {
+			$this->rebuildClassPathCache($pluginDir, $cacheFile);
+		}
+	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Plugin.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Plugin.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Plugin.php	(revision 755)
@@ -0,0 +1,85 @@
+<?php
+
+/**
+ * base plugin class
+ *
+ * you have to implement the <em>process()</em> method, it will receive the parameters that
+ * are in the template code
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+abstract class Dwoo_Plugin
+{
+	/**
+	 * the dwoo instance that runs this plugin
+	 *
+	 * @var Dwoo
+	 */
+	protected $dwoo;
+
+	/**
+	 * constructor, if you override it, call parent::__construct($dwoo); or assign
+	 * the dwoo instance yourself if you need it
+	 *
+	 * @param Dwoo_Core $dwoo the dwoo instance that runs this plugin
+	 */
+	public function __construct(Dwoo_Core $dwoo)
+	{
+		$this->dwoo = $dwoo;
+	}
+
+	// plugins should always implement :
+	// public function process($arg, $arg, ...)
+	// or for block plugins :
+	// public function init($arg, $arg, ...)
+
+	// this could be enforced with :
+	// abstract public function process(...);
+	// if my feature request gets enough interest one day
+	// see => http://bugs.php.net/bug.php?id=44043
+
+	/**
+	 * utility function that converts an array of compiled parameters (or rest array) to a string of xml/html tag attributes
+	 *
+	 * this is to be used in preProcessing or postProcessing functions, example :
+	 *  $p = $compiler->getCompiledParams($params);
+	 *  // get only the rest array as attributes
+	 *  $attributes = Dwoo_Plugin::paramsToAttributes($p['*']);
+	 *  // get all the parameters as attributes (if there is a rest array, it will be included)
+	 *  $attributes = Dwoo_Plugin::paramsToAttributes($p);
+	 *
+	 * @param array $params an array of attributeName=>value items that will be compiled to be ready for inclusion in a php string
+	 * @param string $delim the string delimiter you want to use (defaults to ')
+	 * @return string
+	 */
+	public static function paramsToAttributes(array $params, $delim = '\'')
+	{
+		if (isset($params['*'])) {
+			$params = array_merge($params, $params['*']);
+			unset($params['*']);
+		}
+
+		$out = '';
+		foreach ($params as $attr=>$val) {
+			$out .= ' '.$attr.'=';
+			if (trim($val, '"\'')=='' || $val=='null') {
+				$out .= str_replace($delim, '\\'.$delim, '""');
+			} elseif (substr($val, 0, 1) === $delim && substr($val, -1) === $delim) {
+				$out .= str_replace($delim, '\\'.$delim, '"'.substr($val, 1, -1).'"');
+			} else {
+				$out .= str_replace($delim, '\\'.$delim, '"') . $delim . '.'.$val.'.' . $delim . str_replace($delim, '\\'.$delim, '"');
+			}
+		}
+
+		return ltrim($out);
+	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Processor.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Processor.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Processor.php	(revision 755)
@@ -0,0 +1,44 @@
+<?php
+
+/**
+ * base class for processors
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+abstract class Dwoo_Processor
+{
+	/**
+	 * the compiler instance that runs this processor
+	 *
+	 * @var Dwoo
+	 */
+	protected $compiler;
+
+	/**
+	 * constructor, if you override it, call parent::__construct($dwoo); or assign
+	 * the dwoo instance yourself if you need it
+	 *
+	 * @param Dwoo_Core $dwoo the dwoo instance that runs this plugin
+	 */
+	public function __construct(Dwoo_Compiler $compiler)
+	{
+		$this->compiler = $compiler;
+	}
+
+	/**
+	 * processes the input and returns it filtered
+	 *
+	 * @param string $input the template to process
+	 * @return string
+	 */
+	abstract public function process($input);
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Security/Exception.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Security/Exception.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Security/Exception.php	(revision 755)
@@ -0,0 +1,19 @@
+<?php
+
+/**
+ * dwoo security exception class
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+class Dwoo_Security_Exception extends Dwoo_Exception
+{
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Security/Policy.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Security/Policy.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Security/Policy.php	(revision 755)
@@ -0,0 +1,304 @@
+<?php
+
+/**
+ * represents the security settings of a dwoo instance, it can be passed around to different dwoo instances
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+class Dwoo_Security_Policy
+{
+	/**#@+
+	 * php handling constants, defaults to PHP_REMOVE
+	 *
+	 * PHP_REMOVE : remove all <?php ?> (+ short tags if your short tags option is on) from the input template
+	 * PHP_ALLOW : leave them as they are
+	 * PHP_ENCODE : run htmlentities over them
+	 *
+	 * @var int
+	 */
+	const PHP_ENCODE = 1;
+	const PHP_REMOVE = 2;
+	const PHP_ALLOW = 3;
+	/**#@-*/
+
+	/**#@+
+	 * constant handling constants, defaults to CONST_DISALLOW
+	 *
+	 * CONST_DISALLOW : throw an error if {$dwoo.const.*} is used in the template
+	 * CONST_ALLOW : allow {$dwoo.const.*} calls
+	 */
+	const CONST_DISALLOW = false;
+	const CONST_ALLOW = true;
+	/**#@-*/
+
+	/**
+	 * php functions that are allowed to be used within the template
+	 *
+	 * @var array
+	 */
+	protected $allowedPhpFunctions = array
+	(
+		'str_repeat' => true,
+		'number_format' => true,
+		'htmlentities' => true,
+		'htmlspecialchars' => true,
+		'long2ip' => true,
+		'strlen' => true,
+		'list' => true,
+		'empty' => true,
+		'count' => true,
+		'sizeof' => true,
+		'in_array' => true,
+		'is_array' => true,
+	);
+
+	/**
+	 * methods that are allowed to be used within the template
+	 *
+	 * @var array
+	 */
+	protected $allowedMethods = array();
+
+	/**
+	 * paths that are safe to use with include or other file-access plugins
+	 *
+	 * @var array
+	 */
+	protected $allowedDirectories = array();
+
+	/**
+	 * stores the php handling level
+	 *
+	 * defaults to Dwoo_Security_Policy::PHP_REMOVE
+	 *
+	 * @var int
+	 */
+	protected $phpHandling = self::PHP_REMOVE;
+
+	/**
+	 * stores the constant handling level
+	 *
+	 * defaults to Dwoo_Security_Policy::CONST_DISALLOW
+	 *
+	 * @var bool
+	 */
+	protected $constHandling = self::CONST_DISALLOW;
+
+	/**
+	 * adds a php function to the allowed list
+	 *
+	 * @param mixed $func function name or array of function names
+	 */
+	public function allowPhpFunction($func)
+	{
+		if (is_array($func))
+			foreach ($func as $fname)
+				$this->allowedPhpFunctions[strtolower($fname)] = true;
+		else
+			$this->allowedPhpFunctions[strtolower($func)] = true;
+	}
+
+	/**
+	 * removes a php function from the allowed list
+	 *
+	 * @param mixed $func function name or array of function names
+	 */
+	public function disallowPhpFunction($func)
+	{
+		if (is_array($func))
+			foreach ($func as $fname)
+				unset($this->allowedPhpFunctions[strtolower($fname)]);
+		else
+			unset($this->allowedPhpFunctions[strtolower($func)]);
+	}
+
+	/**
+	 * returns the list of php functions allowed to run, note that the function names
+	 * are stored in the array keys and not values
+	 *
+	 * @return array
+	 */
+	public function getAllowedPhpFunctions()
+	{
+		return $this->allowedPhpFunctions;
+	}
+
+	/**
+	 * adds a class method to the allowed list, this must be used for
+	 * both static and non static method by providing the class name
+	 * and method name to use
+	 *
+	 * @param mixed $class class name or array of array('class', 'method') couples
+	 * @param string $method method name
+	 */
+	public function allowMethod($class, $method = null)
+	{
+		if (is_array($class))
+			foreach ($class as $elem)
+				$this->allowedMethods[strtolower($elem[0])][strtolower($elem[1])] = true;
+		else
+			$this->allowedMethods[strtolower($class)][strtolower($method)] = true;
+	}
+
+	/**
+	 * removes a class method from the allowed list
+	 *
+	 * @param mixed $class class name or array of array('class', 'method') couples
+	 * @param string $method method name
+	 */
+	public function disallowMethod($class, $method = null)
+	{
+		if (is_array($class))
+			foreach ($class as $elem)
+				unset($this->allowedMethods[strtolower($elem[0])][strtolower($elem[1])]);
+		else
+			unset($this->allowedMethods[strtolower($class)][strtolower($method)]);
+	}
+
+	/**
+	 * returns the list of class methods allowed to run, note that the class names
+	 * and method names are stored in the array keys and not values
+	 *
+	 * @return array
+	 */
+	public function getAllowedMethods()
+	{
+		return $this->allowedMethods;
+	}
+
+	/**
+	 * adds a directory to the safelist for includes and other file-access plugins
+	 *
+	 * note that all the includePath directories you provide to the Dwoo_Template_File class
+	 * are automatically marked as safe
+	 *
+	 * @param mixed $path a path name or an array of paths
+	 */
+	public function allowDirectory($path)
+	{
+		if (is_array($path))
+			foreach ($path as $dir)
+				$this->allowedDirectories[realpath($dir)] = true;
+		else
+			$this->allowedDirectories[realpath($path)] = true;
+	}
+
+	/**
+	 * removes a directory from the safelist
+	 *
+	 * @param mixed $path a path name or an array of paths
+	 */
+	public function disallowDirectory($path)
+	{
+		if (is_array($path))
+			foreach ($path as $dir)
+				unset($this->allowedDirectories[realpath($dir)]);
+		else
+			unset($this->allowedDirectories[realpath($path)]);
+	}
+
+	/**
+	 * returns the list of safe paths, note that the paths are stored in the array
+	 * keys and not values
+	 *
+	 * @return array
+	 */
+	public function getAllowedDirectories()
+	{
+		return $this->allowedDirectories;
+	}
+
+	/**
+	 * sets the php handling level, defaults to REMOVE
+	 *
+	 * @param int $level one of the Dwoo_Security_Policy::PHP_* constants
+	 */
+	public function setPhpHandling($level = self::PHP_REMOVE)
+	{
+		$this->phpHandling = $level;
+	}
+
+	/**
+	 * returns the php handling level
+	 *
+	 * @return int the current level, one of the Dwoo_Security_Policy::PHP_* constants
+	 */
+	public function getPhpHandling()
+	{
+		return $this->phpHandling;
+	}
+
+	/**
+	 * sets the constant handling level, defaults to CONST_DISALLOW
+	 *
+	 * @param bool $level one of the Dwoo_Security_Policy::CONST_* constants
+	 */
+	public function setConstantHandling($level = self::CONST_DISALLOW)
+	{
+		$this->constHandling = $level;
+	}
+
+	/**
+	 * returns the constant handling level
+	 *
+	 * @return bool the current level, one of the Dwoo_Security_Policy::CONST_* constants
+	 */
+	public function getConstantHandling()
+	{
+		return $this->constHandling;
+	}
+
+	/**
+	 * this is used at run time to check whether method calls are allowed or not
+	 *
+	 * @param Dwoo_Core $dwoo dwoo instance that calls this
+	 * @param object $obj any object on which the method must be called
+	 * @param string $method lowercased method name
+	 * @param array $args arguments array
+	 * @return mixed result of method call or unll + E_USER_NOTICE if not allowed
+	 */
+	public function callMethod(Dwoo_Core $dwoo, $obj, $method, $args)
+	{
+		foreach ($this->allowedMethods as $class => $methods) {
+			if (!isset($methods[$method])) {
+				continue;
+			}
+			if ($obj instanceof $class) {
+				return call_user_func_array(array($obj, $method), $args);
+			}
+		}
+		$dwoo->triggerError('The current security policy prevents you from calling '.get_class($obj).'::'.$method.'()');
+		return null;
+	}
+
+	/**
+	 * this is used at compile time to check whether static method calls are allowed or not
+	 *
+	 * @param mixed $class lowercased class name or array('class', 'method') couple
+	 * @param string $method lowercased method name
+	 * @return bool
+	 */
+	public function isMethodAllowed($class, $method = null) {
+		if (is_array($class)) {
+			list($class, $method) = $class;
+		}
+		foreach ($this->allowedMethods as $allowedClass => $methods) {
+			if (!isset($methods[$method])) {
+				continue;
+			}
+			if ($class === $allowedClass || is_subclass_of($class, $allowedClass)) {
+				return true;
+			}
+		}
+		return false;
+	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Smarty/Adapter.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Smarty/Adapter.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Smarty/Adapter.php	(revision 755)
@@ -0,0 +1,518 @@
+<?php
+
+if (!defined('DIR_SEP')) {
+	define('DIR_SEP', DIRECTORY_SEPARATOR);
+}
+
+if (!defined('SMARTY_PHP_PASSTHRU')) {
+	define('SMARTY_PHP_PASSTHRU',   0);
+	define('SMARTY_PHP_QUOTE',      1);
+	define('SMARTY_PHP_REMOVE',     2);
+	define('SMARTY_PHP_ALLOW',      3);
+}
+
+if (class_exists('Dwoo_Compiler', false) === false) {
+	require dirname(dirname(__FILE__)) . '/Compiler.php';
+}
+
+/**
+ * a Smarty compatibility layer for Dwoo
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.1.0
+ * @date       2009-07-18
+ * @package    Dwoo
+ */
+class Dwoo_Smarty__Adapter extends Dwoo_Core
+{
+	// magic get/set/call functions that handle unsupported features
+	public function __set($p, $v)
+	{
+		if ($p==='scope') {
+			$this->scope = $v;
+			return;
+		}
+		if ($p==='data') {
+			$this->data = $v;
+			return;
+		}
+		if (array_key_exists($p, $this->compat['properties']) !== false) {
+			if ($this->show_compat_errors) {
+				$this->triggerError('Property '.$p.' is not available in the Dwoo_Smarty_Adapter, however it might be implemented in the future, check out http://wiki.dwoo.org/index.php/SmartySupport for more details.', E_USER_NOTICE);
+			}
+			$this->compat['properties'][$p] = $v;
+		} else {
+			if ($this->show_compat_errors) {
+				$this->triggerError('Property '.$p.' is not available in the Dwoo_Smarty_Adapter, but it is not listed as such, so you might want to tell me about it at j.boggiano@seld.be', E_USER_NOTICE);
+			}
+		}
+	}
+
+	public function __get($p)
+	{
+		if (array_key_exists($p, $this->compat['properties']) !== false) {
+			if ($this->show_compat_errors) {
+				$this->triggerError('Property '.$p.' is not available in the Dwoo_Smarty_Adapter, however it might be implemented in the future, check out http://wiki.dwoo.org/index.php/SmartySupport for more details.', E_USER_NOTICE);
+			}
+			return $this->compat['properties'][$p];
+		} else {
+			if ($this->show_compat_errors) {
+				$this->triggerError('Property '.$p.' is not available in the Dwoo_Smarty_Adapter, but it is not listed as such, so you might want to tell me about it at j.boggiano@seld.be', E_USER_NOTICE);
+			}
+		}
+	}
+
+	public function __call($m, $a)
+	{
+		if (method_exists($this->dataProvider, $m)) {
+			call_user_func_array(array($this->dataProvider, $m), $a);
+		} elseif ($this->show_compat_errors) {
+			if (array_search($m, $this->compat['methods']) !== false) {
+				$this->triggerError('Method '.$m.' is not available in the Dwoo_Smarty_Adapter, however it might be implemented in the future, check out http://wiki.dwoo.org/index.php/SmartySupport for more details.', E_USER_NOTICE);
+			} else {
+				$this->triggerError('Method '.$m.' is not available in the Dwoo_Smarty_Adapter, but it is not listed as such, so you might want to tell me about it at j.boggiano@seld.be', E_USER_NOTICE);
+			}
+		}
+	}
+
+	// list of unsupported properties and methods
+	protected $compat = array
+	(
+		'methods' => array
+		(
+			'register_resource', 'unregister_resource', 'load_filter', 'clear_compiled_tpl',
+			'clear_config', 'get_config_vars', 'config_load'
+		),
+		'properties' => array
+		(
+			'cache_handler_func' => null,
+			'debugging' => false,
+			'error_reporting' => null,
+			'debugging_ctrl' => 'NONE',
+			'request_vars_order' => 'EGPCS',
+			'request_use_auto_globals' => true,
+			'use_sub_dirs' => false,
+			'autoload_filters' => array(),
+			'default_template_handler_func' => '',
+			'debug_tpl' => '',
+			'cache_modified_check' => false,
+			'default_modifiers' => array(),
+			'default_resource_type' => 'file',
+			'config_overwrite' => true,
+			'config_booleanize' => true,
+			'config_read_hidden' => false,
+			'config_fix_newlines' => true,
+			'config_class' => 'Config_File',
+		),
+	);
+
+	// security vars
+	public $security = false;
+	public $trusted_dir = array();
+	public $secure_dir = array();
+	public $php_handling = SMARTY_PHP_PASSTHRU;
+	public $security_settings = array
+	(
+		'PHP_HANDLING'    => false,
+		'IF_FUNCS'        => array
+		(
+			'list', 'empty', 'count', 'sizeof',
+			'in_array', 'is_array',
+		),
+		'INCLUDE_ANY'     => false,
+		'PHP_TAGS'        => false,
+		'MODIFIER_FUNCS'  => array(),
+		'ALLOW_CONSTANTS'  => false
+	);
+
+	// paths
+	public $template_dir = 'templates';
+	public $compile_dir = 'templates_c';
+	public $config_dir = 'configs';
+	public $cache_dir = 'cache';
+	public $plugins_dir = array();
+
+	// misc options
+	public $left_delimiter = '{';
+	public $right_delimiter = '}';
+	public $compile_check = true;
+	public $force_compile = false;
+	public $caching = 0;
+	public $cache_lifetime = 3600;
+	public $compile_id = null;
+	public $compiler_file = null;
+	public $compiler_class = null;
+
+	// dwoo/smarty compat layer
+	public $show_compat_errors = false;
+	protected $dataProvider;
+	protected $_filters = array('pre'=>array(), 'post'=>array(), 'output'=>array());
+	protected static $tplCache = array();
+	protected $compiler = null;
+
+	public function __construct()
+	{
+		parent::__construct();
+		$this->charset = 'iso-8859-1';
+		$this->dataProvider = new Dwoo_Data();
+		$this->compiler = new Dwoo_Compiler();
+	}
+
+	public function display($filename, $cacheId=null, $compileId=null)
+	{
+		$this->fetch($filename, $cacheId, $compileId, true);
+	}
+
+	public function fetch($filename, $cacheId=null, $compileId=null, $display=false)
+	{
+		$this->setCacheDir($this->cache_dir);
+		$this->setCompileDir($this->compile_dir);
+
+		if ($this->security) {
+			$policy = new Dwoo_Security_Policy();
+			$policy->addPhpFunction(array_merge($this->security_settings['IF_FUNCS'], $this->security_settings['MODIFIER_FUNCS']));
+
+			$phpTags = $this->security_settings['PHP_HANDLING'] ? SMARTY_PHP_ALLOW : $this->php_handling;
+			if ($this->security_settings['PHP_TAGS']) {
+				$phpTags = SMARTY_PHP_ALLOW;
+			}
+			switch($phpTags) {
+				case SMARTY_PHP_ALLOW:
+				case SMARTY_PHP_PASSTHRU:
+					$phpTags = Dwoo_Security_Policy::PHP_ALLOW;
+					break;
+				case SMARTY_PHP_QUOTE:
+					$phpTags = Dwoo_Security_Policy::PHP_ENCODE;
+					break;
+				case SMARTY_PHP_REMOVE:
+				default:
+					$phpTags = Dwoo_Security_Policy::PHP_REMOVE;
+					break;
+			}
+			$policy->setPhpHandling($phpTags);
+
+			$policy->setConstantHandling($this->security_settings['ALLOW_CONSTANTS']);
+
+			if ($this->security_settings['INCLUDE_ANY']) {
+				$policy->allowDirectory(preg_replace('{^((?:[a-z]:)?[\\\\/]).*}i', '$1', __FILE__));
+			} else {
+				$policy->allowDirectory($this->secure_dir);
+			}
+
+			$this->setSecurityPolicy($policy);
+		}
+
+		if (!empty($this->plugins_dir)) {
+			foreach ($this->plugins_dir as $dir) {
+				$this->getLoader()->addDirectory(rtrim($dir, '\\/'));
+			}
+		}
+
+		$tpl = $this->makeTemplate($filename, $cacheId, $compileId);
+		if ($this->force_compile) {
+			$tpl->forceCompilation();
+		}
+
+		if ($this->caching > 0) {
+			$this->cacheTime = $this->cache_lifetime;
+		} else {
+			$this->cacheTime = 0;
+		}
+
+		if ($this->compiler_class !== null) {
+			if ($this->compiler_file !== null && !class_exists($this->compiler_class, false)) {
+				include $this->compiler_file;
+			}
+			$this->compiler = new $this->compiler_class;
+		} else {
+			$this->compiler->addPreProcessor('smarty_compat', true);
+			$this->compiler->setLooseOpeningHandling(true);
+		}
+
+		$this->compiler->setDelimiters($this->left_delimiter, $this->right_delimiter);
+
+		return $this->get($tpl, $this->dataProvider, $this->compiler, $display===true);
+	}
+
+	public function get($_tpl, $data = array(), $_compiler = null, $_output = false)
+	{
+		if ($_compiler === null) {
+			$_compiler = $this->compiler;
+		}
+		return parent::get($_tpl, $data, $_compiler, $_output);
+	}
+
+	public function register_function($name, $callback, $cacheable=true, $cache_attrs=null)
+	{
+		if (isset($this->plugins[$name]) && $this->plugins[$name][0] !== self::SMARTY_FUNCTION) {
+			throw new Dwoo_Exception('Multiple plugins of different types can not share the same name');
+		}
+		$this->plugins[$name] = array('type'=>self::SMARTY_FUNCTION, 'callback'=>$callback);
+	}
+
+	public function unregister_function($name)
+	{
+		unset($this->plugins[$name]);
+	}
+
+	public function register_block($name, $callback, $cacheable=true, $cache_attrs=null)
+	{
+		if (isset($this->plugins[$name]) && $this->plugins[$name][0] !== self::SMARTY_BLOCK) {
+			throw new Dwoo_Exception('Multiple plugins of different types can not share the same name');
+		}
+		$this->plugins[$name] = array('type'=>self::SMARTY_BLOCK, 'callback'=>$callback);
+	}
+
+	public function unregister_block($name)
+	{
+		unset($this->plugins[$name]);
+	}
+
+	public function register_modifier($name, $callback)
+	{
+		if (isset($this->plugins[$name]) && $this->plugins[$name][0] !== self::SMARTY_MODIFIER) {
+			throw new Dwoo_Exception('Multiple plugins of different types can not share the same name');
+		}
+		$this->plugins[$name] = array('type'=>self::SMARTY_MODIFIER, 'callback'=>$callback);
+	}
+
+	public function unregister_modifier($name)
+	{
+		unset($this->plugins[$name]);
+	}
+
+	public function register_prefilter($callback)
+	{
+		$processor = new Dwoo_SmartyProcessorAdapter($this->compiler);
+		$processor->registerCallback($callback);
+		$this->_filters['pre'][] = $processor;
+		$this->compiler->addPreProcessor($processor);
+	}
+
+	public function unregister_prefilter($callback)
+	{
+		foreach ($this->_filters['pre'] as $index => $processor)
+			if ($processor->callback === $callback) {
+				$this->compiler->removePostProcessor($processor);
+				unset($this->_filters['pre'][$index]);
+			}
+	}
+
+	public function register_postfilter($callback)
+	{
+		$processor = new Dwoo_SmartyProcessorAdapter($this->compiler);
+		$processor->registerCallback($callback);
+		$this->_filters['post'][] = $processor;
+		$this->compiler->addPostProcessor($processor);
+	}
+
+	public function unregister_postfilter($callback)
+	{
+		foreach ($this->_filters['post'] as $index => $processor)
+			if ($processor->callback === $callback) {
+				$this->compiler->removePostProcessor($processor);
+				unset($this->_filters['post'][$index]);
+			}
+	}
+
+	public function register_outputfilter($callback)
+	{
+		$filter = new Dwoo_SmartyFilterAdapter($this);
+		$filter->registerCallback($callback);
+		$this->_filters['output'][] = $filter;
+		$this->addFilter($filter);
+	}
+
+	public function unregister_outputfilter($callback)
+	{
+		foreach ($this->_filters['output'] as $index => $filter)
+			if ($filter->callback === $callback) {
+				$this->removeOutputFilter($filter);
+				unset($this->_filters['output'][$index]);
+			}
+	}
+
+	function register_object($object, $object_impl, $allowed = array(), $smarty_args = false, $block_methods = array())
+	{
+		settype($allowed, 'array');
+		settype($block_methods, 'array');
+		settype($smarty_args, 'boolean');
+
+		if (!empty($allowed) && $this->show_compat_errors) {
+			$this->triggerError('You can register objects but can not restrict the method/properties used, this is PHP5, you have proper OOP access restrictions so use them.', E_USER_NOTICE);
+		}
+
+		if ($smarty_args) {
+			$this->triggerError('You can register objects but methods will be called using method($arg1, $arg2, $arg3), not as an argument array like smarty did.', E_USER_NOTICE);
+		}
+
+		if (!empty($block_methods)) {
+			$this->triggerError('You can register objects but can not use methods as being block methods, you have to build a plugin for that.', E_USER_NOTICE);
+		}
+
+		$this->dataProvider->assign($object, $object_impl);
+	}
+
+	function unregister_object($object)
+	{
+		$this->dataProvider->clear($object);
+	}
+
+	function get_registered_object($name) {
+		$data = $this->dataProvider->getData();
+		if (isset($data[$name]) && is_object($data[$name])) {
+			return $data[$name];
+		} else {
+			trigger_error('Dwoo_Compiler: object "'.$name.'" was not registered or is not an object', E_USER_ERROR);
+		}
+	}
+
+	public function template_exists($filename)
+	{
+		if (!is_array($this->template_dir)) {
+			return file_exists($this->template_dir.DIRECTORY_SEPARATOR.$filename);
+		} else {
+			foreach ($this->template_dir as $tpl_dir) {
+				if (file_exists($tpl_dir.DIRECTORY_SEPARATOR.$filename)) {
+					return true;
+				}
+			}
+			return false;
+		}
+	}
+
+   	public function is_cached($tpl, $cacheId = null, $compileId = null)
+   	{
+   		return $this->isCached($this->makeTemplate($tpl, $cacheId, $compileId));
+   	}
+
+   	public function append_by_ref($var, &$value, $merge=false)
+   	{
+   		$this->dataProvider->appendByRef($var, $value, $merge);
+   	}
+
+	public function assign_by_ref($name, &$val)
+	{
+		$this->dataProvider->assignByRef($name, $val);
+	}
+
+   	public function clear_assign($var)
+   	{
+   		$this->dataProvider->clear($var);
+   	}
+
+   	public function clear_all_assign()
+   	{
+   		$this->dataProvider->clear();
+   	}
+
+	public function get_template_vars($name=null)
+	{
+		if ($this->show_compat_errors) {
+			trigger_error('get_template_vars does not return values by reference, if you try to modify the data that way you should modify your code.', E_USER_NOTICE);
+		}
+
+		$data = $this->dataProvider->getData();
+   		if ($name === null)
+   			return $data;
+   		elseif (isset($data[$name]))
+   			return $data[$name];
+   		return null;
+   	}
+
+   	public function clear_all_cache($olderThan = 0)
+   	{
+   		$this->clearCache($olderThan);
+   	}
+
+   	public function clear_cache($template, $cacheId = null, $compileId = null, $olderThan = 0)
+   	{
+   		$this->makeTemplate($template, $cacheId, $compileId)->clearCache($olderThan);
+   	}
+
+	public function trigger_error($error_msg, $error_type = E_USER_WARNING)
+	{
+		$this->triggerError($error_msg, $error_type);
+	}
+
+	protected function initGlobals()
+	{
+		parent::initGlobals();
+		$this->globals['ldelim'] = '{';
+		$this->globals['rdelim'] = '}';
+	}
+
+	protected function makeTemplate($file, $cacheId, $compileId)
+	{
+   		if ($compileId === null)
+   			$compileId = $this->compile_id;
+
+		$hash = bin2hex(md5($file.$cacheId.$compileId, true));
+		if (!isset(self::$tplCache[$hash])) {
+			// abs path
+			if (substr($file, 0, 1) === '/' || substr($file, 1, 1) === ':') {
+				self::$tplCache[$hash] = new Dwoo_Template_File($file, null, $cacheId, $compileId);
+			} elseif (is_string($this->template_dir) || is_array($this->template_dir)) {
+				self::$tplCache[$hash] = new Dwoo_Template_File($file, null, $cacheId, $compileId, $this->template_dir);
+			} else {
+				throw new Exception('Unable to load "'.$file.'", check the template_dir');
+			}
+		}
+		return self::$tplCache[$hash];
+	}
+
+	public function triggerError($message, $level=E_USER_NOTICE)
+	{
+		if (is_object($this->template)) {
+			return parent::triggerError($message, $level);
+		}
+		trigger_error('Dwoo error : '.$message, $level);
+	}
+}
+
+class Dwoo_Smarty_Filter_Adapter extends Dwoo_Filter
+{
+	public $callback;
+
+	public function process($input)
+	{
+		return call_user_func($this->callback, $input);
+	}
+
+	public function registerCallback($callback)
+	{
+		$this->callback = $callback;
+	}
+}
+
+class Dwoo_Smarty_Processor_Adapter extends Dwoo_Processor
+{
+	public $callback;
+
+	public function process($input)
+	{
+		return call_user_func($this->callback, $input);
+	}
+
+	public function registerCallback($callback)
+	{
+		$this->callback = $callback;
+	}
+}
+
+// cloaks the adapter if possible with the smarty name to fool type-hinted plugins
+if (class_exists('Smarty', false) === false)
+{
+	interface Smarty {}
+	class Dwoo_Smarty_Adapter extends Dwoo_Smarty__Adapter implements Smarty {}
+}
+else
+{
+	class Dwoo_Smarty_Adapter extends Dwoo_Smarty__Adapter {}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Template/File.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Template/File.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Template/File.php	(revision 755)
@@ -0,0 +1,270 @@
+<?php
+
+/**
+ * represents a Dwoo template contained in a file
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.1.0
+ * @date       2009-07-18
+ * @package    Dwoo
+ */
+class Dwoo_Template_File extends Dwoo_Template_String
+{
+	/**
+	 * template filename
+	 *
+	 * @var string
+	 */
+	protected $file;
+
+	/**
+	 * include path(s) to look into to find this template
+	 *
+	 * @var array
+	 */
+	protected $includePath = null;
+
+	/**
+	 * resolved path cache when looking for a file in multiple include paths
+	 *
+	 * this is reset when the include path is changed
+	 *
+	 * @var string
+	 */
+	protected $resolvedPath = null;
+
+	/**
+	 * creates a template from a file
+	 *
+	 * @param string $file the path to the template file, make sure it exists
+	 * @param int $cacheTime duration of the cache validity for this template,
+	 * 						 if null it defaults to the Dwoo instance that will
+	 * 						 render this template
+	 * @param string $cacheId the unique cache identifier of this page or anything else that
+	 * 						  makes this template's content unique, if null it defaults
+	 * 						  to the current url
+	 * @param string $compileId the unique compiled identifier, which is used to distinguish this
+	 * 							template from others, if null it defaults to the filename+bits of the path
+	 * @param mixed $includePath a string for a single path to look into for the given file, or an array of paths
+	 */
+	public function __construct($file, $cacheTime = null, $cacheId = null, $compileId = null, $includePath = null)
+	{
+		$this->file = $file;
+		$this->name = basename($file);
+		$this->cacheTime = $cacheTime;
+
+		if ($compileId !== null) {
+			$this->compileId = str_replace('../', '__', strtr($compileId, '\\%?=!:;'.PATH_SEPARATOR, '/-------'));
+		}
+
+		if ($cacheId !== null) {
+			$this->cacheId = str_replace('../', '__', strtr($cacheId, '\\%?=!:;'.PATH_SEPARATOR, '/-------'));
+		}
+
+		if (is_string($includePath)) {
+			$this->includePath = array($includePath);
+		} elseif (is_array($includePath)) {
+			$this->includePath = $includePath;
+		}
+	}
+
+	/**
+	 * sets the include path(s) to where the given template filename must be looked up
+	 *
+	 * @param mixed $paths the path to look into, can be string for a single path or an array of paths
+	 */
+	public function setIncludePath($paths)
+	{
+		if (is_array($paths) === false) {
+			$paths = array($paths);
+		}
+
+		$this->includePath = $paths;
+		$this->resolvedPath = null;
+	}
+
+	/**
+	 * return the current include path(s)
+	 *
+	 * @return array
+	 */
+	public function getIncludePath()
+	{
+		return $this->includePath;
+	}
+
+	/**
+	 * Checks if compiled file is valid (exists and it's the modification is greater or
+	 * equal to the modification time of the template file)
+	 *
+	 * @param string file
+	 * @return boolean True cache file existance and it's modification time
+	 */
+	protected function isValidCompiledFile($file) {
+		return parent::isValidCompiledFile($file) && (int)$this->getUid() <= filemtime($file);
+	}
+
+	/**
+	 * returns the template source of this template
+	 *
+	 * @return string
+	 */
+	public function getSource()
+	{
+		return file_get_contents($this->getResourceIdentifier());
+	}
+
+	/**
+	 * returns the resource name for this template class
+	 *
+	 * @return string
+	 */
+	public function getResourceName()
+	{
+		return 'file';
+	}
+
+	/**
+	 * returns this template's source filename
+	 *
+	 * @return string
+	 */
+	public function getResourceIdentifier()
+	{
+		if ($this->resolvedPath !== null) {
+			return $this->resolvedPath;
+		} elseif ($this->includePath === null) {
+			return $this->file;
+		} else {
+			foreach ($this->includePath as $path) {
+				$path = rtrim($path, DIRECTORY_SEPARATOR);
+				if (file_exists($path.DIRECTORY_SEPARATOR.$this->file) === true) {
+					$this->resolvedPath = $path . DIRECTORY_SEPARATOR . $this->file;
+					return $this->resolvedPath;
+				}
+			}
+
+			throw new Dwoo_Exception('Template "'.$this->file.'" could not be found in any of your include path(s)');
+		}
+	}
+
+	/**
+	 * returns an unique value identifying the current version of this template,
+	 * in this case it's the unix timestamp of the last modification
+	 *
+	 * @return string
+	 */
+	public function getUid()
+	{
+		return (string) filemtime($this->getResourceIdentifier());
+	}
+
+	/**
+	 * returns a new template object from the given include name, null if no include is
+	 * possible (resource not found), or false if include is not permitted by this resource type
+	 *
+	 * @param Dwoo_Core $dwoo the dwoo instance requiring it
+	 * @param mixed $resourceId the filename (relative to this template's dir) of the template to include
+	 * @param int $cacheTime duration of the cache validity for this template,
+	 * 						 if null it defaults to the Dwoo instance that will
+	 * 						 render this template
+	 * @param string $cacheId the unique cache identifier of this page or anything else that
+	 * 						  makes this template's content unique, if null it defaults
+	 * 						  to the current url
+	 * @param string $compileId the unique compiled identifier, which is used to distinguish this
+	 * 							template from others, if null it defaults to the filename+bits of the path
+	 * @param Dwoo_ITemplate $parentTemplate the template that is requesting a new template object (through
+	 * 											an include, extends or any other plugin)
+	 * @return Dwoo_Template_File|null
+	 */
+	public static function templateFactory(Dwoo_Core $dwoo, $resourceId, $cacheTime = null, $cacheId = null, $compileId = null, Dwoo_ITemplate $parentTemplate = null)
+	{
+		if (DIRECTORY_SEPARATOR === '\\') {
+			$resourceId = str_replace(array("\t", "\n", "\r", "\f", "\v"), array('\\t', '\\n', '\\r', '\\f', '\\v'), $resourceId);
+		}
+		$resourceId = strtr($resourceId, '\\', '/');
+
+		$includePath = null;
+
+		if (file_exists($resourceId) === false) {
+			if ($parentTemplate === null) {
+				$parentTemplate = $dwoo->getTemplate();
+			}
+			if ($parentTemplate instanceof Dwoo_Template_File) {
+				if ($includePath = $parentTemplate->getIncludePath()) {
+					if (strstr($resourceId, '../')) {
+						throw new Dwoo_Exception('When using an include path you can not reference a template into a parent directory (using ../)');
+					}
+				} else {
+					$resourceId = dirname($parentTemplate->getResourceIdentifier()).DIRECTORY_SEPARATOR.$resourceId;
+					if (file_exists($resourceId) === false) {
+						return null;
+					}
+				}
+			} else {
+				return null;
+			}
+		}
+
+		if ($policy = $dwoo->getSecurityPolicy()) {
+			while (true) {
+				if (preg_match('{^([a-z]+?)://}i', $resourceId)) {
+					throw new Dwoo_Security_Exception('The security policy prevents you to read files from external sources : <em>'.$resourceId.'</em>.');
+				}
+
+				if ($includePath) {
+					break;
+				}
+
+				$resourceId = realpath($resourceId);
+				$dirs = $policy->getAllowedDirectories();
+				foreach ($dirs as $dir=>$dummy) {
+					if (strpos($resourceId, $dir) === 0) {
+						break 2;
+					}
+				}
+				throw new Dwoo_Security_Exception('The security policy prevents you to read <em>'.$resourceId.'</em>');
+			}
+		}
+
+		$class = 'Dwoo_Template_File';
+		if ($parentTemplate) {
+			$class = get_class($parentTemplate);
+		}
+		return new $class($resourceId, $cacheTime, $cacheId, $compileId, $includePath);
+	}
+
+	/**
+	 * returns the full compiled file name and assigns a default value to it if
+	 * required
+	 *
+	 * @param Dwoo_Core $dwoo the dwoo instance that requests the file name
+	 * @return string the full path to the compiled file
+	 */
+	protected function getCompiledFilename(Dwoo_Core $dwoo)
+	{
+		// no compile id was provided, set default
+		if ($this->compileId===null) {
+			$this->compileId = str_replace('../', '__', strtr($this->getResourceIdentifier(), '\\:', '/-'));
+		}
+		return $dwoo->getCompileDir() . $this->compileId.'.d'.Dwoo_Core::RELEASE_TAG.'.php';
+	}
+
+	/**
+	 * returns some php code that will check if this template has been modified or not
+	 *
+	 * if the function returns null, the template will be instanciated and then the Uid checked
+	 *
+	 * @return string
+	 */
+	public function getIsModifiedCode()
+	{
+		return '"'.$this->getUid().'" == filemtime('.var_export($this->getResourceIdentifier(), true).')';
+	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Template/String.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Template/String.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/Dwoo/Template/String.php	(revision 755)
@@ -0,0 +1,497 @@
+<?php
+
+/**
+ * represents a Dwoo template contained in a string
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.1.0
+ * @date       2009-07-18
+ * @package    Dwoo
+ */
+class Dwoo_Template_String implements Dwoo_ITemplate
+{
+	/**
+	 * template name
+	 *
+	 * @var string
+	 */
+	protected $name;
+
+	/**
+	 * template compilation id
+	 *
+	 * @var string
+	 */
+	protected $compileId;
+
+	/**
+	 * template cache id, if not provided in the constructor, it is set to
+	 * the md4 hash of the request_uri. it is however highly recommended to
+	 * provide one that will fit your needs.
+	 *
+	 * in all cases, the compilation id is prepended to the cache id to separate
+	 * templates with similar cache ids from one another
+	 *
+	 * @var string
+	 */
+	protected $cacheId;
+
+	/**
+	 * validity duration of the generated cache file (in seconds)
+	 *
+	 * set to -1 for infinite cache, 0 to disable and null to inherit the Dwoo instance's cache time
+	 *
+	 * @var int
+	 */
+	protected $cacheTime;
+
+	/**
+	 * boolean flag that defines whether the compilation should be enforced (once) or
+	 * not use this if you have issues with the compiled templates not being updated
+	 * but if you do need this it's most likely that you should file a bug report
+	 *
+	 * @var bool
+	 */
+	protected $compilationEnforced;
+
+	/**
+	 * caches the results of the file checks to save some time when the same
+	 * templates is rendered several times
+	 *
+	 * @var array
+	 */
+	protected static $cache = array('cached'=>array(), 'compiled'=>array());
+
+	/**
+	 * holds the compiler that built this template
+	 *
+	 * @var Dwoo_ICompiler
+	 */
+	protected $compiler;
+
+	/**
+	 * chmod value for all files written (cached or compiled ones)
+	 *
+	 * set to null if you don't want any chmod operation to happen
+	 *
+	 * @var int
+	 */
+	protected $chmod = 0777;
+
+	/**
+	 * creates a template from a string
+	 *
+	 * @param string $templateString the template to use
+	 * @param int $cacheTime duration of the cache validity for this template,
+	 * 						 if null it defaults to the Dwoo instance that will
+	 * 						 render this template, set to -1 for infinite cache or 0 to disable
+	 * @param string $cacheId the unique cache identifier of this page or anything else that
+	 * 						  makes this template's content unique, if null it defaults
+	 * 						  to the current url
+	 * @param string $compileId the unique compiled identifier, which is used to distinguish this
+	 * 							template from others, if null it defaults to the md4 hash of the template
+	 */
+	public function __construct($templateString, $cacheTime = null, $cacheId = null, $compileId = null)
+	{
+		$this->template = $templateString;
+		if (function_exists('hash')) {
+			$this->name = hash('md4', $templateString);
+		} else {
+			$this->name = md5($templateString);
+		}
+		$this->cacheTime = $cacheTime;
+
+		if ($compileId !== null) {
+			$this->compileId = str_replace('../', '__', strtr($compileId, '\\%?=!:;'.PATH_SEPARATOR, '/-------'));
+		}
+
+		if ($cacheId !== null) {
+			$this->cacheId = str_replace('../', '__', strtr($cacheId, '\\%?=!:;'.PATH_SEPARATOR, '/-------'));
+		}
+	}
+
+	/**
+	 * returns the cache duration for this template
+	 *
+	 * defaults to null if it was not provided
+	 *
+	 * @return int|null
+	 */
+	public function getCacheTime()
+	{
+		return $this->cacheTime;
+	}
+
+	/**
+	 * sets the cache duration for this template
+	 *
+	 * can be used to set it after the object is created if you did not provide
+	 * it in the constructor
+	 *
+	 * @param int $seconds duration of the cache validity for this template, if
+	 * null it defaults to the Dwoo instance's cache time. 0 = disable and
+	 * -1 = infinite cache
+	 */
+	public function setCacheTime($seconds = null)
+	{
+		$this->cacheTime = $seconds;
+	}
+
+	/**
+	 * returns the chmod value for all files written (cached or compiled ones)
+	 *
+	 * defaults to 0777
+	 *
+	 * @return int|null
+	 */
+	public function getChmod()
+	{
+		return $this->chmod;
+	}
+
+	/**
+	 * set the chmod value for all files written (cached or compiled ones)
+	 *
+	 * set to null if you don't want to do any chmod() operation
+	 *
+	 * @param int $mask new bitmask to use for all files
+	 */
+	public function setChmod($mask = null)
+	{
+		$this->chmod = $mask;
+	}
+
+	/**
+	 * returns the template name
+	 *
+	 * @return string
+	 */
+	public function getName()
+	{
+		return $this->name;
+	}
+
+	/**
+	 * returns the resource name for this template class
+	 *
+	 * @return string
+	 */
+	public function getResourceName()
+	{
+		return 'string';
+	}
+
+	/**
+	 * returns the resource identifier for this template, false here as strings don't have identifiers
+	 *
+	 * @return false
+	 */
+	public function getResourceIdentifier()
+	{
+		return false;
+	}
+
+	/**
+	 * returns the template source of this template
+	 *
+	 * @return string
+	 */
+	public function getSource()
+	{
+		return $this->template;
+	}
+
+	/**
+	 * returns an unique value identifying the current version of this template,
+	 * in this case it's the md4 hash of the content
+	 *
+	 * @return string
+	 */
+	public function getUid()
+	{
+		return $this->name;
+	}
+
+	/**
+	 * returns the compiler used by this template, if it was just compiled, or null
+	 *
+	 * @return Dwoo_ICompiler
+	 */
+	public function getCompiler()
+	{
+		return $this->compiler;
+	}
+
+	/**
+	 * marks this template as compile-forced, which means it will be recompiled even if it
+	 * was already saved and wasn't modified since the last compilation. do not use this in production,
+	 * it's only meant to be used in development (and the development of dwoo particularly)
+	 */
+	public function forceCompilation()
+	{
+		$this->compilationEnforced = true;
+	}
+
+	/**
+	 * returns the cached template output file name, true if it's cache-able but not cached
+	 * or false if it's not cached
+	 *
+	 * @param Dwoo_Core $dwoo the dwoo instance that requests it
+	 * @return string|bool
+	 */
+	public function getCachedTemplate(Dwoo_Core $dwoo)
+	{
+		if ($this->cacheTime !== null) {
+			$cacheLength = $this->cacheTime;
+		} else {
+			$cacheLength = $dwoo->getCacheTime();
+		}
+
+		// file is not cacheable
+		if ($cacheLength == 0) {
+			return false;
+		}
+
+		$cachedFile = $this->getCacheFilename($dwoo);
+
+		if (isset(self::$cache['cached'][$this->cacheId]) === true && file_exists($cachedFile)) {
+			// already checked, return cache file
+			return $cachedFile;
+		} elseif ($this->compilationEnforced !== true && file_exists($cachedFile) && ($cacheLength === -1 || filemtime($cachedFile) > ($_SERVER['REQUEST_TIME'] - $cacheLength)) && $this->isValidCompiledFile($this->getCompiledFilename($dwoo))) {
+			// cache is still valid and can be loaded
+			self::$cache['cached'][$this->cacheId] = true;
+			return $cachedFile;
+		} else {
+			// file is cacheable
+			return true;
+		}
+	}
+
+	/**
+	 * caches the provided output into the cache file
+	 *
+	 * @param Dwoo_Core $dwoo the dwoo instance that requests it
+	 * @param string $output the template output
+	 * @return mixed full path of the cached file or false upon failure
+	 */
+	public function cache(Dwoo_Core $dwoo, $output)
+	{
+		$cacheDir = $dwoo->getCacheDir();
+		$cachedFile = $this->getCacheFilename($dwoo);
+
+		// the code below is courtesy of Rasmus Schultz,
+		// thanks for his help on avoiding concurency issues
+		$temp = tempnam($cacheDir, 'temp');
+		if (!($file = @fopen($temp, 'wb'))) {
+			$temp = $cacheDir . uniqid('temp');
+			if (!($file = @fopen($temp, 'wb'))) {
+				trigger_error('Error writing temporary file \''.$temp.'\'', E_USER_WARNING);
+				return false;
+			}
+		}
+
+		fwrite($file, $output);
+		fclose($file);
+
+		$this->makeDirectory(dirname($cachedFile), $cacheDir);
+		if (!@rename($temp, $cachedFile)) {
+			@unlink($cachedFile);
+			@rename($temp, $cachedFile);
+		}
+
+		if ($this->chmod !== null) {
+			chmod($cachedFile, $this->chmod);
+		}
+
+		self::$cache['cached'][$this->cacheId] = true;
+
+		return $cachedFile;
+	}
+
+	/**
+	 * clears the cached template if it's older than the given time
+	 *
+	 * @param Dwoo_Core $dwoo the dwoo instance that was used to cache that template
+	 * @param int $olderThan minimum time (in seconds) required for the cache to be cleared
+	 * @return bool true if the cache was not present or if it was deleted, false if it remains there
+	 */
+	public function clearCache(Dwoo_Core $dwoo, $olderThan = -1)
+	{
+		$cachedFile = $this->getCacheFilename($dwoo);
+
+		return !file_exists($cachedFile) || (filectime($cachedFile) < (time() - $olderThan) && unlink($cachedFile));
+	}
+
+	/**
+	 * returns the compiled template file name
+	 *
+	 * @param Dwoo_Core $dwoo the dwoo instance that requests it
+	 * @param Dwoo_ICompiler $compiler the compiler that must be used
+	 * @return string
+	 */
+	public function getCompiledTemplate(Dwoo_Core $dwoo, Dwoo_ICompiler $compiler = null)
+	{
+		$compiledFile = $this->getCompiledFilename($dwoo);
+
+		if ($this->compilationEnforced !== true && isset(self::$cache['compiled'][$this->compileId]) === true) {
+			// already checked, return compiled file
+		} elseif ($this->compilationEnforced !== true && $this->isValidCompiledFile($compiledFile)) {
+			// template is compiled
+			self::$cache['compiled'][$this->compileId] = true;
+		} else {
+			// compiles the template
+			$this->compilationEnforced = false;
+
+			if ($compiler === null) {
+				$compiler = $dwoo->getDefaultCompilerFactory($this->getResourceName());
+
+				if ($compiler === null || $compiler === array('Dwoo_Compiler', 'compilerFactory')) {
+					if (class_exists('Dwoo_Compiler', false) === false) {
+						include DWOO_DIRECTORY . 'Dwoo/Compiler.php';
+					}
+					$compiler = Dwoo_Compiler::compilerFactory();
+				} else {
+					$compiler = call_user_func($compiler);
+				}
+			}
+
+			$this->compiler = $compiler;
+
+			$compiler->setCustomPlugins($dwoo->getCustomPlugins());
+			$compiler->setSecurityPolicy($dwoo->getSecurityPolicy());
+			$this->makeDirectory(dirname($compiledFile), $dwoo->getCompileDir());
+			file_put_contents($compiledFile, $compiler->compile($dwoo, $this));
+			if ($this->chmod !== null) {
+				chmod($compiledFile, $this->chmod);
+			}
+
+			self::$cache['compiled'][$this->compileId] = true;
+		}
+
+		return $compiledFile;
+	}
+
+	/**
+	 * Checks if compiled file is valid (it exists)
+	 *
+	 * @param string file
+	 * @return boolean True cache file existance
+	 */
+	protected function isValidCompiledFile($file) {
+		return file_exists($file);
+	}
+
+	/**
+	 * returns a new template string object with the resource id being the template source code
+	 *
+	 * @param Dwoo_Core $dwoo the dwoo instance requiring it
+	 * @param mixed $resourceId the filename (relative to this template's dir) of the template to include
+	 * @param int $cacheTime duration of the cache validity for this template,
+	 * 						 if null it defaults to the Dwoo instance that will
+	 * 						 render this template
+	 * @param string $cacheId the unique cache identifier of this page or anything else that
+	 * 						  makes this template's content unique, if null it defaults
+	 * 						  to the current url
+	 * @param string $compileId the unique compiled identifier, which is used to distinguish this
+	 * 							template from others, if null it defaults to the filename+bits of the path
+	 * @param Dwoo_ITemplate $parentTemplate the template that is requesting a new template object (through
+	 * 											an include, extends or any other plugin)
+	 * @return Dwoo_Template_String
+	 */
+	public static function templateFactory(Dwoo_Core $dwoo, $resourceId, $cacheTime = null, $cacheId = null, $compileId = null, Dwoo_ITemplate $parentTemplate = null)
+	{
+		return new self($resourceId, $cacheTime, $cacheId, $compileId);
+	}
+
+	/**
+	 * returns the full compiled file name and assigns a default value to it if
+	 * required
+	 *
+	 * @param Dwoo_Core $dwoo the dwoo instance that requests the file name
+	 * @return string the full path to the compiled file
+	 */
+	protected function getCompiledFilename(Dwoo_Core $dwoo)
+	{
+		// no compile id was provided, set default
+		if ($this->compileId===null) {
+			$this->compileId = $this->name;
+		}
+		return $dwoo->getCompileDir() . $this->compileId.'.d'.Dwoo_Core::RELEASE_TAG.'.php';
+	}
+
+	/**
+	 * returns the full cached file name and assigns a default value to it if
+	 * required
+	 *
+	 * @param Dwoo_Core $dwoo the dwoo instance that requests the file name
+	 * @return string the full path to the cached file
+	 */
+	protected function getCacheFilename(Dwoo_Core $dwoo)
+	{
+		// no cache id provided, use request_uri as default
+		if ($this->cacheId === null) {
+			if (isset($_SERVER['REQUEST_URI']) === true) {
+				$cacheId = $_SERVER['REQUEST_URI'];
+			} elseif (isset($_SERVER['SCRIPT_FILENAME']) && isset($_SERVER['argv'])) {
+				$cacheId = $_SERVER['SCRIPT_FILENAME'].'-'.implode('-', $_SERVER['argv']);
+			} else {
+				$cacheId = '';
+			}
+			// force compiled id generation
+			$this->getCompiledFilename($dwoo);
+
+			$this->cacheId = str_replace('../', '__', $this->compileId . strtr($cacheId, '\\%?=!:;'.PATH_SEPARATOR, '/-------'));
+		}
+		return $dwoo->getCacheDir() . $this->cacheId.'.html';
+	}
+
+	/**
+	 * returns some php code that will check if this template has been modified or not
+	 *
+	 * if the function returns null, the template will be instanciated and then the Uid checked
+	 *
+	 * @return string
+	 */
+	public function getIsModifiedCode()
+	{
+		return null;
+	}
+
+	/**
+	 * ensures the given path exists
+	 *
+	 * @param string $path any path
+	 * @param string $baseDir the base directory where the directory is created
+	 *                        ($path must still contain the full path, $baseDir
+	 *                        is only used for unix permissions)
+	 */
+	protected function makeDirectory($path, $baseDir = null)
+	{
+		if (is_dir($path) === true) {
+			return;
+		}
+
+		if ($this->chmod === null) {
+			$chmod = 0777;
+		} else {
+			$chmod = $this->chmod;
+		}
+		mkdir($path, $chmod, true);
+
+		// enforce the correct mode for all directories created
+		if (strpos(PHP_OS, 'WIN') !== 0 && $baseDir !== null) {
+			$path = strtr(str_replace($baseDir, '', $path), '\\', '/');
+			$folders = explode('/', trim($path, '/'));
+			foreach ($folders as $folder) {
+				$baseDir .= $folder . DIRECTORY_SEPARATOR;
+				chmod($baseDir, $chmod);
+			}
+		}
+	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/classpath.cache.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/classpath.cache.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/classpath.cache.d17.php	(revision 755)
@@ -0,0 +1,1 @@
+a:64:{s:1:"a";s:97:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/a.php";s:11:"auto_escape";s:107:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/auto_escape.php";s:5:"block";s:101:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/block.php";s:7:"capture";s:103:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/capture.php";s:7:"dynamic";s:103:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/dynamic.php";s:4:"else";s:100:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/else.php";s:6:"elseif";s:102:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/elseif.php";s:3:"for";s:99:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/for.php";s:7:"foreach";s:103:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/foreach.php";s:11:"foreachelse";s:107:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/foreachelse.php";s:7:"forelse";s:103:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/forelse.php";s:2:"if";s:98:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/if.php";s:4:"loop";s:100:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/loop.php";s:7:"section";s:103:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/section.php";s:15:"smartyinterface";s:111:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/smartyinterface.php";s:5:"strip";s:101:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/strip.php";s:8:"template";s:104:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/template.php";s:10:"textformat";s:106:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/textformat.php";s:13:"topLevelBlock";s:109:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/topLevelBlock.php";s:4:"with";s:100:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/with.php";s:8:"withelse";s:104:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/withelse.php";s:11:"html_format";s:108:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/filters/html_format.php";s:6:"assign";s:105:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/assign.php";s:10:"capitalize";s:109:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/capitalize.php";s:3:"cat";s:102:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/cat.php";s:16:"count_characters";s:115:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/count_characters.php";s:16:"count_paragraphs";s:115:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/count_paragraphs.php";s:15:"count_sentences";s:114:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/count_sentences.php";s:11:"count_words";s:110:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/count_words.php";s:7:"counter";s:106:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/counter.php";s:5:"cycle";s:104:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/cycle.php";s:11:"date_format";s:110:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/date_format.php";s:7:"default";s:106:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/default.php";s:4:"dump";s:103:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/dump.php";s:3:"eol";s:102:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/eol.php";s:6:"escape";s:105:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/escape.php";s:4:"eval";s:103:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/eval.php";s:7:"extends";s:106:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/extends.php";s:12:"extendsCheck";s:111:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/extendsCheck.php";s:5:"fetch";s:104:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/fetch.php";s:7:"include";s:106:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/include.php";s:6:"indent";s:105:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/indent.php";s:5:"isset";s:104:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/isset.php";s:14:"load_templates";s:113:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/load_templates.php";s:5:"lower";s:104:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/lower.php";s:6:"mailto";s:105:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/mailto.php";s:4:"math";s:103:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/math.php";s:5:"nl2br";s:104:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/nl2br.php";s:8:"optional";s:107:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/optional.php";s:13:"regex_replace";s:112:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/regex_replace.php";s:7:"replace";s:106:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/replace.php";s:6:"return";s:105:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/return.php";s:7:"reverse";s:106:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/reverse.php";s:4:"safe";s:103:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/safe.php";s:7:"spacify";s:106:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/spacify.php";s:13:"string_format";s:112:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/string_format.php";s:10:"strip_tags";s:109:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/strip_tags.php";s:3:"tif";s:102:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/tif.php";s:8:"truncate";s:107:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/truncate.php";s:5:"upper";s:104:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/upper.php";s:10:"whitespace";s:109:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/whitespace.php";s:8:"wordwrap";s:107:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/wordwrap.php";s:5:"array";s:101:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/helper.array.php";s:13:"smarty_compat";s:117:"/var/tmp/wax/src/jobmonarch/branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/processors/pre.smarty_compat.php";}
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/classpath.cache.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/classpath.cache.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/classpath.cache.d17.php	(revision 755)
@@ -0,0 +1,1 @@
+a:64:{s:1:"a";s:64:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/blocks/a.php";s:11:"auto_escape";s:74:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/blocks/auto_escape.php";s:5:"block";s:68:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/blocks/block.php";s:7:"capture";s:70:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/blocks/capture.php";s:7:"dynamic";s:70:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/blocks/dynamic.php";s:4:"else";s:67:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/blocks/else.php";s:6:"elseif";s:69:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/blocks/elseif.php";s:3:"for";s:66:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/blocks/for.php";s:7:"foreach";s:70:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/blocks/foreach.php";s:11:"foreachelse";s:74:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/blocks/foreachelse.php";s:7:"forelse";s:70:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/blocks/forelse.php";s:2:"if";s:65:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/blocks/if.php";s:4:"loop";s:67:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/blocks/loop.php";s:7:"section";s:70:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/blocks/section.php";s:15:"smartyinterface";s:78:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/blocks/smartyinterface.php";s:5:"strip";s:68:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/blocks/strip.php";s:8:"template";s:71:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/blocks/template.php";s:10:"textformat";s:73:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/blocks/textformat.php";s:13:"topLevelBlock";s:76:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/blocks/topLevelBlock.php";s:4:"with";s:67:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/blocks/with.php";s:8:"withelse";s:71:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/blocks/withelse.php";s:11:"html_format";s:75:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/filters/html_format.php";s:6:"assign";s:72:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/functions/assign.php";s:10:"capitalize";s:76:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/functions/capitalize.php";s:3:"cat";s:69:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/functions/cat.php";s:16:"count_characters";s:82:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/functions/count_characters.php";s:16:"count_paragraphs";s:82:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/functions/count_paragraphs.php";s:15:"count_sentences";s:81:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/functions/count_sentences.php";s:11:"count_words";s:77:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/functions/count_words.php";s:7:"counter";s:73:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/functions/counter.php";s:5:"cycle";s:71:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/functions/cycle.php";s:11:"date_format";s:77:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/functions/date_format.php";s:7:"default";s:73:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/functions/default.php";s:4:"dump";s:70:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/functions/dump.php";s:3:"eol";s:69:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/functions/eol.php";s:6:"escape";s:72:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/functions/escape.php";s:4:"eval";s:70:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/functions/eval.php";s:7:"extends";s:73:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/functions/extends.php";s:12:"extendsCheck";s:78:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/functions/extendsCheck.php";s:5:"fetch";s:71:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/functions/fetch.php";s:7:"include";s:73:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/functions/include.php";s:6:"indent";s:72:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/functions/indent.php";s:5:"isset";s:71:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/functions/isset.php";s:14:"load_templates";s:80:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/functions/load_templates.php";s:5:"lower";s:71:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/functions/lower.php";s:6:"mailto";s:72:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/functions/mailto.php";s:4:"math";s:70:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/functions/math.php";s:5:"nl2br";s:71:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/functions/nl2br.php";s:8:"optional";s:74:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/functions/optional.php";s:13:"regex_replace";s:79:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/functions/regex_replace.php";s:7:"replace";s:73:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/functions/replace.php";s:6:"return";s:72:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/functions/return.php";s:7:"reverse";s:73:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/functions/reverse.php";s:4:"safe";s:70:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/functions/safe.php";s:7:"spacify";s:73:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/functions/spacify.php";s:13:"string_format";s:79:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/functions/string_format.php";s:10:"strip_tags";s:76:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/functions/strip_tags.php";s:3:"tif";s:69:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/functions/tif.php";s:8:"truncate";s:74:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/functions/truncate.php";s:5:"upper";s:71:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/functions/upper.php";s:10:"whitespace";s:76:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/functions/whitespace.php";s:8:"wordwrap";s:74:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/functions/wordwrap.php";s:5:"array";s:68:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/helper.array.php";s:13:"smarty_compat";s:84:"/usr/share/ganglia-webfrontend/dwoo/plugins/builtin/processors/pre.smarty_compat.php";}
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/fairshare_pie.php.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/fairshare_pie.php.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/fairshare_pie.php.d17.php	(revision 755)
@@ -0,0 +1,207 @@
+<?php
+/* template head */
+/* end template head */ ob_start(); /* template body */ ?><?php
+
+function microtime_float(){
+    list($usec, $sec) = explode(" ", microtime());
+    return ((float)$usec + (float)$sec);
+}
+
+#$timerStart = microtime_float();
+
+function colorRed( $color ) {
+        return substr( $color, 0, 2 );
+}
+function colorGreen( $color ) {
+        return substr( $color, 2, 2 );
+}
+function colorBlue( $color ) {
+        return substr( $color, 4, 2 );
+}
+
+function colorDiffer( $first, $second ) {
+
+        // Make sure these two colors differ atleast 50 R/G/B
+        $min_diff = 50;
+
+        $c1r = hexDec( colorRed( $first ) );
+        $c1g = hexDec( colorGreen( $first ) );
+        $c1b = hexDec( colorBlue( $first ) );
+
+        $c2r = hexDec( colorRed( $second ) );
+        $c2g = hexDec( colorGreen( $second ) );
+        $c2b = hexDec( colorBlue( $second ) );
+
+        $rdiff = ($c1r >= $c2r) ? $c1r - $c2r : $c2r - $c1r;
+        $gdiff = ($c1g >= $c2g) ? $c1g - $c2g : $c2g - $c1g;
+        $bdiff = ($c1b >= $c2b) ? $c1b - $c2b : $c2b - $c1b;
+
+        if( $rdiff >= $min_diff or $gdiff >= $min_diff or $bdiff >= $min_diff )
+                return TRUE;
+        else
+                return FALSE;
+}
+
+function randomColor( $known_colors ) {
+
+        $start = "004E00";
+
+        $start_red = colorRed( $start );
+        $start_green = colorGreen( $start );
+        $start_blue = colorBlue( $start );
+
+        $end = "FFFFFF";
+
+        $end_red = colorRed( $end );
+        $end_green = colorGreen( $end );
+        $end_blue = colorBlue( $end );
+
+        $change_color = TRUE;
+
+        while( $change_color ) {
+
+                $change_color = FALSE;
+
+                $new_red = rand( hexDec( $start_red ), hexDec( $end_red ) );
+                $new_green = rand( hexDec( $start_green ), hexDec( $end_green ) );
+                $new_blue = rand( hexDec( $start_blue ), hexDec( $end_blue ) );
+
+                $new = sprintf("%02s", decHex( $new_red ) ) . sprintf("%02s", decHex( $new_green ) ) . sprintf("%02s", decHex( $new_blue ) );
+
+                foreach( $known_colors as $old )
+
+                        if( !colorDiffer( $new, $old ) )
+
+                                $change_color = TRUE;
+        }
+
+        // Whoa! Actually found a good color ;)
+        return $new;
+}
+
+if( !isset($_GET) )
+{
+  $_GET = array();
+}
+
+unset( $_GET['m'] );
+unset( $_GET['mc'] );
+unset( $_GET['hc'] );
+unset( $_GET['r'] );
+unset( $_GET['s'] );
+unset( $_GET['c'] );
+unset( $metricname );
+unset( $metric );
+
+$_GET['h'] = "batch1.irc.sara.nl";
+$_GET['c'] = "LISA Cluster";
+
+$monitor = FALSE;
+$size="250x150";
+
+if(isset($_GET['monitor']))
+{
+	$monitor = TRUE;
+	$size="500x500";
+}
+
+
+unset($context);
+global $context;
+$context = "host";
+
+//global $debug;
+//$debug = 0;
+unset( $metrics );
+global $metrics;
+
+
+include_once "./eval_conf.php";
+include_once "./functions.php";
+
+$base_dir = "/data/ganglia-web-current";
+require $base_dir . "/conf_default.php";
+
+# Include user-defined overrides if they exist.
+if( file_exists( $base_dir . "/conf.php" ) ) {
+  include $base_dir . "/conf.php";
+}
+
+include_once "./get_context.php";
+include_once "./ganglia.php";
+
+$clustername = "LISA Cluster";
+$hostname = "batch1.irc.sara.nl";
+
+#$timerBeforeInclude = microtime_float();
+#include_once "./get_ganglia.php";
+Gmetad($conf['ganglia_ip'], $conf['ganglia_port']);
+#$timerAfterInclude = microtime_float();
+
+
+$fairshare_reporter_host = "batch1.irc.sara.nl";
+
+$rrd_dir = $conf['rrds'] . "/" . $clustername . "/" . $fairshare_reporter_host;
+
+foreach( $metrics as $m_name => $m_details )
+{
+	if (preg_match("/maui_fs_([a-z]+)/i", $m_name, $matches))
+        {
+		if( strpos( $m_name, "_current" ) !== FALSE )
+		{
+			$name_fields = explode( "maui_fs_", $m_name);
+			$name2_fields = explode( "_current", $name_fields[1]);
+			$short_name = $name2_fields[0];
+
+                        $real_value = $metrics[$m_name]['VAL'];
+
+			if( $real_value > 1.00 )
+			{
+				$fs[$short_name] = $real_value;
+			}
+		}
+        }
+}
+
+$pie_args = '';
+
+$colors = array();
+
+$pie_args = "title=" . rawurlencode("Cluster Fairshare Percentages");
+$pie_args .= "&size=". $size;
+
+foreach( $fs as $fs_name => $fs_val )
+{
+    // Show pie chart of loads
+
+    $color = randomColor( $colors );
+    $colors[] = $color;
+
+    $n = $percent_hosts[$color];
+    $name_url = rawurlencode($fs_name);
+    $pie_args .= "&$name_url=$fs_val,$color";
+}
+
+if( !$monitor )
+{
+	echo "<img src=\"pie.php?";
+	echo "$pie_args";
+	echo "\" >";
+}
+else
+{
+	$url = 'https://'. $_SERVER['HTTP_HOST'] . '/pie.php?'.$pie_args;
+	$image_output = file_get_contents( $url );
+	header('Content-Type: image/png');
+	echo( $image_output );
+}
+
+#$timerStop = microtime_float();
+#$timerTotal         = round($timerStop - $timerStart,3);
+#$timerInclude       = round($timerAfterInclude - $timerBeforeInclude,5);
+#file_put_contents('/tmp/fairshare','Total runtime: '.$timerTotal.' include time: '.$timerInclude);
+
+?>
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/cluster_extra.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/cluster_extra.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/cluster_extra.tpl.d17.php	(revision 755)
@@ -0,0 +1,16 @@
+<?php
+/* template head */
+if (function_exists('Dwoo_Plugin_include')===false)
+	$this->getLoader()->loadPlugin('include');
+/* end template head */ ob_start(); /* template body */ ?><!-- A place to put custom HTML for the cluster view. -->
+<?php if ((isset($this->scope["cluster"]) ? $this->scope["cluster"] : null) == "LISA Cluster") {
+?> 
+<?php echo Dwoo_Plugin_include($this, 'fairshare_pie.php', null, null, null, '_root', null);?>
+
+<?php 
+}?>
+
+<!-- <img src="pie.php?<?php echo $this->scope["fairshare_pie_args"];?>" /> -->
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/cluster_host_metric_graphs.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/cluster_host_metric_graphs.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/cluster_host_metric_graphs.tpl.d17.php	(revision 755)
@@ -0,0 +1,57 @@
+<?php
+/* template head */
+/* end template head */ ob_start(); /* template body */ ?><center>
+<table id=graph_sorted_list>
+<tr>
+<?php 
+$_fh2_data = (isset($this->scope["sorted_list"]) ? $this->scope["sorted_list"] : null);
+if ($this->isTraversable($_fh2_data) == true)
+{
+	foreach ($_fh2_data as $this->scope['host'])
+	{
+/* -- foreach start output */
+?>
+<?php echo $this->scope["host"]["metric_image"];
+echo $this->scope["host"]["br"];?>
+
+<?php 
+/* -- foreach end output */
+	}
+}?>
+
+</tr>
+</table>
+
+<?php echo $this->scope["overflow_list_header"];?>
+
+<?php 
+$_fh3_data = (isset($this->scope["overflow_list"]) ? $this->scope["overflow_list"] : null);
+if ($this->isTraversable($_fh3_data) == true)
+{
+	foreach ($_fh3_data as $this->scope['host'])
+	{
+/* -- foreach start output */
+?>
+<?php echo $this->scope["host"]["metric_image"];
+echo $this->scope["host"]["br"];?>
+
+<?php 
+/* -- foreach end output */
+	}
+}?>
+
+<?php echo $this->scope["overflow_list_footer"];?>
+
+
+<?php if (((isset($this->scope["node_legend"]) ? $this->scope["node_legend"] : null) !== null)) {
+?>
+<p>
+(Nodes colored by 1-minute load) | <a href="./node_legend.html">Legend</A>
+</p>
+<?php 
+}?>
+
+</center>
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/cluster_overview.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/cluster_overview.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/cluster_overview.tpl.d17.php	(revision 755)
@@ -0,0 +1,13 @@
+<?php
+/* template head */
+/* end template head */ ob_start(); /* template body */ ?><table cellspacing=1 cellpadding=1 width="100%" border=0>
+ <tr><td>CPUs Total:</td><td align=left><B><?php echo $this->scope["cpu_num"];?></B></td></tr>
+ <tr><td width="60%">Hosts up:</td><td align=left><B><?php echo $this->scope["num_nodes"];?></B></td></tr>
+ <tr><td>Hosts down:</td><td align=left><B><?php echo $this->scope["num_dead_nodes"];?></B></td></tr>
+ <tr><td>&nbsp;</td></tr>
+ <tr><td colspan=2><font class="nobr">Current Load Avg (15, 5, 1m):</font><br>&nbsp;&nbsp;<b><?php echo $this->scope["cluster_load"];?></b></td></tr>
+ <tr><td colspan=2>Avg Utilization (last <?php echo $this->scope["range"];?>):<br>&nbsp;&nbsp;<b><?php echo $this->scope["cluster_util"];?></b></td></tr>
+ </table>
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/cluster_refresh.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/cluster_refresh.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/cluster_refresh.tpl.d17.php	(revision 755)
@@ -0,0 +1,17 @@
+<?php
+/* template head */
+if (function_exists('Dwoo_Plugin_include')===false)
+	$this->getLoader()->loadPlugin('include');
+/* end template head */ ob_start(); /* template body */ ;
+echo $this->scope["localtimestamp"];?><!-- || -->Overview of <?php echo $this->scope["cluster"];?> @ <?php echo $this->scope["localtime"];?><!-- || --><?php echo Dwoo_Plugin_include($this, 'cluster_overview.tpl', null, null, null, '_root', null);?><!-- || --><?php if ((isset($this->scope["pie_args"]) ? $this->scope["pie_args"] : null)) {
+?>./pie.php?<?php echo $this->scope["pie_args"];
+
+}?><!-- || --><?php if ((isset($this->scope["heatmap"]) ? $this->scope["heatmap"] : null) && (isset($this->scope["num_nodes"]) ? $this->scope["num_nodes"] : null) > 0) {
+
+echo $this->scope["heatmap"];
+
+}?><!-- || --><?php echo Dwoo_Plugin_include($this, 'cluster_host_metric_graphs.tpl', null, null, null, '_root', null);?>
+
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/cluster_view.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/cluster_view.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/cluster_view.tpl.d17.php	(revision 755)
@@ -0,0 +1,321 @@
+<?php
+/* template head */
+if (function_exists('Dwoo_Plugin_include')===false)
+	$this->getLoader()->loadPlugin('include');
+/* end template head */ ob_start(); /* template body */ ?><!-- Begin cluster_view.tpl -->
+<?php if ((isset($this->scope["heatmap"]) ? $this->scope["heatmap"] : null)) {
+?>
+<script type="text/javascript" src="js/protovis-r3.2.js"></script>
+<?php 
+}?>
+
+<script type="text/javascript">
+function refreshClusterView() {
+  $.get('cluster_view.php?' + jQuery.param.querystring() + '&refresh', function(data) {
+    var item = data.split("<!-- || -->");
+
+    $('#cluster_title').html(item[1]);
+
+    $('#cluster_overview').html(item[2]);
+
+    if ($('#load_pie').size())
+      $('#load_pie').attr("src", item[3].replace(/&amp;/g, "&"));
+
+    if ($('#heatmap-fig').size()) {
+      eval("heatmap = [" + item[4] + "]")	;
+      vis.render();
+    }
+
+    if ($('#stacked_graph').size()) {
+      var localtimestamp = parseInt(item[0]);
+      var src = $('#stacked_graph').attr('src');
+      $('#stacked_graph').attr("src", jQuery.param.querystring(src, "&st=" + localtimestamp));
+    }
+
+    var host_metric_graphs = $('#host_metric_graphs');
+    host_metric_graphs.css('height', host_metric_graphs.height() + "px");
+    host_metric_graphs.html(item[5]);
+  });
+
+  $("#optional_graphs img").each(function (index) {
+    var src = $(this).attr("src");
+    if ((src.indexOf("graph.php") == 0) ||
+        (src.indexOf("./graph.php") == 0)) {
+      var d = new Date();
+      $(this).attr("src", jQuery.param.querystring(src, "&_=" + d.getTime()));
+    }    
+  });
+}
+
+$(function() {
+  // Modified from http://jqueryui.com/demos/toggle/
+  //run the currently selected effect
+  function runEffect(id){
+    //most effect types need no options passed by default
+    var options = { };
+
+    options = { to: { width: 200,height: 60 } }; 
+    
+    //run the effect
+    $("#"+id+"_div").toggle("blind",options,500);
+  };
+ 
+  //set effect from select menu value
+  $('.button').click(function(event) {
+    runEffect(event.target.id);
+    return false;
+  });
+
+    $(function() {
+        $( "#edit_optional_graphs" ).dialog({ autoOpen: false, minWidth: 550,
+          beforeClose: function(event, ui) {  location.reload(true); } })
+        $( "#edit_optional_graphs_button" ).button();
+        $( "#save_optional_graphs_button" ).button();
+        $( "#close_edit_optional_graphs_link" ).button();
+    });
+
+    $("#edit_optional_graphs_button").click(function(event) {
+      $("#edit_optional_graphs").dialog('open');
+      $('#edit_optional_graphs_content').html('<img src="img/spinner.gif">');
+      $.get('edit_optional_graphs.php', "clustername=<?php echo $this->scope["cluster"];?>", function(data) {
+          $('#edit_optional_graphs_content').html(data);
+      })
+      return false;
+    });
+
+    $("#save_optional_graphs_button").click(function(event) {
+       $.get('edit_optional_graphs.php', $("#edit_optional_reports_form").serialize(), function(data) {
+          $('#edit_optional_graphs_content').html(data);
+          $("#save_optional_graphs_button").hide();
+          setTimeout(function() {
+             $('#edit_optional_graphs').dialog('close');
+          }, 5000);
+        });
+      return false;
+    });
+
+});
+</script>
+
+<?php if ((isset($this->scope["graph_engine"]) ? $this->scope["graph_engine"] : null) == "flot") {
+?>
+<script language="javascript" type="text/javascript" src="js/jquery.flot.min.js"></script>
+<script type="text/javascript" src="js/create-flot-graphs.js"></script>
+<style type="text/css">
+.flotgraph2 {
+  height: <?php echo $this->scope["graph_height"];?>px;
+  width:  <?php echo $this->scope["graph_width"];?>px;
+}
+</style>
+<?php 
+}?>
+
+
+<style type="text/css">
+  .toggler { width: 500px; height: 200px; }
+  a.button { padding: .15em 1em; text-decoration: none; }
+  #effect { width: 240px; height: 135px; padding: 0.4em; position: relative; }
+  #effect h3 { margin: 0; padding: 0.4em; text-align: center; }
+  #heatmap-fig {
+    width: 200px;
+    height: 200px;
+  } 
+</style>
+
+<div id="metric-actions-dialog" title="Metric Actions">
+  <div id="metric-actions-dialog-content">
+    Available Metric actions.
+  </div>
+</div>
+
+<div id="edit_optional_graphs">
+  <div style="text-align:center">
+    <button  id='save_optional_graphs_button'>Save</button>
+  </div>
+  <div id="edit_optional_graphs_content">Empty</div>
+</div>
+
+<div style="background:rgb(238,238,238);text-align:center;">
+  <font size="+1" id="cluster_title">Overview of <?php echo $this->scope["cluster"];?> @ <?php echo $this->scope["localtime"];?></font>
+</div>
+
+<table border="0" cellspacing=4 width="100%">
+<tr>
+<td align="left" valign="top">
+<div id="cluster_overview">
+<?php echo Dwoo_Plugin_include($this, 'cluster_overview.tpl', null, null, null, '_root', null);?>
+
+</div>
+<?php if (((isset($this->scope["extra"]) ? $this->scope["extra"] : null) !== null)) {
+?>
+<?php echo Dwoo_Plugin_include($this, "".(isset($this->scope["extra"]) ? $this->scope["extra"] : null)."", null, null, null, '_root', null);?>
+
+<?php 
+}?>
+
+</td>
+<td rowspan=2 align="center" valign=top>
+<div id="optional_graphs" style="padding-bottom:4px">
+<?php echo $this->scope["optional_reports"];?><br>
+<?php 
+$_fh0_data = (isset($this->scope["optional_graphs_data"]) ? $this->scope["optional_graphs_data"] : null);
+if ($this->isTraversable($_fh0_data) == true)
+{
+	foreach ($_fh0_data as $this->scope['graph'])
+	{
+/* -- foreach start output */
+?>
+  <a href="./graph_all_periods.php?<?php echo $this->scope["graph"]["graph_args"];?>&amp;g=<?php echo $this->scope["graph"]["name"];?>_report&amp;z=large">
+  <img border=0 <?php echo $this->scope["additional_cluster_img_html_args"];?> title="<?php echo $this->scope["cluster"];?> <?php echo $this->scope["graph"]["name"];?>" src="./graph.php?<?php echo $this->scope["graph"]["graph_args"];?>&amp;g=<?php echo $this->scope["graph"]["name"];?>_report&amp;z=medium"></a>
+<?php 
+/* -- foreach end output */
+	}
+}?>
+
+</div>
+<?php if ((isset($this->scope["user_may_edit"]) ? $this->scope["user_may_edit"] : null)) {
+?>
+<button id="edit_optional_graphs_button">Edit Optional Graphs</button>
+<?php 
+}?>
+
+</td>
+</tr>
+
+<tr>
+ <td align="center" valign="top">
+<?php if ((isset($this->scope["php_gd"]) ? $this->scope["php_gd"] : null) && ! (isset($this->scope["heatmap"]) ? $this->scope["heatmap"] : null)) {
+?>
+  <img id="load_pie" src="./pie.php?<?php echo $this->scope["pie_args"];?>" border="0" />
+<?php 
+}?>
+
+<?php if ((isset($this->scope["heatmap"]) ? $this->scope["heatmap"] : null) && (isset($this->scope["num_nodes"]) ? $this->scope["num_nodes"] : null) > 0) {
+?>
+Utilization heatmap<br />
+<div id="heatmap-fig">
+<script type="text/javascript+protovis">
+var heatmap = [
+<?php echo $this->scope["heatmap"];?>
+
+];
+
+var w = heatmap[0].length,
+    h = heatmap.length;
+
+var vis = new pv.Panel()
+    .width(w * <?php echo $this->scope["heatmap_size"];?>)
+    .height(h * <?php echo $this->scope["heatmap_size"];?>)
+    .margin(2)
+    .strokeStyle("#aaa")
+    .lineWidth(4)
+    .antialias(false);
+
+vis.add(pv.Image)
+    .imageWidth(w)
+    .imageHeight(h)
+    .image(pv.Scale.linear()
+        .domain(0, 0.25, 0.5, 0.75, 1.00)
+        .range("#e2ecff", "#caff98", "#ffde5e" , "#ffa15e","#ff634f")
+        .by(function(i, j) heatmap[j][i]));
+
+vis.render();
+    </script>
+ </div>
+<?php 
+}?>
+
+ </td>
+</tr>
+</table>
+
+<?php if ((isset($this->scope["stacked_graph_args"]) ? $this->scope["stacked_graph_args"] : null)) {
+?>
+<center>
+<table width="100%" border=0>
+<tr>
+  <td colspan="1">
+  <font size="+1" style="text-align:center">Stacked Graph - <?php echo $this->scope["metric"];?></font> 
+  </td>
+</tr>
+<tr>
+  <td>
+  <center><img id="stacked_graph" src="stacked.php?<?php echo $this->scope["stacked_graph_args"];?>" alt="<?php echo $this->scope["cluster"];?> <?php echo $this->scope["metric"];?>"></center>
+  </td>
+</tr>
+</table>
+</center>
+<?php 
+}?>
+
+
+<script type="text/javascript">
+// Need to set the field value to metric name
+$("#metrics-picker").val("<?php echo $this->scope["metric_name"];?>");
+</script>
+
+
+<div id="cluster_view_chooser">
+<table border="0" width="100%">
+  <tr>
+  <td style="text-align:center;background:rgb(238,238,238);">
+  Show Hosts Scaled:
+  <?php 
+$_fh1_data = (isset($this->scope["showhosts_levels"]) ? $this->scope["showhosts_levels"] : null);
+$this->globals["foreach"]['default'] = array
+(
+	"iteration"		=> 1,
+	"last"		=> null,
+	"total"		=> $this->count($_fh1_data),
+);
+$_fh1_glob =& $this->globals["foreach"]['default'];
+if ($this->isTraversable($_fh1_data) == true)
+{
+	foreach ($_fh1_data as $this->scope['id']=>$this->scope['showhosts'])
+	{
+		$_fh1_glob["last"] = (string) ($_fh1_glob["iteration"] === $_fh1_glob["total"]);
+/* -- foreach start output */
+?>
+  <input type="radio" name="sh" value="<?php echo $this->scope["id"];?>" id="shch<?php echo $this->scope["id"];?>" OnClick="ganglia_form.submit();" <?php echo $this->scope["showhosts"]["checked"];?>><label for="shch<?php echo $this->scope["id"];?>"><?php echo $this->scope["showhosts"]["name"];?></label>
+  <?php 
+/* -- implode */
+if (!$_fh1_glob["last"]) {
+	echo "";
+}
+/* -- foreach end output */
+		$_fh1_glob["iteration"]+=1;
+	}
+}?>&nbsp;
+  |
+  <span class="nobr"><?php echo $this->scope["cluster"];?> <strong><?php echo $this->scope["metric"];?></strong>
+  last <strong><?php echo $this->scope["range"];?></strong>
+  sorted <strong><?php echo $this->scope["sort"];?></strong></span>
+<?php if (((isset($this->scope["columns_size_dropdown"]) ? $this->scope["columns_size_dropdown"] : null) !== null)) {
+?>
+  |
+   <font>
+   <span class="nobr">Size&nbsp;&nbsp;<?php echo $this->scope["size_menu"];?></span>
+   <span class="nobr">Columns&nbsp;&nbsp;<?php echo $this->scope["cols_menu"];?> (0 = metric + reports)</span>
+   </font>
+<?php 
+}?>
+
+  </td>
+</tr>
+</table>
+</div>
+
+<div id="host_metric_graphs">
+<?php echo Dwoo_Plugin_include($this, 'cluster_host_metric_graphs.tpl', null, null, null, '_root', null);?>
+
+</div>
+
+<script type="text/javascript">
+$(function() {
+  $( "#cluster_view_chooser" ).buttonset();
+});
+</script>
+<!-- End cluster_view.tpl -->
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/compare_hosts.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/compare_hosts.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/compare_hosts.tpl.d17.php	(revision 755)
@@ -0,0 +1,83 @@
+<?php
+/* template head */
+/* end template head */ ob_start(); /* template body */ ?><style>
+.img_view {
+  float: left;
+  margin: 0 0 10px 10px;
+}
+</style>
+<div id="metric-actions-dialog" title="Metric Actions">
+<div id="metric-actions-dialog-content">
+	Available Metric actions.
+</div>
+</div>
+<div id="inspect-graph-dialog" title="Inspect Graph">
+  <div id="inspect-graph-dialog-content">
+  </div>
+</div>
+<div>
+  Enter host regular expression: 
+  <input type="text" name="hreg[]" value="<?php echo $this->scope["hreg_arg"];?>">
+  <button>Go</button>
+</div>
+<div id="compare-hosts-content">
+  <div id=compare-hosts>
+    <?php if ((isset($this->scope["hreg_arg"]) ? $this->scope["hreg_arg"] : null) != '') {
+?>
+    <?php if ((isset($this->scope["number_of_metrics"]) ? $this->scope["number_of_metrics"] : null) == 0) {
+?>
+    <div class="ui-widget">
+      <div class="ui-state-default ui-corner-all" style="padding: 0 .7em;"> 
+        <p><span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span>
+          No matching metrics
+      </div>
+    </div>
+    <?php 
+}
+else {
+?>
+      <?php $this->scope["i"]=0?>
+
+      <?php 
+$_fh0_data = (isset($this->scope["host_metrics"]) ? $this->scope["host_metrics"] : null);
+if ($this->isTraversable($_fh0_data) == true)
+{
+	foreach ($_fh0_data as $this->scope['metric'])
+	{
+/* -- foreach start output */
+?>
+      <?php $this->scope["graphId"]=((isset($this->scope["GRAPH_BASE_ID"]) ? $this->scope["GRAPH_BASE_ID"] : null)).("dg_").((isset($this->scope["i"]) ? $this->scope["i"] : null))?>
+
+      <?php $this->scope["showEventsId"]=((isset($this->scope["SHOW_EVENTS_BASE_ID"]) ? $this->scope["SHOW_EVENTS_BASE_ID"] : null)).("dg_").((isset($this->scope["i"]) ? $this->scope["i"] : null))?>
+
+      <div class="img_view"><font style="font-size: 9px"><?php echo $this->scope["metric"];?></font>
+        <button title="Export to CSV" class="cupid-green" onClick="javascript:location.href='graph.php?<?php echo $this->scope["metric"];
+echo $this->scope["hreg"];
+echo $this->scope["graphargs"];?>&amp;csv=1';return false;">CSV</button>
+        <button title="Export to JSON" class="cupid-green" onClick="javascript:location.href='graph.php?<?php echo $this->scope["metric"];
+echo $this->scope["hreg"];
+echo $this->scope["graphargs"];?>&amp;json=1';return false;">JSON</button>
+        <button title="Decompose aggregate graph" class="shiny-blue" onClick="javascript:location.href='?mreg[]=%5E<?php echo $this->scope["metric"];?>%24<?php echo $this->scope["hreg"];?>&amp;dg=1';return false;">Decompose</button>
+        <input title="Hide/Show Events" type="checkbox" id="<?php echo $this->scope["showEventsId"];?>" onclick="showEvents('<?php echo $this->scope["graphId"];?>', this.checked)"/><label class="show_event_text" for="<?php echo $this->scope["showEventsId"];?>">Hide/Show Events</label>
+        <br /><a href="graph_all_periods.php?title=<?php echo $this->scope["metric"];?>&mreg[]=%5E<?php echo $this->scope["metric"];?>%24<?php echo $this->scope["hreg"];?>&aggregate=1&hl=<?php echo $this->scope["host_list"];?>"><img id="<?php echo $this->scope["graphId"];?>" style="margin-top:5px;" class="noborder <?php echo $this->scope["additional_host_img_css_classes"];?>" src="graph.php?title=<?php echo $this->scope["metric"];?>&mreg[]=%5E<?php echo $this->scope["metric"];?>%24$<?php echo $this->scope["hreg"];
+echo $this->scope["graphargs"];?>&aggregate=1&hl=<?php echo $this->scope["host_list"];?>" /></a>
+      </div>
+      <?php echo ($this->assignInScope((isset($this->scope["i"]) ? $this->scope["i"] : null) + 1, 'i'));?>
+
+      <?php 
+/* -- foreach end output */
+	}
+}?>
+
+    <?php 
+}?>
+
+    <?php 
+}?>
+
+  </div>
+</div>
+<div style="clear: left"></div>
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/decompose_graph.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/decompose_graph.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/decompose_graph.tpl.d17.php	(revision 755)
@@ -0,0 +1,82 @@
+<?php
+/* template head */
+/* end template head */ ob_start(); /* template body */ ?><style>
+.img_view {
+  float: left;
+  margin: 0 0 10px 10px;
+}
+</style>
+<script>
+  function refreshDecomposeGraph() {
+    $("#decompose-graphs img").each(function (index) {
+	var src = $(this).attr("src");
+	if (src.indexOf("graph.php") == 0) {
+          var l = src.indexOf("&_=");
+          if (l != -1)
+            src = src.substring(0, l);
+	  var d = new Date();
+	  $(this).attr("src", src + "&_=" + d.getTime());
+	}    
+    });
+  }
+
+  $(function() {
+    $( "#popup-dialog" ).dialog({ autoOpen: false, minWidth: 850 });
+    $("#create_view_button")
+      .button()
+      .click(function() {
+	$( "#create-new-view-dialog" ).dialog( "open" );
+    });;
+  });
+</script>
+<div id="metric-actions-dialog" title="Metric Actions">
+<div id="metric-actions-dialog-content">
+	Available Metric actions.
+</div>
+</div>
+<div id="popup-dialog" title="Inspect Graph">
+  <div id="popup-dialog-content">
+  </div>
+</div>
+<div id="decompose-graph-content">
+  <div id=decompose-graphs>
+    <?php if ((isset($this->scope["number_of_items"]) ? $this->scope["number_of_items"] : null) == 0) {
+?>
+    <div class="ui-widget">
+      <div class="ui-state-default ui-corner-all" style="padding: 0 .7em;"> 
+        <p><span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span>
+          No graphs decomposed
+      </div>
+    </div>
+    <?php 
+}
+else {
+?>
+      <?php 
+$_fh0_data = (isset($this->scope["items"]) ? $this->scope["items"] : null);
+if ($this->isTraversable($_fh0_data) == true)
+{
+	foreach ($_fh0_data as $this->scope['item'])
+	{
+/* -- foreach start output */
+?>
+      <div class="img_view">
+        <button title="Export to CSV" class="cupid-green" onClick="javascript:location.href='graph.php?<?php echo $this->scope["item"]["url_args"];?>&amp;csv=1';return false;">CSV</button>
+        <button title="Export to JSON" class="cupid-green" onClick="javascript:location.href='graph.php?<?php echo $this->scope["item"]["url_args"];?>&amp;json=1';return false;">JSON</button>
+        <button title="Inspect Graph" onClick="inspectGraph('<?php echo $this->scope["item"]["url_args"];?>'); return false;" class="shiny-blue">Inspect</button>
+        <br /><a href="graph_all_periods.php?<?php echo $this->scope["item"]["url_args"];?>"><img class="noborder <?php echo $this->scope["additional_host_img_css_classes"];?>" style="margin-top:5px;" src="graph.php?<?php echo $this->scope["item"]["url_args"];?>" /></a>
+      </div>
+      <?php 
+/* -- foreach end output */
+	}
+}?>
+
+    <?php 
+}?>
+
+  </div>
+</div>
+<div style="clear: left"></div>
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/footer.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/footer.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/footer.tpl.d17.php	(revision 755)
@@ -0,0 +1,84 @@
+<?php
+/* template head */
+/* end template head */ ob_start(); /* template body */ ?><!-- Begin footer.tpl -->
+</form> <!-- ganglia-form -->
+</div> <!-- tabs-main -->
+
+<div id="tabs-search">
+  Search term matches any number of metrics and hosts. For example type web or disk; wait a split second, and a drop down menu will show up with choices.
+  <!-- Uses LiveSearch from http://andreaslagerkvist.com/jquery/live-search/ -->
+  <div id="metric-search">
+    <form method="post" action="/search/">
+      <p>
+	<label>
+	    <small>Search as you type</small><br />
+	    <input type="text" name="q" id="search-field-q" size="60" placeholder="Search as you type" on />
+	</label>
+      </p>
+    </form>
+  </div>
+</div> 
+
+<div id="create-new-view-dialog" title="Create new view">
+  <div id="create-new-view-layer">
+    <form id="create_view_form">
+      <input type="hidden" name="create_view" value="1">
+      <fieldset>
+	 <label for="name">View Name</label>
+	 <input type="text" name="view_name" id="view_name" class="text ui-widget-content ui-corner-all" />
+         <center><button onclick="createView(); return false;">Create</button></center>
+      </fieldset>
+    </form>
+  </div>
+  <div id="create-new-view-confirmation-layer"></div>
+</div>
+
+<div id="tabs-mobile"></div>
+
+<div id="tabs-autorotation">
+Invoke automatic rotation system. Automatic rotation rotates all of the graphs/metrics specified in a view waiting 
+30 seconds in between each. This will run as long as you have this page open.
+<p>
+Please select the view you want to rotate.</p>
+  <div id="tabs-autorotation-chooser">
+Loading view, please wait...<img src="img/spinner.gif" />
+  </div>
+</div>
+
+<div id="tabs-livedashboard">
+Live dashboard provides you with an overview of all view metrics in a compact format. Data updates every 15 seconds.
+Only those elements that contain a metric or graph report are supported. Aggregate graphs will not be included.
+<p>
+You can get more graphs per page by using your browser zoom functionality.
+<p>
+Please select the view you want to view</p>
+  <div id="tabs-livedashboard-chooser">
+Loading view, please wait...<img src="img/spinner.gif" />
+  </div>
+</div>
+
+
+<hr />
+<div align="center">
+<font size="-1" class="footer">
+Ganglia Web Frontend version <?php echo $this->scope["webfrontend_version"];?>
+
+<a href="http://ganglia.sourceforge.net/downloads.php?component=ganglia-webfrontend&amp;version=<?php echo $this->scope["webfrontend_version"];?>">Check for Updates.</a><br />
+
+Ganglia Web Backend <i>(<?php echo $this->scope["webbackend_component"];?>)</i> version <?php echo $this->scope["webbackend_version"];?>
+
+<a href="http://ganglia.sourceforge.net/downloads.php?component=<?php echo $this->scope["webbackend_component"];?>&amp;version=<?php echo $this->scope["webbackend_version"];?>">Check for Updates.</a><br />
+
+Downloading and parsing ganglia's XML tree took <?php echo $this->scope["parsetime"];?>.<br />
+Images created with <a href="http://www.rrdtool.org/">RRDtool</a> version <?php echo $this->scope["rrdtool_version"];?>.<br />
+<?php echo $this->globals["ad"];?> <?php echo $this->globals["version"];?>.<br />
+</font>
+</div>
+</div> <!-- div-tabs -->
+</BODY>
+<!-- End footer.tpl -->
+</HTML>
+
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/grid_tree.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/grid_tree.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/grid_tree.tpl.d17.php	(revision 755)
@@ -0,0 +1,63 @@
+<?php
+/* template head */
+/* end template head */ ob_start(); /* template body */ ?><table border="0" width="100%">
+<tr>
+  <td class="title"><B><?php echo $this->scope["self"];?> Grid Tree</b></td>
+</tr>
+</table>
+
+<div align="center">
+<table cellspacing="5" cellpadding="5" border="1">
+<tr>
+
+<?php if (((isset($this->scope["parentgrid"]) ? $this->scope["parentgrid"] : null) !== null)) {
+?>
+<td align="center">
+<table cellpadding="3" cellspacing="3" border="0">
+<?php echo $this->scope["parents"];?>
+
+</table>
+</td>
+<?php 
+}?>
+
+</tr>
+
+<tr>
+<td align="center">
+
+<table cellpadding="3" cellspacing="3" border="0">
+<tr>
+ <td colspan="<?php echo $this->scope["n"];?>" class="self" align="center" style="border: thin solid rgb(47,47,47);">
+  <?php echo $this->scope["self"];?>
+
+ </td>
+</tr>
+
+<tr>
+ <?php echo $this->scope["children"];?>
+
+</tr>
+</table>
+
+</td>
+</tr>
+
+</table>
+</div>
+
+<p>
+<hr />
+<b>Legend:</b>
+<table cellspacing="5" border="0">
+<tr>
+<td class="self" width="20">&nbsp;</td><td>This Grid.</td>
+</tr>
+<tr>
+<td class="grid">&nbsp;</td><td>A Remote Grid.</td>
+</tr>
+</table>
+
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/header.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/header.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/header.tpl.d17.php	(revision 755)
@@ -0,0 +1,302 @@
+<?php
+/* template head */
+if (function_exists('Dwoo_Plugin_include')===false)
+	$this->getLoader()->loadPlugin('include');
+/* end template head */ ob_start(); /* template body */ ?><!-- Begin header.tpl -->
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<title>Ganglia:: <?php echo $this->scope["page_title"];?></title>
+<meta http-equiv="Content-type" content="text/html; charset=utf-8">
+<link type="text/css" href="css/smoothness/jquery-ui-1.9.1.custom.min.css" rel="stylesheet" />
+<link type="text/css" href="css/jquery.liveSearch.css" rel="stylesheet" />
+<link type="text/css" href="css/jquery.multiselect.css" rel="stylesheet" />
+<link type="text/css" href="css/jquery.flot.events.css" rel="stylesheet" />
+<link type="text/css" href="./styles.css" rel="stylesheet" />
+<script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
+<script type="text/javascript" src="js/jquery-ui-1.9.1.custom.min.js"></script>
+<script type="text/javascript" src="js/jquery.livesearch.min.js"></script>
+<script type="text/javascript" src="js/ganglia.js"></script>
+<script type="text/javascript" src="js/jquery.gangZoom.js"></script>
+<script type="text/javascript" src="js/jquery.cookie.js"></script>
+<script type="text/javascript" src="js/jquery-ui-timepicker-addon.js"></script>
+<script type="text/javascript" src="js/jquery.ba-bbq.min.js"></script>
+<script type="text/javascript" src="js/combobox.js"></script>
+<script type="text/javascript" src="js/jquery.scrollTo-1.4.2-min.js"></script>
+<script type="text/javascript" src="js/jquery.buttonsetv.js"></script>
+<script type="text/javascript">
+    var server_utc_offset=<?php echo $this->scope["server_utc_offset"];?>;
+    
+    var g_refresh_timer = setTimeout("refresh()", <?php echo $this->scope["refresh"];?> * 1000);
+
+    function refreshHeader() {
+      $.get('header.php?date_only=1', function(data) {
+        var title = $("#page_title").text();
+        var l = title.lastIndexOf(" for ");
+        title = title.substring(0, l);
+        title += " for " + data;
+        $("#page_title").text(title);
+        });
+    }
+
+    function refresh() {
+      var selected_tab = $("#selected_tab").val();
+      if (selected_tab == "agg") {
+        refreshAggregateGraph();
+        g_refresh_timer = setTimeout("refresh()", <?php echo $this->scope["refresh"];?> * 1000);
+      } else if (selected_tab == "v") {
+        refreshHeader();
+        if ($.isFunction(window.refreshView)) {
+          refreshView();
+          g_refresh_timer = setTimeout("refresh()", <?php echo $this->scope["refresh"];?> * 1000);
+        } else if ($.isFunction(window.refreshDecomposeGraph)) {
+          refreshDecomposeGraph();
+          g_refresh_timer = setTimeout("refresh()", <?php echo $this->scope["refresh"];?> * 1000);
+        } else
+          ganglia_form.submit();
+      } else if (selected_tab == "ev") {
+        refreshOverlayEvent();
+        g_refresh_timer = setTimeout("refresh()", <?php echo $this->scope["refresh"];?> * 1000);
+      } else if (selected_tab == "m") {
+        if ($.isFunction(window.refreshClusterView)) {
+          refreshHeader();
+          refreshClusterView();
+          g_refresh_timer = setTimeout("refresh()", <?php echo $this->scope["refresh"];?> * 1000);
+        } else if ($.isFunction(window.refreshHostView)) {
+          refreshHeader();
+          refreshHostView();
+          g_refresh_timer = setTimeout("refresh()", <?php echo $this->scope["refresh"];?> * 1000);
+        } else
+          ganglia_form.submit();
+      } else
+        ganglia_form.submit();
+    }
+
+    $(function() {
+      g_overlay_events = ($("#overlay_events").val() == "true");
+
+      g_tabIndex = new Object();
+      g_tabName = [];
+      var tabName = ["m", "s", "v", "agg", "ch", "ev", "rot", "mob"];
+      var j = 0;
+      for (var i in tabName) {
+        if (tabName[i] == "ev" && !g_overlay_events)
+          continue;
+        g_tabIndex[tabName[i]] = j++;
+        g_tabName.push(tabName[i]);
+      }
+
+      // Follow tab's URL instead of loading its content via ajax
+      var tabs = $("#tabs");
+      if (tabs[0]) {
+        tabs.tabs();
+        // Restore previously selected tab
+        var selected_tab = $("#selected_tab").val();
+        //alert("selected_tab = " + selected_tab);
+        if (typeof g_tabIndex[selected_tab] != 'undefined') {
+          try {
+            //alert("Selecting tab: " + selected_tab);
+            tabs.tabs("select", g_tabIndex[selected_tab]);
+            if (selected_tab == "rot")
+              autoRotationChooser();
+          } catch (err) {
+            try {
+              alert("Error(ganglia.js): Unable to select tab: " + 
+                    selected_tab + ". " + err.getDescription());
+            } catch (err) {
+              // If we can't even show the error, fail silently.
+            }
+          }
+        }
+
+        tabs.bind("tabsselect", function(event, ui) {
+          $("#selected_tab").val(g_tabName[ui.index]);
+          if (g_tabName[ui.index] != "mob")
+            $.cookie("ganglia-selected-tab-" + window.name, ui.index);
+          if (ui.index == g_tabIndex["m"] ||
+              ui.index == g_tabIndex["v"] ||
+              ui.index == g_tabIndex["ch"])
+            ganglia_form.submit();
+        });
+      }
+    });
+
+    $(function() {
+      $("#metrics-picker").combobox();
+
+      <?php echo $this->scope["is_metrics_picker_disabled"];?>
+
+
+      $(".header_btn").button();
+    });
+
+  $(function () {
+
+    done = function done(startTime, endTime) {
+            setStartAndEnd(startTime, endTime);
+            document.forms['ganglia_form'].submit();
+    }
+
+    cancel = function (startTime, endTime) {
+            setStartAndEnd(startTime, endTime);
+    }
+
+    defaults = {
+        startTime: <?php echo $this->scope["start_timestamp"];?>,
+        endTime: <?php echo $this->scope["end_timestamp"];?>,
+        done: done,
+        cancel: cancel
+    }
+
+    $(".host_small_zoomable").gangZoom($.extend({
+        paddingLeft: 67,
+        paddingRight: 30,
+        paddingTop: 38,
+        paddingBottom: 25
+    }, defaults));
+
+    $(".host_medium_zoomable").gangZoom($.extend({
+        paddingLeft: 67,
+        paddingRight: 30,
+        paddingTop: 38,
+        paddingBottom: 40
+    }, defaults));
+
+    $(".host_default_zoomable").gangZoom($.extend({
+        paddingLeft: 66,
+        paddingRight: 30,
+        paddingTop: 37,
+        paddingBottom: 50
+    }, defaults));
+
+    $(".host_large_zoomable").gangZoom($.extend({
+        paddingLeft: 66,
+        paddingRight: 29,
+        paddingTop: 37,
+        paddingBottom: 56
+    }, defaults));
+
+    $(".cluster_zoomable").gangZoom($.extend({
+        paddingLeft: 67,
+        paddingRight: 30,
+        paddingTop: 37,
+        paddingBottom: 50
+    }, defaults));
+
+    function rrdDateTimeString(date) {
+      return (date.getMonth() + 1) + "/" + date.getDate() + "/" + date.getFullYear() + " " + date.getHours() + ":" + date.getMinutes();
+    }
+
+    function setStartAndEnd(startTime, endTime) {
+        // we're getting local start/end times.
+
+        // getTimezoneOffset returns negative values east of UTC,
+        // which is the opposite of PHP. we want negative values to the west.
+        var local_offset = new Date().getTimezoneOffset() * 60 * -1;
+        var delta = local_offset - server_utc_offset;
+        var date = new Date((Math.floor(startTime) - delta) * 1000);
+        $("#datepicker-cs").val(rrdDateTimeString(date));
+        date = new Date((Math.floor(endTime) - delta) * 1000);
+        $("#datepicker-ce").val(rrdDateTimeString(date));
+    }
+
+    initShowEvent();
+    initTimeShift();
+  });
+
+
+</script>
+<?php echo $this->scope["custom_time_head"];?>
+
+</head>
+<body style="background-color: #ffffff;" onunload="g_refresh_timer=null">
+<?php if (((isset($this->scope["user_header"]) ? $this->scope["user_header"] : null) !== null)) {
+?>
+<?php echo Dwoo_Plugin_include($this, "user_header.tpl", null, null, null, '_root', null);?>
+
+<?php 
+}?>
+
+
+<?php if ((isset($this->scope["auth_system_enabled"]) ? $this->scope["auth_system_enabled"] : null)) {
+?>
+<div style="float:right">
+  <?php if ((isset($this->scope["username"]) ? $this->scope["username"] : null)) {
+?>
+    Currently logged in as: <?php echo $this->scope["username"];?> | <a href="logout.php">Logout</a>
+  <?php 
+}
+else {
+?>
+    You are not currently logged in. | <a href="login.php">Login</a>
+  <?php 
+}?>
+
+</div>
+<br style="clear:both"/>
+<?php 
+}?>
+
+
+<div id="tabs">
+<ul>
+  <li><a href="#tabs-main">Main</a></li>
+  <li><a href="#tabs-search">Search</a></li>
+  <li><a href="#tabs-main">Views</a></li>
+  <li><a href="aggregate_graphs.php">Aggregate Graphs</a></li>
+  <li><a href="#tabs-main">Compare Hosts</a></li>
+<?php if ((isset($this->scope["overlay_events"]) ? $this->scope["overlay_events"] : null)) {
+?>
+  <li><a href="events.php">Events</a></li>
+<?php 
+}?>
+
+  <li><a href="#tabs-autorotation" onclick="autoRotationChooser();">Automatic Rotation</a></li>
+  <li><a href="#tabs-livedashboard" onclick="liveDashboardChooser();">Live Dashboard</a></li>  
+  <li><a href="#tabs-mobile" onclick="window.location.href='mobile.php';">Mobile</a></li>
+</ul>
+
+<div id="tabs-main">
+<form action="<?php echo $this->scope["page"];?>" method="GET" name="ganglia_form">
+  <div style="background-color:#dddddd;padding:5px;">
+     <big style="float:left;"><b id="page_title"><?php echo $this->scope["page_title"];?> for <?php echo $this->scope["date"];?></b></big><input style="float:right;" class="header_btn" type="submit" value="Get Fresh Data"/><div style="clear:both"></div>
+  </div>
+  <div style="padding:5px 5px 0 5px;">
+    <div style="float:left;" id="range_menu" class="nobr"><?php echo $this->scope["range_menu"];?></div>
+    <div style="float:left;" id="custom_range_menu"><?php echo $this->scope["custom_time"];?></div>
+    <div style="float:right;"><?php echo $this->scope["additional_buttons"];?>&nbsp;&nbsp;<?php echo $this->scope["alt_view"];?></div>
+    <div style="clear:both;"></div>
+  </div>
+  <div id="sort_menu" style="padding:5px 5px 0 5px;">
+   Metric&nbsp;&nbsp; <select name="m" id="metrics-picker"><?php echo $this->scope["picker_metrics"];?></select>&nbsp;&nbsp;
+     <?php echo $this->scope["sort_menu"];?>
+
+  </div>
+<?php if ((isset($this->scope["node_menu"]) ? $this->scope["node_menu"] : null) != "") {
+?>
+  <div id="sort_menu" style="padding:5px 5px 0 5px;">
+    <?php echo $this->scope["node_menu"];?>&nbsp;&nbsp;<?php echo $this->scope["additional_filter_options"];?>
+
+  </div>
+<?php 
+}?>
+
+
+<input type="hidden" name="tab" id="selected_tab" value="<?php echo $this->scope["selected_tab"];?>">
+<input type="hidden" id="vn" name="vn" value="<?php echo $this->scope["view_name"];?>">
+<?php if ((isset($this->scope["overlay_events"]) ? $this->scope["overlay_events"] : null)) {
+?>
+<input type="hidden" id="overlay_events" value="true">
+<?php 
+}
+else {
+?>
+<input type="hidden" id="overlay_events" value="false">
+<?php 
+}?>
+
+<hr size="1" noshade>
+<!-- End header.tpl -->
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/host_extra.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/host_extra.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/host_extra.tpl.d17.php	(revision 755)
@@ -0,0 +1,6 @@
+<?php
+/* template head */
+/* end template head */ ob_start(); /* template body */ ?><!-- A place to put custom HTML for the host view. Re-implement in a skin. -->
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/host_overview.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/host_overview.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/host_overview.tpl.d17.php	(revision 755)
@@ -0,0 +1,74 @@
+<?php
+/* template head */
+if (function_exists('Dwoo_Plugin_include')===false)
+	$this->getLoader()->loadPlugin('include');
+/* end template head */ ob_start(); /* template body */ ?><br>
+<table border="0" width="100%">
+
+<tr>
+ <td align="left" valign="TOP">
+
+<img src="<?php echo $this->scope["node_image"];?>" class="noborder" height="60" width="30" title="<?php echo $this->scope["host"];?>"/>
+<?php echo $this->scope["node_msg"];?>
+
+
+<table border="0" width="100%">
+<tr>
+  <td colspan="2" class="title">Time and String Metrics</td>
+</tr>
+
+<?php 
+$_fh0_data = (isset($this->scope["s_metrics_data"]) ? $this->scope["s_metrics_data"] : null);
+if ($this->isTraversable($_fh0_data) == true)
+{
+	foreach ($_fh0_data as $this->scope['s_metric'])
+	{
+/* -- foreach start output */
+?>
+<tr>
+ <td class="footer" width="30%"><?php echo $this->scope["s_metric"]["name"];?></td><td><?php echo $this->scope["s_metric"]["value"];?></td>
+</tr>
+<?php 
+/* -- foreach end output */
+	}
+}?>
+
+
+<tr><td>&nbsp;</td></tr>
+
+<tr>
+  <td colspan="2" class="title">Constant Metrics</td>
+</tr>
+
+<?php 
+$_fh1_data = (isset($this->scope["c_metrics_data"]) ? $this->scope["c_metrics_data"] : null);
+if ($this->isTraversable($_fh1_data) == true)
+{
+	foreach ($_fh1_data as $this->scope['c_metric'])
+	{
+/* -- foreach start output */
+?>
+<tr>
+ <td class="footer" width="30%"><?php echo $this->scope["c_metric"]["name"];?></td><td><?php echo $this->scope["c_metric"]["value"];?></td>
+</tr>
+<?php 
+/* -- foreach end output */
+	}
+}?>
+
+</table>
+
+ <hr />
+<?php if (((isset($this->scope["extra"]) ? $this->scope["extra"] : null) !== null)) {
+?>
+<?php echo Dwoo_Plugin_include($this, "".(isset($this->scope["extra"]) ? $this->scope["extra"] : null)."", null, null, null, '_root', null);?>
+
+<?php 
+}?>
+
+</td> 
+</table>
+
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/host_view.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/host_view.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/host_view.tpl.d17.php	(revision 755)
@@ -0,0 +1,426 @@
+<?php
+/* template head */
+if (function_exists('Dwoo_Plugin_include')===false)
+	$this->getLoader()->loadPlugin('include');
+if (function_exists('Dwoo_Plugin_regex_replace')===false)
+	$this->getLoader()->loadPlugin('regex_replace');
+/* end template head */ ob_start(); /* template body */ ?><!-- Begin host_view.tpl -->
+<style type="text/css">
+/* don't display legends for these small graphs */
+.flotlegend, .flotlegendtoplabel {
+  display: none !important;
+}
+.flotheader {
+  margin-top: 2em;
+}
+.flottitle {
+  padding-right: 4em;
+  font-weight: bold;
+}
+.img_view {
+  float: left;
+  margin: 0 0 10px 10px;
+}
+</style>
+<script type="text/javascript">
+var SEPARATOR = "_|_";
+var ALL_GROUPS = "ALLGROUPS";
+var NO_GROUPS = "NOGROUPS";
+// Map metric group id to name
+var g_mgMap = new Object();
+
+function clearStoredMetricGroups() {
+  var stored_groups = $('input[name="metric_group"]');
+  stored_groups.val(NO_GROUPS);
+}
+
+function selectAllMetricGroups() {
+  var stored_groups = $('input[name="metric_group"]');
+  stored_groups.val(ALL_GROUPS);
+}
+
+function addMetricGroup(mgName) {
+  var stored_groups = $('input[name="metric_group"]');
+
+  var open_groups = stored_groups.val();
+  if (open_groups == ALL_GROUPS)
+    return; // no exceptions
+
+  var groups = open_groups.split(SEPARATOR);
+  switch (groups[0]) {
+    case ALL_GROUPS:
+      // Remove from except list
+      for (var i = 1; i < groups.length; i++) {
+        if (groups[i] == mgName) {
+          groups.splice(i, 1);
+          break;
+        }
+      }
+      open_groups = groups.join(SEPARATOR);
+    break;
+    case NO_GROUPS:
+      // Add to list if not already there
+      var inList = false;
+      for (var i = 1; i < groups.length; i++) {
+         if (groups[i] == mgName) {
+           inList = true;
+           break;
+         }
+      }
+      if (!inList) {
+        open_groups += SEPARATOR;
+        open_groups += mgName;
+      }
+    break;
+    default:
+      alert("Unrecognized group option - " + groups[0]);
+  }
+  stored_groups.val(open_groups);
+}
+
+function removeMetricGroup(mgName) {
+  var stored_groups = $('input[name="metric_group"]');
+
+  var open_groups = stored_groups.val();
+  if (open_groups == NO_GROUPS)
+    return; // no exceptions
+
+  var groups = open_groups.split(SEPARATOR);
+  switch (groups[0]) {
+    case ALL_GROUPS:
+      var inList = false;
+      for (var i = 1; i < groups.length; i++) {
+        if (groups[i] == mgName) {
+          inList = true;
+          break;
+        }
+      }
+      if (!inList) {
+        open_groups += SEPARATOR;
+        open_groups += mgName;
+      }
+    break;
+    case NO_GROUPS:
+      for (var i = 1; i < groups.length; i++) {
+        if (groups[i] == mgName) {
+          groups.splice(i, 1);
+          break;
+        }
+      }
+      open_groups = groups.join(SEPARATOR);
+    break;
+    default:
+      alert("Unrecognized group option - " + groups[0]);
+  }
+  stored_groups.val(open_groups);
+}
+
+function toggleMetricGroup(mgId, mgDiv) {
+  var mgName = g_mgMap[mgId];
+  if (mgDiv.is(":visible")) {
+    // metric group is being closed
+    removeMetricGroup(mgName);
+    mgDiv.html("");
+    mgDiv.hide();
+  } else {
+    addMetricGroup(mgName);
+    var url = 'metric_group_view.php?<?php echo $this->scope["baseGraphArgs"];?>&metric_group=' + mgName;
+    url += "&event=";
+    url += ($("#show_all_events").attr("checked") == "checked") ? "show" : "hide";
+    url += "&ts=";
+    url += ($("#timeshift_overlay").attr("checked") == "checked") ? "1" : "0";
+
+    $.get(url, 
+          function(data) {
+            mgDiv.html(data);
+	    mgInitEventBtns(mgDiv);
+	    mgInitTimeshiftBtns(mgDiv);
+            mgDiv.show();
+          });
+  }
+}
+
+function jumpToMetricGroup(mgId) {
+  //alert("jumping to " + mgId);
+  $.scrollTo($('#' + mgId));
+}
+
+function refreshHostView() {
+  $.get('host_overview.php?h=<?php echo $this->scope["hostname"];?>&c=<?php echo $this->scope["cluster"];?>', function(data) {
+    $('#host_overview_div').html(data);
+  });
+
+  $("#optional_graphs img").each(function (index) {
+    var src = $(this).attr("src");
+    if ((src.indexOf("graph.php") == 0) ||
+        (src.indexOf("./graph.php") == 0)) {
+      var d = new Date();
+      $(this).attr("src", jQuery.param.querystring(src, "&_=" + d.getTime()));
+    }    
+  });
+
+  $("#metrics img").each(function (index) {
+    var src = $(this).attr("src");
+    if ((src.indexOf("graph.php") == 0)  ||
+        (src.indexOf("./graph.php") == 0)) {
+      var d = new Date();
+      $(this).attr("src", jQuery.param.querystring(src, "&_=" + d.getTime()));
+    }    
+  });
+}
+
+function mgInitEventBtns(mgDiv) {
+  var checked = $("#show_all_events").attr("checked");
+  mgDiv.find("[id^=" + SHOW_EVENTS_BASE_ID + "]").each(function() {
+    $(this).button();
+    if (checked == "checked")
+      $(this).attr("checked", 'checked');
+    else
+      $(this).removeAttr("checked");
+    $(this).button('refresh');
+  });
+}
+
+function mgInitTimeshiftBtns(mgDiv) {
+  var checked = $("#timeshift_overlay").attr("checked");
+  mgDiv.find("[id^=" + TIME_SHIFT_BASE_ID + "]").each(function() {
+    $(this).button();
+    if (checked == "checked")
+      $(this).attr("checked", 'checked');
+    else
+      $(this).removeAttr("checked");
+    $(this).button('refresh');
+  });
+}
+
+$(function() {
+  var stored_groups = $('input[name="metric_group"]');
+  stored_groups.val("<?php echo $this->scope["g_open_metric_groups"];?>");
+ 
+  $("#edit_optional_graphs").dialog({ autoOpen: false, minWidth: 550,
+    beforeClose: function(event, ui) { location.reload(true); } });
+
+  $("#close_edit_optional_graphs_link").button();
+  $("#popup-dialog").dialog({ autoOpen: false, minWidth: 850 });
+
+  $("#edit_optional_graphs_button").button();
+  $("#edit_optional_graphs_button").click(function(event) {
+    $("#edit_optional_graphs").dialog('open');
+    $('#edit_optional_graphs_content').html('<img src="img/spinner.gif" />');
+    $.get('edit_optional_graphs.php', "hostname=<?php echo $this->scope["hostname"];?>", function(data) {
+      $('#edit_optional_graphs_content').html(data);
+    })
+    return false;
+  });
+
+  $("#save_optional_graphs_button").button();
+  $("#save_optional_graphs_button").click(function(event) {
+    $.get('edit_optional_graphs.php', $("#edit_optional_reports_form").serialize(), function(data) {
+      $('#edit_optional_graphs_content').html(data);
+      $("#save_optional_graphs_button").hide();
+    });
+    return false;
+  });
+
+  $("#expand_all_metric_groups").button();
+  $("#expand_all_metric_groups").click(function(event) {
+    selectAllMetricGroups();
+    document.ganglia_form.submit();
+    return false;
+  });
+
+  $("#collapse_all_metric_groups").button();
+  $("#collapse_all_metric_groups").click(function(event) {
+    clearStoredMetricGroups();
+    document.ganglia_form.submit();
+    return false;
+  });
+
+  $("#host_overview").button();
+  $('#host_overview').click(function() {
+    var options = { to: { width: 200, height: 60 } }; 
+    $("#host_overview_div").toggle("blind", options, 500);
+    return false;
+  });
+
+  $('.metric-group').each(function() {
+    $(this).button();
+    $(this).click(function() {
+      var id = $(this).attr('id');
+      toggleMetricGroup(id, $("#"+id+"_div"));
+      return false;
+    });
+  });
+});
+</script>
+
+<?php if ((isset($this->scope["graph_engine"]) ? $this->scope["graph_engine"] : null) == "flot") {
+?>
+<script language="javascript" type="text/javascript" src="js/jquery.flot.min.js"></script>
+<script type="text/javascript" src="js/create-flot-graphs.js"></script>
+<style type="text/css">
+.flotgraph2 {
+  height: <?php echo $this->scope["graph_height"];?>px;
+  width:  <?php echo $this->scope["graph_width"];?>px;
+}
+</style>
+<?php 
+}?>
+
+
+<style type="text/css">
+  .toggler { width: 500px; height: 200px; }
+  #effect { width: 240px; height: 135px; padding: 0.4em; position: relative; }
+  #effect h3 { margin: 0; padding: 0.4em; text-align: center; }
+</style>
+
+<div id="metric-actions-dialog" title="Metric Actions">
+  <div id="metric-actions-dialog-content">
+	Available Metric actions.
+  </div>
+</div>
+<div id="popup-dialog" title="Inspect Graph">
+  <div id="popup-dialog-navigation"></div>
+  <div id="popup-dialog-content">
+  </div>
+</div>
+
+<div>
+<button id="host_overview" class="button">Host Overview</button>
+</div>
+
+<div style="display: none;" id="host_overview_div">
+<?php echo Dwoo_Plugin_include($this, 'host_overview.tpl', null, null, null, '_root', null);?>
+
+</div>
+
+<div id="edit_optional_graphs">
+  <div style="text-align:center">
+    <button id="save_optional_graphs_button">Save</button>
+  </div>
+  <div id="edit_optional_graphs_content" style="padding: .4em 1em .4em 10px;">Empty</div>
+</div>
+
+<div id="optional_graphs" style="padding-top:5px;">
+<?php echo $this->scope["optional_reports"];?>
+
+<div style='clear: left'></div>
+<?php if ((isset($this->scope["may_edit_cluster"]) ? $this->scope["may_edit_cluster"] : null)) {
+?>
+<div style="text-align:center"><button id="edit_optional_graphs_button">Edit Optional Graphs</button></div>
+<?php 
+}?>
+
+</div>
+
+<div id="sort_column_dropdowns" style="padding-top:5px;">
+<table border="0" width="100%">
+<tr>
+  <td style="text-align:center;background-color:rgb(238,238,238);">
+  <?php echo $this->scope["host"];?> <strong>graphs</strong> (<?php echo $this->scope["host_metrics_count"];?>)
+  last <strong><?php echo $this->scope["range"];?></strong>
+  sorted <strong><?php echo $this->scope["sort"];?></strong>
+<?php if (((isset($this->scope["columns_dropdown"]) ? $this->scope["columns_dropdown"] : null) !== null)) {
+?>
+  <font>
+    Columns&nbsp;&nbsp;<?php echo $this->scope["metric_cols_menu"];?>
+
+    Size&nbsp;&nbsp;<?php echo $this->scope["size_menu"];?>
+
+  </font>
+<?php 
+}?>
+
+  </td>
+</tr>
+</table>
+
+</div>
+
+<div id=metrics style="padding-top:5px">
+<center>
+<div style="padding-bottom:5px;">
+<button id="expand_all_metric_groups">Expand All Metric Groups</button>
+<button id="collapse_all_metric_groups">Collapse All Metric Groups</button>
+<input title="Time Shift Overlay - overlays previous period on all graphs" type="checkbox" id="timeshift_overlay" onclick="showTimeshiftOverlay(this.checked)"/><label for="timeshift_overlay">Timeshift Overlay</label>
+<select id="jump_to_metric_group" class="ui-corner-all" onchange="jumpToMetricGroup(this.options[this.selectedIndex].value);">
+<option disabled="disabled" selected="selected">Jump To Metric Group...</option>
+<?php 
+$_fh0_data = (isset($this->scope["g_metrics_group_data"]) ? $this->scope["g_metrics_group_data"] : null);
+if ($this->isTraversable($_fh0_data) == true)
+{
+	foreach ($_fh0_data as $this->scope['group']=>$this->scope['g_metrics'])
+	{
+/* -- foreach start output */
+?>
+<?php $this->scope["mgId"]="mg_";
+$this->scope["mgId"].=Dwoo_Plugin_regex_replace($this, (isset($this->scope["group"]) ? $this->scope["group"] : null), '/[^a-zA-Z0-9_]/', '_')?>
+
+<option value="<?php echo $this->scope["mgId"];?>"><?php echo $this->scope["group"];?></a>
+<?php 
+/* -- foreach end output */
+	}
+}?>
+
+</select>
+</div>
+<table>
+<tr>
+ <td>
+
+<?php 
+$_fh1_data = (isset($this->scope["g_metrics_group_data"]) ? $this->scope["g_metrics_group_data"] : null);
+if ($this->isTraversable($_fh1_data) == true)
+{
+	foreach ($_fh1_data as $this->scope['group']=>$this->scope['g_metrics'])
+	{
+/* -- foreach start output */
+?>
+<?php $this->scope["mgId"]="mg_";
+$this->scope["mgId"].=Dwoo_Plugin_regex_replace($this, (isset($this->scope["group"]) ? $this->scope["group"] : null), '/[^a-zA-Z0-9_]/', '_')?>
+
+<table border="0" width="100%">
+<tr>
+  <td class="metric">
+  <button id="<?php echo $this->scope["mgId"];?>" class="metric-group" title="Toggle <?php echo $this->scope["group"];?> metrics group on/off"><?php echo $this->scope["group"];?> metrics (<?php echo $this->scope["g_metrics"]["group_metric_count"];?>)</button>
+<script type="text/javascript">$(function() {
+g_mgMap["<?php echo $this->scope["mgId"];?>"] = "<?php echo $this->scope["group"];?>";
+})</script>
+  </td>
+</tr>
+</table>
+
+<?php if ((isset($this->scope["g_metrics"]["visible"]) ? $this->scope["g_metrics"]["visible"]:null)) {
+?>
+<div id="<?php echo $this->scope["mgId"];?>_div">
+<?php 
+}
+else {
+?>
+<div id="<?php echo $this->scope["mgId"];?>_div" class="ui-helper-hidden">
+<?php 
+}?>
+
+<?php if ((isset($this->scope["g_metrics"]["visible"]) ? $this->scope["g_metrics"]["visible"]:null)) {
+?>
+<?php echo Dwoo_Plugin_include($this, 'metric_group_view.tpl', null, null, null, '_root', null);?>
+
+<?php 
+}?>
+
+</div>
+<?php 
+/* -- foreach end output */
+	}
+}?>
+
+ </td>
+</tr>
+</table>
+</center>
+</div>
+<input type="hidden" name="metric_group" value="">
+<!-- End host_view.tpl -->
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/meta_view.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/meta_view.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/meta_view.tpl.d17.php	(revision 755)
@@ -0,0 +1,221 @@
+<?php
+/* template head */
+/* end template head */ ob_start(); /* template body */ ;
+if (((isset($this->scope["filters"]) ? $this->scope["filters"] : null) !== null)) {
+?>
+<table border="0" width="100%">
+  <tr>
+    <?php 
+$_fh1_data = (isset($this->scope["filters"]) ? $this->scope["filters"] : null);
+if ($this->isTraversable($_fh1_data) == true)
+{
+	foreach ($_fh1_data as $this->scope['filter'])
+	{
+/* -- foreach start output */
+?>
+      <td>
+        <b><?php echo $this->scope["filter"]["filter_name"];?></b>
+        <select name="choose_filter[<?php echo $this->scope["filter"]["filter_shortname"];?>]" OnChange="ganglia_form.submit();">
+          <option name=""></option>
+          <?php 
+$_fh0_data = (isset($this->scope["filter"]["choice"]) ? $this->scope["filter"]["choice"]:null);
+if ($this->isTraversable($_fh0_data) == true)
+{
+	foreach ($_fh0_data as $this->scope['choice'])
+	{
+/* -- foreach start output */
+?>
+          <?php if ($this->readVar("choose_filter.".(isset($this->scope["filter"]) ? $this->scope["filter"] : null).".filter_shortname") == (isset($this->scope["choice"]) ? $this->scope["choice"] : null)) {
+?>
+          <option name="<?php echo $this->scope["choice"];?>" selected><?php echo $this->scope["choice"];?></option>
+          <?php 
+}
+else {
+?>
+          <option name="<?php echo $this->scope["choice"];?>"><?php echo $this->scope["choice"];?></option>
+          <?php 
+}?>
+
+          <?php 
+/* -- foreach end output */
+	}
+}?>
+
+        </select>
+      </td>
+    <?php 
+/* -- foreach end output */
+	}
+}?>
+
+  </tr>
+</table>
+<?php 
+}?>
+
+
+<table border="0" width="100%">
+
+<tr>
+<td colspan="3">&nbsp;</td>
+</tr>
+
+<?php 
+$_fh2_data = (isset($this->scope["sources"]) ? $this->scope["sources"] : null);
+if ($this->isTraversable($_fh2_data) == true)
+{
+	foreach ($_fh2_data as $this->scope['source'])
+	{
+/* -- foreach start output */
+?>
+<tr>
+  <td class=<?php echo $this->scope["source"]["class"];?> colspan="3">
+    <a href="<?php echo $this->scope["source"]["url"];?>"><strong><?php echo $this->scope["source"]["name"];?></strong></a> <?php echo $this->scope["source"]["alt_view"];?>
+
+  </td>
+</tr>
+
+<tr>
+<?php if (((isset($this->scope["source"]["public"]) ? $this->scope["source"]["public"]:null) !== null)) {
+?>
+<td align="LEFT" valign="TOP">
+<table cellspacing="1" cellpadding="1" width="100%" border="0">
+ <tr><td>CPUs Total:</td><td align="left"><B><?php echo $this->scope["source"]["cpu_num"];?></B></td></tr>
+ <tr><td width="80%">Hosts up:</td><td align="left"><B><?php echo $this->scope["source"]["num_nodes"];?></B></td></tr>
+ <tr><td>Hosts down:</td><td align="left"><B><?php echo $this->scope["source"]["num_dead_nodes"];?></B></td></tr>
+ <tr><td>&nbsp;</td></tr>
+ <tr><td class="footer" colspan="2"><?php echo $this->scope["source"]["cluster_load"];?></td></tr>
+ <tr><td class="footer" colspan="2"><?php echo $this->scope["source"]["cluster_util"];?></td></tr>
+ <tr><td class="footer" colspan="2"><?php echo $this->scope["source"]["localtime"];?></td></tr>
+</table>
+</td>
+
+<?php if (((isset($this->scope["source"]["self_summary_graphs"]) ? $this->scope["source"]["self_summary_graphs"]:null) !== null)) {
+?>
+<td>
+ <table align="center" border="0">
+  <tr>
+
+   <td>
+    <a href="./graph_all_periods.php?<?php echo $this->scope["source"]["graph_url"];?>&amp;g=load_report&amp;z=large">
+      <img src="./graph.php?<?php echo $this->scope["source"]["graph_url"];?>&amp;g=load_report&amp;z=medium"
+           alt="<?php echo $this->scope["source"]["name"];?> LOAD" border="0" />
+    </a>
+   </td>
+   <td>
+    <a href="./graph_all_periods.php?<?php echo $this->scope["source"]["graph_url"];?>&amp;g=mem_report&amp;z=large">
+      <img src="./graph.php?<?php echo $this->scope["source"]["graph_url"];?>&amp;g=mem_report&amp;z=medium"
+           alt="<?php echo $this->scope["source"]["name"];?> MEM" border="0" />
+    </a>
+   </td>
+  </tr>
+
+  <tr>
+   <td>
+    <a href="./graph_all_periods.php?<?php echo $this->scope["source"]["graph_url"];?>&amp;g=cpu_report&amp;z=large">
+      <img src="./graph.php?<?php echo $this->scope["source"]["graph_url"];?>&amp;g=cpu_report&amp;z=medium"
+           alt="<?php echo $this->scope["source"]["name"];?> CPU" border="0" />
+    </a>
+   </td>
+   <td>
+    <a href="./graph_all_periods.php?<?php echo $this->scope["source"]["graph_url"];?>&amp;g=network_report&amp;z=large">
+      <img src="./graph.php?<?php echo $this->scope["source"]["graph_url"];?>&amp;g=network_report&amp;z=medium"
+           alt="<?php echo $this->scope["source"]["name"];?> NETWORK" border="0" />
+    </a>
+   </td>
+
+  </tr>
+ </table>
+</td>
+<?php 
+}?>
+
+
+<?php if (((isset($this->scope["source"]["summary_graphs"]) ? $this->scope["source"]["summary_graphs"]:null) !== null)) {
+?>
+<td>
+ <table align="center" border="0">
+  <tr>
+
+      <td>
+      <a href="<?php echo $this->scope["source"]["url"];?>">
+        <img src="./graph.php?<?php echo $this->scope["source"]["graph_url"];?>&amp;g=load_report&amp;z=medium&amp;r=<?php echo $this->scope["source"]["range"];?>"
+             alt="<?php echo $this->scope["source"]["name"];?> LOAD" border="0" />
+      </a>
+      </td>
+
+      <td>
+      <a href="<?php echo $this->scope["source"]["url"];?>">
+        <img src="./graph.php?<?php echo $this->scope["source"]["graph_url"];?>&amp;g=network_report&amp;z=medium&amp;r=<?php echo $this->scope["source"]["range"];?>"
+             alt="<?php echo $this->scope["source"]["name"];?> MEM" border="0" />
+      </a>
+      </td>
+
+  </tr>
+ </td>
+</table>
+<?php 
+}?>
+
+<?php 
+}?>
+
+
+
+<?php if (((isset($this->scope["source"]["private"]) ? $this->scope["source"]["private"]:null) !== null)) {
+?>
+  <td align="LEFT" valign="TOP">
+<table cellspacing="1" cellpadding="1" width="100%" border="0">
+ <tr><td>CPUs Total:</td><td align="left"><B><?php echo $this->scope["source"]["cpu_num"];?></B></td></tr>
+ <tr><td width="80%">Nodes:</td><td align="left"><B><?php echo $this->scope["source"]["num_nodes"];?></B></td></tr>
+ <tr><td>&nbsp;</td></tr>
+ <tr><td class="footer" colspan="2"><?php echo $this->scope["source"]["localtime"];?></td></tr>
+</table>
+   </td>
+   <td colspan="2" align=center>This is a private cluster.</td>
+<?php 
+}?>
+
+</tr>
+<?php 
+/* -- foreach end output */
+	}
+}?>
+
+</table>
+
+<?php if (((isset($this->scope["show_snapshot"]) ? $this->scope["show_snapshot"] : null) !== null)) {
+?>
+<table border="0" width="100%">
+<tr>
+  <td colspan="2" class="title">Snapshot of the <?php echo $this->scope["self"];?> |
+    <font size="-1"><a href="./cluster_legend.html">Legend</a></font>
+  </td>
+</tr>
+</table>
+
+<center>
+<table cellspacing="12" cellpadding="2">
+<?php 
+$_fh3_data = (isset($this->scope["snap_rows"]) ? $this->scope["snap_rows"] : null);
+if ($this->isTraversable($_fh3_data) == true)
+{
+	foreach ($_fh3_data as $this->scope['snap_row'])
+	{
+/* -- foreach start output */
+?>
+<tr><?php echo $this->scope["snap_row"]["names"];?></tr>
+<tr><?php echo $this->scope["snap_row"]["images"];?></tr>
+<?php 
+/* -- foreach end output */
+	}
+}?>
+
+</table>
+</center>
+<?php 
+}?>
+
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/metric_group_view.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/metric_group_view.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/metric_group_view.tpl.d17.php	(revision 755)
@@ -0,0 +1,71 @@
+<?php
+/* template head */
+/* end template head */ ob_start(); /* template body */ ?><table><tr>
+<?php $this->scope["i"]=0?>
+
+<?php 
+$_fh2_data = (isset($this->scope["g_metrics"]["metrics"]) ? $this->scope["g_metrics"]["metrics"]:null);
+if ($this->isTraversable($_fh2_data) == true)
+{
+	foreach ($_fh2_data as $this->scope['g_metric'])
+	{
+/* -- foreach start output */
+?>
+<td>
+<font style="font-size: 8px"><?php echo $this->scope["g_metric"]["metric_name"];?> <?php if ((isset($this->scope["g_metric"]["title"]) ? $this->scope["g_metric"]["title"]:null) != '' && (isset($this->scope["g_metric"]["title"]) ? $this->scope["g_metric"]["title"]:null) != (isset($this->scope["g_metric"]["metric_name"]) ? $this->scope["g_metric"]["metric_name"]:null)) {
+?>- <?php echo $this->scope["g_metric"]["title"];
+
+}?></font><br>
+<?php if ((isset($this->scope["may_edit_views"]) ? $this->scope["may_edit_views"] : null)) {
+?>
+<?php $this->scope["graph_args"]="&amp;";
+$this->scope["graph_args"].=(isset($this->scope["g_metric"]["graphargs"]) ? $this->scope["g_metric"]["graphargs"]:null)?>
+
+<button class="cupid-green" title="Metric Actions - Add to View, etc" onclick="metricActions('<?php echo $this->scope["g_metric"]["host_name"];?>','<?php echo $this->scope["g_metric"]["metric_name"];?>', 'metric', '<?php echo $this->scope["graph_args"];?>'); return false;">+</button>
+<?php 
+}?>
+
+<button title="Export to CSV" class="cupid-green" onClick="javascript:location.href='./graph.php?<?php echo $this->scope["g_metric"]["graphargs"];?>&amp;csv=1';return false;">CSV</button>
+<button title="Export to JSON" class="cupid-green" onClick="javascript:location.href='./graph.php?<?php echo $this->scope["g_metric"]["graphargs"];?>&amp;json=1';return false;">JSON</button>
+<button title="Inspect Graph" onClick="inspectGraph('<?php echo $this->scope["g_metric"]["graphargs"];?>'); return false;" class="shiny-blue">Inspect</button>
+<button title="6 month trend" onClick="drawTrendGraph('./graph.php?<?php echo $this->scope["g_metric"]["graphargs"];?>&amp;trend=1&amp;z=xlarge'); return false;" class="shiny-blue">Trend</button>
+
+<?php if ((isset($this->scope["graph_engine"]) ? $this->scope["graph_engine"] : null) == "flot") {
+?>
+<br>
+<div id="placeholder_<?php echo $this->scope["g_metric"]["graphargs"];?>" class="flotgraph2 img_view"></div>
+<div id="placeholder_<?php echo $this->scope["g_metric"]["graphargs"];?>_legend" class="flotlegend"></div>
+<?php 
+}
+else {
+?>
+<?php $this->scope["graphId"]=((isset($this->scope["GRAPH_BASE_ID"]) ? $this->scope["GRAPH_BASE_ID"] : null)).((isset($this->scope["mgId"]) ? $this->scope["mgId"] : null)).((isset($this->scope["i"]) ? $this->scope["i"] : null))?>
+
+<?php $this->scope["showEventsId"]=((isset($this->scope["SHOW_EVENTS_BASE_ID"]) ? $this->scope["SHOW_EVENTS_BASE_ID"] : null)).((isset($this->scope["mgId"]) ? $this->scope["mgId"] : null)).((isset($this->scope["i"]) ? $this->scope["i"] : null))?>
+
+<input title="Hide/Show Events" type="checkbox" id="<?php echo $this->scope["showEventsId"];?>" onclick="showEvents('<?php echo $this->scope["graphId"];?>', this.checked)"/><label class="show_event_text" for="<?php echo $this->scope["showEventsId"];?>">Hide/Show Events</label>
+<?php $this->scope["timeShiftId"]=((isset($this->scope["TIME_SHIFT_BASE_ID"]) ? $this->scope["TIME_SHIFT_BASE_ID"] : null)).((isset($this->scope["mgId"]) ? $this->scope["mgId"] : null)).((isset($this->scope["i"]) ? $this->scope["i"] : null))?>
+
+<input title="Timeshift Overlay" type="checkbox" id="<?php echo $this->scope["timeShiftId"];?>" onclick="showTimeShift('<?php echo $this->scope["graphId"];?>', this.checked)"/><label class="show_timeshift_text" for="<?php echo $this->scope["timeShiftId"];?>">Timeshift</label>
+<br>
+<a href="./graph_all_periods.php?<?php echo $this->scope["g_metric"]["graphargs"];?>&amp;z=large">
+<img id="<?php echo $this->scope["graphId"];?>" class="noborder <?php echo $this->scope["additional_host_img_css_classes"];?>" style="margin:5px;" alt="<?php echo $this->scope["g_metric"]["alt"];?>" src="./graph.php?<?php echo $this->scope["g_metric"]["graphargs"];?>" title="<?php echo $this->scope["g_metric"]["desc"];?>" />
+</A>
+<?php 
+}?>
+
+</td>
+<?php echo $this->scope["g_metric"]["new_row"];?>
+
+<?php echo ($this->assignInScope((isset($this->scope["i"]) ? $this->scope["i"] : null) + 1, 'i'));?>
+
+<?php 
+/* -- foreach end output */
+	}
+}?>
+
+</tr>
+</table>
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/node_extra.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/node_extra.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/node_extra.tpl.d17.php	(revision 755)
@@ -0,0 +1,6 @@
+<?php
+/* template head */
+/* end template head */ ob_start(); /* template body */ ?><!-- Extra content underneath the simple node view. -->
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/physical_view.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/physical_view.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/physical_view.tpl.d17.php	(revision 755)
@@ -0,0 +1,111 @@
+<?php
+/* template head */
+/* end template head */ ob_start(); /* template body */ ?><table cellpadding="1" border="0" width="100%">
+<tr>
+<td colspan=3 class="title"><?php echo $this->scope["cluster"];?> cluster - Physical View |
+ <font size="-1">Columns&nbsp;&nbsp;<?php echo $this->scope["cols_menu"];?></font>
+</td>
+
+<tr>
+<td align="center" valign="top">
+   Verbosity level (Lower is more compact):<br />
+   <?php 
+$_fh0_data = (isset($this->scope["verbosity_levels"]) ? $this->scope["verbosity_levels"] : null);
+if ($this->isTraversable($_fh0_data) == true)
+{
+	foreach ($_fh0_data as $this->scope['verbosity']=>$this->scope['checked'])
+	{
+/* -- foreach start output */
+?>
+   <?php echo $this->scope["verbosity"];?> <input type="radio" name="p" value="<?php echo $this->scope["verbosity"];?>" OnClick="ganglia_form.submit();" <?php echo $this->scope["checked"];?> />&nbsp;
+   <?php 
+/* -- foreach end output */
+	}
+}?>
+
+</td>
+
+<td align="left" valign="top" width="25%">
+Total CPUs: <b><?php echo $this->scope["CPUs"];?></b><br />
+Total Memory: <b><?php echo $this->scope["Memory"];?></b><br />
+</td>
+
+<td align="left" valign="top" width="25%">
+Total Disk: <b><?php echo $this->scope["Disk"];?></b><br />
+Most Full Disk: <b><?php echo $this->scope["most_full"];?></b><br />
+</td>
+
+</tr>
+<tr>
+<td align="left" colspan="3">
+
+<table cellspacing="20">
+<tr>
+<?php 
+$_fh1_data = (isset($this->scope["racks"]) ? $this->scope["racks"] : null);
+if ($this->isTraversable($_fh1_data) == true)
+{
+	foreach ($_fh1_data as $this->scope['rack'])
+	{
+/* -- foreach start output */
+?>
+   <td valign="top" align="center">
+      <table cellspacing="5" border="0">
+         <?php echo $this->scope["rack"]["RackID"];?>
+
+         <?php echo $this->scope["rack"]["nodes"];?>
+
+      </table>
+   </td>
+   <?php echo $this->scope["rack"]["tr"];?>
+
+<?php 
+/* -- foreach end output */
+	}
+}?>
+
+</tr></table>
+
+</td></tr>
+</table>
+
+<hr />
+
+
+<table border="0">
+<tr>
+ <td align="left">
+<font size="-1">
+Legend
+</font>
+ </td>
+</tr>
+<tr>
+<td class="odd">
+<table width="100%" cellpadding="1" cellspacing="0" border="0">
+<tr>
+ <td style="color: blue">Node Name&nbsp;<br /></td>
+ <td align="right" valign="top">
+  <table cellspacing=1 cellpadding=3 border="0">
+  <tr>
+  <td class="L1" align="right">
+  <font size="-1">1-min load</font>
+  </td>
+  </tr>
+ </table>
+<tr>
+<td colspan="2" style="color: rgb(70,70,70)">
+<font size="-1">
+<em>cpu: </em> CPU clock (GHz) (num CPUs)<br />
+<em>mem: </em> Total Memory (GB)
+</font>
+</td>
+</tr>
+</table>
+
+</td>
+</tr>
+</table>
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/show_node.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/show_node.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/show_node.tpl.d17.php	(revision 755)
@@ -0,0 +1,87 @@
+<?php
+/* template head */
+if (function_exists('Dwoo_Plugin_include')===false)
+	$this->getLoader()->loadPlugin('include');
+/* end template head */ ob_start(); /* template body */ ?><!-- Begin show_node.tpl -->
+<table border="0" width="100%">
+<tr>
+  <td colspan="2" class=title><?php echo $this->scope["name"];?> Info</td>
+</tr>
+<tr><td colspan="1">&nbsp;</td></tr>
+<tr>
+<td align="center">
+
+<table cellpadding="2" cellspacing="7" border="1">
+<tr>
+<td class="<?php echo $this->scope["class"];?>">
+   <table cellpadding="1" cellspacing="10" border="0">
+   <tr><td valign="top"><font size="+2"><b><?php echo $this->scope["name"];?></b></font><br />
+   <i><?php echo $this->scope["ip"];?></i><br />
+   <em>Location:</em> <?php echo $this->scope["location"];?><p>
+
+   Cluster local time <?php echo $this->scope["clustertime"];?><br />
+   Last heartbeat received <?php echo $this->scope["age"];?> ago.<br />
+   Uptime <?php echo $this->scope["uptime"];?><br />
+
+   </td>
+   <td align="right" valign="top">
+   <table cellspacing="4" cellpadding="3" border="0"><tr>
+   <tr><td><i>Load:</i></td>
+   <td class=<?php echo $this->scope["load1"];?>><small><?php echo $this->scope["load_one"];?></small></td>
+   <td class=<?php echo $this->scope["load5"];?>><small><?php echo $this->scope["load_five"];?></small></td>
+   <td class=<?php echo $this->scope["load15"];?>><small><?php echo $this->scope["load_fifteen"];?></small></td>
+   </tr><tr><td></td><td><em>1m</em></td><td><em>5m</em></td><td><em>15m</em></td></tr>
+   </table><br />
+
+   <table cellspacing="4" cellpadding="3" border="0"><tr>
+   <td><i>CPU Utilization:</i></td>
+   <td class=<?php echo $this->scope["user"];?>><small><?php echo $this->scope["cpu_user"];?></small></td>
+   <td class=<?php echo $this->scope["sys"];?>><small><?php echo $this->scope["cpu_system"];?></small></td>
+   <td class=<?php echo $this->scope["idle"];?>><small><?php echo $this->scope["cpu_idle"];?></small></td>
+   </tr><tr><td></td><td><em>user</em></td><td><em>sys</em></td><td><em>idle</em></td></tr>
+   </table>
+   </td>
+   </tr>
+   <tr><td align="left" valign="top">
+
+   <b>Hardware</b><br />
+   <em>CPU<?php echo $this->scope["s"];?>:</em> <?php echo $this->scope["cpu"];?><br />
+   <em>Memory (RAM):</em> <?php echo $this->scope["mem"];?><br />
+   <em>Local Disk:</em> <?php echo $this->scope["disk"];?><br />
+   <em>Most Full Disk Partition:</em> <?php echo $this->scope["part_max_used"];?>
+
+   </td>
+   <td align="left" valign="top">
+
+   <b>Software</b><br />
+   <em>OS:</em> <?php echo $this->scope["OS"];?><br />
+   <em>Booted:</em> <?php echo $this->scope["booted"];?><br />
+   <em>Uptime:</em> <?php echo $this->scope["uptime"];?><br />
+   <em>Swap:</em> <?php echo $this->scope["swap"];?><br />
+
+   </td></tr></table>
+</td>
+</tr></table>
+
+ </td>
+</tr>
+<tr>
+<td align="center" valign="middle">
+ <a href="<?php echo $this->scope["physical_view"];?>">Physical View</a> | <a href="<?php echo $this->scope["self"];?>">Reload</a>
+</td>
+</tr>
+<tr>
+ <td>
+<?php if (((isset($this->scope["extra"]) ? $this->scope["extra"] : null) !== null)) {
+?>
+<?php echo Dwoo_Plugin_include($this, "".(isset($this->scope["extra"]) ? $this->scope["extra"] : null)."", null, null, null, '_root', null);?>
+
+<?php 
+}?> 
+</td>
+</tr>
+</table>
+<!-- End show_node.tpl -->
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/user_header.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/user_header.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/user_header.tpl.d17.php	(revision 755)
@@ -0,0 +1,7 @@
+<?php
+/* template head */
+/* end template head */ ob_start(); /* template body */ ?><div style="background: url('https://subtrac.sara.nl/images/b_header.jpg') repeat-x scroll center top; height: 20px;">
+</div>
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/views_view.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/views_view.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/default/views_view.tpl.d17.php	(revision 755)
@@ -0,0 +1,142 @@
+<?php
+/* template head */
+/* end template head */ ob_start(); /* template body */ ?><style type="text/css">
+.img_view {
+  float: left;
+  margin: 0 0 10px 10px;
+}
+</style>
+
+<script type="text/javascript">
+  function refreshView() {
+    $("#view_graphs img").each(function (index) {
+	var src = $(this).attr("src");
+	if (src.indexOf("graph.php") == 0) {
+	  var d = new Date();
+	  $(this).attr("src", jQuery.param.querystring(src, "&_=" + d.getTime()));
+	}    
+    });
+  }
+
+  $(function() {
+    $( "#popup-dialog" ).dialog({ autoOpen: false, width:850 });
+    $("#create_view_button")
+      .button()
+      .click(function() {
+	$( "#create-new-view-dialog" ).dialog( "open" );
+    });
+    $("#delete_view_button")
+      .button()
+      .click(function() {
+        if ($("#vn").val() != "") {
+	  if (confirm("Are you sure you want to delete the view: " + $("#vn").val() + " ?")) {
+	    $.get('views_view.php?view_name=' + 
+                  encodeURIComponent($("#vn").val()) +
+                  '&delete_view&views_menu',
+                  function(data) {
+                    $("#views_menu").html(data);
+                    $("#view_graphs").html("");  
+                    $.cookie('ganglia-selected-view-' + window.name, "");
+		    $("#vn").val("");
+                  });
+          }
+        } else
+	  alert("Please select the view to delete");
+    });
+  });
+</script>
+
+<div id="popup-dialog" title="Inspect Graph">
+  <div id="popup-dialog-content">
+  </div>
+</div>
+
+<table id="views_table">
+<tr><td valign="top">
+<div id="views_menu">
+    <?php echo $this->scope["existing_views"];?>
+
+</div>
+<script type="text/javascript">$(function() { $("#views_menu").buttonsetv(); });</script>
+</td>
+<td valign="top">
+<div>
+<div id="views-content">
+  <div id=view_graphs>
+    <?php if (((isset($this->scope["number_of_view_items"]) ? $this->scope["number_of_view_items"] : null) !== null)) {
+?>
+    <?php if ((isset($this->scope["number_of_view_items"]) ? $this->scope["number_of_view_items"] : null) == 0) {
+?>
+    <div class="ui-widget">
+      <div class="ui-state-default ui-corner-all" style="padding: 0 .7em;"> 
+        <p><span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span>
+          No graphs defined for this view. Please add some
+      </div>
+    </div>
+    <?php 
+}
+else {
+?>
+      <?php $this->scope["i"]=0?>
+
+      <?php 
+$_fh0_data = (isset($this->scope["view_items"]) ? $this->scope["view_items"] : null);
+if ($this->isTraversable($_fh0_data) == true)
+{
+	foreach ($_fh0_data as $this->scope['view_item'])
+	{
+/* -- foreach start output */
+?>
+      <?php $this->scope["graphId"]=((isset($this->scope["GRAPH_BASE_ID"]) ? $this->scope["GRAPH_BASE_ID"] : null)).("view_").((isset($this->scope["i"]) ? $this->scope["i"] : null))?>
+
+      <?php $this->scope["showEventsId"]=((isset($this->scope["SHOW_EVENTS_BASE_ID"]) ? $this->scope["SHOW_EVENTS_BASE_ID"] : null)).("view_").((isset($this->scope["i"]) ? $this->scope["i"] : null))?>
+
+      <div class="img_view">
+        <button title="Export to CSV" class="cupid-green" onClick="javascript:location.href='graph.php?<?php echo $this->scope["view_item"]["url_args"];?>&amp;csv=1';return false;">CSV</button>
+        <button title="Export to JSON" class="cupid-green" onClick="javascript:location.href='graph.php?<?php echo $this->scope["view_item"]["url_args"];?>&amp;json=1';return false;">JSON</button>
+        <?php if ((isset($this->scope["view_item"]["aggregate_graph"]) ? $this->scope["view_item"]["aggregate_graph"]:null) == 1) {
+?>
+        <button title="Decompose aggregate graph" class="shiny-blue" onClick="javascript:location.href='?<?php echo $this->scope["view_item"]["url_args"];?>&amp;dg=1&amp;tab=v';return false;">Decompose</button>
+        <?php 
+}?>
+
+        <button title="Inspect Graph" onClick="inspectGraph('<?php echo $this->scope["view_item"]["url_args"];?>'); return false;" class="shiny-blue">Inspect</button>
+        <input type="checkbox" id="<?php echo $this->scope["showEventsId"];?>" onclick="showEvents('<?php echo $this->scope["graphId"];?>', this.checked)"/><label title="Hide/Show Events" class="show_event_text" for="<?php echo $this->scope["showEventsId"];?>">Hide/Show Events</label>
+        <br />
+<?php if ((isset($this->scope["graph_engine"]) ? $this->scope["graph_engine"] : null) == "flot") {
+?>
+<div id="placeholder_<?php echo $this->scope["view_item"]["url_args"];?>" class="flotgraph2 img_view"></div>
+<div id="placeholder_<?php echo $this->scope["view_item"]["url_args"];?>_legend" class="flotlegend"></div>
+<?php 
+}
+else {
+?>
+<a href="graph_all_periods.php?<?php echo $this->scope["view_item"]["url_args"];?>"><img id="<?php echo $this->scope["graphId"];?>" class="noborder <?php echo $this->scope["additional_host_img_css_classes"];?>" style="margin-top:5px;" src="graph.php?<?php echo $this->scope["view_item"]["url_args"];?>" /></a>
+<?php 
+}?>
+
+      </div>
+      <?php echo ($this->assignInScope((isset($this->scope["i"]) ? $this->scope["i"] : null) + 1, 'i'));?>
+
+      <?php 
+/* -- foreach end output */
+	}
+}?>
+
+    <?php 
+}?>
+
+    <?php 
+}?>
+
+  </div>
+</div>
+<div style="clear: left"></div>
+</div>
+</td>
+</tr>
+</table>
+
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/job_monarch/cluster_extra.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/job_monarch/cluster_extra.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/job_monarch/cluster_extra.tpl.d17.php	(revision 755)
@@ -0,0 +1,20 @@
+<?php
+/* template head */
+if (function_exists('Dwoo_Plugin_include')===false)
+	$this->getLoader()->loadPlugin('include');
+/* end template head */ ob_start(); /* template body */ ?><!-- A place to put custom HTML for the cluster view. -->
+<?php if ((isset($this->scope["cluster"]) ? $this->scope["cluster"] : null) == "LISA Cluster") {
+?> 
+<HR>
+<A HREF="./addons/job_monarch/?c=<?php echo $this->scope["cluster"];?>">
+<IMG SRC="./addons/job_monarch/image.php?c=<?php echo $this->scope["cluster"];?>&view=small-clusterimage" BORDER=0>
+</A>
+<?php echo Dwoo_Plugin_include($this, 'fairshare_pie.php', null, null, null, '_root', null);?>
+
+<?php 
+}?>
+
+<!-- <img src="pie.php?<?php echo $this->scope["fairshare_pie_args"];?>" /> -->
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/job_monarch/cluster_host_metric_graphs.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/job_monarch/cluster_host_metric_graphs.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/job_monarch/cluster_host_metric_graphs.tpl.d17.php	(revision 755)
@@ -0,0 +1,57 @@
+<?php
+/* template head */
+/* end template head */ ob_start(); /* template body */ ?><center>
+<table id=graph_sorted_list>
+<tr>
+<?php 
+$_fh2_data = (isset($this->scope["sorted_list"]) ? $this->scope["sorted_list"] : null);
+if ($this->isTraversable($_fh2_data) == true)
+{
+	foreach ($_fh2_data as $this->scope['host'])
+	{
+/* -- foreach start output */
+?>
+<?php echo $this->scope["host"]["metric_image"];
+echo $this->scope["host"]["br"];?>
+
+<?php 
+/* -- foreach end output */
+	}
+}?>
+
+</tr>
+</table>
+
+<?php echo $this->scope["overflow_list_header"];?>
+
+<?php 
+$_fh3_data = (isset($this->scope["overflow_list"]) ? $this->scope["overflow_list"] : null);
+if ($this->isTraversable($_fh3_data) == true)
+{
+	foreach ($_fh3_data as $this->scope['host'])
+	{
+/* -- foreach start output */
+?>
+<?php echo $this->scope["host"]["metric_image"];
+echo $this->scope["host"]["br"];?>
+
+<?php 
+/* -- foreach end output */
+	}
+}?>
+
+<?php echo $this->scope["overflow_list_footer"];?>
+
+
+<?php if (((isset($this->scope["node_legend"]) ? $this->scope["node_legend"] : null) !== null)) {
+?>
+<p>
+(Nodes colored by 1-minute load) | <a href="./node_legend.html">Legend</A>
+</p>
+<?php 
+}?>
+
+</center>
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/job_monarch/cluster_overview.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/job_monarch/cluster_overview.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/job_monarch/cluster_overview.tpl.d17.php	(revision 755)
@@ -0,0 +1,13 @@
+<?php
+/* template head */
+/* end template head */ ob_start(); /* template body */ ?><table cellspacing=1 cellpadding=1 width="100%" border=0>
+ <tr><td>CPUs Total:</td><td align=left><B><?php echo $this->scope["cpu_num"];?></B></td></tr>
+ <tr><td width="60%">Hosts up:</td><td align=left><B><?php echo $this->scope["num_nodes"];?></B></td></tr>
+ <tr><td>Hosts down:</td><td align=left><B><?php echo $this->scope["num_dead_nodes"];?></B></td></tr>
+ <tr><td>&nbsp;</td></tr>
+ <tr><td colspan=2><font class="nobr">Current Load Avg (15, 5, 1m):</font><br>&nbsp;&nbsp;<b><?php echo $this->scope["cluster_load"];?></b></td></tr>
+ <tr><td colspan=2>Avg Utilization (last <?php echo $this->scope["range"];?>):<br>&nbsp;&nbsp;<b><?php echo $this->scope["cluster_util"];?></b></td></tr>
+ </table>
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/job_monarch/cluster_refresh.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/job_monarch/cluster_refresh.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/job_monarch/cluster_refresh.tpl.d17.php	(revision 755)
@@ -0,0 +1,17 @@
+<?php
+/* template head */
+if (function_exists('Dwoo_Plugin_include')===false)
+	$this->getLoader()->loadPlugin('include');
+/* end template head */ ob_start(); /* template body */ ;
+echo $this->scope["localtimestamp"];?><!-- || -->Overview of <?php echo $this->scope["cluster"];?> @ <?php echo $this->scope["localtime"];?><!-- || --><?php echo Dwoo_Plugin_include($this, 'cluster_overview.tpl', null, null, null, '_root', null);?><!-- || --><?php if ((isset($this->scope["pie_args"]) ? $this->scope["pie_args"] : null)) {
+?>./pie.php?<?php echo $this->scope["pie_args"];
+
+}?><!-- || --><?php if ((isset($this->scope["heatmap"]) ? $this->scope["heatmap"] : null) && (isset($this->scope["num_nodes"]) ? $this->scope["num_nodes"] : null) > 0) {
+
+echo $this->scope["heatmap"];
+
+}?><!-- || --><?php echo Dwoo_Plugin_include($this, 'cluster_host_metric_graphs.tpl', null, null, null, '_root', null);?>
+
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/job_monarch/cluster_view.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/job_monarch/cluster_view.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/job_monarch/cluster_view.tpl.d17.php	(revision 755)
@@ -0,0 +1,321 @@
+<?php
+/* template head */
+if (function_exists('Dwoo_Plugin_include')===false)
+	$this->getLoader()->loadPlugin('include');
+/* end template head */ ob_start(); /* template body */ ?><!-- Begin cluster_view.tpl -->
+<?php if ((isset($this->scope["heatmap"]) ? $this->scope["heatmap"] : null)) {
+?>
+<script type="text/javascript" src="js/protovis-r3.2.js"></script>
+<?php 
+}?>
+
+<script type="text/javascript">
+function refreshClusterView() {
+  $.get('cluster_view.php?' + jQuery.param.querystring() + '&refresh', function(data) {
+    var item = data.split("<!-- || -->");
+
+    $('#cluster_title').html(item[1]);
+
+    $('#cluster_overview').html(item[2]);
+
+    if ($('#load_pie').size())
+      $('#load_pie').attr("src", item[3].replace(/&amp;/g, "&"));
+
+    if ($('#heatmap-fig').size()) {
+      eval("heatmap = [" + item[4] + "]")	;
+      vis.render();
+    }
+
+    if ($('#stacked_graph').size()) {
+      var localtimestamp = parseInt(item[0]);
+      var src = $('#stacked_graph').attr('src');
+      $('#stacked_graph').attr("src", jQuery.param.querystring(src, "&st=" + localtimestamp));
+    }
+
+    var host_metric_graphs = $('#host_metric_graphs');
+    host_metric_graphs.css('height', host_metric_graphs.height() + "px");
+    host_metric_graphs.html(item[5]);
+  });
+
+  $("#optional_graphs img").each(function (index) {
+    var src = $(this).attr("src");
+    if ((src.indexOf("graph.php") == 0) ||
+        (src.indexOf("./graph.php") == 0)) {
+      var d = new Date();
+      $(this).attr("src", jQuery.param.querystring(src, "&_=" + d.getTime()));
+    }    
+  });
+}
+
+$(function() {
+  // Modified from http://jqueryui.com/demos/toggle/
+  //run the currently selected effect
+  function runEffect(id){
+    //most effect types need no options passed by default
+    var options = { };
+
+    options = { to: { width: 200,height: 60 } }; 
+    
+    //run the effect
+    $("#"+id+"_div").toggle("blind",options,500);
+  };
+ 
+  //set effect from select menu value
+  $('.button').click(function(event) {
+    runEffect(event.target.id);
+    return false;
+  });
+
+    $(function() {
+        $( "#edit_optional_graphs" ).dialog({ autoOpen: false, minWidth: 550,
+          beforeClose: function(event, ui) {  location.reload(true); } })
+        $( "#edit_optional_graphs_button" ).button();
+        $( "#save_optional_graphs_button" ).button();
+        $( "#close_edit_optional_graphs_link" ).button();
+    });
+
+    $("#edit_optional_graphs_button").click(function(event) {
+      $("#edit_optional_graphs").dialog('open');
+      $('#edit_optional_graphs_content').html('<img src="img/spinner.gif">');
+      $.get('edit_optional_graphs.php', "clustername=<?php echo $this->scope["cluster"];?>", function(data) {
+          $('#edit_optional_graphs_content').html(data);
+      })
+      return false;
+    });
+
+    $("#save_optional_graphs_button").click(function(event) {
+       $.get('edit_optional_graphs.php', $("#edit_optional_reports_form").serialize(), function(data) {
+          $('#edit_optional_graphs_content').html(data);
+          $("#save_optional_graphs_button").hide();
+          setTimeout(function() {
+             $('#edit_optional_graphs').dialog('close');
+          }, 5000);
+        });
+      return false;
+    });
+
+});
+</script>
+
+<?php if ((isset($this->scope["graph_engine"]) ? $this->scope["graph_engine"] : null) == "flot") {
+?>
+<script language="javascript" type="text/javascript" src="js/jquery.flot.min.js"></script>
+<script type="text/javascript" src="js/create-flot-graphs.js"></script>
+<style type="text/css">
+.flotgraph2 {
+  height: <?php echo $this->scope["graph_height"];?>px;
+  width:  <?php echo $this->scope["graph_width"];?>px;
+}
+</style>
+<?php 
+}?>
+
+
+<style type="text/css">
+  .toggler { width: 500px; height: 200px; }
+  a.button { padding: .15em 1em; text-decoration: none; }
+  #effect { width: 240px; height: 135px; padding: 0.4em; position: relative; }
+  #effect h3 { margin: 0; padding: 0.4em; text-align: center; }
+  #heatmap-fig {
+    width: 200px;
+    height: 200px;
+  } 
+</style>
+
+<div id="metric-actions-dialog" title="Metric Actions">
+  <div id="metric-actions-dialog-content">
+    Available Metric actions.
+  </div>
+</div>
+
+<div id="edit_optional_graphs">
+  <div style="text-align:center">
+    <button  id='save_optional_graphs_button'>Save</button>
+  </div>
+  <div id="edit_optional_graphs_content">Empty</div>
+</div>
+
+<div style="background:rgb(238,238,238);text-align:center;">
+  <font size="+1" id="cluster_title">Overview of <?php echo $this->scope["cluster"];?> @ <?php echo $this->scope["localtime"];?></font>
+</div>
+
+<table border="0" cellspacing=4 width="100%">
+<tr>
+<td align="left" valign="top">
+<div id="cluster_overview">
+<?php echo Dwoo_Plugin_include($this, 'cluster_overview.tpl', null, null, null, '_root', null);?>
+
+</div>
+<?php if (((isset($this->scope["extra"]) ? $this->scope["extra"] : null) !== null)) {
+?>
+<?php echo Dwoo_Plugin_include($this, "".(isset($this->scope["extra"]) ? $this->scope["extra"] : null)."", null, null, null, '_root', null);?>
+
+<?php 
+}?>
+
+</td>
+<td rowspan=2 align="center" valign=top>
+<div id="optional_graphs" style="padding-bottom:4px">
+<?php echo $this->scope["optional_reports"];?><br>
+<?php 
+$_fh0_data = (isset($this->scope["optional_graphs_data"]) ? $this->scope["optional_graphs_data"] : null);
+if ($this->isTraversable($_fh0_data) == true)
+{
+	foreach ($_fh0_data as $this->scope['graph'])
+	{
+/* -- foreach start output */
+?>
+  <a href="./graph_all_periods.php?<?php echo $this->scope["graph"]["graph_args"];?>&amp;g=<?php echo $this->scope["graph"]["name"];?>_report&amp;z=large">
+  <img border=0 <?php echo $this->scope["additional_cluster_img_html_args"];?> title="<?php echo $this->scope["cluster"];?> <?php echo $this->scope["graph"]["name"];?>" src="./graph.php?<?php echo $this->scope["graph"]["graph_args"];?>&amp;g=<?php echo $this->scope["graph"]["name"];?>_report&amp;z=medium"></a>
+<?php 
+/* -- foreach end output */
+	}
+}?>
+
+</div>
+<?php if ((isset($this->scope["user_may_edit"]) ? $this->scope["user_may_edit"] : null)) {
+?>
+<button id="edit_optional_graphs_button">Edit Optional Graphs</button>
+<?php 
+}?>
+
+</td>
+</tr>
+
+<tr>
+ <td align="center" valign="top">
+<?php if ((isset($this->scope["php_gd"]) ? $this->scope["php_gd"] : null) && ! (isset($this->scope["heatmap"]) ? $this->scope["heatmap"] : null)) {
+?>
+  <img id="load_pie" src="./pie.php?<?php echo $this->scope["pie_args"];?>" border="0" />
+<?php 
+}?>
+
+<?php if ((isset($this->scope["heatmap"]) ? $this->scope["heatmap"] : null) && (isset($this->scope["num_nodes"]) ? $this->scope["num_nodes"] : null) > 0) {
+?>
+Utilization heatmap<br />
+<div id="heatmap-fig">
+<script type="text/javascript+protovis">
+var heatmap = [
+<?php echo $this->scope["heatmap"];?>
+
+];
+
+var w = heatmap[0].length,
+    h = heatmap.length;
+
+var vis = new pv.Panel()
+    .width(w * <?php echo $this->scope["heatmap_size"];?>)
+    .height(h * <?php echo $this->scope["heatmap_size"];?>)
+    .margin(2)
+    .strokeStyle("#aaa")
+    .lineWidth(4)
+    .antialias(false);
+
+vis.add(pv.Image)
+    .imageWidth(w)
+    .imageHeight(h)
+    .image(pv.Scale.linear()
+        .domain(0, 0.25, 0.5, 0.75, 1.00)
+        .range("#e2ecff", "#caff98", "#ffde5e" , "#ffa15e","#ff634f")
+        .by(function(i, j) heatmap[j][i]));
+
+vis.render();
+    </script>
+ </div>
+<?php 
+}?>
+
+ </td>
+</tr>
+</table>
+
+<?php if ((isset($this->scope["stacked_graph_args"]) ? $this->scope["stacked_graph_args"] : null)) {
+?>
+<center>
+<table width="100%" border=0>
+<tr>
+  <td colspan="1">
+  <font size="+1" style="text-align:center">Stacked Graph - <?php echo $this->scope["metric"];?></font> 
+  </td>
+</tr>
+<tr>
+  <td>
+  <center><img id="stacked_graph" src="stacked.php?<?php echo $this->scope["stacked_graph_args"];?>" alt="<?php echo $this->scope["cluster"];?> <?php echo $this->scope["metric"];?>"></center>
+  </td>
+</tr>
+</table>
+</center>
+<?php 
+}?>
+
+
+<script type="text/javascript">
+// Need to set the field value to metric name
+$("#metrics-picker").val("<?php echo $this->scope["metric_name"];?>");
+</script>
+
+
+<div id="cluster_view_chooser">
+<table border="0" width="100%">
+  <tr>
+  <td style="text-align:center;background:rgb(238,238,238);">
+  Show Hosts Scaled:
+  <?php 
+$_fh1_data = (isset($this->scope["showhosts_levels"]) ? $this->scope["showhosts_levels"] : null);
+$this->globals["foreach"]['default'] = array
+(
+	"iteration"		=> 1,
+	"last"		=> null,
+	"total"		=> $this->count($_fh1_data),
+);
+$_fh1_glob =& $this->globals["foreach"]['default'];
+if ($this->isTraversable($_fh1_data) == true)
+{
+	foreach ($_fh1_data as $this->scope['id']=>$this->scope['showhosts'])
+	{
+		$_fh1_glob["last"] = (string) ($_fh1_glob["iteration"] === $_fh1_glob["total"]);
+/* -- foreach start output */
+?>
+  <input type="radio" name="sh" value="<?php echo $this->scope["id"];?>" id="shch<?php echo $this->scope["id"];?>" OnClick="ganglia_form.submit();" <?php echo $this->scope["showhosts"]["checked"];?>><label for="shch<?php echo $this->scope["id"];?>"><?php echo $this->scope["showhosts"]["name"];?></label>
+  <?php 
+/* -- implode */
+if (!$_fh1_glob["last"]) {
+	echo "";
+}
+/* -- foreach end output */
+		$_fh1_glob["iteration"]+=1;
+	}
+}?>&nbsp;
+  |
+  <span class="nobr"><?php echo $this->scope["cluster"];?> <strong><?php echo $this->scope["metric"];?></strong>
+  last <strong><?php echo $this->scope["range"];?></strong>
+  sorted <strong><?php echo $this->scope["sort"];?></strong></span>
+<?php if (((isset($this->scope["columns_size_dropdown"]) ? $this->scope["columns_size_dropdown"] : null) !== null)) {
+?>
+  |
+   <font>
+   <span class="nobr">Size&nbsp;&nbsp;<?php echo $this->scope["size_menu"];?></span>
+   <span class="nobr">Columns&nbsp;&nbsp;<?php echo $this->scope["cols_menu"];?> (0 = metric + reports)</span>
+   </font>
+<?php 
+}?>
+
+  </td>
+</tr>
+</table>
+</div>
+
+<div id="host_metric_graphs">
+<?php echo Dwoo_Plugin_include($this, 'cluster_host_metric_graphs.tpl', null, null, null, '_root', null);?>
+
+</div>
+
+<script type="text/javascript">
+$(function() {
+  $( "#cluster_view_chooser" ).buttonset();
+});
+</script>
+<!-- End cluster_view.tpl -->
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/job_monarch/footer.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/job_monarch/footer.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/job_monarch/footer.tpl.d17.php	(revision 755)
@@ -0,0 +1,84 @@
+<?php
+/* template head */
+/* end template head */ ob_start(); /* template body */ ?><!-- Begin footer.tpl -->
+</form> <!-- ganglia-form -->
+</div> <!-- tabs-main -->
+
+<div id="tabs-search">
+  Search term matches any number of metrics and hosts. For example type web or disk; wait a split second, and a drop down menu will show up with choices.
+  <!-- Uses LiveSearch from http://andreaslagerkvist.com/jquery/live-search/ -->
+  <div id="metric-search">
+    <form method="post" action="/search/">
+      <p>
+	<label>
+	    <small>Search as you type</small><br />
+	    <input type="text" name="q" id="search-field-q" size="60" placeholder="Search as you type" on />
+	</label>
+      </p>
+    </form>
+  </div>
+</div> 
+
+<div id="create-new-view-dialog" title="Create new view">
+  <div id="create-new-view-layer">
+    <form id="create_view_form">
+      <input type="hidden" name="create_view" value="1">
+      <fieldset>
+	 <label for="name">View Name</label>
+	 <input type="text" name="view_name" id="view_name" class="text ui-widget-content ui-corner-all" />
+         <center><button onclick="createView(); return false;">Create</button></center>
+      </fieldset>
+    </form>
+  </div>
+  <div id="create-new-view-confirmation-layer"></div>
+</div>
+
+<div id="tabs-mobile"></div>
+
+<div id="tabs-autorotation">
+Invoke automatic rotation system. Automatic rotation rotates all of the graphs/metrics specified in a view waiting 
+30 seconds in between each. This will run as long as you have this page open.
+<p>
+Please select the view you want to rotate.</p>
+  <div id="tabs-autorotation-chooser">
+Loading view, please wait...<img src="img/spinner.gif" />
+  </div>
+</div>
+
+<div id="tabs-livedashboard">
+Live dashboard provides you with an overview of all view metrics in a compact format. Data updates every 15 seconds.
+Only those elements that contain a metric or graph report are supported. Aggregate graphs will not be included.
+<p>
+You can get more graphs per page by using your browser zoom functionality.
+<p>
+Please select the view you want to view</p>
+  <div id="tabs-livedashboard-chooser">
+Loading view, please wait...<img src="img/spinner.gif" />
+  </div>
+</div>
+
+
+<hr />
+<div align="center">
+<font size="-1" class="footer">
+Ganglia Web Frontend version <?php echo $this->scope["webfrontend_version"];?>
+
+<a href="http://ganglia.sourceforge.net/downloads.php?component=ganglia-webfrontend&amp;version=<?php echo $this->scope["webfrontend_version"];?>">Check for Updates.</a><br />
+
+Ganglia Web Backend <i>(<?php echo $this->scope["webbackend_component"];?>)</i> version <?php echo $this->scope["webbackend_version"];?>
+
+<a href="http://ganglia.sourceforge.net/downloads.php?component=<?php echo $this->scope["webbackend_component"];?>&amp;version=<?php echo $this->scope["webbackend_version"];?>">Check for Updates.</a><br />
+
+Downloading and parsing ganglia's XML tree took <?php echo $this->scope["parsetime"];?>.<br />
+Images created with <a href="http://www.rrdtool.org/">RRDtool</a> version <?php echo $this->scope["rrdtool_version"];?>.<br />
+<?php echo $this->globals["ad"];?> <?php echo $this->globals["version"];?>.<br />
+</font>
+</div>
+</div> <!-- div-tabs -->
+</BODY>
+<!-- End footer.tpl -->
+</HTML>
+
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/job_monarch/header.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/job_monarch/header.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/job_monarch/header.tpl.d17.php	(revision 755)
@@ -0,0 +1,303 @@
+<?php
+/* template head */
+if (function_exists('Dwoo_Plugin_include')===false)
+	$this->getLoader()->loadPlugin('include');
+/* end template head */ ob_start(); /* template body */ ?><!-- Begin header.tpl -->
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<title>Ganglia:: <?php echo $this->scope["page_title"];?></title>
+<meta http-equiv="Content-type" content="text/html; charset=utf-8">
+<link type="text/css" href="css/smoothness/jquery-ui-1.8.14.custom.min.css" rel="stylesheet" />
+<link type="text/css" href="css/jquery.liveSearch.css" rel="stylesheet" />
+<link type="text/css" href="css/jquery.multiselect.css" rel="stylesheet" />
+<link type="text/css" href="./styles.css" rel="stylesheet" />
+<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
+<script type="text/javascript" src="js/jquery-ui-1.8.14.custom.min.js"></script>
+<script type="text/javascript" src="js/jquery.livesearch.min.js"></script>
+<script type="text/javascript" src="js/ganglia.js"></script>
+<script type="text/javascript" src="js/jquery.gangZoom.js"></script>
+<script type="text/javascript" src="js/jquery.cookie.js"></script>
+<script type="text/javascript" src="js/jquery-ui-timepicker-addon.js"></script>
+<script type="text/javascript" src="js/jquery.ba-bbq.min.js"></script>
+<script type="text/javascript" src="js/combobox.js"></script>
+<script type="text/javascript" src="js/jquery.scrollTo-1.4.2-min.js"></script>
+<script type="text/javascript" src="js/jquery.buttonsetv.js"></script>
+<script type="text/javascript">
+    var server_utc_offset=<?php echo $this->scope["server_utc_offset"];?>;
+    
+    var g_refresh_timer = setTimeout("refresh()", <?php echo $this->scope["refresh"];?> * 1000);
+
+    function refreshHeader() {
+      $.get('header.php?date_only=1', function(data) {
+        var title = $("#page_title").text();
+        var l = title.lastIndexOf(" for ");
+        title = title.substring(0, l);
+        title += " for " + data;
+        $("#page_title").text(title);
+        });
+    }
+
+    function refresh() {
+      var selected_tab = $("#selected_tab").val();
+      if (selected_tab == "agg") {
+        refreshAggregateGraph();
+        g_refresh_timer = setTimeout("refresh()", <?php echo $this->scope["refresh"];?> * 1000);
+      } else if (selected_tab == "v") {
+        refreshHeader();
+        if ($.isFunction(window.refreshView)) {
+          refreshView();
+          g_refresh_timer = setTimeout("refresh()", <?php echo $this->scope["refresh"];?> * 1000);
+        } else if ($.isFunction(window.refreshDecomposeGraph)) {
+          refreshDecomposeGraph();
+          g_refresh_timer = setTimeout("refresh()", <?php echo $this->scope["refresh"];?> * 1000);
+        } else
+          ganglia_form.submit();
+      } else if (selected_tab == "ev") {
+        refreshOverlayEvent();
+        g_refresh_timer = setTimeout("refresh()", <?php echo $this->scope["refresh"];?> * 1000);
+      } else if (selected_tab == "m") {
+        if ($.isFunction(window.refreshClusterView)) {
+          refreshHeader();
+          refreshClusterView();
+          g_refresh_timer = setTimeout("refresh()", <?php echo $this->scope["refresh"];?> * 1000);
+        } else if ($.isFunction(window.refreshHostView)) {
+          refreshHeader();
+          refreshHostView();
+          g_refresh_timer = setTimeout("refresh()", <?php echo $this->scope["refresh"];?> * 1000);
+        } else
+          ganglia_form.submit();
+      } else
+        ganglia_form.submit();
+    }
+
+    $(function() {
+      g_overlay_events = ($("#overlay_events").val() == "true");
+
+      g_tabIndex = new Object();
+      g_tabName = [];
+      var tabName = ["m", "s", "v", "agg", "ch", "ev", "rot", "mob"];
+      var j = 0;
+      for (var i in tabName) {
+        if (tabName[i] == "ev" && !g_overlay_events)
+          continue;
+        g_tabIndex[tabName[i]] = j++;
+        g_tabName.push(tabName[i]);
+      }
+
+      // Follow tab's URL instead of loading its content via ajax
+      var tabs = $("#tabs");
+      if (tabs[0]) {
+        tabs.tabs();
+        // Restore previously selected tab
+        var selected_tab = $("#selected_tab").val();
+        //alert("selected_tab = " + selected_tab);
+        if (typeof g_tabIndex[selected_tab] != 'undefined') {
+          try {
+            //alert("Selecting tab: " + selected_tab);
+            tabs.tabs("select", g_tabIndex[selected_tab]);
+            if (selected_tab == "rot")
+              autoRotationChooser();
+          } catch (err) {
+            try {
+              alert("Error(ganglia.js): Unable to select tab: " + 
+                    selected_tab + ". " + err.getDescription());
+            } catch (err) {
+              // If we can't even show the error, fail silently.
+            }
+          }
+        }
+
+        tabs.bind("tabsselect", function(event, ui) {
+          $("#selected_tab").val(g_tabName[ui.index]);
+          if (g_tabName[ui.index] != "mob")
+            $.cookie("ganglia-selected-tab-" + window.name, ui.index);
+          if (ui.index == g_tabIndex["m"] ||
+              ui.index == g_tabIndex["v"] ||
+              ui.index == g_tabIndex["ch"])
+            ganglia_form.submit();
+        });
+      }
+    });
+
+    $(function() {
+      $("#metrics-picker").combobox();
+
+      <?php echo $this->scope["is_metrics_picker_disabled"];?>
+
+
+      $(".header_btn").button();
+    });
+
+  $(function () {
+
+    done = function done(startTime, endTime) {
+            setStartAndEnd(startTime, endTime);
+            document.forms['ganglia_form'].submit();
+    }
+
+    cancel = function (startTime, endTime) {
+            setStartAndEnd(startTime, endTime);
+    }
+
+    defaults = {
+        startTime: <?php echo $this->scope["start_timestamp"];?>,
+        endTime: <?php echo $this->scope["end_timestamp"];?>,
+        done: done,
+        cancel: cancel
+    }
+
+    $(".host_small_zoomable").gangZoom($.extend({
+        paddingLeft: 67,
+        paddingRight: 30,
+        paddingTop: 38,
+        paddingBottom: 25
+    }, defaults));
+
+    $(".host_medium_zoomable").gangZoom($.extend({
+        paddingLeft: 67,
+        paddingRight: 30,
+        paddingTop: 38,
+        paddingBottom: 40
+    }, defaults));
+
+    $(".host_default_zoomable").gangZoom($.extend({
+        paddingLeft: 66,
+        paddingRight: 30,
+        paddingTop: 37,
+        paddingBottom: 50
+    }, defaults));
+
+    $(".host_large_zoomable").gangZoom($.extend({
+        paddingLeft: 66,
+        paddingRight: 29,
+        paddingTop: 37,
+        paddingBottom: 56
+    }, defaults));
+
+    $(".cluster_zoomable").gangZoom($.extend({
+        paddingLeft: 67,
+        paddingRight: 30,
+        paddingTop: 37,
+        paddingBottom: 50
+    }, defaults));
+
+    function rrdDateTimeString(date) {
+      return (date.getMonth() + 1) + "/" + date.getDate() + "/" + date.getFullYear() + " " + date.getHours() + ":" + date.getMinutes();
+    }
+
+    function setStartAndEnd(startTime, endTime) {
+        // we're getting local start/end times.
+
+        // getTimezoneOffset returns negative values east of UTC,
+        // which is the opposite of PHP. we want negative values to the west.
+        var local_offset = new Date().getTimezoneOffset() * 60 * -1;
+        var delta = local_offset - server_utc_offset;
+        var date = new Date((Math.floor(startTime) - delta) * 1000);
+        $("#datepicker-cs").val(rrdDateTimeString(date));
+        date = new Date((Math.floor(endTime) - delta) * 1000);
+        $("#datepicker-ce").val(rrdDateTimeString(date));
+    }
+
+    initShowEvent();
+    initTimeShift();
+  });
+
+
+</script>
+<?php echo $this->scope["custom_time_head"];?>
+
+</head>
+<body style="background-color: #ffffff;" onunload="g_refresh_timer=null">
+<?php if (((isset($this->scope["user_header"]) ? $this->scope["user_header"] : null) !== null)) {
+?>
+<?php echo Dwoo_Plugin_include($this, "user_header.tpl", null, null, null, '_root', null);?>
+
+<?php 
+}?>
+
+
+<?php if ((isset($this->scope["auth_system_enabled"]) ? $this->scope["auth_system_enabled"] : null)) {
+?>
+<div style="float:right">
+  <?php if ((isset($this->scope["username"]) ? $this->scope["username"] : null)) {
+?>
+    Currently logged in as: <?php echo $this->scope["username"];?> | <a href="logout.php">Logout</a>
+  <?php 
+}
+else {
+?>
+    You are not currently logged in. | <a href="login.php">Login</a>
+  <?php 
+}?>
+
+</div>
+<br style="clear:both"/>
+<?php 
+}?>
+
+
+<div id="tabs">
+<ul>
+  <li><a href="#tabs-main">Main</a></li>
+  <li><a href="#tabs-search">Search</a></li>
+  <li><a href="#tabs-main">Views</a></li>
+  <li><a href="aggregate_graphs.php">Aggregate Graphs</a></li>
+  <li><a href="#tabs-main">Compare Hosts</a></li>
+<?php if ((isset($this->scope["overlay_events"]) ? $this->scope["overlay_events"] : null)) {
+?>
+  <li><a href="events.php">Events</a></li>
+<?php 
+}?>
+
+  <li><a href="#tabs-autorotation" onclick="autoRotationChooser();">Automatic Rotation</a></li>
+  <li><a href="#tabs-livedashboard" onclick="liveDashboardChooser();">Live Dashboard</a></li>  
+  <li><a href="#tabs-mobile" onclick="window.location.href='mobile.php';">Mobile</a></li>
+</ul>
+
+<div id="tabs-main">
+<form action="<?php echo $this->scope["page"];?>" method="GET" name="ganglia_form">
+
+  <div style="background-color:#dddddd;padding:5px;">
+     <big style="float:left;"><b id="page_title"><?php echo $this->scope["page_title"];?> for <?php echo $this->scope["date"];?></b></big><input style="float:right;" class="header_btn" type="submit" value="Get Fresh Data"/><div style="clear:both"></div>
+  </div>
+<a id="logo" href="http://www.sara.nl/"><img style="float: left;" src="https://subtrac.sara.nl/images/sara_logo.png" alt="SARA" /></a>
+  <div style="padding:5px 5px 0 5px;">
+    <div style="float:left;" id="range_menu" class="nobr"><?php echo $this->scope["range_menu"];?></div>
+    <div style="float:left;" id="custom_range_menu"><?php echo $this->scope["custom_time"];?></div>
+    <div style="float:right;"><?php echo $this->scope["additional_buttons"];?>&nbsp;&nbsp;<?php echo $this->scope["alt_view"];?></div>
+    <div style="clear:both;"></div>
+  </div>
+  <div id="sort_menu" style="padding:5px 5px 0 5px;">
+   Metric&nbsp;&nbsp; <select name="m" id="metrics-picker"><?php echo $this->scope["picker_metrics"];?></select>&nbsp;&nbsp;
+     <?php echo $this->scope["sort_menu"];?>
+
+  </div>
+<?php if ((isset($this->scope["node_menu"]) ? $this->scope["node_menu"] : null) != "") {
+?>
+  <div id="sort_menu" style="padding:5px 5px 0 5px;">
+    <?php echo $this->scope["node_menu"];?>&nbsp;&nbsp;<?php echo $this->scope["additional_filter_options"];?>
+
+  </div>
+<?php 
+}?>
+
+
+<input type="hidden" name="tab" id="selected_tab" value="<?php echo $this->scope["selected_tab"];?>">
+<input type="hidden" id="vn" name="vn" value="<?php echo $this->scope["view_name"];?>">
+<?php if ((isset($this->scope["overlay_events"]) ? $this->scope["overlay_events"] : null)) {
+?>
+<input type="hidden" id="overlay_events" value="true">
+<?php 
+}
+else {
+?>
+<input type="hidden" id="overlay_events" value="false">
+<?php 
+}?>
+
+<hr size="1" noshade>
+<!-- End header.tpl -->
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/job_monarch/host_extra.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/job_monarch/host_extra.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/job_monarch/host_extra.tpl.d17.php	(revision 755)
@@ -0,0 +1,6 @@
+<?php
+/* template head */
+/* end template head */ ob_start(); /* template body */ ?><!-- A place to put custom HTML for the host view. Re-implement in a skin. -->
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/job_monarch/host_overview.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/job_monarch/host_overview.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/job_monarch/host_overview.tpl.d17.php	(revision 755)
@@ -0,0 +1,74 @@
+<?php
+/* template head */
+if (function_exists('Dwoo_Plugin_include')===false)
+	$this->getLoader()->loadPlugin('include');
+/* end template head */ ob_start(); /* template body */ ?><br>
+<table border="0" width="100%">
+
+<tr>
+ <td align="left" valign="TOP">
+
+<img src="<?php echo $this->scope["node_image"];?>" class="noborder" height="60" width="30" title="<?php echo $this->scope["host"];?>"/>
+<?php echo $this->scope["node_msg"];?>
+
+
+<table border="0" width="100%">
+<tr>
+  <td colspan="2" class="title">Time and String Metrics</td>
+</tr>
+
+<?php 
+$_fh3_data = (isset($this->scope["s_metrics_data"]) ? $this->scope["s_metrics_data"] : null);
+if ($this->isTraversable($_fh3_data) == true)
+{
+	foreach ($_fh3_data as $this->scope['s_metric'])
+	{
+/* -- foreach start output */
+?>
+<tr>
+ <td class="footer" width="30%"><?php echo $this->scope["s_metric"]["name"];?></td><td><?php echo $this->scope["s_metric"]["value"];?></td>
+</tr>
+<?php 
+/* -- foreach end output */
+	}
+}?>
+
+
+<tr><td>&nbsp;</td></tr>
+
+<tr>
+  <td colspan="2" class="title">Constant Metrics</td>
+</tr>
+
+<?php 
+$_fh4_data = (isset($this->scope["c_metrics_data"]) ? $this->scope["c_metrics_data"] : null);
+if ($this->isTraversable($_fh4_data) == true)
+{
+	foreach ($_fh4_data as $this->scope['c_metric'])
+	{
+/* -- foreach start output */
+?>
+<tr>
+ <td class="footer" width="30%"><?php echo $this->scope["c_metric"]["name"];?></td><td><?php echo $this->scope["c_metric"]["value"];?></td>
+</tr>
+<?php 
+/* -- foreach end output */
+	}
+}?>
+
+</table>
+
+ <hr />
+<?php if (((isset($this->scope["extra"]) ? $this->scope["extra"] : null) !== null)) {
+?>
+<?php echo Dwoo_Plugin_include($this, "".(isset($this->scope["extra"]) ? $this->scope["extra"] : null)."", null, null, null, '_root', null);?>
+
+<?php 
+}?>
+
+</td> 
+</table>
+
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/job_monarch/host_view.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/job_monarch/host_view.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/job_monarch/host_view.tpl.d17.php	(revision 755)
@@ -0,0 +1,450 @@
+<?php
+/* template head */
+if (function_exists('Dwoo_Plugin_include')===false)
+	$this->getLoader()->loadPlugin('include');
+if (function_exists('Dwoo_Plugin_regex_replace')===false)
+	$this->getLoader()->loadPlugin('regex_replace');
+/* end template head */ ob_start(); /* template body */ ?><!-- Begin host_view.tpl -->
+<style type="text/css">
+/* don't display legends for these small graphs */
+.flotlegend, .flotlegendtoplabel {
+  display: none !important;
+}
+.flotheader {
+  margin-top: 2em;
+}
+.flottitle {
+  padding-right: 4em;
+  font-weight: bold;
+}
+.img_view {
+  float: left;
+  margin: 0 0 10px 10px;
+}
+</style>
+<script type="text/javascript">
+var SEPARATOR = "_|_";
+var ALL_GROUPS = "ALLGROUPS";
+var NO_GROUPS = "NOGROUPS";
+// Map metric group id to name
+var g_mgMap = new Object();
+
+function clearStoredMetricGroups() {
+  var stored_groups = $('input[name="metric_group"]');
+  stored_groups.val(NO_GROUPS);
+}
+
+function selectAllMetricGroups() {
+  var stored_groups = $('input[name="metric_group"]');
+  stored_groups.val(ALL_GROUPS);
+}
+
+function addMetricGroup(mgName) {
+  var stored_groups = $('input[name="metric_group"]');
+
+  var open_groups = stored_groups.val();
+  if (open_groups == ALL_GROUPS)
+    return; // no exceptions
+
+  var groups = open_groups.split(SEPARATOR);
+  switch (groups[0]) {
+    case ALL_GROUPS:
+      // Remove from except list
+      for (var i = 1; i < groups.length; i++) {
+        if (groups[i] == mgName) {
+          groups.splice(i, 1);
+          break;
+        }
+      }
+      open_groups = groups.join(SEPARATOR);
+    break;
+    case NO_GROUPS:
+      // Add to list if not already there
+      var inList = false;
+      for (var i = 1; i < groups.length; i++) {
+         if (groups[i] == mgName) {
+           inList = true;
+           break;
+         }
+      }
+      if (!inList) {
+        open_groups += SEPARATOR;
+        open_groups += mgName;
+      }
+    break;
+    default:
+      alert("Unrecognized group option - " + groups[0]);
+  }
+  stored_groups.val(open_groups);
+}
+
+function removeMetricGroup(mgName) {
+  var stored_groups = $('input[name="metric_group"]');
+
+  var open_groups = stored_groups.val();
+  if (open_groups == NO_GROUPS)
+    return; // no exceptions
+
+  var groups = open_groups.split(SEPARATOR);
+  switch (groups[0]) {
+    case ALL_GROUPS:
+      var inList = false;
+      for (var i = 1; i < groups.length; i++) {
+        if (groups[i] == mgName) {
+          inList = true;
+          break;
+        }
+      }
+      if (!inList) {
+        open_groups += SEPARATOR;
+        open_groups += mgName;
+      }
+    break;
+    case NO_GROUPS:
+      for (var i = 1; i < groups.length; i++) {
+        if (groups[i] == mgName) {
+          groups.splice(i, 1);
+          break;
+        }
+      }
+      open_groups = groups.join(SEPARATOR);
+    break;
+    default:
+      alert("Unrecognized group option - " + groups[0]);
+  }
+  stored_groups.val(open_groups);
+}
+
+function toggleMetricGroup(mgId, mgDiv) {
+  var mgName = g_mgMap[mgId];
+  if (mgDiv.is(":visible"))
+    // metric group is being closed
+    removeMetricGroup(mgName);
+  else
+    addMetricGroup(mgName);
+  document.ganglia_form.submit();
+}
+
+function jumpToMetricGroup(mgId) {
+  //alert("jumping to " + mgId);
+  $.scrollTo($('#' + mgId));
+}
+
+function refreshHostView() {
+  $.get('host_overview.php?h=<?php echo $this->scope["hostname"];?>&c=<?php echo $this->scope["cluster"];?>', function(data) {
+    $('#host_overview_div').html(data);
+  });
+
+  $("#optional_graphs img").each(function (index) {
+    var src = $(this).attr("src");
+    if ((src.indexOf("graph.php") == 0) ||
+        (src.indexOf("./graph.php") == 0)) {
+      var d = new Date();
+      $(this).attr("src", jQuery.param.querystring(src, "&_=" + d.getTime()));
+    }    
+  });
+
+  $("#metrics img").each(function (index) {
+    var src = $(this).attr("src");
+    if ((src.indexOf("graph.php") == 0)  ||
+        (src.indexOf("./graph.php") == 0)) {
+      var d = new Date();
+      $(this).attr("src", jQuery.param.querystring(src, "&_=" + d.getTime()));
+    }    
+  });
+}
+
+$(function() {
+  var stored_groups = $('input[name="metric_group"]');
+  stored_groups.val("<?php echo $this->scope["g_open_metric_groups"];?>");
+ 
+  $("#edit_optional_graphs").dialog({ autoOpen: false, minWidth: 550,
+    beforeClose: function(event, ui) { location.reload(true); } });
+
+  $("#close_edit_optional_graphs_link").button();
+  $("#popup-dialog").dialog({ autoOpen: false, minWidth: 850 });
+
+  $("#edit_optional_graphs_button").button();
+  $("#edit_optional_graphs_button").click(function(event) {
+    $("#edit_optional_graphs").dialog('open');
+    $('#edit_optional_graphs_content').html('<img src="img/spinner.gif" />');
+    $.get('edit_optional_graphs.php', "hostname=<?php echo $this->scope["hostname"];?>", function(data) {
+      $('#edit_optional_graphs_content').html(data);
+    })
+    return false;
+  });
+
+  $("#save_optional_graphs_button").button();
+  $("#save_optional_graphs_button").click(function(event) {
+    $.get('edit_optional_graphs.php', $("#edit_optional_reports_form").serialize(), function(data) {
+      $('#edit_optional_graphs_content').html(data);
+      $("#save_optional_graphs_button").hide();
+    });
+    return false;
+  });
+
+  $("#expand_all_metric_groups").button();
+  $("#expand_all_metric_groups").click(function(event) {
+    selectAllMetricGroups();
+    document.ganglia_form.submit();
+    return false;
+  });
+
+  $("#collapse_all_metric_groups").button();
+  $("#collapse_all_metric_groups").click(function(event) {
+    clearStoredMetricGroups();
+    document.ganglia_form.submit();
+    return false;
+  });
+
+  $("#host_overview").button();
+  $('#host_overview').click(function() {
+    var options = { to: { width: 200, height: 60 } }; 
+    $("#host_overview_div").toggle("blind", options, 500);
+    return false;
+  });
+
+  $('.metric-group').each(function() {
+    $(this).button();
+    $(this).click(function() {
+      var id = $(this).attr('id');
+      toggleMetricGroup(id, $("#"+id+"_div"));
+    });
+  });
+});
+</script>
+
+<?php if ((isset($this->scope["graph_engine"]) ? $this->scope["graph_engine"] : null) == "flot") {
+?>
+<script language="javascript" type="text/javascript" src="js/jquery.flot.min.js"></script>
+<script type="text/javascript" src="js/create-flot-graphs.js"></script>
+<style type="text/css">
+.flotgraph2 {
+  height: <?php echo $this->scope["graph_height"];?>px;
+  width:  <?php echo $this->scope["graph_width"];?>px;
+}
+</style>
+<?php 
+}?>
+
+
+<style type="text/css">
+  .toggler { width: 500px; height: 200px; }
+  #effect { width: 240px; height: 135px; padding: 0.4em; position: relative; }
+  #effect h3 { margin: 0; padding: 0.4em; text-align: center; }
+</style>
+
+<div id="metric-actions-dialog" title="Metric Actions">
+  <div id="metric-actions-dialog-content">
+	Available Metric actions.
+  </div>
+</div>
+<div id="popup-dialog" title="Inspect Graph">
+  <div id="popup-dialog-navigation"></div>
+  <div id="popup-dialog-content">
+  </div>
+</div>
+
+<div>
+<button id="host_overview" class="button">Host Overview</button>
+</div>
+
+<div style="display: none;" id="host_overview_div">
+<?php echo Dwoo_Plugin_include($this, 'host_overview.tpl', null, null, null, '_root', null);?>
+
+</div>
+
+<div id="edit_optional_graphs">
+  <div style="text-align:center">
+    <button id="save_optional_graphs_button">Save</button>
+  </div>
+  <div id="edit_optional_graphs_content" style="padding: .4em 1em .4em 10px;">Empty</div>
+</div>
+
+<div id="optional_graphs" style="padding-top:5px;">
+<?php echo $this->scope["optional_reports"];?>
+
+<div style='clear: left'></div>
+<?php if ((isset($this->scope["may_edit_cluster"]) ? $this->scope["may_edit_cluster"] : null)) {
+?>
+<div style="text-align:center"><button id="edit_optional_graphs_button">Edit Optional Graphs</button></div>
+<?php 
+}?>
+
+</div>
+
+<div id="sort_column_dropdowns" style="padding-top:5px;">
+<table border="0" width="100%">
+<tr>
+  <td style="text-align:center;background-color:rgb(238,238,238);">
+  <?php echo $this->scope["host"];?> <strong>graphs</strong> (<?php echo $this->scope["host_metrics_count"];?>)
+  last <strong><?php echo $this->scope["range"];?></strong>
+  sorted <strong><?php echo $this->scope["sort"];?></strong>
+<?php if (((isset($this->scope["columns_dropdown"]) ? $this->scope["columns_dropdown"] : null) !== null)) {
+?>
+  <font>
+    Columns&nbsp;&nbsp;<?php echo $this->scope["metric_cols_menu"];?>
+
+    Size&nbsp;&nbsp;<?php echo $this->scope["size_menu"];?>
+
+  </font>
+<?php 
+}?>
+
+  </td>
+</tr>
+</table>
+
+</div>
+
+<div id=metrics style="padding-top:5px">
+<center>
+<div style="padding-bottom:5px;">
+<button id="expand_all_metric_groups">Expand All Metric Groups</button>
+<button id="collapse_all_metric_groups">Collapse All Metric Groups</button>
+<input title="Time Shift Overlay - overlays previous period on all graphs" type="checkbox" id="timeshift_overlay" onclick="showTimeshiftOverlay(this.checked)"/><label for="timeshift_overlay">Timeshift Overlay</label>
+<select id="jump_to_metric_group" class="ui-corner-all" onchange="jumpToMetricGroup(this.options[this.selectedIndex].value);">
+<option disabled="disabled" selected="selected">Jump To Metric Group...</option>
+<?php 
+$_fh0_data = (isset($this->scope["g_metrics_group_data"]) ? $this->scope["g_metrics_group_data"] : null);
+if ($this->isTraversable($_fh0_data) == true)
+{
+	foreach ($_fh0_data as $this->scope['group']=>$this->scope['g_metrics'])
+	{
+/* -- foreach start output */
+?>
+<?php $this->scope["mgId"]="mg_";
+$this->scope["mgId"].=Dwoo_Plugin_regex_replace($this, (isset($this->scope["group"]) ? $this->scope["group"] : null), '/[^a-zA-Z0-9_]/', '_')?>
+
+<option value="<?php echo $this->scope["mgId"];?>"><?php echo $this->scope["group"];?></a>
+<?php 
+/* -- foreach end output */
+	}
+}?>
+
+</select>
+</div>
+<table>
+<tr>
+ <td>
+
+<?php 
+$_fh2_data = (isset($this->scope["g_metrics_group_data"]) ? $this->scope["g_metrics_group_data"] : null);
+if ($this->isTraversable($_fh2_data) == true)
+{
+	foreach ($_fh2_data as $this->scope['group']=>$this->scope['g_metrics'])
+	{
+/* -- foreach start output */
+?>
+<?php $this->scope["mgId"]="mg_";
+$this->scope["mgId"].=Dwoo_Plugin_regex_replace($this, (isset($this->scope["group"]) ? $this->scope["group"] : null), '/[^a-zA-Z0-9_]/', '_')?>
+
+<table border="0" width="100%">
+<tr>
+  <td class="metric">
+  <button id="<?php echo $this->scope["mgId"];?>" class="metric-group" title="Toggle <?php echo $this->scope["group"];?> metrics group on/off"><?php echo $this->scope["group"];?> metrics (<?php echo $this->scope["g_metrics"]["group_metric_count"];?>)</button>
+<script type="text/javascript">$(function() {
+g_mgMap["<?php echo $this->scope["mgId"];?>"] = "<?php echo $this->scope["group"];?>";
+})</script>
+  </td>
+</tr>
+</table>
+
+<?php if ((isset($this->scope["g_metrics"]["visible"]) ? $this->scope["g_metrics"]["visible"]:null)) {
+?>
+<div id="<?php echo $this->scope["mgId"];?>_div">
+<?php 
+}
+else {
+?>
+<div id="<?php echo $this->scope["mgId"];?>_div" class="ui-helper-hidden">
+<?php 
+}?>
+
+<?php if ((isset($this->scope["g_metrics"]["visible"]) ? $this->scope["g_metrics"]["visible"]:null)) {
+?>
+<table><tr>
+<?php $this->scope["i"]=0?>
+
+<?php 
+$_fh1_data = (isset($this->scope["g_metrics"]["metrics"]) ? $this->scope["g_metrics"]["metrics"]:null);
+if ($this->isTraversable($_fh1_data) == true)
+{
+	foreach ($_fh1_data as $this->scope['g_metric'])
+	{
+/* -- foreach start output */
+?>
+<td>
+<font style="font-size: 8px"><?php echo $this->scope["g_metric"]["metric_name"];?> <?php if ((isset($this->scope["g_metric"]["title"]) ? $this->scope["g_metric"]["title"]:null) != '' && (isset($this->scope["g_metric"]["title"]) ? $this->scope["g_metric"]["title"]:null) != (isset($this->scope["g_metric"]["metric_name"]) ? $this->scope["g_metric"]["metric_name"]:null)) {
+?>- <?php echo $this->scope["g_metric"]["title"];
+
+}?></font><br>
+<?php if ((isset($this->scope["may_edit_views"]) ? $this->scope["may_edit_views"] : null)) {
+?>
+<?php $this->scope["graph_args"]="&amp;";
+$this->scope["graph_args"].=(isset($this->scope["g_metric"]["graphargs"]) ? $this->scope["g_metric"]["graphargs"]:null)?>
+
+<button class="cupid-green" title="Metric Actions - Add to View, etc" onclick="metricActions('<?php echo $this->scope["g_metric"]["host_name"];?>','<?php echo $this->scope["g_metric"]["metric_name"];?>', 'metric', '<?php echo $this->scope["graph_args"];?>'); return false;">+</button>
+<?php 
+}?>
+
+<button title="Export to CSV" class="cupid-green" onClick="javascript:location.href='./graph.php?<?php echo $this->scope["g_metric"]["graphargs"];?>&amp;csv=1';return false;">CSV</button>
+<button title="Export to JSON" class="cupid-green" onClick="javascript:location.href='./graph.php?<?php echo $this->scope["g_metric"]["graphargs"];?>&amp;json=1';return false;">JSON</button>
+<button title="Inspect Graph" onClick="inspectGraph('<?php echo $this->scope["g_metric"]["graphargs"];?>'); return false;" class="shiny-blue">Inspect</button>
+<button title="6 month trend" onClick="drawTrendGraph('./graph.php?<?php echo $this->scope["g_metric"]["graphargs"];?>&amp;trend=1&amp;z=xlarge'); return false;" class="shiny-blue">Trend</button>
+
+<?php if ((isset($this->scope["graph_engine"]) ? $this->scope["graph_engine"] : null) == "flot") {
+?>
+<br>
+<div id="placeholder_<?php echo $this->scope["g_metric"]["graphargs"];?>" class="flotgraph2 img_view"></div>
+<div id="placeholder_<?php echo $this->scope["g_metric"]["graphargs"];?>_legend" class="flotlegend"></div>
+<?php 
+}
+else {
+?>
+<?php $this->scope["graphId"]=((isset($this->scope["GRAPH_BASE_ID"]) ? $this->scope["GRAPH_BASE_ID"] : null)).((isset($this->scope["mgId"]) ? $this->scope["mgId"] : null)).((isset($this->scope["i"]) ? $this->scope["i"] : null))?>
+
+<?php $this->scope["showEventsId"]=((isset($this->scope["SHOW_EVENTS_BASE_ID"]) ? $this->scope["SHOW_EVENTS_BASE_ID"] : null)).((isset($this->scope["mgId"]) ? $this->scope["mgId"] : null)).((isset($this->scope["i"]) ? $this->scope["i"] : null))?>
+
+<input title="Hide/Show Events" type="checkbox" id="<?php echo $this->scope["showEventsId"];?>" onclick="showEvents('<?php echo $this->scope["graphId"];?>', this.checked)"/><label class="show_event_text" for="<?php echo $this->scope["showEventsId"];?>">Hide/Show Events</label>
+<?php $this->scope["timeShiftId"]=((isset($this->scope["TIME_SHIFT_BASE_ID"]) ? $this->scope["TIME_SHIFT_BASE_ID"] : null)).((isset($this->scope["mgId"]) ? $this->scope["mgId"] : null)).((isset($this->scope["i"]) ? $this->scope["i"] : null))?>
+
+<input title="Timeshift Overlay" type="checkbox" id="<?php echo $this->scope["timeShiftId"];?>" onclick="showTimeShift('<?php echo $this->scope["graphId"];?>', this.checked)"/><label class="show_timeshift_text" for="<?php echo $this->scope["timeShiftId"];?>">Timeshift</label>
+<br>
+<a href="./graph_all_periods.php?<?php echo $this->scope["g_metric"]["graphargs"];?>&amp;z=large">
+<img id="<?php echo $this->scope["graphId"];?>" class="noborder <?php echo $this->scope["additional_host_img_css_classes"];?>" style="margin:5px;" alt="<?php echo $this->scope["g_metric"]["alt"];?>" src="./graph.php?<?php echo $this->scope["g_metric"]["graphargs"];?>" title="<?php echo $this->scope["g_metric"]["desc"];?>" />
+</A>
+<?php 
+}?>
+
+</td>
+<?php echo $this->scope["g_metric"]["new_row"];?>
+
+<?php echo ($this->assignInScope((isset($this->scope["i"]) ? $this->scope["i"] : null) + 1, 'i'));?>
+
+<?php 
+/* -- foreach end output */
+	}
+}?>
+
+</tr>
+</table>
+<?php 
+}?>
+
+</div>
+<?php 
+/* -- foreach end output */
+	}
+}?>
+
+ </td>
+</tr>
+</table>
+</center>
+</div>
+<input type="hidden" name="metric_group" value="">
+<!-- End host_view.tpl -->
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/job_monarch/meta_view.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/job_monarch/meta_view.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/job_monarch/meta_view.tpl.d17.php	(revision 755)
@@ -0,0 +1,221 @@
+<?php
+/* template head */
+/* end template head */ ob_start(); /* template body */ ;
+if (((isset($this->scope["filters"]) ? $this->scope["filters"] : null) !== null)) {
+?>
+<table border="0" width="100%">
+  <tr>
+    <?php 
+$_fh1_data = (isset($this->scope["filters"]) ? $this->scope["filters"] : null);
+if ($this->isTraversable($_fh1_data) == true)
+{
+	foreach ($_fh1_data as $this->scope['filter'])
+	{
+/* -- foreach start output */
+?>
+      <td>
+        <b><?php echo $this->scope["filter"]["filter_name"];?></b>
+        <select name="choose_filter[<?php echo $this->scope["filter"]["filter_shortname"];?>]" OnChange="ganglia_form.submit();">
+          <option name=""></option>
+          <?php 
+$_fh0_data = (isset($this->scope["filter"]["choice"]) ? $this->scope["filter"]["choice"]:null);
+if ($this->isTraversable($_fh0_data) == true)
+{
+	foreach ($_fh0_data as $this->scope['choice'])
+	{
+/* -- foreach start output */
+?>
+          <?php if ($this->readVar("choose_filter.".(isset($this->scope["filter"]) ? $this->scope["filter"] : null).".filter_shortname") == (isset($this->scope["choice"]) ? $this->scope["choice"] : null)) {
+?>
+          <option name="<?php echo $this->scope["choice"];?>" selected><?php echo $this->scope["choice"];?></option>
+          <?php 
+}
+else {
+?>
+          <option name="<?php echo $this->scope["choice"];?>"><?php echo $this->scope["choice"];?></option>
+          <?php 
+}?>
+
+          <?php 
+/* -- foreach end output */
+	}
+}?>
+
+        </select>
+      </td>
+    <?php 
+/* -- foreach end output */
+	}
+}?>
+
+  </tr>
+</table>
+<?php 
+}?>
+
+
+<table border="0" width="100%">
+
+<tr>
+<td colspan="3">&nbsp;</td>
+</tr>
+
+<?php 
+$_fh2_data = (isset($this->scope["sources"]) ? $this->scope["sources"] : null);
+if ($this->isTraversable($_fh2_data) == true)
+{
+	foreach ($_fh2_data as $this->scope['source'])
+	{
+/* -- foreach start output */
+?>
+<tr>
+  <td class=<?php echo $this->scope["source"]["class"];?> colspan="3">
+    <a href="<?php echo $this->scope["source"]["url"];?>"><strong><?php echo $this->scope["source"]["name"];?></strong></a> <?php echo $this->scope["source"]["alt_view"];?>
+
+  </td>
+</tr>
+
+<tr>
+<?php if (((isset($this->scope["source"]["public"]) ? $this->scope["source"]["public"]:null) !== null)) {
+?>
+<td align="LEFT" valign="TOP">
+<table cellspacing="1" cellpadding="1" width="100%" border="0">
+ <tr><td>CPUs Total:</td><td align="left"><B><?php echo $this->scope["source"]["cpu_num"];?></B></td></tr>
+ <tr><td width="80%">Hosts up:</td><td align="left"><B><?php echo $this->scope["source"]["num_nodes"];?></B></td></tr>
+ <tr><td>Hosts down:</td><td align="left"><B><?php echo $this->scope["source"]["num_dead_nodes"];?></B></td></tr>
+ <tr><td>&nbsp;</td></tr>
+ <tr><td class="footer" colspan="2"><?php echo $this->scope["source"]["cluster_load"];?></td></tr>
+ <tr><td class="footer" colspan="2"><?php echo $this->scope["source"]["cluster_util"];?></td></tr>
+ <tr><td class="footer" colspan="2"><?php echo $this->scope["source"]["localtime"];?></td></tr>
+</table>
+</td>
+
+<?php if (((isset($this->scope["source"]["self_summary_graphs"]) ? $this->scope["source"]["self_summary_graphs"]:null) !== null)) {
+?>
+<td>
+ <table align="center" border="0">
+  <tr>
+
+   <td>
+    <a href="./graph_all_periods.php?<?php echo $this->scope["source"]["graph_url"];?>&amp;g=load_report&amp;z=large">
+      <img src="./graph.php?<?php echo $this->scope["source"]["graph_url"];?>&amp;g=load_report&amp;z=medium"
+           alt="<?php echo $this->scope["source"]["name"];?> LOAD" border="0" />
+    </a>
+   </td>
+   <td>
+    <a href="./graph_all_periods.php?<?php echo $this->scope["source"]["graph_url"];?>&amp;g=mem_report&amp;z=large">
+      <img src="./graph.php?<?php echo $this->scope["source"]["graph_url"];?>&amp;g=mem_report&amp;z=medium"
+           alt="<?php echo $this->scope["source"]["name"];?> MEM" border="0" />
+    </a>
+   </td>
+  </tr>
+
+  <tr>
+   <td>
+    <a href="./graph_all_periods.php?<?php echo $this->scope["source"]["graph_url"];?>&amp;g=cpu_report&amp;z=large">
+      <img src="./graph.php?<?php echo $this->scope["source"]["graph_url"];?>&amp;g=cpu_report&amp;z=medium"
+           alt="<?php echo $this->scope["source"]["name"];?> CPU" border="0" />
+    </a>
+   </td>
+   <td>
+    <a href="./graph_all_periods.php?<?php echo $this->scope["source"]["graph_url"];?>&amp;g=network_report&amp;z=large">
+      <img src="./graph.php?<?php echo $this->scope["source"]["graph_url"];?>&amp;g=network_report&amp;z=medium"
+           alt="<?php echo $this->scope["source"]["name"];?> NETWORK" border="0" />
+    </a>
+   </td>
+
+  </tr>
+ </table>
+</td>
+<?php 
+}?>
+
+
+<?php if (((isset($this->scope["source"]["summary_graphs"]) ? $this->scope["source"]["summary_graphs"]:null) !== null)) {
+?>
+<td>
+ <table align="center" border="0">
+  <tr>
+
+      <td>
+      <a href="<?php echo $this->scope["source"]["url"];?>">
+        <img src="./graph.php?<?php echo $this->scope["source"]["graph_url"];?>&amp;g=load_report&amp;z=medium&amp;r=<?php echo $this->scope["source"]["range"];?>"
+             alt="<?php echo $this->scope["source"]["name"];?> LOAD" border="0" />
+      </a>
+      </td>
+
+      <td>
+      <a href="<?php echo $this->scope["source"]["url"];?>">
+        <img src="./graph.php?<?php echo $this->scope["source"]["graph_url"];?>&amp;g=network_report&amp;z=medium&amp;r=<?php echo $this->scope["source"]["range"];?>"
+             alt="<?php echo $this->scope["source"]["name"];?> MEM" border="0" />
+      </a>
+      </td>
+
+  </tr>
+ </td>
+</table>
+<?php 
+}?>
+
+<?php 
+}?>
+
+
+
+<?php if (((isset($this->scope["source"]["private"]) ? $this->scope["source"]["private"]:null) !== null)) {
+?>
+  <td align="LEFT" valign="TOP">
+<table cellspacing="1" cellpadding="1" width="100%" border="0">
+ <tr><td>CPUs Total:</td><td align="left"><B><?php echo $this->scope["source"]["cpu_num"];?></B></td></tr>
+ <tr><td width="80%">Nodes:</td><td align="left"><B><?php echo $this->scope["source"]["num_nodes"];?></B></td></tr>
+ <tr><td>&nbsp;</td></tr>
+ <tr><td class="footer" colspan="2"><?php echo $this->scope["source"]["localtime"];?></td></tr>
+</table>
+   </td>
+   <td colspan="2" align=center>This is a private cluster.</td>
+<?php 
+}?>
+
+</tr>
+<?php 
+/* -- foreach end output */
+	}
+}?>
+
+</table>
+
+<?php if (((isset($this->scope["show_snapshot"]) ? $this->scope["show_snapshot"] : null) !== null)) {
+?>
+<table border="0" width="100%">
+<tr>
+  <td colspan="2" class="title">Snapshot of the <?php echo $this->scope["self"];?> |
+    <font size="-1"><a href="./cluster_legend.html">Legend</a></font>
+  </td>
+</tr>
+</table>
+
+<center>
+<table cellspacing="12" cellpadding="2">
+<?php 
+$_fh3_data = (isset($this->scope["snap_rows"]) ? $this->scope["snap_rows"] : null);
+if ($this->isTraversable($_fh3_data) == true)
+{
+	foreach ($_fh3_data as $this->scope['snap_row'])
+	{
+/* -- foreach start output */
+?>
+<tr><?php echo $this->scope["snap_row"]["names"];?></tr>
+<tr><?php echo $this->scope["snap_row"]["images"];?></tr>
+<?php 
+/* -- foreach end output */
+	}
+}?>
+
+</table>
+</center>
+<?php 
+}?>
+
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/job_monarch/node_extra.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/job_monarch/node_extra.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/job_monarch/node_extra.tpl.d17.php	(revision 755)
@@ -0,0 +1,6 @@
+<?php
+/* template head */
+/* end template head */ ob_start(); /* template body */ ?><!-- Extra content underneath the simple node view. -->
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/job_monarch/physical_view.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/job_monarch/physical_view.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/job_monarch/physical_view.tpl.d17.php	(revision 755)
@@ -0,0 +1,111 @@
+<?php
+/* template head */
+/* end template head */ ob_start(); /* template body */ ?><table cellpadding="1" border="0" width="100%">
+<tr>
+<td colspan=3 class="title"><?php echo $this->scope["cluster"];?> cluster - Physical View |
+ <font size="-1">Columns&nbsp;&nbsp;<?php echo $this->scope["cols_menu"];?></font>
+</td>
+
+<tr>
+<td align="center" valign="top">
+   Verbosity level (Lower is more compact):<br />
+   <?php 
+$_fh0_data = (isset($this->scope["verbosity_levels"]) ? $this->scope["verbosity_levels"] : null);
+if ($this->isTraversable($_fh0_data) == true)
+{
+	foreach ($_fh0_data as $this->scope['verbosity']=>$this->scope['checked'])
+	{
+/* -- foreach start output */
+?>
+   <?php echo $this->scope["verbosity"];?> <input type="radio" name="p" value="<?php echo $this->scope["verbosity"];?>" OnClick="ganglia_form.submit();" <?php echo $this->scope["checked"];?> />&nbsp;
+   <?php 
+/* -- foreach end output */
+	}
+}?>
+
+</td>
+
+<td align="left" valign="top" width="25%">
+Total CPUs: <b><?php echo $this->scope["CPUs"];?></b><br />
+Total Memory: <b><?php echo $this->scope["Memory"];?></b><br />
+</td>
+
+<td align="left" valign="top" width="25%">
+Total Disk: <b><?php echo $this->scope["Disk"];?></b><br />
+Most Full Disk: <b><?php echo $this->scope["most_full"];?></b><br />
+</td>
+
+</tr>
+<tr>
+<td align="left" colspan="3">
+
+<table cellspacing="20">
+<tr>
+<?php 
+$_fh1_data = (isset($this->scope["racks"]) ? $this->scope["racks"] : null);
+if ($this->isTraversable($_fh1_data) == true)
+{
+	foreach ($_fh1_data as $this->scope['rack'])
+	{
+/* -- foreach start output */
+?>
+   <td valign="top" align="center">
+      <table cellspacing="5" border="0">
+         <?php echo $this->scope["rack"]["RackID"];?>
+
+         <?php echo $this->scope["rack"]["nodes"];?>
+
+      </table>
+   </td>
+   <?php echo $this->scope["rack"]["tr"];?>
+
+<?php 
+/* -- foreach end output */
+	}
+}?>
+
+</tr></table>
+
+</td></tr>
+</table>
+
+<hr />
+
+
+<table border="0">
+<tr>
+ <td align="left">
+<font size="-1">
+Legend
+</font>
+ </td>
+</tr>
+<tr>
+<td class="odd">
+<table width="100%" cellpadding="1" cellspacing="0" border="0">
+<tr>
+ <td style="color: blue">Node Name&nbsp;<br /></td>
+ <td align="right" valign="top">
+  <table cellspacing=1 cellpadding=3 border="0">
+  <tr>
+  <td class="L1" align="right">
+  <font size="-1">1-min load</font>
+  </td>
+  </tr>
+ </table>
+<tr>
+<td colspan="2" style="color: rgb(70,70,70)">
+<font size="-1">
+<em>cpu: </em> CPU clock (GHz) (num CPUs)<br />
+<em>mem: </em> Total Memory (GB)
+</font>
+</td>
+</tr>
+</table>
+
+</td>
+</tr>
+</table>
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/job_monarch/show_node.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/job_monarch/show_node.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/job_monarch/show_node.tpl.d17.php	(revision 755)
@@ -0,0 +1,87 @@
+<?php
+/* template head */
+if (function_exists('Dwoo_Plugin_include')===false)
+	$this->getLoader()->loadPlugin('include');
+/* end template head */ ob_start(); /* template body */ ?><!-- Begin show_node.tpl -->
+<table border="0" width="100%">
+<tr>
+  <td colspan="2" class=title><?php echo $this->scope["name"];?> Info</td>
+</tr>
+<tr><td colspan="1">&nbsp;</td></tr>
+<tr>
+<td align="center">
+
+<table cellpadding="2" cellspacing="7" border="1">
+<tr>
+<td class="<?php echo $this->scope["class"];?>">
+   <table cellpadding="1" cellspacing="10" border="0">
+   <tr><td valign="top"><font size="+2"><b><?php echo $this->scope["name"];?></b></font><br />
+   <i><?php echo $this->scope["ip"];?></i><br />
+   <em>Location:</em> <?php echo $this->scope["location"];?><p>
+
+   Cluster local time <?php echo $this->scope["clustertime"];?><br />
+   Last heartbeat received <?php echo $this->scope["age"];?> ago.<br />
+   Uptime <?php echo $this->scope["uptime"];?><br />
+
+   </td>
+   <td align="right" valign="top">
+   <table cellspacing="4" cellpadding="3" border="0"><tr>
+   <tr><td><i>Load:</i></td>
+   <td class=<?php echo $this->scope["load1"];?>><small><?php echo $this->scope["load_one"];?></small></td>
+   <td class=<?php echo $this->scope["load5"];?>><small><?php echo $this->scope["load_five"];?></small></td>
+   <td class=<?php echo $this->scope["load15"];?>><small><?php echo $this->scope["load_fifteen"];?></small></td>
+   </tr><tr><td></td><td><em>1m</em></td><td><em>5m</em></td><td><em>15m</em></td></tr>
+   </table><br />
+
+   <table cellspacing="4" cellpadding="3" border="0"><tr>
+   <td><i>CPU Utilization:</i></td>
+   <td class=<?php echo $this->scope["user"];?>><small><?php echo $this->scope["cpu_user"];?></small></td>
+   <td class=<?php echo $this->scope["sys"];?>><small><?php echo $this->scope["cpu_system"];?></small></td>
+   <td class=<?php echo $this->scope["idle"];?>><small><?php echo $this->scope["cpu_idle"];?></small></td>
+   </tr><tr><td></td><td><em>user</em></td><td><em>sys</em></td><td><em>idle</em></td></tr>
+   </table>
+   </td>
+   </tr>
+   <tr><td align="left" valign="top">
+
+   <b>Hardware</b><br />
+   <em>CPU<?php echo $this->scope["s"];?>:</em> <?php echo $this->scope["cpu"];?><br />
+   <em>Memory (RAM):</em> <?php echo $this->scope["mem"];?><br />
+   <em>Local Disk:</em> <?php echo $this->scope["disk"];?><br />
+   <em>Most Full Disk Partition:</em> <?php echo $this->scope["part_max_used"];?>
+
+   </td>
+   <td align="left" valign="top">
+
+   <b>Software</b><br />
+   <em>OS:</em> <?php echo $this->scope["OS"];?><br />
+   <em>Booted:</em> <?php echo $this->scope["booted"];?><br />
+   <em>Uptime:</em> <?php echo $this->scope["uptime"];?><br />
+   <em>Swap:</em> <?php echo $this->scope["swap"];?><br />
+
+   </td></tr></table>
+</td>
+</tr></table>
+
+ </td>
+</tr>
+<tr>
+<td align="center" valign="middle">
+ <a href="<?php echo $this->scope["physical_view"];?>">Physical View</a> | <a href="<?php echo $this->scope["self"];?>">Reload</a>
+</td>
+</tr>
+<tr>
+ <td>
+<?php if (((isset($this->scope["extra"]) ? $this->scope["extra"] : null) !== null)) {
+?>
+<?php echo Dwoo_Plugin_include($this, "".(isset($this->scope["extra"]) ? $this->scope["extra"] : null)."", null, null, null, '_root', null);?>
+
+<?php 
+}?> 
+</td>
+</tr>
+</table>
+<!-- End show_node.tpl -->
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/job_monarch/user_header.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/job_monarch/user_header.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/job_monarch/user_header.tpl.d17.php	(revision 755)
@@ -0,0 +1,7 @@
+<?php
+/* template head */
+/* end template head */ ob_start(); /* template body */ ?><div style="background: url('https://subtrac.sara.nl/images/b_header.jpg') repeat-x scroll center top; height: 20px;">
+</div>
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/job_monarch/views_view.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/job_monarch/views_view.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/compiled/templates/job_monarch/views_view.tpl.d17.php	(revision 755)
@@ -0,0 +1,142 @@
+<?php
+/* template head */
+/* end template head */ ob_start(); /* template body */ ?><style type="text/css">
+.img_view {
+  float: left;
+  margin: 0 0 10px 10px;
+}
+</style>
+
+<script type="text/javascript">
+  function refreshView() {
+    $("#view_graphs img").each(function (index) {
+	var src = $(this).attr("src");
+	if (src.indexOf("graph.php") == 0) {
+	  var d = new Date();
+	  $(this).attr("src", jQuery.param.querystring(src, "&_=" + d.getTime()));
+	}    
+    });
+  }
+
+  $(function() {
+    $( "#popup-dialog" ).dialog({ autoOpen: false, width:850 });
+    $("#create_view_button")
+      .button()
+      .click(function() {
+	$( "#create-new-view-dialog" ).dialog( "open" );
+    });
+    $("#delete_view_button")
+      .button()
+      .click(function() {
+        if ($("#vn").val() != "") {
+	  if (confirm("Are you sure you want to delete the view: " + $("#vn").val() + " ?")) {
+	    $.get('views_view.php?view_name=' + 
+                  encodeURIComponent($("#vn").val()) +
+                  '&delete_view&views_menu',
+                  function(data) {
+                    $("#views_menu").html(data);
+                    $("#view_graphs").html("");  
+                    $.cookie('ganglia-selected-view-' + window.name, "");
+		    $("#vn").val("");
+                  });
+          }
+        } else
+	  alert("Please select the view to delete");
+    });
+  });
+</script>
+
+<div id="popup-dialog" title="Inspect Graph">
+  <div id="popup-dialog-content">
+  </div>
+</div>
+
+<table id="views_table">
+<tr><td valign="top">
+<div id="views_menu">
+    <?php echo $this->scope["existing_views"];?>
+
+</div>
+<script type="text/javascript">$(function() { $("#views_menu").buttonsetv(); });</script>
+</td>
+<td valign="top">
+<div>
+<div id="views-content">
+  <div id=view_graphs>
+    <?php if (((isset($this->scope["number_of_view_items"]) ? $this->scope["number_of_view_items"] : null) !== null)) {
+?>
+    <?php if ((isset($this->scope["number_of_view_items"]) ? $this->scope["number_of_view_items"] : null) == 0) {
+?>
+    <div class="ui-widget">
+      <div class="ui-state-default ui-corner-all" style="padding: 0 .7em;"> 
+        <p><span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span>
+          No graphs defined for this view. Please add some
+      </div>
+    </div>
+    <?php 
+}
+else {
+?>
+      <?php $this->scope["i"]=0?>
+
+      <?php 
+$_fh0_data = (isset($this->scope["view_items"]) ? $this->scope["view_items"] : null);
+if ($this->isTraversable($_fh0_data) == true)
+{
+	foreach ($_fh0_data as $this->scope['view_item'])
+	{
+/* -- foreach start output */
+?>
+      <?php $this->scope["graphId"]=((isset($this->scope["GRAPH_BASE_ID"]) ? $this->scope["GRAPH_BASE_ID"] : null)).("view_").((isset($this->scope["i"]) ? $this->scope["i"] : null))?>
+
+      <?php $this->scope["showEventsId"]=((isset($this->scope["SHOW_EVENTS_BASE_ID"]) ? $this->scope["SHOW_EVENTS_BASE_ID"] : null)).("view_").((isset($this->scope["i"]) ? $this->scope["i"] : null))?>
+
+      <div class="img_view">
+        <button title="Export to CSV" class="cupid-green" onClick="javascript:location.href='graph.php?<?php echo $this->scope["view_item"]["url_args"];?>&amp;csv=1';return false;">CSV</button>
+        <button title="Export to JSON" class="cupid-green" onClick="javascript:location.href='graph.php?<?php echo $this->scope["view_item"]["url_args"];?>&amp;json=1';return false;">JSON</button>
+        <?php if ((isset($this->scope["view_item"]["aggregate_graph"]) ? $this->scope["view_item"]["aggregate_graph"]:null) == 1) {
+?>
+        <button title="Decompose aggregate graph" class="shiny-blue" onClick="javascript:location.href='?<?php echo $this->scope["view_item"]["url_args"];?>&amp;dg=1&amp;tab=v';return false;">Decompose</button>
+        <?php 
+}?>
+
+        <button title="Inspect Graph" onClick="inspectGraph('<?php echo $this->scope["view_item"]["url_args"];?>'); return false;" class="shiny-blue">Inspect</button>
+        <input type="checkbox" id="<?php echo $this->scope["showEventsId"];?>" onclick="showEvents('<?php echo $this->scope["graphId"];?>', this.checked)"/><label title="Hide/Show Events" class="show_event_text" for="<?php echo $this->scope["showEventsId"];?>">Hide/Show Events</label>
+        <br />
+<?php if ((isset($this->scope["graph_engine"]) ? $this->scope["graph_engine"] : null) == "flot") {
+?>
+<div id="placeholder_<?php echo $this->scope["view_item"]["url_args"];?>" class="flotgraph2 img_view"></div>
+<div id="placeholder_<?php echo $this->scope["view_item"]["url_args"];?>_legend" class="flotlegend"></div>
+<?php 
+}
+else {
+?>
+<a href="graph_all_periods.php?<?php echo $this->scope["view_item"]["url_args"];?>"><img id="<?php echo $this->scope["graphId"];?>" class="noborder <?php echo $this->scope["additional_host_img_css_classes"];?>" style="margin-top:5px;" src="graph.php?<?php echo $this->scope["view_item"]["url_args"];?>" /></a>
+<?php 
+}?>
+
+      </div>
+      <?php echo ($this->assignInScope((isset($this->scope["i"]) ? $this->scope["i"] : null) + 1, 'i'));?>
+
+      <?php 
+/* -- foreach end output */
+	}
+}?>
+
+    <?php 
+}?>
+
+    <?php 
+}?>
+
+  </div>
+</div>
+<div style="clear: left"></div>
+</div>
+</td>
+</tr>
+</table>
+
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/fairshare_pie.php.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/fairshare_pie.php.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/fairshare_pie.php.d17.php	(revision 755)
@@ -0,0 +1,190 @@
+<?php
+/* template head */
+/* end template head */ ob_start(); /* template body */ ?><?php
+
+function colorRed( $color ) {
+        return substr( $color, 0, 2 );
+}
+function colorGreen( $color ) {
+        return substr( $color, 2, 2 );
+}
+function colorBlue( $color ) {
+        return substr( $color, 4, 2 );
+}
+
+function colorDiffer( $first, $second ) {
+
+        // Make sure these two colors differ atleast 50 R/G/B
+        $min_diff = 50;
+
+        $c1r = hexDec( colorRed( $first ) );
+        $c1g = hexDec( colorGreen( $first ) );
+        $c1b = hexDec( colorBlue( $first ) );
+
+        $c2r = hexDec( colorRed( $second ) );
+        $c2g = hexDec( colorGreen( $second ) );
+        $c2b = hexDec( colorBlue( $second ) );
+
+        $rdiff = ($c1r >= $c2r) ? $c1r - $c2r : $c2r - $c1r;
+        $gdiff = ($c1g >= $c2g) ? $c1g - $c2g : $c2g - $c1g;
+        $bdiff = ($c1b >= $c2b) ? $c1b - $c2b : $c2b - $c1b;
+
+        if( $rdiff >= $min_diff or $gdiff >= $min_diff or $bdiff >= $min_diff )
+                return TRUE;
+        else
+                return FALSE;
+}
+
+function randomColor( $known_colors ) {
+
+        $start = "004E00";
+
+        $start_red = colorRed( $start );
+        $start_green = colorGreen( $start );
+        $start_blue = colorBlue( $start );
+
+        $end = "FFFFFF";
+
+        $end_red = colorRed( $end );
+        $end_green = colorGreen( $end );
+        $end_blue = colorBlue( $end );
+
+        $change_color = TRUE;
+
+        while( $change_color ) {
+
+                $change_color = FALSE;
+
+                $new_red = rand( hexDec( $start_red ), hexDec( $end_red ) );
+                $new_green = rand( hexDec( $start_green ), hexDec( $end_green ) );
+                $new_blue = rand( hexDec( $start_blue ), hexDec( $end_blue ) );
+
+                $new = sprintf("%02s", decHex( $new_red ) ) . sprintf("%02s", decHex( $new_green ) ) . sprintf("%02s", decHex( $new_blue ) );
+
+                foreach( $known_colors as $old )
+
+                        if( !colorDiffer( $new, $old ) )
+
+                                $change_color = TRUE;
+        }
+
+        // Whoa! Actually found a good color ;)
+        return $new;
+}
+
+if( !isset($_GET) )
+{
+  $_GET = array();
+}
+
+unset( $_GET['m'] );
+unset( $_GET['mc'] );
+unset( $_GET['hc'] );
+unset( $_GET['r'] );
+unset( $_GET['s'] );
+unset( $_GET['c'] );
+unset( $metricname );
+unset( $metric );
+
+$_GET['h'] = "batch1.irc.sara.nl";
+$_GET['c'] = "LISA Cluster";
+
+$monitor = FALSE;
+$size="250x150";
+
+if(isset($_GET['monitor']))
+{
+	$monitor = TRUE;
+	$size="500x500";
+}
+
+
+unset($context);
+global $context;
+$context = "host";
+
+//global $debug;
+//$debug = 0;
+unset( $metrics );
+global $metrics;
+
+include_once "./eval_conf.php";
+include_once "./functions.php";
+
+$base_dir = "/data/ganglia-web-current";
+require $base_dir . "/conf_default.php";
+
+# Include user-defined overrides if they exist.
+if( file_exists( $base_dir . "/conf.php" ) ) {
+  include $base_dir . "/conf.php";
+}
+
+include_once "./get_context.php";
+include_once "./ganglia.php";
+
+include_once "./get_ganglia.php";
+
+$clustername = "LISA Cluster";
+$hostname = "batch1.irc.sara.nl";
+Gmetad($conf['ganglia_ip'], $conf['ganglia_port']);
+
+$fairshare_reporter_host = "batch1.irc.sara.nl";
+
+$rrd_dir = $conf['rrds'] . "/" . $clustername . "/" . $fairshare_reporter_host;
+
+foreach( $metrics as $m_name => $m_details )
+{
+	if (preg_match("/maui_fs_([a-z]+)/i", $m_name, $matches))
+        {
+		if( strpos( $m_name, "_current" ) !== FALSE )
+		{
+			$name_fields = explode( "maui_fs_", $m_name);
+			$name2_fields = explode( "_current", $name_fields[1]);
+			$short_name = $name2_fields[0];
+
+                        $real_value = $metrics[$m_name]['VAL'];
+
+			if( $real_value > 1.00 )
+			{
+				$fs[$short_name] = $real_value;
+			}
+		}
+        }
+}
+
+$pie_args = '';
+
+$colors = array();
+
+$pie_args = "title=" . rawurlencode("Cluster Fairshare Percentages");
+$pie_args .= "&size=". $size;
+
+foreach( $fs as $fs_name => $fs_val )
+{
+    // Show pie chart of loads
+
+    $color = randomColor( $colors );
+    $colors[] = $color;
+
+    $n = $percent_hosts[$color];
+    $name_url = rawurlencode($fs_name);
+    $pie_args .= "&$name_url=$fs_val,$color";
+}
+
+if( !$monitor )
+{
+	echo "<img src=\"pie.php?";
+	echo "$pie_args";
+	echo "\" >";
+}
+else
+{
+	$url = 'https://'. $_SERVER['HTTP_HOST'] . '/pie.php?'.$pie_args;
+	$image_output = file_get_contents( $url );
+	header('Content-Type: image/png');
+	echo( $image_output );
+}
+?>
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/cluster_extra.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/cluster_extra.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/cluster_extra.tpl.d17.php	(revision 755)
@@ -0,0 +1,16 @@
+<?php
+/* template head */
+if (function_exists('Dwoo_Plugin_include')===false)
+	$this->getLoader()->loadPlugin('include');
+/* end template head */ ob_start(); /* template body */ ?><!-- A place to put custom HTML for the cluster view. -->
+<?php if ((isset($this->scope["cluster"]) ? $this->scope["cluster"] : null) == "LISA Cluster") {
+?> 
+<?php echo Dwoo_Plugin_include($this, 'fairshare_pie.php', null, null, null, '_root', null);?>
+
+<?php 
+}?>
+
+<!-- <img src="pie.php?<?php echo $this->scope["fairshare_pie_args"];?>" /> -->
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/cluster_host_metric_graphs.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/cluster_host_metric_graphs.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/cluster_host_metric_graphs.tpl.d17.php	(revision 755)
@@ -0,0 +1,57 @@
+<?php
+/* template head */
+/* end template head */ ob_start(); /* template body */ ?><center>
+<table id=graph_sorted_list>
+<tr>
+<?php 
+$_fh2_data = (isset($this->scope["sorted_list"]) ? $this->scope["sorted_list"] : null);
+if ($this->isTraversable($_fh2_data) == true)
+{
+	foreach ($_fh2_data as $this->scope['host'])
+	{
+/* -- foreach start output */
+?>
+<?php echo $this->scope["host"]["metric_image"];
+echo $this->scope["host"]["br"];?>
+
+<?php 
+/* -- foreach end output */
+	}
+}?>
+
+</tr>
+</table>
+
+<?php echo $this->scope["overflow_list_header"];?>
+
+<?php 
+$_fh3_data = (isset($this->scope["overflow_list"]) ? $this->scope["overflow_list"] : null);
+if ($this->isTraversable($_fh3_data) == true)
+{
+	foreach ($_fh3_data as $this->scope['host'])
+	{
+/* -- foreach start output */
+?>
+<?php echo $this->scope["host"]["metric_image"];
+echo $this->scope["host"]["br"];?>
+
+<?php 
+/* -- foreach end output */
+	}
+}?>
+
+<?php echo $this->scope["overflow_list_footer"];?>
+
+
+<?php if (((isset($this->scope["node_legend"]) ? $this->scope["node_legend"] : null) !== null)) {
+?>
+<p>
+(Nodes colored by 1-minute load) | <a href="./node_legend.html">Legend</A>
+</p>
+<?php 
+}?>
+
+</center>
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/cluster_overview.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/cluster_overview.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/cluster_overview.tpl.d17.php	(revision 755)
@@ -0,0 +1,13 @@
+<?php
+/* template head */
+/* end template head */ ob_start(); /* template body */ ?><table cellspacing=1 cellpadding=1 width="100%" border=0>
+ <tr><td>CPUs Total:</td><td align=left><B><?php echo $this->scope["cpu_num"];?></B></td></tr>
+ <tr><td width="60%">Hosts up:</td><td align=left><B><?php echo $this->scope["num_nodes"];?></B></td></tr>
+ <tr><td>Hosts down:</td><td align=left><B><?php echo $this->scope["num_dead_nodes"];?></B></td></tr>
+ <tr><td>&nbsp;</td></tr>
+ <tr><td colspan=2><font class="nobr">Current Load Avg (15, 5, 1m):</font><br>&nbsp;&nbsp;<b><?php echo $this->scope["cluster_load"];?></b></td></tr>
+ <tr><td colspan=2>Avg Utilization (last <?php echo $this->scope["range"];?>):<br>&nbsp;&nbsp;<b><?php echo $this->scope["cluster_util"];?></b></td></tr>
+ </table>
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/cluster_refresh.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/cluster_refresh.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/cluster_refresh.tpl.d17.php	(revision 755)
@@ -0,0 +1,17 @@
+<?php
+/* template head */
+if (function_exists('Dwoo_Plugin_include')===false)
+	$this->getLoader()->loadPlugin('include');
+/* end template head */ ob_start(); /* template body */ ;
+echo $this->scope["localtimestamp"];?><!-- || -->Overview of <?php echo $this->scope["cluster"];?> @ <?php echo $this->scope["localtime"];?><!-- || --><?php echo Dwoo_Plugin_include($this, 'cluster_overview.tpl', null, null, null, '_root', null);?><!-- || --><?php if ((isset($this->scope["pie_args"]) ? $this->scope["pie_args"] : null)) {
+?>./pie.php?<?php echo $this->scope["pie_args"];
+
+}?><!-- || --><?php if ((isset($this->scope["heatmap"]) ? $this->scope["heatmap"] : null) && (isset($this->scope["num_nodes"]) ? $this->scope["num_nodes"] : null) > 0) {
+
+echo $this->scope["heatmap"];
+
+}?><!-- || --><?php echo Dwoo_Plugin_include($this, 'cluster_host_metric_graphs.tpl', null, null, null, '_root', null);?>
+
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/cluster_view.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/cluster_view.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/cluster_view.tpl.d17.php	(revision 755)
@@ -0,0 +1,321 @@
+<?php
+/* template head */
+if (function_exists('Dwoo_Plugin_include')===false)
+	$this->getLoader()->loadPlugin('include');
+/* end template head */ ob_start(); /* template body */ ?><!-- Begin cluster_view.tpl -->
+<?php if ((isset($this->scope["heatmap"]) ? $this->scope["heatmap"] : null)) {
+?>
+<script type="text/javascript" src="js/protovis-r3.2.js"></script>
+<?php 
+}?>
+
+<script type="text/javascript">
+function refreshClusterView() {
+  $.get('cluster_view.php?' + jQuery.param.querystring() + '&refresh', function(data) {
+    var item = data.split("<!-- || -->");
+
+    $('#cluster_title').html(item[1]);
+
+    $('#cluster_overview').html(item[2]);
+
+    if ($('#load_pie').size())
+      $('#load_pie').attr("src", item[3].replace(/&amp;/g, "&"));
+
+    if ($('#heatmap-fig').size()) {
+      eval("heatmap = [" + item[4] + "]")	;
+      vis.render();
+    }
+
+    if ($('#stacked_graph').size()) {
+      var localtimestamp = parseInt(item[0]);
+      var src = $('#stacked_graph').attr('src');
+      $('#stacked_graph').attr("src", jQuery.param.querystring(src, "&st=" + localtimestamp));
+    }
+
+    var host_metric_graphs = $('#host_metric_graphs');
+    host_metric_graphs.css('height', host_metric_graphs.height() + "px");
+    host_metric_graphs.html(item[5]);
+  });
+
+  $("#optional_graphs img").each(function (index) {
+    var src = $(this).attr("src");
+    if ((src.indexOf("graph.php") == 0) ||
+        (src.indexOf("./graph.php") == 0)) {
+      var d = new Date();
+      $(this).attr("src", jQuery.param.querystring(src, "&_=" + d.getTime()));
+    }    
+  });
+}
+
+$(function() {
+  // Modified from http://jqueryui.com/demos/toggle/
+  //run the currently selected effect
+  function runEffect(id){
+    //most effect types need no options passed by default
+    var options = { };
+
+    options = { to: { width: 200,height: 60 } }; 
+    
+    //run the effect
+    $("#"+id+"_div").toggle("blind",options,500);
+  };
+ 
+  //set effect from select menu value
+  $('.button').click(function(event) {
+    runEffect(event.target.id);
+    return false;
+  });
+
+    $(function() {
+        $( "#edit_optional_graphs" ).dialog({ autoOpen: false, minWidth: 550,
+          beforeClose: function(event, ui) {  location.reload(true); } })
+        $( "#edit_optional_graphs_button" ).button();
+        $( "#save_optional_graphs_button" ).button();
+        $( "#close_edit_optional_graphs_link" ).button();
+    });
+
+    $("#edit_optional_graphs_button").click(function(event) {
+      $("#edit_optional_graphs").dialog('open');
+      $('#edit_optional_graphs_content').html('<img src="img/spinner.gif">');
+      $.get('edit_optional_graphs.php', "clustername=<?php echo $this->scope["cluster"];?>", function(data) {
+          $('#edit_optional_graphs_content').html(data);
+      })
+      return false;
+    });
+
+    $("#save_optional_graphs_button").click(function(event) {
+       $.get('edit_optional_graphs.php', $("#edit_optional_reports_form").serialize(), function(data) {
+          $('#edit_optional_graphs_content').html(data);
+          $("#save_optional_graphs_button").hide();
+          setTimeout(function() {
+             $('#edit_optional_graphs').dialog('close');
+          }, 5000);
+        });
+      return false;
+    });
+
+});
+</script>
+
+<?php if ((isset($this->scope["graph_engine"]) ? $this->scope["graph_engine"] : null) == "flot") {
+?>
+<script language="javascript" type="text/javascript" src="js/jquery.flot.min.js"></script>
+<script type="text/javascript" src="js/create-flot-graphs.js"></script>
+<style type="text/css">
+.flotgraph2 {
+  height: <?php echo $this->scope["graph_height"];?>px;
+  width:  <?php echo $this->scope["graph_width"];?>px;
+}
+</style>
+<?php 
+}?>
+
+
+<style type="text/css">
+  .toggler { width: 500px; height: 200px; }
+  a.button { padding: .15em 1em; text-decoration: none; }
+  #effect { width: 240px; height: 135px; padding: 0.4em; position: relative; }
+  #effect h3 { margin: 0; padding: 0.4em; text-align: center; }
+  #heatmap-fig {
+    width: 200px;
+    height: 200px;
+  } 
+</style>
+
+<div id="metric-actions-dialog" title="Metric Actions">
+  <div id="metric-actions-dialog-content">
+    Available Metric actions.
+  </div>
+</div>
+
+<div id="edit_optional_graphs">
+  <div style="text-align:center">
+    <button  id='save_optional_graphs_button'>Save</button>
+  </div>
+  <div id="edit_optional_graphs_content">Empty</div>
+</div>
+
+<div style="background:rgb(238,238,238);text-align:center;">
+  <font size="+1" id="cluster_title">Overview of <?php echo $this->scope["cluster"];?> @ <?php echo $this->scope["localtime"];?></font>
+</div>
+
+<table border="0" cellspacing=4 width="100%">
+<tr>
+<td align="left" valign="top">
+<div id="cluster_overview">
+<?php echo Dwoo_Plugin_include($this, 'cluster_overview.tpl', null, null, null, '_root', null);?>
+
+</div>
+<?php if (((isset($this->scope["extra"]) ? $this->scope["extra"] : null) !== null)) {
+?>
+<?php echo Dwoo_Plugin_include($this, "".(isset($this->scope["extra"]) ? $this->scope["extra"] : null)."", null, null, null, '_root', null);?>
+
+<?php 
+}?>
+
+</td>
+<td rowspan=2 align="center" valign=top>
+<div id="optional_graphs" style="padding-bottom:4px">
+<?php echo $this->scope["optional_reports"];?><br>
+<?php 
+$_fh0_data = (isset($this->scope["optional_graphs_data"]) ? $this->scope["optional_graphs_data"] : null);
+if ($this->isTraversable($_fh0_data) == true)
+{
+	foreach ($_fh0_data as $this->scope['graph'])
+	{
+/* -- foreach start output */
+?>
+  <a href="./graph_all_periods.php?<?php echo $this->scope["graph"]["graph_args"];?>&amp;g=<?php echo $this->scope["graph"]["name"];?>_report&amp;z=large">
+  <img border=0 <?php echo $this->scope["additional_cluster_img_html_args"];?> title="<?php echo $this->scope["cluster"];?> <?php echo $this->scope["graph"]["name"];?>" src="./graph.php?<?php echo $this->scope["graph"]["graph_args"];?>&amp;g=<?php echo $this->scope["graph"]["name"];?>_report&amp;z=medium"></a>
+<?php 
+/* -- foreach end output */
+	}
+}?>
+
+</div>
+<?php if ((isset($this->scope["user_may_edit"]) ? $this->scope["user_may_edit"] : null)) {
+?>
+<button id="edit_optional_graphs_button">Edit Optional Graphs</button>
+<?php 
+}?>
+
+</td>
+</tr>
+
+<tr>
+ <td align="center" valign="top">
+<?php if ((isset($this->scope["php_gd"]) ? $this->scope["php_gd"] : null) && ! (isset($this->scope["heatmap"]) ? $this->scope["heatmap"] : null)) {
+?>
+  <img id="load_pie" src="./pie.php?<?php echo $this->scope["pie_args"];?>" border="0" />
+<?php 
+}?>
+
+<?php if ((isset($this->scope["heatmap"]) ? $this->scope["heatmap"] : null) && (isset($this->scope["num_nodes"]) ? $this->scope["num_nodes"] : null) > 0) {
+?>
+Utilization heatmap<br />
+<div id="heatmap-fig">
+<script type="text/javascript+protovis">
+var heatmap = [
+<?php echo $this->scope["heatmap"];?>
+
+];
+
+var w = heatmap[0].length,
+    h = heatmap.length;
+
+var vis = new pv.Panel()
+    .width(w * <?php echo $this->scope["heatmap_size"];?>)
+    .height(h * <?php echo $this->scope["heatmap_size"];?>)
+    .margin(2)
+    .strokeStyle("#aaa")
+    .lineWidth(4)
+    .antialias(false);
+
+vis.add(pv.Image)
+    .imageWidth(w)
+    .imageHeight(h)
+    .image(pv.Scale.linear()
+        .domain(0, 0.25, 0.5, 0.75, 1.00)
+        .range("#e2ecff", "#caff98", "#ffde5e" , "#ffa15e","#ff634f")
+        .by(function(i, j) heatmap[j][i]));
+
+vis.render();
+    </script>
+ </div>
+<?php 
+}?>
+
+ </td>
+</tr>
+</table>
+
+<?php if ((isset($this->scope["stacked_graph_args"]) ? $this->scope["stacked_graph_args"] : null)) {
+?>
+<center>
+<table width="100%" border=0>
+<tr>
+  <td colspan="1">
+  <font size="+1" style="text-align:center">Stacked Graph - <?php echo $this->scope["metric"];?></font> 
+  </td>
+</tr>
+<tr>
+  <td>
+  <center><img id="stacked_graph" src="stacked.php?<?php echo $this->scope["stacked_graph_args"];?>" alt="<?php echo $this->scope["cluster"];?> <?php echo $this->scope["metric"];?>"></center>
+  </td>
+</tr>
+</table>
+</center>
+<?php 
+}?>
+
+
+<script type="text/javascript">
+// Need to set the field value to metric name
+$("#metrics-picker").val("<?php echo $this->scope["metric_name"];?>");
+</script>
+
+
+<div id="cluster_view_chooser">
+<table border="0" width="100%">
+  <tr>
+  <td style="text-align:center;background:rgb(238,238,238);">
+  Show Hosts Scaled:
+  <?php 
+$_fh1_data = (isset($this->scope["showhosts_levels"]) ? $this->scope["showhosts_levels"] : null);
+$this->globals["foreach"]['default'] = array
+(
+	"iteration"		=> 1,
+	"last"		=> null,
+	"total"		=> $this->count($_fh1_data),
+);
+$_fh1_glob =& $this->globals["foreach"]['default'];
+if ($this->isTraversable($_fh1_data) == true)
+{
+	foreach ($_fh1_data as $this->scope['id']=>$this->scope['showhosts'])
+	{
+		$_fh1_glob["last"] = (string) ($_fh1_glob["iteration"] === $_fh1_glob["total"]);
+/* -- foreach start output */
+?>
+  <input type="radio" name="sh" value="<?php echo $this->scope["id"];?>" id="shch<?php echo $this->scope["id"];?>" OnClick="ganglia_form.submit();" <?php echo $this->scope["showhosts"]["checked"];?>><label for="shch<?php echo $this->scope["id"];?>"><?php echo $this->scope["showhosts"]["name"];?></label>
+  <?php 
+/* -- implode */
+if (!$_fh1_glob["last"]) {
+	echo "";
+}
+/* -- foreach end output */
+		$_fh1_glob["iteration"]+=1;
+	}
+}?>&nbsp;
+  |
+  <span class="nobr"><?php echo $this->scope["cluster"];?> <strong><?php echo $this->scope["metric"];?></strong>
+  last <strong><?php echo $this->scope["range"];?></strong>
+  sorted <strong><?php echo $this->scope["sort"];?></strong></span>
+<?php if (((isset($this->scope["columns_size_dropdown"]) ? $this->scope["columns_size_dropdown"] : null) !== null)) {
+?>
+  |
+   <font>
+   <span class="nobr">Size&nbsp;&nbsp;<?php echo $this->scope["size_menu"];?></span>
+   <span class="nobr">Columns&nbsp;&nbsp;<?php echo $this->scope["cols_menu"];?> (0 = metric + reports)</span>
+   </font>
+<?php 
+}?>
+
+  </td>
+</tr>
+</table>
+</div>
+
+<div id="host_metric_graphs">
+<?php echo Dwoo_Plugin_include($this, 'cluster_host_metric_graphs.tpl', null, null, null, '_root', null);?>
+
+</div>
+
+<script type="text/javascript">
+$(function() {
+  $( "#cluster_view_chooser" ).buttonset();
+});
+</script>
+<!-- End cluster_view.tpl -->
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/footer.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/footer.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/footer.tpl.d17.php	(revision 755)
@@ -0,0 +1,84 @@
+<?php
+/* template head */
+/* end template head */ ob_start(); /* template body */ ?><!-- Begin footer.tpl -->
+</form> <!-- ganglia-form -->
+</div> <!-- tabs-main -->
+
+<div id="tabs-search">
+  Search term matches any number of metrics and hosts. For example type web or disk; wait a split second, and a drop down menu will show up with choices.
+  <!-- Uses LiveSearch from http://andreaslagerkvist.com/jquery/live-search/ -->
+  <div id="metric-search">
+    <form method="post" action="/search/">
+      <p>
+	<label>
+	    <small>Search as you type</small><br />
+	    <input type="text" name="q" id="search-field-q" size="60" placeholder="Search as you type" on />
+	</label>
+      </p>
+    </form>
+  </div>
+</div> 
+
+<div id="create-new-view-dialog" title="Create new view">
+  <div id="create-new-view-layer">
+    <form id="create_view_form">
+      <input type="hidden" name="create_view" value="1">
+      <fieldset>
+	 <label for="name">View Name</label>
+	 <input type="text" name="view_name" id="view_name" class="text ui-widget-content ui-corner-all" />
+         <center><button onclick="createView(); return false;">Create</button></center>
+      </fieldset>
+    </form>
+  </div>
+  <div id="create-new-view-confirmation-layer"></div>
+</div>
+
+<div id="tabs-mobile"></div>
+
+<div id="tabs-autorotation">
+Invoke automatic rotation system. Automatic rotation rotates all of the graphs/metrics specified in a view waiting 
+30 seconds in between each. This will run as long as you have this page open.
+<p>
+Please select the view you want to rotate.</p>
+  <div id="tabs-autorotation-chooser">
+Loading view, please wait...<img src="img/spinner.gif" />
+  </div>
+</div>
+
+<div id="tabs-livedashboard">
+Live dashboard provides you with an overview of all view metrics in a compact format. Data updates every 15 seconds.
+Only those elements that contain a metric or graph report are supported. Aggregate graphs will not be included.
+<p>
+You can get more graphs per page by using your browser zoom functionality.
+<p>
+Please select the view you want to view</p>
+  <div id="tabs-livedashboard-chooser">
+Loading view, please wait...<img src="img/spinner.gif" />
+  </div>
+</div>
+
+
+<hr />
+<div align="center">
+<font size="-1" class="footer">
+Ganglia Web Frontend version <?php echo $this->scope["webfrontend_version"];?>
+
+<a href="http://ganglia.sourceforge.net/downloads.php?component=ganglia-webfrontend&amp;version=<?php echo $this->scope["webfrontend_version"];?>">Check for Updates.</a><br />
+
+Ganglia Web Backend <i>(<?php echo $this->scope["webbackend_component"];?>)</i> version <?php echo $this->scope["webbackend_version"];?>
+
+<a href="http://ganglia.sourceforge.net/downloads.php?component=<?php echo $this->scope["webbackend_component"];?>&amp;version=<?php echo $this->scope["webbackend_version"];?>">Check for Updates.</a><br />
+
+Downloading and parsing ganglia's XML tree took <?php echo $this->scope["parsetime"];?>.<br />
+Images created with <a href="http://www.rrdtool.org/">RRDtool</a> version <?php echo $this->scope["rrdtool_version"];?>.<br />
+<?php echo $this->globals["ad"];?> <?php echo $this->globals["version"];?>.<br />
+</font>
+</div>
+</div> <!-- div-tabs -->
+</BODY>
+<!-- End footer.tpl -->
+</HTML>
+
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/grid_tree.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/grid_tree.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/grid_tree.tpl.d17.php	(revision 755)
@@ -0,0 +1,63 @@
+<?php
+/* template head */
+/* end template head */ ob_start(); /* template body */ ?><table border="0" width="100%">
+<tr>
+  <td class="title"><B><?php echo $this->scope["self"];?> Grid Tree</b></td>
+</tr>
+</table>
+
+<div align="center">
+<table cellspacing="5" cellpadding="5" border="1">
+<tr>
+
+<?php if (((isset($this->scope["parentgrid"]) ? $this->scope["parentgrid"] : null) !== null)) {
+?>
+<td align="center">
+<table cellpadding="3" cellspacing="3" border="0">
+<?php echo $this->scope["parents"];?>
+
+</table>
+</td>
+<?php 
+}?>
+
+</tr>
+
+<tr>
+<td align="center">
+
+<table cellpadding="3" cellspacing="3" border="0">
+<tr>
+ <td colspan="<?php echo $this->scope["n"];?>" class="self" align="center" style="border: thin solid rgb(47,47,47);">
+  <?php echo $this->scope["self"];?>
+
+ </td>
+</tr>
+
+<tr>
+ <?php echo $this->scope["children"];?>
+
+</tr>
+</table>
+
+</td>
+</tr>
+
+</table>
+</div>
+
+<p>
+<hr />
+<b>Legend:</b>
+<table cellspacing="5" border="0">
+<tr>
+<td class="self" width="20">&nbsp;</td><td>This Grid.</td>
+</tr>
+<tr>
+<td class="grid">&nbsp;</td><td>A Remote Grid.</td>
+</tr>
+</table>
+
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/header.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/header.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/header.tpl.d17.php	(revision 755)
@@ -0,0 +1,302 @@
+<?php
+/* template head */
+if (function_exists('Dwoo_Plugin_include')===false)
+	$this->getLoader()->loadPlugin('include');
+/* end template head */ ob_start(); /* template body */ ?><!-- Begin header.tpl -->
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<title>Ganglia:: <?php echo $this->scope["page_title"];?></title>
+<meta http-equiv="Content-type" content="text/html; charset=utf-8">
+<link type="text/css" href="css/smoothness/jquery-ui-1.9.1.custom.min.css" rel="stylesheet" />
+<link type="text/css" href="css/jquery.liveSearch.css" rel="stylesheet" />
+<link type="text/css" href="css/jquery.multiselect.css" rel="stylesheet" />
+<link type="text/css" href="css/jquery.flot.events.css" rel="stylesheet" />
+<link type="text/css" href="./styles.css" rel="stylesheet" />
+<script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
+<script type="text/javascript" src="js/jquery-ui-1.9.1.custom.min.js"></script>
+<script type="text/javascript" src="js/jquery.livesearch.min.js"></script>
+<script type="text/javascript" src="js/ganglia.js"></script>
+<script type="text/javascript" src="js/jquery.gangZoom.js"></script>
+<script type="text/javascript" src="js/jquery.cookie.js"></script>
+<script type="text/javascript" src="js/jquery-ui-timepicker-addon.js"></script>
+<script type="text/javascript" src="js/jquery.ba-bbq.min.js"></script>
+<script type="text/javascript" src="js/combobox.js"></script>
+<script type="text/javascript" src="js/jquery.scrollTo-1.4.2-min.js"></script>
+<script type="text/javascript" src="js/jquery.buttonsetv.js"></script>
+<script type="text/javascript">
+    var server_utc_offset=<?php echo $this->scope["server_utc_offset"];?>;
+    
+    var g_refresh_timer = setTimeout("refresh()", <?php echo $this->scope["refresh"];?> * 1000);
+
+    function refreshHeader() {
+      $.get('header.php?date_only=1', function(data) {
+        var title = $("#page_title").text();
+        var l = title.lastIndexOf(" for ");
+        title = title.substring(0, l);
+        title += " for " + data;
+        $("#page_title").text(title);
+        });
+    }
+
+    function refresh() {
+      var selected_tab = $("#selected_tab").val();
+      if (selected_tab == "agg") {
+        refreshAggregateGraph();
+        g_refresh_timer = setTimeout("refresh()", <?php echo $this->scope["refresh"];?> * 1000);
+      } else if (selected_tab == "v") {
+        refreshHeader();
+        if ($.isFunction(window.refreshView)) {
+          refreshView();
+          g_refresh_timer = setTimeout("refresh()", <?php echo $this->scope["refresh"];?> * 1000);
+        } else if ($.isFunction(window.refreshDecomposeGraph)) {
+          refreshDecomposeGraph();
+          g_refresh_timer = setTimeout("refresh()", <?php echo $this->scope["refresh"];?> * 1000);
+        } else
+          ganglia_form.submit();
+      } else if (selected_tab == "ev") {
+        refreshOverlayEvent();
+        g_refresh_timer = setTimeout("refresh()", <?php echo $this->scope["refresh"];?> * 1000);
+      } else if (selected_tab == "m") {
+        if ($.isFunction(window.refreshClusterView)) {
+          refreshHeader();
+          refreshClusterView();
+          g_refresh_timer = setTimeout("refresh()", <?php echo $this->scope["refresh"];?> * 1000);
+        } else if ($.isFunction(window.refreshHostView)) {
+          refreshHeader();
+          refreshHostView();
+          g_refresh_timer = setTimeout("refresh()", <?php echo $this->scope["refresh"];?> * 1000);
+        } else
+          ganglia_form.submit();
+      } else
+        ganglia_form.submit();
+    }
+
+    $(function() {
+      g_overlay_events = ($("#overlay_events").val() == "true");
+
+      g_tabIndex = new Object();
+      g_tabName = [];
+      var tabName = ["m", "s", "v", "agg", "ch", "ev", "rot", "mob"];
+      var j = 0;
+      for (var i in tabName) {
+        if (tabName[i] == "ev" && !g_overlay_events)
+          continue;
+        g_tabIndex[tabName[i]] = j++;
+        g_tabName.push(tabName[i]);
+      }
+
+      // Follow tab's URL instead of loading its content via ajax
+      var tabs = $("#tabs");
+      if (tabs[0]) {
+        tabs.tabs();
+        // Restore previously selected tab
+        var selected_tab = $("#selected_tab").val();
+        //alert("selected_tab = " + selected_tab);
+        if (typeof g_tabIndex[selected_tab] != 'undefined') {
+          try {
+            //alert("Selecting tab: " + selected_tab);
+            tabs.tabs("select", g_tabIndex[selected_tab]);
+            if (selected_tab == "rot")
+              autoRotationChooser();
+          } catch (err) {
+            try {
+              alert("Error(ganglia.js): Unable to select tab: " + 
+                    selected_tab + ". " + err.getDescription());
+            } catch (err) {
+              // If we can't even show the error, fail silently.
+            }
+          }
+        }
+
+        tabs.bind("tabsselect", function(event, ui) {
+          $("#selected_tab").val(g_tabName[ui.index]);
+          if (g_tabName[ui.index] != "mob")
+            $.cookie("ganglia-selected-tab-" + window.name, ui.index);
+          if (ui.index == g_tabIndex["m"] ||
+              ui.index == g_tabIndex["v"] ||
+              ui.index == g_tabIndex["ch"])
+            ganglia_form.submit();
+        });
+      }
+    });
+
+    $(function() {
+      $("#metrics-picker").combobox();
+
+      <?php echo $this->scope["is_metrics_picker_disabled"];?>
+
+
+      $(".header_btn").button();
+    });
+
+  $(function () {
+
+    done = function done(startTime, endTime) {
+            setStartAndEnd(startTime, endTime);
+            document.forms['ganglia_form'].submit();
+    }
+
+    cancel = function (startTime, endTime) {
+            setStartAndEnd(startTime, endTime);
+    }
+
+    defaults = {
+        startTime: <?php echo $this->scope["start_timestamp"];?>,
+        endTime: <?php echo $this->scope["end_timestamp"];?>,
+        done: done,
+        cancel: cancel
+    }
+
+    $(".host_small_zoomable").gangZoom($.extend({
+        paddingLeft: 67,
+        paddingRight: 30,
+        paddingTop: 38,
+        paddingBottom: 25
+    }, defaults));
+
+    $(".host_medium_zoomable").gangZoom($.extend({
+        paddingLeft: 67,
+        paddingRight: 30,
+        paddingTop: 38,
+        paddingBottom: 40
+    }, defaults));
+
+    $(".host_default_zoomable").gangZoom($.extend({
+        paddingLeft: 66,
+        paddingRight: 30,
+        paddingTop: 37,
+        paddingBottom: 50
+    }, defaults));
+
+    $(".host_large_zoomable").gangZoom($.extend({
+        paddingLeft: 66,
+        paddingRight: 29,
+        paddingTop: 37,
+        paddingBottom: 56
+    }, defaults));
+
+    $(".cluster_zoomable").gangZoom($.extend({
+        paddingLeft: 67,
+        paddingRight: 30,
+        paddingTop: 37,
+        paddingBottom: 50
+    }, defaults));
+
+    function rrdDateTimeString(date) {
+      return (date.getMonth() + 1) + "/" + date.getDate() + "/" + date.getFullYear() + " " + date.getHours() + ":" + date.getMinutes();
+    }
+
+    function setStartAndEnd(startTime, endTime) {
+        // we're getting local start/end times.
+
+        // getTimezoneOffset returns negative values east of UTC,
+        // which is the opposite of PHP. we want negative values to the west.
+        var local_offset = new Date().getTimezoneOffset() * 60 * -1;
+        var delta = local_offset - server_utc_offset;
+        var date = new Date((Math.floor(startTime) - delta) * 1000);
+        $("#datepicker-cs").val(rrdDateTimeString(date));
+        date = new Date((Math.floor(endTime) - delta) * 1000);
+        $("#datepicker-ce").val(rrdDateTimeString(date));
+    }
+
+    initShowEvent();
+    initTimeShift();
+  });
+
+
+</script>
+<?php echo $this->scope["custom_time_head"];?>
+
+</head>
+<body style="background-color: #ffffff;" onunload="g_refresh_timer=null">
+<?php if (((isset($this->scope["user_header"]) ? $this->scope["user_header"] : null) !== null)) {
+?>
+<?php echo Dwoo_Plugin_include($this, "user_header.tpl", null, null, null, '_root', null);?>
+
+<?php 
+}?>
+
+
+<?php if ((isset($this->scope["auth_system_enabled"]) ? $this->scope["auth_system_enabled"] : null)) {
+?>
+<div style="float:right">
+  <?php if ((isset($this->scope["username"]) ? $this->scope["username"] : null)) {
+?>
+    Currently logged in as: <?php echo $this->scope["username"];?> | <a href="logout.php">Logout</a>
+  <?php 
+}
+else {
+?>
+    You are not currently logged in. | <a href="login.php">Login</a>
+  <?php 
+}?>
+
+</div>
+<br style="clear:both"/>
+<?php 
+}?>
+
+
+<div id="tabs">
+<ul>
+  <li><a href="#tabs-main">Main</a></li>
+  <li><a href="#tabs-search">Search</a></li>
+  <li><a href="#tabs-main">Views</a></li>
+  <li><a href="aggregate_graphs.php">Aggregate Graphs</a></li>
+  <li><a href="#tabs-main">Compare Hosts</a></li>
+<?php if ((isset($this->scope["overlay_events"]) ? $this->scope["overlay_events"] : null)) {
+?>
+  <li><a href="events.php">Events</a></li>
+<?php 
+}?>
+
+  <li><a href="#tabs-autorotation" onclick="autoRotationChooser();">Automatic Rotation</a></li>
+  <li><a href="#tabs-livedashboard" onclick="liveDashboardChooser();">Live Dashboard</a></li>  
+  <li><a href="#tabs-mobile" onclick="window.location.href='mobile.php';">Mobile</a></li>
+</ul>
+
+<div id="tabs-main">
+<form action="<?php echo $this->scope["page"];?>" method="GET" name="ganglia_form">
+  <div style="background-color:#dddddd;padding:5px;">
+     <big style="float:left;"><b id="page_title"><?php echo $this->scope["page_title"];?> for <?php echo $this->scope["date"];?></b></big><input style="float:right;" class="header_btn" type="submit" value="Get Fresh Data"/><div style="clear:both"></div>
+  </div>
+  <div style="padding:5px 5px 0 5px;">
+    <div style="float:left;" id="range_menu" class="nobr"><?php echo $this->scope["range_menu"];?></div>
+    <div style="float:left;" id="custom_range_menu"><?php echo $this->scope["custom_time"];?></div>
+    <div style="float:right;"><?php echo $this->scope["additional_buttons"];?>&nbsp;&nbsp;<?php echo $this->scope["alt_view"];?></div>
+    <div style="clear:both;"></div>
+  </div>
+  <div id="sort_menu" style="padding:5px 5px 0 5px;">
+   Metric&nbsp;&nbsp; <select name="m" id="metrics-picker"><?php echo $this->scope["picker_metrics"];?></select>&nbsp;&nbsp;
+     <?php echo $this->scope["sort_menu"];?>
+
+  </div>
+<?php if ((isset($this->scope["node_menu"]) ? $this->scope["node_menu"] : null) != "") {
+?>
+  <div id="sort_menu" style="padding:5px 5px 0 5px;">
+    <?php echo $this->scope["node_menu"];?>&nbsp;&nbsp;<?php echo $this->scope["additional_filter_options"];?>
+
+  </div>
+<?php 
+}?>
+
+
+<input type="hidden" name="tab" id="selected_tab" value="<?php echo $this->scope["selected_tab"];?>">
+<input type="hidden" id="vn" name="vn" value="<?php echo $this->scope["view_name"];?>">
+<?php if ((isset($this->scope["overlay_events"]) ? $this->scope["overlay_events"] : null)) {
+?>
+<input type="hidden" id="overlay_events" value="true">
+<?php 
+}
+else {
+?>
+<input type="hidden" id="overlay_events" value="false">
+<?php 
+}?>
+
+<hr size="1" noshade>
+<!-- End header.tpl -->
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/host_overview.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/host_overview.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/host_overview.tpl.d17.php	(revision 755)
@@ -0,0 +1,74 @@
+<?php
+/* template head */
+if (function_exists('Dwoo_Plugin_include')===false)
+	$this->getLoader()->loadPlugin('include');
+/* end template head */ ob_start(); /* template body */ ?><br>
+<table border="0" width="100%">
+
+<tr>
+ <td align="left" valign="TOP">
+
+<img src="<?php echo $this->scope["node_image"];?>" class="noborder" height="60" width="30" title="<?php echo $this->scope["host"];?>"/>
+<?php echo $this->scope["node_msg"];?>
+
+
+<table border="0" width="100%">
+<tr>
+  <td colspan="2" class="title">Time and String Metrics</td>
+</tr>
+
+<?php 
+$_fh2_data = (isset($this->scope["s_metrics_data"]) ? $this->scope["s_metrics_data"] : null);
+if ($this->isTraversable($_fh2_data) == true)
+{
+	foreach ($_fh2_data as $this->scope['s_metric'])
+	{
+/* -- foreach start output */
+?>
+<tr>
+ <td class="footer" width="30%"><?php echo $this->scope["s_metric"]["name"];?></td><td><?php echo $this->scope["s_metric"]["value"];?></td>
+</tr>
+<?php 
+/* -- foreach end output */
+	}
+}?>
+
+
+<tr><td>&nbsp;</td></tr>
+
+<tr>
+  <td colspan="2" class="title">Constant Metrics</td>
+</tr>
+
+<?php 
+$_fh3_data = (isset($this->scope["c_metrics_data"]) ? $this->scope["c_metrics_data"] : null);
+if ($this->isTraversable($_fh3_data) == true)
+{
+	foreach ($_fh3_data as $this->scope['c_metric'])
+	{
+/* -- foreach start output */
+?>
+<tr>
+ <td class="footer" width="30%"><?php echo $this->scope["c_metric"]["name"];?></td><td><?php echo $this->scope["c_metric"]["value"];?></td>
+</tr>
+<?php 
+/* -- foreach end output */
+	}
+}?>
+
+</table>
+
+ <hr />
+<?php if (((isset($this->scope["extra"]) ? $this->scope["extra"] : null) !== null)) {
+?>
+<?php echo Dwoo_Plugin_include($this, "".(isset($this->scope["extra"]) ? $this->scope["extra"] : null)."", null, null, null, '_root', null);?>
+
+<?php 
+}?>
+
+</td> 
+</table>
+
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/host_view.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/host_view.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/host_view.tpl.d17.php	(revision 755)
@@ -0,0 +1,426 @@
+<?php
+/* template head */
+if (function_exists('Dwoo_Plugin_include')===false)
+	$this->getLoader()->loadPlugin('include');
+if (function_exists('Dwoo_Plugin_regex_replace')===false)
+	$this->getLoader()->loadPlugin('regex_replace');
+/* end template head */ ob_start(); /* template body */ ?><!-- Begin host_view.tpl -->
+<style type="text/css">
+/* don't display legends for these small graphs */
+.flotlegend, .flotlegendtoplabel {
+  display: none !important;
+}
+.flotheader {
+  margin-top: 2em;
+}
+.flottitle {
+  padding-right: 4em;
+  font-weight: bold;
+}
+.img_view {
+  float: left;
+  margin: 0 0 10px 10px;
+}
+</style>
+<script type="text/javascript">
+var SEPARATOR = "_|_";
+var ALL_GROUPS = "ALLGROUPS";
+var NO_GROUPS = "NOGROUPS";
+// Map metric group id to name
+var g_mgMap = new Object();
+
+function clearStoredMetricGroups() {
+  var stored_groups = $('input[name="metric_group"]');
+  stored_groups.val(NO_GROUPS);
+}
+
+function selectAllMetricGroups() {
+  var stored_groups = $('input[name="metric_group"]');
+  stored_groups.val(ALL_GROUPS);
+}
+
+function addMetricGroup(mgName) {
+  var stored_groups = $('input[name="metric_group"]');
+
+  var open_groups = stored_groups.val();
+  if (open_groups == ALL_GROUPS)
+    return; // no exceptions
+
+  var groups = open_groups.split(SEPARATOR);
+  switch (groups[0]) {
+    case ALL_GROUPS:
+      // Remove from except list
+      for (var i = 1; i < groups.length; i++) {
+        if (groups[i] == mgName) {
+          groups.splice(i, 1);
+          break;
+        }
+      }
+      open_groups = groups.join(SEPARATOR);
+    break;
+    case NO_GROUPS:
+      // Add to list if not already there
+      var inList = false;
+      for (var i = 1; i < groups.length; i++) {
+         if (groups[i] == mgName) {
+           inList = true;
+           break;
+         }
+      }
+      if (!inList) {
+        open_groups += SEPARATOR;
+        open_groups += mgName;
+      }
+    break;
+    default:
+      alert("Unrecognized group option - " + groups[0]);
+  }
+  stored_groups.val(open_groups);
+}
+
+function removeMetricGroup(mgName) {
+  var stored_groups = $('input[name="metric_group"]');
+
+  var open_groups = stored_groups.val();
+  if (open_groups == NO_GROUPS)
+    return; // no exceptions
+
+  var groups = open_groups.split(SEPARATOR);
+  switch (groups[0]) {
+    case ALL_GROUPS:
+      var inList = false;
+      for (var i = 1; i < groups.length; i++) {
+        if (groups[i] == mgName) {
+          inList = true;
+          break;
+        }
+      }
+      if (!inList) {
+        open_groups += SEPARATOR;
+        open_groups += mgName;
+      }
+    break;
+    case NO_GROUPS:
+      for (var i = 1; i < groups.length; i++) {
+        if (groups[i] == mgName) {
+          groups.splice(i, 1);
+          break;
+        }
+      }
+      open_groups = groups.join(SEPARATOR);
+    break;
+    default:
+      alert("Unrecognized group option - " + groups[0]);
+  }
+  stored_groups.val(open_groups);
+}
+
+function toggleMetricGroup(mgId, mgDiv) {
+  var mgName = g_mgMap[mgId];
+  if (mgDiv.is(":visible")) {
+    // metric group is being closed
+    removeMetricGroup(mgName);
+    mgDiv.html("");
+    mgDiv.hide();
+  } else {
+    addMetricGroup(mgName);
+    var url = 'metric_group_view.php?<?php echo $this->scope["baseGraphArgs"];?>&metric_group=' + mgName;
+    url += "&event=";
+    url += ($("#show_all_events").attr("checked") == "checked") ? "show" : "hide";
+    url += "&ts=";
+    url += ($("#timeshift_overlay").attr("checked") == "checked") ? "1" : "0";
+
+    $.get(url, 
+          function(data) {
+            mgDiv.html(data);
+	    mgInitEventBtns(mgDiv);
+	    mgInitTimeshiftBtns(mgDiv);
+            mgDiv.show();
+          });
+  }
+}
+
+function jumpToMetricGroup(mgId) {
+  //alert("jumping to " + mgId);
+  $.scrollTo($('#' + mgId));
+}
+
+function refreshHostView() {
+  $.get('host_overview.php?h=<?php echo $this->scope["hostname"];?>&c=<?php echo $this->scope["cluster"];?>', function(data) {
+    $('#host_overview_div').html(data);
+  });
+
+  $("#optional_graphs img").each(function (index) {
+    var src = $(this).attr("src");
+    if ((src.indexOf("graph.php") == 0) ||
+        (src.indexOf("./graph.php") == 0)) {
+      var d = new Date();
+      $(this).attr("src", jQuery.param.querystring(src, "&_=" + d.getTime()));
+    }    
+  });
+
+  $("#metrics img").each(function (index) {
+    var src = $(this).attr("src");
+    if ((src.indexOf("graph.php") == 0)  ||
+        (src.indexOf("./graph.php") == 0)) {
+      var d = new Date();
+      $(this).attr("src", jQuery.param.querystring(src, "&_=" + d.getTime()));
+    }    
+  });
+}
+
+function mgInitEventBtns(mgDiv) {
+  var checked = $("#show_all_events").attr("checked");
+  mgDiv.find("[id^=" + SHOW_EVENTS_BASE_ID + "]").each(function() {
+    $(this).button();
+    if (checked == "checked")
+      $(this).attr("checked", 'checked');
+    else
+      $(this).removeAttr("checked");
+    $(this).button('refresh');
+  });
+}
+
+function mgInitTimeshiftBtns(mgDiv) {
+  var checked = $("#timeshift_overlay").attr("checked");
+  mgDiv.find("[id^=" + TIME_SHIFT_BASE_ID + "]").each(function() {
+    $(this).button();
+    if (checked == "checked")
+      $(this).attr("checked", 'checked');
+    else
+      $(this).removeAttr("checked");
+    $(this).button('refresh');
+  });
+}
+
+$(function() {
+  var stored_groups = $('input[name="metric_group"]');
+  stored_groups.val("<?php echo $this->scope["g_open_metric_groups"];?>");
+ 
+  $("#edit_optional_graphs").dialog({ autoOpen: false, minWidth: 550,
+    beforeClose: function(event, ui) { location.reload(true); } });
+
+  $("#close_edit_optional_graphs_link").button();
+  $("#popup-dialog").dialog({ autoOpen: false, minWidth: 850 });
+
+  $("#edit_optional_graphs_button").button();
+  $("#edit_optional_graphs_button").click(function(event) {
+    $("#edit_optional_graphs").dialog('open');
+    $('#edit_optional_graphs_content').html('<img src="img/spinner.gif" />');
+    $.get('edit_optional_graphs.php', "hostname=<?php echo $this->scope["hostname"];?>", function(data) {
+      $('#edit_optional_graphs_content').html(data);
+    })
+    return false;
+  });
+
+  $("#save_optional_graphs_button").button();
+  $("#save_optional_graphs_button").click(function(event) {
+    $.get('edit_optional_graphs.php', $("#edit_optional_reports_form").serialize(), function(data) {
+      $('#edit_optional_graphs_content').html(data);
+      $("#save_optional_graphs_button").hide();
+    });
+    return false;
+  });
+
+  $("#expand_all_metric_groups").button();
+  $("#expand_all_metric_groups").click(function(event) {
+    selectAllMetricGroups();
+    document.ganglia_form.submit();
+    return false;
+  });
+
+  $("#collapse_all_metric_groups").button();
+  $("#collapse_all_metric_groups").click(function(event) {
+    clearStoredMetricGroups();
+    document.ganglia_form.submit();
+    return false;
+  });
+
+  $("#host_overview").button();
+  $('#host_overview').click(function() {
+    var options = { to: { width: 200, height: 60 } }; 
+    $("#host_overview_div").toggle("blind", options, 500);
+    return false;
+  });
+
+  $('.metric-group').each(function() {
+    $(this).button();
+    $(this).click(function() {
+      var id = $(this).attr('id');
+      toggleMetricGroup(id, $("#"+id+"_div"));
+      return false;
+    });
+  });
+});
+</script>
+
+<?php if ((isset($this->scope["graph_engine"]) ? $this->scope["graph_engine"] : null) == "flot") {
+?>
+<script language="javascript" type="text/javascript" src="js/jquery.flot.min.js"></script>
+<script type="text/javascript" src="js/create-flot-graphs.js"></script>
+<style type="text/css">
+.flotgraph2 {
+  height: <?php echo $this->scope["graph_height"];?>px;
+  width:  <?php echo $this->scope["graph_width"];?>px;
+}
+</style>
+<?php 
+}?>
+
+
+<style type="text/css">
+  .toggler { width: 500px; height: 200px; }
+  #effect { width: 240px; height: 135px; padding: 0.4em; position: relative; }
+  #effect h3 { margin: 0; padding: 0.4em; text-align: center; }
+</style>
+
+<div id="metric-actions-dialog" title="Metric Actions">
+  <div id="metric-actions-dialog-content">
+	Available Metric actions.
+  </div>
+</div>
+<div id="popup-dialog" title="Inspect Graph">
+  <div id="popup-dialog-navigation"></div>
+  <div id="popup-dialog-content">
+  </div>
+</div>
+
+<div>
+<button id="host_overview" class="button">Host Overview</button>
+</div>
+
+<div style="display: none;" id="host_overview_div">
+<?php echo Dwoo_Plugin_include($this, 'host_overview.tpl', null, null, null, '_root', null);?>
+
+</div>
+
+<div id="edit_optional_graphs">
+  <div style="text-align:center">
+    <button id="save_optional_graphs_button">Save</button>
+  </div>
+  <div id="edit_optional_graphs_content" style="padding: .4em 1em .4em 10px;">Empty</div>
+</div>
+
+<div id="optional_graphs" style="padding-top:5px;">
+<?php echo $this->scope["optional_reports"];?>
+
+<div style='clear: left'></div>
+<?php if ((isset($this->scope["may_edit_cluster"]) ? $this->scope["may_edit_cluster"] : null)) {
+?>
+<div style="text-align:center"><button id="edit_optional_graphs_button">Edit Optional Graphs</button></div>
+<?php 
+}?>
+
+</div>
+
+<div id="sort_column_dropdowns" style="padding-top:5px;">
+<table border="0" width="100%">
+<tr>
+  <td style="text-align:center;background-color:rgb(238,238,238);">
+  <?php echo $this->scope["host"];?> <strong>graphs</strong> (<?php echo $this->scope["host_metrics_count"];?>)
+  last <strong><?php echo $this->scope["range"];?></strong>
+  sorted <strong><?php echo $this->scope["sort"];?></strong>
+<?php if (((isset($this->scope["columns_dropdown"]) ? $this->scope["columns_dropdown"] : null) !== null)) {
+?>
+  <font>
+    Columns&nbsp;&nbsp;<?php echo $this->scope["metric_cols_menu"];?>
+
+    Size&nbsp;&nbsp;<?php echo $this->scope["size_menu"];?>
+
+  </font>
+<?php 
+}?>
+
+  </td>
+</tr>
+</table>
+
+</div>
+
+<div id=metrics style="padding-top:5px">
+<center>
+<div style="padding-bottom:5px;">
+<button id="expand_all_metric_groups">Expand All Metric Groups</button>
+<button id="collapse_all_metric_groups">Collapse All Metric Groups</button>
+<input title="Time Shift Overlay - overlays previous period on all graphs" type="checkbox" id="timeshift_overlay" onclick="showTimeshiftOverlay(this.checked)"/><label for="timeshift_overlay">Timeshift Overlay</label>
+<select id="jump_to_metric_group" class="ui-corner-all" onchange="jumpToMetricGroup(this.options[this.selectedIndex].value);">
+<option disabled="disabled" selected="selected">Jump To Metric Group...</option>
+<?php 
+$_fh0_data = (isset($this->scope["g_metrics_group_data"]) ? $this->scope["g_metrics_group_data"] : null);
+if ($this->isTraversable($_fh0_data) == true)
+{
+	foreach ($_fh0_data as $this->scope['group']=>$this->scope['g_metrics'])
+	{
+/* -- foreach start output */
+?>
+<?php $this->scope["mgId"]="mg_";
+$this->scope["mgId"].=Dwoo_Plugin_regex_replace($this, (isset($this->scope["group"]) ? $this->scope["group"] : null), '/[^a-zA-Z0-9_]/', '_')?>
+
+<option value="<?php echo $this->scope["mgId"];?>"><?php echo $this->scope["group"];?></a>
+<?php 
+/* -- foreach end output */
+	}
+}?>
+
+</select>
+</div>
+<table>
+<tr>
+ <td>
+
+<?php 
+$_fh1_data = (isset($this->scope["g_metrics_group_data"]) ? $this->scope["g_metrics_group_data"] : null);
+if ($this->isTraversable($_fh1_data) == true)
+{
+	foreach ($_fh1_data as $this->scope['group']=>$this->scope['g_metrics'])
+	{
+/* -- foreach start output */
+?>
+<?php $this->scope["mgId"]="mg_";
+$this->scope["mgId"].=Dwoo_Plugin_regex_replace($this, (isset($this->scope["group"]) ? $this->scope["group"] : null), '/[^a-zA-Z0-9_]/', '_')?>
+
+<table border="0" width="100%">
+<tr>
+  <td class="metric">
+  <button id="<?php echo $this->scope["mgId"];?>" class="metric-group" title="Toggle <?php echo $this->scope["group"];?> metrics group on/off"><?php echo $this->scope["group"];?> metrics (<?php echo $this->scope["g_metrics"]["group_metric_count"];?>)</button>
+<script type="text/javascript">$(function() {
+g_mgMap["<?php echo $this->scope["mgId"];?>"] = "<?php echo $this->scope["group"];?>";
+})</script>
+  </td>
+</tr>
+</table>
+
+<?php if ((isset($this->scope["g_metrics"]["visible"]) ? $this->scope["g_metrics"]["visible"]:null)) {
+?>
+<div id="<?php echo $this->scope["mgId"];?>_div">
+<?php 
+}
+else {
+?>
+<div id="<?php echo $this->scope["mgId"];?>_div" class="ui-helper-hidden">
+<?php 
+}?>
+
+<?php if ((isset($this->scope["g_metrics"]["visible"]) ? $this->scope["g_metrics"]["visible"]:null)) {
+?>
+<?php echo Dwoo_Plugin_include($this, 'metric_group_view.tpl', null, null, null, '_root', null);?>
+
+<?php 
+}?>
+
+</div>
+<?php 
+/* -- foreach end output */
+	}
+}?>
+
+ </td>
+</tr>
+</table>
+</center>
+</div>
+<input type="hidden" name="metric_group" value="">
+<!-- End host_view.tpl -->
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/meta_view.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/meta_view.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/meta_view.tpl.d17.php	(revision 755)
@@ -0,0 +1,221 @@
+<?php
+/* template head */
+/* end template head */ ob_start(); /* template body */ ;
+if (((isset($this->scope["filters"]) ? $this->scope["filters"] : null) !== null)) {
+?>
+<table border="0" width="100%">
+  <tr>
+    <?php 
+$_fh1_data = (isset($this->scope["filters"]) ? $this->scope["filters"] : null);
+if ($this->isTraversable($_fh1_data) == true)
+{
+	foreach ($_fh1_data as $this->scope['filter'])
+	{
+/* -- foreach start output */
+?>
+      <td>
+        <b><?php echo $this->scope["filter"]["filter_name"];?></b>
+        <select name="choose_filter[<?php echo $this->scope["filter"]["filter_shortname"];?>]" OnChange="ganglia_form.submit();">
+          <option name=""></option>
+          <?php 
+$_fh0_data = (isset($this->scope["filter"]["choice"]) ? $this->scope["filter"]["choice"]:null);
+if ($this->isTraversable($_fh0_data) == true)
+{
+	foreach ($_fh0_data as $this->scope['choice'])
+	{
+/* -- foreach start output */
+?>
+          <?php if ($this->readVar("choose_filter.".(isset($this->scope["filter"]) ? $this->scope["filter"] : null).".filter_shortname") == (isset($this->scope["choice"]) ? $this->scope["choice"] : null)) {
+?>
+          <option name="<?php echo $this->scope["choice"];?>" selected><?php echo $this->scope["choice"];?></option>
+          <?php 
+}
+else {
+?>
+          <option name="<?php echo $this->scope["choice"];?>"><?php echo $this->scope["choice"];?></option>
+          <?php 
+}?>
+
+          <?php 
+/* -- foreach end output */
+	}
+}?>
+
+        </select>
+      </td>
+    <?php 
+/* -- foreach end output */
+	}
+}?>
+
+  </tr>
+</table>
+<?php 
+}?>
+
+
+<table border="0" width="100%">
+
+<tr>
+<td colspan="3">&nbsp;</td>
+</tr>
+
+<?php 
+$_fh2_data = (isset($this->scope["sources"]) ? $this->scope["sources"] : null);
+if ($this->isTraversable($_fh2_data) == true)
+{
+	foreach ($_fh2_data as $this->scope['source'])
+	{
+/* -- foreach start output */
+?>
+<tr>
+  <td class=<?php echo $this->scope["source"]["class"];?> colspan="3">
+    <a href="<?php echo $this->scope["source"]["url"];?>"><strong><?php echo $this->scope["source"]["name"];?></strong></a> <?php echo $this->scope["source"]["alt_view"];?>
+
+  </td>
+</tr>
+
+<tr>
+<?php if (((isset($this->scope["source"]["public"]) ? $this->scope["source"]["public"]:null) !== null)) {
+?>
+<td align="LEFT" valign="TOP">
+<table cellspacing="1" cellpadding="1" width="100%" border="0">
+ <tr><td>CPUs Total:</td><td align="left"><B><?php echo $this->scope["source"]["cpu_num"];?></B></td></tr>
+ <tr><td width="80%">Hosts up:</td><td align="left"><B><?php echo $this->scope["source"]["num_nodes"];?></B></td></tr>
+ <tr><td>Hosts down:</td><td align="left"><B><?php echo $this->scope["source"]["num_dead_nodes"];?></B></td></tr>
+ <tr><td>&nbsp;</td></tr>
+ <tr><td class="footer" colspan="2"><?php echo $this->scope["source"]["cluster_load"];?></td></tr>
+ <tr><td class="footer" colspan="2"><?php echo $this->scope["source"]["cluster_util"];?></td></tr>
+ <tr><td class="footer" colspan="2"><?php echo $this->scope["source"]["localtime"];?></td></tr>
+</table>
+</td>
+
+<?php if (((isset($this->scope["source"]["self_summary_graphs"]) ? $this->scope["source"]["self_summary_graphs"]:null) !== null)) {
+?>
+<td>
+ <table align="center" border="0">
+  <tr>
+
+   <td>
+    <a href="./graph_all_periods.php?<?php echo $this->scope["source"]["graph_url"];?>&amp;g=load_report&amp;z=large">
+      <img src="./graph.php?<?php echo $this->scope["source"]["graph_url"];?>&amp;g=load_report&amp;z=medium"
+           alt="<?php echo $this->scope["source"]["name"];?> LOAD" border="0" />
+    </a>
+   </td>
+   <td>
+    <a href="./graph_all_periods.php?<?php echo $this->scope["source"]["graph_url"];?>&amp;g=mem_report&amp;z=large">
+      <img src="./graph.php?<?php echo $this->scope["source"]["graph_url"];?>&amp;g=mem_report&amp;z=medium"
+           alt="<?php echo $this->scope["source"]["name"];?> MEM" border="0" />
+    </a>
+   </td>
+  </tr>
+
+  <tr>
+   <td>
+    <a href="./graph_all_periods.php?<?php echo $this->scope["source"]["graph_url"];?>&amp;g=cpu_report&amp;z=large">
+      <img src="./graph.php?<?php echo $this->scope["source"]["graph_url"];?>&amp;g=cpu_report&amp;z=medium"
+           alt="<?php echo $this->scope["source"]["name"];?> CPU" border="0" />
+    </a>
+   </td>
+   <td>
+    <a href="./graph_all_periods.php?<?php echo $this->scope["source"]["graph_url"];?>&amp;g=network_report&amp;z=large">
+      <img src="./graph.php?<?php echo $this->scope["source"]["graph_url"];?>&amp;g=network_report&amp;z=medium"
+           alt="<?php echo $this->scope["source"]["name"];?> NETWORK" border="0" />
+    </a>
+   </td>
+
+  </tr>
+ </table>
+</td>
+<?php 
+}?>
+
+
+<?php if (((isset($this->scope["source"]["summary_graphs"]) ? $this->scope["source"]["summary_graphs"]:null) !== null)) {
+?>
+<td>
+ <table align="center" border="0">
+  <tr>
+
+      <td>
+      <a href="<?php echo $this->scope["source"]["url"];?>">
+        <img src="./graph.php?<?php echo $this->scope["source"]["graph_url"];?>&amp;g=load_report&amp;z=medium&amp;r=<?php echo $this->scope["source"]["range"];?>"
+             alt="<?php echo $this->scope["source"]["name"];?> LOAD" border="0" />
+      </a>
+      </td>
+
+      <td>
+      <a href="<?php echo $this->scope["source"]["url"];?>">
+        <img src="./graph.php?<?php echo $this->scope["source"]["graph_url"];?>&amp;g=network_report&amp;z=medium&amp;r=<?php echo $this->scope["source"]["range"];?>"
+             alt="<?php echo $this->scope["source"]["name"];?> MEM" border="0" />
+      </a>
+      </td>
+
+  </tr>
+ </td>
+</table>
+<?php 
+}?>
+
+<?php 
+}?>
+
+
+
+<?php if (((isset($this->scope["source"]["private"]) ? $this->scope["source"]["private"]:null) !== null)) {
+?>
+  <td align="LEFT" valign="TOP">
+<table cellspacing="1" cellpadding="1" width="100%" border="0">
+ <tr><td>CPUs Total:</td><td align="left"><B><?php echo $this->scope["source"]["cpu_num"];?></B></td></tr>
+ <tr><td width="80%">Nodes:</td><td align="left"><B><?php echo $this->scope["source"]["num_nodes"];?></B></td></tr>
+ <tr><td>&nbsp;</td></tr>
+ <tr><td class="footer" colspan="2"><?php echo $this->scope["source"]["localtime"];?></td></tr>
+</table>
+   </td>
+   <td colspan="2" align=center>This is a private cluster.</td>
+<?php 
+}?>
+
+</tr>
+<?php 
+/* -- foreach end output */
+	}
+}?>
+
+</table>
+
+<?php if (((isset($this->scope["show_snapshot"]) ? $this->scope["show_snapshot"] : null) !== null)) {
+?>
+<table border="0" width="100%">
+<tr>
+  <td colspan="2" class="title">Snapshot of the <?php echo $this->scope["self"];?> |
+    <font size="-1"><a href="./cluster_legend.html">Legend</a></font>
+  </td>
+</tr>
+</table>
+
+<center>
+<table cellspacing="12" cellpadding="2">
+<?php 
+$_fh3_data = (isset($this->scope["snap_rows"]) ? $this->scope["snap_rows"] : null);
+if ($this->isTraversable($_fh3_data) == true)
+{
+	foreach ($_fh3_data as $this->scope['snap_row'])
+	{
+/* -- foreach start output */
+?>
+<tr><?php echo $this->scope["snap_row"]["names"];?></tr>
+<tr><?php echo $this->scope["snap_row"]["images"];?></tr>
+<?php 
+/* -- foreach end output */
+	}
+}?>
+
+</table>
+</center>
+<?php 
+}?>
+
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/metric_group_view.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/metric_group_view.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/metric_group_view.tpl.d17.php	(revision 755)
@@ -0,0 +1,71 @@
+<?php
+/* template head */
+/* end template head */ ob_start(); /* template body */ ?><table><tr>
+<?php $this->scope["i"]=0?>
+
+<?php 
+$_fh0_data = (isset($this->scope["g_metrics"]["metrics"]) ? $this->scope["g_metrics"]["metrics"]:null);
+if ($this->isTraversable($_fh0_data) == true)
+{
+	foreach ($_fh0_data as $this->scope['g_metric'])
+	{
+/* -- foreach start output */
+?>
+<td>
+<font style="font-size: 8px"><?php echo $this->scope["g_metric"]["metric_name"];?> <?php if ((isset($this->scope["g_metric"]["title"]) ? $this->scope["g_metric"]["title"]:null) != '' && (isset($this->scope["g_metric"]["title"]) ? $this->scope["g_metric"]["title"]:null) != (isset($this->scope["g_metric"]["metric_name"]) ? $this->scope["g_metric"]["metric_name"]:null)) {
+?>- <?php echo $this->scope["g_metric"]["title"];
+
+}?></font><br>
+<?php if ((isset($this->scope["may_edit_views"]) ? $this->scope["may_edit_views"] : null)) {
+?>
+<?php $this->scope["graph_args"]="&amp;";
+$this->scope["graph_args"].=(isset($this->scope["g_metric"]["graphargs"]) ? $this->scope["g_metric"]["graphargs"]:null)?>
+
+<button class="cupid-green" title="Metric Actions - Add to View, etc" onclick="metricActions('<?php echo $this->scope["g_metric"]["host_name"];?>','<?php echo $this->scope["g_metric"]["metric_name"];?>', 'metric', '<?php echo $this->scope["graph_args"];?>'); return false;">+</button>
+<?php 
+}?>
+
+<button title="Export to CSV" class="cupid-green" onClick="javascript:location.href='./graph.php?<?php echo $this->scope["g_metric"]["graphargs"];?>&amp;csv=1';return false;">CSV</button>
+<button title="Export to JSON" class="cupid-green" onClick="javascript:location.href='./graph.php?<?php echo $this->scope["g_metric"]["graphargs"];?>&amp;json=1';return false;">JSON</button>
+<button title="Inspect Graph" onClick="inspectGraph('<?php echo $this->scope["g_metric"]["graphargs"];?>'); return false;" class="shiny-blue">Inspect</button>
+<button title="6 month trend" onClick="drawTrendGraph('./graph.php?<?php echo $this->scope["g_metric"]["graphargs"];?>&amp;trend=1&amp;z=xlarge'); return false;" class="shiny-blue">Trend</button>
+
+<?php if ((isset($this->scope["graph_engine"]) ? $this->scope["graph_engine"] : null) == "flot") {
+?>
+<br>
+<div id="placeholder_<?php echo $this->scope["g_metric"]["graphargs"];?>" class="flotgraph2 img_view"></div>
+<div id="placeholder_<?php echo $this->scope["g_metric"]["graphargs"];?>_legend" class="flotlegend"></div>
+<?php 
+}
+else {
+?>
+<?php $this->scope["graphId"]=((isset($this->scope["GRAPH_BASE_ID"]) ? $this->scope["GRAPH_BASE_ID"] : null)).((isset($this->scope["mgId"]) ? $this->scope["mgId"] : null)).((isset($this->scope["i"]) ? $this->scope["i"] : null))?>
+
+<?php $this->scope["showEventsId"]=((isset($this->scope["SHOW_EVENTS_BASE_ID"]) ? $this->scope["SHOW_EVENTS_BASE_ID"] : null)).((isset($this->scope["mgId"]) ? $this->scope["mgId"] : null)).((isset($this->scope["i"]) ? $this->scope["i"] : null))?>
+
+<input title="Hide/Show Events" type="checkbox" id="<?php echo $this->scope["showEventsId"];?>" onclick="showEvents('<?php echo $this->scope["graphId"];?>', this.checked)"/><label class="show_event_text" for="<?php echo $this->scope["showEventsId"];?>">Hide/Show Events</label>
+<?php $this->scope["timeShiftId"]=((isset($this->scope["TIME_SHIFT_BASE_ID"]) ? $this->scope["TIME_SHIFT_BASE_ID"] : null)).((isset($this->scope["mgId"]) ? $this->scope["mgId"] : null)).((isset($this->scope["i"]) ? $this->scope["i"] : null))?>
+
+<input title="Timeshift Overlay" type="checkbox" id="<?php echo $this->scope["timeShiftId"];?>" onclick="showTimeShift('<?php echo $this->scope["graphId"];?>', this.checked)"/><label class="show_timeshift_text" for="<?php echo $this->scope["timeShiftId"];?>">Timeshift</label>
+<br>
+<a href="./graph_all_periods.php?<?php echo $this->scope["g_metric"]["graphargs"];?>&amp;z=large">
+<img id="<?php echo $this->scope["graphId"];?>" class="noborder <?php echo $this->scope["additional_host_img_css_classes"];?>" style="margin:5px;" alt="<?php echo $this->scope["g_metric"]["alt"];?>" src="./graph.php?<?php echo $this->scope["g_metric"]["graphargs"];?>" title="<?php echo $this->scope["g_metric"]["desc"];?>" />
+</A>
+<?php 
+}?>
+
+</td>
+<?php echo $this->scope["g_metric"]["new_row"];?>
+
+<?php echo ($this->assignInScope((isset($this->scope["i"]) ? $this->scope["i"] : null) + 1, 'i'));?>
+
+<?php 
+/* -- foreach end output */
+	}
+}?>
+
+</tr>
+</table>
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/node_extra.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/node_extra.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/node_extra.tpl.d17.php	(revision 755)
@@ -0,0 +1,6 @@
+<?php
+/* template head */
+/* end template head */ ob_start(); /* template body */ ?><!-- Extra content underneath the simple node view. -->
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/physical_view.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/physical_view.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/physical_view.tpl.d17.php	(revision 755)
@@ -0,0 +1,111 @@
+<?php
+/* template head */
+/* end template head */ ob_start(); /* template body */ ?><table cellpadding="1" border="0" width="100%">
+<tr>
+<td colspan=3 class="title"><?php echo $this->scope["cluster"];?> cluster - Physical View |
+ <font size="-1">Columns&nbsp;&nbsp;<?php echo $this->scope["cols_menu"];?></font>
+</td>
+
+<tr>
+<td align="center" valign="top">
+   Verbosity level (Lower is more compact):<br />
+   <?php 
+$_fh0_data = (isset($this->scope["verbosity_levels"]) ? $this->scope["verbosity_levels"] : null);
+if ($this->isTraversable($_fh0_data) == true)
+{
+	foreach ($_fh0_data as $this->scope['verbosity']=>$this->scope['checked'])
+	{
+/* -- foreach start output */
+?>
+   <?php echo $this->scope["verbosity"];?> <input type="radio" name="p" value="<?php echo $this->scope["verbosity"];?>" OnClick="ganglia_form.submit();" <?php echo $this->scope["checked"];?> />&nbsp;
+   <?php 
+/* -- foreach end output */
+	}
+}?>
+
+</td>
+
+<td align="left" valign="top" width="25%">
+Total CPUs: <b><?php echo $this->scope["CPUs"];?></b><br />
+Total Memory: <b><?php echo $this->scope["Memory"];?></b><br />
+</td>
+
+<td align="left" valign="top" width="25%">
+Total Disk: <b><?php echo $this->scope["Disk"];?></b><br />
+Most Full Disk: <b><?php echo $this->scope["most_full"];?></b><br />
+</td>
+
+</tr>
+<tr>
+<td align="left" colspan="3">
+
+<table cellspacing="20">
+<tr>
+<?php 
+$_fh1_data = (isset($this->scope["racks"]) ? $this->scope["racks"] : null);
+if ($this->isTraversable($_fh1_data) == true)
+{
+	foreach ($_fh1_data as $this->scope['rack'])
+	{
+/* -- foreach start output */
+?>
+   <td valign="top" align="center">
+      <table cellspacing="5" border="0">
+         <?php echo $this->scope["rack"]["RackID"];?>
+
+         <?php echo $this->scope["rack"]["nodes"];?>
+
+      </table>
+   </td>
+   <?php echo $this->scope["rack"]["tr"];?>
+
+<?php 
+/* -- foreach end output */
+	}
+}?>
+
+</tr></table>
+
+</td></tr>
+</table>
+
+<hr />
+
+
+<table border="0">
+<tr>
+ <td align="left">
+<font size="-1">
+Legend
+</font>
+ </td>
+</tr>
+<tr>
+<td class="odd">
+<table width="100%" cellpadding="1" cellspacing="0" border="0">
+<tr>
+ <td style="color: blue">Node Name&nbsp;<br /></td>
+ <td align="right" valign="top">
+  <table cellspacing=1 cellpadding=3 border="0">
+  <tr>
+  <td class="L1" align="right">
+  <font size="-1">1-min load</font>
+  </td>
+  </tr>
+ </table>
+<tr>
+<td colspan="2" style="color: rgb(70,70,70)">
+<font size="-1">
+<em>cpu: </em> CPU clock (GHz) (num CPUs)<br />
+<em>mem: </em> Total Memory (GB)
+</font>
+</td>
+</tr>
+</table>
+
+</td>
+</tr>
+</table>
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/show_node.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/show_node.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/show_node.tpl.d17.php	(revision 755)
@@ -0,0 +1,87 @@
+<?php
+/* template head */
+if (function_exists('Dwoo_Plugin_include')===false)
+	$this->getLoader()->loadPlugin('include');
+/* end template head */ ob_start(); /* template body */ ?><!-- Begin show_node.tpl -->
+<table border="0" width="100%">
+<tr>
+  <td colspan="2" class=title><?php echo $this->scope["name"];?> Info</td>
+</tr>
+<tr><td colspan="1">&nbsp;</td></tr>
+<tr>
+<td align="center">
+
+<table cellpadding="2" cellspacing="7" border="1">
+<tr>
+<td class="<?php echo $this->scope["class"];?>">
+   <table cellpadding="1" cellspacing="10" border="0">
+   <tr><td valign="top"><font size="+2"><b><?php echo $this->scope["name"];?></b></font><br />
+   <i><?php echo $this->scope["ip"];?></i><br />
+   <em>Location:</em> <?php echo $this->scope["location"];?><p>
+
+   Cluster local time <?php echo $this->scope["clustertime"];?><br />
+   Last heartbeat received <?php echo $this->scope["age"];?> ago.<br />
+   Uptime <?php echo $this->scope["uptime"];?><br />
+
+   </td>
+   <td align="right" valign="top">
+   <table cellspacing="4" cellpadding="3" border="0"><tr>
+   <tr><td><i>Load:</i></td>
+   <td class=<?php echo $this->scope["load1"];?>><small><?php echo $this->scope["load_one"];?></small></td>
+   <td class=<?php echo $this->scope["load5"];?>><small><?php echo $this->scope["load_five"];?></small></td>
+   <td class=<?php echo $this->scope["load15"];?>><small><?php echo $this->scope["load_fifteen"];?></small></td>
+   </tr><tr><td></td><td><em>1m</em></td><td><em>5m</em></td><td><em>15m</em></td></tr>
+   </table><br />
+
+   <table cellspacing="4" cellpadding="3" border="0"><tr>
+   <td><i>CPU Utilization:</i></td>
+   <td class=<?php echo $this->scope["user"];?>><small><?php echo $this->scope["cpu_user"];?></small></td>
+   <td class=<?php echo $this->scope["sys"];?>><small><?php echo $this->scope["cpu_system"];?></small></td>
+   <td class=<?php echo $this->scope["idle"];?>><small><?php echo $this->scope["cpu_idle"];?></small></td>
+   </tr><tr><td></td><td><em>user</em></td><td><em>sys</em></td><td><em>idle</em></td></tr>
+   </table>
+   </td>
+   </tr>
+   <tr><td align="left" valign="top">
+
+   <b>Hardware</b><br />
+   <em>CPU<?php echo $this->scope["s"];?>:</em> <?php echo $this->scope["cpu"];?><br />
+   <em>Memory (RAM):</em> <?php echo $this->scope["mem"];?><br />
+   <em>Local Disk:</em> <?php echo $this->scope["disk"];?><br />
+   <em>Most Full Disk Partition:</em> <?php echo $this->scope["part_max_used"];?>
+
+   </td>
+   <td align="left" valign="top">
+
+   <b>Software</b><br />
+   <em>OS:</em> <?php echo $this->scope["OS"];?><br />
+   <em>Booted:</em> <?php echo $this->scope["booted"];?><br />
+   <em>Uptime:</em> <?php echo $this->scope["uptime"];?><br />
+   <em>Swap:</em> <?php echo $this->scope["swap"];?><br />
+
+   </td></tr></table>
+</td>
+</tr></table>
+
+ </td>
+</tr>
+<tr>
+<td align="center" valign="middle">
+ <a href="<?php echo $this->scope["physical_view"];?>">Physical View</a> | <a href="<?php echo $this->scope["self"];?>">Reload</a>
+</td>
+</tr>
+<tr>
+ <td>
+<?php if (((isset($this->scope["extra"]) ? $this->scope["extra"] : null) !== null)) {
+?>
+<?php echo Dwoo_Plugin_include($this, "".(isset($this->scope["extra"]) ? $this->scope["extra"] : null)."", null, null, null, '_root', null);?>
+
+<?php 
+}?> 
+</td>
+</tr>
+</table>
+<!-- End show_node.tpl -->
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/templates/footer.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/templates/footer.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/templates/footer.tpl.d17.php	(revision 755)
@@ -0,0 +1,6 @@
+<?php
+/* template head */
+/* end template head */ ob_start(); /* template body */ ;
+ /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/views_view.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/views_view.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/default/views_view.tpl.d17.php	(revision 755)
@@ -0,0 +1,142 @@
+<?php
+/* template head */
+/* end template head */ ob_start(); /* template body */ ?><style type="text/css">
+.img_view {
+  float: left;
+  margin: 0 0 10px 10px;
+}
+</style>
+
+<script type="text/javascript">
+  function refreshView() {
+    $("#view_graphs img").each(function (index) {
+	var src = $(this).attr("src");
+	if (src.indexOf("graph.php") == 0) {
+	  var d = new Date();
+	  $(this).attr("src", jQuery.param.querystring(src, "&_=" + d.getTime()));
+	}    
+    });
+  }
+
+  $(function() {
+    $( "#popup-dialog" ).dialog({ autoOpen: false, width:850 });
+    $("#create_view_button")
+      .button()
+      .click(function() {
+	$( "#create-new-view-dialog" ).dialog( "open" );
+    });
+    $("#delete_view_button")
+      .button()
+      .click(function() {
+        if ($("#vn").val() != "") {
+	  if (confirm("Are you sure you want to delete the view: " + $("#vn").val() + " ?")) {
+	    $.get('views_view.php?view_name=' + 
+                  encodeURIComponent($("#vn").val()) +
+                  '&delete_view&views_menu',
+                  function(data) {
+                    $("#views_menu").html(data);
+                    $("#view_graphs").html("");  
+                    $.cookie('ganglia-selected-view-' + window.name, "");
+		    $("#vn").val("");
+                  });
+          }
+        } else
+	  alert("Please select the view to delete");
+    });
+  });
+</script>
+
+<div id="popup-dialog" title="Inspect Graph">
+  <div id="popup-dialog-content">
+  </div>
+</div>
+
+<table id="views_table">
+<tr><td valign="top">
+<div id="views_menu">
+    <?php echo $this->scope["existing_views"];?>
+
+</div>
+<script type="text/javascript">$(function() { $("#views_menu").buttonsetv(); });</script>
+</td>
+<td valign="top">
+<div>
+<div id="views-content">
+  <div id=view_graphs>
+    <?php if (((isset($this->scope["number_of_view_items"]) ? $this->scope["number_of_view_items"] : null) !== null)) {
+?>
+    <?php if ((isset($this->scope["number_of_view_items"]) ? $this->scope["number_of_view_items"] : null) == 0) {
+?>
+    <div class="ui-widget">
+      <div class="ui-state-default ui-corner-all" style="padding: 0 .7em;"> 
+        <p><span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span>
+          No graphs defined for this view. Please add some
+      </div>
+    </div>
+    <?php 
+}
+else {
+?>
+      <?php $this->scope["i"]=0?>
+
+      <?php 
+$_fh0_data = (isset($this->scope["view_items"]) ? $this->scope["view_items"] : null);
+if ($this->isTraversable($_fh0_data) == true)
+{
+	foreach ($_fh0_data as $this->scope['view_item'])
+	{
+/* -- foreach start output */
+?>
+      <?php $this->scope["graphId"]=((isset($this->scope["GRAPH_BASE_ID"]) ? $this->scope["GRAPH_BASE_ID"] : null)).("view_").((isset($this->scope["i"]) ? $this->scope["i"] : null))?>
+
+      <?php $this->scope["showEventsId"]=((isset($this->scope["SHOW_EVENTS_BASE_ID"]) ? $this->scope["SHOW_EVENTS_BASE_ID"] : null)).("view_").((isset($this->scope["i"]) ? $this->scope["i"] : null))?>
+
+      <div class="img_view">
+        <button title="Export to CSV" class="cupid-green" onClick="javascript:location.href='graph.php?<?php echo $this->scope["view_item"]["url_args"];?>&amp;csv=1';return false;">CSV</button>
+        <button title="Export to JSON" class="cupid-green" onClick="javascript:location.href='graph.php?<?php echo $this->scope["view_item"]["url_args"];?>&amp;json=1';return false;">JSON</button>
+        <?php if ((isset($this->scope["view_item"]["aggregate_graph"]) ? $this->scope["view_item"]["aggregate_graph"]:null) == 1) {
+?>
+        <button title="Decompose aggregate graph" class="shiny-blue" onClick="javascript:location.href='?<?php echo $this->scope["view_item"]["url_args"];?>&amp;dg=1&amp;tab=v';return false;">Decompose</button>
+        <?php 
+}?>
+
+        <button title="Inspect Graph" onClick="inspectGraph('<?php echo $this->scope["view_item"]["url_args"];?>'); return false;" class="shiny-blue">Inspect</button>
+        <input type="checkbox" id="<?php echo $this->scope["showEventsId"];?>" onclick="showEvents('<?php echo $this->scope["graphId"];?>', this.checked)"/><label title="Hide/Show Events" class="show_event_text" for="<?php echo $this->scope["showEventsId"];?>">Hide/Show Events</label>
+        <br />
+<?php if ((isset($this->scope["graph_engine"]) ? $this->scope["graph_engine"] : null) == "flot") {
+?>
+<div id="placeholder_<?php echo $this->scope["view_item"]["url_args"];?>" class="flotgraph2 img_view"></div>
+<div id="placeholder_<?php echo $this->scope["view_item"]["url_args"];?>_legend" class="flotlegend"></div>
+<?php 
+}
+else {
+?>
+<a href="graph_all_periods.php?<?php echo $this->scope["view_item"]["url_args"];?>"><img id="<?php echo $this->scope["graphId"];?>" class="noborder <?php echo $this->scope["additional_host_img_css_classes"];?>" style="margin-top:5px;" src="graph.php?<?php echo $this->scope["view_item"]["url_args"];?>" /></a>
+<?php 
+}?>
+
+      </div>
+      <?php echo ($this->assignInScope((isset($this->scope["i"]) ? $this->scope["i"] : null) + 1, 'i'));?>
+
+      <?php 
+/* -- foreach end output */
+	}
+}?>
+
+    <?php 
+}?>
+
+    <?php 
+}?>
+
+  </div>
+</div>
+<div style="clear: left"></div>
+</div>
+</td>
+</tr>
+</table>
+
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/footer.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/footer.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/footer.tpl.d17.php	(revision 755)
@@ -0,0 +1,22 @@
+<?php
+/* template head */
+/* end template head */ ob_start(); /* template body */ ?><HR>
+<CENTER>
+<FONT SIZE="-1" class=footer>
+<A HREF="https://oss.trac.surfsara.nl/jobmonarch/">Job Monarch</A> version <?php echo $this->scope["monarchversion"];?>
+
+<A HREF="https://oss.trac.surfsara.nl/jobmonarch/">Check for Updates.</A><BR>
+
+Ganglia web version <?php echo $this->scope["webfrontendversion"];?><BR>
+
+Downloading and parsing ganglia's XML tree took <?php echo $this->scope["parsetime"];?>.<BR>
+Images created with <A HREF="http://www.rrdtool.org/">RRDTool</A>.<BR>
+</FONT>
+</CENTER>
+
+</FORM>
+</BODY>
+</HTML>
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/header.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/header.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/header.tpl.d17.php	(revision 755)
@@ -0,0 +1,113 @@
+<?php
+/* template head */
+/* end template head */ ob_start(); /* template body */ ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<HTML>
+<HEAD>
+<TITLE>Ganglia :: <?php echo $this->scope["longpage_title"];?></TITLE>
+<META http-equiv="Content-type" content="text/html; charset=utf-8">
+<META http-equiv="refresh" content="<?php echo $this->scope["refresh"];
+echo $this->scope["redirect"];?>" >
+<LINK rel="stylesheet" href="./styles.css" type="text/css">
+<SCRIPT LANGUAGE="javascript" SRC="ts_picker.js"></SCRIPT>
+<SCRIPT LANGUAGE="javascript">
+
+        function setPeriodTimestamps() {
+
+                document.<?php echo $this->scope["form_name"];?>.period_start.value = document.<?php echo $this->scope["form_name"];?>.period_start_pick.value;
+                document.<?php echo $this->scope["form_name"];?>.period_stop.value = document.<?php echo $this->scope["form_name"];?>.period_stop_pick.value;
+        }
+
+</SCRIPT>
+</HEAD>
+<BODY BGCOLOR="#FFFFFF">
+
+<FORM ACTION="./" METHOD="GET" NAME="<?php echo $this->scope["form_name"];?>">
+<INPUT TYPE="HIDDEN" NAME="c" VALUE="<?php echo $this->scope["cluster"];?>">
+<INPUT TYPE="HIDDEN" NAME="view" VALUE="<?php echo $this->scope["view"];?>">
+<TABLE WIDTH="100%">
+<TR>
+  <TD ROWSPAN="2" WIDTH="150">
+  <A HREF="https://subtrac.sara.nl/oss/jobmonarch/">
+  <IMG SRC="./jobmonarch.gif" 
+      ALT="Ganglia" BORDER="0"></A>
+  </TD>
+  <TD VALIGN="TOP">
+
+  <TABLE WIDTH="100%" CELLPADDING="8" CELLSPACING="0" BORDER=0>
+  <TR BGCOLOR="#DDDDDD">
+     <TD BGCOLOR="#DDDDDD">
+     <FONT SIZE="+1">
+     <B><?php echo $this->scope["page_title"];?> for <?php echo $this->scope["date"];?></B>
+     </FONT>
+     </TD>
+     <TD BGCOLOR="#DDDDDD" ALIGN="RIGHT">
+     <INPUT TYPE="SUBMIT" VALUE="Get Fresh Data">
+     </TD>
+     <TD></TD>
+  </TR>
+  <TR>
+     <TD COLSPAN=1>
+     <?php echo $this->scope["metric_menu"];?> &nbsp;&nbsp;
+     <?php echo $this->scope["range_menu"];?>&nbsp;&nbsp;
+     <?php echo $this->scope["sort_menu"];?>&nbsp;&nbsp;
+<?php if ("".(isset($this->scope["timeperiod"]) ? $this->scope["timeperiod"] : null)."" == "yes") {
+?>
+    <INPUT TYPE="HIDDEN" NAME="period_start" VALUE="<?php echo $this->scope["period_start"];?>">
+    <INPUT TYPE="HIDDEN" NAME="period_stop" VALUE="<?php echo $this->scope["period_stop"];?>">
+    <INPUT TYPE="HIDDEN" NAME="h" VALUE="<?php echo $this->scope["hostname"];?>">
+    <BR><BR><B>Graph/ from
+    <INPUT TYPE="text" NAME="period_start_pick" VALUE="<?php echo $this->scope["period_start"];?>" ALT="Start time" DISABLED="TRUE">
+    <a href="javascript:show_calendar('document.<?php echo $this->scope["form_name"];?>.period_start_pick', document.<?php echo $this->scope["form_name"];?>.period_start_pick.value);" alt="Click to select a date/time" title="Click to select a date/time">
+    <img src="cal.gif" width="16" height="16" border="0"></a>
+    <a href="#" onClick="javascript: document.<?php echo $this->scope["form_name"];?>.period_start_pick.value=''" alt="Click here to clear field" title="Click here to clear field">
+    <IMG SRC="redcross.jpg" BORDER=0></A>
+    to <INPUT TYPE="text" NAME="period_stop_pick" VALUE="<?php echo $this->scope["period_stop"];?>" ALT="Stop time" DISABLED="TRUE">
+    <a href="javascript:show_calendar('document.<?php echo $this->scope["form_name"];?>.period_stop_pick', document.<?php echo $this->scope["form_name"];?>.period_stop_pick.value);" alt="Click to select a date/time" title="Click to select a date/time">
+    <img src="cal.gif" width="16" height="16" border="0"></a>
+    <a href="#" onClick="javascript: document.<?php echo $this->scope["form_name"];?>.period_stop_pick.value=''" alt="Click here to clear field" title="Click here to clear field">
+    </B>
+    <IMG SRC="redcross.jpg" BORDER=0></A>
+
+<?php if ("".(isset($this->scope["hostview"]) ? $this->scope["hostview"] : null)."" == "yes") {
+?>
+    <INPUT TYPE="HIDDEN" NAME="job_start" VALUE="<?php echo $this->scope["job_start"];?>">
+    <INPUT TYPE="HIDDEN" NAME="job_stop" VALUE="<?php echo $this->scope["job_stop"];?>">
+<?php 
+}?>
+
+    <INPUT TYPE="submit" onClick="setPeriodTimestamps();" VALUE="Refresh graphs">
+<?php 
+}?>
+
+     </TD>
+     <TD>
+      <B><?php echo $this->scope["alt_view"];?></B>
+     </TD>
+
+  </TR>
+  </TABLE>
+
+<?php if ("".(isset($this->scope["search"]) ? $this->scope["search"] : null)."" == "yes") {
+?>
+     <TD align="right"><CENTER>
+       <A HREF="./?c=<?php echo $this->scope["cluster_url"];?>&view=search">
+       <B><I>Jobarchive</I></B><BR>
+       <IMG SRC="./document_archive.jpg" HEIGHT=100 ALT="Search the archive for <?php echo $this->scope["cluster"];?>" TITLE="Search the archive for <?php echo $this->scope["cluster"];?>" BORDER=0></A></CENTER>
+     </TD>
+<?php 
+}?>
+
+
+  </TD>
+</TR>
+</TABLE> 
+
+<FONT SIZE="+1">
+<?php echo $this->scope["node_menu"];?>
+
+</FONT>
+
+<HR SIZE="1" NOSHADE>
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/job_monarch/cluster_extra.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/job_monarch/cluster_extra.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/job_monarch/cluster_extra.tpl.d17.php	(revision 755)
@@ -0,0 +1,9 @@
+<?php
+/* template head */
+/* end template head */ ob_start(); /* template body */ ?><HR>
+<A HREF="./addons/job_monarch/?c=<?php echo $this->scope["cluster"];?>">
+<IMG SRC="./addons/job_monarch/image.php?c=<?php echo $this->scope["cluster"];?>&j_view=small-clusterimage" BORDER=0>
+</A>
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/job_monarch/cluster_host_metric_graphs.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/job_monarch/cluster_host_metric_graphs.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/job_monarch/cluster_host_metric_graphs.tpl.d17.php	(revision 755)
@@ -0,0 +1,57 @@
+<?php
+/* template head */
+/* end template head */ ob_start(); /* template body */ ?><center>
+<table id=graph_sorted_list>
+<tr>
+<?php 
+$_fh0_data = (isset($this->scope["sorted_list"]) ? $this->scope["sorted_list"] : null);
+if ($this->isTraversable($_fh0_data) == true)
+{
+	foreach ($_fh0_data as $this->scope['host'])
+	{
+/* -- foreach start output */
+?>
+<?php echo $this->scope["host"]["metric_image"];
+echo $this->scope["host"]["br"];?>
+
+<?php 
+/* -- foreach end output */
+	}
+}?>
+
+</tr>
+</table>
+
+<?php echo $this->scope["overflow_list_header"];?>
+
+<?php 
+$_fh1_data = (isset($this->scope["overflow_list"]) ? $this->scope["overflow_list"] : null);
+if ($this->isTraversable($_fh1_data) == true)
+{
+	foreach ($_fh1_data as $this->scope['host'])
+	{
+/* -- foreach start output */
+?>
+<?php echo $this->scope["host"]["metric_image"];
+echo $this->scope["host"]["br"];?>
+
+<?php 
+/* -- foreach end output */
+	}
+}?>
+
+<?php echo $this->scope["overflow_list_footer"];?>
+
+
+<?php if (((isset($this->scope["node_legend"]) ? $this->scope["node_legend"] : null) !== null)) {
+?>
+<p>
+(Nodes colored by 1-minute load) | <a href="./node_legend.html">Legend</A>
+</p>
+<?php 
+}?>
+
+</center>
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/job_monarch/cluster_overview.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/job_monarch/cluster_overview.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/job_monarch/cluster_overview.tpl.d17.php	(revision 755)
@@ -0,0 +1,13 @@
+<?php
+/* template head */
+/* end template head */ ob_start(); /* template body */ ?><table cellspacing=1 cellpadding=1 width="100%" border=0>
+ <tr><td>CPUs Total:</td><td align=left><B><?php echo $this->scope["cpu_num"];?></B></td></tr>
+ <tr><td width="60%">Hosts up:</td><td align=left><B><?php echo $this->scope["num_nodes"];?></B></td></tr>
+ <tr><td>Hosts down:</td><td align=left><B><?php echo $this->scope["num_dead_nodes"];?></B></td></tr>
+ <tr><td>&nbsp;</td></tr>
+ <tr><td colspan=2><font class="nobr">Current Load Avg (15, 5, 1m):</font><br>&nbsp;&nbsp;<b><?php echo $this->scope["cluster_load"];?></b></td></tr>
+ <tr><td colspan=2>Avg Utilization (last <?php echo $this->scope["range"];?>):<br>&nbsp;&nbsp;<b><?php echo $this->scope["cluster_util"];?></b></td></tr>
+ </table>
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/job_monarch/cluster_view.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/job_monarch/cluster_view.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/job_monarch/cluster_view.tpl.d17.php	(revision 755)
@@ -0,0 +1,321 @@
+<?php
+/* template head */
+if (function_exists('Dwoo_Plugin_include')===false)
+	$this->getLoader()->loadPlugin('include');
+/* end template head */ ob_start(); /* template body */ ?><!-- Begin cluster_view.tpl -->
+<?php if ((isset($this->scope["heatmap"]) ? $this->scope["heatmap"] : null)) {
+?>
+<script type="text/javascript" src="js/protovis-r3.2.js"></script>
+<?php 
+}?>
+
+<script type="text/javascript">
+function refreshClusterView() {
+  $.get('cluster_view.php?' + jQuery.param.querystring() + '&refresh', function(data) {
+    var item = data.split("<!-- || -->");
+
+    $('#cluster_title').html(item[1]);
+
+    $('#cluster_overview').html(item[2]);
+
+    if ($('#load_pie').size())
+      $('#load_pie').attr("src", item[3].replace(/&amp;/g, "&"));
+
+    if ($('#heatmap-fig').size()) {
+      eval("heatmap = [" + item[4] + "]")	;
+      vis.render();
+    }
+
+    if ($('#stacked_graph').size()) {
+      var localtimestamp = parseInt(item[0]);
+      var src = $('#stacked_graph').attr('src');
+      $('#stacked_graph').attr("src", jQuery.param.querystring(src, "&st=" + localtimestamp));
+    }
+
+    var host_metric_graphs = $('#host_metric_graphs');
+    host_metric_graphs.css('height', host_metric_graphs.height() + "px");
+    host_metric_graphs.html(item[5]);
+  });
+
+  $("#optional_graphs img").each(function (index) {
+    var src = $(this).attr("src");
+    if ((src.indexOf("graph.php") == 0) ||
+        (src.indexOf("./graph.php") == 0)) {
+      var d = new Date();
+      $(this).attr("src", jQuery.param.querystring(src, "&_=" + d.getTime()));
+    }    
+  });
+}
+
+$(function() {
+  // Modified from http://jqueryui.com/demos/toggle/
+  //run the currently selected effect
+  function runEffect(id){
+    //most effect types need no options passed by default
+    var options = { };
+
+    options = { to: { width: 200,height: 60 } }; 
+    
+    //run the effect
+    $("#"+id+"_div").toggle("blind",options,500);
+  };
+ 
+  //set effect from select menu value
+  $('.button').click(function(event) {
+    runEffect(event.target.id);
+    return false;
+  });
+
+    $(function() {
+        $( "#edit_optional_graphs" ).dialog({ autoOpen: false, minWidth: 550,
+          beforeClose: function(event, ui) {  location.reload(true); } })
+        $( "#edit_optional_graphs_button" ).button();
+        $( "#save_optional_graphs_button" ).button();
+        $( "#close_edit_optional_graphs_link" ).button();
+    });
+
+    $("#edit_optional_graphs_button").click(function(event) {
+      $("#edit_optional_graphs").dialog('open');
+      $('#edit_optional_graphs_content').html('<img src="img/spinner.gif">');
+      $.get('edit_optional_graphs.php', "clustername=<?php echo $this->scope["cluster"];?>", function(data) {
+          $('#edit_optional_graphs_content').html(data);
+      })
+      return false;
+    });
+
+    $("#save_optional_graphs_button").click(function(event) {
+       $.get('edit_optional_graphs.php', $("#edit_optional_reports_form").serialize(), function(data) {
+          $('#edit_optional_graphs_content').html(data);
+          $("#save_optional_graphs_button").hide();
+          setTimeout(function() {
+             $('#edit_optional_graphs').dialog('close');
+          }, 5000);
+        });
+      return false;
+    });
+
+});
+</script>
+
+<?php if ((isset($this->scope["graph_engine"]) ? $this->scope["graph_engine"] : null) == "flot") {
+?>
+<script language="javascript" type="text/javascript" src="js/jquery.flot.min.js"></script>
+<script type="text/javascript" src="js/create-flot-graphs.js"></script>
+<style type="text/css">
+.flotgraph2 {
+  height: <?php echo $this->scope["graph_height"];?>px;
+  width:  <?php echo $this->scope["graph_width"];?>px;
+}
+</style>
+<?php 
+}?>
+
+
+<style type="text/css">
+  .toggler { width: 500px; height: 200px; }
+  a.button { padding: .15em 1em; text-decoration: none; }
+  #effect { width: 240px; height: 135px; padding: 0.4em; position: relative; }
+  #effect h3 { margin: 0; padding: 0.4em; text-align: center; }
+  #heatmap-fig {
+    width: 200px;
+    height: 200px;
+  } 
+</style>
+
+<div id="metric-actions-dialog" title="Metric Actions">
+  <div id="metric-actions-dialog-content">
+    Available Metric actions.
+  </div>
+</div>
+
+<div id="edit_optional_graphs">
+  <div style="text-align:center">
+    <button  id='save_optional_graphs_button'>Save</button>
+  </div>
+  <div id="edit_optional_graphs_content">Empty</div>
+</div>
+
+<div style="background:rgb(238,238,238);text-align:center;">
+  <font size="+1" id="cluster_title">Overview of <?php echo $this->scope["cluster"];?> @ <?php echo $this->scope["localtime"];?></font>
+</div>
+
+<table border="0" cellspacing=4 width="100%">
+<tr>
+<td align="left" valign="top">
+<div id="cluster_overview">
+<?php echo Dwoo_Plugin_include($this, 'cluster_overview.tpl', null, null, null, '_root', null);?>
+
+</div>
+<?php if (((isset($this->scope["extra"]) ? $this->scope["extra"] : null) !== null)) {
+?>
+<?php echo Dwoo_Plugin_include($this, "".(isset($this->scope["extra"]) ? $this->scope["extra"] : null)."", null, null, null, '_root', null);?>
+
+<?php 
+}?>
+
+</td>
+<td rowspan=2 align="center" valign=top>
+<div id="optional_graphs" style="padding-bottom:4px">
+<?php echo $this->scope["optional_reports"];?><br>
+<?php 
+$_fh0_data = (isset($this->scope["optional_graphs_data"]) ? $this->scope["optional_graphs_data"] : null);
+if ($this->isTraversable($_fh0_data) == true)
+{
+	foreach ($_fh0_data as $this->scope['graph'])
+	{
+/* -- foreach start output */
+?>
+  <a href="./graph_all_periods.php?<?php echo $this->scope["graph"]["graph_args"];?>&amp;g=<?php echo $this->scope["graph"]["name"];?>_report&amp;z=large">
+  <img border=0 <?php echo $this->scope["additional_cluster_img_html_args"];?> title="<?php echo $this->scope["cluster"];?> <?php echo $this->scope["graph"]["name"];?>" src="./graph.php?<?php echo $this->scope["graph"]["graph_args"];?>&amp;g=<?php echo $this->scope["graph"]["name"];?>_report&amp;z=medium"></a>
+<?php 
+/* -- foreach end output */
+	}
+}?>
+
+</div>
+<?php if ((isset($this->scope["user_may_edit"]) ? $this->scope["user_may_edit"] : null)) {
+?>
+<button id="edit_optional_graphs_button">Edit Optional Graphs</button>
+<?php 
+}?>
+
+</td>
+</tr>
+
+<tr>
+ <td align="center" valign="top">
+<?php if ((isset($this->scope["php_gd"]) ? $this->scope["php_gd"] : null) && ! (isset($this->scope["heatmap"]) ? $this->scope["heatmap"] : null)) {
+?>
+  <img id="load_pie" src="./pie.php?<?php echo $this->scope["pie_args"];?>" border="0" />
+<?php 
+}?>
+
+<?php if ((isset($this->scope["heatmap"]) ? $this->scope["heatmap"] : null) && (isset($this->scope["num_nodes"]) ? $this->scope["num_nodes"] : null) > 0) {
+?>
+Utilization heatmap<br />
+<div id="heatmap-fig">
+<script type="text/javascript+protovis">
+var heatmap = [
+<?php echo $this->scope["heatmap"];?>
+
+];
+
+var w = heatmap[0].length,
+    h = heatmap.length;
+
+var vis = new pv.Panel()
+    .width(w * <?php echo $this->scope["heatmap_size"];?>)
+    .height(h * <?php echo $this->scope["heatmap_size"];?>)
+    .margin(2)
+    .strokeStyle("#aaa")
+    .lineWidth(4)
+    .antialias(false);
+
+vis.add(pv.Image)
+    .imageWidth(w)
+    .imageHeight(h)
+    .image(pv.Scale.linear()
+        .domain(0, 0.25, 0.5, 0.75, 1.00)
+        .range("#e2ecff", "#caff98", "#ffde5e" , "#ffa15e","#ff634f")
+        .by(function(i, j) heatmap[j][i]));
+
+vis.render();
+    </script>
+ </div>
+<?php 
+}?>
+
+ </td>
+</tr>
+</table>
+
+<?php if ((isset($this->scope["stacked_graph_args"]) ? $this->scope["stacked_graph_args"] : null)) {
+?>
+<center>
+<table width="100%" border=0>
+<tr>
+  <td colspan="1">
+  <font size="+1" style="text-align:center">Stacked Graph - <?php echo $this->scope["metric"];?></font> 
+  </td>
+</tr>
+<tr>
+  <td>
+  <center><img id="stacked_graph" src="stacked.php?<?php echo $this->scope["stacked_graph_args"];?>" alt="<?php echo $this->scope["cluster"];?> <?php echo $this->scope["metric"];?>"></center>
+  </td>
+</tr>
+</table>
+</center>
+<?php 
+}?>
+
+
+<script type="text/javascript">
+// Need to set the field value to metric name
+$("#metrics-picker").val("<?php echo $this->scope["metric_name"];?>");
+</script>
+
+
+<div id="cluster_view_chooser">
+<table border="0" width="100%">
+  <tr>
+  <td style="text-align:center;background:rgb(238,238,238);">
+  Show Hosts Scaled:
+  <?php 
+$_fh1_data = (isset($this->scope["showhosts_levels"]) ? $this->scope["showhosts_levels"] : null);
+$this->globals["foreach"]['default'] = array
+(
+	"iteration"		=> 1,
+	"last"		=> null,
+	"total"		=> $this->count($_fh1_data),
+);
+$_fh1_glob =& $this->globals["foreach"]['default'];
+if ($this->isTraversable($_fh1_data) == true)
+{
+	foreach ($_fh1_data as $this->scope['id']=>$this->scope['showhosts'])
+	{
+		$_fh1_glob["last"] = (string) ($_fh1_glob["iteration"] === $_fh1_glob["total"]);
+/* -- foreach start output */
+?>
+  <input type="radio" name="sh" value="<?php echo $this->scope["id"];?>" id="shch<?php echo $this->scope["id"];?>" OnClick="ganglia_form.submit();" <?php echo $this->scope["showhosts"]["checked"];?>><label for="shch<?php echo $this->scope["id"];?>"><?php echo $this->scope["showhosts"]["name"];?></label>
+  <?php 
+/* -- implode */
+if (!$_fh1_glob["last"]) {
+	echo "";
+}
+/* -- foreach end output */
+		$_fh1_glob["iteration"]+=1;
+	}
+}?>&nbsp;
+  |
+  <span class="nobr"><?php echo $this->scope["cluster"];?> <strong><?php echo $this->scope["metric"];?></strong>
+  last <strong><?php echo $this->scope["range"];?></strong>
+  sorted <strong><?php echo $this->scope["sort"];?></strong></span>
+<?php if (((isset($this->scope["columns_size_dropdown"]) ? $this->scope["columns_size_dropdown"] : null) !== null)) {
+?>
+  |
+   <font>
+   <span class="nobr">Size&nbsp;&nbsp;<?php echo $this->scope["size_menu"];?></span>
+   <span class="nobr">Columns&nbsp;&nbsp;<?php echo $this->scope["cols_menu"];?> (0 = metric + reports)</span>
+   </font>
+<?php 
+}?>
+
+  </td>
+</tr>
+</table>
+</div>
+
+<div id="host_metric_graphs">
+<?php echo Dwoo_Plugin_include($this, 'cluster_host_metric_graphs.tpl', null, null, null, '_root', null);?>
+
+</div>
+
+<script type="text/javascript">
+$(function() {
+  $( "#cluster_view_chooser" ).buttonset();
+});
+</script>
+<!-- End cluster_view.tpl -->
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/job_monarch/header.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/job_monarch/header.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/job_monarch/header.tpl.d17.php	(revision 755)
@@ -0,0 +1,303 @@
+<?php
+/* template head */
+if (function_exists('Dwoo_Plugin_include')===false)
+	$this->getLoader()->loadPlugin('include');
+/* end template head */ ob_start(); /* template body */ ?><!-- Begin header.tpl -->
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<title>Ganglia:: <?php echo $this->scope["page_title"];?></title>
+<meta http-equiv="Content-type" content="text/html; charset=utf-8">
+<link type="text/css" href="css/smoothness/jquery-ui-1.9.1.custom.min.css" rel="stylesheet" />
+<link type="text/css" href="css/jquery.liveSearch.css" rel="stylesheet" />
+<link type="text/css" href="css/jquery.multiselect.css" rel="stylesheet" />
+<link type="text/css" href="css/jquery.flot.events.css" rel="stylesheet" />
+<link type="text/css" href="./styles.css" rel="stylesheet" />
+<link type="text/css" href="addons/job_monarch/styles.css" rel="stylesheet" />
+<script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
+<script type="text/javascript" src="js/jquery-ui-1.9.1.custom.min.js"></script>
+<script type="text/javascript" src="js/jquery.livesearch.min.js"></script>
+<script type="text/javascript" src="js/ganglia.js"></script>
+<script type="text/javascript" src="js/jquery.gangZoom.js"></script>
+<script type="text/javascript" src="js/jquery.cookie.js"></script>
+<script type="text/javascript" src="js/jquery-ui-timepicker-addon.js"></script>
+<script type="text/javascript" src="js/jquery.ba-bbq.min.js"></script>
+<script type="text/javascript" src="js/combobox.js"></script>
+<script type="text/javascript" src="js/jquery.scrollTo-1.4.2-min.js"></script>
+<script type="text/javascript" src="js/jquery.buttonsetv.js"></script>
+<script type="text/javascript">
+    var server_utc_offset=<?php echo $this->scope["server_utc_offset"];?>;
+    
+    var g_refresh_timer = setTimeout("refresh()", <?php echo $this->scope["refresh"];?> * 1000);
+
+    function refreshHeader() {
+      $.get('header.php?date_only=1', function(data) {
+        var title = $("#page_title").text();
+        var l = title.lastIndexOf(" for ");
+        title = title.substring(0, l);
+        title += " for " + data;
+        $("#page_title").text(title);
+        });
+    }
+
+    function refresh() {
+      var selected_tab = $("#selected_tab").val();
+      if (selected_tab == "agg") {
+        refreshAggregateGraph();
+        g_refresh_timer = setTimeout("refresh()", <?php echo $this->scope["refresh"];?> * 1000);
+      } else if (selected_tab == "v") {
+        refreshHeader();
+        if ($.isFunction(window.refreshView)) {
+          refreshView();
+          g_refresh_timer = setTimeout("refresh()", <?php echo $this->scope["refresh"];?> * 1000);
+        } else if ($.isFunction(window.refreshDecomposeGraph)) {
+          refreshDecomposeGraph();
+          g_refresh_timer = setTimeout("refresh()", <?php echo $this->scope["refresh"];?> * 1000);
+        } else
+          ganglia_form.submit();
+      } else if (selected_tab == "ev") {
+        refreshOverlayEvent();
+        g_refresh_timer = setTimeout("refresh()", <?php echo $this->scope["refresh"];?> * 1000);
+      } else if (selected_tab == "m") {
+        if ($.isFunction(window.refreshClusterView)) {
+          refreshHeader();
+          refreshClusterView();
+          g_refresh_timer = setTimeout("refresh()", <?php echo $this->scope["refresh"];?> * 1000);
+        } else if ($.isFunction(window.refreshHostView)) {
+          refreshHeader();
+          refreshHostView();
+          g_refresh_timer = setTimeout("refresh()", <?php echo $this->scope["refresh"];?> * 1000);
+        } else
+          ganglia_form.submit();
+      } else
+        ganglia_form.submit();
+    }
+
+    $(function() {
+      g_overlay_events = ($("#overlay_events").val() == "true");
+
+      g_tabIndex = new Object();
+      g_tabName = [];
+      var tabName = ["m", "s", "v", "agg", "ch", "ev", "rot", "mob"];
+      var j = 0;
+      for (var i in tabName) {
+        if (tabName[i] == "ev" && !g_overlay_events)
+          continue;
+        g_tabIndex[tabName[i]] = j++;
+        g_tabName.push(tabName[i]);
+      }
+
+      // Follow tab's URL instead of loading its content via ajax
+      var tabs = $("#tabs");
+      if (tabs[0]) {
+        tabs.tabs();
+        // Restore previously selected tab
+        var selected_tab = $("#selected_tab").val();
+        //alert("selected_tab = " + selected_tab);
+        if (typeof g_tabIndex[selected_tab] != 'undefined') {
+          try {
+            //alert("Selecting tab: " + selected_tab);
+            tabs.tabs("select", g_tabIndex[selected_tab]);
+            if (selected_tab == "rot")
+              autoRotationChooser();
+          } catch (err) {
+            try {
+              alert("Error(ganglia.js): Unable to select tab: " + 
+                    selected_tab + ". " + err.getDescription());
+            } catch (err) {
+              // If we can't even show the error, fail silently.
+            }
+          }
+        }
+
+        tabs.bind("tabsselect", function(event, ui) {
+          $("#selected_tab").val(g_tabName[ui.index]);
+          if (g_tabName[ui.index] != "mob")
+            $.cookie("ganglia-selected-tab-" + window.name, ui.index);
+          if (ui.index == g_tabIndex["m"] ||
+              ui.index == g_tabIndex["v"] ||
+              ui.index == g_tabIndex["ch"])
+            ganglia_form.submit();
+        });
+      }
+    });
+
+    $(function() {
+      $("#metrics-picker").combobox();
+
+      <?php echo $this->scope["is_metrics_picker_disabled"];?>
+
+
+      $(".header_btn").button();
+    });
+
+  $(function () {
+
+    done = function done(startTime, endTime) {
+            setStartAndEnd(startTime, endTime);
+            document.forms['ganglia_form'].submit();
+    }
+
+    cancel = function (startTime, endTime) {
+            setStartAndEnd(startTime, endTime);
+    }
+
+    defaults = {
+        startTime: <?php echo $this->scope["start_timestamp"];?>,
+        endTime: <?php echo $this->scope["end_timestamp"];?>,
+        done: done,
+        cancel: cancel
+    }
+
+    $(".host_small_zoomable").gangZoom($.extend({
+        paddingLeft: 67,
+        paddingRight: 30,
+        paddingTop: 38,
+        paddingBottom: 25
+    }, defaults));
+
+    $(".host_medium_zoomable").gangZoom($.extend({
+        paddingLeft: 67,
+        paddingRight: 30,
+        paddingTop: 38,
+        paddingBottom: 40
+    }, defaults));
+
+    $(".host_default_zoomable").gangZoom($.extend({
+        paddingLeft: 66,
+        paddingRight: 30,
+        paddingTop: 37,
+        paddingBottom: 50
+    }, defaults));
+
+    $(".host_large_zoomable").gangZoom($.extend({
+        paddingLeft: 66,
+        paddingRight: 29,
+        paddingTop: 37,
+        paddingBottom: 56
+    }, defaults));
+
+    $(".cluster_zoomable").gangZoom($.extend({
+        paddingLeft: 67,
+        paddingRight: 30,
+        paddingTop: 37,
+        paddingBottom: 50
+    }, defaults));
+
+    function rrdDateTimeString(date) {
+      return (date.getMonth() + 1) + "/" + date.getDate() + "/" + date.getFullYear() + " " + date.getHours() + ":" + date.getMinutes();
+    }
+
+    function setStartAndEnd(startTime, endTime) {
+        // we're getting local start/end times.
+
+        // getTimezoneOffset returns negative values east of UTC,
+        // which is the opposite of PHP. we want negative values to the west.
+        var local_offset = new Date().getTimezoneOffset() * 60 * -1;
+        var delta = local_offset - server_utc_offset;
+        var date = new Date((Math.floor(startTime) - delta) * 1000);
+        $("#datepicker-cs").val(rrdDateTimeString(date));
+        date = new Date((Math.floor(endTime) - delta) * 1000);
+        $("#datepicker-ce").val(rrdDateTimeString(date));
+    }
+
+    initShowEvent();
+    initTimeShift();
+  });
+
+
+</script>
+<?php echo $this->scope["custom_time_head"];?>
+
+</head>
+<body style="background-color: #ffffff;" onunload="g_refresh_timer=null">
+<?php if (((isset($this->scope["user_header"]) ? $this->scope["user_header"] : null) !== null)) {
+?>
+<?php echo Dwoo_Plugin_include($this, "user_header.tpl", null, null, null, '_root', null);?>
+
+<?php 
+}?>
+
+
+<?php if ((isset($this->scope["auth_system_enabled"]) ? $this->scope["auth_system_enabled"] : null)) {
+?>
+<div style="float:right">
+  <?php if ((isset($this->scope["username"]) ? $this->scope["username"] : null)) {
+?>
+    Currently logged in as: <?php echo $this->scope["username"];?> | <a href="logout.php">Logout</a>
+  <?php 
+}
+else {
+?>
+    You are not currently logged in. | <a href="login.php">Login</a>
+  <?php 
+}?>
+
+</div>
+<br style="clear:both"/>
+<?php 
+}?>
+
+
+<div id="tabs">
+<ul>
+  <li><a href="#tabs-main">Main</a></li>
+  <li><a href="#tabs-search">Search</a></li>
+  <li><a href="#tabs-main">Views</a></li>
+  <li><a href="aggregate_graphs.php">Aggregate Graphs</a></li>
+  <li><a href="#tabs-main">Compare Hosts</a></li>
+<?php if ((isset($this->scope["overlay_events"]) ? $this->scope["overlay_events"] : null)) {
+?>
+  <li><a href="events.php">Events</a></li>
+<?php 
+}?>
+
+  <li><a href="#tabs-autorotation" onclick="autoRotationChooser();">Automatic Rotation</a></li>
+  <li><a href="#tabs-livedashboard" onclick="liveDashboardChooser();">Live Dashboard</a></li>  
+  <li><a href="#tabs-mobile" onclick="window.location.href='mobile.php';">Mobile</a></li>
+</ul>
+
+<div id="tabs-main">
+<form action="<?php echo $this->scope["page"];?>" method="GET" name="ganglia_form">
+  <div style="background-color:#dddddd;padding:5px;">
+     <big style="float:left;"><b id="page_title"><?php echo $this->scope["page_title"];?> for <?php echo $this->scope["date"];?></b></big><input style="float:right;" class="header_btn" type="submit" value="Get Fresh Data"/><div style="clear:both"></div>
+  </div>
+  <div style="padding:5px 5px 0 5px;">
+    <div style="float:left;" id="range_menu" class="nobr"><?php echo $this->scope["range_menu"];?></div>
+    <div style="float:left;" id="custom_range_menu"><?php echo $this->scope["custom_time"];?></div>
+    <div style="float:right;"><?php echo $this->scope["additional_buttons"];?>&nbsp;&nbsp;<?php echo $this->scope["alt_view"];?></div>
+    <div style="clear:both;"></div>
+  </div>
+  <div id="sort_menu" style="padding:5px 5px 0 5px;">
+   Metric&nbsp;&nbsp; <select name="m" id="metrics-picker"><?php echo $this->scope["picker_metrics"];?></select>&nbsp;&nbsp;
+     <?php echo $this->scope["sort_menu"];?>
+
+  </div>
+<?php if ((isset($this->scope["node_menu"]) ? $this->scope["node_menu"] : null) != "") {
+?>
+  <div id="sort_menu" style="padding:5px 5px 0 5px;">
+    <?php echo $this->scope["node_menu"];?>&nbsp;&nbsp;<?php echo $this->scope["additional_filter_options"];?>
+
+  </div>
+<?php 
+}?>
+
+
+<input type="hidden" name="tab" id="selected_tab" value="<?php echo $this->scope["selected_tab"];?>">
+<input type="hidden" id="vn" name="vn" value="<?php echo $this->scope["view_name"];?>">
+<?php if ((isset($this->scope["overlay_events"]) ? $this->scope["overlay_events"] : null)) {
+?>
+<input type="hidden" id="overlay_events" value="true">
+<?php 
+}
+else {
+?>
+<input type="hidden" id="overlay_events" value="false">
+<?php 
+}?>
+
+<hr size="1" noshade>
+<!-- End header.tpl -->
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/job_monarch/host_extra.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/job_monarch/host_extra.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/job_monarch/host_extra.tpl.d17.php	(revision 755)
@@ -0,0 +1,9 @@
+<?php
+/* template head */
+/* end template head */ ob_start(); /* template body */ ?><a href="./addons/job_monarch/?c=<?php echo $this->scope["cluster"];?>&h=<?php echo $this->scope["host"];?>">
+<IMG SRC="./addons/job_monarch/image.php?c=<?php echo $this->scope["cluster"];?>&h=<?php echo $this->scope["host"];?>&j_view=hostimage" BORDER=0>
+</a>
+<hr>
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/overview.tpl.d17.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/overview.tpl.d17.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/compiled/templates/overview.tpl.d17.php	(revision 755)
@@ -0,0 +1,352 @@
+<?php
+/* template head */
+/* end template head */ ob_start(); /* template body */ ?><CENTER>
+<TABLE cellpadding="15">
+<TR>
+
+  <TD>
+
+
+<TABLE ALIGN=CENTER class="overview" cellpadding="5">
+
+<COL id="kol1">
+<COL id="kol2">
+<COL id="kol3">
+<COL id="kol4">
+
+<TR class="overview_header">
+<TD>Batch</TD>
+<TD>Jobs</TD>
+<TD>Nodes</TD>
+<TD>Cpus</TD>
+</TR>
+
+<?php if ("".(isset($this->scope["na_nodes"]) ? $this->scope["na_nodes"] : null)."" == "yes") {
+?>
+<TR class="overview">
+<TD class="gray">
+Unavailable
+</TD>
+<TD class="gray">
+<?php echo $this->scope["na_jobs"];?>
+
+</TD>
+<TD class="gray">
+<?php echo $this->scope["na_nodes"];?>
+
+</TD>
+<TD class="gray">
+<?php echo $this->scope["na_cpus"];?>
+
+</TD>
+</TR>
+<?php 
+}?>
+
+
+<TR class="overview_line">
+<TD class="blue">
+Capacity
+</TD>
+<TD class="blue">
+</TD>
+<TD class="blue">
+<?php echo $this->scope["avail_nodes"];?>
+
+</TD>
+<TD class="blue">
+<?php echo $this->scope["avail_cpus"];?>
+
+</TD>
+</TR>
+
+
+
+<TR class="overview">
+<TD class="red">
+Allocated
+</TD>
+<TD class="red">
+<?php echo $this->scope["running_jobs"];?>
+
+</TD>
+<TD class="red">
+<?php echo $this->scope["running_nodes"];?>
+
+</TD>
+<TD class="red">
+<?php echo $this->scope["running_cpus"];?>
+
+</TD>
+</TR>
+
+<TR class="overview_line">
+<TD class="gray">
+Queued
+</TD>
+<TD class="gray">
+<?php echo $this->scope["queued_jobs"];?>
+
+</TD>
+<TD class="gray">
+<?php echo $this->scope["queued_nodes"];?>
+
+</TD>
+<TD class="gray">
+<?php echo $this->scope["queued_cpus"];?>
+
+</TD>
+</TR>
+
+<TR class="overview">
+<TD class="brown">
+Total
+</TD>
+<TD class="brown">
+<?php echo $this->scope["total_jobs"];?>
+
+</TD>
+<TD class="brown">
+<?php echo $this->scope["total_nodes"];?>
+
+</TD>
+<TD class="brown">
+<?php echo $this->scope["total_cpus"];?>
+
+</TD>
+</TR>
+
+
+<TR class="overview">
+<TD class="green">
+Unallocated
+</TD>
+<TD class="green">
+</TD>
+<TD class="green">
+<?php echo $this->scope["free_nodes"];?>
+
+</TD>
+<TD class="green">
+<?php echo $this->scope["free_cpus"];?>
+
+</TD>
+</TR>
+
+<TR class="overview" id="selected">
+<TD>
+View
+</TD>
+<TD>
+<?php echo $this->scope["view_jobs"];?>
+
+</TD>
+<TD>
+<?php echo $this->scope["view_nodes"];?>
+
+</TD>
+<TD>
+<?php echo $this->scope["view_cpus"];?>
+
+</TD>
+</TR>
+
+</TABLE>
+
+<BR>
+<div id="monarchimage">
+<?php echo $this->scope["rjqj_graph"];?>
+
+</div>
+
+  <TD ALIGN="CENTER"><CENTER>
+<!-- INCLUDESCRIPT BLOCK : ci_script -->
+    <div id="monarchimage">
+    <IMG SRC="<?php echo $this->scope["clusterimage"];?>" USEMAP="#MONARCH_CLUSTER_BIG" BORDER="0">
+    </div>
+    <MAP NAME="MONARCH_CLUSTER_BIG">
+<?php if ("".(isset($this->scope["nodes_clustermap"]) ? $this->scope["nodes_clustermap"] : null)."" == "yes") {
+?>
+<?php echo $this->scope["node_area_map"];?>
+
+<?php 
+}?>
+
+    </MAP>
+    <BR>
+<FONT class="footer">Last updated: <?php echo $this->scope["report_time"];?></FONT></CENTER>
+  </TD>
+
+  </TD>
+  <TD ALIGN="CENTER">
+    <IMG SRC="<?php echo $this->scope["pie"];?>">
+  </TD>
+</TR>
+</TABLE>
+
+<BR>
+
+<SCRIPT TYPE="text/javascript" SRC="libtoga.js"></SCRIPT>
+<NOSCRIPT><P>[Sorting by column header requires JavaScript]<BR><BR></P></NOSCRIPT>
+
+<INPUT TYPE="HIDDEN" NAME="sortby" VALUE="<?php echo $this->scope["sortby"];?>">
+<INPUT TYPE="HIDDEN" NAME="sortorder" VALUE="<?php echo $this->scope["sortorder"];?>">
+<INPUT TYPE="HIDDEN" NAME="c" VALUE="<?php echo $this->scope["clustername"];?>">
+<INPUT TYPE="HIDDEN" NAME="queue" VALUE="<?php echo $this->scope["queue"];?>">
+<INPUT TYPE="HIDDEN" NAME="state" VALUE="<?php echo $this->scope["state"];?>">
+<INPUT TYPE="HIDDEN" NAME="owner" VALUE="<?php echo $this->scope["owner"];?>">
+<INPUT TYPE="HIDDEN" NAME="id" VALUE="<?php echo $this->scope["id"];?>">
+<INPUT TYPE="HIDDEN" NAME="filterorder" VALUE="<?php echo $this->scope["order"];?>">
+
+<TABLE WIDTH="100%" CELLPADDING="2" CELLSPACING="2" BORDER=0>
+<TR CLASS="monarch">
+<TH><B><A HREF="#" onClick="setSort( 'id' )" ALT="Jobid" TITLE="Jobid">Id</A></B></TH>
+<TH><B><A HREF="#" onClick="setSort( 'state' )" ALT="State" TITLE="State">S</A></B></TH>
+<TH><B><A HREF="#" onClick="setSort( 'owner' )">Owner</A></B></TH>
+<TH><B><A HREF="#" onClick="setSort( 'queue' )">Queue</A></B></TH>
+<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>
+<?php if ("".(isset($this->scope["column_header_req_mem"]) ? $this->scope["column_header_req_mem"] : null)."" == "yes") {
+?>
+<TH><B><A HREF="#" onClick="setSort( 'req_mem' )" ALT="Requested Memory" TITLE="Requested Memory">Req. Memory</A></B></TH>
+<?php 
+}?>
+
+<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>
+<?php if ("".(isset($this->scope["column_header_queued"]) ? $this->scope["column_header_queued"] : null)."" == "yes") {
+?>
+<TH><B><A HREF="#" onClick="setSort( 'queued' )">Queued</A></B></TH>
+<?php 
+}?>
+
+<?php if ("".(isset($this->scope["column_header_nodes"]) ? $this->scope["column_header_nodes"] : null)."" == "yes") {
+?>
+<TH WIDTH="11%"><B><A HREF="#" onClick="setSort( 'nodes' )" ALT="Nodes" TITLE="Nodes">Nodes</A></B></TH>
+<?php 
+}?>
+
+<TH><B><A HREF="#" onClick="setSort( 'start' )">Started</A></B></TH>
+<TH><B><A HREF="#" onClick="setSort( 'runningtime' )">Runningtime</A></B></TH>
+</TR>
+
+<?php 
+$_loop0_data = (isset($this->scope["node_list"]) ? $this->scope["node_list"] : null);
+if ($this->isTraversable($_loop0_data) == true)
+{
+	foreach ($_loop0_data as $tmp_key => $this->scope["-loop-"])
+	{
+		$_loop0_scope = $this->setScope(array("-loop-"));
+/* -- loop start output */
+?>
+  <TR CLASS="<?php echo $this->scope["nodeclass"];?>">
+    <TD><A HREF="#" onClick="setFilter( 'id', '<?php echo $this->scope["id"];?>' )"><?php echo $this->scope["id"];?></A></TD>
+    <TD><A HREF="#" onClick="setFilter( 'state', '<?php echo $this->scope["state"];?>' )" ALT="<?php echo $this->scope["fullstate"];?>" TITLE="<?php echo $this->scope["fullstate"];?>"><?php echo $this->scope["state"];?></A></TD>
+    <TD><A HREF="#" onClick="setFilter( 'owner', '<?php echo $this->scope["owner"];?>' )"><?php echo $this->scope["owner"];?></A></TD>
+    <TD><A HREF="#" onClick="setFilter( 'queue', '<?php echo $this->scope["queue"];?>' )"><?php echo $this->scope["queue"];?></A></TD>
+    <TD ALT="<?php echo $this->scope["fulljobname"];?>" TITLE="<?php echo $this->scope["fulljobname"];?>">
+<?php if ("".(isset($this->scope["jobname_hint_start"]) ? $this->scope["jobname_hint_start"] : null)."" == "yes") {
+?>
+    <FONT CLASS="jobname_hint">
+<?php 
+}?>
+
+    <?php echo $this->scope["name"];?>
+
+<?php if ("".(isset($this->scope["jobname_hint_end"]) ? $this->scope["jobname_hint_end"] : null)."" == "yes") {
+?>
+    </FONT>
+<?php 
+}?>
+
+    </TD>
+    <TD><?php echo $this->scope["req_cpu"];?></TD>
+<?php if ("".(isset($this->scope["column_req_mem"]) ? $this->scope["column_req_mem"] : null)."" == "yes") {
+?>
+    <TD><?php echo $this->scope["req_memory"];?></TD>
+<?php 
+}?>
+
+    <TD><?php echo $this->scope["nodes"];?>/<?php echo $this->scope["cpus"];?></TD>
+<?php if ("".(isset($this->scope["column_queued"]) ? $this->scope["column_queued"] : null)."" == "yes") {
+?>
+    <TD><?php echo $this->scope["queued"];?></TD>
+<?php 
+}?>
+
+<?php if ("".(isset($this->scope["column_nodes"]) ? $this->scope["column_nodes"] : null)."" == "yes") {
+?>
+    <TD><?php echo $this->scope["nodes_hostnames"];?></TD>
+<?php 
+}?>
+
+    <TD><?php echo $this->scope["started"];?></TD>
+    <TD><?php echo $this->scope["runningtime"];?></TD>
+  </TR>
+<?php 
+/* -- loop end output */
+		$this->setScope($_loop0_scope, true);
+	}
+}
+?>
+
+</TABLE>
+</CENTER>
+
+<?php if ("".(isset($this->scope["showhosts"]) ? $this->scope["showhosts"] : null)."" == "yes") {
+?>
+<TABLE BORDER="0" WIDTH="100%">
+<TR>
+  <TD CLASS=title COLSPAN="2">
+  <FONT SIZE="-1">
+  Show Hosts:
+  yes<INPUT type=radio name="sh" value="1" OnClick="toga_form.submit();" <?php echo $this->scope["checked1"];?>>
+  no<INPUT type=radio name="sh" value="0" OnClick="toga_form.submit();" <?php echo $this->scope["checked0"];?>>
+  </FONT>
+  |
+  job <strong><?php echo $this->scope["id"];?></strong> metric <strong><?php echo $this->scope["metric"];?></strong>
+  |
+   <FONT SIZE="-1">
+   Columns&nbsp;&nbsp;<?php echo $this->scope["cols_menu"];?>
+
+   </FONT>
+  </TD>
+</TR>
+   
+</TABLE>
+
+<CENTER>
+<TABLE>
+<TR>
+<?php 
+$_loop1_data = (isset($this->scope["sorted_list"]) ? $this->scope["sorted_list"] : null);
+if ($this->isTraversable($_loop1_data) == true)
+{
+	foreach ($_loop1_data as $tmp_key => $this->scope["-loop-"])
+	{
+		$_loop1_scope = $this->setScope(array("-loop-"));
+/* -- loop start output */
+?>
+<?php echo $this->scope["metric_image"];
+echo $this->scope["br"];?>
+
+<?php 
+/* -- loop end output */
+		$this->setScope($_loop1_scope, true);
+	}
+}
+?>
+
+</TR>
+</TABLE>
+
+<p>
+(Nodes colored by 1-minute load) | <A HREF="../../node_legend.html" ALT="Node Image egend">Legend</A>
+
+</CENTER>
+
+<?php 
+}?>
+
+<?php  /* end template body */
+return $this->buffer . ob_get_clean();
+?>
Index: /branches/0.4/web/addons/job_monarch/dwoo/dwooAutoload.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/dwooAutoload.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/dwooAutoload.php	(revision 755)
@@ -0,0 +1,12 @@
+<?php
+
+include dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Dwoo'. DIRECTORY_SEPARATOR . 'Core.php';
+
+function dwooAutoload($class)
+{
+	if (substr($class, 0, 5) === 'Dwoo_' || $class === 'Dwoo') {
+		include DWOO_DIRECTORY . strtr($class, '_', DIRECTORY_SEPARATOR).'.php';
+	}
+}
+
+spl_autoload_register('dwooAutoload');
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/a.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/a.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/a.php	(revision 755)
@@ -0,0 +1,67 @@
+<?php
+
+/**
+ * Outputs a html &lt;a&gt; tag
+ * <pre>
+ *  * href : the target URI where the link must point
+ *  * rest : any other attributes you want to add to the tag can be added as named parameters
+ * </pre>
+ *
+ * Example :
+ *
+ * <code>
+ * {* Create a simple link out of an url variable and add a special class attribute: *}
+ *
+ * {a $url class="external" /}
+ *
+ * {* Mark a link as active depending on some other variable : *}
+ *
+ * {a $link.url class=tif($link.active "active"); $link.title /}
+ *
+ * {* This is similar to: <a href="{$link.url}" class="{if $link.active}active{/if}">{$link.title}</a> *}
+ * </code>
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+class Dwoo_Plugin_a extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Block
+{
+	public function init($href, array $rest=array())
+	{
+	}
+
+	public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type)
+	{
+		$p = $compiler->getCompiledParams($params);
+
+		$out = Dwoo_Compiler::PHP_OPEN . 'echo \'<a '.self::paramsToAttributes($p);
+
+		return $out.'>\';' . Dwoo_Compiler::PHP_CLOSE;
+	}
+
+	public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content)
+	{
+		$p = $compiler->getCompiledParams($params);
+
+		// no content was provided so use the url as display text
+		if ($content == "") {
+			// merge </a> into the href if href is a string
+			if (substr($p['href'], -1) === '"' || substr($p['href'], -1) === '\'') {
+				return Dwoo_Compiler::PHP_OPEN . 'echo '.substr($p['href'], 0, -1).'</a>'.substr($p['href'], -1).';'.Dwoo_Compiler::PHP_CLOSE;
+			}
+			// otherwise append
+			return Dwoo_Compiler::PHP_OPEN . 'echo '.$p['href'].'.\'</a>\';'.Dwoo_Compiler::PHP_CLOSE;
+		}
+
+		// return content
+		return $content . '</a>';
+	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/auto_escape.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/auto_escape.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/auto_escape.php	(revision 755)
@@ -0,0 +1,61 @@
+<?php
+
+/**
+ * Overrides the compiler auto-escape setting within the block
+ * <pre>
+ *  * enabled : if set to "on", "enable", true or 1 then the compiler autoescaping is enabled inside this block. set to "off", "disable", false or 0 to disable it
+ * </pre>
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+class Dwoo_Plugin_auto_escape extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Block
+{
+	protected static $stack = array();
+
+	public function init($enabled)
+	{
+	}
+
+	public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type)
+	{
+		$params = $compiler->getCompiledParams($params);
+		switch(strtolower(trim((string) $params['enabled'], '"\''))) {
+
+		case 'on':
+		case 'true':
+		case 'enabled':
+		case 'enable':
+		case '1':
+			$enable = true;
+			break;
+		case 'off':
+		case 'false':
+		case 'disabled':
+		case 'disable':
+		case '0':
+			$enable = false;
+			break;
+		default:
+			throw new Dwoo_Compilation_Exception($compiler, 'Auto_Escape : Invalid parameter ('.$params['enabled'].'), valid parameters are "enable"/true or "disable"/false');
+
+		}
+
+		self::$stack[] = $compiler->getAutoEscape();
+		$compiler->setAutoEscape($enable);
+		return '';
+	}
+
+	public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content)
+	{
+		$compiler->setAutoEscape(array_pop(self::$stack));
+		return $content;
+	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/block.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/block.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/block.php	(revision 755)
@@ -0,0 +1,34 @@
+<?php
+
+/**
+ * This is used only when rendering a template that has blocks but is not extending anything, 
+ * it doesn't do anything by itself and should not be used outside of template inheritance context,
+ * see {@link http://wiki.dwoo.org/index.php/TemplateInheritance} to read more about it.
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+class Dwoo_Plugin_block extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Block
+{
+	public function init($name='')
+	{
+	}
+
+	public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type)
+	{
+		return '';
+	}
+
+	public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content)
+	{
+		return $content;
+	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/capture.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/capture.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/capture.php	(revision 755)
@@ -0,0 +1,61 @@
+<?php
+
+/**
+ * Captures all the output within this block and saves it into {$.capture.default} by default,
+ * or {$.capture.name} if you provide another name.
+ * <pre>
+ *  * name : capture name, used to read the value afterwards
+ *  * assign : if set, the value is also saved in the given variable
+ *  * cat : if true, the value is appended to the previous one (if any) instead of overwriting it
+ * </pre>
+ * If the cat parameter is true, the content
+ * will be appended to the existing content
+ *
+ * Example :
+ *
+ * <code>
+ * {capture "foo"}
+ *   Anything in here won't show, it will be saved for later use..
+ * {/capture}
+ * Output was : {$.capture.foo}
+ * </code>
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+class Dwoo_Plugin_capture extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Block
+{
+	public function init($name = 'default', $assign = null, $cat = false, $trim = false)
+	{
+	}
+
+	public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type)
+	{
+		return Dwoo_Compiler::PHP_OPEN.$prepend.'ob_start();'.$append.Dwoo_Compiler::PHP_CLOSE;
+	}
+
+	public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content)
+	{
+		$params = $compiler->getCompiledParams($params);
+
+		$out = $content . Dwoo_Compiler::PHP_OPEN.$prepend."\n".'$tmp = ob_get_clean();';
+		if ($params['trim'] !== 'false' && $params['trim'] !== 0) {
+			$out .= "\n".'$tmp = trim($tmp);';
+		}
+		if ($params['cat'] === 'true' || $params['cat'] === 1) {
+			$out .= "\n".'$tmp = $this->readVar(\'dwoo.capture.\'.'.$params['name'].') . $tmp;';
+		}
+		if ($params['assign'] !== 'null') {
+			$out .= "\n".'$this->scope['.$params['assign'].'] = $tmp;';
+		}
+		return $out . "\n".'$this->globals[\'capture\']['.$params['name'].'] = $tmp;'.$append.Dwoo_Compiler::PHP_CLOSE;
+	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/dynamic.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/dynamic.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/dynamic.php	(revision 755)
@@ -0,0 +1,70 @@
+<?php
+
+/**
+ * Marks the contents of the block as dynamic. Which means that it will not be cached.
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+class Dwoo_Plugin_dynamic extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Block
+{
+	public function init()
+	{
+	}
+
+	public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type)
+	{
+		return '';
+	}
+
+	public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content)
+	{
+		try {
+			$compiler->findBlock('dynamic');
+			return $content;
+		} catch (Dwoo_Compilation_Exception $e) {
+		}
+		$output = Dwoo_Compiler::PHP_OPEN .
+			'if($doCache) {'."\n\t".
+				'echo \'<dwoo:dynamic_\'.$dynamicId.\'>'.
+				str_replace('\'', '\\\'', $content) .
+				'</dwoo:dynamic_\'.$dynamicId.\'>\';'.
+			"\n} else {\n\t";
+				if(substr($content, 0, strlen(Dwoo_Compiler::PHP_OPEN)) == Dwoo_Compiler::PHP_OPEN) {
+					$output .= substr($content, strlen(Dwoo_Compiler::PHP_OPEN));
+				} else {
+					$output .= Dwoo_Compiler::PHP_CLOSE . $content;
+				}
+				if(substr($output, -strlen(Dwoo_Compiler::PHP_CLOSE)) == Dwoo_Compiler::PHP_CLOSE) {
+					$output = substr($output, 0, -strlen(Dwoo_Compiler::PHP_CLOSE));
+				} else {
+					$output .= Dwoo_Compiler::PHP_OPEN;
+				}
+			$output .= "\n}". Dwoo_Compiler::PHP_CLOSE;
+
+		return $output;
+	}
+
+	public static function unescape($output, $dynamicId, $compiledFile)
+	{
+		$output = preg_replace_callback('/<dwoo:dynamic_('.$dynamicId.')>(.+?)<\/dwoo:dynamic_'.$dynamicId.'>/s', array('self', 'unescapePhp'), $output, -1, $count);
+		// re-add the includes on top of the file
+		if ($count && preg_match('#/\* template head \*/(.+?)/\* end template head \*/#s', file_get_contents($compiledFile), $m)) {
+			$output = '<?php '.$m[1].' ?>'.$output;
+		}
+		return $output;
+	}
+
+	public static function unescapePhp($match)
+	{
+		return preg_replace('{<\?php /\*'.$match[1].'\*/ echo \'(.+?)\'; \?>}s', '$1', $match[2]);
+	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/else.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/else.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/else.php	(revision 755)
@@ -0,0 +1,63 @@
+<?php
+
+/**
+ * Generic else block, it supports all builtin optional-display blocks which are if/for/foreach/loop/with
+ *
+ * If any of those block contains an else statement, the content between {else} and {/block} (you do not
+ * need to close the else block) will be shown if the block's condition has no been met
+ *
+ * Example :
+ *
+ * <code>
+ * {foreach $array val}
+ *   $array is not empty so we display it's values : {$val}
+ * {else}
+ *   if this shows, it means that $array is empty or doesn't exist.
+ * {/foreach}
+ * </code>
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+class Dwoo_Plugin_else extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Block
+{
+	public function init()
+	{
+	}
+
+	public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type)
+	{
+		$preContent = '';
+		while (true) {
+			$preContent .= $compiler->removeTopBlock();
+			$block =& $compiler->getCurrentBlock();
+			$interfaces = class_implements($block['class'], false);
+			if (in_array('Dwoo_IElseable', $interfaces) !== false) {
+				break;
+			}
+		}
+
+		$params['initialized'] = true;
+		$compiler->injectBlock($type, $params);
+		return $preContent;
+	}
+
+	public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content)
+	{
+		if (!isset($params['initialized'])) {
+			return '';
+		}
+
+		$block =& $compiler->getCurrentBlock();
+		$block['params']['hasElse'] = Dwoo_Compiler::PHP_OPEN."else {\n".Dwoo_Compiler::PHP_CLOSE . $content . Dwoo_Compiler::PHP_OPEN."\n}".Dwoo_Compiler::PHP_CLOSE;
+		return '';
+	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/elseif.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/elseif.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/elseif.php	(revision 755)
@@ -0,0 +1,61 @@
+<?php
+
+/**
+ * Acts as a php elseif block, allowing you to add one more condition
+ * if the previous one(s) didn't match. See the {if} plugin for syntax details
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+class Dwoo_Plugin_elseif extends Dwoo_Plugin_if implements Dwoo_ICompilable_Block, Dwoo_IElseable
+{
+	public function init(array $rest)
+	{
+	}
+
+	public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type)
+	{
+		$preContent = '';
+		while (true) {
+			$preContent .= $compiler->removeTopBlock();
+			$block =& $compiler->getCurrentBlock();
+			$interfaces = class_implements($block['class'], false);
+			if (in_array('Dwoo_IElseable', $interfaces) !== false) {
+				break;
+			}
+		}
+
+		$params['initialized'] = true;
+		$compiler->injectBlock($type, $params);
+		return $preContent;
+	}
+
+	public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content)
+	{
+		if (!isset($params['initialized'])) {
+			return '';
+		}
+
+		$tokens = $compiler->getParamTokens($params);
+		$params = $compiler->getCompiledParams($params);
+
+		$pre = Dwoo_Compiler::PHP_OPEN."elseif (".implode(' ', self::replaceKeywords($params['*'], $tokens['*'], $compiler)).") {\n" . Dwoo_Compiler::PHP_CLOSE;
+		$post = Dwoo_Compiler::PHP_OPEN."\n}".Dwoo_Compiler::PHP_CLOSE;
+
+		if (isset($params['hasElse'])) {
+			$post .= $params['hasElse'];
+		}
+
+		$block =& $compiler->getCurrentBlock();
+		$block['params']['hasElse'] = $pre . $content . $post;
+		return '';
+	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/for.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/for.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/for.php	(revision 755)
@@ -0,0 +1,146 @@
+<?php
+
+/**
+ * Similar to the php for block
+ * <pre>
+ *  * name : for name to access it's iterator variables through {$.for.name.var} see {@link http://wiki.dwoo.org/index.php/IteratorVariables} for details
+ *  * from : array to iterate from (which equals 0) or a number as a start value
+ *  * to : value to stop iterating at (equals count($array) by default if you set an array in from)
+ *  * step : defines the incrementation of the pointer at each iteration
+ * </pre>
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.1.0
+ * @date       2009-07-18
+ * @package    Dwoo
+ */
+class Dwoo_Plugin_for extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Block, Dwoo_IElseable
+{
+	public static $cnt=0;
+
+	public function init($name, $from, $to=null, $step=1, $skip=0)
+	{
+	}
+
+	public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type)
+	{
+		// get block params and save the current template pointer to use it in the postProcessing method
+		$currentBlock =& $compiler->getCurrentBlock();
+		$currentBlock['params']['tplPointer'] = $compiler->getPointer();
+
+		return '';
+	}
+
+	public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content)
+	{
+		$params = $compiler->getCompiledParams($params);
+		$tpl = $compiler->getTemplateSource($params['tplPointer']);
+
+		// assigns params
+		$from = $params['from'];
+		$name = $params['name'];
+		$step = $params['step'];
+		$to = $params['to'];
+
+ 		// evaluates which global variables have to be computed
+		$varName = '$dwoo.for.'.trim($name, '"\'').'.';
+		$shortVarName = '$.for.'.trim($name, '"\'').'.';
+		$usesAny = strpos($tpl, $varName) !== false || strpos($tpl, $shortVarName) !== false;
+		$usesFirst = strpos($tpl, $varName.'first') !== false || strpos($tpl, $shortVarName.'first') !== false;
+		$usesLast = strpos($tpl, $varName.'last') !== false || strpos($tpl, $shortVarName.'last') !== false;
+		$usesIndex = strpos($tpl, $varName.'index') !== false || strpos($tpl, $shortVarName.'index') !== false;
+		$usesIteration = $usesFirst || $usesLast || strpos($tpl, $varName.'iteration') !== false || strpos($tpl, $shortVarName.'iteration') !== false;
+		$usesShow = strpos($tpl, $varName.'show') !== false || strpos($tpl, $shortVarName.'show') !== false;
+		$usesTotal = $usesLast || strpos($tpl, $varName.'total') !== false || strpos($tpl, $shortVarName.'total') !== false;
+
+		if (strpos($name, '$this->scope[') !== false) {
+			$usesAny = $usesFirst = $usesLast = $usesIndex = $usesIteration = $usesShow = $usesTotal = true;
+		}
+
+		// gets foreach id
+		$cnt = self::$cnt++;
+
+		// builds pre processing output for
+		$out = Dwoo_Compiler::PHP_OPEN . "\n".'$_for'.$cnt.'_from = '.$from.';'.
+										"\n".'$_for'.$cnt.'_to = '.$to.';'.
+										"\n".'$_for'.$cnt.'_step = abs('.$step.');'.
+										"\n".'if (is_numeric($_for'.$cnt.'_from) && !is_numeric($_for'.$cnt.'_to)) { $this->triggerError(\'For requires the <em>to</em> parameter when using a numerical <em>from</em>\'); }'.
+										"\n".'$tmp_shows = $this->isArray($_for'.$cnt.'_from, true) || (is_numeric($_for'.$cnt.'_from) && (abs(($_for'.$cnt.'_from - $_for'.$cnt.'_to)/$_for'.$cnt.'_step) !== 0 || $_for'.$cnt.'_from == $_for'.$cnt.'_to));';
+		// adds for properties
+		if ($usesAny) {
+			$out .= "\n".'$this->globals["for"]['.$name.'] = array'."\n(";
+			if ($usesIndex) $out .="\n\t".'"index"		=> 0,';
+			if ($usesIteration) $out .="\n\t".'"iteration"		=> 1,';
+			if ($usesFirst) $out .="\n\t".'"first"		=> null,';
+			if ($usesLast) $out .="\n\t".'"last"		=> null,';
+			if ($usesShow) $out .="\n\t".'"show"		=> $tmp_shows,';
+			if ($usesTotal) $out .="\n\t".'"total"		=> $this->isArray($_for'.$cnt.'_from) ? floor($this->count($_for'.$cnt.'_from) / $_for'.$cnt.'_step) : (is_numeric($_for'.$cnt.'_from) ? abs(($_for'.$cnt.'_to + 1 - $_for'.$cnt.'_from)/$_for'.$cnt.'_step) : 0),';
+			$out.="\n);\n".'$_for'.$cnt.'_glob =& $this->globals["for"]['.$name.'];';
+		}
+		// checks if for must be looped
+		$out .= "\n".'if ($tmp_shows)'."\n{";
+		// set from/to to correct values if an array was given
+		$out .= "\n\t".'if ($this->isArray($_for'.$cnt.'_from'.(isset($params['hasElse']) ? ', true' : '').') == true) {
+		$_for'.$cnt.'_to = is_numeric($_for'.$cnt.'_to) ? $_for'.$cnt.'_to - $_for'.$cnt.'_step : $this->count($_for'.$cnt.'_from) - 1;
+		$_for'.$cnt.'_from = 0;
+	}';
+
+		// if input are pure numbers it shouldn't reorder them, if it's variables it gets too messy though so in that case a counter should be used
+		$reverse = false;
+		$condition = '<=';
+		$incrementer = '+';
+
+		if (preg_match('{^(["\']?)([0-9]+)\1$}', $from, $mN1) && preg_match('{^(["\']?)([0-9]+)\1$}', $to, $mN2)) {
+			$from = (int) $mN1[2];
+			$to = (int) $mN2[2];
+			if ($from > $to) {
+				$reverse = true;
+				$condition = '>=';
+				$incrementer = '-';
+			}
+		}
+
+		// reverse from and to if needed
+		if (!$reverse) {
+			$out .= "\n\t".'if ($_for'.$cnt.'_from > $_for'.$cnt.'_to) {
+				$tmp = $_for'.$cnt.'_from;
+				$_for'.$cnt.'_from = $_for'.$cnt.'_to;
+				$_for'.$cnt.'_to = $tmp;
+			}';
+		}
+
+		$out .= "\n\t".'for ($this->scope['.$name.'] = $_for'.$cnt.'_from; $this->scope['.$name.'] '.$condition.' $_for'.$cnt.'_to; $this->scope['.$name.'] '.$incrementer.'= $_for'.$cnt.'_step)'."\n\t{";
+		// updates properties
+		if ($usesIndex) {
+			$out .="\n\t\t".'$_for'.$cnt.'_glob["index"] = $this->scope['.$name.'];';
+		}
+		if ($usesFirst) {
+			$out .= "\n\t\t".'$_for'.$cnt.'_glob["first"] = (string) ($_for'.$cnt.'_glob["iteration"] === 1);';
+		}
+		if ($usesLast) {
+			$out .= "\n\t\t".'$_for'.$cnt.'_glob["last"] = (string) ($_for'.$cnt.'_glob["iteration"] === $_for'.$cnt.'_glob["total"]);';
+		}
+		$out .= "\n/* -- for start output */\n".Dwoo_Compiler::PHP_CLOSE;
+
+
+		// build post processing output and cache it
+		$postOut = Dwoo_Compiler::PHP_OPEN . '/* -- for end output */';
+		// update properties
+		if ($usesIteration) {
+			$postOut .= "\n\t\t".'$_for'.$cnt.'_glob["iteration"]+=1;';
+		}
+		// end loop
+		$postOut .= "\n\t}\n}\n".Dwoo_Compiler::PHP_CLOSE;
+
+		if (isset($params['hasElse'])) {
+			$postOut .= $params['hasElse'];
+		}
+
+		return $out . $content . $postOut;
+	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/foreach.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/foreach.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/foreach.php	(revision 755)
@@ -0,0 +1,152 @@
+<?php
+
+/**
+ * Similar to the php foreach block, loops over an array
+ *
+ * Note that if you don't provide the item parameter, the key will act as item
+ * <pre>
+ *  * from : the array that you want to iterate over
+ *  * key : variable name for the key (or for the item if item is not defined)
+ *  * item : variable name for each item
+ *  * name : foreach name to access it's iterator variables through {$.foreach.name.var} see {@link http://wiki.dwoo.org/index.php/IteratorVariables} for details
+ * </pre>
+ * Example :
+ *
+ * <code>
+ * {foreach $array val}
+ *   {$val.something}
+ * {/foreach}
+ * </code>
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.1.0
+ * @date       2009-07-18
+ * @package    Dwoo
+ */
+class Dwoo_Plugin_foreach extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Block, Dwoo_IElseable
+{
+	public static $cnt=0;
+
+	public function init($from, $key=null, $item=null, $name='default', $implode=null)
+	{
+	}
+
+	public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type)
+	{
+		// get block params and save the current template pointer to use it in the postProcessing method
+		$currentBlock =& $compiler->getCurrentBlock();
+		$currentBlock['params']['tplPointer'] = $compiler->getPointer();
+
+		return '';
+	}
+
+	public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content)
+	{
+		$params = $compiler->getCompiledParams($params);
+		$tpl = $compiler->getTemplateSource($params['tplPointer']);
+
+		// assigns params
+		$src = $params['from'];
+
+		if ($params['item'] !== 'null') {
+			if ($params['key'] !== 'null') {
+				$key = $params['key'];
+			}
+			$val = $params['item'];
+		} elseif ($params['key'] !== 'null') {
+			$val = $params['key'];
+		} else {
+			throw new Dwoo_Compilation_Exception($compiler, 'Foreach <em>item</em> parameter missing');
+		}
+		$name = $params['name'];
+
+		if (substr($val, 0, 1) !== '"' && substr($val, 0, 1) !== '\'') {
+			throw new Dwoo_Compilation_Exception($compiler, 'Foreach <em>item</em> parameter must be of type string');
+		}
+		if (isset($key) && substr($val, 0, 1) !== '"' && substr($val, 0, 1) !== '\'') {
+			throw new Dwoo_Compilation_Exception($compiler, 'Foreach <em>key</em> parameter must be of type string');
+		}
+
+		// evaluates which global variables have to be computed
+		$varName = '$dwoo.foreach.'.trim($name, '"\'').'.';
+		$shortVarName = '$.foreach.'.trim($name, '"\'').'.';
+		$usesAny = strpos($tpl, $varName) !== false || strpos($tpl, $shortVarName) !== false;
+		$usesFirst = strpos($tpl, $varName.'first') !== false || strpos($tpl, $shortVarName.'first') !== false;
+		$usesLast = strpos($tpl, $varName.'last') !== false || strpos($tpl, $shortVarName.'last') !== false;
+		$usesIndex = $usesFirst || strpos($tpl, $varName.'index') !== false || strpos($tpl, $shortVarName.'index') !== false;
+		$usesIteration = $usesLast || strpos($tpl, $varName.'iteration') !== false || strpos($tpl, $shortVarName.'iteration') !== false;
+		$usesShow = strpos($tpl, $varName.'show') !== false || strpos($tpl, $shortVarName.'show') !== false;
+		$usesTotal = $usesLast || strpos($tpl, $varName.'total') !== false || strpos($tpl, $shortVarName.'total') !== false;
+
+		if (strpos($name, '$this->scope[') !== false) {
+			$usesAny = $usesFirst = $usesLast = $usesIndex = $usesIteration = $usesShow = $usesTotal = true;
+		}
+
+		// override globals vars if implode is used
+		if ($params['implode'] !== 'null') {
+			$implode = $params['implode'];
+			$usesAny = true;
+			$usesLast = true;
+			$usesIteration = true;
+			$usesTotal = true;
+		}
+
+		// gets foreach id
+		$cnt = self::$cnt++;
+
+		// build pre content output
+		$pre = Dwoo_Compiler::PHP_OPEN . "\n".'$_fh'.$cnt.'_data = '.$src.';';
+		// adds foreach properties
+		if ($usesAny) {
+			$pre .= "\n".'$this->globals["foreach"]['.$name.'] = array'."\n(";
+			if ($usesIndex) $pre .="\n\t".'"index"		=> 0,';
+			if ($usesIteration) $pre .="\n\t".'"iteration"		=> 1,';
+			if ($usesFirst) $pre .="\n\t".'"first"		=> null,';
+			if ($usesLast) $pre .="\n\t".'"last"		=> null,';
+			if ($usesShow) $pre .="\n\t".'"show"		=> $this->isArray($_fh'.$cnt.'_data, true),';
+			if ($usesTotal) $pre .="\n\t".'"total"		=> $this->count($_fh'.$cnt.'_data),';
+			$pre.="\n);\n".'$_fh'.$cnt.'_glob =& $this->globals["foreach"]['.$name.'];';
+		}
+		// checks if foreach must be looped
+		$pre .= "\n".'if ($this->isTraversable($_fh'.$cnt.'_data'.(isset($params['hasElse']) ? ', true' : '').') == true)'."\n{";
+		// iterates over keys
+		$pre .= "\n\t".'foreach ($_fh'.$cnt.'_data as '.(isset($key)?'$this->scope['.$key.']=>':'').'$this->scope['.$val.'])'."\n\t{";
+		// updates properties
+		if ($usesFirst) {
+			$pre .= "\n\t\t".'$_fh'.$cnt.'_glob["first"] = (string) ($_fh'.$cnt.'_glob["index"] === 0);';
+		}
+		if ($usesLast) {
+			$pre .= "\n\t\t".'$_fh'.$cnt.'_glob["last"] = (string) ($_fh'.$cnt.'_glob["iteration"] === $_fh'.$cnt.'_glob["total"]);';
+		}
+		$pre .= "\n/* -- foreach start output */\n".Dwoo_Compiler::PHP_CLOSE;
+
+		// build post content output
+		$post = Dwoo_Compiler::PHP_OPEN . "\n";
+
+		if (isset($implode)) {
+			$post .= '/* -- implode */'."\n".'if (!$_fh'.$cnt.'_glob["last"]) {'.
+				"\n\t".'echo '.$implode.";\n}\n";
+		}
+		$post .= '/* -- foreach end output */';
+		// update properties
+		if ($usesIndex) {
+			$post.="\n\t\t".'$_fh'.$cnt.'_glob["index"]+=1;';
+		}
+		if ($usesIteration) {
+			$post.="\n\t\t".'$_fh'.$cnt.'_glob["iteration"]+=1;';
+		}
+		// end loop
+		$post .= "\n\t}\n}".Dwoo_Compiler::PHP_CLOSE;
+		if (isset($params['hasElse'])) {
+			$post .= $params['hasElse'];
+		}
+
+		return $pre . $content . $post;
+	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/foreachelse.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/foreachelse.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/foreachelse.php	(revision 755)
@@ -0,0 +1,43 @@
+<?php
+
+/**
+ * This plugin serves as a {else} block specifically for the {foreach} plugin.
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+class Dwoo_Plugin_foreachelse extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Block
+{
+	public function init()
+	{
+	}
+
+	public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type)
+	{
+		$with =& $compiler->findBlock('foreach', true);
+
+		$params['initialized'] = true;
+		$compiler->injectBlock($type, $params);
+
+		return '';
+	}
+
+	public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content)
+	{
+		if (!isset($params['initialized'])) {
+			return '';
+		}
+
+		$block =& $compiler->getCurrentBlock();
+		$block['params']['hasElse'] = Dwoo_Compiler::PHP_OPEN."else {\n".Dwoo_Compiler::PHP_CLOSE . $content . Dwoo_Compiler::PHP_OPEN."\n}".Dwoo_Compiler::PHP_CLOSE;
+		return '';
+	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/forelse.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/forelse.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/forelse.php	(revision 755)
@@ -0,0 +1,43 @@
+<?php
+
+/**
+ * This plugin serves as a {else} block specifically for the {for} plugin.
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+class Dwoo_Plugin_forelse extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Block
+{
+	public function init()
+	{
+	}
+
+	public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type)
+	{
+		$with =& $compiler->findBlock('for', true);
+
+		$params['initialized'] = true;
+		$compiler->injectBlock($type, $params);
+
+		return '';
+	}
+
+	public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content)
+	{
+		if (!isset($params['initialized'])) {
+			return '';
+		}
+
+		$block =& $compiler->getCurrentBlock();
+		$block['params']['hasElse'] = Dwoo_Compiler::PHP_OPEN."else {\n".Dwoo_Compiler::PHP_CLOSE . $content . Dwoo_Compiler::PHP_OPEN."\n}".Dwoo_Compiler::PHP_CLOSE;
+		return '';
+	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/if.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/if.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/if.php	(revision 755)
@@ -0,0 +1,227 @@
+<?php
+
+/**
+ * Conditional block, the syntax is very similar to the php one, allowing () || && and
+ * other php operators. Additional operators and their equivalent php syntax are as follow :
+ *
+ * eq -> ==
+ * neq or ne -> !=
+ * gte or ge -> >=
+ * lte or le -> <=
+ * gt -> >
+ * lt -> <
+ * mod -> %
+ * not -> !
+ * X is [not] div by Y -> (X % Y) == 0
+ * X is [not] even [by Y] -> (X % 2) == 0 or ((X/Y) % 2) == 0
+ * X is [not] odd [by Y] -> (X % 2) != 0 or ((X/Y) % 2) != 0
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+class Dwoo_Plugin_if extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Block, Dwoo_IElseable
+{
+	public function init(array $rest)
+	{
+	}
+
+	public static function replaceKeywords(array $params, array $tokens, Dwoo_Compiler $compiler)
+	{
+		$p = array();
+
+		reset($params);
+		while (list($k,$v) = each($params)) {
+			$v = (string) $v;
+			if(substr($v, 0, 1) === '"' || substr($v, 0, 1) === '\'') {
+				$vmod = strtolower(substr($v, 1, -1));
+			} else {
+				$vmod = strtolower($v);
+			}
+			switch($vmod) {
+
+			case 'and':
+				if ($tokens[$k] === Dwoo_Compiler::T_UNQUOTED_STRING) {
+					$p[] = '&&';
+				} else {
+					$p[] = $v;
+				}
+				break;
+			case 'or':
+				if ($tokens[$k] === Dwoo_Compiler::T_UNQUOTED_STRING) {
+					$p[] = '||';
+				} else {
+					$p[] = $v;
+				}
+				break;
+			case 'eq':
+				if ($tokens[$k] === Dwoo_Compiler::T_UNQUOTED_STRING) {
+					$p[] = '==';
+				} else {
+					$p[] = $v;
+				}
+				break;
+			case 'ne':
+			case 'neq':
+				if ($tokens[$k] === Dwoo_Compiler::T_UNQUOTED_STRING) {
+					$p[] = '!=';
+				} else {
+					$p[] = $v;
+				}
+				break;
+			case 'gte':
+			case 'ge':
+				if ($tokens[$k] === Dwoo_Compiler::T_UNQUOTED_STRING) {
+					$p[] = '>=';
+				} else {
+					$p[] = $v;
+				}
+				break;
+			case 'lte':
+			case 'le':
+				if ($tokens[$k] === Dwoo_Compiler::T_UNQUOTED_STRING) {
+					$p[] = '<=';
+				} else {
+					$p[] = $v;
+				}
+				break;
+			case 'gt':
+				if ($tokens[$k] === Dwoo_Compiler::T_UNQUOTED_STRING) {
+					$p[] = '>';
+				} else {
+					$p[] = $v;
+				}
+				break;
+			case 'lt':
+				if ($tokens[$k] === Dwoo_Compiler::T_UNQUOTED_STRING) {
+					$p[] = '<';
+				} else {
+					$p[] = $v;
+				}
+				break;
+			case 'mod':
+				if ($tokens[$k] === Dwoo_Compiler::T_UNQUOTED_STRING) {
+					$p[] = '%';
+				} else {
+					$p[] = $v;
+				}
+				break;
+			case 'not':
+				if ($tokens[$k] === Dwoo_Compiler::T_UNQUOTED_STRING) {
+					$p[] = '!';
+				} else {
+					$p[] = $v;
+				}
+				break;
+			case '<>':
+				$p[] = '!=';
+				break;
+			case '==':
+			case '!=':
+			case '>=':
+			case '<=':
+			case '>':
+			case '<':
+			case '===':
+			case '!==':
+			case '%':
+			case '!':
+				$p[] = $vmod;
+				break;
+			case 'is':
+				if ($tokens[$k] !== Dwoo_Compiler::T_UNQUOTED_STRING) {
+					$p[] = $v;
+					break;
+				}
+				if (isset($params[$k+1]) && strtolower(trim($params[$k+1], '"\'')) === 'not' && $tokens[$k+1] === Dwoo_Compiler::T_UNQUOTED_STRING) {
+					$negate = true;
+					next($params);
+				} else {
+					$negate = false;
+				}
+				$ptr = 1+(int)$negate;
+				if ($tokens[$k+$ptr] !== Dwoo_Compiler::T_UNQUOTED_STRING) {
+					break;
+				}
+				if (!isset($params[$k+$ptr])) {
+					$params[$k+$ptr] = '';
+				} else {
+					$params[$k+$ptr] = trim($params[$k+$ptr], '"\'');
+				}
+				switch($params[$k+$ptr]) {
+
+				case 'div':
+					if (isset($params[$k+$ptr+1]) && strtolower(trim($params[$k+$ptr+1], '"\'')) === 'by') {
+						$p[] = ' % '.$params[$k+$ptr+2].' '.($negate?'!':'=').'== 0';
+						next($params);
+						next($params);
+						next($params);
+					} else {
+						throw new Dwoo_Compilation_Exception($compiler, 'If : Syntax error : syntax should be "if $a is [not] div by $b", found '.$params[$k-1].' is '.($negate?'not ':'').'div '.$params[$k+$ptr+1].' '.$params[$k+$ptr+2]);
+					}
+					break;
+				case 'even':
+					$a = array_pop($p);
+					if (isset($params[$k+$ptr+1]) && strtolower(trim($params[$k+$ptr+1], '"\'')) === 'by') {
+						$b = $params[$k+$ptr+2];
+						$p[] = '('.$a .' / '.$b.') % 2 '.($negate?'!':'=').'== 0';
+						next($params);
+						next($params);
+					} else {
+						$p[] = $a.' % 2 '.($negate?'!':'=').'== 0';
+					}
+					next($params);
+					break;
+				case 'odd':
+					$a = array_pop($p);
+					if (isset($params[$k+$ptr+1]) && strtolower(trim($params[$k+$ptr+1], '"\'')) === 'by') {
+						$b = $params[$k+$ptr+2];
+						$p[] = '('.$a .' / '.$b.') % 2 '.($negate?'=':'!').'== 0';
+						next($params);
+						next($params);
+					} else {
+						$p[] = $a.' % 2 '.($negate?'=':'!').'== 0';
+					}
+					next($params);
+					break;
+				default:
+					throw new Dwoo_Compilation_Exception($compiler, 'If : Syntax error : syntax should be "if $a is [not] (div|even|odd) [by $b]", found '.$params[$k-1].' is '.$params[$k+$ptr+1]);
+
+				}
+				break;
+			default:
+				$p[] = $v;
+
+			}
+		}
+
+		return $p;
+	}
+
+	public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type)
+	{
+		return '';
+	}
+
+	public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content)
+	{
+		$tokens = $compiler->getParamTokens($params);
+		$params = $compiler->getCompiledParams($params);
+		$pre = Dwoo_Compiler::PHP_OPEN.'if ('.implode(' ', self::replaceKeywords($params['*'], $tokens['*'], $compiler)).") {\n".Dwoo_Compiler::PHP_CLOSE;
+
+		$post = Dwoo_Compiler::PHP_OPEN."\n}".Dwoo_Compiler::PHP_CLOSE;
+
+		if (isset($params['hasElse'])) {
+			$post .= $params['hasElse'];
+		}
+
+		return $pre . $content . $post;
+	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/loop.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/loop.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/loop.php	(revision 755)
@@ -0,0 +1,128 @@
+<?php
+
+/**
+ * Loops over an array and moves the scope into each value, allowing for shorter loop constructs
+ *
+ * Note that to access the array key within a loop block, you have to use the {$_key} variable,
+ * you can not specify it yourself.
+ * <pre>
+ *  * from : the array that you want to iterate over
+ *  * name : loop name to access it's iterator variables through {$.loop.name.var} see {@link http://wiki.dwoo.org/index.php/IteratorVariables} for details
+ * </pre>
+ * Example :
+ *
+ * instead of a foreach block such as :
+ *
+ * <code>
+ * {foreach $variable value}
+ *   {$value.foo} {$value.bar}
+ * {/foreach}
+ * </code>
+ *
+ * you can do :
+ *
+ * <code>
+ * {loop $variable}
+ *   {$foo} {$bar}
+ * {/loop}
+ * </code>
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.1.0
+ * @date       2009-07-18
+ * @package    Dwoo
+ */
+class Dwoo_Plugin_loop extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Block, Dwoo_IElseable
+{
+	public static $cnt=0;
+
+	public function init($from, $name='default')
+	{
+	}
+
+	public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type)
+	{
+		// get block params and save the current template pointer to use it in the postProcessing method
+		$currentBlock =& $compiler->getCurrentBlock();
+		$currentBlock['params']['tplPointer'] = $compiler->getPointer();
+
+		return '';
+	}
+
+	public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content)
+	{
+		$params = $compiler->getCompiledParams($params);
+		$tpl = $compiler->getTemplateSource($params['tplPointer']);
+
+		// assigns params
+		$src = $params['from'];
+		$name = $params['name'];
+
+		// evaluates which global variables have to be computed
+		$varName = '$dwoo.loop.'.trim($name, '"\'').'.';
+		$shortVarName = '$.loop.'.trim($name, '"\'').'.';
+		$usesAny = strpos($tpl, $varName) !== false || strpos($tpl, $shortVarName) !== false;
+		$usesFirst = strpos($tpl, $varName.'first') !== false || strpos($tpl, $shortVarName.'first') !== false;
+		$usesLast = strpos($tpl, $varName.'last') !== false || strpos($tpl, $shortVarName.'last') !== false;
+		$usesIndex = $usesFirst || strpos($tpl, $varName.'index') !== false || strpos($tpl, $shortVarName.'index') !== false;
+		$usesIteration = $usesLast || strpos($tpl, $varName.'iteration') !== false || strpos($tpl, $shortVarName.'iteration') !== false;
+		$usesShow = strpos($tpl, $varName.'show') !== false || strpos($tpl, $shortVarName.'show') !== false;
+		$usesTotal = $usesLast || strpos($tpl, $varName.'total') !== false || strpos($tpl, $shortVarName.'total') !== false;
+
+		if (strpos($name, '$this->scope[') !== false) {
+			$usesAny = $usesFirst = $usesLast = $usesIndex = $usesIteration = $usesShow = $usesTotal = true;
+		}
+
+		// gets foreach id
+		$cnt = self::$cnt++;
+
+		// builds pre processing output
+		$pre = Dwoo_Compiler::PHP_OPEN . "\n".'$_loop'.$cnt.'_data = '.$src.';';
+		// adds foreach properties
+		if ($usesAny) {
+			$pre .= "\n".'$this->globals["loop"]['.$name.'] = array'."\n(";
+			if ($usesIndex) $pre .="\n\t".'"index"		=> 0,';
+			if ($usesIteration) $pre .="\n\t".'"iteration"		=> 1,';
+			if ($usesFirst) $pre .="\n\t".'"first"		=> null,';
+			if ($usesLast) $pre .="\n\t".'"last"		=> null,';
+			if ($usesShow) $pre .="\n\t".'"show"		=> $this->isTraversable($_loop'.$cnt.'_data, true),';
+			if ($usesTotal) $pre .="\n\t".'"total"		=> $this->count($_loop'.$cnt.'_data),';
+			$pre.="\n);\n".'$_loop'.$cnt.'_glob =& $this->globals["loop"]['.$name.'];';
+		}
+		// checks if the loop must be looped
+		$pre .= "\n".'if ($this->isTraversable($_loop'.$cnt.'_data'.(isset($params['hasElse']) ? ', true' : '').') == true)'."\n{";
+		// iterates over keys
+		$pre .= "\n\t".'foreach ($_loop'.$cnt.'_data as $tmp_key => $this->scope["-loop-"])'."\n\t{";
+		// updates properties
+		if ($usesFirst) {
+			$pre .= "\n\t\t".'$_loop'.$cnt.'_glob["first"] = (string) ($_loop'.$cnt.'_glob["index"] === 0);';
+		}
+		if ($usesLast) {
+			$pre .= "\n\t\t".'$_loop'.$cnt.'_glob["last"] = (string) ($_loop'.$cnt.'_glob["iteration"] === $_loop'.$cnt.'_glob["total"]);';
+		}
+		$pre .= "\n\t\t".'$_loop'.$cnt.'_scope = $this->setScope(array("-loop-"));' . "\n/* -- loop start output */\n".Dwoo_Compiler::PHP_CLOSE;
+
+		// build post processing output and cache it
+		$post = Dwoo_Compiler::PHP_OPEN . "\n".'/* -- loop end output */'."\n\t\t".'$this->setScope($_loop'.$cnt.'_scope, true);';
+		// update properties
+		if ($usesIndex) {
+			$post.="\n\t\t".'$_loop'.$cnt.'_glob["index"]+=1;';
+		}
+		if ($usesIteration) {
+			$post.="\n\t\t".'$_loop'.$cnt.'_glob["iteration"]+=1;';
+		}
+		// end loop
+		$post .= "\n\t}\n}\n" . Dwoo_Compiler::PHP_CLOSE;
+		if (isset($params['hasElse'])) {
+			$post .= $params['hasElse'];
+		}
+
+		return $pre . $content . $post;
+	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/section.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/section.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/section.php	(revision 755)
@@ -0,0 +1,131 @@
+<?php
+
+/**
+ * Compatibility plugin for smarty templates, do not use otherwise, this is deprecated.
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+class Dwoo_Plugin_section extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Block, Dwoo_IElseable
+{
+	public static $cnt=0;
+
+	public function init($name, $loop, $start = null, $step = null, $max = null, $show = true)
+	{
+	}
+
+	public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type)
+	{
+		return '';
+	}
+
+	public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content)
+	{
+		$output = Dwoo_Compiler::PHP_OPEN;
+		$params = $compiler->getCompiledParams($params);
+
+		// assigns params
+		$loop = $params['loop'];
+		$start = $params['start'];
+		$max = $params['max'];
+		$name = $params['name'];
+		$step = $params['step'];
+		$show = $params['show'];
+
+		// gets unique id
+		$cnt = self::$cnt++;
+
+		$output .= '$this->globals[\'section\']['.$name.'] = array();'."\n".
+		'$_section'.$cnt.' =& $this->globals[\'section\']['.$name.'];'."\n";
+
+		if ($loop !== 'null') {
+			$output .= '$_section'.$cnt.'[\'loop\'] = is_array($tmp = '.$loop.') ? count($tmp) : max(0, (int) $tmp);'."\n";
+		} else {
+			$output .= '$_section'.$cnt.'[\'loop\'] = 1;'."\n";
+		}
+
+		if ($show !== 'null') {
+			$output .= '$_section'.$cnt.'[\'show\'] = '.$show.";\n";
+		} else {
+			$output .= '$_section'.$cnt.'[\'show\'] = true;'."\n";
+		}
+
+		if ($name !== 'null') {
+			$output .= '$_section'.$cnt.'[\'name\'] = '.$name.";\n";
+		} else {
+			$output .= '$_section'.$cnt.'[\'name\'] = true;'."\n";
+		}
+
+		if ($max !== 'null') {
+			$output .= '$_section'.$cnt.'[\'max\'] = (int)'.$max.";\n".
+						'if($_section'.$cnt.'[\'max\'] < 0) { $_section'.$cnt.'[\'max\'] = $_section'.$cnt.'[\'loop\']; }'."\n";
+		} else {
+			$output .= '$_section'.$cnt.'[\'max\'] = $_section'.$cnt.'[\'loop\'];'."\n";
+		}
+
+		if ($step !== 'null') {
+			$output .= '$_section'.$cnt.'[\'step\'] = (int)'.$step.' == 0 ? 1 : (int) '.$step.";\n";
+		} else {
+			$output .= '$_section'.$cnt.'[\'step\'] = 1;'."\n";
+		}
+
+		if ($start !== 'null') {
+			$output .= '$_section'.$cnt.'[\'start\'] = (int)'.$start.";\n";
+		} else {
+			$output .= '$_section'.$cnt.'[\'start\'] = $_section'.$cnt.'[\'step\'] > 0 ? 0 : $_section'.$cnt.'[\'loop\'] - 1;'."\n".
+						'if ($_section'.$cnt.'[\'start\'] < 0) { $_section'.$cnt.'[\'start\'] = max($_section'.$cnt.'[\'step\'] > 0 ? 0 : -1, $_section'.$cnt.'[\'loop\'] + $_section'.$cnt.'[\'start\']); } '."\n".
+						'else { $_section'.$cnt.'[\'start\'] = min($_section'.$cnt.'[\'start\'], $_section'.$cnt.'[\'step\'] > 0 ? $_section'.$cnt.'[\'loop\'] : $_section'.$cnt.'[\'loop\'] -1); }'."\n";
+		}
+
+/*		if ($usesAny) {
+			$output .= "\n".'$this->globals["section"]['.$name.'] = array'."\n(";
+			if ($usesIndex) $output .="\n\t".'"index"		=> 0,';
+			if ($usesIteration) $output .="\n\t".'"iteration"		=> 1,';
+			if ($usesFirst) $output .="\n\t".'"first"		=> null,';
+			if ($usesLast) $output .="\n\t".'"last"		=> null,';
+			if ($usesShow) $output .="\n\t".'"show"		=> ($this->isArray($_for'.$cnt.'_from, true)) || (is_numeric($_for'.$cnt.'_from) && $_for'.$cnt.'_from != $_for'.$cnt.'_to),';
+			if ($usesTotal) $output .="\n\t".'"total"		=> $this->isArray($_for'.$cnt.'_from) ? $this->count($_for'.$cnt.'_from) - $_for'.$cnt.'_skip : (is_numeric($_for'.$cnt.'_from) ? abs(($_for'.$cnt.'_to + 1 - $_for'.$cnt.'_from)/$_for'.$cnt.'_step) : 0),';
+			$out.="\n);\n".'$_section'.$cnt.'[\'glob\'] =& $this->globals["section"]['.$name.'];'."\n\n";
+		}
+*/
+
+		$output .= 'if ($_section'.$cnt.'[\'show\']) {'."\n";
+		if ($start === 'null' && $step === 'null' && $max === 'null') {
+			$output .= '	$_section'.$cnt.'[\'total\'] = $_section'.$cnt.'[\'loop\'];'."\n";
+		} else {
+			$output .= '	$_section'.$cnt.'[\'total\'] = min(ceil(($_section'.$cnt.'[\'step\'] > 0 ? $_section'.$cnt.'[\'loop\'] - $_section'.$cnt.'[\'start\'] : $_section'.$cnt.'[\'start\'] + 1) / abs($_section'.$cnt.'[\'step\'])), $_section'.$cnt.'[\'max\']);'."\n";
+		}
+		$output .= '	if ($_section'.$cnt.'[\'total\'] == 0) {'."\n".
+				   '		$_section'.$cnt.'[\'show\'] = false;'."\n".
+				   '	}'."\n".
+				   '} else {'."\n".
+				   '	$_section'.$cnt.'[\'total\'] = 0;'."\n}\n";
+		$output .= 'if ($_section'.$cnt.'[\'show\']) {'."\n";
+		$output .= "\t".'for ($this->scope['.$name.'] = $_section'.$cnt.'[\'start\'], $_section'.$cnt.'[\'iteration\'] = 1; '.
+				 	'$_section'.$cnt.'[\'iteration\'] <= $_section'.$cnt.'[\'total\']; '.
+				 	'$this->scope['.$name.'] += $_section'.$cnt.'[\'step\'], $_section'.$cnt.'[\'iteration\']++) {'."\n";
+		$output .= "\t\t".'$_section'.$cnt.'[\'rownum\'] = $_section'.$cnt.'[\'iteration\'];'."\n";
+		$output .= "\t\t".'$_section'.$cnt.'[\'index_prev\'] = $this->scope['.$name.'] - $_section'.$cnt.'[\'step\'];'."\n";
+		$output .= "\t\t".'$_section'.$cnt.'[\'index_next\'] = $this->scope['.$name.'] + $_section'.$cnt.'[\'step\'];'."\n";
+		$output .= "\t\t".'$_section'.$cnt.'[\'first\']      = ($_section'.$cnt.'[\'iteration\'] == 1);'."\n";
+		$output .= "\t\t".'$_section'.$cnt.'[\'last\']       = ($_section'.$cnt.'[\'iteration\'] == $_section'.$cnt.'[\'total\']);'."\n";
+
+		$output .= Dwoo_Compiler::PHP_CLOSE . $content . Dwoo_Compiler::PHP_OPEN;
+
+		$output .= "\n\t}\n} " . Dwoo_Compiler::PHP_CLOSE;
+
+		if (isset($params['hasElse'])) {
+			$output .= $params['hasElse'];
+		}
+
+		return $output;
+	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/smartyinterface.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/smartyinterface.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/smartyinterface.php	(revision 755)
@@ -0,0 +1,59 @@
+<?php
+
+/**
+ * Smarty compatibility layer for block plugins, this is used internally and you should not call it
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+class Dwoo_Plugin_smartyinterface extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Block
+{
+	public function init($__funcname, $__functype, array $rest=array()) {}
+
+	public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type)
+	{
+		$params = $compiler->getCompiledParams($params);
+		$func = $params['__funcname'];
+		$pluginType = $params['__functype'];
+		$params = $params['*'];
+
+		if ($pluginType & Dwoo_Core::CUSTOM_PLUGIN) {
+			$customPlugins = $compiler->getDwoo()->getCustomPlugins();
+			$callback = $customPlugins[$func]['callback'];
+			if (is_array($callback)) {
+				if (is_object($callback[0])) {
+					$callback = '$this->customPlugins[\''.$func.'\'][0]->'.$callback[1].'(';
+				} else {
+					$callback = ''.$callback[0].'::'.$callback[1].'(';
+				}
+			} else {
+				$callback = $callback.'(';
+			}
+		} else {
+			$callback = 'smarty_block_'.$func.'(';
+		}
+
+		$paramsOut = '';
+		foreach ($params as $i=>$p) {
+			$paramsOut .= var_export($i, true).' => '.$p.',';
+		}
+
+		$curBlock =& $compiler->getCurrentBlock();
+		$curBlock['params']['postOut'] = Dwoo_Compiler::PHP_OPEN.' $_block_content = ob_get_clean(); $_block_repeat=false; echo '.$callback.'$_tag_stack[count($_tag_stack)-1], $_block_content, $this, $_block_repeat); } array_pop($_tag_stack);'.Dwoo_Compiler::PHP_CLOSE;
+
+		return Dwoo_Compiler::PHP_OPEN.$prepend.' if (!isset($_tag_stack)){ $_tag_stack = array(); } $_tag_stack[] = array('.$paramsOut.'); $_block_repeat=true; '.$callback.'$_tag_stack[count($_tag_stack)-1], null, $this, $_block_repeat); while ($_block_repeat) { ob_start();'.Dwoo_Compiler::PHP_CLOSE;
+	}
+
+	public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content)
+	{
+		return $content . $params['postOut'];
+	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/strip.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/strip.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/strip.php	(revision 755)
@@ -0,0 +1,50 @@
+<?php
+
+/**
+ * Strips the spaces at the beginning and end of each line and also the line breaks
+ * <pre>
+ *  * mode : sets the content being stripped, available mode are 'default' or 'js'
+ *    for javascript, which strips the comments to prevent syntax errors
+ * </pre>
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.1.0
+ * @date       2009-07-18
+ * @package    Dwoo
+ */
+class Dwoo_Plugin_strip extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Block
+{
+	public function init($mode = "default")
+	{
+	}
+
+	public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type)
+	{
+		return '';
+	}
+
+	public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content)
+	{
+		$params = $compiler->getCompiledParams($params);
+
+		$mode = trim($params['mode'], '"\'');
+		switch ($mode) {
+			case 'js':
+			case 'javascript':
+				$content = preg_replace('#(?<!:)//\s[^\r\n]*|/\*.*?\*/#s','', $content);
+
+			case 'default':
+			default:
+		}
+
+		$content = preg_replace(array("/\n/","/\r/",'/(<\?(?:php)?|<%)\s*/'), array('','','$1 '), preg_replace('#^\s*(.+?)\s*$#m', '$1', $content));
+
+		return $content;
+	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/template.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/template.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/template.php	(revision 755)
@@ -0,0 +1,88 @@
+<?php
+
+/**
+ * Defines a sub-template that can then be called (even recursively) with the defined arguments
+ * <pre>
+ *  * name : template name
+ *  * rest : list of arguments and optional default values
+ * </pre>
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.1.0
+ * @date       2009-07-18
+ * @package    Dwoo
+ */
+class Dwoo_Plugin_template extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Block
+{
+	public function init($name, array $rest = array())
+	{
+	}
+
+	public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type)
+	{
+		$params = $compiler->getCompiledParams($params);
+		$parsedParams = array();
+		if (!isset($params['*']))
+			$params['*'] = array();
+		foreach ($params['*'] as $param=>$defValue) {
+			if (is_numeric($param)) {
+				$param = $defValue;
+				$defValue = null;
+			}
+			$param = trim($param, '\'"');
+			if (!preg_match('#^[a-z0-9_]+$#i', $param)) {
+				throw new Dwoo_Compilation_Exception($compiler, 'Function : parameter names must contain only A-Z, 0-9 or _');
+			}
+			$parsedParams[$param] = $defValue;
+		}
+		$params['name'] = substr($params['name'], 1, -1);
+		$params['*'] = $parsedParams;
+		$params['uuid'] = uniqid();
+		$compiler->addTemplatePlugin($params['name'], $parsedParams, $params['uuid']);
+		$currentBlock =& $compiler->getCurrentBlock();
+		$currentBlock['params'] = $params;
+		return '';
+	}
+
+	public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content)
+	{
+		$paramstr = 'Dwoo_Core $dwoo';
+		$init = 'static $_callCnt = 0;'."\n".
+		'$dwoo->scope[\' '.$params['uuid'].'\'.$_callCnt] = array();'."\n".
+		'$_scope = $dwoo->setScope(array(\' '.$params['uuid'].'\'.($_callCnt++)));'."\n";
+		$cleanup = '/* -- template end output */ $dwoo->setScope($_scope, true);';
+		foreach ($params['*'] as $param=>$defValue) {
+			if ($defValue === null) {
+				$paramstr.=', $'.$param;
+			} else {
+				$paramstr.=', $'.$param.' = '.$defValue;
+			}
+			$init .= '$dwoo->scope[\''.$param.'\'] = $'.$param.";\n";
+		}
+		$init .= '/* -- template start output */';
+
+		$funcName = 'Dwoo_Plugin_'.$params['name'].'_'.$params['uuid'];
+
+		$search = array(
+			'$this->charset',
+			'$this->',
+			'$this,',
+		);
+		$replacement = array(
+			'$dwoo->getCharset()',
+			'$dwoo->',
+			'$dwoo,',
+		);
+		$content = str_replace($search, $replacement, $content);
+
+		$body = 'if (!function_exists(\''.$funcName."')) {\nfunction ".$funcName.'('.$paramstr.') {'."\n$init".Dwoo_Compiler::PHP_CLOSE.
+			$prepend.$content.$append.
+			Dwoo_Compiler::PHP_OPEN.$cleanup."\n}\n}";
+		$compiler->addTemplatePlugin($params['name'], $params['*'], $params['uuid'], $body);
+	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/textformat.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/textformat.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/textformat.php	(revision 755)
@@ -0,0 +1,94 @@
+<?php
+
+/**
+ * Formats a string to the given format, you can wrap lines at a certain
+ * length and indent them
+ * <pre>
+ *  * wrap : maximum line length
+ *  * wrap_char : the character(s) to use to break the line
+ *  * wrap_cut : if true, the words that are longer than $wrap are cut instead of overflowing
+ *  * indent : amount of $indent_char to insert before every line
+ *  * indent_char : character(s) to insert before every line
+ *  * indent_first : amount of additional $indent_char to insert before the first line of each paragraphs
+ *  * style : some predefined formatting styles that set up every required variables, can be "email" or "html"
+ *  * assign : if set, the formatted text is assigned to that variable instead of being output
+ * </pre>
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+class Dwoo_Plugin_textformat extends Dwoo_Block_Plugin
+{
+	protected $wrap;
+	protected $wrapChar;
+	protected $wrapCut;
+	protected $indent;
+	protected $indChar;
+	protected $indFirst;
+	protected $assign;
+
+	public function init($wrap=80, $wrap_char="\r\n", $wrap_cut=false, $indent=0, $indent_char=" ", $indent_first=0, $style="", $assign="")
+	{
+		if ($indent_char === 'tab') {
+			$indent_char = "\t";
+		}
+
+		switch($style) {
+
+		case 'email':
+			$wrap = 72;
+			$indent_first = 0;
+			break;
+		case 'html':
+			$wrap_char = '<br />';
+			$indent_char = $indent_char == "\t" ? '&nbsp;&nbsp;&nbsp;&nbsp;':'&nbsp;';
+			break;
+
+		}
+
+		$this->wrap = (int) $wrap;
+		$this->wrapChar = (string) $wrap_char;
+		$this->wrapCut = (bool) $wrap_cut;
+		$this->indent = (int) $indent;
+		$this->indChar = (string) $indent_char;
+		$this->indFirst = (int) $indent_first + $this->indent;
+		$this->assign = (string) $assign;
+	}
+
+	public function process()
+	{
+		// gets paragraphs
+		$pgs = explode("\n", str_replace(array("\r\n", "\r"), "\n", $this->buffer));
+
+		while (list($i,) = each($pgs)) {
+			if (empty($pgs[$i])) {
+				continue;
+			}
+
+			// removes line breaks and extensive white space
+			$pgs[$i] = preg_replace(array('#\s+#', '#^\s*(.+?)\s*$#m'), array(' ', '$1'), str_replace("\n", '', $pgs[$i]));
+
+			// wordwraps + indents lines
+			$pgs[$i] = str_repeat($this->indChar, $this->indFirst) .
+			   		wordwrap(
+							$pgs[$i],
+							max($this->wrap - $this->indent, 1),
+							$this->wrapChar . str_repeat($this->indChar, $this->indent),
+							$this->wrapCut
+					);
+		}
+
+		if ($this->assign !== '') {
+			$this->dwoo->assignInScope(implode($this->wrapChar . $this->wrapChar, $pgs), $this->assign);
+		} else {
+			return implode($this->wrapChar . $this->wrapChar, $pgs);
+		}
+	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/topLevelBlock.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/topLevelBlock.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/topLevelBlock.php	(revision 755)
@@ -0,0 +1,32 @@
+<?php
+
+/**
+ * Internal plugin used to wrap the template output, do not use in your templates as it will break them
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+final class Dwoo_Plugin_topLevelBlock extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Block
+{
+	public function init()
+	{
+	}
+
+	public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type)
+	{
+		return '/* end template head */ ob_start(); /* template body */ '.Dwoo_Compiler::PHP_CLOSE;
+	}
+
+	public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content)
+	{
+		return $content . Dwoo_Compiler::PHP_OPEN.' /* end template body */'."\n".'return $this->buffer . ob_get_clean();';
+	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/with.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/with.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/with.php	(revision 755)
@@ -0,0 +1,76 @@
+<?php
+
+/**
+ * Moves the scope down into the provided variable, allowing you to use shorter
+ * variable names if you repeatedly access values into a single array
+ *
+ * The with block won't display anything at all if the provided scope is empty,
+ * so in effect it acts as {if $var}*content*{/if}
+ * <pre>
+ *  * var : the variable name to move into
+ * </pre>
+ * Example :
+ *
+ * instead of the following :
+ *
+ * <code>
+ * {if $long.boring.prefix}
+ *   {$long.boring.prefix.val} - {$long.boring.prefix.secondVal} - {$long.boring.prefix.thirdVal}
+ * {/if}
+ * </code>
+ *
+ * you can use :
+ *
+ * <code>
+ * {with $long.boring.prefix}
+ *   {$val} - {$secondVal} - {$thirdVal}
+ * {/with}
+ * </code>
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+class Dwoo_Plugin_with extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Block, Dwoo_IElseable
+{
+	protected static $cnt=0;
+
+	public function init($var)
+	{
+	}
+
+	public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type)
+	{
+		return '';
+	}
+
+	public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content)
+	{
+		$rparams = $compiler->getRealParams($params);
+		$cparams = $compiler->getCompiledParams($params);
+
+		$compiler->setScope($rparams['var']);
+
+
+		$pre = Dwoo_Compiler::PHP_OPEN. 'if ('.$cparams['var'].')'."\n{\n".
+			'$_with'.(self::$cnt).' = $this->setScope("'.$rparams['var'].'");'.
+			"\n/* -- start with output */\n".Dwoo_Compiler::PHP_CLOSE;
+
+		$post = Dwoo_Compiler::PHP_OPEN. "\n/* -- end with output */\n".
+			'$this->setScope($_with'.(self::$cnt++).', true);'.
+			"\n}\n".Dwoo_Compiler::PHP_CLOSE;
+
+		if (isset($params['hasElse'])) {
+			$post .= $params['hasElse'];
+		}
+
+		return $pre . $content . $post;
+	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/withelse.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/withelse.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/blocks/withelse.php	(revision 755)
@@ -0,0 +1,43 @@
+<?php
+
+/**
+ * This plugin serves as a {else} block specifically for the {with} plugin.
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+class Dwoo_Plugin_withelse extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Block
+{
+	public function init()
+	{
+	}
+
+	public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type)
+	{
+		$with =& $compiler->findBlock('with', true);
+
+		$params['initialized'] = true;
+		$compiler->injectBlock($type, $params);
+
+		return '';
+	}
+
+	public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content)
+	{
+		if (!isset($params['initialized'])) {
+			return '';
+		}
+
+		$block =& $compiler->getCurrentBlock();
+		$block['params']['hasElse'] = Dwoo_Compiler::PHP_OPEN."else {\n".Dwoo_Compiler::PHP_CLOSE . $content . Dwoo_Compiler::PHP_OPEN."\n}".Dwoo_Compiler::PHP_CLOSE;
+		return '';
+	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/filters/html_format.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/filters/html_format.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/filters/html_format.php	(revision 755)
@@ -0,0 +1,175 @@
+<?php
+
+/**
+ * Formats any html output (must be valid xml where every tag opened is closed)
+ * using a single tab for indenting. 'pre' and other whitespace sensitive
+ * tags should not be affected.
+ *
+ * It is not recommended to use this on every template if you render multiple
+ * templates per page, you should only use it once on the main page template so that
+ * everything is formatted in one pass.
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+class Dwoo_Filter_html_format extends Dwoo_Filter
+{
+	/**
+	 * tab count to auto-indent the source
+	 *
+	 * @var int
+	 */
+	protected static $tabCount = -1;
+
+	/**
+	 * stores the additional data (following a tag) of the last call to open/close/singleTag
+	 *
+	 * @var string
+	 */
+	protected static $lastCallAdd = '';
+
+	/**
+	 * formats the input using the singleTag/closeTag/openTag functions
+	 *
+	 * It is auto indenting the whole code, excluding <textarea>, <code> and <pre> tags that must be kept intact.
+	 * Those tags must however contain only htmlentities-escaped text for everything to work properly.
+	 * Inline tags are presented on a single line with their content
+	 *
+	 * @param Dwoo_Core $dwoo the dwoo instance rendering this
+	 * @param string $input the xhtml to format
+	 * @return string formatted xhtml
+	 */
+	public function process($input)
+	{
+		self::$tabCount = -1;
+
+		// auto indent all but textareas & pre (or we have weird tabs inside)
+		$input = preg_replace_callback("#(<[^>]+>)(\s*)([^<]*)#", array('self', 'tagDispatcher'), $input);
+
+		return $input;
+	}
+
+	/**
+	 * helper function for format()'s preg_replace call
+	 *
+	 * @param array	$input	array of matches (1=>tag, 2=>whitespace(optional), 3=>additional non-html content)
+	 * @return string the indented tag
+	 */
+	protected static function tagDispatcher($input)
+	{
+		// textarea, pre, code tags and comments are to be left alone to avoid any non-wanted whitespace inside them so it just outputs them as they were
+		if (substr($input[1],0,9) == "<textarea" || substr($input[1],0,4) == "<pre" || substr($input[1],0,5) == "<code" || substr($input[1],0,4) == "<!--" || substr($input[1],0,9) == "<![CDATA[") {
+			return $input[1] . $input[3];
+		}
+		// closing textarea, code and pre tags and self-closed tags (i.e. <br />) are printed as singleTags because we didn't use openTag for the formers and the latter is a single tag
+		if (substr($input[1],0,10) == "</textarea" || substr($input[1],0,5) == "</pre" || substr($input[1],0,6) == "</code" || substr($input[1],-2) == "/>") {
+			return self::singleTag($input[1],$input[3],$input[2]);
+		}
+		// it's the closing tag
+		if ($input[0][1]=="/"){
+			return self::closeTag($input[1],$input[3],$input[2]);
+		}
+		// opening tag
+		return self::openTag($input[1],$input[3],$input[2]);
+	}
+
+	/**
+	 * returns an open tag and adds a tab into the auto indenting
+	 *
+	 * @param string $tag content of the tag
+	 * @param string $add additional data (anything before the following tag)
+	 * @param string $whitespace white space between the tag and the additional data
+	 * @return string
+	 */
+	protected static function openTag($tag,$add,$whitespace)
+	{
+		$tabs = str_pad('',self::$tabCount++,"\t");
+
+		if (preg_match('#^<(a|label|option|textarea|h1|h2|h3|h4|h5|h6|strong|b|em|i|abbr|acronym|cite|span|sub|sup|u|s|title)(?: [^>]*|)>#', $tag)) {
+			// if it's one of those tag it's inline so it does not require a leading line break
+			$result = $tag . $whitespace . str_replace("\n","\n".$tabs,$add);
+		} elseif (substr($tag,0,9) == '<!DOCTYPE') {
+			// it's the doctype declaration so no line break here either
+			$result = $tabs . $tag;
+		} else {
+			// normal block tag
+			$result = "\n".$tabs . $tag;
+
+			if (!empty($add)) {
+				$result .= "\n".$tabs."\t".str_replace("\n","\n\t".$tabs,$add);
+			}
+		}
+
+		self::$lastCallAdd = $add;
+
+		return $result;
+	}
+
+	/**
+	 * returns a closing tag and removes a tab from the auto indenting
+	 *
+	 * @param string $tag content of the tag
+	 * @param string $add additional data (anything before the following tag)
+	 * @param string $whitespace white space between the tag and the additional data
+	 * @return string
+	 */
+	protected static function closeTag($tag,$add,$whitespace)
+	{
+		$tabs = str_pad('',--self::$tabCount,"\t");
+
+		// if it's one of those tag it's inline so it does not require a leading line break
+		if (preg_match('#^</(a|label|option|textarea|h1|h2|h3|h4|h5|h6|strong|b|em|i|abbr|acronym|cite|span|sub|sup|u|s|title)>#', $tag)) {
+			$result = $tag . $whitespace . str_replace("\n","\n".$tabs,$add);
+		} else {
+			$result = "\n".$tabs.$tag;
+
+			if (!empty($add)) {
+				$result .= "\n".$tabs."\t".str_replace("\n","\n\t".$tabs,$add);
+			}
+		}
+
+		self::$lastCallAdd = $add;
+
+		return $result;
+	}
+
+	/**
+	 * returns a single tag with auto indenting
+	 *
+	 * @param string $tag content of the tag
+	 * @param string $add additional data (anything before the following tag)
+	 * @return string
+	 */
+	protected static function singleTag($tag,$add,$whitespace)
+	{
+		$tabs = str_pad('',self::$tabCount,"\t");
+
+		// if it's img, br it's inline so it does not require a leading line break
+		// if it's a closing textarea, code or pre tag, it does not require a leading line break either or it creates whitespace at the end of those blocks
+		if (preg_match('#^<(img|br|/textarea|/pre|/code)(?: [^>]*|)>#', $tag)) {
+			$result = $tag.$whitespace;
+
+			if (!empty($add)) {
+				$result .= str_replace("\n","\n".$tabs,$add);
+			}
+		} else {
+			$result = "\n".$tabs.$tag;
+
+			if (!empty($add)) {
+				$result .= "\n".$tabs.str_replace("\n","\n".$tabs,$add);
+			}
+		}
+
+		self::$lastCallAdd = $add;
+
+		return $result;
+	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/assign.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/assign.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/assign.php	(revision 755)
@@ -0,0 +1,23 @@
+<?php
+
+/**
+ * Assigns a value to a variable
+ * <pre>
+ *  * value : the value that you want to save
+ *  * var : the variable name (without the leading $)
+ * </pre>
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+function Dwoo_Plugin_assign_compile(Dwoo_Compiler $compiler, $value, $var)
+{
+	return '$this->assignInScope('.$value.', '.$var.')';
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/capitalize.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/capitalize.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/capitalize.php	(revision 755)
@@ -0,0 +1,38 @@
+<?php
+
+/**
+ * Capitalizes the first letter of each word
+ * <pre>
+ *  * value : the string to capitalize
+ *  * numwords : if true, the words containing numbers are capitalized as well
+ * </pre>
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.1.0
+ * @date       2009-07-18
+ * @package    Dwoo
+ */
+function Dwoo_Plugin_capitalize(Dwoo_Core $dwoo, $value, $numwords=false)
+{
+	if ($numwords || preg_match('#^[^0-9]+$#',$value))
+	{
+		return mb_convert_case((string) $value,MB_CASE_TITLE, $dwoo->getCharset());
+	} else {
+		$bits = explode(' ', (string) $value);
+		$out = '';
+		while (list(,$v) = each($bits)) {
+			if (preg_match('#^[^0-9]+$#', $v)) {
+				$out .=	' '.mb_convert_case($v, MB_CASE_TITLE, $dwoo->getCharset());
+			} else {
+				$out .=	' '.$v;
+			}
+		}
+
+		return substr($out, 1);
+	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/cat.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/cat.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/cat.php	(revision 755)
@@ -0,0 +1,22 @@
+<?php
+
+/**
+ * Concatenates any number of variables or strings fed into it
+ * <pre>
+ *  * rest : two or more strings that will be merged into one
+ * </pre>
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+function Dwoo_Plugin_cat_compile(Dwoo_Compiler $compiler, $value, array $rest)
+{
+	return '('.$value.').('.implode(').(', $rest).')';
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/count_characters.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/count_characters.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/count_characters.php	(revision 755)
@@ -0,0 +1,27 @@
+<?php
+
+/**
+ * Counts the characters in a string
+ * <pre>
+ *  * value : the string to process
+ *  * count_spaces : if true, the white-space characters are counted as well
+ * </pre>
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+function Dwoo_Plugin_count_characters_compile(Dwoo_Compiler $compiler, $value, $count_spaces=false)
+{
+	if ($count_spaces==='false') {
+		return 'preg_match_all(\'#[^\s\pZ]#u\', '.$value.', $tmp)';
+	} else {
+		return 'mb_strlen('.$value.', $this->charset)';
+	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/count_paragraphs.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/count_paragraphs.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/count_paragraphs.php	(revision 755)
@@ -0,0 +1,22 @@
+<?php
+
+/**
+ * Counts the paragraphs in a string
+ * <pre>
+ *  * value : the string to process
+ * </pre>
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+function Dwoo_Plugin_count_paragraphs_compile(Dwoo_Compiler $compiler, $value)
+{
+	return '(preg_match_all(\'#[\r\n]+#\', '.$value.', $tmp)+1)';
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/count_sentences.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/count_sentences.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/count_sentences.php	(revision 755)
@@ -0,0 +1,22 @@
+<?php
+
+/**
+ * Counts the sentences in a string
+ * <pre>
+ *  * value : the string to process
+ * </pre>
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+function Dwoo_Plugin_count_sentences_compile(Dwoo_Compiler $compiler, $value)
+{
+	return "preg_match_all('#[\w\pL]\.(?![\w\pL])#u', $value, \$tmp)";
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/count_words.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/count_words.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/count_words.php	(revision 755)
@@ -0,0 +1,22 @@
+<?php
+
+/**
+ * Counts the words in a string
+ * <pre>
+ *  * value : the string to process
+ * </pre>
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+function Dwoo_Plugin_count_words_compile(Dwoo_Compiler $compiler, $value)
+{
+	return 'preg_match_all(strcasecmp($this->charset, \'utf-8\')===0 ? \'#[\w\pL]+#u\' : \'#\w+#\', '.$value.', $tmp)';
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/counter.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/counter.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/counter.php	(revision 755)
@@ -0,0 +1,76 @@
+<?php
+
+/**
+ * Initiates a counter that is incremented every time you call it
+ * <pre>
+ *  * name : the counter name, define it if you want to have multiple concurrent counters
+ *  * start : the start value, if it's set, it will reset the counter to this value, defaults to 1
+ *  * skip : the value to add to the counter at each call, defaults to 1
+ *  * direction : "up" (default) or "down" to define whether the counter increments or decrements
+ *  * print : if false, the counter will not output the current count, defaults to true
+ *  * assign : if set, the counter is saved into the given variable and does not output anything, overriding the print parameter
+ * </pre>
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+class Dwoo_Plugin_counter extends Dwoo_Plugin
+{
+	protected $counters = array();
+
+	public function process($name = 'default', $start = null, $skip = null, $direction = null, $print = null, $assign = null)
+	{
+		// init counter
+		if (!isset($this->counters[$name])) {
+			$this->counters[$name] = array
+			(
+				'count'		=>	$start===null ? 1 : (int) $start,
+				'skip'		=>	$skip===null ? 1 : (int) $skip,
+				'print'		=>	$print===null ? true : (bool) $print,
+				'assign'	=>	$assign===null ? null : (string) $assign,
+				'direction'	=>	strtolower($direction)==='down' ? -1 : 1,
+			);
+		}
+		// increment
+		else
+		{
+			// override setting if present
+			if ($skip !== null) {
+				$this->counters[$name]['skip'] = (int) $skip;
+			}
+
+			if ($direction !== null) {
+				$this->counters[$name]['direction'] = strtolower($direction)==='down' ? -1 : 1;
+			}
+
+			if ($print !== null) {
+				$this->counters[$name]['print'] = (bool) $print;
+			}
+
+			if ($assign !== null) {
+				$this->counters[$name]['assign'] = (string) $assign;
+			}
+
+			if ($start !== null) {
+				$this->counters[$name]['count'] = (int) $start;
+			} else {
+				$this->counters[$name]['count'] += ($this->counters[$name]['skip'] * $this->counters[$name]['direction']);
+			}
+		}
+
+		$out = $this->counters[$name]['count'];
+
+		if ($this->counters[$name]['assign'] !== null) {
+			$this->dwoo->assignInScope($out, $this->counters[$name]['assign']);
+		} elseif ($this->counters[$name]['print'] === true) {
+			return $out;
+		}
+	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/cycle.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/cycle.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/cycle.php	(revision 755)
@@ -0,0 +1,68 @@
+<?php
+
+/**
+ * Cycles between several values and returns one of them on each call
+ * <pre>
+ *  * name : the cycler name, specify if you need to have multiple concurrent cycles running
+ *  * values : an array of values or a string of values delimited by $delimiter
+ *  * print : if false, the pointer will go to the next one but not print anything
+ *  * advance : if false, the pointer will not advance to the next value
+ *  * delimiter : the delimiter used to split values if they are provided as a string
+ *  * assign : if set, the value is saved in that variable instead of being output
+ *  * reset : if true, the pointer is reset to the first value
+ * </pre>
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.1.0
+ * @date       2009-07-18
+ * @package    Dwoo
+ */
+class Dwoo_Plugin_cycle extends Dwoo_Plugin
+{
+	protected $cycles = array();
+
+	public function process($name = 'default', $values = null, $print = true, $advance = true, $delimiter = ',', $assign = null, $reset = false)
+	{
+		if ($values !== null) {
+			if (is_string($values)) {
+				$values = explode($delimiter, $values);
+			}
+
+			if (!isset($this->cycles[$name]) || $this->cycles[$name]['values'] !== $values) {
+				$this->cycles[$name]['index'] = 0;
+			}
+
+			$this->cycles[$name]['values'] = array_values($values);
+		} elseif (isset($this->cycles[$name])) {
+			$values = $this->cycles[$name]['values'];
+		}
+
+		if ($reset) {
+			$this->cycles[$name]['index'] = 0;
+		}
+
+		if ($print) {
+			$out = $values[$this->cycles[$name]['index']];
+		} else {
+			$out = null;
+		}
+
+		if ($advance) {
+			if ($this->cycles[$name]['index'] >= count($values)-1) {
+				$this->cycles[$name]['index'] = 0;
+			} else {
+				$this->cycles[$name]['index']++;
+			}
+		}
+
+		if ($assign === null) {
+			return $out;
+		}
+		$this->dwoo->assignInScope($out, $assign);
+	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/date_format.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/date_format.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/date_format.php	(revision 755)
@@ -0,0 +1,54 @@
+<?php
+
+/**
+ * Formats a date
+ * <pre>
+ *  * value : the date, as a unix timestamp, mysql datetime or whatever strtotime() can parse
+ *  * format : output format, see {@link http://php.net/strftime} for details
+ *  * default : a default timestamp value, if the first one is empty
+ * </pre>
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.1
+ * @date       2008-12-24
+ * @package    Dwoo
+ */
+function Dwoo_Plugin_date_format(Dwoo_Core $dwoo, $value, $format='%b %e, %Y', $default=null)
+{
+	if (!empty($value)) {
+		// convert if it's not a valid unix timestamp
+		if (preg_match('#^-?\d{1,10}$#', $value)===0) {
+			$value = strtotime($value);
+		}
+	} elseif (!empty($default)) {
+		// convert if it's not a valid unix timestamp
+		if (preg_match('#^-?\d{1,10}$#', $default)===0) {
+			$value = strtotime($default);
+		} else {
+			$value = $default;
+		}
+	} else {
+		return '';
+	}
+
+	// Credits for that windows compat block to Monte Ohrt who made smarty's date_format plugin
+	if (DIRECTORY_SEPARATOR == '\\') {
+		$_win_from = array('%D',       '%h', '%n', '%r',          '%R',    '%t', '%T');
+		$_win_to   = array('%m/%d/%y', '%b', "\n", '%I:%M:%S %p', '%H:%M', "\t", '%H:%M:%S');
+		if (strpos($format, '%e') !== false) {
+			$_win_from[] = '%e';
+			$_win_to[]   = sprintf('%\' 2d', date('j', $value));
+		}
+		if (strpos($format, '%l') !== false) {
+			$_win_from[] = '%l';
+			$_win_to[]   = sprintf('%\' 2d', date('h', $value));
+		}
+		$format = str_replace($_win_from, $_win_to, $format);
+	}
+	return strftime($format, $value);
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/default.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/default.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/default.php	(revision 755)
@@ -0,0 +1,23 @@
+<?php
+
+/**
+ * Returns a variable or a default value if it's empty
+ * <pre>
+ *  * value : the variable to check
+ *  * default : fallback value if the first one is empty
+ * </pre>
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+function Dwoo_Plugin_default_compile(Dwoo_Compiler $compiler, $value, $default='')
+{
+	return '(($tmp = '.$value.')===null||$tmp===\'\' ? '.$default.' : $tmp)';
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/dump.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/dump.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/dump.php	(revision 755)
@@ -0,0 +1,173 @@
+<?php
+
+/**
+ * Dumps values of the given variable, or the entire data if nothing provided
+ * <pre>
+ *  * var : the variable to display
+ *  * show_methods : if set to true, the public methods of any object encountered are also displayed
+ * </pre>
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+class Dwoo_Plugin_dump extends Dwoo_Plugin
+{
+	protected $outputObjects;
+	protected $outputMethods;
+
+	public function process($var = '$', $show_methods = false)
+	{
+		$this->outputMethods = $show_methods;
+		if ($var === '$') {
+			$var = $this->dwoo->getData();
+			$out = '<div style="background:#aaa; padding:5px; margin:5px; color:#000;">data';
+		} else {
+			$out = '<div style="background:#aaa; padding:5px; margin:5px; color:#000;">dump';
+		}
+
+		$this->outputObjects = array();
+
+		if (!is_array($var)) {
+			if (is_object($var)) {
+				return $this->exportObj('', $var);
+			} else {
+				return $this->exportVar('', $var);
+			}
+		}
+
+		$scope = $this->dwoo->getScope();
+
+		if ($var === $scope) {
+			$out .= ' (current scope): <div style="background:#ccc;">';
+		} else {
+			$out .= ':<div style="padding-left:20px;">';
+		}
+
+		$out .= $this->export($var, $scope);
+
+		return $out .'</div></div>';
+	}
+
+	protected function export($var, $scope)
+	{
+		$out = '';
+		foreach ($var as $i=>$v) {
+			if (is_array($v) || (is_object($v) && $v instanceof Iterator)) {
+				$out .= $i.' ('.(is_array($v) ? 'array':'object: '.get_class($v)).')';
+				if ($v===$scope) {
+					$out .= ' (current scope):<div style="background:#ccc;padding-left:20px;">'.$this->export($v, $scope).'</div>';
+				} else {
+					$out .= ':<div style="padding-left:20px;">'.$this->export($v, $scope).'</div>';
+				}
+			} elseif (is_object($v)) {
+				$out .= $this->exportObj($i.' (object: '.get_class($v).'):', $v);
+			} else {
+				$out .= $this->exportVar($i.' = ', $v);
+			}
+		}
+		return $out;
+	}
+
+	protected function exportVar($i, $v)
+	{
+		if (is_string($v) || is_bool($v) || is_numeric($v)) {
+			return $i.htmlentities(var_export($v, true)).'<br />';
+		} elseif (is_null($v)) {
+			return $i.'null<br />';
+		} elseif (is_resource($v)) {
+			return $i.'resource('.get_resource_type($v).')<br />';
+		} else {
+			return $i.htmlentities(var_export($v, true)).'<br />';
+		}
+	}
+
+	protected function exportObj($i, $obj)
+	{
+		if (array_search($obj, $this->outputObjects, true) !== false) {
+			return $i . ' [recursion, skipped]<br />';
+		}
+
+		$this->outputObjects[] = $obj;
+
+		$list = (array) $obj;
+
+		$protectedLength = strlen(get_class($obj)) + 2;
+
+		$out = array();
+
+		if ($this->outputMethods) {
+			$ref = new ReflectionObject($obj);
+
+			foreach ($ref->getMethods() as $method) {
+				if (!$method->isPublic()) {
+					continue;
+				}
+
+				if (empty($out['method'])) {
+					$out['method'] = '';
+				}
+
+				$params = array();
+				foreach ($method->getParameters() as $param) {
+					$params[] = ($param->isPassedByReference() ? '&':'') . '$'.$param->getName() . ($param->isOptional() ? ' = '.var_export($param->getDefaultValue(), true) : '');
+				}
+
+				$out['method'] .= '(method) ' . $method->getName() .'('.implode(', ', $params).')<br />';
+			}
+		}
+
+		foreach ($list as $attributeName => $attributeValue) {
+			if(property_exists($obj, $attributeName)) {
+				$key = 'public';
+			} elseif(substr($attributeName, 0, 3) === "\0*\0") {
+				$key = 'protected';
+				$attributeName = substr($attributeName, 3);
+			} else {
+				$key = 'private';
+				$attributeName = substr($attributeName, $protectedLength);
+			}
+
+			if (empty($out[$key])) {
+				$out[$key] = '';
+			}
+
+			$out[$key] .= '('.$key.') ';
+
+			if (is_array($attributeValue)) {
+				$out[$key] .= $attributeName.' (array):<br />
+							<div style="padding-left:20px;">'.$this->export($attributeValue, false).'</div>';
+			} elseif (is_object($attributeValue)) {
+				$out[$key] .= $this->exportObj($attributeName.' (object: '.get_class($attributeValue).'):', $attributeValue);
+			} else {
+				$out[$key] .= $this->exportVar($attributeName.' = ', $attributeValue);
+			}
+		}
+
+		$return = $i . '<br /><div style="padding-left:20px;">';
+
+		if (!empty($out['method'])) {
+			$return .= $out['method'];
+		}
+
+		if (!empty($out['public'])) {
+			$return .= $out['public'];
+		}
+
+		if (!empty($out['protected'])) {
+			$return .= $out['protected'];
+		}
+
+		if (!empty($out['private'])) {
+			$return .= $out['private'];
+		}
+
+		return $return . '</div>';
+	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/eol.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/eol.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/eol.php	(revision 755)
@@ -0,0 +1,20 @@
+<?php
+
+/**
+ * Returns the correct end of line character(s) for the current operating system
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+function Dwoo_Plugin_eol_compile(Dwoo_Compiler $compiler)
+{
+	return 'PHP_EOL';
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/escape.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/escape.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/escape.php	(revision 755)
@@ -0,0 +1,61 @@
+<?php
+
+/**
+ * Applies various escaping schemes on the given string
+ * <pre>
+ *  * value : the string to process
+ *  * format : escaping format to use, valid formats are : html, htmlall, url, urlpathinfo, quotes, hex, hexentity, javascript and mail
+ *  * charset : character set to use for the conversion (applies to some formats only), defaults to the current Dwoo charset
+ * </pre>
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+function Dwoo_Plugin_escape(Dwoo_Core $dwoo, $value='', $format='html', $charset=null)
+{
+	if ($charset === null) {
+		$charset = $dwoo->getCharset();
+	}
+
+	switch($format)
+	{
+
+	case 'html':
+		return htmlspecialchars((string) $value, ENT_QUOTES, $charset);
+	case 'htmlall':
+		return htmlentities((string) $value, ENT_QUOTES, $charset);
+	case 'url':
+		return rawurlencode((string) $value);
+	case 'urlpathinfo':
+		return str_replace('%2F', '/', rawurlencode((string) $value));
+	case 'quotes':
+		return preg_replace("#(?<!\\\\)'#", "\\'", (string) $value);
+	case 'hex':
+		$out = '';
+		$cnt = strlen((string) $value);
+		for ($i=0; $i < $cnt; $i++) {
+			$out .= '%' . bin2hex((string) $value[$i]);
+		}
+		return $out;
+	case 'hexentity':
+		$out = '';
+		$cnt = strlen((string) $value);
+		for ($i=0; $i < $cnt; $i++)
+			$out .= '&#x' . bin2hex((string) $value[$i]) . ';';
+		return $out;
+	case 'javascript':
+		return strtr((string) $value, array('\\'=>'\\\\',"'"=>"\\'",'"'=>'\\"',"\r"=>'\\r',"\n"=>'\\n','</'=>'<\/'));
+	case 'mail':
+		return str_replace(array('@', '.'), array('&nbsp;(AT)&nbsp;', '&nbsp;(DOT)&nbsp;'), (string) $value);
+	default:
+		return $dwoo->triggerError('Escape\'s format argument must be one of : html, htmlall, url, urlpathinfo, hex, hexentity, javascript or mail, "'.$format.'" given.', E_USER_WARNING);
+
+	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/eval.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/eval.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/eval.php	(revision 755)
@@ -0,0 +1,42 @@
+<?php
+
+/**
+ * Evaluates the given string as if it was a template
+ *
+ * Although this plugin is kind of optimized and will
+ * not recompile your string each time, it is still not
+ * a good practice to use it. If you want to have templates
+ * stored in a database or something you should probably use
+ * the Dwoo_Template_String class or make another class that
+ * extends it
+ * <pre>
+ *  * var : the string to use as a template
+ *  * assign : if set, the output of the template will be saved in this variable instead of being output
+ * </pre>
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+function Dwoo_Plugin_eval(Dwoo_Core $dwoo, $var, $assign = null)
+{
+	if ($var == '') {
+		return;
+	}
+
+	$tpl = new Dwoo_Template_String($var);
+	$clone = clone $dwoo;
+	$out = $clone->get($tpl, $dwoo->readVar('_parent'));
+
+	if ($assign !== null) {
+		$dwoo->assignInScope($out, $assign);
+	} else {
+		return $out;
+	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/extends.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/extends.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/extends.php	(revision 755)
@@ -0,0 +1,161 @@
+<?php
+
+/**
+ * Extends another template, read more about template inheritance at {@link http://wiki.dwoo.org/index.php/TemplateInheritance}
+ * <pre>
+ *  * file : the template to extend
+ * </pre>
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.1.0
+ * @date       2009-07-18
+ * @package    Dwoo
+ */
+class Dwoo_Plugin_extends extends Dwoo_Plugin implements Dwoo_ICompilable
+{
+	protected static $childSource;
+	protected static $regex;
+	protected static $l;
+	protected static $r;
+	protected static $lastReplacement;
+
+	public static function compile(Dwoo_Compiler $compiler, $file)
+	{
+		list($l, $r) = $compiler->getDelimiters();
+		self::$l = preg_quote($l,'/');
+		self::$r = preg_quote($r,'/');
+		self::$regex = '/
+			'.self::$l.'block\s(["\']?)(.+?)\1'.self::$r.'(?:\r?\n?)
+			((?:
+				(?R)
+				|
+				[^'.self::$l.']*
+				(?:
+					(?! '.self::$l.'\/?block\b )
+					'.self::$l.'
+					[^'.self::$l.']*+
+				)*
+			)*)
+			'.self::$l.'\/block'.self::$r.'
+			/six';
+
+		if ($compiler->getLooseOpeningHandling()) {
+			self::$l .= '\s*';
+			self::$r = '\s*'.self::$r;
+		}
+		$inheritanceTree = array(array('source'=>$compiler->getTemplateSource()));
+		$curPath = dirname($compiler->getDwoo()->getTemplate()->getResourceIdentifier()) . DIRECTORY_SEPARATOR;
+		$curTpl = $compiler->getDwoo()->getTemplate();
+
+		while (!empty($file)) {
+			if ($file === '""' || $file === "''" || (substr($file, 0, 1) !== '"' && substr($file, 0, 1) !== '\'')) {
+				throw new Dwoo_Compilation_Exception($compiler, 'Extends : The file name must be a non-empty string');
+				return;
+			}
+
+			if (preg_match('#^["\']([a-z]{2,}):(.*?)["\']$#i', $file, $m)) {
+				// resource:identifier given, extract them
+				$resource = $m[1];
+				$identifier = $m[2];
+			} else {
+				// get the current template's resource
+				$resource = $curTpl->getResourceName();
+				$identifier = substr($file, 1, -1);
+			}
+
+			try {
+				$parent = $compiler->getDwoo()->templateFactory($resource, $identifier, null, null, null, $curTpl);
+			} catch (Dwoo_Security_Exception $e) {
+				throw new Dwoo_Compilation_Exception($compiler, 'Extends : Security restriction : '.$e->getMessage());
+			} catch (Dwoo_Exception $e) {
+				throw new Dwoo_Compilation_Exception($compiler, 'Extends : '.$e->getMessage());
+			}
+
+			if ($parent === null) {
+				throw new Dwoo_Compilation_Exception($compiler, 'Extends : Resource "'.$resource.':'.$identifier.'" not found.');
+			} elseif ($parent === false) {
+				throw new Dwoo_Compilation_Exception($compiler, 'Extends : Resource "'.$resource.'" does not support extends.');
+			}
+
+			$curTpl = $parent;
+			$newParent = array('source'=>$parent->getSource(), 'resource'=>$resource, 'identifier'=>$parent->getResourceIdentifier(), 'uid'=>$parent->getUid());
+			if (array_search($newParent, $inheritanceTree, true) !== false) {
+				throw new Dwoo_Compilation_Exception($compiler, 'Extends : Recursive template inheritance detected');
+			}
+			$inheritanceTree[] = $newParent;
+
+			if (preg_match('/^'.self::$l.'extends(?:\(?\s*|\s+)(?:file=)?\s*((["\']).+?\2|\S+?)\s*\)?\s*?'.self::$r.'/i', $parent->getSource(), $match)) {
+				$curPath = dirname($identifier) . DIRECTORY_SEPARATOR;
+				if (isset($match[2]) && $match[2] == '"') {
+					$file = '"'.str_replace('"', '\\"', substr($match[1], 1, -1)).'"';
+				} elseif (isset($match[2]) && $match[2] == "'") {
+					$file = '"'.substr($match[1], 1, -1).'"';
+				} else {
+					$file = '"'.$match[1].'"';
+				}
+			} else {
+				$file = false;
+			}
+		}
+
+		while (true) {
+			$parent = array_pop($inheritanceTree);
+			$child = end($inheritanceTree);
+			self::$childSource = $child['source'];
+			self::$lastReplacement = count($inheritanceTree) === 1;
+			if (!isset($newSource)) {
+				$newSource = $parent['source'];
+			}
+			$newSource = preg_replace_callback(self::$regex, array('Dwoo_Plugin_extends', 'replaceBlock'), $newSource);
+			$newSource = $l.'do extendsCheck('.var_export($parent['resource'].':'.$parent['identifier'], true).')'.$r.$newSource;
+
+			if (self::$lastReplacement) {
+				break;
+			}
+		}
+		$compiler->setTemplateSource($newSource);
+		$compiler->recompile();
+	}
+
+	protected static function replaceBlock(array $matches)
+	{
+		$matches[3] = self::removeTrailingNewline($matches[3]);
+
+		if (preg_match_all(self::$regex, self::$childSource, $override) && in_array($matches[2], $override[2])) {
+			$key = array_search($matches[2], $override[2]);
+			$override = self::removeTrailingNewline($override[3][$key]);
+
+			$l = stripslashes(self::$l);
+			$r = stripslashes(self::$r);
+
+			if (self::$lastReplacement) {
+				return preg_replace('/'.self::$l.'\$dwoo\.parent'.self::$r.'/is', $matches[3], $override);
+			}
+			return $l.'block '.$matches[1].$matches[2].$matches[1].$r.preg_replace('/'.self::$l.'\$dwoo\.parent'.self::$r.'/is', $matches[3], $override).$l.'/block'.$r;
+		}
+
+		if (preg_match(self::$regex, $matches[3])) {
+			return preg_replace_callback(self::$regex, array('Dwoo_Plugin_extends', 'replaceBlock'), $matches[3] );
+		}
+
+		if (self::$lastReplacement) {
+			return $matches[3];
+		}
+
+		return  $matches[0];
+	}
+
+	protected static function removeTrailingNewline($text)
+	{
+		return substr($text, -1) === "\n"
+				? substr($text, -2, 1) === "\r"
+					? substr($text, 0, -2)
+					: substr($text, 0, -1)
+				: $text;
+	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/extendsCheck.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/extendsCheck.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/extendsCheck.php	(revision 755)
@@ -0,0 +1,52 @@
+<?php
+
+/**
+ * Checks whether an extended file has been modified, and if so recompiles the current template. This is for internal use only, do not use.
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.1.0
+ * @date       2009-07-18
+ * @package    Dwoo
+ */
+function Dwoo_Plugin_extendsCheck_compile(Dwoo_Compiler $compiler, $file)
+{
+	preg_match('#^["\']([a-z]{2,}):(.*?)["\']$#i', $file, $m);
+	$resource = $m[1];
+	$identifier = $m[2];
+
+	$tpl = $compiler->getDwoo()->templateFactory($resource, $identifier);
+
+	if ($tpl === null) {
+		throw new Dwoo_Compilation_Exception($compiler, 'Load Templates : Resource "'.$resource.':'.$identifier.'" not found.');
+	} elseif ($tpl === false) {
+		throw new Dwoo_Compilation_Exception($compiler, 'Load Templates : Resource "'.$resource.'" does not support includes.');
+	}
+
+
+	$out = '\'\';// checking for modification in '.$resource.':'.$identifier."\r\n";
+	
+	$modCheck = $tpl->getIsModifiedCode();
+	
+	if ($modCheck) {
+		$out .= 'if (!('.$modCheck.')) { ob_end_clean(); return false; }';
+	} else {
+		$out .= 'try {
+	$tpl = $this->templateFactory("'.$resource.'", "'.$identifier.'");
+} catch (Dwoo_Exception $e) {
+	$this->triggerError(\'Load Templates : Resource <em>'.$resource.'</em> was not added to Dwoo, can not extend <em>'.$identifier.'</em>\', E_USER_WARNING);
+}
+if ($tpl === null)
+	$this->triggerError(\'Load Templates : Resource "'.$resource.':'.$identifier.'" was not found.\', E_USER_WARNING);
+elseif ($tpl === false)
+	$this->triggerError(\'Load Templates : Resource "'.$resource.'" does not support extends.\', E_USER_WARNING);
+if ($tpl->getUid() != "'.$tpl->getUid().'") { ob_end_clean(); return false; }';
+	}
+	
+	return $out;
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/fetch.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/fetch.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/fetch.php	(revision 755)
@@ -0,0 +1,50 @@
+<?php
+
+/**
+ * Reads a file
+ * <pre>
+ *  * file : path or URI of the file to read (however reading from another website is not recommended for performance reasons)
+ *  * assign : if set, the file will be saved in this variable instead of being output
+ * </pre>
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.1.0
+ * @date       2009-07-18
+ * @package    Dwoo
+ */
+function Dwoo_Plugin_fetch(Dwoo_Core $dwoo, $file, $assign = null)
+{
+	if ($file === '') {
+		return;
+	}
+
+	if ($policy = $dwoo->getSecurityPolicy()) {
+		while (true) {
+			if (preg_match('{^([a-z]+?)://}i', $file)) {
+				return $dwoo->triggerError('The security policy prevents you to read files from external sources.', E_USER_WARNING);
+			}
+
+			$file = realpath($file);
+			$dirs = $policy->getAllowedDirectories();
+			foreach ($dirs as $dir=>$dummy) {
+				if (strpos($file, $dir) === 0) {
+					break 2;
+				}
+			}
+			return $dwoo->triggerError('The security policy prevents you to read <em>'.$file.'</em>', E_USER_WARNING);
+		}
+	}
+	$file = str_replace(array("\t", "\n", "\r"), array('\\t', '\\n', '\\r'), $file);
+
+	$out = file_get_contents($file);
+
+	if ($assign === null) {
+		return $out;
+	}
+	$dwoo->assignInScope($out, $assign);
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/include.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/include.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/include.php	(revision 755)
@@ -0,0 +1,79 @@
+<?php
+
+/**
+ * Inserts another template into the current one
+ * <pre>
+ *  * file : the resource name of the template
+ *  * cache_time : cache length in seconds
+ *  * cache_id : cache identifier for the included template
+ *  * compile_id : compilation identifier for the included template
+ *  * data : data to feed into the included template, it can be any array and will default to $_root (the current data)
+ *  * assign : if set, the output of the included template will be saved in this variable instead of being output
+ *  * rest : any additional parameter/value provided will be added to the data array
+ * </pre>
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.1.0
+ * @date       2009-07-18
+ * @package    Dwoo
+ */
+function Dwoo_Plugin_include(Dwoo_Core $dwoo, $file, $cache_time = null, $cache_id = null, $compile_id = null, $data = '_root', $assign = null, array $rest = array())
+{
+	if ($file === '') {
+		return;
+	}
+
+	if (preg_match('#^([a-z]{2,}):(.*)$#i', $file, $m)) {
+		// resource:identifier given, extract them
+		$resource = $m[1];
+		$identifier = $m[2];
+	} else {
+		// get the current template's resource
+		$resource = $dwoo->getTemplate()->getResourceName();
+		$identifier = $file;
+	}
+
+	try {
+		$include = $dwoo->templateFactory($resource, $identifier, $cache_time, $cache_id, $compile_id);
+	} catch (Dwoo_Security_Exception $e) {
+		return $dwoo->triggerError('Include : Security restriction : '.$e->getMessage(), E_USER_WARNING);
+	} catch (Dwoo_Exception $e) {
+		return $dwoo->triggerError('Include : '.$e->getMessage(), E_USER_WARNING);
+	}
+
+	if ($include === null) {
+		return $dwoo->triggerError('Include : Resource "'.$resource.':'.$identifier.'" not found.', E_USER_WARNING);
+	} elseif ($include === false) {
+		return $dwoo->triggerError('Include : Resource "'.$resource.'" does not support includes.', E_USER_WARNING);
+	}
+
+	if (is_string($data)) {
+		$vars = $dwoo->readVar($data);
+	} else {
+		$vars = $data;
+	}
+
+	if (count($rest)) {
+		$vars = $rest + $vars;
+	}
+
+	$clone = clone $dwoo;
+	$out = $clone->get($include, $vars);
+
+	if ($assign !== null) {
+		$dwoo->assignInScope($out, $assign);
+	}
+
+	foreach ($clone->getReturnValues() as $name => $value) {
+		$dwoo->assignInScope($value, $name);
+	}
+
+	if ($assign === null) {
+		return $out;
+	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/indent.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/indent.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/indent.php	(revision 755)
@@ -0,0 +1,24 @@
+<?php
+
+/**
+ * Indents every line of a text by the given amount of characters
+ * <pre>
+ *  * value : the string to indent
+ *  * by : how many characters should be inserted before each line
+ *  * char : the character(s) to insert
+ * </pre>
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+function Dwoo_Plugin_indent_compile(Dwoo_Compiler $compiler, $value, $by=4, $char=' ')
+{
+	return "preg_replace('#^#m', '".str_repeat(substr($char, 1, -1), trim($by, '"\''))."', $value)";
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/isset.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/isset.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/isset.php	(revision 755)
@@ -0,0 +1,22 @@
+<?php
+
+/**
+ * Checks whether a variable is not null
+ * <pre>
+ *  * var : variable to check
+ * </pre>
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+function Dwoo_Plugin_isset_compile(Dwoo_Compiler $compiler, $var)
+{
+	return '('.$var.' !== null)';
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/load_templates.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/load_templates.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/load_templates.php	(revision 755)
@@ -0,0 +1,74 @@
+<?php
+
+/**
+ * Loads sub-templates contained in an external file
+ * <pre>
+ *  * file : the resource name of the file to load
+ * </pre>
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.1.0
+ * @date       2009-07-18
+ * @package    Dwoo
+ */
+function Dwoo_Plugin_load_templates_compile(Dwoo_Compiler $compiler, $file)
+{
+	$file = substr($file, 1, -1);
+
+	if ($file === '') {
+		return;
+	}
+
+	if (preg_match('#^([a-z]{2,}):(.*)$#i', $file, $m)) {
+		// resource:identifier given, extract them
+		$resource = $m[1];
+		$identifier = $m[2];
+	} else {
+		// get the current template's resource
+		$resource = $compiler->getDwoo()->getTemplate()->getResourceName();
+		$identifier = $file;
+	}
+
+	$tpl = $compiler->getDwoo()->templateFactory($resource, $identifier);
+
+	if ($tpl === null) {
+		throw new Dwoo_Compilation_Exception($compiler, 'Load Templates : Resource "'.$resource.':'.$identifier.'" not found.');
+	} elseif ($tpl === false) {
+		throw new Dwoo_Compilation_Exception($compiler, 'Load Templates : Resource "'.$resource.'" does not support includes.');
+	}
+
+	$cmp = clone $compiler;
+	$cmp->compile($compiler->getDwoo(), $tpl);
+	foreach ($cmp->getTemplatePlugins() as $template=>$args) {
+		$compiler->addTemplatePlugin($template, $args['params'], $args['uuid'], $args['body']);
+	}
+	foreach ($cmp->getUsedPlugins() as $plugin=>$type) {
+		$compiler->addUsedPlugin($plugin, $type);
+	}
+
+	$out = '\'\';// checking for modification in '.$resource.':'.$identifier."\r\n";
+	
+	$modCheck = $tpl->getIsModifiedCode();
+	
+	if ($modCheck) {
+		$out .= 'if (!('.$modCheck.')) { ob_end_clean(); return false; }';
+	} else {
+		$out .= 'try {
+	$tpl = $this->templateFactory("'.$resource.'", "'.$identifier.'");
+} catch (Dwoo_Exception $e) {
+	$this->triggerError(\'Load Templates : Resource <em>'.$resource.'</em> was not added to Dwoo, can not extend <em>'.$identifier.'</em>\', E_USER_WARNING);
+}
+if ($tpl === null)
+	$this->triggerError(\'Load Templates : Resource "'.$resource.':'.$identifier.'" was not found.\', E_USER_WARNING);
+elseif ($tpl === false)
+	$this->triggerError(\'Load Templates : Resource "'.$resource.'" does not support extends.\', E_USER_WARNING);
+if ($tpl->getUid() != "'.$tpl->getUid().'") { ob_end_clean(); return false; }';
+	}
+	
+	return $out;
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/lower.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/lower.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/lower.php	(revision 755)
@@ -0,0 +1,22 @@
+<?php
+
+/**
+ * Makes the input string lower cased
+ * <pre>
+ *  * value : the string to process
+ * </pre>
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+function Dwoo_Plugin_lower_compile(Dwoo_Compiler $compiler, $value)
+{
+	return 'mb_strtolower((string) '.$value.', $this->charset)';
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/mailto.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/mailto.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/mailto.php	(revision 755)
@@ -0,0 +1,117 @@
+<?php
+
+/**
+ * Outputs a mailto link with optional spam-proof (okay probably not) encoding
+ * <pre>
+ *  * address : target email address
+ *  * text : display text to show for the link, defaults to the address if not provided
+ *  * subject : the email subject
+ *  * encode : one of the available encoding (none, js, jscharcode or hex)
+ *  * cc : address(es) to carbon copy, comma separated
+ *  * bcc : address(es) to blind carbon copy, comma separated
+ *  * newsgroups : newsgroup(s) to post to, comma separated
+ *  * followupto : address(es) to follow up, comma separated
+ *  * extra : additional attributes to add to the &lt;a&gt; tag
+ * </pre>
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.1.0
+ * @date       2009-07-18
+ * @package    Dwoo
+ */
+function Dwoo_Plugin_mailto(Dwoo_Core $dwoo, $address, $text=null, $subject=null, $encode=null, $cc=null, $bcc=null, $newsgroups=null, $followupto=null, $extra=null)
+{
+	if (empty($address)) {
+		return '';
+	}
+	if (empty($text)) {
+		$text = $address;
+	}
+
+	// build address string
+	$address .= '?';
+
+	if (!empty($subject)) {
+		$address .= 'subject='.rawurlencode($subject).'&';
+	}
+	if (!empty($cc)) {
+		$address .= 'cc='.rawurlencode($cc).'&';
+	}
+	if (!empty($bcc)) {
+		$address .= 'bcc='.rawurlencode($bcc).'&';
+	}
+	if (!empty($newsgroups)) {
+		$address .= 'newsgroups='.rawurlencode($newsgroups).'&';
+	}
+	if (!empty($followupto)) {
+		$address .= 'followupto='.rawurlencode($followupto).'&';
+	}
+
+	$address = rtrim($address, '?&');
+
+	// output
+	switch($encode)
+	{
+
+	case 'none':
+	case null:
+		return '<a href="mailto:'.$address.'" '.$extra.'>'.$text.'</a>';
+
+	case 'js':
+	case 'javascript':
+		$str = 'document.write(\'<a href="mailto:'.$address.'" '.$extra.'>'.$text.'</a>\');';
+		$len = strlen($str);
+
+		$out = '';
+		for ($i=0; $i<$len; $i++) {
+			$out .= '%'.bin2hex($str[$i]);
+		}
+		return '<script type="text/javascript">eval(unescape(\''.$out.'\'));</script>';
+
+		break;
+	case 'javascript_charcode':
+	case 'js_charcode':
+	case 'jscharcode':
+	case 'jschar':
+		$str = '<a href="mailto:'.$address.'" '.$extra.'>'.$text.'</a>';
+		$len = strlen($str);
+
+		$out = '<script type="text/javascript">'."\n<!--\ndocument.write(String.fromCharCode(";
+		for ($i=0; $i<$len; $i++) {
+			$out .= ord($str[$i]).',';
+		}
+		return rtrim($out, ',') . "));\n-->\n</script>\n";
+
+		break;
+
+	case 'hex':
+		if (strpos($address, '?') !== false) {
+			return $dwoo->triggerError('Mailto: Hex encoding is not possible with extra attributes, use one of : <em>js, jscharcode or none</em>.', E_USER_WARNING);
+		}
+
+		$out = '<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;';
+		$len = strlen($address);
+		for ($i=0; $i<$len; $i++) {
+			if (preg_match('#\w#', $address[$i])) {
+				$out .= '%'.bin2hex($address[$i]);
+			} else {
+				$out .= $address[$i];
+			}
+		}
+		$out .= '" '.$extra.'>';
+		$len = strlen($text);
+		for ($i=0; $i<$len; $i++) {
+			$out .= '&#x'.bin2hex($text[$i]);
+		}
+		return $out.'</a>';
+
+	default:
+		return $dwoo->triggerError('Mailto: <em>encode</em> argument is invalid, it must be one of : <em>none (= no value), js, js_charcode or hex</em>', E_USER_WARNING);
+
+	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/math.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/math.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/math.php	(revision 755)
@@ -0,0 +1,130 @@
+<?php
+
+/**
+ * Computes a mathematical equation
+ * <pre>
+ *  * equation : the equation to compute, it can include normal variables with $foo or special math variables without the dollar sign
+ *  * format : output format, see {@link http://php.net/sprintf} for details
+ *  * assign : if set, the output is assigned into the given variable name instead of being output
+ *  * rest : all math specific variables that you use must be defined, see the example
+ * </pre>
+ * Example :
+ *
+ * <code>
+ * {$c=2}
+ * {math "(a+b)*$c/4" a=3 b=5}
+ *
+ * output is : 4 ( = (3+5)*2/4)
+ * </code>
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+function Dwoo_Plugin_math_compile(Dwoo_Compiler $compiler, $equation, $format='', $assign='', array $rest=array())
+{
+	/**
+	 * Holds the allowed function, characters, operators and constants
+	 */
+	$allowed = array
+	(
+		'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
+		'+', '-', '/', '*', '.', ' ', '<<', '>>', '%', '&', '^', '|', '~',
+		'abs(', 'ceil(', 'floor(', 'exp(', 'log10(',
+		'cos(', 'sin(', 'sqrt(', 'tan(',
+		'M_PI', 'INF', 'M_E',
+	);
+
+	/**
+	 * Holds the functions that can accept multiple arguments
+	 */
+	$funcs = array
+	(
+ 		'round(', 'log(', 'pow(',
+		'max(', 'min(', 'rand(',
+ 	);
+
+	$equation = $equationSrc = str_ireplace(array('pi', 'M_PI()', 'inf', ' e '), array('M_PI', 'M_PI', 'INF', ' M_E '), $equation);
+
+	$delim = $equation[0];
+	$open = $delim.'.';
+	$close = '.'.$delim;
+	$equation = substr($equation, 1, -1);
+	$out = '';
+	$ptr = 1;
+	$allowcomma = 0;
+	while (strlen($equation) > 0) {
+		$substr = substr($equation, 0, $ptr);
+		if (array_search($substr, $allowed) !== false) {
+			// allowed string
+			$out.=$substr;
+			$equation = substr($equation, $ptr);
+			$ptr = 0;
+		} elseif (array_search($substr, $funcs) !== false) {
+			// allowed func
+			$out.=$substr;
+			$equation = substr($equation, $ptr);
+			$ptr = 0;
+			$allowcomma++;
+			if ($allowcomma === 1) {
+				$allowed[] = ',';
+			}
+		} elseif (isset($rest[$substr])) {
+			// variable
+			$out.=$rest[$substr];
+			$equation = substr($equation, $ptr);
+			$ptr = 0;
+		} elseif ($substr === $open) {
+			// pre-replaced variable
+			preg_match('#.*\((?:[^()]*?|(?R))\)'.str_replace('.', '\\.', $close).'#', substr($equation, 2), $m);
+			if (empty($m)) {
+				preg_match('#.*?'.str_replace('.', '\\.', $close).'#', substr($equation, 2), $m);
+			}
+			$out.=substr($m[0], 0, -2);
+			$equation = substr($equation, strlen($m[0])+2);
+			$ptr = 0;
+		} elseif ($substr==='(') {
+			// opening parenthesis
+			if ($allowcomma>0) {
+				$allowcomma++;
+			}
+
+			$out.=$substr;
+			$equation = substr($equation, $ptr);
+			$ptr = 0;
+		} elseif ($substr===')') {
+			// closing parenthesis
+			if ($allowcomma>0) {
+				$allowcomma--;
+				if ($allowcomma===0) {
+					array_pop($allowed);
+				}
+			}
+
+			$out.=$substr;
+			$equation = substr($equation, $ptr);
+			$ptr = 0;
+		} elseif ($ptr >= strlen($equation)) {
+			// parse error if we've consumed the entire equation without finding anything valid
+			throw new Dwoo_Compilation_Exception($compiler, 'Math : Syntax error or variable undefined in equation '.$equationSrc.' at '.$substr);
+			return;
+		} else {
+			// nothing special, advance
+			$ptr++;
+		}
+	}
+	if ($format !== '\'\'') {
+		$out = 'sprintf('.$format.', '.$out.')';
+	}
+	if ($assign !== '\'\'') {
+		return '($this->assignInScope('.$out.', '.$assign.'))';
+	}
+	return '('.$out.')';
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/nl2br.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/nl2br.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/nl2br.php	(revision 755)
@@ -0,0 +1,22 @@
+<?php
+
+/**
+ * Converts line breaks into <br /> tags
+ * <pre>
+ *  * value : the string to process
+ * </pre>
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+function Dwoo_Plugin_nl2br_compile(Dwoo_Compiler $compiler, $value)
+{
+	return 'nl2br((string) '.$value.')';
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/optional.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/optional.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/optional.php	(revision 755)
@@ -0,0 +1,23 @@
+<?php
+
+/**
+ * Prints out a variable without any notice if it doesn't exist
+ *
+ * <pre>
+ *  * value : the variable to print
+ * </pre>
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.1.1
+ * @date       2009-10-18
+ * @package    Dwoo
+ */
+function Dwoo_Plugin_optional_compile(Dwoo_Compiler $compiler, $value)
+{
+	return $value;
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/regex_replace.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/regex_replace.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/regex_replace.php	(revision 755)
@@ -0,0 +1,38 @@
+<?php
+
+/**
+ * Replaces the search string by the replace string using regular expressions
+ * <pre>
+ *  * value : the string to search into
+ *  * search : the string to search for, must be a complete regular expression including delimiters
+ *  * replace : the string to use as a replacement, must be a complete regular expression including delimiters
+ * </pre>
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+function Dwoo_Plugin_regex_replace(Dwoo_Core $dwoo, $value, $search, $replace)
+{
+	$search = (array) $search;
+	$cnt = count($search);
+
+	for ($i = 0; $i < $cnt; $i++) {
+		// Credits for this to Monte Ohrt who made smarty's regex_replace modifier
+		if (($pos = strpos($search[$i], "\0")) !== false) {
+			$search[$i] = substr($search[$i], 0, $pos);
+		}
+
+		if (preg_match('#[a-z\s]+$#is', $search[$i], $m) && (strpos($m[0], 'e') !== false)) {
+			$search[$i] = substr($search[$i], 0, -strlen($m[0])) . str_replace(array('e', ' '), '', $m[0]);
+		}
+	}
+
+	return preg_replace($search, $replace, $value);
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/replace.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/replace.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/replace.php	(revision 755)
@@ -0,0 +1,28 @@
+<?php
+
+/**
+ * Replaces the search string by the replace string
+ * <pre>
+ *  * value : the string to search into
+ *  * search : the string to search for
+ *  * replace : the string to use as a replacement
+ * </pre>
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+function Dwoo_Plugin_replace_compile(Dwoo_Compiler $compiler, $value, $search, $replace, $case_sensitive = true)
+{
+	if ($case_sensitive == 'false' || (bool)$case_sensitive === false) {
+		return 'str_ireplace('.$search.', '.$replace.', '.$value.')';
+	} else {
+		return 'str_replace('.$search.', '.$replace.', '.$value.')';
+	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/return.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/return.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/return.php	(revision 755)
@@ -0,0 +1,32 @@
+<?php
+
+/**
+ * Inserts another template into the current one
+ * <pre>
+ *  * file : the resource name of the template
+ *  * cache_time : cache length in seconds
+ *  * cache_id : cache identifier for the included template
+ *  * compile_id : compilation identifier for the included template
+ *  * data : data to feed into the included template, it can be any array and will default to $_root (the current data)
+ *  * assign : if set, the output of the included template will be saved in this variable instead of being output
+ *  * rest : any additional parameter/value provided will be added to the data array
+ * </pre>
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.1.0
+ * @date       2009-07-18
+ * @package    Dwoo
+ */
+function Dwoo_Plugin_return_compile(Dwoo_Compiler $compiler, array $rest = array())
+{
+    $out = array();
+    foreach ($rest as $var => $val) {
+        $out[] = '$this->setReturnValue('.var_export($var, true).', '.$val.')';
+    }
+    return '('.implode('.', $out).')';
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/reverse.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/reverse.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/reverse.php	(revision 755)
@@ -0,0 +1,34 @@
+<?php
+
+/**
+ * Reverses a string or an array
+ * <pre>
+ *  * value : the string or array to reverse
+ *  * preserve_keys : if value is an array and this is true, then the array keys are left intact
+ * </pre>
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+function Dwoo_Plugin_reverse(Dwoo_Core $dwoo, $value, $preserve_keys=false)
+{
+	if (is_array($value)) {
+		return array_reverse($value, $preserve_keys);
+	} elseif(($charset=$dwoo->getCharset()) === 'iso-8859-1') {
+		return strrev((string) $value);
+	} else {
+	    $strlen = mb_strlen($value);
+	    $out = '';
+	    while ($strlen--) {
+	        $out .= mb_substr($value, $strlen, 1, $charset);
+	    }
+		return $out;
+	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/safe.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/safe.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/safe.php	(revision 755)
@@ -0,0 +1,22 @@
+<?php
+
+/**
+ * Marks the variable as safe and removes the auto-escape function, only useful if you turned auto-escaping on
+ * <pre>
+ *  * var : the variable to pass through untouched
+ * </pre>
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+function Dwoo_Plugin_safe_compile(Dwoo_Compiler $compiler, $var)
+{
+	return preg_replace('#\(is_string\(\$tmp=(.+)\) \? htmlspecialchars\(\$tmp, ENT_QUOTES, \$this->charset\) : \$tmp\)#', '$1', $var);
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/spacify.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/spacify.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/spacify.php	(revision 755)
@@ -0,0 +1,23 @@
+<?php
+
+/**
+ * Adds spaces (or the given character(s)) between every character of a string
+ * <pre>
+ *  * value : the string to process
+ *  * space_char : the character(s) to insert between each character
+ * </pre>
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+function Dwoo_Plugin_spacify_compile(Dwoo_Compiler $compiler, $value, $space_char=' ')
+{
+	return 'implode('.$space_char.', str_split('.$value.', 1))';
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/string_format.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/string_format.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/string_format.php	(revision 755)
@@ -0,0 +1,23 @@
+<?php
+
+/**
+ * Formats a string using the sprintf function
+ * <pre>
+ *  * value : the string to format
+ *  * format : the format to use, see {@link http://php.net/sprintf} for details
+ * </pre>
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+function Dwoo_Plugin_string_format_compile(Dwoo_Compiler $compiler, $value, $format)
+{
+	return 'sprintf('.$format.','.$value.')';
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/strip_tags.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/strip_tags.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/strip_tags.php	(revision 755)
@@ -0,0 +1,27 @@
+<?php
+
+/**
+ * Removes all html tags
+ * <pre>
+ *  * value : the string to process
+ *  * addspace : if true, a space is added in place of every removed tag
+ * </pre>
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+function Dwoo_Plugin_strip_tags_compile(Dwoo_Compiler $compiler, $value, $addspace=true)
+{
+	if ($addspace==='true') {
+		return "preg_replace('#<[^>]*>#', ' ', $value)";
+	} else {
+		return "strip_tags($value)";
+	}
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/tif.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/tif.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/tif.php	(revision 755)
@@ -0,0 +1,74 @@
+<?php
+
+/**
+ * Ternary if operation
+ *
+ * It evaluates the first argument and returns the second if it's true, or the third if it's false
+ * <pre>
+ *  * rest : you can not use named parameters to call this, use it either with three arguments in the correct order (expression, true result, false result) or write it as in php (expression ? true result : false result)
+ * </pre>
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+function Dwoo_Plugin_tif_compile(Dwoo_Compiler $compiler, array $rest, array $tokens)
+{
+	// load if plugin
+	if (!class_exists('Dwoo_Plugin_if', false)) {
+		try {
+			$compiler->getDwoo()->getLoader()->loadPlugin('if');
+		} catch (Exception $e) {
+			throw new Dwoo_Compilation_Exception($compiler, 'Tif: the if plugin is required to use Tif');
+		}
+	}
+
+	if (count($rest) == 1) {
+		return $rest[0];
+	}
+
+	// fetch false result and remove the ":" if it was present
+	$falseResult = array_pop($rest);
+
+	if (trim(end($rest), '"\'') === ':') {
+		// remove the ':' if present
+		array_pop($rest);
+	} elseif (trim(end($rest), '"\'') === '?' || count($rest) === 1) {
+		if ($falseResult === '?' || $falseResult === ':') {
+			throw new Dwoo_Compilation_Exception($compiler, 'Tif: incomplete tif statement, value missing after '.$falseResult);
+		}
+		// there was in fact no false result provided, so we move it to be the true result instead
+		$trueResult = $falseResult;
+		$falseResult = "''";
+	}
+
+	// fetch true result if needed
+	if (!isset($trueResult)) {
+		$trueResult = array_pop($rest);
+		// no true result provided so we use the expression arg
+		if ($trueResult === '?') {
+			$trueResult = true;
+		}
+	}
+
+	// remove the '?' if present
+	if (trim(end($rest), '"\'') === '?') {
+		array_pop($rest);
+	}
+
+	// check params were correctly provided
+	if (empty($rest) || $trueResult === null || $falseResult === null) {
+		throw new Dwoo_Compilation_Exception($compiler, 'Tif: you must provide three parameters serving as <expression> ? <true value> : <false value>');
+	}
+
+	// parse condition
+	$condition = Dwoo_Plugin_if::replaceKeywords($rest, $tokens, $compiler);
+
+	return '(('.implode(' ', $condition).') ? '.($trueResult===true ? implode(' ', $condition) : $trueResult).' : '.$falseResult.')';
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/truncate.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/truncate.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/truncate.php	(revision 755)
@@ -0,0 +1,45 @@
+<?php
+
+/**
+ * Truncates a string at the given length
+ * <pre>
+ *  * value : text to truncate
+ *  * length : the maximum length for the string
+ *  * etc : the characters that are added to show that the string was cut off
+ *  * break : if true, the string will be cut off at the exact length, instead of cutting at the nearest space
+ *  * middle : if true, the string will contain the beginning and the end, and the extra characters will be removed from the middle
+ * </pre>
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.1.0
+ * @date       2009-07-18
+ * @package    Dwoo
+ */
+function Dwoo_Plugin_truncate(Dwoo_Core $dwoo, $value, $length=80, $etc='...', $break=false, $middle=false)
+{
+	if ($length == 0) {
+		return '';
+	}
+
+	$value = (string) $value;
+	$etc = (string) $etc;
+	$length = (int) $length;
+
+	if (strlen($value) < $length) {
+		return $value;
+	}
+
+	$length = max($length - strlen($etc), 0);
+	if ($break === false && $middle === false) {
+		$value = preg_replace('#\s+(\S*)?$#', '', substr($value, 0, $length+1));
+	}
+	if ($middle === false) {
+		return substr($value, 0, $length) . $etc;
+	}
+	return substr($value, 0, ceil($length/2)) . $etc . substr($value, -floor($length/2));
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/upper.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/upper.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/upper.php	(revision 755)
@@ -0,0 +1,22 @@
+<?php
+
+/**
+ * Makes a string uppercased
+ * <pre>
+ *  * value : the text to uppercase
+ * </pre>
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+function Dwoo_Plugin_upper_compile(Dwoo_Compiler $compiler, $value)
+{
+	return 'mb_strtoupper((string) '.$value.', $this->charset)';
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/whitespace.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/whitespace.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/whitespace.php	(revision 755)
@@ -0,0 +1,33 @@
+<?php
+
+/**
+ * Replaces all white-space characters with the given string
+ * <pre>
+ *  * value : the text to process
+ *  * with : the replacement string, note that any number of consecutive white-space characters will be replaced by a single replacement string
+ * </pre>
+ * Example :
+ *
+ * <code>
+ * {"a    b  c		d
+ *
+ * e"|whitespace}
+ *
+ * results in : a b c d e
+ * </code>
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+function Dwoo_Plugin_whitespace_compile(Dwoo_Compiler $compiler, $value, $with=' ')
+{
+	return "preg_replace('#\s+#'.(strcasecmp(\$this->charset, 'utf-8')===0?'u':''), $with, $value)";
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/wordwrap.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/wordwrap.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/functions/wordwrap.php	(revision 755)
@@ -0,0 +1,25 @@
+<?php
+
+/**
+ * Wraps a text at the given line length
+ * <pre>
+ *  * value : the text to wrap
+ *  * length : maximum line length
+ *  * break : the character(s) to use to break the line
+ *  * cut : if true, the line is cut at the exact length instead of breaking at the nearest space
+ * </pre>
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+function Dwoo_Plugin_wordwrap_compile(Dwoo_Compiler $compiler, $value, $length=80, $break="\n", $cut=false)
+{
+	return 'wordwrap('.$value.','.$length.','.$break.','.$cut.')';
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/helper.array.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/helper.array.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/helper.array.php	(revision 755)
@@ -0,0 +1,36 @@
+<?php
+
+/**
+ * Builds an array with all the provided variables, use named parameters to make an associative array
+ * <pre>
+ *  * rest : any number of variables, strings or anything that you want to store in the array
+ * </pre>
+ * Example :
+ *
+ * <code>
+ * {array(a, b, c)} results in array(0=>'a', 1=>'b', 2=>'c')
+ * {array(a=foo, b=5, c=array(4,5))} results in array('a'=>'foo', 'b'=>5, 'c'=>array(0=>4, 1=>5))
+ * </code>
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+function Dwoo_Plugin_array_compile(Dwoo_Compiler $compiler, array $rest=array())
+{
+	$out = array();
+	foreach ($rest as $key => $value) {
+		if (!is_numeric($key) && !strstr($key, '$this->scope')) {
+			$key = "'".$key."'";
+		}
+		$out[] = $key.'=>'.$value;
+	}
+	return 'array('.implode(', ', $out).')';
+}
Index: /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/processors/pre.smarty_compat.php
===================================================================
--- /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/processors/pre.smarty_compat.php	(revision 755)
+++ /branches/0.4/web/addons/job_monarch/dwoo/plugins/builtin/processors/pre.smarty_compat.php	(revision 755)
@@ -0,0 +1,73 @@
+<?php
+
+/**
+ * Performs some template conversions to allow smarty templates to be used by
+ * the Dwoo compiler.
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from the use of this software.
+ *
+ * @author     Jordi Boggiano <j.boggiano@seld.be>
+ * @copyright  Copyright (c) 2008, Jordi Boggiano
+ * @license    http://dwoo.org/LICENSE   Modified BSD License
+ * @link       http://dwoo.org/
+ * @version    1.0.0
+ * @date       2008-10-23
+ * @package    Dwoo
+ */
+class Dwoo_Processor_smarty_compat extends Dwoo_Processor
+{
+	public function process($input)
+	{
+		list($l, $r) = $this->compiler->getDelimiters();
+
+		$rl = preg_quote($l,'/');
+		$rr = preg_quote($r,'/');
+		$sectionParam = '(?:(name|loop|start|step|max|show)\s*=\s*(\S+))?\s*';
+		$input = preg_replace_callback('/'.$rl.'\s*section '.str_repeat($sectionParam, 6).'\s*'.$rr.'(.+?)(?:'.$rl.'\s*sectionelse\s*'.$rr.'(.+?))?'.$rl.'\s*\/section\s*'.$rr.'/is', array($this, 'convertSection'), $input);
+		$input = str_replace('$smarty.section.', '$smarty.for.', $input);
+
+		$smarty = array
+		(
+			'/'.$rl.'\s*ldelim\s*'.$rr.'/',
+			'/'.$rl.'\s*rdelim\s*'.$rr.'/',
+			'/'.$rl.'\s*\$smarty\.ldelim\s*'.$rr.'/',
+			'/'.$rl.'\s*\$smarty\.rdelim\s*'.$rr.'/',
+			'/\$smarty\./',
+			'/'.$rl.'\s*php\s*'.$rr.'/',
+			'/'.$rl.'\s*\/php\s*'.$rr.'/',
+			'/\|(@?)strip(\||'.$rr.')/',
+			'/'.$rl.'\s*sectionelse\s*'.$rr.'/',
+		);
+
+		$dwoo = array
+		(
+			'\\'.$l,
+			$r,
+			'\\'.$l,
+			$r,
+			'$dwoo.',
+			'<?php ',
+			' ?>',
+			'|$1whitespace$2',
+			$l.'else'.$r,
+		);
+
+		if (preg_match('{\|@([a-z][a-z0-9_]*)}i', $input, $matches)) {
+			trigger_error('The Smarty Compatibility Module has detected that you use |@'.$matches[1].' in your template, this might lead to problems as Dwoo interprets the @ operator differently than Smarty, see http://wiki.dwoo.org/index.php/Syntax#The_.40_Operator', E_USER_NOTICE);
+		}
+
+		return preg_replace($smarty, $dwoo, $input);
+	}
+
+	protected function convertSection(array $matches)
+	{
+		$params = array();
+		$index = 1;
+		while (!empty($matches[$index]) && $index < 13) {
+			$params[$matches[$index]] = $matches[$index+1];
+			$index += 2;
+		}
+		return str_replace('['.trim($params['name'], '"\'').']', '[$'.trim($params['name'], '"\'').']', $matches[0]);
+	}
+}
