<?php
/***************************************************************************
- * Copyright (C) 2003-2010 Polytechnique.org *
+ * Copyright (C) 2003-2011 Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
return array($this->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]));
}
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');
}
}
-// 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:
?>