@@ -5,12 +5,12 @@ |
||
5 | 5 | |
6 | 6 | class HtmlAsset extends Asset { |
7 | 7 | |
8 | - public $type = HtmlAsset::class; |
|
9 | - public $namespace = 'property'; |
|
8 | + public $type = HtmlAsset::class; |
|
9 | + public $namespace = 'property'; |
|
10 | 10 | public $options = ["formatting", "bold", "italic", "deleted", "unorderedlist","orderedlist", "image", "file", "link"]; |
11 | 11 | |
12 | - // return it raw |
|
13 | - public static function html($data) { |
|
14 | - return $data['value']; |
|
15 | - } |
|
12 | + // return it raw |
|
13 | + public static function html($data) { |
|
14 | + return $data['value']; |
|
15 | + } |
|
16 | 16 | } |
@@ -7,7 +7,7 @@ |
||
7 | 7 | |
8 | 8 | public $type = HtmlAsset::class; |
9 | 9 | public $namespace = 'property'; |
10 | - public $options = ["formatting", "bold", "italic", "deleted", "unorderedlist","orderedlist", "image", "file", "link"]; |
|
10 | + public $options = ["formatting", "bold", "italic", "deleted", "unorderedlist", "orderedlist", "image", "file", "link"]; |
|
11 | 11 | |
12 | 12 | // return it raw |
13 | 13 | public static function html($data) { |
@@ -5,10 +5,10 @@ |
||
5 | 5 | |
6 | 6 | class DropdownAsset extends Asset { |
7 | 7 | |
8 | - public $type = DropdownAsset::class; |
|
9 | - public $namespace = 'property'; |
|
8 | + public $type = DropdownAsset::class; |
|
9 | + public $namespace = 'property'; |
|
10 | 10 | |
11 | - public static function html($data) { |
|
12 | - return '<span>' . $data['value'] . '</span>'; |
|
13 | - } |
|
11 | + public static function html($data) { |
|
12 | + return '<span>' . $data['value'] . '</span>'; |
|
13 | + } |
|
14 | 14 | } |
15 | 15 | \ No newline at end of file |
@@ -4,11 +4,11 @@ |
||
4 | 4 | |
5 | 5 | class TextAsset extends Asset { |
6 | 6 | |
7 | - public $type = TextAsset::class; |
|
8 | - public $namespace = 'property'; |
|
7 | + public $type = TextAsset::class; |
|
8 | + public $namespace = 'property'; |
|
9 | 9 | |
10 | - public static function html($data) { |
|
11 | - return '<p>' . $data['value'] . '</p>'; |
|
12 | - } |
|
10 | + public static function html($data) { |
|
11 | + return '<p>' . $data['value'] . '</p>'; |
|
12 | + } |
|
13 | 13 | |
14 | 14 | } |
15 | 15 | \ No newline at end of file |
@@ -26,11 +26,11 @@ |
||
26 | 26 | 'type' => self::HTML |
27 | 27 | ), |
28 | 28 | 'status' => array( |
29 | - 'name' => 'Published', |
|
30 | - 'type' => self::DROPDOWN, |
|
29 | + 'name' => 'Published', |
|
30 | + 'type' => self::DROPDOWN, |
|
31 | 31 | 'options' => ['published' => 'Published', 'unpublished' => 'Unpublished'], |
32 | 32 | 'published' => ['published'] |
33 | - ), |
|
33 | + ), |
|
34 | 34 | ); |
35 | 35 | |
36 | 36 | public static function about() { |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <div class="row form-group"> |
2 | - <?php $key = isset($data['unique_id']) ? $data['key'] . '_' . $data['unique_id'] : $data['key'] ; ?> |
|
2 | + <?php $key = isset($data['unique_id']) ? $data['key'] . '_' . $data['unique_id'] : $data['key']; ?> |
|
3 | 3 | {{ html()->label($data['name'])->class('col-md-2 form-control-label')->for($key) }} |
4 | 4 | <div class="col-md-10"> |
5 | 5 | |
@@ -7,16 +7,16 @@ discard block |
||
7 | 7 | ->text() |
8 | 8 | ->attribute('id', $key) |
9 | 9 | ->class('form-control'); |
10 | - if($data['required']){ |
|
10 | + if ($data['required']) { |
|
11 | 11 | $input = $input->required(); |
12 | 12 | } |
13 | - if($asset_classname){ |
|
13 | + if ($asset_classname) { |
|
14 | 14 | $name = 'assetInjectionform[' . $asset_classname . '][' . $data['unique_id'] . '][' . $data['key'] . ']'; |
15 | - }else{ |
|
15 | + }else { |
|
16 | 16 | $name = $data['key']; |
17 | 17 | } |
18 | 18 | |
19 | - $name .= (isset($multiform) && $multiform) ? '[]' : '';?> |
|
19 | + $name .= (isset($multiform) && $multiform) ? '[]' : ''; ?> |
|
20 | 20 | |
21 | 21 | {{ $input->name($name)->value(old($name, !empty($data['value']) ? $data['value'] : NULL)) }} |
22 | 22 |
@@ -13,7 +13,7 @@ |
||
13 | 13 | } |
14 | 14 | if($asset_classname){ |
15 | 15 | $name = 'assetInjectionform[' . $asset_classname . '][' . $data['unique_id'] . '][' . $data['key'] . ']'; |
16 | - }else{ |
|
16 | + } else{ |
|
17 | 17 | $name = $data['key']; |
18 | 18 | } |
19 | 19 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <div class="row form-group"> |
2 | - <?php $key = isset($data['unique_id']) ? $data['key'] . '_' . $data['unique_id'] : $data['key'] ; ?> |
|
2 | + <?php $key = isset($data['unique_id']) ? $data['key'] . '_' . $data['unique_id'] : $data['key']; ?> |
|
3 | 3 | {{ html()->label($data['name'])->class('col-md-2 form-control-label')->for($key) }} |
4 | 4 | <div class="col-md-10"> |
5 | 5 | |
@@ -7,16 +7,16 @@ discard block |
||
7 | 7 | ->text() |
8 | 8 | ->attribute('id', $key) |
9 | 9 | ->class('form-control'); |
10 | - if($data['required']){ |
|
10 | + if ($data['required']) { |
|
11 | 11 | $input = $input->required(); |
12 | 12 | } |
13 | - if($asset_classname){ |
|
13 | + if ($asset_classname) { |
|
14 | 14 | $name = 'assetInjectionform[' . $asset_classname . '][' . $data['unique_id'] . '][' . $data['key'] . ']'; |
15 | - }else{ |
|
15 | + }else { |
|
16 | 16 | $name = $data['key']; |
17 | 17 | } |
18 | 18 | |
19 | - $name .= (isset($multiform) && $multiform) ? '[]' : '';?> |
|
19 | + $name .= (isset($multiform) && $multiform) ? '[]' : ''; ?> |
|
20 | 20 | |
21 | 21 | {{ $input->name($name)->value(old($name, !empty($data['value']) ? $data['value'] : NULL)) }} |
22 | 22 |
@@ -13,7 +13,7 @@ |
||
13 | 13 | } |
14 | 14 | if($asset_classname){ |
15 | 15 | $name = 'assetInjectionform[' . $asset_classname . '][' . $data['unique_id'] . '][' . $data['key'] . ']'; |
16 | - }else{ |
|
16 | + } else{ |
|
17 | 17 | $name = $data['key']; |
18 | 18 | } |
19 | 19 |
@@ -65,7 +65,7 @@ |
||
65 | 65 | public static function html($data) :string |
66 | 66 | { |
67 | 67 | return '<img src="' . self::getImageUrl($data['value']) . '" />'; |
68 | - } |
|
68 | + } |
|
69 | 69 | |
70 | 70 | |
71 | 71 |
@@ -31,24 +31,24 @@ |
||
31 | 31 | */ |
32 | 32 | public static function getImageUrl(string $filename, int $width = null, int $height = null) :string |
33 | 33 | { |
34 | - $imagePath = public_path().'/vendor/phpsa-datastore/'; |
|
34 | + $imagePath = public_path() . '/vendor/phpsa-datastore/'; |
|
35 | 35 | |
36 | 36 | if ($width !== null || $height !== null) { |
37 | - $path = 'thumbs/' . (int) $width . 'x' . (int) $height . '.' . $filename; |
|
37 | + $path = 'thumbs/' . (int) $width . 'x' . (int) $height . '.' . $filename; |
|
38 | 38 | |
39 | - if(!is_file($imagePath . $path)){ |
|
40 | - try{ |
|
39 | + if (!is_file($imagePath . $path)) { |
|
40 | + try { |
|
41 | 41 | Image::make($imagePath . 'img/' . $filename) |
42 | - ->resize($width, $height, function ($constraint) |
|
42 | + ->resize($width, $height, function($constraint) |
|
43 | 43 | { |
44 | 44 | $constraint->aspectRatio(); |
45 | 45 | }) |
46 | 46 | ->save($imagePath . $path); |
47 | - }catch(\Exception $e){ |
|
47 | + }catch (\Exception $e) { |
|
48 | 48 | //Silent fallback as the image does not exist! |
49 | 49 | } |
50 | 50 | } |
51 | - }else{ |
|
51 | + }else { |
|
52 | 52 | $path = 'img/' . $filename; |
53 | 53 | } |
54 | 54 | return '/vendor/phpsa-datastore/' . $path; |
@@ -44,11 +44,11 @@ |
||
44 | 44 | $constraint->aspectRatio(); |
45 | 45 | }) |
46 | 46 | ->save($imagePath . $path); |
47 | - }catch(\Exception $e){ |
|
47 | + } catch(\Exception $e){ |
|
48 | 48 | //Silent fallback as the image does not exist! |
49 | 49 | } |
50 | 50 | } |
51 | - }else{ |
|
51 | + } else{ |
|
52 | 52 | $path = 'img/' . $filename; |
53 | 53 | } |
54 | 54 | return '/vendor/phpsa-datastore/' . $path; |
@@ -17,17 +17,17 @@ |
||
17 | 17 | /** |
18 | 18 | * @var DatastoreRepository |
19 | 19 | */ |
20 | - protected $datastoreRepository; |
|
20 | + protected $datastoreRepository; |
|
21 | 21 | |
22 | - /** |
|
23 | - * UserController constructor. |
|
24 | - * |
|
25 | - * @param DatastoreRepository $datastoreRepository |
|
22 | + /** |
|
23 | + * UserController constructor. |
|
24 | + * |
|
25 | + * @param DatastoreRepository $datastoreRepository |
|
26 | 26 | * @todo get rid of these datastoreRepository and make use of the mode only |
27 | - */ |
|
28 | - public function __construct(DatastoreRepository $datastoreRepository) |
|
29 | - { |
|
30 | - $this->datastoreRepository = $datastoreRepository; |
|
27 | + */ |
|
28 | + public function __construct(DatastoreRepository $datastoreRepository) |
|
29 | + { |
|
30 | + $this->datastoreRepository = $datastoreRepository; |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -52,16 +52,16 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @return DatastorePages |
54 | 54 | */ |
55 | - protected function getPageBySlug($slug){ |
|
55 | + protected function getPageBySlug($slug) { |
|
56 | 56 | $page = DatastorePages::where('slug', $slug)->first(); |
57 | - if(!$page){ |
|
57 | + if (!$page) { |
|
58 | 58 | abort(404); |
59 | 59 | } |
60 | 60 | |
61 | 61 | $datastore = $page->datastore; |
62 | 62 | $user = auth()->user(); |
63 | 63 | |
64 | - if(!$datastore->statusIsActive() && (!$user || !$user->can('manage datastore'))) { |
|
64 | + if (!$datastore->statusIsActive() && (!$user || !$user->can('manage datastore'))) { |
|
65 | 65 | abort(404); |
66 | 66 | } |
67 | 67 | return $page; |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * |
75 | 75 | * @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory |
76 | 76 | */ |
77 | - public function page($slug){ |
|
77 | + public function page($slug) { |
|
78 | 78 | |
79 | 79 | $page = $this->getPageBySlug($slug); |
80 | 80 | |
@@ -88,11 +88,11 @@ discard block |
||
88 | 88 | |
89 | 89 | } |
90 | 90 | |
91 | - public function childPage($parent_slug, $slug){ |
|
91 | + public function childPage($parent_slug, $slug) { |
|
92 | 92 | return $this->page($slug); |
93 | 93 | } |
94 | 94 | |
95 | - public function articleByAuthor($author_id, $slug){ |
|
95 | + public function articleByAuthor($author_id, $slug) { |
|
96 | 96 | $this->datastoreRepository->paginateSearchProp('author', $author_id, Phpsa\Datastore\Ams\Article\ItemAsset::class, $this->canViewAll('published')); |
97 | 97 | } |
98 | 98 |
@@ -17,8 +17,8 @@ discard block |
||
17 | 17 | */ |
18 | 18 | public static function isAssocArray(array $array) :bool |
19 | 19 | { |
20 | - if (array() === $array) return false; |
|
21 | - return array_keys($array) !== range(0, count($array) - 1); |
|
20 | + if (array() === $array) return false; |
|
21 | + return array_keys($array) !== range(0, count($array) - 1); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | } |
180 | 180 | |
181 | 181 | |
182 | - /** |
|
182 | + /** |
|
183 | 183 | * Gets the module based on the classname |
184 | 184 | * @param string $class |
185 | 185 | * @return string |
@@ -34,8 +34,7 @@ discard block |
||
34 | 34 | $pattern = "/(.)([A-Z])/"; |
35 | 35 | $replacement = "\\1 \\2"; |
36 | 36 | $return = ($ucfirst) ? |
37 | - ucfirst(preg_replace($pattern, $replacement, $string)) : |
|
38 | - strtolower(preg_replace($pattern, $replacement, $string)); |
|
37 | + ucfirst(preg_replace($pattern, $replacement, $string)) : strtolower(preg_replace($pattern, $replacement, $string)); |
|
39 | 38 | |
40 | 39 | return ($glue !== null) ? str_replace(' ', $glue, $return) : $return; |
41 | 40 | } |
@@ -51,7 +50,7 @@ discard block |
||
51 | 50 | public static function parseAssetType(string $queryString, bool $key = false) |
52 | 51 | { |
53 | 52 | $assetParts = explode(".", strtolower($queryString)); |
54 | - if(count($assetParts) > 2){ |
|
53 | + if (count($assetParts) > 2) { |
|
55 | 54 | throw new DatastoreException("Assets are only 2 tiers deep"); |
56 | 55 | } |
57 | 56 | $asset = array_pop($assetParts); |
@@ -59,7 +58,7 @@ discard block |
||
59 | 58 | |
60 | 59 | $list = !empty($assetParts) && isset($list[$assetParts[0]]) ? $list[$assetParts[0]] : array_shift($list); |
61 | 60 | |
62 | - if(!isset($list[$asset])){ |
|
61 | + if (!isset($list[$asset])) { |
|
63 | 62 | throw new DatastoreException("Asset not found"); |
64 | 63 | } |
65 | 64 | return $key ? $list[$asset]['class'] : $list[$asset]; |
@@ -90,22 +89,22 @@ discard block |
||
90 | 89 | ); |
91 | 90 | } |
92 | 91 | |
93 | - public static function getStatusEquals($className){ |
|
92 | + public static function getStatusEquals($className) { |
|
94 | 93 | $statusEquals = self::assetInfo($className, 'status_equals'); |
95 | - if(!$statusEquals){ |
|
94 | + if (!$statusEquals) { |
|
96 | 95 | return null; |
97 | 96 | } |
98 | - $props = self::getAssetProps($className,$statusEquals); |
|
99 | - return isset($props['published'])?$props['published'] : null; |
|
97 | + $props = self::getAssetProps($className, $statusEquals); |
|
98 | + return isset($props['published']) ? $props['published'] : null; |
|
100 | 99 | } |
101 | 100 | |
102 | 101 | |
103 | - public static function getAssetProps($className, $property = null){ |
|
102 | + public static function getAssetProps($className, $property = null) { |
|
104 | 103 | $properties = self::assetInfo($className, 'properties'); |
105 | - if(!$properties){ |
|
104 | + if (!$properties) { |
|
106 | 105 | throw new DatastoreException("No Properties found for asset"); |
107 | 106 | } |
108 | - if($property){ |
|
107 | + if ($property) { |
|
109 | 108 | return isset($properties[$property]) ? $properties[$property] : null; |
110 | 109 | } |
111 | 110 | return $properties; |
@@ -123,7 +122,7 @@ discard block |
||
123 | 122 | { |
124 | 123 | $assets = array(); |
125 | 124 | $datastoreAssets = config("datastore.assets"); |
126 | - foreach($datastoreAssets as $className){ |
|
125 | + foreach ($datastoreAssets as $className) { |
|
127 | 126 | |
128 | 127 | $asset = self::getAssetItem($className); |
129 | 128 | |
@@ -131,20 +130,20 @@ discard block |
||
131 | 130 | throw new DatastoreException('Only assets of type assets should be used ' . $className); |
132 | 131 | } |
133 | 132 | |
134 | - if(!$includeChildren && $asset['is_child']){ |
|
133 | + if (!$includeChildren && $asset['is_child']) { |
|
135 | 134 | continue; |
136 | 135 | } |
137 | 136 | |
138 | - if($asset['children'] && $includeChildren && !in_array($asset['children'], $datastoreAssets)){ |
|
139 | - $child = self::getAssetItem($asset['children']); |
|
137 | + if ($asset['children'] && $includeChildren && !in_array($asset['children'], $datastoreAssets)) { |
|
138 | + $child = self::getAssetItem($asset['children']); |
|
140 | 139 | if (self::assetNamespace($child['class']) !== 'asset') { |
141 | 140 | throw new DatastoreException('Only assets of type assets should be used ' . $child['class']); |
142 | 141 | } |
143 | 142 | |
144 | 143 | if ($grouped) |
145 | 144 | { |
146 | - $mod = Helpers::getModule($child['class']); |
|
147 | - $assets[strtolower($mod)][strtolower($child['shortname'])] = $child; |
|
145 | + $mod = Helpers::getModule($child['class']); |
|
146 | + $assets[strtolower($mod)][strtolower($child['shortname'])] = $child; |
|
148 | 147 | } |
149 | 148 | else |
150 | 149 | { |
@@ -155,8 +154,8 @@ discard block |
||
155 | 154 | |
156 | 155 | if ($grouped) |
157 | 156 | { |
158 | - $mod = Helpers::getModule($className); |
|
159 | - $assets[strtolower($mod)][strtolower($asset['shortname'])] = $asset; |
|
157 | + $mod = Helpers::getModule($className); |
|
158 | + $assets[strtolower($mod)][strtolower($asset['shortname'])] = $asset; |
|
160 | 159 | } |
161 | 160 | else |
162 | 161 | { |
@@ -167,9 +166,9 @@ discard block |
||
167 | 166 | } |
168 | 167 | |
169 | 168 | ksort($assets); |
170 | - if($grouped){ |
|
171 | - foreach($assets as &$group){ |
|
172 | - uasort($group, function ($a , $b) { |
|
169 | + if ($grouped) { |
|
170 | + foreach ($assets as &$group) { |
|
171 | + uasort($group, function($a, $b) { |
|
173 | 172 | return strcmp($a['name'], $b['name']); |
174 | 173 | }); |
175 | 174 | } |
@@ -189,7 +188,7 @@ discard block |
||
189 | 188 | $parts = explode('\\', $class); |
190 | 189 | array_pop($parts); |
191 | 190 | $ns = ''; |
192 | - if(end($parts) !== 'Ams'){ |
|
191 | + if (end($parts) !== 'Ams') { |
|
193 | 192 | $ns = ucfirst(array_pop($parts)); |
194 | 193 | } |
195 | 194 | |
@@ -217,7 +216,7 @@ discard block |
||
217 | 216 | { |
218 | 217 | $mod = self::getModule($className); |
219 | 218 | $sn = Self::assetInfo($className, 'shortname'); |
220 | - return !empty($mod) ? strtolower($mod .'.' . $sn) : strtolower($sn); |
|
219 | + return !empty($mod) ? strtolower($mod . '.' . $sn) : strtolower($sn); |
|
221 | 220 | } |
222 | 221 | |
223 | 222 | /** |
@@ -257,15 +256,15 @@ discard block |
||
257 | 256 | } |
258 | 257 | $fp = fopen(FCPATH . $file, 'r'); |
259 | 258 | |
260 | - $class = $buffer = ''; |
|
261 | - $i = 0; |
|
259 | + $class = $buffer = ''; |
|
260 | + $i = 0; |
|
262 | 261 | while (!$class) |
263 | 262 | { |
264 | 263 | if (feof($fp)) |
265 | 264 | break; |
266 | 265 | |
267 | - $buffer .= fread($fp, 512); |
|
268 | - $tokens = token_get_all($buffer); |
|
266 | + $buffer .= fread($fp, 512); |
|
267 | + $tokens = token_get_all($buffer); |
|
269 | 268 | |
270 | 269 | if (strpos($buffer, '{') === false) |
271 | 270 | continue; |
@@ -17,7 +17,9 @@ discard block |
||
17 | 17 | */ |
18 | 18 | public static function isAssocArray(array $array) :bool |
19 | 19 | { |
20 | - if (array() === $array) return false; |
|
20 | + if (array() === $array) { |
|
21 | + return false; |
|
22 | + } |
|
21 | 23 | return array_keys($array) !== range(0, count($array) - 1); |
22 | 24 | } |
23 | 25 | |
@@ -145,8 +147,7 @@ discard block |
||
145 | 147 | { |
146 | 148 | $mod = Helpers::getModule($child['class']); |
147 | 149 | $assets[strtolower($mod)][strtolower($child['shortname'])] = $child; |
148 | - } |
|
149 | - else |
|
150 | + } else |
|
150 | 151 | { |
151 | 152 | $assets[strtolower($child['shortname'])] = $child; |
152 | 153 | } |
@@ -157,8 +158,7 @@ discard block |
||
157 | 158 | { |
158 | 159 | $mod = Helpers::getModule($className); |
159 | 160 | $assets[strtolower($mod)][strtolower($asset['shortname'])] = $asset; |
160 | - } |
|
161 | - else |
|
161 | + } else |
|
162 | 162 | { |
163 | 163 | $assets[strtolower($asset['shortname'])] = $asset; |
164 | 164 | } |
@@ -261,14 +261,16 @@ discard block |
||
261 | 261 | $i = 0; |
262 | 262 | while (!$class) |
263 | 263 | { |
264 | - if (feof($fp)) |
|
265 | - break; |
|
264 | + if (feof($fp)) { |
|
265 | + break; |
|
266 | + } |
|
266 | 267 | |
267 | 268 | $buffer .= fread($fp, 512); |
268 | 269 | $tokens = token_get_all($buffer); |
269 | 270 | |
270 | - if (strpos($buffer, '{') === false) |
|
271 | - continue; |
|
271 | + if (strpos($buffer, '{') === false) { |
|
272 | + continue; |
|
273 | + } |
|
272 | 274 | |
273 | 275 | for (; $i < count($tokens); $i++) |
274 | 276 | { |