From: <pan...@us...> - 2008-09-25 11:10:52
|
Revision: 382 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=382&view=rev Author: panzaboi Date: 2008-09-25 11:10:50 +0000 (Thu, 25 Sep 2008) Log Message: ----------- Error: New Error Management Index: LoginForm using Dojo Archive: list and view problems implemented Modified Paths: -------------- website/application/default/controllers/ArchieveController.php website/application/default/controllers/ErrorController.php website/application/default/controllers/IndexController.php Modified: website/application/default/controllers/ArchieveController.php =================================================================== --- website/application/default/controllers/ArchieveController.php 2008-09-25 11:10:06 UTC (rev 381) +++ website/application/default/controllers/ArchieveController.php 2008-09-25 11:10:50 UTC (rev 382) @@ -4,8 +4,17 @@ { public function indexAction() { - $this->_helper->getHelper('viewRenderer')->setNoRender(true); + $this->view->challenges = $this->_model->getChallenges(); } -} - -?> \ No newline at end of file + + public function viewAction() + { + $id = $this->_getParam('id'); + $problem = $this->_model->get($id); + + if (!$problem) + return $this->_forward('index', null, null, $this->_getAllParams() + array('message' => 'noProblem')); + + $this->view->problem = $problem; + } +} \ No newline at end of file Modified: website/application/default/controllers/ErrorController.php =================================================================== --- website/application/default/controllers/ErrorController.php 2008-09-25 11:10:06 UTC (rev 381) +++ website/application/default/controllers/ErrorController.php 2008-09-25 11:10:50 UTC (rev 382) @@ -4,33 +4,23 @@ { public function errorAction() { - $errors = $this->_getParam('error_handler'); - $this->_helper->getHelper('viewRenderer')->setNoRender(true); + $this->getResponse()->clearBody(); + $error = $this->_getParam('error_handler'); - switch ($errors->type) { + switch ($error->type) { case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER: case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION: - // 404 error -- controller or action not found - $this->getResponse()->setRawHeader('HTTP/1.1 404 Not Found'); - - $content =<<<EOH -<h1>Error!</h1> -<p>The page you requested was not found.</p> -EOH; - break; + $this->getResponse()->setHttpResponseCode(404); + + $this->view->msg = $this->view->translate('error_404'); + break; default: - // application error - $content =<<<EOH -<h1>Error!</h1> -<p>An unexpected error occurred with your request. Please try again later.</p> -EOH; - break; + $this->view->msg = $this->view->translate('error_other'); + break; } - - // Clear previous content - $this->getResponse()->clearBody(); - $this->getResponse()->appendBody($content); + + $this->view->env = $this->getInvokeArg('environment'); + $this->view->exception = $error->exception; + $this->view->request = $error->request; } -} - -?> \ No newline at end of file +} \ No newline at end of file Modified: website/application/default/controllers/IndexController.php =================================================================== --- website/application/default/controllers/IndexController.php 2008-09-25 11:10:06 UTC (rev 381) +++ website/application/default/controllers/IndexController.php 2008-09-25 11:10:50 UTC (rev 382) @@ -4,31 +4,50 @@ { public function indexAction() { - $this->_helper->getHelper('viewRenderer')->setNoRender(true); - + echo $this->getLoginForm(); + } + + public function loginAction() + { $form = $this->getLoginForm(); if (!$this->getRequest()->isPost()) { - echo $form; - return; + return $this->_forward('index', null, null, $this->_getAllParams()); } if (!$form->isValid($this->getRequest()->getPost())) { - echo $form; - return; + $this->view->form = $form; + $this->renderScript('layout/loginform.phtml', 'login'); + return $this->_forward('index'); } $values = $form->getValues(); + $result = $this->_model->authoricate($values); if (!$result) { - $form->setDescription('Wrong Username/Password combination!'); - echo $form; - return; + $form->setDescription($this->view->translate('wrongEmailPwd')); + $this->view->form = $form; + $this->renderScript('layout/loginform.phtml', 'login'); + + return $this->_forward('index'); } + + $redirect = new Zend_Session_Namespace('Redirect'); + if ($redirect->to) + { + $this->getRequest()->setParam('redirect', $redirect->to); + $redirect->unsetAll(); + } + else + { + return $this->_redirect('/index/index'); + } + + $this->_helper->getHelper('viewRenderer')->setNoRender(true); } protected function getLoginForm() @@ -39,6 +58,4 @@ 'name' => 'loginform', )); } -} - -?> \ No newline at end of file +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |