@@ -6,15 +6,11 @@ |
||
| 6 | 6 | use Ffcms\Core\Cache\MemoryObject; |
| 7 | 7 | use Ffcms\Core\Debug\DebugMeasure; |
| 8 | 8 | use Ffcms\Core\Debug\Manager as Debug; |
| 9 | -use Ffcms\Core\Exception\ForbiddenException; |
|
| 10 | -use Ffcms\Core\Exception\JsonException; |
|
| 11 | 9 | use Ffcms\Core\Exception\NativeException; |
| 12 | 10 | use Ffcms\Core\Exception\NotFoundException; |
| 13 | -use Ffcms\Core\Exception\SyntaxException; |
|
| 14 | 11 | use Ffcms\Core\Exception\TemplateException; |
| 15 | 12 | use Ffcms\Core\Helper\Security; |
| 16 | 13 | use Ffcms\Core\Helper\Type\Any; |
| 17 | -use Ffcms\Core\Helper\Type\Obj; |
|
| 18 | 14 | use Ffcms\Core\Helper\Type\Str; |
| 19 | 15 | use Ffcms\Core\I18n\Translate; |
| 20 | 16 | use Ffcms\Core\Managers\BootManager; |
@@ -185,22 +185,22 @@ discard block |
||
| 185 | 185 | $html = null; |
| 186 | 186 | // lets try to get html full content to page render |
| 187 | 187 | try { |
| 188 | - $this->startMeasure(__METHOD__ . '::callback'); |
|
| 188 | + $this->startMeasure(__METHOD__.'::callback'); |
|
| 189 | 189 | /** @var \Ffcms\Core\Arch\Controller $callClass */ |
| 190 | 190 | $callClass = null; |
| 191 | - $callMethod = 'action' . self::$Request->getAction(); |
|
| 191 | + $callMethod = 'action'.self::$Request->getAction(); |
|
| 192 | 192 | |
| 193 | 193 | // define callback class namespace/name full path |
| 194 | - $cName = (self::$Request->getCallbackAlias() ?? '\Apps\Controller\\' . env_name . '\\' . self::$Request->getController()); |
|
| 194 | + $cName = (self::$Request->getCallbackAlias() ?? '\Apps\Controller\\'.env_name.'\\'.self::$Request->getController()); |
|
| 195 | 195 | if (!class_exists($cName)) |
| 196 | - throw new NotFoundException('Callback class not found: ' . App::$Security->strip_tags($cName)); |
|
| 196 | + throw new NotFoundException('Callback class not found: '.App::$Security->strip_tags($cName)); |
|
| 197 | 197 | |
| 198 | 198 | $callClass = new $cName; |
| 199 | 199 | // check if callback method (action) is exist in class object |
| 200 | 200 | if (!method_exists($callClass, $callMethod)) |
| 201 | - throw new NotFoundException('Method "' . App::$Security->strip_tags($callMethod) . '()" not founded in "' . get_class($callClass) . '"'); |
|
| 201 | + throw new NotFoundException('Method "'.App::$Security->strip_tags($callMethod).'()" not founded in "'.get_class($callClass).'"'); |
|
| 202 | 202 | |
| 203 | - $this->stopMeasure(__METHOD__ . '::callback'); |
|
| 203 | + $this->stopMeasure(__METHOD__.'::callback'); |
|
| 204 | 204 | $params = []; |
| 205 | 205 | if (!Str::likeEmpty(self::$Request->getID())) { |
| 206 | 206 | $params[] = self::$Request->getID(); |
@@ -224,10 +224,10 @@ discard block |
||
| 224 | 224 | 'current' => count($params) |
| 225 | 225 | ])); |
| 226 | 226 | |
| 227 | - $this->startMeasure($cName . '::' . $callMethod); |
|
| 227 | + $this->startMeasure($cName.'::'.$callMethod); |
|
| 228 | 228 | // make callback call to action in controller and get response |
| 229 | 229 | $actionResponse = call_user_func_array([$callClass, $callMethod], $params); |
| 230 | - $this->stopMeasure($cName . '::' . $callMethod); |
|
| 230 | + $this->stopMeasure($cName.'::'.$callMethod); |
|
| 231 | 231 | |
| 232 | 232 | // set response to controller attribute |
| 233 | 233 | if (!Str::likeEmpty($actionResponse)) |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | $html = $e->display(); |
| 242 | 242 | } else { // or hook exception to system based :))) |
| 243 | 243 | if (App::$Debug) { |
| 244 | - $msg = $e->getMessage() . $e->getTraceAsString(); |
|
| 244 | + $msg = $e->getMessage().$e->getTraceAsString(); |
|
| 245 | 245 | $html = (new NativeException($msg))->display(); |
| 246 | 246 | } else { |
| 247 | 247 | $html = (new NativeException($e->getMessage()))->display(); |
@@ -156,8 +156,9 @@ discard block |
||
| 156 | 156 | |
| 157 | 157 | /** @var array $objects */ |
| 158 | 158 | $objects = App::$Properties->getAll('object'); |
| 159 | - if (!Any::isArray($objects)) |
|
| 160 | - throw new NativeException('Object configurations is not loaded: /Private/Config/Object.php'); |
|
| 159 | + if (!Any::isArray($objects)) { |
|
| 160 | + throw new NativeException('Object configurations is not loaded: /Private/Config/Object.php'); |
|
| 161 | + } |
|
| 161 | 162 | |
| 162 | 163 | // each all objects as service_name => service_instance() |
| 163 | 164 | foreach ($objects as $name => $instance) { |
@@ -192,20 +193,23 @@ discard block |
||
| 192 | 193 | |
| 193 | 194 | // define callback class namespace/name full path |
| 194 | 195 | $cName = (self::$Request->getCallbackAlias() ?? '\Apps\Controller\\' . env_name . '\\' . self::$Request->getController()); |
| 195 | - if (!class_exists($cName)) |
|
| 196 | - throw new NotFoundException('Callback class not found: ' . App::$Security->strip_tags($cName)); |
|
| 196 | + if (!class_exists($cName)) { |
|
| 197 | + throw new NotFoundException('Callback class not found: ' . App::$Security->strip_tags($cName)); |
|
| 198 | + } |
|
| 197 | 199 | |
| 198 | 200 | $callClass = new $cName; |
| 199 | 201 | // check if callback method (action) is exist in class object |
| 200 | - if (!method_exists($callClass, $callMethod)) |
|
| 201 | - throw new NotFoundException('Method "' . App::$Security->strip_tags($callMethod) . '()" not founded in "' . get_class($callClass) . '"'); |
|
| 202 | + if (!method_exists($callClass, $callMethod)) { |
|
| 203 | + throw new NotFoundException('Method "' . App::$Security->strip_tags($callMethod) . '()" not founded in "' . get_class($callClass) . '"'); |
|
| 204 | + } |
|
| 202 | 205 | |
| 203 | 206 | $this->stopMeasure(__METHOD__ . '::callback'); |
| 204 | 207 | $params = []; |
| 205 | 208 | if (!Str::likeEmpty(self::$Request->getID())) { |
| 206 | 209 | $params[] = self::$Request->getID(); |
| 207 | - if (!Str::likeEmpty(self::$Request->getAdd())) |
|
| 208 | - $params[] = self::$Request->getAdd(); |
|
| 210 | + if (!Str::likeEmpty(self::$Request->getAdd())) { |
|
| 211 | + $params[] = self::$Request->getAdd(); |
|
| 212 | + } |
|
| 209 | 213 | } |
| 210 | 214 | |
| 211 | 215 | // get instance of callback object (class::method) as reflection |
@@ -213,16 +217,18 @@ discard block |
||
| 213 | 217 | $argCount = 0; |
| 214 | 218 | // calculate method defined arguments count |
| 215 | 219 | foreach ($instance->getParameters() as $arg) { |
| 216 | - if (!$arg->isOptional()) |
|
| 217 | - $argCount++; |
|
| 220 | + if (!$arg->isOptional()) { |
|
| 221 | + $argCount++; |
|
| 222 | + } |
|
| 218 | 223 | } |
| 219 | 224 | // compare method arg count with passed |
| 220 | - if (count($params) < $argCount) |
|
| 221 | - throw new NotFoundException(__('Arguments for method %method% is not enough. Expected: %required%, got: %current%.', [ |
|
| 225 | + if (count($params) < $argCount) { |
|
| 226 | + throw new NotFoundException(__('Arguments for method %method% is not enough. Expected: %required%, got: %current%.', [ |
|
| 222 | 227 | 'method' => $callMethod, |
| 223 | 228 | 'required' => $argCount, |
| 224 | 229 | 'current' => count($params) |
| 225 | 230 | ])); |
| 231 | + } |
|
| 226 | 232 | |
| 227 | 233 | $this->startMeasure($cName . '::' . $callMethod); |
| 228 | 234 | // make callback call to action in controller and get response |
@@ -230,8 +236,9 @@ discard block |
||
| 230 | 236 | $this->stopMeasure($cName . '::' . $callMethod); |
| 231 | 237 | |
| 232 | 238 | // set response to controller attribute |
| 233 | - if (!Str::likeEmpty($actionResponse)) |
|
| 234 | - $callClass->setOutput($actionResponse); |
|
| 239 | + if (!Str::likeEmpty($actionResponse)) { |
|
| 240 | + $callClass->setOutput($actionResponse); |
|
| 241 | + } |
|
| 235 | 242 | |
| 236 | 243 | // build full compiled output html data with default layout and widgets |
| 237 | 244 | $html = $callClass->buildOutput(); |
@@ -6,7 +6,6 @@ |
||
| 6 | 6 | use Ffcms\Core\App; |
| 7 | 7 | use Ffcms\Core\Exception\SyntaxException; |
| 8 | 8 | use Ffcms\Core\Helper\Type\Any; |
| 9 | -use Ffcms\Core\Helper\Type\Obj; |
|
| 10 | 9 | use Ffcms\Core\Helper\Type\Str; |
| 11 | 10 | use Ffcms\Core\Interfaces\iModel; |
| 12 | 11 | use Ffcms\Core\Traits\DynamicGlobal; |
@@ -143,8 +143,9 @@ discard block |
||
| 143 | 143 | } |
| 144 | 144 | // add message about wrong attribute to session holder, later display it |
| 145 | 145 | $attrLabel = $attr; |
| 146 | - if ($this->getLabel($attr) !== null) |
|
| 147 | - $attrLabel = $this->getLabel($attr); |
|
| 146 | + if ($this->getLabel($attr) !== null) { |
|
| 147 | + $attrLabel = $this->getLabel($attr); |
|
| 148 | + } |
|
| 148 | 149 | |
| 149 | 150 | App::$Session->getFlashBag()->add('warning', __('Field "%field%" is incorrect', ['field' => $attrLabel])); |
| 150 | 151 | } |
@@ -162,8 +163,9 @@ discard block |
||
| 162 | 163 | $properties = null; |
| 163 | 164 | // list all properties here, array_walk sucks on performance! |
| 164 | 165 | foreach ($this as $property => $value) { |
| 165 | - if (Str::startsWith('_', $property)) |
|
| 166 | - continue; |
|
| 166 | + if (Str::startsWith('_', $property)) { |
|
| 167 | + continue; |
|
| 168 | + } |
|
| 167 | 169 | |
| 168 | 170 | $properties[$property] = $value; |
| 169 | 171 | } |
@@ -177,8 +179,9 @@ discard block |
||
| 177 | 179 | public function clearProperties(): void |
| 178 | 180 | { |
| 179 | 181 | foreach ($this as $property => $value) { |
| 180 | - if (!Str::startsWith('_', $property)) |
|
| 181 | - $this->{$property} = null; |
|
| 182 | + if (!Str::startsWith('_', $property)) { |
|
| 183 | + $this->{$property} = null; |
|
| 184 | + } |
|
| 182 | 185 | } |
| 183 | 186 | } |
| 184 | 187 | |
@@ -195,12 +198,15 @@ discard block |
||
| 195 | 198 | foreach ($rules as $rule) { |
| 196 | 199 | if (Any::isArray($rule[0])) { // 2 or more rules [['field1', 'field2'], 'filter', 'filter_argv'] |
| 197 | 200 | foreach ($rule[0] as $tfield) { |
| 198 | - if ($tfield == $field) |
|
| 199 | - $response[$rule[1]] = $rule[2]; // ['min_length' => 1, 'required' => null] |
|
| 201 | + if ($tfield == $field) { |
|
| 202 | + $response[$rule[1]] = $rule[2]; |
|
| 203 | + } |
|
| 204 | + // ['min_length' => 1, 'required' => null] |
|
| 200 | 205 | } |
| 201 | 206 | } else { // 1 rule ['field1', 'filter', 'filter_argv'] |
| 202 | - if ($rule[0] === $field) |
|
| 203 | - $response[$rule[1]] = $rule[2]; |
|
| 207 | + if ($rule[0] === $field) { |
|
| 208 | + $response[$rule[1]] = $rule[2]; |
|
| 209 | + } |
|
| 204 | 210 | } |
| 205 | 211 | } |
| 206 | 212 | |
@@ -249,7 +249,7 @@ |
||
| 249 | 249 | /** |
| 250 | 250 | * Show custom code library link |
| 251 | 251 | * @param string $type - js or css allowed |
| 252 | - * @return array|null|string |
|
| 252 | + * @return null|string |
|
| 253 | 253 | */ |
| 254 | 254 | public function showCodeLink(string $type) |
| 255 | 255 | { |
@@ -9,7 +9,6 @@ |
||
| 9 | 9 | use Ffcms\Core\Helper\FileSystem\File; |
| 10 | 10 | use Ffcms\Core\Helper\FileSystem\Normalize; |
| 11 | 11 | use Ffcms\Core\Helper\Type\Any; |
| 12 | -use Ffcms\Core\Helper\Type\Obj; |
|
| 13 | 12 | use Ffcms\Core\Helper\Type\Str; |
| 14 | 13 | use Ffcms\Core\Template\Variables; |
| 15 | 14 | use Ffcms\Core\Traits\DynamicGlobal; |
@@ -55,16 +55,16 @@ discard block |
||
| 55 | 55 | $this->lang = App::$Request->getLanguage(); |
| 56 | 56 | // get theme config and build full path |
| 57 | 57 | $themeConfig = App::$Properties->get('theme'); |
| 58 | - $this->themePath = root . DIRECTORY_SEPARATOR . 'Apps' . DIRECTORY_SEPARATOR . 'View' . DIRECTORY_SEPARATOR . env_name; |
|
| 58 | + $this->themePath = root.DIRECTORY_SEPARATOR.'Apps'.DIRECTORY_SEPARATOR.'View'.DIRECTORY_SEPARATOR.env_name; |
|
| 59 | 59 | if (isset($themeConfig[env_name]) && Str::length($themeConfig[env_name]) > 0) { |
| 60 | - $this->themePath .= DIRECTORY_SEPARATOR . $themeConfig[env_name]; |
|
| 60 | + $this->themePath .= DIRECTORY_SEPARATOR.$themeConfig[env_name]; |
|
| 61 | 61 | } else { |
| 62 | - $this->themePath .= DIRECTORY_SEPARATOR . 'default'; |
|
| 62 | + $this->themePath .= DIRECTORY_SEPARATOR.'default'; |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | // check if theme is available |
| 66 | 66 | if (!Directory::exist($this->themePath)) |
| 67 | - throw new NativeException('Apps theme is not founded: ' . Str::replace(root, null, $this->themePath)); |
|
| 67 | + throw new NativeException('Apps theme is not founded: '.Str::replace(root, null, $this->themePath)); |
|
| 68 | 68 | |
| 69 | 69 | // get input args and build class properties |
| 70 | 70 | $args = func_get_args(); |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | |
| 103 | 103 | // path still not defined? |
| 104 | 104 | if (!$path) |
| 105 | - throw new SyntaxException('View not found: ' . App::$Security->strip_tags($path)); |
|
| 105 | + throw new SyntaxException('View not found: '.App::$Security->strip_tags($path)); |
|
| 106 | 106 | |
| 107 | 107 | // cleanup from slashes on start/end |
| 108 | 108 | $path = trim($path, '/\\'); |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | // lets try to get full path for current theme |
| 131 | 131 | $tmpPath = $path; |
| 132 | 132 | if (!Str::startsWith($this->themePath, $path)) |
| 133 | - $tmpPath = Normalize::diskPath($this->themePath . '/' . $path . '.php'); |
|
| 133 | + $tmpPath = Normalize::diskPath($this->themePath.'/'.$path.'.php'); |
|
| 134 | 134 | } else { // sounds like a object-depended view call from controller or etc |
| 135 | 135 | // get stack trace of callbacks |
| 136 | 136 | $calledLog = debug_backtrace(); |
@@ -144,13 +144,13 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | // depended controller is not founded? Let finish |
| 146 | 146 | if (!$calledController) |
| 147 | - throw new SyntaxException('View render is failed: callback controller not founded! Call with relative path: ' . $path); |
|
| 147 | + throw new SyntaxException('View render is failed: callback controller not founded! Call with relative path: '.$path); |
|
| 148 | 148 | |
| 149 | 149 | // get controller name |
| 150 | - $controllerName = Str::sub($calledController, Str::length('Apps\Controller\\' . env_name . '\\')); |
|
| 150 | + $controllerName = Str::sub($calledController, Str::length('Apps\Controller\\'.env_name.'\\')); |
|
| 151 | 151 | $controllerName = Str::lowerCase($controllerName); |
| 152 | 152 | // get full path |
| 153 | - $tmpPath = $this->themePath . DIRECTORY_SEPARATOR . $controllerName . DIRECTORY_SEPARATOR . $path . '.php'; |
|
| 153 | + $tmpPath = $this->themePath.DIRECTORY_SEPARATOR.$controllerName.DIRECTORY_SEPARATOR.$path.'.php'; |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | // check if builded view full path is exist |
@@ -159,18 +159,18 @@ discard block |
||
| 159 | 159 | |
| 160 | 160 | // hmm, not founded. Lets try to find in caller directory (for widgets, apps packages and other) |
| 161 | 161 | if ($source !== null) { |
| 162 | - $tmpPath = Normalize::diskPath($source . DIRECTORY_SEPARATOR . $path . '.php'); |
|
| 162 | + $tmpPath = Normalize::diskPath($source.DIRECTORY_SEPARATOR.$path.'.php'); |
|
| 163 | 163 | if (File::exist($tmpPath)) { |
| 164 | 164 | // add notify for native views |
| 165 | 165 | if (App::$Debug) |
| 166 | - App::$Debug->addMessage('Render native viewer: ' . Str::replace(root, null, $tmpPath), 'info'); |
|
| 166 | + App::$Debug->addMessage('Render native viewer: '.Str::replace(root, null, $tmpPath), 'info'); |
|
| 167 | 167 | |
| 168 | 168 | return $tmpPath; |
| 169 | 169 | } |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | if (App::$Debug) |
| 173 | - App::$Debug->addMessage('Viewer not founded on rendering: ' . $path, 'warning'); |
|
| 173 | + App::$Debug->addMessage('Viewer not founded on rendering: '.$path, 'warning'); |
|
| 174 | 174 | |
| 175 | 175 | return null; |
| 176 | 176 | } |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | foreach ($items as $item) { |
| 263 | 263 | $item = trim($item, '/'); |
| 264 | 264 | if (!Str::startsWith(App::$Alias->scriptUrl, $item) && !Str::startsWith('http', $item)) { // is local without proto and domain |
| 265 | - $item = App::$Alias->scriptUrl . '/' . $item; |
|
| 265 | + $item = App::$Alias->scriptUrl.'/'.$item; |
|
| 266 | 266 | } |
| 267 | 267 | $output[] = $item; |
| 268 | 268 | } |
@@ -271,9 +271,9 @@ discard block |
||
| 271 | 271 | $output = null; |
| 272 | 272 | foreach ($clear as $row) { |
| 273 | 273 | if ($type === 'css') { |
| 274 | - $output .= '<link rel="stylesheet" type="text/css" href="' . $row . '">' . "\n"; |
|
| 274 | + $output .= '<link rel="stylesheet" type="text/css" href="'.$row.'">'."\n"; |
|
| 275 | 275 | } elseif ($type === 'js') { |
| 276 | - $output .= '<script src="' . $row . '"></script>' . "\n"; |
|
| 276 | + $output .= '<script src="'.$row.'"></script>'."\n"; |
|
| 277 | 277 | } |
| 278 | 278 | } |
| 279 | 279 | |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | |
| 296 | 296 | $code = null; |
| 297 | 297 | foreach (App::$Alias->getPlainCode($type) as $row) { |
| 298 | - $code .= $row . "\n"; |
|
| 298 | + $code .= $row."\n"; |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | return $code; |
@@ -63,8 +63,9 @@ discard block |
||
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | // check if theme is available |
| 66 | - if (!Directory::exist($this->themePath)) |
|
| 67 | - throw new NativeException('Apps theme is not founded: ' . Str::replace(root, null, $this->themePath)); |
|
| 66 | + if (!Directory::exist($this->themePath)) { |
|
| 67 | + throw new NativeException('Apps theme is not founded: ' . Str::replace(root, null, $this->themePath)); |
|
| 68 | + } |
|
| 68 | 69 | |
| 69 | 70 | // get input args and build class properties |
| 70 | 71 | $args = func_get_args(); |
@@ -89,20 +90,24 @@ discard block |
||
| 89 | 90 | $source = $this->sourcePath; |
| 90 | 91 | |
| 91 | 92 | // if path is not defined - try to find it in arguments |
| 92 | - if (!$path) |
|
| 93 | - $path = array_shift($arguments); |
|
| 93 | + if (!$path) { |
|
| 94 | + $path = array_shift($arguments); |
|
| 95 | + } |
|
| 94 | 96 | |
| 95 | 97 | // if arguments is not define - try to find in arguments |
| 96 | - if (!$params) |
|
| 97 | - $params = array_shift($arguments); |
|
| 98 | + if (!$params) { |
|
| 99 | + $params = array_shift($arguments); |
|
| 100 | + } |
|
| 98 | 101 | |
| 99 | 102 | // if directory of caller is not defiend - lets find in argument |
| 100 | - if (!$source) |
|
| 101 | - $source = array_shift($arguments); |
|
| 103 | + if (!$source) { |
|
| 104 | + $source = array_shift($arguments); |
|
| 105 | + } |
|
| 102 | 106 | |
| 103 | 107 | // path still not defined? |
| 104 | - if (!$path) |
|
| 105 | - throw new SyntaxException('View not found: ' . App::$Security->strip_tags($path)); |
|
| 108 | + if (!$path) { |
|
| 109 | + throw new SyntaxException('View not found: ' . App::$Security->strip_tags($path)); |
|
| 110 | + } |
|
| 106 | 111 | |
| 107 | 112 | // cleanup from slashes on start/end |
| 108 | 113 | $path = trim($path, '/\\'); |
@@ -129,8 +134,9 @@ discard block |
||
| 129 | 134 | if (Str::contains('/', $path)) { |
| 130 | 135 | // lets try to get full path for current theme |
| 131 | 136 | $tmpPath = $path; |
| 132 | - if (!Str::startsWith($this->themePath, $path)) |
|
| 133 | - $tmpPath = Normalize::diskPath($this->themePath . '/' . $path . '.php'); |
|
| 137 | + if (!Str::startsWith($this->themePath, $path)) { |
|
| 138 | + $tmpPath = Normalize::diskPath($this->themePath . '/' . $path . '.php'); |
|
| 139 | + } |
|
| 134 | 140 | } else { // sounds like a object-depended view call from controller or etc |
| 135 | 141 | // get stack trace of callbacks |
| 136 | 142 | $calledLog = debug_backtrace(); |
@@ -138,13 +144,15 @@ discard block |
||
| 138 | 144 | |
| 139 | 145 | // lets try to find controller in backtrace |
| 140 | 146 | foreach ($calledLog as $caller) { |
| 141 | - if (isset($caller['class']) && Str::startsWith('Apps\Controller\\', $caller['class'])) |
|
| 142 | - $calledController = (string)$caller['class']; |
|
| 147 | + if (isset($caller['class']) && Str::startsWith('Apps\Controller\\', $caller['class'])) { |
|
| 148 | + $calledController = (string)$caller['class']; |
|
| 149 | + } |
|
| 143 | 150 | } |
| 144 | 151 | |
| 145 | 152 | // depended controller is not founded? Let finish |
| 146 | - if (!$calledController) |
|
| 147 | - throw new SyntaxException('View render is failed: callback controller not founded! Call with relative path: ' . $path); |
|
| 153 | + if (!$calledController) { |
|
| 154 | + throw new SyntaxException('View render is failed: callback controller not founded! Call with relative path: ' . $path); |
|
| 155 | + } |
|
| 148 | 156 | |
| 149 | 157 | // get controller name |
| 150 | 158 | $controllerName = Str::sub($calledController, Str::length('Apps\Controller\\' . env_name . '\\')); |
@@ -154,23 +162,26 @@ discard block |
||
| 154 | 162 | } |
| 155 | 163 | |
| 156 | 164 | // check if builded view full path is exist |
| 157 | - if (File::exist($tmpPath)) |
|
| 158 | - return $tmpPath; |
|
| 165 | + if (File::exist($tmpPath)) { |
|
| 166 | + return $tmpPath; |
|
| 167 | + } |
|
| 159 | 168 | |
| 160 | 169 | // hmm, not founded. Lets try to find in caller directory (for widgets, apps packages and other) |
| 161 | 170 | if ($source !== null) { |
| 162 | 171 | $tmpPath = Normalize::diskPath($source . DIRECTORY_SEPARATOR . $path . '.php'); |
| 163 | 172 | if (File::exist($tmpPath)) { |
| 164 | 173 | // add notify for native views |
| 165 | - if (App::$Debug) |
|
| 166 | - App::$Debug->addMessage('Render native viewer: ' . Str::replace(root, null, $tmpPath), 'info'); |
|
| 174 | + if (App::$Debug) { |
|
| 175 | + App::$Debug->addMessage('Render native viewer: ' . Str::replace(root, null, $tmpPath), 'info'); |
|
| 176 | + } |
|
| 167 | 177 | |
| 168 | 178 | return $tmpPath; |
| 169 | 179 | } |
| 170 | 180 | } |
| 171 | 181 | |
| 172 | - if (App::$Debug) |
|
| 173 | - App::$Debug->addMessage('Viewer not founded on rendering: ' . $path, 'warning'); |
|
| 182 | + if (App::$Debug) { |
|
| 183 | + App::$Debug->addMessage('Viewer not founded on rendering: ' . $path, 'warning'); |
|
| 184 | + } |
|
| 174 | 185 | |
| 175 | 186 | return null; |
| 176 | 187 | } |
@@ -193,8 +204,9 @@ discard block |
||
| 193 | 204 | */ |
| 194 | 205 | protected function renderSandbox($path, $params = null) |
| 195 | 206 | { |
| 196 | - if (!$path || !File::exist($path)) |
|
| 197 | - return null; |
|
| 207 | + if (!$path || !File::exist($path)) { |
|
| 208 | + return null; |
|
| 209 | + } |
|
| 198 | 210 | |
| 199 | 211 | // render defaults params as variables |
| 200 | 212 | if (Any::isArray($params) && count($params) > 0) { |
@@ -218,8 +230,9 @@ discard block |
||
| 218 | 230 | ob_end_clean(); |
| 219 | 231 | // prepare output message |
| 220 | 232 | $msg = $e->getMessage(); |
| 221 | - if (!Str::likeEmpty($msg)) |
|
| 222 | - $msg .= '. '; |
|
| 233 | + if (!Str::likeEmpty($msg)) { |
|
| 234 | + $msg .= '. '; |
|
| 235 | + } |
|
| 223 | 236 | |
| 224 | 237 | $msg .= __('Native exception catched in view: %path% in line %line%', ['path' => $path, 'line' => $e->getLine()]); |
| 225 | 238 | exit($e->display($msg)); |
@@ -255,8 +268,9 @@ discard block |
||
| 255 | 268 | { |
| 256 | 269 | $items = App::$Alias->getCustomLibraryArray($type); |
| 257 | 270 | // check if custom library available |
| 258 | - if (!$items || !Any::isArray($items) || count($items) < 1) |
|
| 259 | - return null; |
|
| 271 | + if (!$items || !Any::isArray($items) || count($items) < 1) { |
|
| 272 | + return null; |
|
| 273 | + } |
|
| 260 | 274 | |
| 261 | 275 | $output = []; |
| 262 | 276 | foreach ($items as $item) { |
@@ -290,8 +304,9 @@ discard block |
||
| 290 | 304 | */ |
| 291 | 305 | public function showPlainCode(?string $type = null): ?string |
| 292 | 306 | { |
| 293 | - if (!App::$Alias->getPlainCode($type) || !Any::isArray(App::$Alias->getPlainCode($type))) |
|
| 294 | - return null; |
|
| 307 | + if (!App::$Alias->getPlainCode($type) || !Any::isArray(App::$Alias->getPlainCode($type))) { |
|
| 308 | + return null; |
|
| 309 | + } |
|
| 295 | 310 | |
| 296 | 311 | $code = null; |
| 297 | 312 | foreach (App::$Alias->getPlainCode($type) as $row) { |
@@ -4,7 +4,6 @@ |
||
| 4 | 4 | |
| 5 | 5 | use Apps\ActiveRecord\App as AppRecord; |
| 6 | 6 | use Ffcms\Core\Helper\Type\Any; |
| 7 | -use Ffcms\Core\Helper\Type\Obj; |
|
| 8 | 7 | use Ffcms\Core\Helper\Type\Str; |
| 9 | 8 | use Ffcms\Core\Interfaces\iWidget; |
| 10 | 9 | use Ffcms\Core\Traits\DynamicGlobal; |
@@ -33,8 +33,9 @@ |
||
| 33 | 33 | $object = new self::$class; |
| 34 | 34 | if (Any::isArray($params) && count($params) > 0) { |
| 35 | 35 | foreach ($params as $property => $value) { |
| 36 | - if (property_exists($object, $property)) |
|
| 37 | - $object->{$property} = $value; |
|
| 36 | + if (property_exists($object, $property)) { |
|
| 37 | + $object->{$property} = $value; |
|
| 38 | + } |
|
| 38 | 39 | } |
| 39 | 40 | } |
| 40 | 41 | |
@@ -8,7 +8,6 @@ |
||
| 8 | 8 | use DebugBar\StandardDebugBar; |
| 9 | 9 | use Ffcms\Core\App; |
| 10 | 10 | use Ffcms\Core\Helper\Type\Any; |
| 11 | -use Ffcms\Core\Helper\Type\Obj; |
|
| 12 | 11 | |
| 13 | 12 | /** |
| 14 | 13 | * Class Debug. Provide methods of display information about debug and collected data in debug bar |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | $this->render = $this->bar->getJavascriptRenderer(); |
| 30 | 30 | try { |
| 31 | 31 | $this->bar->addCollector(new ConfigCollector()); |
| 32 | - } catch (\Exception $oe){} |
|
| 32 | + } catch (\Exception $oe) {} |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | /** |
@@ -80,8 +80,9 @@ |
||
| 80 | 80 | */ |
| 81 | 81 | public function addMessage($m, $type = 'info') |
| 82 | 82 | { |
| 83 | - if (!Any::isStr($m) || !Any::isStr($type)) |
|
| 84 | - return; |
|
| 83 | + if (!Any::isStr($m) || !Any::isStr($type)) { |
|
| 84 | + return; |
|
| 85 | + } |
|
| 85 | 86 | |
| 86 | 87 | $m = App::$Security->secureHtml($m); |
| 87 | 88 | try { |
@@ -7,7 +7,6 @@ |
||
| 7 | 7 | use Ffcms\Core\Helper\HTML\System\NativeGenerator; |
| 8 | 8 | use Ffcms\Core\Helper\Type\Any; |
| 9 | 9 | use Ffcms\Core\Helper\Type\Arr; |
| 10 | -use Ffcms\Core\Helper\Type\Obj; |
|
| 11 | 10 | use Ffcms\Core\Helper\Type\Str; |
| 12 | 11 | |
| 13 | 12 | class Nav extends NativeGenerator |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | } elseif ($item['type'] === 'tab') { |
| 60 | 60 | $activeObject = false; |
| 61 | 61 | $item['type'] = 'link'; // fix for global Listing builder |
| 62 | - $item['link'] = '#' . $elements['tabAnchor'] . $tabIdx; |
|
| 62 | + $item['link'] = '#'.$elements['tabAnchor'].$tabIdx; |
|
| 63 | 63 | |
| 64 | 64 | $item['property']['role'] = 'presentation'; |
| 65 | 65 | |
@@ -74,10 +74,10 @@ discard block |
||
| 74 | 74 | |
| 75 | 75 | // mark active tab |
| 76 | 76 | if ($activeObject === true) |
| 77 | - $item['property']['class'] .= (Str::length($item['property']['class']) > 0 ? ' ' : null) . 'active'; |
|
| 77 | + $item['property']['class'] .= (Str::length($item['property']['class']) > 0 ? ' ' : null).'active'; |
|
| 78 | 78 | |
| 79 | 79 | // tab special properties for bootstrap |
| 80 | - $item['linkProperty']['aria-controls'] = $elements['tabAnchor'] . $tabIdx; |
|
| 80 | + $item['linkProperty']['aria-controls'] = $elements['tabAnchor'].$tabIdx; |
|
| 81 | 81 | $item['linkProperty']['role'] = 'tab'; |
| 82 | 82 | $item['linkProperty']['data-toggle'] = 'tab'; |
| 83 | 83 | |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | } else { |
| 97 | 97 | return self::nohtml($itemContent); |
| 98 | 98 | } |
| 99 | - }, ['role' => 'tabpanel', 'class' => 'tab-pane fade' . ($activeObject === true ? ' in active' : null), 'id' => $elements['tabAnchor'] . $tabIdx]); |
|
| 99 | + }, ['role' => 'tabpanel', 'class' => 'tab-pane fade'.($activeObject === true ? ' in active' : null), 'id' => $elements['tabAnchor'].$tabIdx]); |
|
| 100 | 100 | $tabIdx++; |
| 101 | 101 | } |
| 102 | 102 | } |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | // check if global class "nav" isset |
| 105 | 105 | if ($elements['property']['class'] !== null) { |
| 106 | 106 | if (!Str::contains('nav ', $elements['property']['class'])) { |
| 107 | - $elements['property']['class'] = 'nav ' . $elements['property']['class']; |
|
| 107 | + $elements['property']['class'] = 'nav '.$elements['property']['class']; |
|
| 108 | 108 | } |
| 109 | 109 | } else { |
| 110 | 110 | $elements['property']['class'] = 'nav'; |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | return $tabContent; |
| 129 | 129 | }, $elements['tabProperty']); |
| 130 | 130 | } |
| 131 | - return $listing . $tabContent; |
|
| 131 | + return $listing.$tabContent; |
|
| 132 | 132 | }, $blockProperty); |
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | \ No newline at end of file |
@@ -20,18 +20,21 @@ discard block |
||
| 20 | 20 | public static function display(array $elements): ?string |
| 21 | 21 | { |
| 22 | 22 | // check if elements isn't empty and contains rows |
| 23 | - if (!isset($elements['items']) || count($elements['items']) < 1) |
|
| 24 | - return null; |
|
| 23 | + if (!isset($elements['items']) || count($elements['items']) < 1) { |
|
| 24 | + return null; |
|
| 25 | + } |
|
| 25 | 26 | |
| 26 | 27 | // prepare tab order |
| 27 | - if ($elements['tabAnchor'] === null) |
|
| 28 | - $elements['tabAnchor'] = Str::randomLatin(mt_rand(6, 12)); |
|
| 28 | + if ($elements['tabAnchor'] === null) { |
|
| 29 | + $elements['tabAnchor'] = Str::randomLatin(mt_rand(6, 12)); |
|
| 30 | + } |
|
| 29 | 31 | |
| 30 | 32 | // set global element properties |
| 31 | 33 | $blockProperty = []; |
| 32 | 34 | if ($elements['blockProperty'] !== null) { |
| 33 | - if (Any::isArray($elements['blockProperty'])) |
|
| 34 | - $blockProperty = $elements['blockProperty']; |
|
| 35 | + if (Any::isArray($elements['blockProperty'])) { |
|
| 36 | + $blockProperty = $elements['blockProperty']; |
|
| 37 | + } |
|
| 35 | 38 | unset($elements['blockProperty']); |
| 36 | 39 | } |
| 37 | 40 | |
@@ -73,8 +76,9 @@ discard block |
||
| 73 | 76 | } |
| 74 | 77 | |
| 75 | 78 | // mark active tab |
| 76 | - if ($activeObject === true) |
|
| 77 | - $item['property']['class'] .= (Str::length($item['property']['class']) > 0 ? ' ' : null) . 'active'; |
|
| 79 | + if ($activeObject === true) { |
|
| 80 | + $item['property']['class'] .= (Str::length($item['property']['class']) > 0 ? ' ' : null) . 'active'; |
|
| 81 | + } |
|
| 78 | 82 | |
| 79 | 83 | // tab special properties for bootstrap |
| 80 | 84 | $item['linkProperty']['aria-controls'] = $elements['tabAnchor'] . $tabIdx; |
@@ -4,14 +4,12 @@ |
||
| 4 | 4 | |
| 5 | 5 | use Ffcms\Core\App; |
| 6 | 6 | use Ffcms\Core\Arch\Model; |
| 7 | -use Ffcms\Core\Exception\NativeException; |
|
| 8 | 7 | use Ffcms\Core\Exception\SyntaxException; |
| 9 | 8 | use Ffcms\Core\Helper\FileSystem\File; |
| 10 | 9 | use Ffcms\Core\Helper\HTML\Form\Constructor; |
| 11 | 10 | use Ffcms\Core\Helper\HTML\System\NativeGenerator; |
| 12 | 11 | use Ffcms\Core\Helper\Type\Any; |
| 13 | 12 | use Ffcms\Core\Helper\Type\Arr; |
| 14 | -use Ffcms\Core\Helper\Type\Obj; |
|
| 15 | 13 | use Ffcms\Core\Helper\Type\Str; |
| 16 | 14 | |
| 17 | 15 | /** |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | { |
| 80 | 80 | $form = self::buildSingleTag('form', $this->formProperty, false); |
| 81 | 81 | if ($this->model->_tokenRequired) { |
| 82 | - $form .= PHP_EOL . $this->field('_csrf_token', 'hidden', ['value' => $this->model->_csrf_token]); |
|
| 82 | + $form .= PHP_EOL.$this->field('_csrf_token', 'hidden', ['value' => $this->model->_csrf_token]); |
|
| 83 | 83 | } |
| 84 | 84 | return $form; |
| 85 | 85 | } |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | { |
| 98 | 98 | if ($this->model === null) { |
| 99 | 99 | if (App::$Debug) |
| 100 | - App::$Debug->addMessage('Form model is not defined for field name: [' . strip_tags($object) . ']'); |
|
| 100 | + App::$Debug->addMessage('Form model is not defined for field name: ['.strip_tags($object).']'); |
|
| 101 | 101 | |
| 102 | 102 | return null; |
| 103 | 103 | } |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | // check if model contains current tag name as property |
| 111 | 111 | if (!property_exists($this->model, $propertyName)) { |
| 112 | 112 | if (App::$Debug) |
| 113 | - App::$Debug->addMessage('Form field ["' . $object . '"] is not defined in model: [' . get_class($this->model) . ']', 'error'); |
|
| 113 | + App::$Debug->addMessage('Form field ["'.$object.'"] is not defined in model: ['.get_class($this->model).']', 'error'); |
|
| 114 | 114 | |
| 115 | 115 | return null; |
| 116 | 116 | } |
@@ -131,13 +131,13 @@ discard block |
||
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | // prepare labels text and label "for" attr |
| 134 | - $labelFor = $this->name . '-' . $propertyName; |
|
| 134 | + $labelFor = $this->name.'-'.$propertyName; |
|
| 135 | 135 | $labelText = $this->model->getLabel($object); |
| 136 | 136 | $itemValue = $this->model->{$propertyName}; |
| 137 | 137 | // sounds like a dot-separated $object |
| 138 | 138 | if ($propertyName !== $object) { |
| 139 | 139 | $nesting = trim(strstr($object, '.'), '.'); |
| 140 | - $labelFor .= '-' . Str::replace('.', '-', $nesting); |
|
| 140 | + $labelFor .= '-'.Str::replace('.', '-', $nesting); |
|
| 141 | 141 | $itemValue = Arr::getByPath($nesting, $itemValue); |
| 142 | 142 | } |
| 143 | 143 | |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | public function submitButton($title, array $property = []) |
| 179 | 179 | { |
| 180 | 180 | $property['type'] = 'submit'; |
| 181 | - $property['name'] = $this->name . '[submit]'; |
|
| 181 | + $property['name'] = $this->name.'[submit]'; |
|
| 182 | 182 | $property['value'] = $title; |
| 183 | 183 | return self::buildSingleTag('input', $property); |
| 184 | 184 | } |
@@ -192,10 +192,10 @@ discard block |
||
| 192 | 192 | { |
| 193 | 193 | // pre-validate form fields based on model rules and jquery.validation |
| 194 | 194 | if ($validate) { |
| 195 | - App::$Alias->addPlainCode('js', '$().ready(function() { $("#' . $this->name . '").validate(); });'); |
|
| 195 | + App::$Alias->addPlainCode('js', '$().ready(function() { $("#'.$this->name.'").validate(); });'); |
|
| 196 | 196 | App::$Alias->setCustomLibrary('js', '/vendor/bower/jquery-validation/dist/jquery.validate.min.js'); |
| 197 | 197 | if (App::$Request->getLanguage() !== 'en') { |
| 198 | - $localeFile = '/vendor/bower/jquery-validation/src/localization/messages_' . App::$Request->getLanguage() . '.js'; |
|
| 198 | + $localeFile = '/vendor/bower/jquery-validation/src/localization/messages_'.App::$Request->getLanguage().'.js'; |
|
| 199 | 199 | if (File::exist($localeFile)) { |
| 200 | 200 | App::$Alias->setCustomLibrary('js', $localeFile); |
| 201 | 201 | } |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | $formName = $this->model->getFormName(); |
| 207 | 207 | if (Any::isArray($badAttr) && count($badAttr) > 0) { |
| 208 | 208 | foreach ($badAttr as $attr) { |
| 209 | - $itemId = $formName . '-' . $attr; |
|
| 209 | + $itemId = $formName.'-'.$attr; |
|
| 210 | 210 | try { |
| 211 | 211 | $render = App::$View->render(static::$structLayer['jsnotify'], ['itemId' => $itemId]); |
| 212 | 212 | App::$Alias->addPlainCode('js', $render); |
@@ -46,8 +46,9 @@ discard block |
||
| 46 | 46 | public function __construct($model, array $property = null, array $layerFiles = null) |
| 47 | 47 | { |
| 48 | 48 | // prevent white-screen locks when model is not passed or passed wrong |
| 49 | - if (!$model instanceof Model) |
|
| 50 | - throw new SyntaxException('Bad model type passed in form builder. Check for init: new Form()'); |
|
| 49 | + if (!$model instanceof Model) { |
|
| 50 | + throw new SyntaxException('Bad model type passed in form builder. Check for init: new Form()'); |
|
| 51 | + } |
|
| 51 | 52 | |
| 52 | 53 | $this->model = $model; |
| 53 | 54 | $this->name = $model->getFormName(); |
@@ -55,8 +56,9 @@ discard block |
||
| 55 | 56 | // check if passed custom layer file |
| 56 | 57 | if (Any::isArray($layerFiles) && count($layerFiles) > 0) { |
| 57 | 58 | foreach (array_keys(static::$structLayer) as $type) { |
| 58 | - if (isset($layerFiles[$type]) && Any::isStr($layerFiles[$type])) |
|
| 59 | - static::$structLayer[$type] = $layerFiles[$type]; |
|
| 59 | + if (isset($layerFiles[$type]) && Any::isStr($layerFiles[$type])) { |
|
| 60 | + static::$structLayer[$type] = $layerFiles[$type]; |
|
| 61 | + } |
|
| 60 | 62 | } |
| 61 | 63 | } |
| 62 | 64 | // set model submit method |
@@ -64,8 +66,9 @@ discard block |
||
| 64 | 66 | |
| 65 | 67 | $property['id'] = $this->name; // define form id |
| 66 | 68 | // if action is not defined - define it |
| 67 | - if (!$property['action']) |
|
| 68 | - $property['action'] = App::$Request->getFullUrl(); |
|
| 69 | + if (!$property['action']) { |
|
| 70 | + $property['action'] = App::$Request->getFullUrl(); |
|
| 71 | + } |
|
| 69 | 72 | |
| 70 | 73 | // set property global for this form |
| 71 | 74 | $this->formProperty = $property; |
@@ -96,21 +99,24 @@ discard block |
||
| 96 | 99 | public function field(string $object, string $type, ?array $property = null, ?string $helper = null, ?string $layerFile = null) |
| 97 | 100 | { |
| 98 | 101 | if ($this->model === null) { |
| 99 | - if (App::$Debug) |
|
| 100 | - App::$Debug->addMessage('Form model is not defined for field name: [' . strip_tags($object) . ']'); |
|
| 102 | + if (App::$Debug) { |
|
| 103 | + App::$Debug->addMessage('Form model is not defined for field name: [' . strip_tags($object) . ']'); |
|
| 104 | + } |
|
| 101 | 105 | |
| 102 | 106 | return null; |
| 103 | 107 | } |
| 104 | 108 | |
| 105 | 109 | // can be dots separated object |
| 106 | 110 | $propertyName = $object; |
| 107 | - if (Str::contains('.', $propertyName)) |
|
| 108 | - $propertyName = strstr($propertyName, '.', true); |
|
| 111 | + if (Str::contains('.', $propertyName)) { |
|
| 112 | + $propertyName = strstr($propertyName, '.', true); |
|
| 113 | + } |
|
| 109 | 114 | |
| 110 | 115 | // check if model contains current tag name as property |
| 111 | 116 | if (!property_exists($this->model, $propertyName)) { |
| 112 | - if (App::$Debug) |
|
| 113 | - App::$Debug->addMessage('Form field ["' . $object . '"] is not defined in model: [' . get_class($this->model) . ']', 'error'); |
|
| 117 | + if (App::$Debug) { |
|
| 118 | + App::$Debug->addMessage('Form field ["' . $object . '"] is not defined in model: [' . get_class($this->model) . ']', 'error'); |
|
| 119 | + } |
|
| 114 | 120 | |
| 115 | 121 | return null; |
| 116 | 122 | } |
@@ -159,8 +165,9 @@ discard block |
||
| 159 | 165 | 'help' => self::nohtml($helper) |
| 160 | 166 | ]); |
| 161 | 167 | } catch (SyntaxException $e) { |
| 162 | - if (App::$Debug) |
|
| 163 | - App::$Debug->addException($e); |
|
| 168 | + if (App::$Debug) { |
|
| 169 | + App::$Debug->addException($e); |
|
| 170 | + } |
|
| 164 | 171 | |
| 165 | 172 | $response = null; |
| 166 | 173 | } |
@@ -211,8 +218,9 @@ discard block |
||
| 211 | 218 | $render = App::$View->render(static::$structLayer['jsnotify'], ['itemId' => $itemId]); |
| 212 | 219 | App::$Alias->addPlainCode('js', $render); |
| 213 | 220 | } catch (SyntaxException $e) { |
| 214 | - if (App::$Debug) |
|
| 215 | - App::$Debug->addException($e); |
|
| 221 | + if (App::$Debug) { |
|
| 222 | + App::$Debug->addException($e); |
|
| 223 | + } |
|
| 216 | 224 | } |
| 217 | 225 | } |
| 218 | 226 | } |
@@ -48,7 +48,7 @@ |
||
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
| 51 | - * @param string|array $name |
|
| 51 | + * @param string $name |
|
| 52 | 52 | * @param string|array|null $value |
| 53 | 53 | * @param array|null $properties |
| 54 | 54 | * @return null|string |
@@ -4,9 +4,7 @@ |
||
| 4 | 4 | |
| 5 | 5 | use Ffcms\Core\App; |
| 6 | 6 | use Ffcms\Core\Arch\Model; |
| 7 | -use Ffcms\Core\Exception\SyntaxException; |
|
| 8 | 7 | use Ffcms\Core\Helper\Type\Any; |
| 9 | -use Ffcms\Core\Helper\Type\Obj; |
|
| 10 | 8 | use Ffcms\Core\Helper\Type\Str; |
| 11 | 9 | |
| 12 | 10 | /** |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | break; |
| 108 | 108 | default: |
| 109 | 109 | if (App::$Debug) |
| 110 | - App::$Debug->addMessage('Field has unknown type: ' . App::$Security->strip_tags($name)); |
|
| 110 | + App::$Debug->addMessage('Field has unknown type: '.App::$Security->strip_tags($name)); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | return $builder->make(); |
@@ -157,12 +157,12 @@ discard block |
||
| 157 | 157 | if (Str::contains('.', $name)) { |
| 158 | 158 | $splitedName = explode('.', $name); |
| 159 | 159 | foreach ($splitedName as $nameKey) { |
| 160 | - $properties['name'] .= '[' . $nameKey . ']'; |
|
| 161 | - $properties['id'] .= '-' . $nameKey; |
|
| 160 | + $properties['name'] .= '['.$nameKey.']'; |
|
| 161 | + $properties['id'] .= '-'.$nameKey; |
|
| 162 | 162 | } |
| 163 | 163 | } else { // standard property definition - add field name |
| 164 | - $properties['name'] .= '[' . $name . ']'; |
|
| 165 | - $properties['id'] .= '-' . $name; |
|
| 164 | + $properties['name'] .= '['.$name.']'; |
|
| 165 | + $properties['id'] .= '-'.$name; |
|
| 166 | 166 | } |
| 167 | 167 | } |
| 168 | 168 | } |
| 169 | 169 | \ No newline at end of file |
@@ -56,8 +56,9 @@ discard block |
||
| 56 | 56 | public function makeTag($name, $value = null, ?array $properties = null): ?string |
| 57 | 57 | { |
| 58 | 58 | // check if properties is passed well |
| 59 | - if ($properties !== null && !Any::isArray($properties)) |
|
| 60 | - return null; |
|
| 59 | + if ($properties !== null && !Any::isArray($properties)) { |
|
| 60 | + return null; |
|
| 61 | + } |
|
| 61 | 62 | |
| 62 | 63 | // add properties to autovalidation by js (properties passed by ref) |
| 63 | 64 | $this->addValidationProperties($name, $properties); |
@@ -106,8 +107,9 @@ discard block |
||
| 106 | 107 | $builder = new RadioField($properties, $name, $value); |
| 107 | 108 | break; |
| 108 | 109 | default: |
| 109 | - if (App::$Debug) |
|
| 110 | - App::$Debug->addMessage('Field has unknown type: ' . App::$Security->strip_tags($name)); |
|
| 110 | + if (App::$Debug) { |
|
| 111 | + App::$Debug->addMessage('Field has unknown type: ' . App::$Security->strip_tags($name)); |
|
| 112 | + } |
|
| 111 | 113 | } |
| 112 | 114 | |
| 113 | 115 | return $builder->make(); |
@@ -150,8 +152,9 @@ discard block |
||
| 150 | 152 | { |
| 151 | 153 | // standard property data definition |
| 152 | 154 | $properties['name'] = $properties['id'] = $this->formName; // form global name |
| 153 | - if ($value !== null && !Any::isEmpty($value)) |
|
| 154 | - $properties['value'] = $value; |
|
| 155 | + if ($value !== null && !Any::isEmpty($value)) { |
|
| 156 | + $properties['value'] = $value; |
|
| 157 | + } |
|
| 155 | 158 | |
| 156 | 159 | // sounds like a array-path based obj name |
| 157 | 160 | if (Str::contains('.', $name)) { |
@@ -6,7 +6,6 @@ |
||
| 6 | 6 | use Ffcms\Core\Helper\HTML\System\NativeGenerator; |
| 7 | 7 | use Ffcms\Core\Helper\Type\Any; |
| 8 | 8 | use Ffcms\Core\Helper\Type\Arr; |
| 9 | -use Ffcms\Core\Helper\Type\Obj; |
|
| 10 | 9 | |
| 11 | 10 | /** |
| 12 | 11 | * Class MultiCheckboxField. Make multiple checkboxes form field |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | // check if options is defined |
| 44 | 44 | $options = $this->properties['options']; |
| 45 | 45 | if (!Any::isIterable($options)) |
| 46 | - throw new SyntaxException('Options for field ' . self::nohtml($this->name) . ' is not iterable'); |
|
| 46 | + throw new SyntaxException('Options for field '.self::nohtml($this->name).' is not iterable'); |
|
| 47 | 47 | |
| 48 | 48 | unset($this->properties['options']); |
| 49 | 49 | |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | $this->properties['value'] = $opt; |
| 65 | 65 | // apply structured checkboxes style for each item |
| 66 | 66 | $build .= App::$View->render('native/form/multi_checkboxes_list', [ |
| 67 | - 'item' => self::buildSingleTag('input', $this->properties) . self::nohtml($opt) |
|
| 67 | + 'item' => self::buildSingleTag('input', $this->properties).self::nohtml($opt) |
|
| 68 | 68 | ]); |
| 69 | 69 | } |
| 70 | 70 | |
@@ -42,8 +42,9 @@ |
||
| 42 | 42 | { |
| 43 | 43 | // check if options is defined |
| 44 | 44 | $options = $this->properties['options']; |
| 45 | - if (!Any::isIterable($options)) |
|
| 46 | - throw new SyntaxException('Options for field ' . self::nohtml($this->name) . ' is not iterable'); |
|
| 45 | + if (!Any::isIterable($options)) { |
|
| 46 | + throw new SyntaxException('Options for field ' . self::nohtml($this->name) . ' is not iterable'); |
|
| 47 | + } |
|
| 47 | 48 | |
| 48 | 49 | unset($this->properties['options']); |
| 49 | 50 | |