summaryrefslogtreecommitdiff
path: root/lib/Minz
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2015-01-31 14:48:35 +0100
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2015-01-31 14:48:35 +0100
commitc29b6d4c226cf9c45d7d372ee4bce3bcbcca99a6 (patch)
tree9a8f2be9185cd110988bf8a687aaa316c9145db9 /lib/Minz
parente92acfd8227bc3ac94e9039343ff76c20facf29a (diff)
parente91b72b63cd11ae3c4f59e48439e93955242c673 (diff)
Merge branch 'dev' into beta
Conflicts: README.fr.md README.md
Diffstat (limited to 'lib/Minz')
-rw-r--r--lib/Minz/Configuration.php7
-rw-r--r--lib/Minz/Error.php39
-rw-r--r--lib/Minz/ExtensionManager.php5
-rw-r--r--lib/Minz/Session.php4
-rw-r--r--lib/Minz/Url.php34
5 files changed, 29 insertions, 60 deletions
diff --git a/lib/Minz/Configuration.php b/lib/Minz/Configuration.php
index fe415e22b..ab5bb4fc2 100644
--- a/lib/Minz/Configuration.php
+++ b/lib/Minz/Configuration.php
@@ -16,16 +16,9 @@ class Minz_Configuration {
* @param $config_filename the filename of the configuration
* @param $default_filename a filename containing default values for the configuration
* @param $configuration_setter an optional helper to set values in configuration
- * @throws Minz_ConfigurationNamespaceException if the namespace already exists.
*/
public static function register($namespace, $config_filename, $default_filename = null,
$configuration_setter = null) {
- if (isset(self::$config_list[$namespace])) {
- throw new Minz_ConfigurationNamespaceException(
- $namespace . ' namespace already exists'
- );
- }
-
self::$config_list[$namespace] = new Minz_Configuration(
$namespace, $config_filename, $default_filename, $configuration_setter
);
diff --git a/lib/Minz/Error.php b/lib/Minz/Error.php
index 3eadc6d98..3e4a3e8f3 100644
--- a/lib/Minz/Error.php
+++ b/lib/Minz/Error.php
@@ -23,42 +23,13 @@ class Minz_Error {
$logs = self::processLogs ($logs);
$error_filename = APP_PATH . '/Controllers/errorController.php';
- switch ($code) {
- case 200 :
- header('HTTP/1.1 200 OK');
- break;
- case 403 :
- header('HTTP/1.1 403 Forbidden');
- break;
- case 404 :
- header('HTTP/1.1 404 Not Found');
- break;
- case 500 :
- header('HTTP/1.1 500 Internal Server Error');
- break;
- case 503 :
- header('HTTP/1.1 503 Service Unavailable');
- break;
- default :
- header('HTTP/1.1 500 Internal Server Error');
- }
-
if (file_exists ($error_filename)) {
- $params = array (
- 'code' => $code,
- 'logs' => $logs
- );
+ Minz_Session::_param('error_code', $code);
+ Minz_Session::_param('error_logs', $logs);
- if ($redirect) {
- Minz_Request::forward (array (
- 'c' => 'error'
- ), true);
- } else {
- Minz_Request::forward (array (
- 'c' => 'error',
- 'params' => $params
- ), false);
- }
+ Minz_Request::forward (array (
+ 'c' => 'error'
+ ), $redirect);
} else {
echo '<h1>An error occured</h1>' . "\n";
diff --git a/lib/Minz/ExtensionManager.php b/lib/Minz/ExtensionManager.php
index 7edc7afaa..c5c68a8d4 100644
--- a/lib/Minz/ExtensionManager.php
+++ b/lib/Minz/ExtensionManager.php
@@ -56,6 +56,9 @@ class Minz_ExtensionManager {
foreach ($list_potential_extensions as $ext_dir) {
$ext_pathname = EXTENSIONS_PATH . '/' . $ext_dir;
+ if (!is_dir($ext_pathname)) {
+ continue;
+ }
$metadata_filename = $ext_pathname . '/' . self::$ext_metaname;
// Try to load metadata file.
@@ -111,7 +114,7 @@ class Minz_ExtensionManager {
$entry_point_filename = $info['path'] . '/' . self::$ext_entry_point;
$ext_class_name = $info['entrypoint'] . 'Extension';
- include($entry_point_filename);
+ include_once($entry_point_filename);
// Test if the given extension class exists.
if (!class_exists($ext_class_name)) {
diff --git a/lib/Minz/Session.php b/lib/Minz/Session.php
index cfe8debe9..058685ada 100644
--- a/lib/Minz/Session.php
+++ b/lib/Minz/Session.php
@@ -65,7 +65,9 @@ class Minz_Session {
* @param $l la durée de vie
*/
public static function keepCookie($l) {
- $cookie_dir = empty($_SERVER['REQUEST_URI']) ? '' : $_SERVER['REQUEST_URI'];
+ // Get the script_name (e.g. /p/i/index.php) and keep only the path.
+ $cookie_dir = empty($_SERVER['SCRIPT_NAME']) ? '' : $_SERVER['SCRIPT_NAME'];
+ $cookie_dir = dirname($cookie_dir);
session_set_cookie_params($l, $cookie_dir, '', false, true);
}
diff --git a/lib/Minz/Url.php b/lib/Minz/Url.php
index e9f9a69ba..af555a277 100644
--- a/lib/Minz/Url.php
+++ b/lib/Minz/Url.php
@@ -45,45 +45,45 @@ class Minz_Url {
return $url_string;
}
-
+
/**
* Construit l'URI d'une URL
* @param l'url sous forme de tableau
* @param $encodage pour indiquer comment encoder les & (& ou &amp; pour html)
* @return l'uri sous la forme ?key=value&key2=value2
*/
- private static function printUri ($url, $encodage) {
+ private static function printUri($url, $encodage) {
$uri = '';
$separator = '?';
-
- if($encodage == 'html') {
+
+ if ($encodage === 'html') {
$and = '&amp;';
} else {
$and = '&';
}
-
- if (isset ($url['c'])
- && $url['c'] != Minz_Request::defaultControllerName ()) {
+
+ if (isset($url['c'])
+ && $url['c'] != Minz_Request::defaultControllerName()) {
$uri .= $separator . 'c=' . $url['c'];
$separator = $and;
}
-
- if (isset ($url['a'])
- && $url['a'] != Minz_Request::defaultActionName ()) {
+
+ if (isset($url['a'])
+ && $url['a'] != Minz_Request::defaultActionName()) {
$uri .= $separator . 'a=' . $url['a'];
$separator = $and;
}
-
- if (isset ($url['params'])) {
+
+ if (isset($url['params'])) {
foreach ($url['params'] as $key => $param) {
- $uri .= $separator . $key . '=' . $param;
+ $uri .= $separator . urlencode($key) . '=' . urlencode($param);
$separator = $and;
}
}
-
+
return $uri;
}
-
+
/**
* Vérifie que les éléments du tableau représentant une url soit ok
* @param l'url sous forme de tableau (sinon renverra directement $url)
@@ -91,7 +91,7 @@ class Minz_Url {
*/
public static function checkUrl ($url) {
$url_checked = $url;
-
+
if (is_array ($url)) {
if (!isset ($url['c'])) {
$url_checked['c'] = Minz_Request::defaultControllerName ();
@@ -103,7 +103,7 @@ class Minz_Url {
$url_checked['params'] = array ();
}
}
-
+
return $url_checked;
}
}