Cosmetics : remove spaces at the end of lines and correct lines with more than 80 chars
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1643 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
@@ -73,7 +73,7 @@ class test_cachefile extends PHPUnit_Framework_TestCase
|
||||
$this->assertEquals ("DATA_TO_STORE", $res);
|
||||
}
|
||||
|
||||
public function testDel1 ()
|
||||
public function testDel1 ()
|
||||
{
|
||||
$c = new cachefile ();
|
||||
$res = $c->delete ("id");
|
||||
|
||||
@@ -185,7 +185,7 @@ class test_markdown extends PHPUnit_Framework_TestCase
|
||||
</ul>");
|
||||
$md = new markdown ();
|
||||
printf ($md->html ("* line1
|
||||
end
|
||||
end
|
||||
* line2
|
||||
end"));
|
||||
}
|
||||
@@ -244,21 +244,24 @@ base</code></pre>");
|
||||
// Links
|
||||
public function testLinkHTTP1 ()
|
||||
{
|
||||
$this->expectOutputString("<p><a href='http://example.com'>http://example.com</a></p>");
|
||||
$this->expectOutputString(
|
||||
"<p><a href='http://example.com'>http://example.com</a></p>");
|
||||
$md = new markdown ();
|
||||
printf ($md->html ("<http://example.com>"));
|
||||
}
|
||||
|
||||
public function testLinkHTTP2 ()
|
||||
{
|
||||
$this->expectOutputString("<p><a href='https://example.com'>https://example.com</a></p>");
|
||||
$this->expectOutputString(
|
||||
"<p><a href='https://example.com'>https://example.com</a></p>");
|
||||
$md = new markdown ();
|
||||
printf ($md->html ("<https://example.com>"));
|
||||
}
|
||||
|
||||
public function testLinkHTTP3 ()
|
||||
{
|
||||
$this->expectOutputString("<p><a href='mailto://test@example.com'>test@example.com</a></p>");
|
||||
$this->expectOutputString(
|
||||
"<p><a href='mailto://test@example.com'>test@example.com</a></p>");
|
||||
$md = new markdown ();
|
||||
printf ($md->html ("<test@example.com>"));
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ class test_outputjson extends PHPUnit_Framework_TestCase
|
||||
$this->expectOutputString("\"\"");
|
||||
$output = new outputjson ();
|
||||
$output->out ("");
|
||||
}
|
||||
}
|
||||
|
||||
/** Entry string */
|
||||
public function testoutputjson2 ()
|
||||
|
||||
@@ -79,7 +79,7 @@ class authldap extends auth
|
||||
{
|
||||
if ($this->ldapdnuser === NULL)
|
||||
throw new Exception ("No user authenticated !", 401);
|
||||
$search = ldap_search ($this->ldapconn, $this->ldapdnuser,
|
||||
$search = ldap_search ($this->ldapconn, $this->ldapdnuser,
|
||||
$this->ldapfiltersearch);
|
||||
if ($search === FALSE)
|
||||
throw new Exception ("Can not found the details for user", 401);
|
||||
@@ -120,7 +120,7 @@ class authldap extends auth
|
||||
foreach ($info as $key=>$vals)
|
||||
{
|
||||
if ($key === "count") continue;
|
||||
if (isset ($vals["sn"][0]) && isset ($vals["givenname"][0]) &&
|
||||
if (isset ($vals["sn"][0]) && isset ($vals["givenname"][0]) &&
|
||||
isset ($vals["mail"]))
|
||||
{
|
||||
$datas[$key] = array ("lastname"=>$vals["sn"][0],
|
||||
|
||||
@@ -188,7 +188,7 @@ class authorizationdb extends authorization
|
||||
"ownerid"=>$ownerid,
|
||||
"groupid"=>$groupid,
|
||||
"modbits"=>$modbits));
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/** Remove the informations about an object and all its sub-objects
|
||||
|
||||
@@ -22,7 +22,7 @@ class authparams
|
||||
if (!isset ($_SESSION["auth"]["email"]) ||
|
||||
!isset ($_SESSION["auth"]["password"]))
|
||||
throw new Exception ("No previous email in session", 401);
|
||||
return array ("email"=>$_SESSION["auth"]["email"],
|
||||
return array ("email"=>$_SESSION["auth"]["email"],
|
||||
"password"=>$_SESSION["auth"]["email"]);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,15 +5,15 @@
|
||||
|
||||
require_once ("auth.php");
|
||||
/** User authentication against SYMPA server
|
||||
Sympa is a mailling list server. It can handle authentication with
|
||||
Sympa is a mailling list server. It can handle authentication with
|
||||
- a username (a email adress)
|
||||
- a password
|
||||
- a list to check if the user is recorded in
|
||||
- a list to check if the user is recorded in
|
||||
- a Sympa SOAP server WSDL
|
||||
- the part of list which should be test : subscriber, owner, editor
|
||||
It use the SOAP protocol. So the PHP SOAP library is needed and the network
|
||||
must be open between the Web server and the Sympa server.
|
||||
POC :
|
||||
POC :
|
||||
$auth = new authsympa ();
|
||||
$auth->wsdl = "https://lists.domain.tld/sympa/wsdl";
|
||||
$auth->list = "listtest@lists.domain.tld";
|
||||
|
||||
@@ -84,7 +84,7 @@ class cachefile
|
||||
chmod ($this->directory, 0777);
|
||||
}
|
||||
if (! is_writable ($this->directory))
|
||||
throw new Exception (sprintf (_("Cache directory %s is not writable"),
|
||||
throw new Exception (sprintf (_("Cache directory %s is not writable"),
|
||||
$this->directory), 500);
|
||||
if (! is_readable ($this->directory))
|
||||
throw new Exception (sprintf (_("Cache directory %s is not readable"),
|
||||
|
||||
@@ -18,7 +18,7 @@ class cacheoutput
|
||||
/** Current path at start due to lack of information in __destruct*/
|
||||
private $cacheCWD = null;
|
||||
|
||||
/**
|
||||
/**
|
||||
@param string $id The cache identifier
|
||||
@param integer|null $ttl The cache Time to Leave in seconds (60s by
|
||||
default)
|
||||
|
||||
12
cli.php
12
cli.php
@@ -6,7 +6,7 @@
|
||||
/** Allow to interract with controllers and models from the CLI */
|
||||
class cli
|
||||
{
|
||||
/** Run in CLI mode with parameters
|
||||
/** Run in CLI mode with parameters
|
||||
Example of cli code :
|
||||
#!/usr/bin/php5
|
||||
<?php
|
||||
@@ -29,11 +29,13 @@ class cli
|
||||
echo " $launcher -listmethods <class> : \n";
|
||||
echo " display the methods available the controller class\n";
|
||||
echo " $launcher -expert -listmethods <class> :\n";
|
||||
echo " display the methods available the model or controller class\n";
|
||||
echo " display the methods available the model or controller class".
|
||||
"\n";
|
||||
echo " $launcher -listmethodsdetails <class> : \n";
|
||||
echo " display the methods available the controller class\n";
|
||||
echo " $launcher -expert -listmethodsdetails <class> :\n";
|
||||
echo " display the methods available the model or controller class\n";
|
||||
echo " display the methods available the model or controller class".
|
||||
"\n";
|
||||
echo " $launcher <class> <method> [args]\n";
|
||||
echo " execute the method with the provided args\n";
|
||||
echo " $launcher -expert <class> <method> [args]\n";
|
||||
@@ -66,7 +68,6 @@ class cli
|
||||
// Lists the classes available in controllers and models if expert mode
|
||||
echo "List of classes available :\n";
|
||||
echo " ".implode ("\n ", $classes)."\n";
|
||||
|
||||
echo "Usage : ".$launcher;
|
||||
if ($EXPERT) echo " -expert";
|
||||
echo " -listmethods <class>\n";
|
||||
@@ -131,7 +132,7 @@ class cli
|
||||
else
|
||||
echo ">";
|
||||
}
|
||||
|
||||
|
||||
if ($argv[0] === "-listmethodsdetails")
|
||||
{
|
||||
echo "\n";
|
||||
@@ -166,7 +167,6 @@ class cli
|
||||
$found = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($found === FALSE)
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
@package domframework
|
||||
@author Dominique Fournier <dominique@fournier38.fr> */
|
||||
|
||||
/** Manage the configurations of the module done by administrator in a config
|
||||
/** Manage the configurations of the module done by administrator in a config
|
||||
file
|
||||
It is based on the module configuration defaults
|
||||
POC :
|
||||
POC :
|
||||
$config = new config();
|
||||
$config->default = array ("param"=>"default",
|
||||
"param2"=>array (1,2,3),
|
||||
@@ -32,7 +32,6 @@ class config
|
||||
public function params ()
|
||||
{
|
||||
return print_r ($this->default, TRUE);
|
||||
|
||||
}
|
||||
|
||||
/** Get the value of the provided parameter recorded in .php file
|
||||
@@ -44,7 +43,7 @@ class config
|
||||
throw new Exception ("Unknown parameter '$param'");
|
||||
if (!file_exists ($this->confFile))
|
||||
{
|
||||
if (@file_put_contents ($this->confFile,
|
||||
if (@file_put_contents ($this->confFile,
|
||||
"<?php\r\n\$conf = array ();\r\n")
|
||||
=== FALSE)
|
||||
throw new Exception (sprintf (
|
||||
|
||||
24
dblayer.php
24
dblayer.php
@@ -24,7 +24,7 @@ To use it, extends in your code this class, and define the attributes :
|
||||
the dbLayer abstraction don't supports primary key on multiples columns
|
||||
- protected $unique = array ("column", array ("column1", "column2");)
|
||||
|
||||
Optionnaly, you can add the
|
||||
Optionnaly, you can add the
|
||||
- protected $debug = TRUE : enable the debug on screen (NOT FOR PROD !!)
|
||||
*/
|
||||
|
||||
@@ -444,7 +444,7 @@ class dblayer extends PDO
|
||||
return $res;
|
||||
}
|
||||
|
||||
/** Update the key tuple with the provided datas
|
||||
/** Update the key tuple with the provided datas
|
||||
Return the number of rows modified
|
||||
@param string|integer $updatekey The key applied on primary key to be
|
||||
updated
|
||||
@@ -557,7 +557,7 @@ class dblayer extends PDO
|
||||
}
|
||||
else
|
||||
{
|
||||
// One column in unique
|
||||
// One column in unique
|
||||
if (!array_key_exists ($columns, $datasOK)) continue;
|
||||
$select = array ();
|
||||
if ($columns === $this->primary)
|
||||
@@ -690,7 +690,7 @@ class dblayer extends PDO
|
||||
}
|
||||
|
||||
/** Create the table defined by the differents fields.
|
||||
Define the SQL syntax based on SQL engines
|
||||
Define the SQL syntax based on SQL engines
|
||||
$table = "dns zones";
|
||||
$fields = array (
|
||||
"id"=>array ("integer", "not null", "autoincrement"),
|
||||
@@ -755,7 +755,7 @@ class dblayer extends PDO
|
||||
if ($this->primary === $field)
|
||||
$sql .= " PRIMARY KEY";
|
||||
// Others parameters for field
|
||||
// Sort to put the autoincrement field in front of params, if it is
|
||||
// Sort to put the autoincrement field in front of params, if it is
|
||||
// present
|
||||
sort ($params);
|
||||
foreach ($params as $p)
|
||||
@@ -842,7 +842,7 @@ class dblayer extends PDO
|
||||
if ($this->primary === $field)
|
||||
$sql .= " PRIMARY KEY";
|
||||
// Others parameters for field
|
||||
// Sort to put the autoincrement field in front of params, if it is
|
||||
// Sort to put the autoincrement field in front of params, if it is
|
||||
// present
|
||||
sort ($params);
|
||||
foreach ($params as $p)
|
||||
@@ -876,7 +876,6 @@ class dblayer extends PDO
|
||||
$i = 0;
|
||||
foreach ($this->foreign as $field=>$k)
|
||||
{
|
||||
|
||||
$sql .= ",\n FOREIGN KEY(`$field`) REFERENCES `".$k[0]."`(`".
|
||||
$k[1]."`)";
|
||||
if (isset ($k[2]))
|
||||
@@ -936,7 +935,7 @@ class dblayer extends PDO
|
||||
if ($this->primary === $field)
|
||||
$sql .= " PRIMARY KEY";
|
||||
// Others parameters for field
|
||||
// Sort to put the autoincrement field in front of params, if it is
|
||||
// Sort to put the autoincrement field in front of params, if it is
|
||||
// present
|
||||
sort ($params);
|
||||
foreach ($params as $p)
|
||||
@@ -988,7 +987,7 @@ class dblayer extends PDO
|
||||
echo "$sql\n";
|
||||
return $this->db->exec($sql);
|
||||
}
|
||||
|
||||
|
||||
/** This function permit to send a SQL request to the database to do a SELECT
|
||||
Return the an array with the datas */
|
||||
public function directRead ($sql)
|
||||
@@ -1007,7 +1006,7 @@ error_reporting (E_ALL);
|
||||
require_once ("domframework/dbLayer.php");
|
||||
class zone extends dbLayer
|
||||
{
|
||||
// The database must be initialized with
|
||||
// The database must be initialized with
|
||||
// CREATE TABLE `dns_zones` (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
// zone VARCHAR(255) NOT NULL,
|
||||
// viewname VARCHAR(255),
|
||||
@@ -1015,7 +1014,7 @@ class zone extends dbLayer
|
||||
// comment VARCHAR(1024),
|
||||
// opendate DATETIME NOT NULL,
|
||||
// closedate DATETIME,
|
||||
// UNIQUE (zone,viewname));
|
||||
// UNIQUE (zone,viewname));
|
||||
protected $table = "dns_zones";
|
||||
protected $fields = array (
|
||||
"id"=>array ("integer", "not null", "autoincrement"),
|
||||
@@ -1032,7 +1031,8 @@ class zone extends dbLayer
|
||||
|
||||
ini_set ("date.timezone", "Europe/Paris");
|
||||
$zone = new zone ("sqlite:datas/database.db");
|
||||
$last = $zone->create (array ("zone"=>"testZone", "opendate"=>date("Y-m-d H:i:s")));
|
||||
$last = $zone->create (array ("zone"=>"testZone",
|
||||
"opendate"=>date("Y-m-d H:i:s")));
|
||||
//print_r ($zone->read ());
|
||||
$zone->update (2040, array ("zone"=>"testZone2"));
|
||||
print_r ($zone->delete ($last));
|
||||
|
||||
2
debian/changelog
vendored
2
debian/changelog
vendored
@@ -39,7 +39,7 @@ domframework (0.4-1) testing; urgency=low
|
||||
|
||||
domframework (0.3-1) testing; urgency=low
|
||||
* dbLayer : Create a operationnal list table for sqlite/mysql/pgsql
|
||||
* authorization model
|
||||
* authorization model
|
||||
-- Dominique Fournier <dominique@fournier38.fr> Fri, 20 Jun 2014 15:18:47 +0100
|
||||
|
||||
domframework (0.2-1) testing; urgency=low
|
||||
|
||||
1
debian/control
vendored
1
debian/control
vendored
@@ -12,4 +12,3 @@ Recommends: php5-cli
|
||||
Description: PHP Framework with basic functionnalities
|
||||
The DomFramework allow the developpers to create easily some PHP applications.
|
||||
Provide authentication, abstraction to databases, and much more !
|
||||
|
||||
|
||||
4
debian/rules
vendored
4
debian/rules
vendored
@@ -12,7 +12,7 @@
|
||||
clean:
|
||||
dh_testdir
|
||||
dh_testroot
|
||||
dh_clean
|
||||
dh_clean
|
||||
|
||||
install: build
|
||||
dh_testdir
|
||||
@@ -26,7 +26,7 @@ install: build
|
||||
binary: build install
|
||||
dh_testdir
|
||||
dh_testroot
|
||||
dh_installchangelogs
|
||||
dh_installchangelogs
|
||||
# dh_installdocs
|
||||
# dh_installexamples
|
||||
# dh_install
|
||||
|
||||
2
debian/watch
vendored
2
debian/watch
vendored
@@ -6,7 +6,7 @@
|
||||
# Compulsory line, this is a version 3 file
|
||||
version=3
|
||||
|
||||
# Uncomment to examine a Webpage
|
||||
# Uncomment to examine a Webpage
|
||||
# <Webpage URL> <string match>
|
||||
#http://www.example.com/downloads.php #PACKAGE#-(.*)\.tar\.gz
|
||||
|
||||
|
||||
16
docs/USAGE
16
docs/USAGE
@@ -103,7 +103,12 @@ Add the debug on routing with
|
||||
to help to see the matches.
|
||||
|
||||
We can use some variables to be passed to the called function :
|
||||
$route->get ("home3/{plo}/{str}", function ($str, $plo) {echo "$str $plo";});
|
||||
$route->get ("home3/{plo}/{str}",
|
||||
function ($str, $plo)
|
||||
{
|
||||
echo "$str $plo";
|
||||
}
|
||||
);
|
||||
|
||||
There is a special action named "redirect" in the "route" class. It provide the
|
||||
capability to re-route the Web browser to another page. Put in action :
|
||||
@@ -113,7 +118,8 @@ new page named "nextPage/". The FALSE will be change in case of modular
|
||||
application (see the MODULAR APPLICATION chapter)
|
||||
|
||||
The Ending slash can be a problem and can be removed by using :
|
||||
// If there is a no catch route ending with slash, try to reroute without slash
|
||||
// If there is a no catch route ending with slash, try to reroute without
|
||||
// slash
|
||||
$route->get ("{string}/",
|
||||
function ($string)
|
||||
{
|
||||
@@ -191,7 +197,7 @@ To use it :
|
||||
// Display the form
|
||||
echo $f->printHTML ("post", $values, $errors);
|
||||
|
||||
The fields are defined by :
|
||||
The fields are defined by :
|
||||
- name : name of the field in the HTML page
|
||||
- label : label written to the describe the field
|
||||
- [titles] : text written in radio/checkboxes
|
||||
@@ -213,7 +219,7 @@ In case of error, an exception is raised.
|
||||
------------------------
|
||||
A database abstraction permits to forget if the database engine is MySQL, SQLite
|
||||
or PostgreSQL. It can read, insert, update easily from arrays, but display the
|
||||
tables without having to think about the backend.
|
||||
tables without having to think about the backend.
|
||||
It check the foreign keys before doing insertions/updates, look at unique
|
||||
constrains. It can create table with the different syntax of the engines.
|
||||
Define your table like this :
|
||||
@@ -239,7 +245,7 @@ Define your table like this :
|
||||
public $unique = array ("id");
|
||||
/** The foreign keys of the table */
|
||||
public $foreign = array ("zoneid"=>array ("dns_zones", "id",
|
||||
"ON UPDATE CASCADE ON DELETE CASCADE"));
|
||||
"ON UPDATE CASCADE ON DELETE CASCADE"));
|
||||
/** SQL Debug */
|
||||
public $debug = FALSE;
|
||||
/** Translation */
|
||||
|
||||
10
form.php
10
form.php
@@ -143,8 +143,8 @@ die ("FORM/VERIFY : UNUSED and dirty\n");
|
||||
$ret[$field->name] = $message;
|
||||
$field->error = $message;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($this->debug)
|
||||
{
|
||||
@@ -395,7 +395,7 @@ die ("FORM/VERIFY : UNUSED and dirty\n");
|
||||
$res .= " <option value='";
|
||||
$res .= htmlspecialchars ($key, ENT_QUOTES)."'";
|
||||
if (isset ($values[$field->name]) &&
|
||||
is_string ($values[$field->name]) &&
|
||||
is_string ($values[$field->name]) &&
|
||||
$values[$field->name] == $key)
|
||||
$res .= " selected='selected'";
|
||||
elseif (isset ($values[$field->name]) &&
|
||||
@@ -408,7 +408,7 @@ die ("FORM/VERIFY : UNUSED and dirty\n");
|
||||
}
|
||||
|
||||
$res .= " </select>\n";
|
||||
if (isset ($errors[$field->name]))
|
||||
if (isset ($errors[$field->name]))
|
||||
$res .= " <span class='help-block'>".$errors[$field->name][1].
|
||||
"</span>\n";
|
||||
}
|
||||
@@ -495,7 +495,7 @@ die ("FORM/VERIFY : UNUSED and dirty\n");
|
||||
return $res;
|
||||
}
|
||||
|
||||
/** Check the token from the user
|
||||
/** Check the token from the user
|
||||
@param string $tokenFromUser The value form the user's token */
|
||||
public function checkToken ($tokenFromUser)
|
||||
{
|
||||
|
||||
4
http.php
4
http.php
@@ -8,7 +8,7 @@
|
||||
class http
|
||||
{
|
||||
/** Choose the best choice from user choices.
|
||||
Can be used for languages (HTTP_ACCEPT_LANGUAGE), type of pages
|
||||
Can be used for languages (HTTP_ACCEPT_LANGUAGE), type of pages
|
||||
(HTTP_ACCEPT)...
|
||||
Ex. fr, en-gb;q=0.8, en;q=0.7
|
||||
Ex. text/html,application/xhtml+xml,application/xml;q=0.9,* /*;q=0.8
|
||||
@@ -65,7 +65,7 @@ class http
|
||||
@param integer $code The HTTP code to translate in text */
|
||||
function codetext ($code)
|
||||
{
|
||||
switch ($code)
|
||||
switch ($code)
|
||||
{
|
||||
case 100: $text = 'Continue'; break;
|
||||
case 101: $text = 'Switching Protocols'; break;
|
||||
|
||||
@@ -26,7 +26,7 @@ class logger
|
||||
public $timezone = "UTC";
|
||||
/** Minimum log level in the logs */
|
||||
public $loglevelmin = LOG_NOTICE;
|
||||
/** In Syslog mode, the facility to use
|
||||
/** In Syslog mode, the facility to use
|
||||
See http://fr2.php.net/manual/en/function.openlog.php for $syslogFacility */
|
||||
public $syslogFacility = LOG_USER;
|
||||
/** In Syslog, prefix the log by the text */
|
||||
@@ -48,7 +48,7 @@ class logger
|
||||
LOG_WARNING => "WARNING",
|
||||
LOG_NOTICE => "NOTICE",
|
||||
LOG_INFO => "INFO",
|
||||
LOG_DEBUG => "DEBUG");
|
||||
LOG_DEBUG => "DEBUG");
|
||||
|
||||
/** Store a new message log in the log manager defined by $logtype
|
||||
@param string $message Message to log
|
||||
|
||||
@@ -265,7 +265,8 @@ class markdown
|
||||
// Remove last \n to put closing tag at the end of line
|
||||
//$res = substr ($res, 0, -1);
|
||||
$oldType = array_pop ($typeStack);
|
||||
$this->debugMKD (str_repeat (" ", end ($indentStack))."</$oldType>");
|
||||
$this->debugMKD (str_repeat (" ", end ($indentStack)).
|
||||
"</$oldType>");
|
||||
$res .= str_repeat (" ", end ($indentStack))."</$oldType>";
|
||||
array_pop ($indentStack);
|
||||
array_pop ($htmlStack);
|
||||
@@ -317,7 +318,8 @@ class markdown
|
||||
{
|
||||
$this->debugMKD ("DEB2 : CODE : Close older HTML");
|
||||
$oldType = array_pop ($typeStack);
|
||||
$this->debugMKD (str_repeat (" ", end ($indentStack))."</$oldType>");
|
||||
$this->debugMKD (str_repeat (" ", end ($indentStack)).
|
||||
"</$oldType>");
|
||||
$res .= str_repeat (" ", end ($indentStack))."</$oldType>";
|
||||
array_pop ($indentStack);
|
||||
array_pop ($htmlStack);
|
||||
@@ -356,7 +358,7 @@ class markdown
|
||||
array_pop ($htmlStack);
|
||||
}
|
||||
|
||||
// If code, there is no emphasis, email, and other conversions
|
||||
// If code, there is no emphasis, email, and other conversions
|
||||
if ($type !== "code")
|
||||
{
|
||||
$timetmp = microtime (TRUE);
|
||||
|
||||
@@ -14,7 +14,7 @@ class outputcsv extends output
|
||||
throw new Exception ("CSV support not available in PHP !", 500);
|
||||
}
|
||||
|
||||
/** Display in CSV the datas provided
|
||||
/** Display in CSV the datas provided
|
||||
@param mixed $data The data to be displayed */
|
||||
public function out ($data)
|
||||
{
|
||||
|
||||
@@ -9,8 +9,8 @@ class outputhtml extends output
|
||||
{
|
||||
/** Data is printed by viewClass->viewmethod, in the middle of $layout
|
||||
title is put in the title of the HTML page
|
||||
$replacement modify the result (it can do title too :
|
||||
array ("{title}"=>"title to display")
|
||||
$replacement modify the result (it can do title too :
|
||||
array ("{title}"=>"title to display")
|
||||
@param mixed $data Data to display on the page
|
||||
@param string|null $title Title to put on head of page
|
||||
@param string|null $viewClass Class in views to use to display
|
||||
@@ -43,7 +43,7 @@ class outputhtml extends output
|
||||
$layoutPage = file_get_contents ("views/$layout.html");
|
||||
$resView = str_replace ("{content}", $resView, $layoutPage);
|
||||
}
|
||||
|
||||
|
||||
// Do the title replacement in the replacement structure
|
||||
if (! isset ($replacement["{title}"]))
|
||||
$replacement["{title}"] = $title;
|
||||
|
||||
@@ -15,7 +15,7 @@ class outputjson extends output
|
||||
"install php5-json", 500);
|
||||
}
|
||||
|
||||
/** Display in JSOn the datas provided
|
||||
/** Display in JSOn the datas provided
|
||||
@param mixed $data The data to be displayed */
|
||||
public function out ($data)
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ class renderer
|
||||
/** The output type */
|
||||
public $output = NULL;
|
||||
/** Title by default : space to be compatible with HTML5 */
|
||||
public $title = " ";
|
||||
public $title = " ";
|
||||
/** Filename of class containing the presentation layer */
|
||||
public $viewClass = FALSE;
|
||||
/** Method apply to class object to display the $result */
|
||||
@@ -22,7 +22,7 @@ class renderer
|
||||
public $replacement = array();
|
||||
/** Array to variable definition */
|
||||
public $variable = array ();
|
||||
|
||||
|
||||
/** Display the $this->result result in the output model defined by
|
||||
$this->output */
|
||||
public function run ()
|
||||
|
||||
2
rest.php
2
rest.php
@@ -26,7 +26,7 @@ class rest
|
||||
$type = $http->bestChoice ($_SERVER["HTTP_ACCEPT"], $this->allowedtypes,
|
||||
$type);
|
||||
}
|
||||
|
||||
|
||||
require_once ("domframework/output$type.php");
|
||||
$constr = "output$type";
|
||||
$method = "out";
|
||||
|
||||
18
route.php
18
route.php
@@ -15,21 +15,21 @@ class route
|
||||
public $method = "";
|
||||
/** The module name */
|
||||
public $module = NULL;
|
||||
/** The debug mode :
|
||||
/** The debug mode :
|
||||
0:NoDebug, 1:routing, 2:more debug (developpement)*/
|
||||
public $debug=0;
|
||||
//public $defaultOutput = "html"; // Default renderer : html
|
||||
|
||||
/** Return the baseURL of the site
|
||||
Always finish with a slash
|
||||
@param string|null $module The module name (if thereis one) */
|
||||
@param string|null $module The module name (if thereis one) */
|
||||
function baseURL ($module = FALSE)
|
||||
{
|
||||
if ($this->module === NULL)
|
||||
$this->module = $module;
|
||||
if ($this->baseURL !== "")
|
||||
return $this->baseURL;
|
||||
|
||||
|
||||
if (!isset ($_SERVER["SERVER_PORT"]))
|
||||
$_SERVER["SERVER_PORT"] = "80";
|
||||
$port = ":".$_SERVER["SERVER_PORT"];
|
||||
@@ -132,7 +132,7 @@ class route
|
||||
if (substr ($destURL, 0, strlen ($baseURL)) !== $baseURL)
|
||||
throw new Exception ("Can't redirect outside this site (Base $baseURL)",
|
||||
405);
|
||||
|
||||
|
||||
if ($this->debug)
|
||||
{
|
||||
echo "<pre>\n";
|
||||
@@ -183,7 +183,7 @@ class route
|
||||
ob_flush ();
|
||||
flush ();
|
||||
}
|
||||
|
||||
|
||||
$class = $action[0];
|
||||
$method = $action[1];
|
||||
$params = array_slice ($action, 2);
|
||||
@@ -298,7 +298,7 @@ class route
|
||||
$rc = @include_once ("controllers/controller_$class.php");
|
||||
// For loading framework classes
|
||||
if ($rc === FALSE) @include_once ("$class.php");
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
$reflection = new ReflectionMethod ($class, $method);
|
||||
@@ -364,13 +364,13 @@ class route
|
||||
catch (Exception $e)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//echo "passConstruct=";print_r ($passConstruct);
|
||||
// Check if the method need parameters
|
||||
$reflection = new ReflectionMethod ($class, $method);
|
||||
$passMethod = array();
|
||||
//echo "getParameters=";var_dump ($reflection->getParameters());
|
||||
foreach($reflection->getParameters() as $key=>$param)
|
||||
foreach($reflection->getParameters() as $key=>$param)
|
||||
{
|
||||
if (isset ($matches[$param->getName ()]))
|
||||
$passMethod[] = $matches[$param->getName ()];
|
||||
@@ -426,7 +426,7 @@ class route
|
||||
Throw an exception in case of error */
|
||||
public function method ()
|
||||
{
|
||||
if (isset ($_POST["_METHOD"]) &&
|
||||
if (isset ($_POST["_METHOD"]) &&
|
||||
($_POST["_METHOD"] === "GET" ||
|
||||
$_POST["_METHOD"] === "POST" ||
|
||||
$_POST["_METHOD"] === "PUT" ||
|
||||
|
||||
@@ -128,6 +128,5 @@ class verify
|
||||
if (strspn ($val, "0123456789") !== strlen ($val))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
|
||||
|
||||
/** This is the version of DomFramework.
|
||||
It can be used to test if the framework is uptodate for the application with :
|
||||
It can be used to test if the framework is uptodate for the application
|
||||
with :
|
||||
require ("domframework/version.php");
|
||||
if (!defined ("DOMFRAMEWORK_VERSION") ||
|
||||
version_compare (DOMFRAMEWORK_VERSION, "0.6") < 0)
|
||||
|
||||
Reference in New Issue
Block a user