_uses = array_merge($this->_uses, $args); } public function assign($arg0 = null, $arg1 = null) { if (is_string($arg0)) { $this->_vars[$arg0] = $arg1; }elseif (is_array($arg0)) { $this->_vars += $arg0; }elseif (is_object($arg0)) { $this->_vars += get_object_vars($arg0); } } public function getTheme() { return $this->_theme; } public function setTheme($theme) { // Check available themes $theme = trim($theme, '/'); $themes = Flyspray::listThemes(); if (in_array($theme, $themes)) { $this->_theme = $theme.'/'; } else { $this->_theme = $themes[0].'/'; } } public function setTitle($title) { $this->_title = $title; } public function themeUrl() { return sprintf('%sthemes/%s', $GLOBALS['baseurl'], $this->_theme); } public function pushTpl($_tpl) { $this->_tpls[] = $_tpl; } public function catch_start() { ob_start(); } public function catch_end() { $this->_tpls[] = array(ob_get_contents()); ob_end_clean(); } public function display($_tpl, $_arg0 = null, $_arg1 = null) { // if only plain text if (is_array($_tpl) && count($tpl)) { echo $_tpl[0]; return; } // variables part if (!is_null($_arg0)) { $this->assign($_arg0, $_arg1); } foreach ($this->_uses as $_var) { global $$_var; } extract($this->_vars, EXTR_REFS|EXTR_SKIP); if (is_readable(BASEDIR . '/themes/' . $this->_theme.'templates/'.$_tpl)) { require BASEDIR . '/themes/' . $this->_theme.'templates/'.$_tpl; } elseif (is_readable(BASEDIR . '/themes/CleanFS/templates/'.$_tpl)) { # if a custom theme folder only contains a fraction of the .tpl files, use the template of the default full theme as fallback. require BASEDIR . '/themes/CleanFS/templates/'.$_tpl; } else { # This is needed to catch times when there is no theme (for example setup pages, where BASEDIR is ../setup/ not ../) require BASEDIR . "/templates/".$_tpl; } } public function render() { while (count($this->_tpls)) { $this->display(array_shift($this->_tpls)); } } public function fetch($tpl, $arg0 = null, $arg1 = null) { ob_start(); $this->display($tpl, $arg0, $arg1); return ob_get_clean(); } } class FSTpl extends Tpl { public $_uses = array('fs', 'conf', 'baseurl', 'language', 'proj', 'user'); public function get_image($name, $base = true) { global $proj, $baseurl; $pathinfo = pathinfo($name); $link = sprintf('themes/%s/', $proj->prefs['theme_style']); if ($pathinfo['dirname'] != '.') { $link .= $pathinfo['dirname'] . '/'; $name = $pathinfo['basename']; } $extensions = array('.png', '.gif', '.jpg', '.ico'); foreach ($extensions as $ext) { if (is_file(BASEDIR . '/' . $link . $name . $ext)) { return ($base) ? ($baseurl . $link . $name . $ext) : ($link . $name . $ext); } } return ''; } } /** * Draws the form start tag and the important anticsrftoken on 'post'-forms * * @param string action * @param string name optional attribute of form tag * @param string method optional request method, default 'post' * @param string enctype optional enctype, default 'multipart/form-data' * @param string attr optional attributes for the form tag, example: 'id="myformid" class="myextracssclass"' * * @return string */ function tpl_form($action, $name=null, $method=null, $enctype=null, $attr='') { global $baseurl; if (null === $method) { $method='post'; } if (null === $enctype) { $enctype='multipart/form-data'; } if(substr($action,0,4)!='http'){$action=$baseurl.$action;} return '