X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=classes%2Fplwizard.php;h=e12eec7f45c608c087a92152575255df406d307a;hb=b1ee04c545a3ec61d0464afee7222be8b98424c4;hp=78242f24adcdc60c71c05f5e2b645f113cf55bfd;hpb=ddb649901f5a88d695a7050f2a59da140842ec89;p=platal.git diff --git a/classes/plwizard.php b/classes/plwizard.php deleted file mode 100644 index 78242f2..0000000 --- a/classes/plwizard.php +++ /dev/null @@ -1,219 +0,0 @@ -name = 'wiz_' . $name; - $this->layout = $layout; - $this->stateless = $stateless; - $this->pages = array(); - $this->lookup = array(); - $this->titles = array(); - $this->ajax = $ajax; - if (!isset($_SESSION[$this->name])) { - $_SESSION[$this->name] = array(); - $_SESSION[$this->name . '_page'] = null; - $_SESSION[$this->name . '_stack'] = array(); - } - } - - public function addPage($class, $title, $id = null) - { - if ($id == null) { - $id = count($this->pages); - } - $this->lookup[$id] = count($this->pages); - $this->inv_lookup[] = $id; - $this->pages[] = $class; - $this->titles[] = $title; - } - - 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, $mode = 'normal') - { - if ($this->stateless && (isset($this->lookup[$pgid]) || isset($this->pages[$pgid]))) { - $curpage = is_numeric($pgid) ? $pgid : $this->lookup[$pgid]; - } else if ($this->stateless && is_null($pgid)) { - $curpage = 0; - } else { - $curpage = $_SESSION[$this->name . '_page']; - } - $oldpage = $curpage; - - // Process the previous page - if (Post::has('valid_page')) { - $page = $this->getPage(Post::i('valid_page')); - $curpage = Post::i('valid_page'); - $next = $page->process(); - $last = $curpage; - switch ($next) { - case PlWizard::FIRST_PAGE: - $curpage = 0; - break; - case PlWizard::PREVIOUS_PAGE: - if (!$this->stateless && count($_SESSION[$this->name . '_stack'])) { - $curpage = array_pop($_SESSION[$this->name . '_stack']); - } elseif ($curpage && $this->stateless) { - $curpage--; - } else { - $curpage = 0; - } - break; - case PlWizard::NEXT_PAGE: - if ($curpage < count($this->pages) - 1) { - $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[$next]; - break; - } - if (!$this->stateless) { - array_push($_SESSION[$this->name . '_stack'], $last); - } - } - if (is_null($curpage)) { - $curpage = 0; - } - - // Prepare the page - $_SESSION[$this->name . '_page'] = $curpage; - if ($curpage != $oldpage) { - pl_redirect($baseurl . '/' . $this->inv_lookup[$curpage]); - } else if (!isset($page)) { - $page = $this->getPage($curpage); - } - if ($mode == 'ajax') { - header('Content-Type: text/html; charset=utf-8'); - $smarty->changeTpl($page->template(), NO_SKIN); - } else { - $smarty->changeTpl($this->layout); - } - $smarty->assign('pages', $this->titles); - $smarty->assign('current', $curpage); - $smarty->assign('lookup', $this->inv_lookup); - $smarty->assign('stateless', $this->stateless); - $smarty->assign('wiz_baseurl', $baseurl); - $smarty->assign('wiz_ajax', $this->ajax); - $smarty->assign('tab_width', (int)(99 / count($this->pages))); - $smarty->assign('wiz_page', $page->template()); - $smarty->assign('xorg_no_errors', true); - $page->prepare($smarty, isset($this->inv_lookup[$curpage]) ? $this->inv_lookup[$curpage] : $curpage); - } -} - -// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: -?>