* Tidied up admin API
[simplicity.git] / source / lib / simplicity / modules / error / admin / errors.php
blobb34f795f4209eaaf100dc808e05fb0f7a1c32b7d
1 <?php
2 /**
3 * Errors
5 * View the Simplicity error log.
7 * @author John Le Drew <jp@antz29.com>
8 * @copyright Copyright (c) 2009, John Le Drew
9 * @license http://www.opensource.org/licenses/mit-license.php MIT License
10 * @version 2.0.0-alpha
12 * @s-logo /_static/admin:errors/img/nav/errors.png
14 class smp_ErrorsAdminController extends smp_AdminController {
16 public function adminPreAction()
18 $db = smp_DataConnectionManager::getConnection('errors');
19 $t = smp_DataTable::create('error_log',$db);
21 $this->registerRestfulTable(smp_DataTable::create('error_log',$db));
22 $this->registerRestfulMethod('getClear');
25 public function getIndexAction()
27 $db = smp_DataConnectionManager::getConnection('errors');
29 try {
30 $e = smp_DataTable::create('error_log',$db);
31 $this->getView()->set('errors',$e->search('all')->orderBy(array('date'=>'desc')));
32 } catch (Exception $e) {
33 $this->getView()->set('errors',array());
38 public function getDetailsAction()
40 $db = smp_DataConnectionManager::getConnection('errors');
42 try {
43 $e = smp_DataTable::create('error_log',$db);
44 if (!$e->find(array('id'=>$this->_uri['id']))) {
45 return;
48 $t = $this->getView();
49 $t->set('code',$e->code);
50 $t->set('message',$e->msg);
51 $t->set('file',$e->file);
52 $t->set('line',$e->line);
53 $t->set('trace',unserialize($e->trace));
54 $t->set('context',$e->context);
55 $t->set('headers',unserialize($e->headers));
56 } catch (Exception $e) {
57 $this->setStatus('404','404 Not Found');
62 public function getClear()
64 $db = smp_DataConnectionManager::getConnection('errors');
65 return $db->query('delete from error_log');