X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=classes%2Fplpage.php;h=63ece95d1ca64b1b8cd74a6a57d3e8c01c7137d7;hb=4d1c62e006bc896e9ddb59d15dc7a7e30f9eb48e;hp=875981e674af398446983a1985c80ef609b4dbff;hpb=fc2cfa65c5e0d22fb1711827009064bc1909c1c6;p=platal.git diff --git a/classes/plpage.php b/classes/plpage.php index 875981e..63ece95 100644 --- a/classes/plpage.php +++ b/classes/plpage.php @@ -134,6 +134,12 @@ abstract class PlPage extends Smarty $this->_page_typ = SKINNED; } + if ($this->_page_type == SIMPLE) { + $this->assign('simple', true); + } else { + $this->assign('simple', false); + } + switch ($this->_page_type) { case NO_SKIN: if (!($globals->debug & DEBUG_SMARTY)) { @@ -143,8 +149,6 @@ abstract class PlPage extends Smarty exit; case SIMPLE: - $this->assign('simple', true); - case SKINNED: $this->register_modifier('escape_html', 'escape_html'); $this->default_modifiers = Array('@escape_html'); @@ -242,6 +246,34 @@ abstract class PlPage extends Smarty } // }}} + // {{{ function trigRedirect + + // Acts as trig(), but replaces the template with a simple one displaying + // the error messages and a "continue" link. + private function trigRedirect($msg, $continue, $type = 'errors') + { + $this->trig($msg, $type); + $this->coreTpl('msgredirect.tpl'); + $this->assign('continue', $continue); + $this->run(); + } + + public function trigErrorRedirect($msg, $continue) + { + $this->trigRedirect($msg, $continue, 'errors'); + } + + public function trigWarningRedirect($msg, $continue) + { + $this->trigRedirect($msg, $continue, 'warnings'); + } + + public function trigSuccessRedirect($msg, $continue) + { + $this->trigRedirect($msg, $continue, 'success'); + } + + // }}} // {{{ function kill() public function kill($msg, $type = 'errors') @@ -338,6 +370,10 @@ abstract class PlPage extends Smarty protected function jsonDisplay() { pl_content_headers("text/javascript"); + if (!empty($GLOBALS['pl_errors'])) { + $this->jsonAssign('pl_errors', join("\n", $GLOBALS['pl_errors'])); + $GLOBALS['pl_errors'] = array(); + } array_walk_recursive($this->_jsonVars, "escape_xorgDB"); $jsonbegin = Env::v('jsonBegin'); $jsonend = Env::v('jsonEnd');