@@ -23,22 +23,22 @@ |
||
23 | 23 | |
24 | 24 | public static function today($format=Dato::FORMAT) |
25 | 25 | { |
26 | - return Dato::today($format); |
|
27 | - } |
|
26 | + return Dato::today($format); |
|
27 | + } |
|
28 | 28 | |
29 | 29 | public static function date($date=null, $format=Dato::FORMAT) : string |
30 | - { |
|
31 | - return Dato::format($date); |
|
32 | - } |
|
30 | + { |
|
31 | + return Dato::format($date); |
|
32 | + } |
|
33 | 33 | // |
34 | 34 | // //------------------------------------------------------------ MySQL DateTime helpers |
35 | 35 | // public static function year($date=null) : string |
36 | - // { |
|
37 | - // return Dato::format($date, Dato::FORMAT_YEAR); |
|
38 | - // } |
|
36 | + // { |
|
37 | + // return Dato::format($date, Dato::FORMAT_YEAR); |
|
38 | + // } |
|
39 | 39 | // |
40 | - // public static function datetime($date=null) : string |
|
41 | - // { |
|
42 | - // return DatoTempo::format($date); |
|
43 | - // } |
|
40 | + // public static function datetime($date=null) : string |
|
41 | + // { |
|
42 | + // return DatoTempo::format($date); |
|
43 | + // } |
|
44 | 44 | } |
@@ -21,12 +21,12 @@ |
||
21 | 21 | return $this->__toString(); |
22 | 22 | } |
23 | 23 | |
24 | - public static function today($format=Dato::FORMAT) |
|
24 | + public static function today($format = Dato::FORMAT) |
|
25 | 25 | { |
26 | 26 | return Dato::today($format); |
27 | 27 | } |
28 | 28 | |
29 | - public static function date($date=null, $format=Dato::FORMAT) : string |
|
29 | + public static function date($date = null, $format = Dato::FORMAT) : string |
|
30 | 30 | { |
31 | 31 | return Dato::format($date); |
32 | 32 | } |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | public function __debugInfo() |
17 | 17 | { |
18 | 18 | $dbg = get_object_vars($this); |
19 | - $dbg['configurations']['template_engine'] = isset($dbg['configurations']['template_engine'])? get_class($dbg['configurations']['template_engine']) : 'NOT SET'; |
|
19 | + $dbg['configurations']['template_engine'] = isset($dbg['configurations']['template_engine']) ? get_class($dbg['configurations']['template_engine']) : 'NOT SET'; |
|
20 | 20 | |
21 | 21 | return $dbg; |
22 | 22 | } |
@@ -34,45 +34,45 @@ discard block |
||
34 | 34 | public function get($configuration) |
35 | 35 | { |
36 | 36 | |
37 | - if(!is_string($configuration)) |
|
37 | + if (!is_string($configuration)) |
|
38 | 38 | throw new LamentException($configuration); |
39 | 39 | |
40 | - if($this->has($configuration)) |
|
40 | + if ($this->has($configuration)) |
|
41 | 41 | return $this->configurations[$configuration]; |
42 | 42 | |
43 | 43 | |
44 | 44 | // fallbacks |
45 | - if(preg_match('/^settings\./', $configuration, $m) === 1) |
|
45 | + if (preg_match('/^settings\./', $configuration, $m) === 1) |
|
46 | 46 | { |
47 | 47 | $ret = $this->configurations; |
48 | - foreach(explode('.', $configuration) as $k) |
|
48 | + foreach (explode('.', $configuration) as $k) |
|
49 | 49 | { |
50 | - if(!isset($ret[$k])) |
|
50 | + if (!isset($ret[$k])) |
|
51 | 51 | throw new ConfigurationException($configuration); |
52 | 52 | $ret = $ret[$k]; |
53 | 53 | } |
54 | 54 | |
55 | 55 | return $ret; |
56 | 56 | } |
57 | - elseif(class_exists($configuration)) // auto create instances |
|
57 | + elseif (class_exists($configuration)) // auto create instances |
|
58 | 58 | { |
59 | 59 | |
60 | 60 | $rc = new \ReflectionClass($configuration); |
61 | 61 | |
62 | 62 | $construction_args = []; |
63 | 63 | $instance = null; |
64 | - if(!is_null($rc->getConstructor())) |
|
64 | + if (!is_null($rc->getConstructor())) |
|
65 | 65 | { |
66 | - foreach($rc->getConstructor()->getParameters() as $param) |
|
66 | + foreach ($rc->getConstructor()->getParameters() as $param) |
|
67 | 67 | { |
68 | - $construction_args []= $this->get($param->getType().''); |
|
68 | + $construction_args [] = $this->get($param->getType().''); |
|
69 | 69 | } |
70 | 70 | $instance = $rc->newInstanceArgs($construction_args); |
71 | 71 | } |
72 | 72 | else |
73 | 73 | $instance = $rc->newInstanceArgs(); |
74 | 74 | |
75 | - if($rc->hasMethod('set_container')) |
|
75 | + if ($rc->hasMethod('set_container')) |
|
76 | 76 | $instance->set_container($this); |
77 | 77 | |
78 | 78 | return $instance; |
@@ -34,11 +34,13 @@ discard block |
||
34 | 34 | public function get($configuration) |
35 | 35 | { |
36 | 36 | |
37 | - if(!is_string($configuration)) |
|
38 | - throw new LamentException($configuration); |
|
37 | + if(!is_string($configuration)) { |
|
38 | + throw new LamentException($configuration); |
|
39 | + } |
|
39 | 40 | |
40 | - if($this->has($configuration)) |
|
41 | - return $this->configurations[$configuration]; |
|
41 | + if($this->has($configuration)) { |
|
42 | + return $this->configurations[$configuration]; |
|
43 | + } |
|
42 | 44 | |
43 | 45 | |
44 | 46 | // fallbacks |
@@ -47,17 +49,19 @@ discard block |
||
47 | 49 | $ret = $this->configurations; |
48 | 50 | foreach(explode('.', $configuration) as $k) |
49 | 51 | { |
50 | - if(!isset($ret[$k])) |
|
51 | - throw new ConfigurationException($configuration); |
|
52 | + if(!isset($ret[$k])) { |
|
53 | + throw new ConfigurationException($configuration); |
|
54 | + } |
|
52 | 55 | $ret = $ret[$k]; |
53 | 56 | } |
54 | 57 | |
55 | 58 | return $ret; |
56 | - } |
|
57 | - elseif(class_exists($configuration)) // auto create instances |
|
59 | + } elseif(class_exists($configuration)) { |
|
60 | + // auto create instances |
|
58 | 61 | { |
59 | 62 | |
60 | 63 | $rc = new \ReflectionClass($configuration); |
64 | + } |
|
61 | 65 | |
62 | 66 | $construction_args = []; |
63 | 67 | $instance = null; |
@@ -68,12 +72,13 @@ discard block |
||
68 | 72 | $construction_args []= $this->get($param->getType().''); |
69 | 73 | } |
70 | 74 | $instance = $rc->newInstanceArgs($construction_args); |
75 | + } else { |
|
76 | + $instance = $rc->newInstanceArgs(); |
|
71 | 77 | } |
72 | - else |
|
73 | - $instance = $rc->newInstanceArgs(); |
|
74 | 78 | |
75 | - if($rc->hasMethod('set_container')) |
|
76 | - $instance->set_container($this); |
|
79 | + if($rc->hasMethod('set_container')) { |
|
80 | + $instance->set_container($this); |
|
81 | + } |
|
77 | 82 | |
78 | 83 | return $instance; |
79 | 84 | } |
@@ -265,7 +265,7 @@ |
||
265 | 265 | * const NOTICE = 'notice'; // Normal but significant events. |
266 | 266 | * const INFO = 'info'; // Interesting events. User logs in, SQL logs. |
267 | 267 | * const DEBUG = 'debug'; // Detailed debug information. |
268 | - */ |
|
268 | + */ |
|
269 | 269 | private static function map_error_level_to_log_level($level) : string |
270 | 270 | { |
271 | 271 | // http://php.net/manual/en/errorfunc.constants.php |
@@ -13,8 +13,8 @@ discard block |
||
13 | 13 | |
14 | 14 | class LogLaddy implements LoggerInterface |
15 | 15 | { |
16 | - use \Psr\Log\LoggerTrait; // PSR implementation |
|
17 | - use \HexMakina\Debugger\Debugger; // Debugger |
|
16 | + use \Psr\Log\LoggerTrait; // PSR implementation |
|
17 | + use \HexMakina\Debugger\Debugger; // Debugger |
|
18 | 18 | |
19 | 19 | const REPORTING_USER = 'user_messages'; |
20 | 20 | const INTERNAL_ERROR = 'error'; |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | $context['class'] = get_class($throwable); |
56 | 56 | $context['trace'] = $throwable->getTrace(); |
57 | 57 | |
58 | - if(is_subclass_of($throwable, 'Error') || get_class($throwable) === 'Error') |
|
58 | + if (is_subclass_of($throwable, 'Error') || get_class($throwable) === 'Error') |
|
59 | 59 | (new LogLaddy())->alert(self::INTERNAL_ERROR, $context); |
60 | - elseif(is_subclass_of($throwable, 'Exception') || get_class($throwable) === 'Exception') |
|
60 | + elseif (is_subclass_of($throwable, 'Exception') || get_class($throwable) === 'Exception') |
|
61 | 61 | (new LogLaddy())->notice(self::USER_EXCEPTION, $context); |
62 | 62 | else |
63 | 63 | { |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | |
69 | 69 | public function system_halted($level) |
70 | 70 | { |
71 | - switch($level) |
|
71 | + switch ($level) |
|
72 | 72 | { |
73 | 73 | case LogLevel::ERROR: |
74 | 74 | case LogLevel::CRITICAL: |
@@ -86,19 +86,19 @@ discard block |
||
86 | 86 | $display_error = null; |
87 | 87 | |
88 | 88 | // --- Handles Throwables (exception_handler()) |
89 | - if($message==self::INTERNAL_ERROR || $message== self::USER_EXCEPTION) |
|
89 | + if ($message == self::INTERNAL_ERROR || $message == self::USER_EXCEPTION) |
|
90 | 90 | { |
91 | 91 | $this->has_halting_messages = true; |
92 | 92 | $display_error = self::format_throwable_message($context['class'], $context['code'], $context['file'], $context['line'], $context['text']); |
93 | 93 | error_log($display_error); |
94 | - $display_error.= self::format_trace($context['trace'], false); |
|
94 | + $display_error .= self::format_trace($context['trace'], false); |
|
95 | 95 | self::HTTP_500($display_error); |
96 | 96 | } |
97 | - elseif($this->system_halted($level)) // analyses error level |
|
97 | + elseif ($this->system_halted($level)) // analyses error level |
|
98 | 98 | { |
99 | 99 | $display_error = sprintf(PHP_EOL.'%s in file %s:%d'.PHP_EOL.'%s', $level, self::format_file($context['file']), $context['line'], $message); |
100 | 100 | error_log($display_error); |
101 | - $display_error.= self::format_trace($context['trace'], true); |
|
101 | + $display_error .= self::format_trace($context['trace'], true); |
|
102 | 102 | self::HTTP_500($display_error); |
103 | 103 | } |
104 | 104 | else |
@@ -128,10 +128,10 @@ discard block |
||
128 | 128 | // ----------------------------------------------------------- User messages:add one |
129 | 129 | public function report_to_user($level, $message, $context = []) |
130 | 130 | { |
131 | - if(!isset($_SESSION[self::REPORTING_USER])) |
|
131 | + if (!isset($_SESSION[self::REPORTING_USER])) |
|
132 | 132 | $_SESSION[self::REPORTING_USER] = []; |
133 | 133 | |
134 | - if(!isset($_SESSION[self::REPORTING_USER][$level])) |
|
134 | + if (!isset($_SESSION[self::REPORTING_USER][$level])) |
|
135 | 135 | $_SESSION[self::REPORTING_USER][$level] = []; |
136 | 136 | |
137 | 137 | $_SESSION[self::REPORTING_USER][$level][] = [$message, $context]; |
@@ -163,21 +163,21 @@ discard block |
||
163 | 163 | private static function map_error_level_to_log_level($level) : string |
164 | 164 | { |
165 | 165 | // http://php.net/manual/en/errorfunc.constants.php |
166 | - $m=[]; |
|
166 | + $m = []; |
|
167 | 167 | |
168 | - $m[E_ERROR]=$m[E_PARSE]=$m[E_CORE_ERROR]=$m[E_COMPILE_ERROR]=$m[E_USER_ERROR]=$m[E_RECOVERABLE_ERROR]=LogLevel::ALERT; |
|
169 | - $m[1]=$m[4]=$m[16]=$m[64]=$m[256]=$m[4096]=LogLevel::ALERT; |
|
168 | + $m[E_ERROR] = $m[E_PARSE] = $m[E_CORE_ERROR] = $m[E_COMPILE_ERROR] = $m[E_USER_ERROR] = $m[E_RECOVERABLE_ERROR] = LogLevel::ALERT; |
|
169 | + $m[1] = $m[4] = $m[16] = $m[64] = $m[256] = $m[4096] = LogLevel::ALERT; |
|
170 | 170 | |
171 | - $m[E_WARNING]=$m[E_CORE_WARNING]=$m[E_COMPILE_WARNING]=$m[E_USER_WARNING]=LogLevel::CRITICAL; |
|
172 | - $m[2]=$m[32]=$m[128]=$m[512]=LogLevel::CRITICAL; |
|
171 | + $m[E_WARNING] = $m[E_CORE_WARNING] = $m[E_COMPILE_WARNING] = $m[E_USER_WARNING] = LogLevel::CRITICAL; |
|
172 | + $m[2] = $m[32] = $m[128] = $m[512] = LogLevel::CRITICAL; |
|
173 | 173 | |
174 | - $m[E_NOTICE]=$m[E_USER_NOTICE]=LogLevel::ERROR; |
|
175 | - $m[8]=$m[1024]=LogLevel::ERROR; |
|
174 | + $m[E_NOTICE] = $m[E_USER_NOTICE] = LogLevel::ERROR; |
|
175 | + $m[8] = $m[1024] = LogLevel::ERROR; |
|
176 | 176 | |
177 | - $m[E_STRICT]=$m[E_DEPRECATED]=$m[E_USER_DEPRECATED]=$m[E_ALL]=LogLevel::DEBUG; |
|
178 | - $m[2048]=$m[8192]=$m[16384]=$m[32767]=LogLevel::DEBUG; |
|
177 | + $m[E_STRICT] = $m[E_DEPRECATED] = $m[E_USER_DEPRECATED] = $m[E_ALL] = LogLevel::DEBUG; |
|
178 | + $m[2048] = $m[8192] = $m[16384] = $m[32767] = LogLevel::DEBUG; |
|
179 | 179 | |
180 | - if(isset($m[$level])) |
|
180 | + if (isset($m[$level])) |
|
181 | 181 | return $m[$level]; |
182 | 182 | |
183 | 183 | throw new \Exception(__FUNCTION__."($level): $level is unknown"); |
@@ -55,11 +55,11 @@ discard block |
||
55 | 55 | $context['class'] = get_class($throwable); |
56 | 56 | $context['trace'] = $throwable->getTrace(); |
57 | 57 | |
58 | - if(is_subclass_of($throwable, 'Error') || get_class($throwable) === 'Error') |
|
59 | - (new LogLaddy())->alert(self::INTERNAL_ERROR, $context); |
|
60 | - elseif(is_subclass_of($throwable, 'Exception') || get_class($throwable) === 'Exception') |
|
61 | - (new LogLaddy())->notice(self::USER_EXCEPTION, $context); |
|
62 | - else |
|
58 | + if(is_subclass_of($throwable, 'Error') || get_class($throwable) === 'Error') { |
|
59 | + (new LogLaddy())->alert(self::INTERNAL_ERROR, $context); |
|
60 | + } elseif(is_subclass_of($throwable, 'Exception') || get_class($throwable) === 'Exception') { |
|
61 | + (new LogLaddy())->notice(self::USER_EXCEPTION, $context); |
|
62 | + } else |
|
63 | 63 | { |
64 | 64 | die('This Throwable is not an Error or an Exception. This is unfortunate.'); |
65 | 65 | } |
@@ -93,15 +93,15 @@ discard block |
||
93 | 93 | error_log($display_error); |
94 | 94 | $display_error.= self::format_trace($context['trace'], false); |
95 | 95 | self::HTTP_500($display_error); |
96 | - } |
|
97 | - elseif($this->system_halted($level)) // analyses error level |
|
96 | + } elseif($this->system_halted($level)) { |
|
97 | + // analyses error level |
|
98 | 98 | { |
99 | 99 | $display_error = sprintf(PHP_EOL.'%s in file %s:%d'.PHP_EOL.'%s', $level, self::format_file($context['file']), $context['line'], $message); |
100 | + } |
|
100 | 101 | error_log($display_error); |
101 | 102 | $display_error.= self::format_trace($context['trace'], true); |
102 | 103 | self::HTTP_500($display_error); |
103 | - } |
|
104 | - else |
|
104 | + } else |
|
105 | 105 | {// --- Handles user messages, through SESSION storage |
106 | 106 | $this->report_to_user($level, $message, $context); |
107 | 107 | } |
@@ -128,11 +128,13 @@ discard block |
||
128 | 128 | // ----------------------------------------------------------- User messages:add one |
129 | 129 | public function report_to_user($level, $message, $context = []) |
130 | 130 | { |
131 | - if(!isset($_SESSION[self::REPORTING_USER])) |
|
132 | - $_SESSION[self::REPORTING_USER] = []; |
|
131 | + if(!isset($_SESSION[self::REPORTING_USER])) { |
|
132 | + $_SESSION[self::REPORTING_USER] = []; |
|
133 | + } |
|
133 | 134 | |
134 | - if(!isset($_SESSION[self::REPORTING_USER][$level])) |
|
135 | - $_SESSION[self::REPORTING_USER][$level] = []; |
|
135 | + if(!isset($_SESSION[self::REPORTING_USER][$level])) { |
|
136 | + $_SESSION[self::REPORTING_USER][$level] = []; |
|
137 | + } |
|
136 | 138 | |
137 | 139 | $_SESSION[self::REPORTING_USER][$level][] = [$message, $context]; |
138 | 140 | } |
@@ -177,8 +179,9 @@ discard block |
||
177 | 179 | $m[E_STRICT]=$m[E_DEPRECATED]=$m[E_USER_DEPRECATED]=$m[E_ALL]=LogLevel::DEBUG; |
178 | 180 | $m[2048]=$m[8192]=$m[16384]=$m[32767]=LogLevel::DEBUG; |
179 | 181 | |
180 | - if(isset($m[$level])) |
|
181 | - return $m[$level]; |
|
182 | + if(isset($m[$level])) { |
|
183 | + return $m[$level]; |
|
184 | + } |
|
182 | 185 | |
183 | 186 | throw new \Exception(__FUNCTION__."($level): $level is unknown"); |
184 | 187 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | |
13 | 13 | function __construct($file_manageable_model, $filetype) |
14 | 14 | { |
15 | - if(!is_subclass_of($file_manageable_model, '\HexMakina\Crudites\TightModel')) |
|
15 | + if (!is_subclass_of($file_manageable_model, '\HexMakina\Crudites\TightModel')) |
|
16 | 16 | throw new \Exception("__construct($file_manageable_model) // only Model items are manageable"); |
17 | 17 | |
18 | 18 | $this->pmi = $file_manageable_model; |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | public function download($url) |
33 | 33 | { |
34 | 34 | $filename = $this->build_filename(); |
35 | - $filename .= '.' . pathinfo($url, PATHINFO_EXTENSION); |
|
35 | + $filename .= '.'.pathinfo($url, PATHINFO_EXTENSION); |
|
36 | 36 | |
37 | 37 | $filepath = $this->build_path_to_file($filename); |
38 | 38 | |
@@ -58,10 +58,10 @@ discard block |
||
58 | 58 | return $this->pmi->get_id().'/'; |
59 | 59 | |
60 | 60 | $pmi_model_type = get_class($this->pmi)::model_type(); |
61 | - if(!isset($this->pmi) || is_null($this->get_type())) |
|
61 | + if (!isset($this->pmi) || is_null($this->get_type())) |
|
62 | 62 | throw new \Exception(__FUNCTION__." // undefined manageable item or picture type"); |
63 | 63 | |
64 | - if(!isset($settings[$pmi_model_type][$this->get_type()]['import_directory'])) |
|
64 | + if (!isset($settings[$pmi_model_type][$this->get_type()]['import_directory'])) |
|
65 | 65 | throw new \Exception(__FUNCTION__." // undefined configuration for '".($pmi_model_type)."'>'".$this->get_type()."'>'import_directory'"); |
66 | 66 | |
67 | 67 | // global $settings; |
@@ -12,8 +12,9 @@ discard block |
||
12 | 12 | |
13 | 13 | function __construct($file_manageable_model, $filetype) |
14 | 14 | { |
15 | - if(!is_subclass_of($file_manageable_model, '\HexMakina\Crudites\TightModel')) |
|
16 | - throw new \Exception("__construct($file_manageable_model) // only Model items are manageable"); |
|
15 | + if(!is_subclass_of($file_manageable_model, '\HexMakina\Crudites\TightModel')) { |
|
16 | + throw new \Exception("__construct($file_manageable_model) // only Model items are manageable"); |
|
17 | + } |
|
17 | 18 | |
18 | 19 | $this->pmi = $file_manageable_model; |
19 | 20 | $this->picture_type = $filetype; |
@@ -58,11 +59,13 @@ discard block |
||
58 | 59 | return $this->pmi->get_id().'/'; |
59 | 60 | |
60 | 61 | $pmi_model_type = get_class($this->pmi)::model_type(); |
61 | - if(!isset($this->pmi) || is_null($this->get_type())) |
|
62 | - throw new \Exception(__FUNCTION__." // undefined manageable item or picture type"); |
|
62 | + if(!isset($this->pmi) || is_null($this->get_type())) { |
|
63 | + throw new \Exception(__FUNCTION__." // undefined manageable item or picture type"); |
|
64 | + } |
|
63 | 65 | |
64 | - if(!isset($settings[$pmi_model_type][$this->get_type()]['import_directory'])) |
|
65 | - throw new \Exception(__FUNCTION__." // undefined configuration for '".($pmi_model_type)."'>'".$this->get_type()."'>'import_directory'"); |
|
66 | + if(!isset($settings[$pmi_model_type][$this->get_type()]['import_directory'])) { |
|
67 | + throw new \Exception(__FUNCTION__." // undefined configuration for '".($pmi_model_type)."'>'".$this->get_type()."'>'import_directory'"); |
|
68 | + } |
|
66 | 69 | |
67 | 70 | // global $settings; |
68 | 71 | // return $settings[$pmi_model_type][$this->get_type()]['import_directory'].$this->pmi->get_id().'/'; |
@@ -4,14 +4,14 @@ |
||
4 | 4 | |
5 | 5 | interface CRUDController |
6 | 6 | { |
7 | - public function dashboard(); |
|
8 | - public function edit(); |
|
9 | - public function save(); |
|
10 | - public function listing(); |
|
7 | + public function dashboard(); |
|
8 | + public function edit(); |
|
9 | + public function save(); |
|
10 | + public function listing(); |
|
11 | 11 | |
12 | - public function destroy(); |
|
12 | + public function destroy(); |
|
13 | 13 | |
14 | - public function errors() : array; |
|
14 | + public function errors() : array; |
|
15 | 15 | } |
16 | 16 | |
17 | 17 |
@@ -19,15 +19,15 @@ discard block |
||
19 | 19 | return $this->router()->prehop('traduko'); |
20 | 20 | } |
21 | 21 | |
22 | - public function update_file($lang='fra') |
|
22 | + public function update_file($lang = 'fra') |
|
23 | 23 | { |
24 | - try{ |
|
24 | + try { |
|
25 | 25 | $locale_path = $this->box('settings.locale.directory_path').'/'.$this->box('settings.locale.file_name'); |
26 | 26 | self::create_file($locale_path, $lang); |
27 | 27 | |
28 | 28 | $this->logger()->nice(L('KADRO_SYSTEM_FILE_UPDATED')); |
29 | 29 | } |
30 | - catch(\Exception $e) |
|
30 | + catch (\Exception $e) |
|
31 | 31 | { |
32 | 32 | $this->logger()->notice(L('KADRO_SYSTEM_FILE_UPDATED')); |
33 | 33 | } |
@@ -38,11 +38,11 @@ discard block |
||
38 | 38 | { |
39 | 39 | $res = Traduko::filter(['lang' => $lang]); |
40 | 40 | $assoc = []; |
41 | - foreach($res as $id => $trad) |
|
41 | + foreach ($res as $id => $trad) |
|
42 | 42 | { |
43 | - if(!isset($assoc[$trad->kategorio])) |
|
43 | + if (!isset($assoc[$trad->kategorio])) |
|
44 | 44 | $assoc[$trad->kategorio] = []; |
45 | - if(!isset($assoc[$trad->kategorio][$trad->sekcio])) |
|
45 | + if (!isset($assoc[$trad->kategorio][$trad->sekcio])) |
|
46 | 46 | $assoc[$trad->kategorio][$trad->sekcio] = []; |
47 | 47 | |
48 | 48 | $assoc[$trad->kategorio][$trad->sekcio][$trad->referenco] = $trad->$lang; |
@@ -57,8 +57,8 @@ discard block |
||
57 | 57 | public static function init($locale_path) |
58 | 58 | { |
59 | 59 | $languages = array_keys(array_slice(Traduko::inspect(Traduko::table_name())->columns(), 4)); |
60 | - foreach($languages as $l) |
|
61 | - self::create_file($locale_path,$l); |
|
60 | + foreach ($languages as $l) |
|
61 | + self::create_file($locale_path, $l); |
|
62 | 62 | |
63 | 63 | return $languages; |
64 | 64 | } |
@@ -26,8 +26,7 @@ discard block |
||
26 | 26 | self::create_file($locale_path, $lang); |
27 | 27 | |
28 | 28 | $this->logger()->nice(L('KADRO_SYSTEM_FILE_UPDATED')); |
29 | - } |
|
30 | - catch(\Exception $e) |
|
29 | + } catch(\Exception $e) |
|
31 | 30 | { |
32 | 31 | $this->logger()->notice(L('KADRO_SYSTEM_FILE_UPDATED')); |
33 | 32 | } |
@@ -40,10 +39,12 @@ discard block |
||
40 | 39 | $assoc = []; |
41 | 40 | foreach($res as $id => $trad) |
42 | 41 | { |
43 | - if(!isset($assoc[$trad->kategorio])) |
|
44 | - $assoc[$trad->kategorio] = []; |
|
45 | - if(!isset($assoc[$trad->kategorio][$trad->sekcio])) |
|
46 | - $assoc[$trad->kategorio][$trad->sekcio] = []; |
|
42 | + if(!isset($assoc[$trad->kategorio])) { |
|
43 | + $assoc[$trad->kategorio] = []; |
|
44 | + } |
|
45 | + if(!isset($assoc[$trad->kategorio][$trad->sekcio])) { |
|
46 | + $assoc[$trad->kategorio][$trad->sekcio] = []; |
|
47 | + } |
|
47 | 48 | |
48 | 49 | $assoc[$trad->kategorio][$trad->sekcio][$trad->referenco] = $trad->$lang; |
49 | 50 | } |
@@ -57,8 +58,9 @@ discard block |
||
57 | 58 | public static function init($locale_path) |
58 | 59 | { |
59 | 60 | $languages = array_keys(array_slice(Traduko::inspect(Traduko::table_name())->columns(), 4)); |
60 | - foreach($languages as $l) |
|
61 | - self::create_file($locale_path,$l); |
|
61 | + foreach($languages as $l) { |
|
62 | + self::create_file($locale_path,$l); |
|
63 | + } |
|
62 | 64 | |
63 | 65 | return $languages; |
64 | 66 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | namespace HexMakina\kadro\Controllers; |
13 | 13 | |
14 | 14 | use \HexMakina\Crudites\Crudites; |
15 | -use \HexMakina\kadro\Auth\{Operator,OperatorInterface,ACL,AccessRefusedException}; |
|
15 | +use \HexMakina\kadro\Auth\{Operator, OperatorInterface, ACL, AccessRefusedException}; |
|
16 | 16 | |
17 | 17 | |
18 | 18 | class OperatorController extends \HexMakina\kadro\Controllers\ORMController |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | parent::edit(); |
24 | 24 | |
25 | 25 | // do we create? or do we edit someone else ? must be admin |
26 | - if(is_null($this->load_model) || $this->operator()->operator_id() !== $this->load_model->operator_id()) |
|
26 | + if (is_null($this->load_model) || $this->operator()->operator_id() !== $this->load_model->operator_id()) |
|
27 | 27 | $this->authorize('group_admin'); |
28 | 28 | |
29 | 29 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | |
36 | 36 | public function save() |
37 | 37 | { |
38 | - if($this->operator()->operator_id() !== $this->form_model->operator_id()) |
|
38 | + if ($this->operator()->operator_id() !== $this->form_model->operator_id()) |
|
39 | 39 | $this->authorize('group_admin'); |
40 | 40 | |
41 | 41 | parent::save(); |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | public function before_save() : array |
45 | 45 | { |
46 | 46 | //------------------------------------------------------------- PASSWORDS |
47 | - if($this->form_model->get('password') != $this->form_model->get('password_verification')) |
|
47 | + if ($this->form_model->get('password') != $this->form_model->get('password_verification')) |
|
48 | 48 | { |
49 | 49 | $this->logger()->warning(L('KADRO_operator_ERR_PASSWORDS_MISMATCH')); |
50 | 50 | return $this->edit(); |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | public function dashboard() |
59 | 59 | { |
60 | 60 | $real_operator_class = get_class($this->operator()); |
61 | - $this->viewport('users', $real_operator_class::filter([], ['order_by' => [null,'username', 'ASC']])); |
|
61 | + $this->viewport('users', $real_operator_class::filter([], ['order_by' => [null, 'username', 'ASC']])); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | public function destroy() |
@@ -71,10 +71,10 @@ discard block |
||
71 | 71 | parent::authorize('group_admin'); |
72 | 72 | |
73 | 73 | $operator = Operator::one($this->router()->params()); |
74 | - if($operator->username() == $this->operator()->username()) |
|
74 | + if ($operator->username() == $this->operator()->username()) |
|
75 | 75 | throw new AccessRefusedException(); |
76 | 76 | |
77 | - if(Operator::toggle_boolean(Operator::table_name(), 'active', $operator->operator_id()) === true) |
|
77 | + if (Operator::toggle_boolean(Operator::table_name(), 'active', $operator->operator_id()) === true) |
|
78 | 78 | { |
79 | 79 | $confirmation_message = $operator->is_active() ? 'KADRO_operator_DISABLED' : 'KADRO_operator_ENABLED'; |
80 | 80 | $this->logger()->nice(L($confirmation_message, [$operator->name()])); |
@@ -92,14 +92,14 @@ discard block |
||
92 | 92 | parent::authorize('group_admin'); |
93 | 93 | |
94 | 94 | $operator = Operator::one(['username' => $this->router()->params('username')]); |
95 | - if($operator->username() == $this->operator()->username()) |
|
95 | + if ($operator->username() == $this->operator()->username()) |
|
96 | 96 | throw new AccessRefusedException(); |
97 | 97 | |
98 | 98 | $permission_id = $this->router()->params('permission_id'); |
99 | 99 | |
100 | 100 | $row_data = ['operator_id' => $operator->operator_id(), 'permission_id' => $permission_id]; |
101 | 101 | $row = ACL::table()->restore($row_data); |
102 | - if($row->is_new()) |
|
102 | + if ($row->is_new()) |
|
103 | 103 | { |
104 | 104 | $row = ACL::table()->produce($row_data); |
105 | 105 | $res = $row->persist(); |
@@ -23,8 +23,9 @@ discard block |
||
23 | 23 | parent::edit(); |
24 | 24 | |
25 | 25 | // do we create? or do we edit someone else ? must be admin |
26 | - if(is_null($this->load_model) || $this->operator()->operator_id() !== $this->load_model->operator_id()) |
|
27 | - $this->authorize('group_admin'); |
|
26 | + if(is_null($this->load_model) || $this->operator()->operator_id() !== $this->load_model->operator_id()) { |
|
27 | + $this->authorize('group_admin'); |
|
28 | + } |
|
28 | 29 | |
29 | 30 | } |
30 | 31 | |
@@ -35,8 +36,9 @@ discard block |
||
35 | 36 | |
36 | 37 | public function save() |
37 | 38 | { |
38 | - if($this->operator()->operator_id() !== $this->form_model->operator_id()) |
|
39 | - $this->authorize('group_admin'); |
|
39 | + if($this->operator()->operator_id() !== $this->form_model->operator_id()) { |
|
40 | + $this->authorize('group_admin'); |
|
41 | + } |
|
40 | 42 | |
41 | 43 | parent::save(); |
42 | 44 | } |
@@ -71,15 +73,15 @@ discard block |
||
71 | 73 | parent::authorize('group_admin'); |
72 | 74 | |
73 | 75 | $operator = Operator::one($this->router()->params()); |
74 | - if($operator->username() == $this->operator()->username()) |
|
75 | - throw new AccessRefusedException(); |
|
76 | + if($operator->username() == $this->operator()->username()) { |
|
77 | + throw new AccessRefusedException(); |
|
78 | + } |
|
76 | 79 | |
77 | 80 | if(Operator::toggle_boolean(Operator::table_name(), 'active', $operator->operator_id()) === true) |
78 | 81 | { |
79 | 82 | $confirmation_message = $operator->is_active() ? 'KADRO_operator_DISABLED' : 'KADRO_operator_ENABLED'; |
80 | 83 | $this->logger()->nice(L($confirmation_message, [$operator->name()])); |
81 | - } |
|
82 | - else |
|
84 | + } else |
|
83 | 85 | { |
84 | 86 | $this->logger()->warning(L('CRUDITES_ERR_QUERY_FAILED')); |
85 | 87 | } |
@@ -92,8 +94,9 @@ discard block |
||
92 | 94 | parent::authorize('group_admin'); |
93 | 95 | |
94 | 96 | $operator = Operator::one(['username' => $this->router()->params('username')]); |
95 | - if($operator->username() == $this->operator()->username()) |
|
96 | - throw new AccessRefusedException(); |
|
97 | + if($operator->username() == $this->operator()->username()) { |
|
98 | + throw new AccessRefusedException(); |
|
99 | + } |
|
97 | 100 | |
98 | 101 | $permission_id = $this->router()->params('permission_id'); |
99 | 102 | |
@@ -103,8 +106,7 @@ discard block |
||
103 | 106 | { |
104 | 107 | $row = ACL::table()->produce($row_data); |
105 | 108 | $res = $row->persist(); |
106 | - } |
|
107 | - else |
|
109 | + } else |
|
108 | 110 | { |
109 | 111 | $row->wipe(); |
110 | 112 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | require APP_BASE.'vendor/autoload.php'; |
15 | 15 | |
16 | 16 | require 'PSR4Autoloader.class.php'; |
17 | - $loader=new PSR4Autoloader; |
|
17 | + $loader = new PSR4Autoloader; |
|
18 | 18 | $loader->register(); //Register loader with SPL autoloader stack. |
19 | 19 | |
20 | 20 | $loader->addNamespace('HexMakina', APP_BASE.'/lib/'); |
@@ -39,9 +39,9 @@ discard block |
||
39 | 39 | |
40 | 40 | //--------------------------------------------------------------- parametroj |
41 | 41 | require_once APP_BASE.'configs/settings.php'; |
42 | - $box=new Container\LeMarchand($settings); |
|
42 | + $box = new Container\LeMarchand($settings); |
|
43 | 43 | |
44 | - foreach($box->get('settings.app.namespaces') as $namespace => $path) |
|
44 | + foreach ($box->get('settings.app.namespaces') as $namespace => $path) |
|
45 | 45 | { |
46 | 46 | $loader->addNamespace($namespace, $path); |
47 | 47 | } |
@@ -57,9 +57,9 @@ discard block |
||
57 | 57 | |
58 | 58 | //--------------------------------------------------------------- kuketoj |
59 | 59 | setcookie('cookie_test', 'test_value', time()+(365 * 24 * 60 * 60), "/", ""); |
60 | - $cookies_enabled=isset($_COOKIE['cookie_test']); // houston, do we have cookies ? |
|
60 | + $cookies_enabled = isset($_COOKIE['cookie_test']); // houston, do we have cookies ? |
|
61 | 61 | |
62 | - if($cookies_enabled === false) |
|
62 | + if ($cookies_enabled === false) |
|
63 | 63 | { |
64 | 64 | ini_set('session.use_cookies', 0); |
65 | 65 | ini_set('session.use_only_cookies', 0); |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | } |
69 | 69 | |
70 | 70 | //--------------------------------------------------------------- Session Management |
71 | - $StateAgent=new StateAgent($box->get('settings.app.session_start_options') ?? []); |
|
71 | + $StateAgent = new StateAgent($box->get('settings.app.session_start_options') ?? []); |
|
72 | 72 | $StateAgent->add_runtime_filters((array)$box->get('settings.filter')); |
73 | 73 | $StateAgent->add_runtime_filters((array)($_SESSION['filter'] ?? [])); |
74 | 74 | $StateAgent->add_runtime_filters((array)($_REQUEST['filter'] ?? [])); |
@@ -92,24 +92,24 @@ discard block |
||
92 | 92 | //--------------------------------------------------------------- ŝablonoj |
93 | 93 | require_once 'smarty/smarty/libs/Smarty.class.php'; |
94 | 94 | // Load smarty template parser |
95 | - if(is_null($box->get('settings.smarty.template_path')) || is_null($box->get('settings.smarty.compiled_path'))) |
|
95 | + if (is_null($box->get('settings.smarty.template_path')) || is_null($box->get('settings.smarty.compiled_path'))) |
|
96 | 96 | throw new \Exception("SMARTY CONFIG ERROR: missing parameters"); |
97 | 97 | |
98 | - $smarty=new \Smarty(); |
|
98 | + $smarty = new \Smarty(); |
|
99 | 99 | $box->register('template_engine', $smarty); |
100 | 100 | |
101 | - $smarty->setTemplateDir($box->get('RouterInterface')->file_root() . $box->get('settings.smarty.template_path').'app'); |
|
102 | - $smarty->addTemplateDir($box->get('RouterInterface')->file_root() . $box->get('settings.smarty.template_path')); |
|
103 | - $smarty->addTemplateDir(KADRO_BASE . 'Views/'); |
|
101 | + $smarty->setTemplateDir($box->get('RouterInterface')->file_root().$box->get('settings.smarty.template_path').'app'); |
|
102 | + $smarty->addTemplateDir($box->get('RouterInterface')->file_root().$box->get('settings.smarty.template_path')); |
|
103 | + $smarty->addTemplateDir(KADRO_BASE.'Views/'); |
|
104 | 104 | |
105 | - $smarty->setCompileDir(APP_BASE . $box->get('settings.smarty.compiled_path')); |
|
105 | + $smarty->setCompileDir(APP_BASE.$box->get('settings.smarty.compiled_path')); |
|
106 | 106 | $smarty->setDebugging($box->get('settings.smarty.debug')); |
107 | 107 | |
108 | - $smarty->registerClass('Lezer', '\HexMakina\Lezer\Lezer'); |
|
109 | - $smarty->registerClass('Marker', '\HexMakina\Format\HTML\Marker'); |
|
110 | - $smarty->registerClass('Form', '\HexMakina\Format\HTML\Form'); |
|
111 | - $smarty->registerClass('TableToForm', '\HexMakina\kadro\TableToForm'); |
|
112 | - $smarty->registerClass('Dato', '\HexMakina\Format\Tempo\Dato'); |
|
108 | + $smarty->registerClass('Lezer', '\HexMakina\Lezer\Lezer'); |
|
109 | + $smarty->registerClass('Marker', '\HexMakina\Format\HTML\Marker'); |
|
110 | + $smarty->registerClass('Form', '\HexMakina\Format\HTML\Form'); |
|
111 | + $smarty->registerClass('TableToForm', '\HexMakina\kadro\TableToForm'); |
|
112 | + $smarty->registerClass('Dato', '\HexMakina\Format\Tempo\Dato'); |
|
113 | 113 | |
114 | 114 | $smarty->assign('APP_NAME', $box->get('settings.app.name')); |
115 | 115 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | $lezer->init(); |
125 | 125 | |
126 | 126 | $smarty->assign('language', $language); |
127 | - if($cookies_enabled === true) |
|
127 | + if ($cookies_enabled === true) |
|
128 | 128 | setcookie('lang', $language, time()+(365 * 24 * 60 * 60), "/", ""); |
129 | 129 | |
130 | 130 | } |
@@ -92,8 +92,9 @@ discard block |
||
92 | 92 | //--------------------------------------------------------------- ŝablonoj |
93 | 93 | require_once 'smarty/smarty/libs/Smarty.class.php'; |
94 | 94 | // Load smarty template parser |
95 | - if(is_null($box->get('settings.smarty.template_path')) || is_null($box->get('settings.smarty.compiled_path'))) |
|
96 | - throw new \Exception("SMARTY CONFIG ERROR: missing parameters"); |
|
95 | + if(is_null($box->get('settings.smarty.template_path')) || is_null($box->get('settings.smarty.compiled_path'))) { |
|
96 | + throw new \Exception("SMARTY CONFIG ERROR: missing parameters"); |
|
97 | + } |
|
97 | 98 | |
98 | 99 | $smarty=new \Smarty(); |
99 | 100 | $box->register('template_engine', $smarty); |
@@ -124,7 +125,8 @@ discard block |
||
124 | 125 | $lezer->init(); |
125 | 126 | |
126 | 127 | $smarty->assign('language', $language); |
127 | - if($cookies_enabled === true) |
|
128 | - setcookie('lang', $language, time()+(365 * 24 * 60 * 60), "/", ""); |
|
128 | + if($cookies_enabled === true) { |
|
129 | + setcookie('lang', $language, time()+(365 * 24 * 60 * 60), "/", ""); |
|
130 | + } |
|
129 | 131 | |
130 | 132 | } |
@@ -66,10 +66,10 @@ discard block |
||
66 | 66 | return $this->get('language_code'); |
67 | 67 | } |
68 | 68 | |
69 | - public static function query_retrieve($filters=[], $options=[]) : Select |
|
69 | + public static function query_retrieve($filters = [], $options = []) : Select |
|
70 | 70 | { |
71 | 71 | $Query = static::table()->select(); |
72 | - if(isset($options['eager']) && $options['eager'] === true) |
|
72 | + if (isset($options['eager']) && $options['eager'] === true) |
|
73 | 73 | { |
74 | 74 | $Query->group_by('id'); |
75 | 75 | |
@@ -78,10 +78,10 @@ discard block |
||
78 | 78 | $Query->select_also(["GROUP_CONCAT(DISTINCT kadro_permission.id) as permission_ids", "GROUP_CONCAT(DISTINCT kadro_permission.name) as permission_names"]); |
79 | 79 | } |
80 | 80 | |
81 | - if(isset($filters['model']) && !empty($filters['model'])) |
|
81 | + if (isset($filters['model']) && !empty($filters['model'])) |
|
82 | 82 | { |
83 | 83 | $model = $filters['model']; |
84 | - $Query->join([static::otm('t'), static::otm('a')],[[static::otm('a'),static::otm('k'), 't_from','id']], 'INNER'); |
|
84 | + $Query->join([static::otm('t'), static::otm('a')], [[static::otm('a'), static::otm('k'), 't_from', 'id']], 'INNER'); |
|
85 | 85 | $Query->aw_fields_eq(['model_id' => $filters['model']->get_id(), 'model_type' => get_class($filters['model'])::model_type()], static::otm('a')); |
86 | 86 | } |
87 | 87 |