@@ -32,7 +32,7 @@ |
||
32 | 32 | $connector = new \elFinderConnector(new \elFinder([ |
33 | 33 | 'locale' => '', |
34 | 34 | 'roots' => [ |
35 | - ['driver' => 'LocalFileSystem', 'path' => root . '/upload/', 'URL' => App::$Alias->scriptUrl . '/upload/'] |
|
35 | + ['driver' => 'LocalFileSystem', 'path' => root.'/upload/', 'URL' => App::$Alias->scriptUrl.'/upload/'] |
|
36 | 36 | ] |
37 | 37 | ])); |
38 | 38 |
@@ -33,12 +33,12 @@ discard block |
||
33 | 33 | parent::before(); |
34 | 34 | $configs = AppRecord::getConfigs('app', 'Content'); |
35 | 35 | // prevent null-type config data |
36 | - if ((int)$configs['gallerySize'] > 0) { |
|
37 | - $this->maxSize = (int)$configs['gallerySize'] * 1024; |
|
36 | + if ((int) $configs['gallerySize'] > 0) { |
|
37 | + $this->maxSize = (int) $configs['gallerySize'] * 1024; |
|
38 | 38 | } |
39 | 39 | |
40 | - if ((int)$configs['galleryResize'] > 0) { |
|
41 | - $this->maxResize = (int)$configs['galleryResize']; |
|
40 | + if ((int) $configs['galleryResize'] > 0) { |
|
41 | + $this->maxResize = (int) $configs['galleryResize']; |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | |
@@ -116,8 +116,8 @@ discard block |
||
116 | 116 | } |
117 | 117 | |
118 | 118 | // check if directory exist |
119 | - if (!Directory::exist('/upload/gallery/' . $id)) { |
|
120 | - Directory::create('/upload/gallery/' . $id); |
|
119 | + if (!Directory::exist('/upload/gallery/'.$id)) { |
|
120 | + Directory::create('/upload/gallery/'.$id); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | // get file object |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | |
130 | 130 | // check file size |
131 | 131 | if ($file->getSize() < 1 || $file->getSize() > $this->maxSize) { |
132 | - throw new ForbiddenException(__('File size is too big. Max size: %size%kb', ['size' => intval($this->maxSize/1024)])); |
|
132 | + throw new ForbiddenException(__('File size is too big. Max size: %size%kb', ['size' => intval($this->maxSize / 1024)])); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | // check file extension |
@@ -138,37 +138,37 @@ discard block |
||
138 | 138 | } |
139 | 139 | |
140 | 140 | // create origin directory |
141 | - $originPath = '/upload/gallery/' . $id . '/orig/'; |
|
141 | + $originPath = '/upload/gallery/'.$id.'/orig/'; |
|
142 | 142 | if (!Directory::exist($originPath)) { |
143 | 143 | Directory::create($originPath); |
144 | 144 | } |
145 | 145 | |
146 | 146 | // lets make a new file name |
147 | - $fileName = App::$Security->simpleHash($file->getFilename() . $file->getSize()); |
|
148 | - $fileNewName = $fileName . '.' . $file->guessExtension(); |
|
147 | + $fileName = App::$Security->simpleHash($file->getFilename().$file->getSize()); |
|
148 | + $fileNewName = $fileName.'.'.$file->guessExtension(); |
|
149 | 149 | // save file from tmp to gallery origin directory |
150 | 150 | $file->move(Normalize::diskFullPath($originPath), $fileNewName); |
151 | 151 | |
152 | 152 | // lets resize preview image for it |
153 | - $thumbPath = '/upload/gallery/' . $id . '/thumb/'; |
|
153 | + $thumbPath = '/upload/gallery/'.$id.'/thumb/'; |
|
154 | 154 | if (!Directory::exist($thumbPath)) { |
155 | 155 | Directory::create($thumbPath); |
156 | 156 | } |
157 | 157 | |
158 | 158 | $thumb = new Image(); |
159 | - $thumb->setCacheDir(root . '/Private/Cache/images'); |
|
159 | + $thumb->setCacheDir(root.'/Private/Cache/images'); |
|
160 | 160 | |
161 | 161 | // open original file, resize it and save |
162 | - $thumbSaveName = Normalize::diskFullPath($thumbPath) . '/' . $fileName . '.jpg'; |
|
163 | - $thumb->open(Normalize::diskFullPath($originPath) . DIRECTORY_SEPARATOR . $fileNewName) |
|
162 | + $thumbSaveName = Normalize::diskFullPath($thumbPath).'/'.$fileName.'.jpg'; |
|
163 | + $thumb->open(Normalize::diskFullPath($originPath).DIRECTORY_SEPARATOR.$fileNewName) |
|
164 | 164 | ->cropResize($this->maxResize) |
165 | 165 | ->save($thumbSaveName, 'jpg', 90); |
166 | 166 | $thumb = null; |
167 | 167 | |
168 | 168 | // dont ask me why there is 2nd lvl array (can contains multiply items to frontend response) |
169 | 169 | $output = [ |
170 | - 'thumbnailUrl' => '/upload/gallery/' . $id . '/thumb/' . $fileName . '.jpg', |
|
171 | - 'url' => '/upload/gallery/' . $id . '/orig/' . $fileNewName, |
|
170 | + 'thumbnailUrl' => '/upload/gallery/'.$id.'/thumb/'.$fileName.'.jpg', |
|
171 | + 'url' => '/upload/gallery/'.$id.'/orig/'.$fileNewName, |
|
172 | 172 | 'name' => $fileNewName |
173 | 173 | ]; |
174 | 174 | |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | throw new NativeException('Permission denied'); |
198 | 198 | } |
199 | 199 | |
200 | - $thumbDir = Normalize::diskFullPath('/upload/gallery/' . $id . '/orig/'); |
|
200 | + $thumbDir = Normalize::diskFullPath('/upload/gallery/'.$id.'/orig/'); |
|
201 | 201 | if (!Directory::exist($thumbDir)) { |
202 | 202 | throw new NotFoundException('Nothing found'); |
203 | 203 | } |
@@ -212,8 +212,8 @@ discard block |
||
212 | 212 | $fileExt = Str::lastIn($file, '.'); |
213 | 213 | $fileName = Str::sub($file, 0, -Str::length($fileExt)); |
214 | 214 | $output[] = [ |
215 | - 'thumbnailUrl' => '/upload/gallery/' . $id . '/thumb/' . $fileName . '.jpg', |
|
216 | - 'url' => '/upload/gallery/' . $id . '/orig/' . $file, |
|
215 | + 'thumbnailUrl' => '/upload/gallery/'.$id.'/thumb/'.$fileName.'.jpg', |
|
216 | + 'url' => '/upload/gallery/'.$id.'/orig/'.$file, |
|
217 | 217 | 'name' => $file |
218 | 218 | ]; |
219 | 219 | } |
@@ -245,8 +245,8 @@ discard block |
||
245 | 245 | } |
246 | 246 | |
247 | 247 | // generate path |
248 | - $thumb = '/upload/gallery/' . $id . '/thumb/' . $fileName . '.jpg'; |
|
249 | - $full = '/upload/gallery/' . $id . '/orig/' . $file; |
|
248 | + $thumb = '/upload/gallery/'.$id.'/thumb/'.$fileName.'.jpg'; |
|
249 | + $full = '/upload/gallery/'.$id.'/orig/'.$file; |
|
250 | 250 | |
251 | 251 | // check if file exists and remove |
252 | 252 | if (File::exist($thumb) || File::exist($full)) { |
@@ -26,12 +26,12 @@ |
||
26 | 26 | */ |
27 | 27 | public static function get($role_id) |
28 | 28 | { |
29 | - $role = MainApp::$Memory->get('user.role.cache.' . $role_id); |
|
29 | + $role = MainApp::$Memory->get('user.role.cache.'.$role_id); |
|
30 | 30 | |
31 | 31 | // not founded in cache |
32 | 32 | if ($role === null) { |
33 | 33 | $role = self::find($role_id); |
34 | - MainApp::$Memory->set('user.role.cache.' . $role_id, $role); |
|
34 | + MainApp::$Memory->set('user.role.cache.'.$role_id, $role); |
|
35 | 35 | } |
36 | 36 | return $role; |
37 | 37 | } |
@@ -37,15 +37,15 @@ discard block |
||
37 | 37 | } |
38 | 38 | |
39 | 39 | // convert id to real integer |
40 | - $user_id = (int)$user_id; |
|
40 | + $user_id = (int) $user_id; |
|
41 | 41 | |
42 | 42 | if (!Obj::isInt($user_id) || $user_id < 1) { |
43 | 43 | return null; |
44 | 44 | } |
45 | 45 | |
46 | 46 | // check in memory cache object |
47 | - if (MainApp::$Memory->get('user.object.cache.' . $user_id) !== null) { |
|
48 | - return MainApp::$Memory->get('user.object.cache.' . $user_id); |
|
47 | + if (MainApp::$Memory->get('user.object.cache.'.$user_id) !== null) { |
|
48 | + return MainApp::$Memory->get('user.object.cache.'.$user_id); |
|
49 | 49 | } |
50 | 50 | // not founded in memory? lets make query |
51 | 51 | $user = self::find($user_id); |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | } |
56 | 56 | |
57 | 57 | // store cache and return object |
58 | - MainApp::$Memory->set('user.object.cache.' . $user->id, $user); |
|
58 | + MainApp::$Memory->set('user.object.cache.'.$user->id, $user); |
|
59 | 59 | return $user; |
60 | 60 | } |
61 | 61 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | */ |
66 | 66 | public function getId() |
67 | 67 | { |
68 | - return (int)$this->id; |
|
68 | + return (int) $this->id; |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | { |
88 | 88 | // get data from session |
89 | 89 | $session_token = MainApp::$Session->get('ff_user_token', null); |
90 | - $session_id = (int)MainApp::$Session->get('ff_user_id', 0); |
|
90 | + $session_id = (int) MainApp::$Session->get('ff_user_id', 0); |
|
91 | 91 | |
92 | 92 | // validate session data |
93 | 93 | if (null === $session_token || $session_id < 1 || Str::length($session_token) < 64) { |
@@ -121,12 +121,12 @@ discard block |
||
121 | 121 | } |
122 | 122 | |
123 | 123 | // convert id to real integer |
124 | - $id = (int)$id; |
|
124 | + $id = (int) $id; |
|
125 | 125 | |
126 | - $find = MainApp::$Memory->get('user.counter.cache.' . $id); |
|
126 | + $find = MainApp::$Memory->get('user.counter.cache.'.$id); |
|
127 | 127 | if ($find === null) { |
128 | 128 | $find = self::where('id', '=', $id)->count(); |
129 | - MainApp::$Memory->set('user.counter.cache.' . $id, $find); |
|
129 | + MainApp::$Memory->set('user.counter.cache.'.$id, $find); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | return $find === 1; |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | } |
47 | 47 | |
48 | 48 | // check in cache |
49 | - if (MainApp::$Memory->get('profile.object.cache.' . $user_id) !== null) { |
|
50 | - return MainApp::$Memory->get('profile.object.cache.' . $user_id); |
|
49 | + if (MainApp::$Memory->get('profile.object.cache.'.$user_id) !== null) { |
|
50 | + return MainApp::$Memory->get('profile.object.cache.'.$user_id); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | // find row |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | |
61 | 61 | $object = $profile->first(); |
62 | 62 | |
63 | - MainApp::$Memory->set('profile.object.cache.' . $user_id, $object); |
|
63 | + MainApp::$Memory->set('profile.object.cache.'.$user_id, $object); |
|
64 | 64 | return $object; |
65 | 65 | } |
66 | 66 | |
@@ -71,17 +71,17 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public function getAvatarUrl($type = 'small') |
73 | 73 | { |
74 | - $default = '/upload/user/avatar/' . $type . '/default.jpg'; |
|
74 | + $default = '/upload/user/avatar/'.$type.'/default.jpg'; |
|
75 | 75 | if (!Arr::in($type, ['small', 'big', 'medium'])) { |
76 | - return MainApp::$Alias->scriptUrl . $default; |
|
76 | + return MainApp::$Alias->scriptUrl.$default; |
|
77 | 77 | } |
78 | 78 | |
79 | - $route = '/upload/user/avatar/' . $type . '/' . $this->user_id . '.jpg'; |
|
79 | + $route = '/upload/user/avatar/'.$type.'/'.$this->user_id.'.jpg'; |
|
80 | 80 | if (File::exist($route)) { |
81 | - return MainApp::$Alias->scriptUrl . $route . '?mtime=' . File::mTime($route); |
|
81 | + return MainApp::$Alias->scriptUrl.$route.'?mtime='.File::mTime($route); |
|
82 | 82 | } |
83 | 83 | |
84 | - return MainApp::$Alias->scriptUrl . $default; |
|
84 | + return MainApp::$Alias->scriptUrl.$default; |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | { |
93 | 93 | $userNick = $this->nick; |
94 | 94 | if ($userNick === null || Str::likeEmpty($userNick)) { |
95 | - $userNick = 'id' . $this->id; |
|
95 | + $userNick = 'id'.$this->id; |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | return $userNick; |
@@ -27,12 +27,12 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public static function getByPath($path = '') |
29 | 29 | { |
30 | - if (MainApp::$Memory->get('cache.content.category.path.' . $path) !== null) { |
|
31 | - return MainApp::$Memory->get('cache.content.category.path.' . $path); |
|
30 | + if (MainApp::$Memory->get('cache.content.category.path.'.$path) !== null) { |
|
31 | + return MainApp::$Memory->get('cache.content.category.path.'.$path); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | $record = self::where('path', '=', $path)->first(); |
35 | - MainApp::$Memory->set('cache.content.category.path.' . $path, $record); |
|
35 | + MainApp::$Memory->set('cache.content.category.path.'.$path, $record); |
|
36 | 36 | return $record; |
37 | 37 | } |
38 | 38 | |
@@ -43,12 +43,12 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public static function getById($id) |
45 | 45 | { |
46 | - if (MainApp::$Memory->get('cache.content.category.id.' . $id) !== null) { |
|
47 | - return MainApp::$Memory->get('cache.content.category.id.' . $id); |
|
46 | + if (MainApp::$Memory->get('cache.content.category.id.'.$id) !== null) { |
|
47 | + return MainApp::$Memory->get('cache.content.category.id.'.$id); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | $record = self::find($id); |
51 | - MainApp::$Memory->set('cache.content.category.id.' . $id, $record); |
|
51 | + MainApp::$Memory->set('cache.content.category.id.'.$id, $record); |
|
52 | 52 | return $record; |
53 | 53 | } |
54 | 54 | |
@@ -82,12 +82,12 @@ discard block |
||
82 | 82 | } else { |
83 | 83 | // set level marker based on slashes count in pathway |
84 | 84 | $slashCount = Str::entryCount($path, '/'); |
85 | - for ($i=-1; $i <= $slashCount; $i++) { |
|
85 | + for ($i = -1; $i <= $slashCount; $i++) { |
|
86 | 86 | $title .= '--'; |
87 | 87 | } |
88 | 88 | } |
89 | 89 | // add canonical title from db |
90 | - $title .= ' ' . Serialize::getDecodeLocale($data->title); |
|
90 | + $title .= ' '.Serialize::getDecodeLocale($data->title); |
|
91 | 91 | // set response as array [id => title, ... ] |
92 | 92 | $response[$data->id] = $title; |
93 | 93 | } |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | |
149 | 149 | $scriptVersion = $this->getScriptVersion(); |
150 | 150 | |
151 | - return $scriptVersion === (float)$this->version; |
|
151 | + return $scriptVersion === (float) $this->version; |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |
@@ -157,16 +157,16 @@ discard block |
||
157 | 157 | */ |
158 | 158 | public function getScriptVersion() |
159 | 159 | { |
160 | - $class = 'Apps\Controller\Admin\\' . $this->sys_name; |
|
160 | + $class = 'Apps\Controller\Admin\\'.$this->sys_name; |
|
161 | 161 | if (!class_exists($class)) { |
162 | 162 | return false; |
163 | 163 | } |
164 | 164 | |
165 | - if (!defined($class . '::VERSION')) { |
|
165 | + if (!defined($class.'::VERSION')) { |
|
166 | 166 | return false; |
167 | 167 | } |
168 | 168 | |
169 | - return (float)constant($class . '::VERSION'); |
|
169 | + return (float) constant($class.'::VERSION'); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | } |
173 | 173 | \ No newline at end of file |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | } |
96 | 96 | |
97 | 97 | // build path and check is file exists on disk |
98 | - $path = '/upload/gallery/' . $this->id . '/orig/' . $pName; |
|
98 | + $path = '/upload/gallery/'.$this->id.'/orig/'.$pName; |
|
99 | 99 | if (!File::exist($path)) { |
100 | 100 | return null; |
101 | 101 | } |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | |
117 | 117 | // remove extension, thumbs always in jpeg ;D |
118 | 118 | $pName = Str::cleanExtension($pName); |
119 | - $path = '/upload/gallery/' . $this->id . '/thumb/' . $pName . '.jpg'; |
|
119 | + $path = '/upload/gallery/'.$this->id.'/thumb/'.$pName.'.jpg'; |
|
120 | 120 | |
121 | 121 | if (!File::exist($path)) { |
122 | 122 | return null; |
@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | } |
33 | 33 | // check cache is defined |
34 | 34 | if ($this->cache === null || !Obj::isLikeInt($this->cache)) { |
35 | - $this->cache = (int)$cfg['cache']; |
|
35 | + $this->cache = (int) $cfg['cache']; |
|
36 | 36 | } |
37 | 37 | // check item count is defined |
38 | 38 | if ($this->count === null || !Obj::isLikeInt($this->count)) { |
39 | - $this->count = (int)$cfg['count']; |
|
39 | + $this->count = (int) $cfg['count']; |
|
40 | 40 | } |
41 | 41 | } |
42 | 42 | |
@@ -56,12 +56,12 @@ discard block |
||
56 | 56 | $query = $this->makeQuery(); |
57 | 57 | } else { |
58 | 58 | // try get query result from cache |
59 | - $query = App::$Cache->get('widget.newcontent.' . $cacheHash); |
|
59 | + $query = App::$Cache->get('widget.newcontent.'.$cacheHash); |
|
60 | 60 | if ($query === null) { |
61 | 61 | // if query is not cached make it |
62 | 62 | $query = $this->makeQuery(); |
63 | 63 | // and save result to cache |
64 | - App::$Cache->set('widget.newcontent.' . $cacheHash, $query, $this->cache); |
|
64 | + App::$Cache->set('widget.newcontent.'.$cacheHash, $query, $this->cache); |
|
65 | 65 | } |
66 | 66 | } |
67 | 67 |