name = 'wiz_' . $name; $this->layout = $layout; $this->stateless = $stateless; $this->pages = array(); $this->lookup = array(); if (!isset($_SESSION[$this->name])) { $_SESSION[$this->name] = array(); } $_SESSION[$this->name . '_page'] = null; } public function addPage($class, $id = null) { if ($id != null) { $this->lookup[$id] = count($this->pages); } $this->pages[] = $class; } public function set($varname, $value) { $_SESSION[$this->name][$varname] = $value; } public function get($varname, $default = null) { return isset($_SESSION[$this->name][$varname]) ? $_SESSION[$this->name][$varname] : $default; } public function v($varname, $default = "") { return $this->get($varname, $default); } public function i($varname, $default = 0) { return (int)$this->get($varname, $default); } public function clear($varname = null) { if (is_null($varname)) { $_SESSION[$this->name] = array(); } else { unset($_SESSION[$this->name][$varname]); } $_SESSION[$this->name . '_page'] = null; } private function &getPage($id) { $page = $this->pages[$id]; return new $page($this); } public function apply(PlatalPage &$smarty, $baseurl, $pgid = null) { $curpage =& $_SESSION[$this->name . '_page']; // Process the previous page if (!is_null($curpage)) { $page = $this->getPage($curpage); $next = $page->process(); switch ($next) { case PlWizard::FIRST_PAGE: $curpage = 0; break; case PlWizard::PREVIOUS_PAGE: $curpage--; break; case PlWizard::NEXT_PAGE: $curpage++; break; case PlWizard::LAST_PAGE: $curpage = count($this->pages) - 1; break; case PlWizard::CURRENT_PAGE: break; // don't change the page default: $curpage = is_numeric($next) ? $next : $this->lookup[$curpage]; break; } } else { $curpage = 0; } if ($this->stateless && (in_array($pgid, $this->lookup) || isset($this->pages[$pgid]))) { $curpage = $pgid; } // Prepare the page $page = $this->getPage($curpage); $smarty->assign('wiz_page', $page->template()); $page->prepare($smarty); } } // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: ?>