@@ -168,7 +168,7 @@ |
||
168 | 168 | /** |
169 | 169 | * Get user person like a object via email |
170 | 170 | * @param string|null $email |
171 | - * @return null|self |
|
171 | + * @return null|ActiveModel |
|
172 | 172 | */ |
173 | 173 | public static function getIdentityViaEmail(?string $email = null) |
174 | 174 | { |
@@ -5,7 +5,6 @@ |
||
5 | 5 | use Ffcms\Core\App as MainApp; |
6 | 6 | use Ffcms\Core\Arch\ActiveModel; |
7 | 7 | use Ffcms\Core\Helper\Type\Any; |
8 | -use Ffcms\Core\Helper\Type\Obj; |
|
9 | 8 | use Ffcms\Core\Helper\Type\Str; |
10 | 9 | use Ffcms\Core\Interfaces\iUser; |
11 | 10 |
@@ -50,13 +50,13 @@ discard block |
||
50 | 50 | } |
51 | 51 | |
52 | 52 | // check if id is looks like integer |
53 | - if (!Any::isInt($id) || (int)$id < 1) { |
|
53 | + if (!Any::isInt($id) || (int) $id < 1) { |
|
54 | 54 | return null; |
55 | 55 | } |
56 | 56 | |
57 | 57 | // check in memory cache object |
58 | - if (MainApp::$Memory->get('user.object.cache.' . $id) !== null) { |
|
59 | - return MainApp::$Memory->get('user.object.cache.' . $id); |
|
58 | + if (MainApp::$Memory->get('user.object.cache.'.$id) !== null) { |
|
59 | + return MainApp::$Memory->get('user.object.cache.'.$id); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | // not founded in memory? lets make query |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | ->find($id); |
65 | 65 | |
66 | 66 | // store cache and return object |
67 | - MainApp::$Memory->set('user.object.cache.' . $user->id, $user); |
|
67 | + MainApp::$Memory->set('user.object.cache.'.$user->id, $user); |
|
68 | 68 | return $user; |
69 | 69 | } |
70 | 70 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function getId(): ?int |
76 | 76 | { |
77 | - return (int)$this->id; |
|
77 | + return (int) $this->id; |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | public static function isAuth(): bool |
96 | 96 | { |
97 | 97 | // get data from session |
98 | - $sessionUserId = (int)MainApp::$Session->get('ff_user_id', 0); |
|
98 | + $sessionUserId = (int) MainApp::$Session->get('ff_user_id', 0); |
|
99 | 99 | |
100 | 100 | // check if session contains user id data |
101 | 101 | if ($sessionUserId < 1) { |
@@ -128,10 +128,10 @@ discard block |
||
128 | 128 | return false; |
129 | 129 | } |
130 | 130 | |
131 | - $find = MainApp::$Memory->get('user.counter.cache.' . $id); |
|
131 | + $find = MainApp::$Memory->get('user.counter.cache.'.$id); |
|
132 | 132 | if (!$find) { |
133 | 133 | $find = self::where('id', $id)->count(); |
134 | - MainApp::$Memory->set('user.counter.cache.' . $id, $find); |
|
134 | + MainApp::$Memory->set('user.counter.cache.'.$id, $find); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | return $find === 1; |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | */ |
232 | 232 | public function inBlacklist(?string $target = null): bool |
233 | 233 | { |
234 | - if ($target === null || (int)$target < 1) { |
|
234 | + if ($target === null || (int) $target < 1) { |
|
235 | 235 | return false; |
236 | 236 | } |
237 | 237 |
@@ -5,7 +5,6 @@ |
||
5 | 5 | |
6 | 6 | use Ffcms\Console\Command; |
7 | 7 | use Ffcms\Core\Helper\FileSystem\File; |
8 | -use Ffcms\Core\Helper\Type\Obj; |
|
9 | 8 | use Ffcms\Core\Helper\Type\Str; |
10 | 9 | use Symfony\Component\Console\Input\InputArgument; |
11 | 10 | use Symfony\Component\Console\Input\InputInterface; |
@@ -58,9 +58,9 @@ |
||
58 | 58 | // work with migration template: read & parse & save |
59 | 59 | $tpl = File::read('/Private/Carcase/Migration.tphp'); |
60 | 60 | $classContent = Str::replace(['%class%', '%table%'], [$name, $table], $tpl); |
61 | - $fullPath = $dir . $name . '-' . $suffix . '.php'; |
|
61 | + $fullPath = $dir.$name.'-'.$suffix.'.php'; |
|
62 | 62 | File::write($fullPath, $classContent); |
63 | 63 | // show success msg |
64 | - $output->write('New migration is created: ' . $fullPath); |
|
64 | + $output->write('New migration is created: '.$fullPath); |
|
65 | 65 | } |
66 | 66 | } |
67 | 67 | \ No newline at end of file |
@@ -5,10 +5,7 @@ |
||
5 | 5 | |
6 | 6 | use Apps\ActiveRecord\Migration; |
7 | 7 | use Ffcms\Console\Command; |
8 | -use Ffcms\Core\Helper\FileSystem\File; |
|
9 | 8 | use Ffcms\Core\Helper\Type\Any; |
10 | -use Ffcms\Core\Helper\Type\Obj; |
|
11 | -use Ffcms\Core\Helper\Type\Str; |
|
12 | 9 | use Ffcms\Core\Managers\MigrationsManager; |
13 | 10 | use Symfony\Component\Console\Input\InputArgument; |
14 | 11 | use Symfony\Component\Console\Input\InputInterface; |
@@ -51,7 +51,7 @@ |
||
51 | 51 | // list found migrations and ask to revert each one |
52 | 52 | $fired = false; |
53 | 53 | foreach ($search as $migration) { |
54 | - if (!$this->confirm('Are you sure to revert: ' . $migration)) { |
|
54 | + if (!$this->confirm('Are you sure to revert: '.$migration)) { |
|
55 | 55 | continue; |
56 | 56 | } |
57 | 57 | // run down migration |
@@ -3,13 +3,8 @@ |
||
3 | 3 | namespace Apps\Console; |
4 | 4 | |
5 | 5 | |
6 | -use Apps\ActiveRecord\Migration; |
|
7 | 6 | use Ffcms\Console\Command; |
8 | -use Ffcms\Core\Helper\FileSystem\File; |
|
9 | 7 | use Ffcms\Core\Helper\Type\Any; |
10 | -use Ffcms\Core\Helper\Type\Arr; |
|
11 | -use Ffcms\Core\Helper\Type\Obj; |
|
12 | -use Ffcms\Core\Helper\Type\Str; |
|
13 | 8 | use Ffcms\Core\Managers\MigrationsManager; |
14 | 9 | use Symfony\Component\Console\Input\InputArgument; |
15 | 10 | use Symfony\Component\Console\Input\InputInterface; |
@@ -51,11 +51,11 @@ |
||
51 | 51 | // require confirmation from user each ever migration file |
52 | 52 | $fired = false; |
53 | 53 | foreach ($search as $migration) { |
54 | - if (!$this->confirm('Are you sure to apply migration: ' . $migration, true)) { |
|
54 | + if (!$this->confirm('Are you sure to apply migration: '.$migration, true)) { |
|
55 | 55 | continue; |
56 | 56 | } |
57 | 57 | $manager->makeUp($migration); |
58 | - $fired = true; |
|
58 | + $fired = true; |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | if ($fired) { |
@@ -11,7 +11,6 @@ |
||
11 | 11 | use Ffcms\Core\Helper\FileSystem\Directory; |
12 | 12 | use Ffcms\Core\Helper\FileSystem\File; |
13 | 13 | use Ffcms\Core\Helper\Type\Any; |
14 | -use Ffcms\Core\Helper\Type\Obj; |
|
15 | 14 | use Ffcms\Core\Helper\Type\Str; |
16 | 15 | |
17 | 16 | /** |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | if ($this->_content->id === null) { |
60 | 60 | $this->_new = true; |
61 | 61 | if (!$this->galleryFreeId) { |
62 | - $this->galleryFreeId = '_tmp_' . Str::randomLatin(mt_rand(16, 32)); |
|
62 | + $this->galleryFreeId = '_tmp_'.Str::randomLatin(mt_rand(16, 32)); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | if (!$this->authorId) { |
@@ -94,8 +94,8 @@ discard block |
||
94 | 94 | public function rules(): array |
95 | 95 | { |
96 | 96 | $res = [ |
97 | - ['title.' . App::$Request->getLanguage(), 'required'], |
|
98 | - ['text.' . App::$Request->getLanguage(), 'required'], |
|
97 | + ['title.'.App::$Request->getLanguage(), 'required'], |
|
98 | + ['text.'.App::$Request->getLanguage(), 'required'], |
|
99 | 99 | ['text', 'used'], |
100 | 100 | ['path', 'reverse_match', '/[\/\'~`\!@#\$%\^&\*\(\)+=\{\}\[\]\|;:"\<\>,\?\\\]/'], |
101 | 101 | [['path', 'categoryId', 'authorId', 'display', 'galleryFreeId', 'title', 'important'], 'required'], |
@@ -108,9 +108,9 @@ discard block |
||
108 | 108 | ]; |
109 | 109 | |
110 | 110 | foreach (App::$Properties->get('languages') as $lang) { |
111 | - $res[] = ['title.' . $lang, 'length_max', 120, null, true, true]; |
|
112 | - $res[] = ['keywords.' . $lang, 'length_max', 150]; |
|
113 | - $res[] = ['description.' . $lang, 'length_max', 250]; |
|
111 | + $res[] = ['title.'.$lang, 'length_max', 120, null, true, true]; |
|
112 | + $res[] = ['keywords.'.$lang, 'length_max', 150]; |
|
113 | + $res[] = ['description.'.$lang, 'length_max', 250]; |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | return $res; |
@@ -166,10 +166,10 @@ discard block |
||
166 | 166 | $this->_content->meta_keywords = $this->metaKeywords; |
167 | 167 | $this->_content->meta_description = $this->metaDescription; |
168 | 168 | $this->_content->source = $this->source; |
169 | - $this->_content->important = (int)$this->important; |
|
169 | + $this->_content->important = (int) $this->important; |
|
170 | 170 | // check if rating is changed |
171 | - if ((int)$this->addRating !== 0) { |
|
172 | - $this->_content->rating += (int)$this->addRating; |
|
171 | + if ((int) $this->addRating !== 0) { |
|
172 | + $this->_content->rating += (int) $this->addRating; |
|
173 | 173 | } |
174 | 174 | // check if special comment hash is exist |
175 | 175 | if ($this->_new || Str::length($this->_content->comment_hash) < 32) { |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | } |
183 | 183 | |
184 | 184 | // save poster data |
185 | - $posterPath = '/upload/gallery/' . $this->galleryFreeId . '/orig/' . $this->poster; |
|
185 | + $posterPath = '/upload/gallery/'.$this->galleryFreeId.'/orig/'.$this->poster; |
|
186 | 186 | if (File::exist($posterPath)) { |
187 | 187 | $this->_content->poster = $this->poster; |
188 | 188 | } |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | |
218 | 218 | // move files |
219 | 219 | if ($tmpGalleryId !== $this->_content->id) { |
220 | - Directory::rename('/upload/gallery/' . $tmpGalleryId, $this->_content->id); |
|
220 | + Directory::rename('/upload/gallery/'.$tmpGalleryId, $this->_content->id); |
|
221 | 221 | } |
222 | 222 | } |
223 | 223 |
@@ -4,7 +4,6 @@ |
||
4 | 4 | |
5 | 5 | use Apps\ActiveRecord\System; |
6 | 6 | use Ffcms\Core\Arch\Model; |
7 | -use Ffcms\Core\Helper\FileSystem\File; |
|
8 | 7 | use Ffcms\Core\Helper\Type\Str; |
9 | 8 | use Ffcms\Core\Managers\MigrationsManager; |
10 | 9 |
@@ -43,7 +43,7 @@ |
||
43 | 43 | $name = Str::firstIn($fullName, '-'); |
44 | 44 | // get update version number from migration name |
45 | 45 | list($type, $obj, $version) = explode('_', $name); |
46 | - $intVersion = (int)Str::replace('.', '', $this->dbVersion); |
|
46 | + $intVersion = (int) Str::replace('.', '', $this->dbVersion); |
|
47 | 47 | // if migration version > db version - implement it |
48 | 48 | if ($version > $intVersion) { |
49 | 49 | $this->updateQueries[] = $file; |
@@ -8,7 +8,6 @@ |
||
8 | 8 | use Ffcms\Core\App; |
9 | 9 | use Ffcms\Core\Arch\Model; |
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 | use Ffcms\Core\Interfaces\iUser; |
14 | 13 |
@@ -32,7 +32,7 @@ |
||
32 | 32 | /** |
33 | 33 | * EntityContentSearch constructor. Pass search terms (query string) to model and used items to skip it by id. |
34 | 34 | * @param $terms |
35 | - * @param int|array $skipIds |
|
35 | + * @param integer $skipIds |
|
36 | 36 | * @param int|null $categoryId |
37 | 37 | */ |
38 | 38 | public function __construct($terms, $skipIds = 0, $categoryId = null) |
@@ -8,7 +8,6 @@ |
||
8 | 8 | use Ffcms\Core\Exception\NotFoundException; |
9 | 9 | use Ffcms\Core\Helper\Text; |
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 | /** |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | |
62 | 62 | $index = implode('-', $this->_skip); |
63 | 63 | // try to get this slow query from cache |
64 | - $cache = App::$Cache->getItem('entity.content.search.index.' . $index); |
|
64 | + $cache = App::$Cache->getItem('entity.content.search.index.'.$index); |
|
65 | 65 | if (!$cache->isHit()) { |
66 | 66 | $cache->set($this->makeSearch()); |
67 | 67 | $cache->expiresAfter(static::CACHE_TIME); |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | $this->items[] = [ |
95 | 95 | 'title' => $item->getLocaled('title'), |
96 | 96 | 'snippet' => Text::snippet($text), |
97 | - 'uri' => '/content/read/' . $item->getPath(), |
|
97 | + 'uri' => '/content/read/'.$item->getPath(), |
|
98 | 98 | 'thumb' => $item->getPosterThumbUri() |
99 | 99 | ]; |
100 | 100 | } |
@@ -9,7 +9,6 @@ |
||
9 | 9 | use Ffcms\Core\Helper\FileSystem\Directory; |
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 Gregwar\Image\Image; |
15 | 14 |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
47 | - * Set default values from database record |
|
48 | - */ |
|
47 | + * Set default values from database record |
|
48 | + */ |
|
49 | 49 | public function before() |
50 | 50 | { |
51 | 51 | // set data from db record |
@@ -85,9 +85,9 @@ discard block |
||
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
88 | - * Form labels |
|
89 | - * @return array |
|
90 | - */ |
|
88 | + * Form labels |
|
89 | + * @return array |
|
90 | + */ |
|
91 | 91 | public function labels(): array |
92 | 92 | { |
93 | 93 | return [ |
@@ -100,9 +100,9 @@ discard block |
||
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
103 | - * Content update form validation rules |
|
104 | - * @return array |
|
105 | - */ |
|
103 | + * Content update form validation rules |
|
104 | + * @return array |
|
105 | + */ |
|
106 | 106 | public function rules(): array |
107 | 107 | { |
108 | 108 | $r = [ |
@@ -57,13 +57,13 @@ discard block |
||
57 | 57 | // set current user id |
58 | 58 | $this->authorId = App::$User->identity()->getId(); |
59 | 59 | // set true if it is a new content item |
60 | - if ($this->_record->id === null || (int)$this->_record->id < 1) { |
|
60 | + if ($this->_record->id === null || (int) $this->_record->id < 1) { |
|
61 | 61 | $this->_new = true; |
62 | 62 | } |
63 | 63 | |
64 | 64 | // set random path slug if not defined |
65 | 65 | if ($this->path === null || Str::likeEmpty($this->path)) { |
66 | - $randPath = date('d-m-Y') . '-' . Str::randomLatin(mt_rand(8, 12)); |
|
66 | + $randPath = date('d-m-Y').'-'.Str::randomLatin(mt_rand(8, 12)); |
|
67 | 67 | $this->path = Str::lowerCase($randPath); |
68 | 68 | } |
69 | 69 | } |
@@ -107,21 +107,21 @@ discard block |
||
107 | 107 | { |
108 | 108 | $r = [ |
109 | 109 | [['path', 'categoryId'], 'required'], |
110 | - ['title.' . App::$Request->getLanguage(), 'required'], |
|
111 | - ['text.' . App::$Request->getLanguage(), 'required', null, true, true], |
|
110 | + ['title.'.App::$Request->getLanguage(), 'required'], |
|
111 | + ['text.'.App::$Request->getLanguage(), 'required', null, true, true], |
|
112 | 112 | ['text', 'used', null, true, true], |
113 | 113 | ['path', 'direct_match', '/^[a-zA-Z0-9\-]+$/'], |
114 | 114 | ['categoryId', 'in', $this->categoryIds()], |
115 | 115 | ['path', 'Apps\Model\Front\Content\FormNarrowContentUpdate::validatePath'], |
116 | 116 | ['poster', 'used'], |
117 | 117 | ['poster', 'isFile', ['jpg', 'png', 'gif', 'jpeg']], |
118 | - ['poster', 'sizeFile', (int)$this->_configs['gallerySize'] * 1024] // in bytes |
|
118 | + ['poster', 'sizeFile', (int) $this->_configs['gallerySize'] * 1024] // in bytes |
|
119 | 119 | ]; |
120 | 120 | |
121 | 121 | foreach (App::$Properties->get('languages') as $lang) { |
122 | - $r[] = ['title.' . $lang, 'length_max', 120, null, true, true]; |
|
123 | - $r[] = ['keywords.' . $lang, 'length_max', 150]; |
|
124 | - $r[] = ['description.' . $lang, 'length_max', 250]; |
|
122 | + $r[] = ['title.'.$lang, 'length_max', 120, null, true, true]; |
|
123 | + $r[] = ['keywords.'.$lang, 'length_max', 150]; |
|
124 | + $r[] = ['description.'.$lang, 'length_max', 250]; |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | return $r; |
@@ -147,9 +147,9 @@ discard block |
||
147 | 147 | $this->_record->title = $this->title; |
148 | 148 | $this->_record->text = $this->text; |
149 | 149 | $this->_record->path = $this->path; |
150 | - $this->_record->category_id = (int)$this->categoryId; |
|
150 | + $this->_record->category_id = (int) $this->categoryId; |
|
151 | 151 | $this->_record->display = 0; // set to premoderation |
152 | - $this->_record->author_id = (int)$this->authorId; |
|
152 | + $this->_record->author_id = (int) $this->authorId; |
|
153 | 153 | if ($this->_new) { |
154 | 154 | $this->_record->comment_hash = $this->generateCommentHash(); |
155 | 155 | } |
@@ -159,8 +159,8 @@ discard block |
||
159 | 159 | // work with poster data |
160 | 160 | if ($this->poster !== null) { |
161 | 161 | // lets move poster from tmp to gallery |
162 | - $originDir = '/upload/gallery/' . $this->_record->id . '/orig/'; |
|
163 | - $thumbDir = '/upload/gallery/' . $this->_record->id . '/thumb/'; |
|
162 | + $originDir = '/upload/gallery/'.$this->_record->id.'/orig/'; |
|
163 | + $thumbDir = '/upload/gallery/'.$this->_record->id.'/thumb/'; |
|
164 | 164 | if (!Directory::exist($originDir)) { |
165 | 165 | Directory::create($originDir); |
166 | 166 | } |
@@ -169,17 +169,17 @@ discard block |
||
169 | 169 | Directory::create($thumbDir); |
170 | 170 | } |
171 | 171 | |
172 | - $fileName = App::$Security->simpleHash($this->poster->getClientOriginalName() . $this->poster->getSize()); |
|
173 | - $newFullName = $fileName . '.' . $this->poster->guessExtension(); |
|
172 | + $fileName = App::$Security->simpleHash($this->poster->getClientOriginalName().$this->poster->getSize()); |
|
173 | + $newFullName = $fileName.'.'.$this->poster->guessExtension(); |
|
174 | 174 | // move poster to upload gallery directory |
175 | 175 | $this->poster->move(Normalize::diskFullPath($originDir), $newFullName); |
176 | 176 | // initialize image resizer |
177 | 177 | $thumb = new Image(); |
178 | - $thumb->setCacheDir(root . '/Private/Cache/images'); |
|
178 | + $thumb->setCacheDir(root.'/Private/Cache/images'); |
|
179 | 179 | |
180 | 180 | // open original file, resize it and save |
181 | - $thumbSaveName = Normalize::diskFullPath($thumbDir) . '/' . $fileName . '.jpg'; |
|
182 | - $thumb->open(Normalize::diskFullPath($originDir) . DIRECTORY_SEPARATOR . $newFullName) |
|
181 | + $thumbSaveName = Normalize::diskFullPath($thumbDir).'/'.$fileName.'.jpg'; |
|
182 | + $thumb->open(Normalize::diskFullPath($originDir).DIRECTORY_SEPARATOR.$newFullName) |
|
183 | 183 | ->cropResize($this->_configs['galleryResize']) |
184 | 184 | ->save($thumbSaveName, 'jpg', 90); |
185 | 185 | $thumb = null; |