remove the examples
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2244 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
@@ -1,21 +0,0 @@
|
|||||||
Options -Indexes
|
|
||||||
<IfModule mod_rewrite.c>
|
|
||||||
RewriteEngine on
|
|
||||||
# if your app is in a subfolder
|
|
||||||
# RewriteBase /my_app/
|
|
||||||
# test string is a valid files
|
|
||||||
RewriteCond %{SCRIPT_FILENAME} !-f
|
|
||||||
# test string is a valid directory
|
|
||||||
RewriteCond %{SCRIPT_FILENAME} !-d
|
|
||||||
RewriteRule ^(.*)$ index.php?uri=/$1 [NC,L,QSA]
|
|
||||||
# with QSA flag (query string append),
|
|
||||||
# forces the rewrite engine to append a query string part of the
|
|
||||||
# substitution string to the existing string, instead of replacing it.
|
|
||||||
</IfModule>
|
|
||||||
|
|
||||||
# Allow to see a /.html file without having a Forbidden due to Apache conf
|
|
||||||
<FilesMatch "^\.html">
|
|
||||||
Satisfy Any
|
|
||||||
Allow from all
|
|
||||||
</FilesMatch>
|
|
||||||
|
|
||||||
@@ -1,198 +0,0 @@
|
|||||||
<?php
|
|
||||||
/** DomFramework Blog
|
|
||||||
@package domframework-blog
|
|
||||||
@author Dominique Fournier <dominique@fournier38.fr> */
|
|
||||||
|
|
||||||
require ("domframework/form.php");
|
|
||||||
require_once ("models/model_file.php");
|
|
||||||
|
|
||||||
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 = $res["title"];
|
|
||||||
$renderer->variable = array (
|
|
||||||
"title"=>$res["title"],
|
|
||||||
"content"=>$res["content"],
|
|
||||||
"articleid"=>$articleid,
|
|
||||||
);
|
|
||||||
$renderer->run ();
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
catch (Exception $e)
|
|
||||||
{
|
|
||||||
// TODO !!
|
|
||||||
echo "404 with ".$e->getMessage();
|
|
||||||
exit;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Return the listing of all the recorded articles */
|
|
||||||
public function listing ()
|
|
||||||
{
|
|
||||||
$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;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Edit the provided article $articleid */
|
|
||||||
public function editShow ($articleid=false)
|
|
||||||
{
|
|
||||||
if ($articleid !== false)
|
|
||||||
$res = $this->get ($articleid);
|
|
||||||
else
|
|
||||||
$res = array ("title"=>"", "content"=>"");
|
|
||||||
|
|
||||||
$field = new formfield ("title", "Title");
|
|
||||||
$field->mandatory = true;
|
|
||||||
$formFields[] = $field;
|
|
||||||
$field = new formfield ("content", "Content");
|
|
||||||
$field->mandatory = true;
|
|
||||||
$formFields[] = $field;
|
|
||||||
$field = new formfield ("submit", "Record");
|
|
||||||
$field->type = "submit";
|
|
||||||
$formFields[] = $field;
|
|
||||||
|
|
||||||
$f = new form ();
|
|
||||||
$f->fields ($formFields);
|
|
||||||
|
|
||||||
$renderer = new renderer ();
|
|
||||||
$renderer->output = "html";
|
|
||||||
$renderer->viewClass = "view_blog";
|
|
||||||
$renderer->viewMethod = "edit";
|
|
||||||
$renderer->layout = "layout";
|
|
||||||
$renderer->result = $f->printHTML ("post", $res);
|
|
||||||
$renderer->run ();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Save the informations to edit a new article */
|
|
||||||
public function editSave ($articleid)
|
|
||||||
{
|
|
||||||
$field = new formfield ("title", "Title");
|
|
||||||
$field->mandatory = true;
|
|
||||||
$formFields[] = $field;
|
|
||||||
$field = new formfield ("content", "Content");
|
|
||||||
$field->mandatory = true;
|
|
||||||
$formFields[] = $field;
|
|
||||||
$field = new formfield ("submit", "Record");
|
|
||||||
$field->type = "submit";
|
|
||||||
$formFields[] = $field;
|
|
||||||
|
|
||||||
$f = new form ();
|
|
||||||
$f->fields ($formFields);
|
|
||||||
$values = $f->values();
|
|
||||||
unset ($values["submit"]);
|
|
||||||
$model = new model_file ();
|
|
||||||
$model->set ($values, $articleid);
|
|
||||||
$r = new route ();
|
|
||||||
$r->redirect ("/", "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
deny from all
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
a:2:{s:5:"title";s:11:"Super title";s:7:"content";s:15:"Mega content !!";}
|
|
||||||
@@ -1,69 +0,0 @@
|
|||||||
<?php
|
|
||||||
/** DomFramework Blog
|
|
||||||
@package domframework
|
|
||||||
@author Dominique Fournier <dominique@fournier38.fr> */
|
|
||||||
|
|
||||||
require_once ("domframework/route.php");
|
|
||||||
require_once ("domframework/renderer.php");
|
|
||||||
session_start();
|
|
||||||
|
|
||||||
error_reporting (E_ALL);
|
|
||||||
// Autoload des controllers
|
|
||||||
spl_autoload_register (
|
|
||||||
function ($class) {
|
|
||||||
if (file_exists ("controllers/controller_$class.php"))
|
|
||||||
include "controllers/controller_$class.php"; });
|
|
||||||
|
|
||||||
$route = new route ();
|
|
||||||
$route->debug =0 ;
|
|
||||||
$route->get ("",
|
|
||||||
function ()
|
|
||||||
{
|
|
||||||
$a = new blog ();
|
|
||||||
$a->listingHtml();
|
|
||||||
});
|
|
||||||
|
|
||||||
$route->get ("{articleid}.txt",
|
|
||||||
function ($articleid)
|
|
||||||
{
|
|
||||||
$a = new blog ();
|
|
||||||
$a->getTxt ($articleid);
|
|
||||||
});
|
|
||||||
|
|
||||||
$route->get ("{articleid}.xml",
|
|
||||||
function ($articleid)
|
|
||||||
{
|
|
||||||
$a = new blog ();
|
|
||||||
$a->getXml ($articleid);
|
|
||||||
});
|
|
||||||
|
|
||||||
$route->get ("{articleid}.json",
|
|
||||||
function ($articleid)
|
|
||||||
{
|
|
||||||
$a = new blog ();
|
|
||||||
$a->getJson ($articleid);
|
|
||||||
});
|
|
||||||
|
|
||||||
$route->get ("{articleid}/edit",
|
|
||||||
function ($articleid)
|
|
||||||
{
|
|
||||||
$a = new blog ();
|
|
||||||
$a->editShow ($articleid);
|
|
||||||
});
|
|
||||||
|
|
||||||
$route->post ("{articleid}/edit",
|
|
||||||
function ($articleid)
|
|
||||||
{
|
|
||||||
$a = new blog ();
|
|
||||||
$a->editSave ($articleid);
|
|
||||||
});
|
|
||||||
|
|
||||||
$route->get ("{articleid}",
|
|
||||||
function ($articleid)
|
|
||||||
{
|
|
||||||
$a = new blog ();
|
|
||||||
$a->getHtml ($articleid);
|
|
||||||
});
|
|
||||||
|
|
||||||
header ($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
|
|
||||||
echo "404 !";
|
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
<?php
|
|
||||||
/** DomFramework Blog
|
|
||||||
@package domframework-blog
|
|
||||||
@author Dominique Fournier <dominique@fournier38.fr> */
|
|
||||||
|
|
||||||
/** Model_file : store the blog datas in files */
|
|
||||||
class model_file
|
|
||||||
{
|
|
||||||
/** The path where the blog articles files are stored */
|
|
||||||
public $dataPath = "datas/";
|
|
||||||
|
|
||||||
/** Return a provided article
|
|
||||||
@param string|integer|null $articleid Teh article to display */
|
|
||||||
function get ($articleid = FALSE)
|
|
||||||
{
|
|
||||||
$this->dataPath = realpath ($this->dataPath);
|
|
||||||
if ($this->dataPath === FALSE)
|
|
||||||
throw new Exception (dgettext("domframework",
|
|
||||||
"Folder data not available"), 500);
|
|
||||||
$fileArticle = $this->dataPath."/".$articleid;
|
|
||||||
if (! file_exists ($fileArticle))
|
|
||||||
throw new Exception (dgettext("domframework",
|
|
||||||
"Article not found"), 404);
|
|
||||||
$fileArticle = realpath ($fileArticle);
|
|
||||||
if (substr ($fileArticle, 0, strlen ($this->dataPath)) !== $this->dataPath)
|
|
||||||
throw new Exception (dgettext("domframework",
|
|
||||||
"Asked article not in data path"), 404);
|
|
||||||
if ($fileArticle === FALSE)
|
|
||||||
throw new Exception (dgettext("domframework",
|
|
||||||
"Article not found"), 404);
|
|
||||||
return unserialize (file_get_contents ($fileArticle));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Create a new article if $articleid is false or edit an existing article
|
|
||||||
if $articleid is defined */
|
|
||||||
function set ($data, $articleid = FALSE)
|
|
||||||
{
|
|
||||||
$this->dataPath = realpath ($this->dataPath);
|
|
||||||
if ($this->dataPath === FALSE)
|
|
||||||
throw new Exception (dgettext("domframework",
|
|
||||||
"Folder data not available"), 500);
|
|
||||||
$fileArticle = $this->dataPath."/".$articleid;
|
|
||||||
if (! file_exists ($fileArticle))
|
|
||||||
throw new Exception (dgettext("domframework",
|
|
||||||
"Article not found"), 404);
|
|
||||||
$fileArticle = realpath ($fileArticle);
|
|
||||||
if (substr ($fileArticle, 0, strlen ($this->dataPath)) !== $this->dataPath)
|
|
||||||
throw new Exception (dgettext("domframework",
|
|
||||||
"Asked article not in data path"), 404);
|
|
||||||
if ($fileArticle === FALSE)
|
|
||||||
throw new Exception (dgettext("domframework",
|
|
||||||
"Article not found"), 404);
|
|
||||||
return file_put_contents ($fileArticle, serialize ($data));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Return a list of all the articles ID */
|
|
||||||
function listing ()
|
|
||||||
{
|
|
||||||
$list = glob ($this->dataPath."/*");
|
|
||||||
if ($list === FALSE || empty ($list))
|
|
||||||
throw new Exception (dgettext("domframework",
|
|
||||||
"No article found"), 404);
|
|
||||||
foreach ($list as $key=>$val)
|
|
||||||
$list[$key] = basename ($val);
|
|
||||||
return $list;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
|
||||||
<title>{title}</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
{content}
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
<?php
|
|
||||||
/** DomFramework Blog
|
|
||||||
@package domframework-blog
|
|
||||||
@author Dominique Fournier <dominique@fournier38.fr> */
|
|
||||||
|
|
||||||
/** Display the articles of the blog */
|
|
||||||
class view_blog
|
|
||||||
{
|
|
||||||
/** Return the datas
|
|
||||||
@param array $data The list of titles */
|
|
||||||
public function get ($data, $variable)
|
|
||||||
{
|
|
||||||
$res = "<a href='".$variable["articleid"]."/edit'>Edit</a><br/>";
|
|
||||||
$res.= "<h1>".$variable["title"]."</h1>\n";
|
|
||||||
$res.= "<p>".$variable["content"]."</p>\n";
|
|
||||||
return $res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Display the list of titles
|
|
||||||
@param array $data The list of titles */
|
|
||||||
public function listing ($data, $variable)
|
|
||||||
{
|
|
||||||
$content = "<ul>\n";
|
|
||||||
foreach ($data as $val)
|
|
||||||
{
|
|
||||||
$content .= " <li>";
|
|
||||||
$content .= "<a href='".urlencode ($val)."'>".htmlentities ($val)."</a>";
|
|
||||||
$content .= "</li>\n";
|
|
||||||
}
|
|
||||||
$content .= "</ul>\n";
|
|
||||||
return $content;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Create/Edit a blog */
|
|
||||||
public function edit ($data, $variable)
|
|
||||||
{
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user