git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1246 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
139 lines
3.3 KiB
PHP
139 lines
3.3 KiB
PHP
<?php
|
|
/** DomFramework Blog
|
|
@package domframework-blog
|
|
@author Dominique Fournier <dominique@fournier38.fr> */
|
|
|
|
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;
|
|
};
|
|
}
|
|
}
|