@@ -150,6 +150,9 @@ |
||
150 | 150 | $instance->hooks[$hook_name][] = $fn; |
151 | 151 | } |
152 | 152 | |
153 | + /** |
|
154 | + * @param string $hook_name |
|
155 | + */ |
|
153 | 156 | public static function fire($hook_name, $params = null) |
154 | 157 | { |
155 | 158 | $instance = self::get_instance(); |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | // Search through routes and find first match |
42 | 42 | foreach ($routes as $pattern => $handler_name) { |
43 | 43 | $patternRep = strtr($pattern, $tokens); |
44 | - if (preg_match('#^/?' . $patternRep . '/?$#', $path_info, $matches)) { |
|
44 | + if (preg_match('#^/?'.$patternRep.'/?$#', $path_info, $matches)) { |
|
45 | 45 | $discovered_handler = $handler_name; |
46 | 46 | $regex_matches = $matches; |
47 | 47 | $params = isset($regex_matches[1]) ? explode("/", $regex_matches[1]) : array(); |
@@ -84,10 +84,10 @@ discard block |
||
84 | 84 | } |
85 | 85 | |
86 | 86 | if ($handler_instance) { |
87 | - if (self::is_xhr_request() && method_exists($handler_instance, $action . '_xhr')) { |
|
87 | + if (self::is_xhr_request() && method_exists($handler_instance, $action.'_xhr')) { |
|
88 | 88 | header('Content-type: application/json'); // @todo support xml |
89 | 89 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
90 | - header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
|
90 | + header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); |
|
91 | 91 | header('Cache-Control: no-store, no-cache, must-revalidate'); |
92 | 92 | header('Cache-Control: post-check=0, pre-check=0', false); |
93 | 93 | header("Access-Control-Allow-Origin: *"); // @todo make this a parameter? |
@@ -18,7 +18,7 @@ |
||
18 | 18 | * Constructor |
19 | 19 | * @param string $template |
20 | 20 | * @param mixed $data |
21 | - * @param string $templateFolder |
|
21 | + * @param string $templateRootFolder |
|
22 | 22 | */ |
23 | 23 | public function __construct($template = null, $data = null, $templateRootFolder = ERDIKO_APP) |
24 | 24 | { |
@@ -21,19 +21,19 @@ |
||
21 | 21 | class ApiController extends Controller |
22 | 22 | { |
23 | 23 | |
24 | - /** |
|
25 | - * Contructor |
|
26 | - */ |
|
24 | + /** |
|
25 | + * Contructor |
|
26 | + */ |
|
27 | 27 | public function __construct() |
28 | 28 | { |
29 | 29 | $this->_webroot = ERDIKO_ROOT; |
30 | 30 | $this->_response = new \erdiko\core\ApiResponse; |
31 | 31 | } |
32 | 32 | |
33 | - /** |
|
34 | - * setStatusCode |
|
35 | - * |
|
36 | - */ |
|
33 | + /** |
|
34 | + * setStatusCode |
|
35 | + * |
|
36 | + */ |
|
37 | 37 | public function setStatusCode($code = null) |
38 | 38 | { |
39 | 39 | if (!empty($code)) { |
@@ -8,11 +8,11 @@ |
||
8 | 8 | * @author John Arroyo, [email protected] |
9 | 9 | */ |
10 | 10 | |
11 | -ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . ERDIKO_ROOT . |
|
12 | - PATH_SEPARATOR . ERDIKO_VENDOR . PATH_SEPARATOR . ERDIKO_APP . PATH_SEPARATOR . ERDIKO_SRC); |
|
11 | +ini_set('include_path', ini_get('include_path').PATH_SEPARATOR.ERDIKO_ROOT. |
|
12 | + PATH_SEPARATOR.ERDIKO_VENDOR.PATH_SEPARATOR.ERDIKO_APP.PATH_SEPARATOR.ERDIKO_SRC); |
|
13 | 13 | |
14 | 14 | |
15 | -spl_autoload_register(function ($name) { |
|
15 | +spl_autoload_register(function($name) { |
|
16 | 16 | |
17 | 17 | // error_log("autoload: $name"); |
18 | 18 |
@@ -14,43 +14,43 @@ |
||
14 | 14 | |
15 | 15 | class FlashMessages |
16 | 16 | { |
17 | - /** |
|
18 | - * Reset the messages |
|
19 | - */ |
|
20 | - public static function reset() |
|
21 | - { |
|
22 | - $_SESSION['erdiko_flash_message'] = array(); |
|
23 | - } |
|
17 | + /** |
|
18 | + * Reset the messages |
|
19 | + */ |
|
20 | + public static function reset() |
|
21 | + { |
|
22 | + $_SESSION['erdiko_flash_message'] = array(); |
|
23 | + } |
|
24 | 24 | |
25 | - /** |
|
26 | - * Set flash message |
|
27 | - * Add a message to the array |
|
28 | - * @note: Should we restrict/limit types to only the 4 listed in the header? |
|
29 | - * @param string $message |
|
30 | - * @param string $type |
|
31 | - */ |
|
32 | - public static function set($message, $type = 'danger') |
|
33 | - { |
|
34 | - $_SESSION['erdiko_flash_message'][] = array( |
|
35 | - 'text' => $message, |
|
36 | - 'type' => $type |
|
37 | - ); |
|
25 | + /** |
|
26 | + * Set flash message |
|
27 | + * Add a message to the array |
|
28 | + * @note: Should we restrict/limit types to only the 4 listed in the header? |
|
29 | + * @param string $message |
|
30 | + * @param string $type |
|
31 | + */ |
|
32 | + public static function set($message, $type = 'danger') |
|
33 | + { |
|
34 | + $_SESSION['erdiko_flash_message'][] = array( |
|
35 | + 'text' => $message, |
|
36 | + 'type' => $type |
|
37 | + ); |
|
38 | 38 | |
39 | - $_SESSION['erdiko_flash_message']; |
|
40 | - } |
|
39 | + $_SESSION['erdiko_flash_message']; |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * Get flash messages |
|
44 | - * @return array $messages |
|
45 | - */ |
|
46 | - public static function get() |
|
47 | - { |
|
48 | - $messages = array(); |
|
49 | - if(isset($_SESSION['erdiko_flash_message'])) |
|
50 | - $messages = $_SESSION['erdiko_flash_message']; |
|
51 | - self::reset(); |
|
42 | + /** |
|
43 | + * Get flash messages |
|
44 | + * @return array $messages |
|
45 | + */ |
|
46 | + public static function get() |
|
47 | + { |
|
48 | + $messages = array(); |
|
49 | + if(isset($_SESSION['erdiko_flash_message'])) |
|
50 | + $messages = $_SESSION['erdiko_flash_message']; |
|
51 | + self::reset(); |
|
52 | 52 | |
53 | - return $messages; |
|
54 | - } |
|
53 | + return $messages; |
|
54 | + } |
|
55 | 55 | |
56 | 56 | } |
57 | 57 | \ No newline at end of file |
@@ -46,7 +46,7 @@ |
||
46 | 46 | public static function get() |
47 | 47 | { |
48 | 48 | $messages = array(); |
49 | - if(isset($_SESSION['erdiko_flash_message'])) |
|
49 | + if (isset($_SESSION['erdiko_flash_message'])) |
|
50 | 50 | $messages = $_SESSION['erdiko_flash_message']; |
51 | 51 | self::reset(); |
52 | 52 |
@@ -46,8 +46,9 @@ |
||
46 | 46 | public static function get() |
47 | 47 | { |
48 | 48 | $messages = array(); |
49 | - if(isset($_SESSION['erdiko_flash_message'])) |
|
50 | - $messages = $_SESSION['erdiko_flash_message']; |
|
49 | + if(isset($_SESSION['erdiko_flash_message'])) { |
|
50 | + $messages = $_SESSION['erdiko_flash_message']; |
|
51 | + } |
|
51 | 52 | self::reset(); |
52 | 53 | |
53 | 54 | return $messages; |
@@ -20,9 +20,9 @@ |
||
20 | 20 | class AjaxController extends Controller |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * Contructor |
|
25 | - */ |
|
23 | + /** |
|
24 | + * Contructor |
|
25 | + */ |
|
26 | 26 | public function __construct() |
27 | 27 | { |
28 | 28 | $this->_webroot = ERDIKO_ROOT; |
@@ -20,4 +20,4 @@ |
||
20 | 20 | |
21 | 21 | // Set a default context if none specified |
22 | 22 | if(empty(getenv('ERDIKO_CONTEXT'))) |
23 | - putenv("ERDIKO_CONTEXT=default"); |
|
24 | 23 | \ No newline at end of file |
24 | + putenv("ERDIKO_CONTEXT=default"); |
|
25 | 25 | \ No newline at end of file |
@@ -19,5 +19,5 @@ |
||
19 | 19 | putenv("ERDIKO_DEBUG=".$debug); |
20 | 20 | |
21 | 21 | // Set a default context if none specified |
22 | -if(empty(getenv('ERDIKO_CONTEXT'))) |
|
22 | +if (empty(getenv('ERDIKO_CONTEXT'))) |
|
23 | 23 | putenv("ERDIKO_CONTEXT=default"); |
24 | 24 | \ No newline at end of file |
@@ -19,5 +19,6 @@ |
||
19 | 19 | putenv("ERDIKO_DEBUG=".$debug); |
20 | 20 | |
21 | 21 | // Set a default context if none specified |
22 | -if(empty(getenv('ERDIKO_CONTEXT'))) |
|
23 | - putenv("ERDIKO_CONTEXT=default"); |
|
24 | 22 | \ No newline at end of file |
23 | +if(empty(getenv('ERDIKO_CONTEXT'))) { |
|
24 | + putenv("ERDIKO_CONTEXT=default"); |
|
25 | +} |
@@ -51,22 +51,22 @@ discard block |
||
51 | 51 | * Set, and send, the HTTP status code. |
52 | 52 | */ |
53 | 53 | public function setStatusCode($code = null) { |
54 | - if(!empty($code)) { |
|
54 | + if(!empty($code)) { |
|
55 | 55 | $this->_statusCode = $code; |
56 | 56 | http_response_code($this->_statusCode); // this sends the http status code |
57 | - } |
|
57 | + } |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | public function setErrors($errors = null) |
61 | 61 | { |
62 | - if(!empty($errors)) { |
|
62 | + if(!empty($errors)) { |
|
63 | 63 | |
64 | 64 | if(!is_array($errors)) { |
65 | - $errors = array($errors); |
|
65 | + $errors = array($errors); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | $this->_errors = $errors; |
69 | - } |
|
69 | + } |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -76,16 +76,16 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public function render() |
78 | 78 | { |
79 | - $responseData = array( |
|
80 | - "status" => $this->_statusCode, |
|
81 | - "body" => $this->_content, |
|
82 | - "errors" => $this->_errors |
|
79 | + $responseData = array( |
|
80 | + "status" => $this->_statusCode, |
|
81 | + "body" => $this->_content, |
|
82 | + "errors" => $this->_errors |
|
83 | 83 | ); |
84 | 84 | |
85 | - // set the mime type to JSON |
|
86 | - header('Content-Type: application/json'); |
|
85 | + // set the mime type to JSON |
|
86 | + header('Content-Type: application/json'); |
|
87 | 87 | |
88 | - return json_encode($responseData); |
|
88 | + return json_encode($responseData); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * Set, and send, the HTTP status code. |
52 | 52 | */ |
53 | 53 | public function setStatusCode($code = null) { |
54 | - if(!empty($code)) { |
|
54 | + if (!empty($code)) { |
|
55 | 55 | $this->_statusCode = $code; |
56 | 56 | http_response_code($this->_statusCode); // this sends the http status code |
57 | 57 | } |
@@ -59,9 +59,9 @@ discard block |
||
59 | 59 | |
60 | 60 | public function setErrors($errors = null) |
61 | 61 | { |
62 | - if(!empty($errors)) { |
|
62 | + if (!empty($errors)) { |
|
63 | 63 | |
64 | - if(!is_array($errors)) { |
|
64 | + if (!is_array($errors)) { |
|
65 | 65 | $errors = array($errors); |
66 | 66 | } |
67 | 67 |
@@ -18,11 +18,11 @@ |
||
18 | 18 | /** |
19 | 19 | * Theme |
20 | 20 | */ |
21 | - protected $_theme; |
|
21 | + protected $_theme; |
|
22 | 22 | /** |
23 | 23 | * Content |
24 | 24 | */ |
25 | - protected $_content = null; |
|
25 | + protected $_content = null; |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * Ajax render function |