@@ -5,7 +5,6 @@ |
||
| 5 | 5 | use Ffcms\Core\Helper\HTML\System\NativeGenerator; |
| 6 | 6 | use Ffcms\Core\Helper\Type\Any; |
| 7 | 7 | use Ffcms\Core\Helper\Type\Arr; |
| 8 | -use Ffcms\Core\Helper\Type\Obj; |
|
| 9 | 8 | |
| 10 | 9 | class MultiSelectField extends NativeGenerator implements iField |
| 11 | 10 | { |
@@ -37,7 +37,7 @@ |
||
| 37 | 37 | $options = $this->properties['options']; |
| 38 | 38 | $optionsKey = (bool)$this->properties['optionsKey']; |
| 39 | 39 | if (!Any::isIterable($options)) |
| 40 | - throw new SyntaxException('Options for field ' . self::nohtml($this->name) . ' is not iterable'); |
|
| 40 | + throw new SyntaxException('Options for field '.self::nohtml($this->name).' is not iterable'); |
|
| 41 | 41 | |
| 42 | 42 | unset($this->properties['options']); |
| 43 | 43 | |
@@ -36,8 +36,9 @@ discard block |
||
| 36 | 36 | // check if options is defined |
| 37 | 37 | $options = $this->properties['options']; |
| 38 | 38 | $optionsKey = (bool)$this->properties['optionsKey']; |
| 39 | - if (!Any::isIterable($options)) |
|
| 40 | - throw new SyntaxException('Options for field ' . self::nohtml($this->name) . ' is not iterable'); |
|
| 39 | + if (!Any::isIterable($options)) { |
|
| 40 | + throw new SyntaxException('Options for field ' . self::nohtml($this->name) . ' is not iterable'); |
|
| 41 | + } |
|
| 41 | 42 | |
| 42 | 43 | unset($this->properties['options']); |
| 43 | 44 | |
@@ -56,11 +57,13 @@ discard block |
||
| 56 | 57 | if ($optionsKey === true) { |
| 57 | 58 | $optionProperty['value'] = $val; |
| 58 | 59 | // check if current element is active |
| 59 | - if (Any::isArray($this->value) && Arr::in((string)$val, $this->value)) |
|
| 60 | - $optionProperty['selected'] = 'selected'; |
|
| 60 | + if (Any::isArray($this->value) && Arr::in((string)$val, $this->value)) { |
|
| 61 | + $optionProperty['selected'] = 'selected'; |
|
| 62 | + } |
|
| 61 | 63 | } else { |
| 62 | - if (Any::isArray($this->value) && Arr::in((string)$text, $this->value)) |
|
| 63 | - $optionProperty['selected'] = 'selected'; |
|
| 64 | + if (Any::isArray($this->value) && Arr::in((string)$text, $this->value)) { |
|
| 65 | + $optionProperty['selected'] = 'selected'; |
|
| 66 | + } |
|
| 64 | 67 | } |
| 65 | 68 | $optionsDOM .= self::buildContainerTag('option', $optionProperty, $text); |
| 66 | 69 | } |
@@ -4,7 +4,6 @@ |
||
| 4 | 4 | |
| 5 | 5 | use Ffcms\Core\Helper\Type\Any; |
| 6 | 6 | use Ffcms\Core\Helper\Type\Arr; |
| 7 | -use Ffcms\Core\Helper\Type\Obj; |
|
| 8 | 7 | |
| 9 | 8 | /** |
| 10 | 9 | * Class SimplePagination. Build and display html pagination block |
@@ -37,17 +37,20 @@ discard block |
||
| 37 | 37 | public function display(array $property = null): ?string |
| 38 | 38 | { |
| 39 | 39 | // total items is less to pagination requirement |
| 40 | - if (($this->page * $this->step) + 1 > $this->total) |
|
| 41 | - return null; |
|
| 40 | + if (($this->page * $this->step) + 1 > $this->total) { |
|
| 41 | + return null; |
|
| 42 | + } |
|
| 42 | 43 | |
| 43 | 44 | $lastPage = ceil($this->total / $this->step); // 6/5 ~ 2 = 0..2 |
| 44 | 45 | |
| 45 | - if ($lastPage <= 1) |
|
| 46 | - return null; |
|
| 46 | + if ($lastPage <= 1) { |
|
| 47 | + return null; |
|
| 48 | + } |
|
| 47 | 49 | |
| 48 | 50 | // prevent hack-boy's any try |
| 49 | - if ($this->page > $lastPage) |
|
| 50 | - return null; |
|
| 51 | + if ($this->page > $lastPage) { |
|
| 52 | + return null; |
|
| 53 | + } |
|
| 51 | 54 | |
| 52 | 55 | $items = []; |
| 53 | 56 | // more then 10 items in pagination |
@@ -137,8 +140,9 @@ discard block |
||
| 137 | 140 | protected function generateItems($start, $end) |
| 138 | 141 | { |
| 139 | 142 | // prevent any shit's |
| 140 | - if ($end <= $start) |
|
| 141 | - return null; |
|
| 143 | + if ($end <= $start) { |
|
| 144 | + return null; |
|
| 145 | + } |
|
| 142 | 146 | |
| 143 | 147 | $items = []; |
| 144 | 148 | for ($i = $start; $i < $end; $i++) { |
@@ -4,7 +4,6 @@ |
||
| 4 | 4 | |
| 5 | 5 | use Ffcms\Core\App; |
| 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\Helper\Url; |
| 10 | 9 | |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | $purifier = App::$Memory->get('object.purifier.helpers'); |
| 25 | 25 | } else { |
| 26 | 26 | $config = \HTMLPurifier_Config::createDefault(); |
| 27 | - $config->set('Cache.SerializerPath', root . '/Private/Cache/HTMLPurifier/'); |
|
| 27 | + $config->set('Cache.SerializerPath', root.'/Private/Cache/HTMLPurifier/'); |
|
| 28 | 28 | $config->set('AutoFormat.AutoParagraph', false); |
| 29 | 29 | |
| 30 | 30 | // allow use target=_blank for links |
@@ -65,9 +65,9 @@ discard block |
||
| 65 | 65 | $build = null; |
| 66 | 66 | foreach ($property as $p => $v) { |
| 67 | 67 | if ($v === null || $v === false || $v === true) { |
| 68 | - $build .= ' ' . self::nohtml($p); |
|
| 68 | + $build .= ' '.self::nohtml($p); |
|
| 69 | 69 | } else { |
| 70 | - $build .= ' ' . self::nohtml($p) . '="' . self::nohtml($v) . '"'; |
|
| 70 | + $build .= ' '.self::nohtml($p).'="'.self::nohtml($v).'"'; |
|
| 71 | 71 | } |
| 72 | 72 | } |
| 73 | 73 | return $build; |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | public static function buildSingleTag($tagName, array $property = null, $closeSlash = true) |
| 84 | 84 | { |
| 85 | - return '<' . self::nohtml($tagName) . self::applyProperty($property) . ($closeSlash ? '/>' : '>'); |
|
| 85 | + return '<'.self::nohtml($tagName).self::applyProperty($property).($closeSlash ? '/>' : '>'); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | if ($valueHtml !== true) |
| 100 | 100 | $value = self::nohtml($value); |
| 101 | 101 | |
| 102 | - return '<' . $tagName . self::applyProperty($property) . '>' . $value . '</' . $tagName . '>'; |
|
| 102 | + return '<'.$tagName.self::applyProperty($property).'>'.$value.'</'.$tagName.'>'; |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
@@ -140,13 +140,13 @@ discard block |
||
| 140 | 140 | if (!Str::contains('/', $elementPoint) || count($elementArray) < 2) { |
| 141 | 141 | $active = $elementPoint === $currentPoint; |
| 142 | 142 | } else { |
| 143 | - $elementPoint = $elementArray[0] . '/' . $elementArray[1]; |
|
| 143 | + $elementPoint = $elementArray[0].'/'.$elementArray[1]; |
|
| 144 | 144 | $active = Str::startsWith($elementPoint, $currentPoint); |
| 145 | 145 | } |
| 146 | 146 | break; |
| 147 | 147 | case 'id': |
| 148 | 148 | $elementArray = explode('/', $elementPoint); |
| 149 | - $elementPoint = $elementArray[0] . '/' . $elementArray[1]; |
|
| 149 | + $elementPoint = $elementArray[0].'/'.$elementArray[1]; |
|
| 150 | 150 | if ($elementArray[2] === null) { // looks like id is not defined in element |
| 151 | 151 | if (Str::contains('?', $currentPoint)) { |
| 152 | 152 | $currentPoint = Str::firstIn($currentPoint, '?'); |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | $currentToId = implode('/', array_slice($currentArray, 0, 3)); |
| 156 | 156 | $active = $elementPoint === $currentToId; |
| 157 | 157 | } else { |
| 158 | - $elementPoint .= '/' . $elementArray[2]; |
|
| 158 | + $elementPoint .= '/'.$elementArray[2]; |
|
| 159 | 159 | $active = Str::startsWith($elementPoint, $currentPoint); |
| 160 | 160 | } |
| 161 | 161 | break; |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | */ |
| 211 | 211 | public static function convertLink($uri) |
| 212 | 212 | { |
| 213 | - $link = App::$Alias->baseUrl . '/'; |
|
| 213 | + $link = App::$Alias->baseUrl.'/'; |
|
| 214 | 214 | if (Any::isArray($uri)) { |
| 215 | 215 | $link .= Url::buildPathway($uri); |
| 216 | 216 | } elseif (Str::startsWith('http', $uri)) { |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | if (Str::likeEmpty($uri)) |
| 234 | 234 | return null; |
| 235 | 235 | |
| 236 | - return implode('/', array_map(function($v){ |
|
| 236 | + return implode('/', array_map(function($v) { |
|
| 237 | 237 | return urlencode($v); |
| 238 | 238 | }, explode('/', $uri))); |
| 239 | 239 | } |
@@ -59,8 +59,9 @@ discard block |
||
| 59 | 59 | */ |
| 60 | 60 | public static function applyProperty(array $property = null) |
| 61 | 61 | { |
| 62 | - if ($property === null || count($property) < 1) |
|
| 63 | - return null; |
|
| 62 | + if ($property === null || count($property) < 1) { |
|
| 63 | + return null; |
|
| 64 | + } |
|
| 64 | 65 | |
| 65 | 66 | $build = null; |
| 66 | 67 | foreach ($property as $p => $v) { |
@@ -96,8 +97,9 @@ discard block |
||
| 96 | 97 | public static function buildContainerTag($tagName, array $property = null, $value = null, $valueHtml = false) |
| 97 | 98 | { |
| 98 | 99 | $tagName = self::nohtml($tagName); |
| 99 | - if ($valueHtml !== true) |
|
| 100 | - $value = self::nohtml($value); |
|
| 100 | + if ($valueHtml !== true) { |
|
| 101 | + $value = self::nohtml($value); |
|
| 102 | + } |
|
| 101 | 103 | |
| 102 | 104 | return '<' . $tagName . self::applyProperty($property) . '>' . $value . '</' . $tagName . '>'; |
| 103 | 105 | } |
@@ -111,8 +113,9 @@ discard block |
||
| 111 | 113 | public static function safeUri($string, $encode = true) |
| 112 | 114 | { |
| 113 | 115 | $string = self::nohtml($string); |
| 114 | - if ($encode === true) |
|
| 115 | - $string = self::encode($string); |
|
| 116 | + if ($encode === true) { |
|
| 117 | + $string = self::encode($string); |
|
| 118 | + } |
|
| 116 | 119 | |
| 117 | 120 | return $string; |
| 118 | 121 | } |
@@ -230,8 +233,9 @@ discard block |
||
| 230 | 233 | */ |
| 231 | 234 | public static function encode(?string $uri = null) |
| 232 | 235 | { |
| 233 | - if (Str::likeEmpty($uri)) |
|
| 234 | - return null; |
|
| 236 | + if (Str::likeEmpty($uri)) { |
|
| 237 | + return null; |
|
| 238 | + } |
|
| 235 | 239 | |
| 236 | 240 | return implode('/', array_map(function($v){ |
| 237 | 241 | return urlencode($v); |
@@ -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 | |
| 12 | 11 | /** |
| 13 | 12 | * Class Table. Helper for drawing tables using php static call Table::display([params]) |
@@ -35,13 +35,13 @@ discard block |
||
| 35 | 35 | // init dom model |
| 36 | 36 | $dom = new Dom(); |
| 37 | 37 | // draw response |
| 38 | - $table = $dom->table(function () use ($dom, $elements, $selectOptions) { |
|
| 38 | + $table = $dom->table(function() use ($dom, $elements, $selectOptions) { |
|
| 39 | 39 | $res = null; |
| 40 | 40 | // check if thead is defined |
| 41 | 41 | if (isset($elements['thead']) && Any::isArray($elements['thead']) && count($elements['thead']) > 0 && Any::isArray($elements['thead']['titles'])) { |
| 42 | 42 | // add thead container |
| 43 | - $res .= $dom->thead(function () use ($dom, $elements, $selectOptions) { |
|
| 44 | - return $dom->tr(function () use ($dom, $elements, $selectOptions) { |
|
| 43 | + $res .= $dom->thead(function() use ($dom, $elements, $selectOptions) { |
|
| 44 | + return $dom->tr(function() use ($dom, $elements, $selectOptions) { |
|
| 45 | 45 | $tr = null; |
| 46 | 46 | foreach ($elements['thead']['titles'] as $order => $title) { |
| 47 | 47 | $th = null; |
@@ -56,12 +56,12 @@ discard block |
||
| 56 | 56 | } |
| 57 | 57 | // make global checkbox for selectable columns |
| 58 | 58 | if ($selectOptions !== false && $order + 1 === $selectOptions['attachOrder']) { |
| 59 | - $th = $dom->input(function () { |
|
| 59 | + $th = $dom->input(function() { |
|
| 60 | 60 | return null; |
| 61 | - }, ['type' => 'checkbox', 'name' => 'selectAll']) . ' ' . $th; |
|
| 61 | + }, ['type' => 'checkbox', 'name' => 'selectAll']).' '.$th; |
|
| 62 | 62 | } |
| 63 | 63 | // build tr row collecting all th's |
| 64 | - $tr .= $dom->th(function () use ($th) { |
|
| 64 | + $tr .= $dom->th(function() use ($th) { |
|
| 65 | 65 | return $th; |
| 66 | 66 | }, $title['property']); |
| 67 | 67 | } |
@@ -80,14 +80,14 @@ discard block |
||
| 80 | 80 | // sort td items inside row by key increment |
| 81 | 81 | ksort($row); |
| 82 | 82 | // add data in tr container |
| 83 | - $tr .= $dom->tr(function () use ($dom, $row, $selectOptions) { |
|
| 83 | + $tr .= $dom->tr(function() use ($dom, $row, $selectOptions) { |
|
| 84 | 84 | $td = null; |
| 85 | 85 | foreach ($row as $order => $item) { |
| 86 | 86 | if (!Any::isInt($order)) |
| 87 | 87 | continue; |
| 88 | 88 | |
| 89 | 89 | // collect td item |
| 90 | - $td .= $dom->td(function () use ($dom, $order, $item, $selectOptions) { |
|
| 90 | + $td .= $dom->td(function() use ($dom, $order, $item, $selectOptions) { |
|
| 91 | 91 | $text = null; |
| 92 | 92 | // make text secure based on passed options |
| 93 | 93 | if ($item['html'] === true) { |
@@ -101,9 +101,9 @@ discard block |
||
| 101 | 101 | } |
| 102 | 102 | // check if selectable box is enabled and equal current order id |
| 103 | 103 | if ($selectOptions !== false && $order === $selectOptions['attachOrder']) { |
| 104 | - $text = $dom->input(function (){ |
|
| 104 | + $text = $dom->input(function() { |
|
| 105 | 105 | return null; |
| 106 | - }, Arr::merge($selectOptions['selector'], ['value' => htmlentities($text, null, 'UTF-8')])) . ' ' . $text; |
|
| 106 | + }, Arr::merge($selectOptions['selector'], ['value' => htmlentities($text, null, 'UTF-8')])).' '.$text; |
|
| 107 | 107 | } |
| 108 | 108 | return $text; |
| 109 | 109 | }, $item['property']); |
@@ -126,14 +126,14 @@ discard block |
||
| 126 | 126 | // build js code for "selectAll" checkbox |
| 127 | 127 | self::buildSelectorHtml($selectOptions); |
| 128 | 128 | // return response inside "form" tag |
| 129 | - return $dom->form(function () use ($dom, $selectOptions, $table) { |
|
| 129 | + return $dom->form(function() use ($dom, $selectOptions, $table) { |
|
| 130 | 130 | foreach ($selectOptions['buttons'] as $btn) { |
| 131 | 131 | if (!Any::isArray($btn)) |
| 132 | 132 | continue; |
| 133 | 133 | |
| 134 | - $table .= $dom->input(function(){ |
|
| 134 | + $table .= $dom->input(function() { |
|
| 135 | 135 | return null; |
| 136 | - }, $btn) . ' '; |
|
| 136 | + }, $btn).' '; |
|
| 137 | 137 | } |
| 138 | 138 | return $table; |
| 139 | 139 | }, $selectOptions['form']); |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | private static function buildSelectorHtml(array $opt) |
| 150 | 150 | { |
| 151 | 151 | $js = '$(function () { |
| 152 | - var targetSwitchbox = $(\'input[name="' . $opt['selector']['name'] . '"]\'); |
|
| 152 | + var targetSwitchbox = $(\'input[name="' . $opt['selector']['name'].'"]\'); |
|
| 153 | 153 | $(\'input[name="selectAll"]\').change(function() { |
| 154 | 154 | $(targetSwitchbox).each(function () { |
| 155 | 155 | $(this).prop(\'checked\', !$(this).is(\':checked\')); |
@@ -23,8 +23,9 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | public static function display(array $elements): ?string |
| 25 | 25 | { |
| 26 | - if (!array_key_exists('tbody', $elements) || !Any::isArray($elements['tbody']['items']) || count($elements['tbody']['items']) < 1) |
|
| 27 | - return null; |
|
| 26 | + if (!array_key_exists('tbody', $elements) || !Any::isArray($elements['tbody']['items']) || count($elements['tbody']['items']) < 1) { |
|
| 27 | + return null; |
|
| 28 | + } |
|
| 28 | 29 | |
| 29 | 30 | $selectOptions = false; |
| 30 | 31 | if (isset($elements['selectableBox'])) { |
@@ -83,8 +84,9 @@ discard block |
||
| 83 | 84 | $tr .= $dom->tr(function () use ($dom, $row, $selectOptions) { |
| 84 | 85 | $td = null; |
| 85 | 86 | foreach ($row as $order => $item) { |
| 86 | - if (!Any::isInt($order)) |
|
| 87 | - continue; |
|
| 87 | + if (!Any::isInt($order)) { |
|
| 88 | + continue; |
|
| 89 | + } |
|
| 88 | 90 | |
| 89 | 91 | // collect td item |
| 90 | 92 | $td .= $dom->td(function () use ($dom, $order, $item, $selectOptions) { |
@@ -128,8 +130,9 @@ discard block |
||
| 128 | 130 | // return response inside "form" tag |
| 129 | 131 | return $dom->form(function () use ($dom, $selectOptions, $table) { |
| 130 | 132 | foreach ($selectOptions['buttons'] as $btn) { |
| 131 | - if (!Any::isArray($btn)) |
|
| 132 | - continue; |
|
| 133 | + if (!Any::isArray($btn)) { |
|
| 134 | + continue; |
|
| 135 | + } |
|
| 133 | 136 | |
| 134 | 137 | $table .= $dom->input(function(){ |
| 135 | 138 | return null; |
@@ -4,7 +4,6 @@ |
||
| 4 | 4 | |
| 5 | 5 | use Ffcms\Core\Helper\Type\Any; |
| 6 | 6 | use Ffcms\Core\Helper\Type\Arr; |
| 7 | -use Ffcms\Core\Helper\Type\Obj; |
|
| 8 | 7 | use Ffcms\Core\Helper\Type\Str; |
| 9 | 8 | |
| 10 | 9 | /** |
@@ -23,8 +23,9 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | public static function length_min($object, $length): bool |
| 25 | 25 | { |
| 26 | - if (!Any::isLine($object)) |
|
| 27 | - return false; |
|
| 26 | + if (!Any::isLine($object)) { |
|
| 27 | + return false; |
|
| 28 | + } |
|
| 28 | 29 | |
| 29 | 30 | return Str::length((string)$object) >= $length; |
| 30 | 31 | } |
@@ -37,8 +38,9 @@ discard block |
||
| 37 | 38 | */ |
| 38 | 39 | public static function length_max($object, $length): bool |
| 39 | 40 | { |
| 40 | - if (!Any::isLine($object)) |
|
| 41 | - return false; |
|
| 41 | + if (!Any::isLine($object)) { |
|
| 42 | + return false; |
|
| 43 | + } |
|
| 42 | 44 | |
| 43 | 45 | return Str::length((string)$object) <= $length; |
| 44 | 46 | } |
@@ -51,12 +53,14 @@ discard block |
||
| 51 | 53 | */ |
| 52 | 54 | public static function in($object, array $handle): bool |
| 53 | 55 | { |
| 54 | - if (!Any::isLine($object)) |
|
| 55 | - return false; |
|
| 56 | + if (!Any::isLine($object)) { |
|
| 57 | + return false; |
|
| 58 | + } |
|
| 56 | 59 | |
| 57 | 60 | // allow empty, validate on required rule |
| 58 | - if (Any::isEmpty($object)) |
|
| 59 | - return true; |
|
| 61 | + if (Any::isEmpty($object)) { |
|
| 62 | + return true; |
|
| 63 | + } |
|
| 60 | 64 | |
| 61 | 65 | $object = Any::guessValueType($object); |
| 62 | 66 | |
@@ -82,8 +86,9 @@ discard block |
||
| 82 | 86 | */ |
| 83 | 87 | public static function checked($object): bool |
| 84 | 88 | { |
| 85 | - if (!Any::isBool($object)) |
|
| 86 | - return false; |
|
| 89 | + if (!Any::isBool($object)) { |
|
| 90 | + return false; |
|
| 91 | + } |
|
| 87 | 92 | |
| 88 | 93 | return (bool)$object; |
| 89 | 94 | } |
@@ -155,11 +160,14 @@ discard block |
||
| 155 | 160 | */ |
| 156 | 161 | public static function email($object): bool |
| 157 | 162 | { |
| 158 | - if (Any::isEmpty($object)) // allow empty |
|
| 163 | + if (Any::isEmpty($object)) { |
|
| 164 | + // allow empty |
|
| 159 | 165 | return true; |
| 166 | + } |
|
| 160 | 167 | |
| 161 | - if (!Any::isLine($object)) |
|
| 162 | - return false; |
|
| 168 | + if (!Any::isLine($object)) { |
|
| 169 | + return false; |
|
| 170 | + } |
|
| 163 | 171 | |
| 164 | 172 | return Str::isEmail($object); |
| 165 | 173 | } |
@@ -171,11 +179,14 @@ discard block |
||
| 171 | 179 | */ |
| 172 | 180 | public static function phone($object): bool |
| 173 | 181 | { |
| 174 | - if (Any::isEmpty($object)) // allow empty |
|
| 182 | + if (Any::isEmpty($object)) { |
|
| 183 | + // allow empty |
|
| 175 | 184 | return true; |
| 185 | + } |
|
| 176 | 186 | |
| 177 | - if (!Any::isLine($object)) |
|
| 178 | - return false; |
|
| 187 | + if (!Any::isLine($object)) { |
|
| 188 | + return false; |
|
| 189 | + } |
|
| 179 | 190 | |
| 180 | 191 | return Str::isPhone($object); |
| 181 | 192 | } |
@@ -187,11 +198,14 @@ discard block |
||
| 187 | 198 | */ |
| 188 | 199 | public static function url($object): bool |
| 189 | 200 | { |
| 190 | - if (Any::isEmpty($object)) // allow empty |
|
| 201 | + if (Any::isEmpty($object)) { |
|
| 202 | + // allow empty |
|
| 191 | 203 | return true; |
| 204 | + } |
|
| 192 | 205 | |
| 193 | - if (!Any::isLine($object)) |
|
| 194 | - return false; |
|
| 206 | + if (!Any::isLine($object)) { |
|
| 207 | + return false; |
|
| 208 | + } |
|
| 195 | 209 | |
| 196 | 210 | return Str::isUrl($object); |
| 197 | 211 | } |
@@ -204,8 +218,9 @@ discard block |
||
| 204 | 218 | */ |
| 205 | 219 | public static function equal($object, $value = null): bool |
| 206 | 220 | { |
| 207 | - if (!Any::isLine($object)) |
|
| 208 | - return false; |
|
| 221 | + if (!Any::isLine($object)) { |
|
| 222 | + return false; |
|
| 223 | + } |
|
| 209 | 224 | |
| 210 | 225 | return $object === $value; |
| 211 | 226 | } |
@@ -218,8 +233,9 @@ discard block |
||
| 218 | 233 | */ |
| 219 | 234 | public static function notequal($object, $value = null): bool |
| 220 | 235 | { |
| 221 | - if (!Any::isLine($object)) |
|
| 222 | - return false; |
|
| 236 | + if (!Any::isLine($object)) { |
|
| 237 | + return false; |
|
| 238 | + } |
|
| 223 | 239 | |
| 224 | 240 | return $object !== $value; |
| 225 | 241 | } |
@@ -254,11 +270,13 @@ discard block |
||
| 254 | 270 | */ |
| 255 | 271 | public static function reg_match($object, $value): bool |
| 256 | 272 | { |
| 257 | - if (!Any::isLine($object)) |
|
| 258 | - return false; |
|
| 273 | + if (!Any::isLine($object)) { |
|
| 274 | + return false; |
|
| 275 | + } |
|
| 259 | 276 | |
| 260 | - if (Str::likeEmpty($object)) |
|
| 261 | - return true; |
|
| 277 | + if (Str::likeEmpty($object)) { |
|
| 278 | + return true; |
|
| 279 | + } |
|
| 262 | 280 | |
| 263 | 281 | // what the f*ck? -> return preg_match($value, $object) > 0; |
| 264 | 282 | return (bool)preg_match($value, $object); |
@@ -272,8 +290,9 @@ discard block |
||
| 272 | 290 | */ |
| 273 | 291 | public static function intList($object, $value): bool |
| 274 | 292 | { |
| 275 | - if (!Any::isLine($object)) |
|
| 276 | - return false; |
|
| 293 | + if (!Any::isLine($object)) { |
|
| 294 | + return false; |
|
| 295 | + } |
|
| 277 | 296 | |
| 278 | 297 | return !preg_match('/[^0-9\s,]/$', $object); |
| 279 | 298 | } |
@@ -287,8 +306,9 @@ discard block |
||
| 287 | 306 | public static function isFile($object, $value): bool |
| 288 | 307 | { |
| 289 | 308 | // allow empty fields, "required" option filter that |
| 290 | - if ($object === null) |
|
| 291 | - return true; |
|
| 309 | + if ($object === null) { |
|
| 310 | + return true; |
|
| 311 | + } |
|
| 292 | 312 | |
| 293 | 313 | $all = false; |
| 294 | 314 | // if string is given |
@@ -301,13 +321,15 @@ discard block |
||
| 301 | 321 | } |
| 302 | 322 | |
| 303 | 323 | // input file is not object? |
| 304 | - if ($object === null || !Any::isObj($object)) |
|
| 305 | - return false; |
|
| 324 | + if ($object === null || !Any::isObj($object)) { |
|
| 325 | + return false; |
|
| 326 | + } |
|
| 306 | 327 | |
| 307 | 328 | // get guess file type, based on mime-type |
| 308 | 329 | $type = $object->guessExtension(); |
| 309 | - if ($type === null) |
|
| 310 | - return false; |
|
| 330 | + if ($type === null) { |
|
| 331 | + return false; |
|
| 332 | + } |
|
| 311 | 333 | |
| 312 | 334 | return ($all ? true : Arr::in($type, $value)); |
| 313 | 335 | } |
@@ -321,21 +343,24 @@ discard block |
||
| 321 | 343 | public static function sizeFile($object, $value): bool |
| 322 | 344 | { |
| 323 | 345 | // allow empty field, validate on filter 'required' |
| 324 | - if ($object === null) |
|
| 325 | - return true; |
|
| 346 | + if ($object === null) { |
|
| 347 | + return true; |
|
| 348 | + } |
|
| 326 | 349 | |
| 327 | 350 | if (!Any::isArray($value)) { |
| 328 | 351 | $value = [0, $value]; |
| 329 | 352 | } |
| 330 | 353 | |
| 331 | 354 | // input file is not object? |
| 332 | - if ($object === null || !Any::isObj($object)) |
|
| 333 | - return false; |
|
| 355 | + if ($object === null || !Any::isObj($object)) { |
|
| 356 | + return false; |
|
| 357 | + } |
|
| 334 | 358 | |
| 335 | 359 | // get file upload size in bytes |
| 336 | 360 | $realSize = $object->getClientSize(); |
| 337 | - if ($realSize === null) |
|
| 338 | - return false; |
|
| 361 | + if ($realSize === null) { |
|
| 362 | + return false; |
|
| 363 | + } |
|
| 339 | 364 | |
| 340 | 365 | return $realSize > $value[0] && $realSize <= $value[1]; |
| 341 | 366 | } |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | * String html tags and escape quotes |
| 51 | 51 | * @param string|array $html |
| 52 | 52 | * @param boolean $escapeQuotes |
| 53 | - * @return string|array|null |
|
| 53 | + * @return string|null |
|
| 54 | 54 | */ |
| 55 | 55 | public function strip_tags($html, $escapeQuotes = true) |
| 56 | 56 | { |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | * @deprecated |
| 91 | 91 | * @param $var |
| 92 | 92 | * @param null $indent |
| 93 | - * @return mixed|string |
|
| 93 | + * @return string|null |
|
| 94 | 94 | */ |
| 95 | 95 | public function var_export54($var, $indent = null, $guessTypes = false) { |
| 96 | 96 | return Arr::exportVar($var, $indent, $guessTypes); |
@@ -5,7 +5,6 @@ |
||
| 5 | 5 | use Ffcms\Core\App; |
| 6 | 6 | use Ffcms\Core\Helper\Type\Any; |
| 7 | 7 | use Ffcms\Core\Helper\Type\Arr; |
| 8 | -use Ffcms\Core\Helper\Type\Obj; |
|
| 9 | 8 | use Ffcms\Core\Helper\Type\Str; |
| 10 | 9 | |
| 11 | 10 | /** |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | public function __construct() |
| 23 | 23 | { |
| 24 | 24 | $config = \HTMLPurifier_Config::createDefault(); |
| 25 | - $config->set('Cache.SerializerPath', root . '/Private/Cache/HTMLPurifier/'); |
|
| 25 | + $config->set('Cache.SerializerPath', root.'/Private/Cache/HTMLPurifier/'); |
|
| 26 | 26 | $config->set('HTML.Allowed', 'p,b,strong,em,a[href],i,span,ul,ol,li,blockquote,h2,h3,pre,code,img[src|alt|width|height]'); |
| 27 | 27 | //$config->set('URI.Base', 'http://www.example.com'); |
| 28 | 28 | //$config->set('URI.MakeAbsolute', true); |
@@ -60,8 +60,9 @@ discard block |
||
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | $text = strip_tags($html); |
| 63 | - if ($escapeQuotes) |
|
| 64 | - $text = $this->escapeQuotes($text); |
|
| 63 | + if ($escapeQuotes) { |
|
| 64 | + $text = $this->escapeQuotes($text); |
|
| 65 | + } |
|
| 65 | 66 | |
| 66 | 67 | return $text; |
| 67 | 68 | } |
@@ -113,8 +114,9 @@ discard block |
||
| 113 | 114 | */ |
| 114 | 115 | public static function password_hash($password, $salt = null) |
| 115 | 116 | { |
| 116 | - if ($salt === null || !Any::isStr($salt) || Str::length($salt) < 1) |
|
| 117 | - $salt = App::$Properties->get('passwordSalt'); |
|
| 117 | + if ($salt === null || !Any::isStr($salt) || Str::length($salt) < 1) { |
|
| 118 | + $salt = App::$Properties->get('passwordSalt'); |
|
| 119 | + } |
|
| 118 | 120 | |
| 119 | 121 | return crypt($password, $salt); |
| 120 | 122 | } |
@@ -126,8 +128,9 @@ discard block |
||
| 126 | 128 | */ |
| 127 | 129 | public static function simpleHash($string): ?string |
| 128 | 130 | { |
| 129 | - if (!Any::isLine($string)) |
|
| 130 | - return null; |
|
| 131 | + if (!Any::isLine($string)) { |
|
| 132 | + return null; |
|
| 133 | + } |
|
| 131 | 134 | |
| 132 | 135 | return dechex(crc32($string)); |
| 133 | 136 | } |
@@ -213,8 +213,8 @@ discard block |
||
| 213 | 213 | |
| 214 | 214 | /** |
| 215 | 215 | * Case-ignore replace $needle to $replacement in string $haystack. Alias for function str_ireplace() |
| 216 | - * @param string|array $needle |
|
| 217 | - * @param string|array $replacement |
|
| 216 | + * @param string[] $needle |
|
| 217 | + * @param string $replacement |
|
| 218 | 218 | * @param string $haystack |
| 219 | 219 | * @return string |
| 220 | 220 | */ |
@@ -318,9 +318,6 @@ discard block |
||
| 318 | 318 | |
| 319 | 319 | /** |
| 320 | 320 | * Concat string with add string by separator |
| 321 | - * @param string $separator |
|
| 322 | - * @param string $string1 |
|
| 323 | - * @param string $string2 |
|
| 324 | 321 | * @return string |
| 325 | 322 | */ |
| 326 | 323 | public static function concat() |
@@ -297,7 +297,7 @@ |
||
| 297 | 297 | |
| 298 | 298 | $output = null; |
| 299 | 299 | foreach ($args as $string) { |
| 300 | - $output .= $string . $separator; |
|
| 300 | + $output .= $string.$separator; |
|
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | $output = rtrim($output, $separator); |
@@ -28,8 +28,9 @@ discard block |
||
| 28 | 28 | public static function startsWith(?string $what, ?string $where): bool |
| 29 | 29 | { |
| 30 | 30 | // check is not empty string |
| 31 | - if (self::likeEmpty($what) || self::likeEmpty($where)) |
|
| 32 | - return false; |
|
| 31 | + if (self::likeEmpty($what) || self::likeEmpty($where)) { |
|
| 32 | + return false; |
|
| 33 | + } |
|
| 33 | 34 | |
| 34 | 35 | $prefix = self::sub($where, 0, self::length($what)); |
| 35 | 36 | return $prefix === $what; |
@@ -44,8 +45,9 @@ discard block |
||
| 44 | 45 | public static function endsWith(?string $what, ?string $where): bool |
| 45 | 46 | { |
| 46 | 47 | // check is not empty string |
| 47 | - if (self::likeEmpty($what) || self::likeEmpty($where)) |
|
| 48 | - return false; |
|
| 48 | + if (self::likeEmpty($what) || self::likeEmpty($where)) { |
|
| 49 | + return false; |
|
| 50 | + } |
|
| 49 | 51 | |
| 50 | 52 | $suffix = self::sub($where, -self::length($what)); |
| 51 | 53 | return $suffix === $what; |
@@ -59,8 +61,9 @@ discard block |
||
| 59 | 61 | */ |
| 60 | 62 | public static function firstIn(?string $string, ?string $delimiter): ?string |
| 61 | 63 | { |
| 62 | - if (self::likeEmpty($string) || self::likeEmpty($delimiter)) |
|
| 63 | - return null; |
|
| 64 | + if (self::likeEmpty($string) || self::likeEmpty($delimiter)) { |
|
| 65 | + return null; |
|
| 66 | + } |
|
| 64 | 67 | |
| 65 | 68 | return strstr($string, $delimiter, true); |
| 66 | 69 | } |
@@ -74,13 +77,15 @@ discard block |
||
| 74 | 77 | */ |
| 75 | 78 | public static function lastIn(?string $string, ?string $delimiter, bool $withoutDelimiter = false): ?string |
| 76 | 79 | { |
| 77 | - if (self::likeEmpty($string) || self::likeEmpty($delimiter)) |
|
| 78 | - return null; |
|
| 80 | + if (self::likeEmpty($string) || self::likeEmpty($delimiter)) { |
|
| 81 | + return null; |
|
| 82 | + } |
|
| 79 | 83 | |
| 80 | 84 | $pos = mb_strrpos($string, $delimiter); |
| 81 | 85 | // if entry is not founded return false |
| 82 | - if (!Any::isInt($pos)) |
|
| 83 | - return null; |
|
| 86 | + if (!Any::isInt($pos)) { |
|
| 87 | + return null; |
|
| 88 | + } |
|
| 84 | 89 | |
| 85 | 90 | // remove delimiter pointer |
| 86 | 91 | if ($withoutDelimiter) { |
@@ -98,8 +103,9 @@ discard block |
||
| 98 | 103 | public static function cleanExtension(?string $string): ?string |
| 99 | 104 | { |
| 100 | 105 | // no extension in string is founded |
| 101 | - if (!self::contains('.', $string)) |
|
| 102 | - return $string; |
|
| 106 | + if (!self::contains('.', $string)) { |
|
| 107 | + return $string; |
|
| 108 | + } |
|
| 103 | 109 | |
| 104 | 110 | $splited = explode('.', $string); |
| 105 | 111 | array_pop($splited); |
@@ -124,8 +130,9 @@ discard block |
||
| 124 | 130 | */ |
| 125 | 131 | public static function lowerCase(?string $string): ?string |
| 126 | 132 | { |
| 127 | - if ($string === null) |
|
| 128 | - return null; |
|
| 133 | + if ($string === null) { |
|
| 134 | + return null; |
|
| 135 | + } |
|
| 129 | 136 | |
| 130 | 137 | return mb_strtolower($string, 'UTF-8'); |
| 131 | 138 | } |
@@ -137,8 +144,9 @@ discard block |
||
| 137 | 144 | */ |
| 138 | 145 | public static function upperCase(?string $string = null): ?string |
| 139 | 146 | { |
| 140 | - if ($string === null) |
|
| 141 | - return null; |
|
| 147 | + if ($string === null) { |
|
| 148 | + return null; |
|
| 149 | + } |
|
| 142 | 150 | |
| 143 | 151 | return mb_strtoupper($string, 'UTF-8'); |
| 144 | 152 | } |
@@ -205,8 +213,9 @@ discard block |
||
| 205 | 213 | */ |
| 206 | 214 | public static function replace($needle, $replacement, ?string $haystack): ?string |
| 207 | 215 | { |
| 208 | - if ($haystack === null) |
|
| 209 | - return null; |
|
| 216 | + if ($haystack === null) { |
|
| 217 | + return null; |
|
| 218 | + } |
|
| 210 | 219 | |
| 211 | 220 | return str_replace($needle, $replacement, $haystack); |
| 212 | 221 | } |
@@ -220,8 +229,9 @@ discard block |
||
| 220 | 229 | */ |
| 221 | 230 | public static function ireplace($needle, $replacement, ?string $haystack): ?string |
| 222 | 231 | { |
| 223 | - if ($haystack === null) |
|
| 224 | - return null; |
|
| 232 | + if ($haystack === null) { |
|
| 233 | + return null; |
|
| 234 | + } |
|
| 225 | 235 | |
| 226 | 236 | return str_ireplace($needle, $replacement, $haystack); |
| 227 | 237 | } |
@@ -9,7 +9,6 @@ |
||
| 9 | 9 | use Ffcms\Core\Helper\Serialize; |
| 10 | 10 | use Ffcms\Core\Helper\Type\Any; |
| 11 | 11 | use Ffcms\Core\Helper\Type\Arr; |
| 12 | -use Ffcms\Core\Helper\Type\Obj; |
|
| 13 | 12 | use Ffcms\Core\Helper\Type\Str; |
| 14 | 13 | |
| 15 | 14 | /** |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | if (Any::isArray($params) && count($params) > 0) { |
| 56 | 56 | foreach ($params as $var => $value) { |
| 57 | - $text = Str::replace('%' . $var . '%', $value, $text); |
|
| 57 | + $text = Str::replace('%'.$var.'%', $value, $text); |
|
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | return $text; |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | public function translate(string $text, array $params = null) |
| 70 | 70 | { |
| 71 | 71 | $index = null; |
| 72 | - $namespace = 'Apps\Controller\\' . env_name . '\\'; |
|
| 72 | + $namespace = 'Apps\Controller\\'.env_name.'\\'; |
|
| 73 | 73 | foreach (@debug_backtrace() as $caller) { |
| 74 | 74 | if (isset($caller['class']) && Str::startsWith($namespace, $caller['class'])) { |
| 75 | 75 | $index = Str::sub((string)$caller['class'], Str::length($namespace)); |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | protected function load(string $index): ?array |
| 87 | 87 | { |
| 88 | - $file = root . '/I18n/' . env_name . '/' . App::$Request->getLanguage() . '/' . $index . '.php'; |
|
| 88 | + $file = root.'/I18n/'.env_name.'/'.App::$Request->getLanguage().'/'.$index.'.php'; |
|
| 89 | 89 | if (!File::exist($file)) |
| 90 | 90 | return []; |
| 91 | 91 | |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | public function getAvailableLangs(): array |
| 122 | 122 | { |
| 123 | 123 | $langs = ['en']; |
| 124 | - $scan = Directory::scan(root . '/I18n/' . env_name . '/', GLOB_ONLYDIR, true); |
|
| 124 | + $scan = Directory::scan(root.'/I18n/'.env_name.'/', GLOB_ONLYDIR, true); |
|
| 125 | 125 | foreach ($scan as $row) { |
| 126 | 126 | $langs[] = trim($row, '/'); |
| 127 | 127 | } |
@@ -48,8 +48,9 @@ discard block |
||
| 48 | 48 | $this->indexes[] = $index; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - if ($this->cached && Any::isStr($text) && isset($this->cached[$text])) |
|
| 52 | - $text = $this->cached[$text]; |
|
| 51 | + if ($this->cached && Any::isStr($text) && isset($this->cached[$text])) { |
|
| 52 | + $text = $this->cached[$text]; |
|
| 53 | + } |
|
| 53 | 54 | } |
| 54 | 55 | |
| 55 | 56 | if (Any::isArray($params) && count($params) > 0) { |
@@ -86,8 +87,9 @@ discard block |
||
| 86 | 87 | protected function load(string $index): ?array |
| 87 | 88 | { |
| 88 | 89 | $file = root . '/I18n/' . env_name . '/' . App::$Request->getLanguage() . '/' . $index . '.php'; |
| 89 | - if (!File::exist($file)) |
|
| 90 | - return []; |
|
| 90 | + if (!File::exist($file)) { |
|
| 91 | + return []; |
|
| 92 | + } |
|
| 91 | 93 | |
| 92 | 94 | return require($file); |
| 93 | 95 | } |
@@ -101,13 +103,15 @@ discard block |
||
| 101 | 103 | { |
| 102 | 104 | $path = Normalize::diskFullPath($path); |
| 103 | 105 | // check if file exist |
| 104 | - if (!File::exist($path)) |
|
| 105 | - return false; |
|
| 106 | + if (!File::exist($path)) { |
|
| 107 | + return false; |
|
| 108 | + } |
|
| 106 | 109 | |
| 107 | 110 | // load file translations |
| 108 | 111 | $addTranslation = require($path); |
| 109 | - if (!Any::isArray($addTranslation)) |
|
| 110 | - return false; |
|
| 112 | + if (!Any::isArray($addTranslation)) { |
|
| 113 | + return false; |
|
| 114 | + } |
|
| 111 | 115 | |
| 112 | 116 | // merge data |
| 113 | 117 | $this->cached = Arr::merge($this->cached, $addTranslation); |
@@ -142,11 +146,13 @@ discard block |
||
| 142 | 146 | $lang = App::$Request->getLanguage(); |
| 143 | 147 | } |
| 144 | 148 | // unserialize from string to array |
| 145 | - if (Any::isStr($input)) |
|
| 146 | - $input = Serialize::decode($input); |
|
| 149 | + if (Any::isStr($input)) { |
|
| 150 | + $input = Serialize::decode($input); |
|
| 151 | + } |
|
| 147 | 152 | |
| 148 | - if (Any::isArray($input) && array_key_exists($lang, $input)) |
|
| 149 | - return $input[$lang]; |
|
| 153 | + if (Any::isArray($input) && array_key_exists($lang, $input)) { |
|
| 154 | + return $input[$lang]; |
|
| 155 | + } |
|
| 150 | 156 | |
| 151 | 157 | return $default; |
| 152 | 158 | } |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | 28 | * BootManager constructor. Pass composer loader inside |
| 29 | - * @param bool|object $loader |
|
| 29 | + * @param boolean $loader |
|
| 30 | 30 | */ |
| 31 | 31 | public function __construct($loader = false) |
| 32 | 32 | { |
@@ -8,7 +8,6 @@ |
||
| 8 | 8 | use Ffcms\Core\Helper\FileSystem\Directory; |
| 9 | 9 | use Ffcms\Core\Helper\FileSystem\File; |
| 10 | 10 | use Ffcms\Core\Helper\Type\Any; |
| 11 | -use Ffcms\Core\Helper\Type\Obj; |
|
| 12 | 11 | use Ffcms\Core\Helper\Type\Str; |
| 13 | 12 | |
| 14 | 13 | /** |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | // check if cache is enabled |
| 44 | 44 | if (App::$Cache !== null) { |
| 45 | 45 | // try to get bootable class map from cache, or initialize parsing |
| 46 | - $cache = App::$Cache->getItem('boot.' . env_name . '.class.map'); |
|
| 46 | + $cache = App::$Cache->getItem('boot.'.env_name.'.class.map'); |
|
| 47 | 47 | if (!$cache->isHit()) { |
| 48 | 48 | $this->compileBootableClasses(); |
| 49 | 49 | $cache->set($this->objects)->expiresAfter(static::CACHE_TREE_TIME); |
@@ -96,11 +96,11 @@ discard block |
||
| 96 | 96 | { |
| 97 | 97 | // list app root's |
| 98 | 98 | foreach ($this->appRoots as $app) { |
| 99 | - $app .= '/Apps/Controller/' . env_name; |
|
| 99 | + $app .= '/Apps/Controller/'.env_name; |
|
| 100 | 100 | $files = File::listFiles($app, ['.php'], true); |
| 101 | 101 | foreach ($files as $file) { |
| 102 | 102 | // define full class name with namespace |
| 103 | - $class = 'Apps\Controller\\' . env_name . '\\' . Str::cleanExtension($file); |
|
| 103 | + $class = 'Apps\Controller\\'.env_name.'\\'.Str::cleanExtension($file); |
|
| 104 | 104 | // check if class exists (must be loaded over autoloader), boot method exist and this is controller instanceof |
| 105 | 105 | if (class_exists($class) && method_exists($class, 'boot') && is_a($class, 'Ffcms\Core\Arch\Controller', true)) { |
| 106 | 106 | $this->objects[] = $class; |
@@ -110,14 +110,14 @@ discard block |
||
| 110 | 110 | |
| 111 | 111 | // list widget root's |
| 112 | 112 | foreach ($this->widgetRoots as $widget) { |
| 113 | - $widget .= '/Widgets/' . env_name; |
|
| 113 | + $widget .= '/Widgets/'.env_name; |
|
| 114 | 114 | // widgets are packed in directory, classname should be the same with root directory name |
| 115 | 115 | $dirs = Directory::scan($widget, GLOB_ONLYDIR, true); |
| 116 | 116 | if (!Any::isArray($dirs)) |
| 117 | 117 | continue; |
| 118 | 118 | |
| 119 | 119 | foreach ($dirs as $instance) { |
| 120 | - $class = 'Widgets\\' . env_name . '\\' . $instance . '\\' . $instance; |
|
| 120 | + $class = 'Widgets\\'.env_name.'\\'.$instance.'\\'.$instance; |
|
| 121 | 121 | if (class_exists($class) && method_exists($class, 'boot') && is_a($class, 'Ffcms\Core\Arch\Widget', true)) { |
| 122 | 122 | $this->objects[] = $class; |
| 123 | 123 | } |
@@ -81,11 +81,13 @@ discard block |
||
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | // set default root path if not found anything else |
| 84 | - if (count($this->appRoots) < 1) |
|
| 85 | - $this->appRoots = [root]; |
|
| 84 | + if (count($this->appRoots) < 1) { |
|
| 85 | + $this->appRoots = [root]; |
|
| 86 | + } |
|
| 86 | 87 | |
| 87 | - if (count($this->widgetRoots) < 1) |
|
| 88 | - $this->widgetRoots = [root]; |
|
| 88 | + if (count($this->widgetRoots) < 1) { |
|
| 89 | + $this->widgetRoots = [root]; |
|
| 90 | + } |
|
| 89 | 91 | } |
| 90 | 92 | |
| 91 | 93 | /** |
@@ -113,8 +115,9 @@ discard block |
||
| 113 | 115 | $widget .= '/Widgets/' . env_name; |
| 114 | 116 | // widgets are packed in directory, classname should be the same with root directory name |
| 115 | 117 | $dirs = Directory::scan($widget, GLOB_ONLYDIR, true); |
| 116 | - if (!Any::isArray($dirs)) |
|
| 117 | - continue; |
|
| 118 | + if (!Any::isArray($dirs)) { |
|
| 119 | + continue; |
|
| 120 | + } |
|
| 118 | 121 | |
| 119 | 122 | foreach ($dirs as $instance) { |
| 120 | 123 | $class = 'Widgets\\' . env_name . '\\' . $instance . '\\' . $instance; |
@@ -133,8 +136,9 @@ discard block |
||
| 133 | 136 | { |
| 134 | 137 | $this->startMeasure(__METHOD__); |
| 135 | 138 | |
| 136 | - if (!Any::isArray($this->objects)) |
|
| 137 | - return false; |
|
| 139 | + if (!Any::isArray($this->objects)) { |
|
| 140 | + return false; |
|
| 141 | + } |
|
| 138 | 142 | |
| 139 | 143 | foreach ($this->objects as $class) { |
| 140 | 144 | forward_static_call([$class, 'boot']); |