*/ error_reporting (E_ALL); /** The main class : manage all the blogs articles */ class blog { /** Return an article @param string|integer|null $articleid The article to display */ private function get ($articleid = FALSE) { require_once ("models/model_file.php"); $data = new model_file(); return $data->get ($articleid); } /** Return an article in text @param string|integer|null $articleid The article to display */ public function getTxt ($articleid = FALSE) { try { $res = $this->get ($articleid); $renderer = new renderer (); $renderer->output = "txt"; $renderer->result = $res; $renderer->run (); exit; } catch (Exception $e) {}; } /** Return an article in xml @param string|integer|null $articleid The article to display */ public function getXml ($articleid = FALSE) { try { $res = $this->get ($articleid); $renderer = new renderer (); $renderer->output = "xml"; $renderer->result = $res; $renderer->run (); exit; } catch (Exception $e) {}; } /** Return an article in CSV @param string|integer|null $articleid The article to display */ public function getCsv ($articleid = FALSE) { try { $res = $this->get ($articleid); $renderer = new renderer (); $renderer->output = "csv"; $renderer->result = $res; $renderer->run (); exit; } catch (Exception $e) {}; } /** Return an article in JSON @param string|integer|null $articleid The article to display */ public function getJson ($articleid = FALSE) { try { $res = $this->get ($articleid); $renderer = new renderer (); $renderer->output = "json"; $renderer->result = $res; $renderer->run (); exit; } catch (Exception $e) {}; } /** Return an article in HTML @param string|integer|null $articleid The article to display */ public function getHtml ($articleid = FALSE) { try { $res = $this->get ($articleid); $renderer = new renderer (); $renderer->output = "html"; $renderer->result = $res; $renderer->viewClass = "view_blog"; $renderer->viewMethod = "get"; $renderer->layout = "layout"; // $renderer->title = "Super Title"; $renderer->run (); exit; } catch (Exception $e) { // TODO !! echo "404 with ".$e->getMessage(); exit; }; } /** Return the listing of all the recorded articles */ public function listing () { require_once ("models/model_file.php"); $data = new model_file(); return $data->listing (); } /** Return the listing of all the recorded articles in HTML */ public function listingHtml () { try { $res = $this->listing (); $renderer = new renderer (); $renderer->output = "html"; $renderer->result = $res; $renderer->viewClass = "view_blog"; $renderer->viewMethod = "listing"; $renderer->layout = "layout"; $renderer->run (); exit; } catch (Exception $e) { // TODO !! echo "404 with ".$e->getMessage(); exit; }; } }