X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=classes%2Fplerrorreport.php;h=2dee64ed530b23ce22fbc9161d2cdaa2efa8b4ec;hb=75b5406387c0c362517dd905d561f7b616dddc96;hp=194cd1bf9840b733e7872095e0e1bd730153dfc5;hpb=88541046480799a8d92eba186f22e22c0c64efb0;p=platal.git diff --git a/classes/plerrorreport.php b/classes/plerrorreport.php index 194cd1b..2dee64e 100644 --- a/classes/plerrorreport.php +++ b/classes/plerrorreport.php @@ -1,6 +1,6 @@ date, $this->error, serialize($this->state)); } - public function fromCSV(array $entry) + public static function fromCSV(array $entry) { return new PlErrorReport($entry[0], $entry[1], unserialize($entry[2])); } @@ -62,6 +62,12 @@ class PlErrorReport return new PlErrorReportIterator(); } + public static function feed(PlPage $page, PlUser $user) + { + $feed = new PlErrorReportFeed(); + return $feed->run($page, $user); + } + public static function clear() { @unlink(Platal::globals()->spoolroot . '/spool/tmp/site_errors'); @@ -113,5 +119,39 @@ class PlErrorReportIterator implements PlIterator } } -// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: +class PlErrorReportFeed extends PlFeed +{ + public function __construct() + { + global $globals; + parent::__construct($globals->core->sitename . ' :: News', + $globals->baseurl . '/site_errors', + 'Erreurs d\'exécution', + $globals->baseurl . '/images/logo.png', + $globals->coreroot . '/templates/site_errors.feed.tpl'); + } + + protected function fetch(PlUser $user) + { + global $globals; + $it = PlErrorReport::iterate(); + $data = array(); + while ($row = $it->next()) { + $title = explode("\n", $row->error); + $title = $title[0]; + $line = array(); + $line['id'] = $row->date + count($data); + $line['author'] = 'admin'; + $line['link'] = $globals->baseurl . '/site_errors'; + $line['data'] = $row; + $line['title'] = $title; + $line['last_modification'] = $row->date; + $line['publication'] = $row->date; + $data[] = $line; + } + return PlIteratorUtils::fromArray($data, 1, true); + } +} + +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8: ?>