@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Web\Factory\Action; |
6 | 6 |
@@ -33,24 +33,24 @@ |
||
33 | 33 | */ |
34 | 34 | public function __invoke($menuItem) |
35 | 35 | { |
36 | - if($menuItem['href']) { |
|
37 | - return strpos($menuItem['href'], 'http') === 0 ? $menuItem['href'] : '/' . $menuItem['href']; |
|
36 | + if ($menuItem[ 'href' ]) { |
|
37 | + return strpos($menuItem[ 'href' ], 'http') === 0 ? $menuItem[ 'href' ] : '/' . $menuItem[ 'href' ]; |
|
38 | 38 | } |
39 | - elseif($menuItem['article_slug']) { |
|
39 | + elseif ($menuItem[ 'article_slug' ]) { |
|
40 | 40 | // @todo refactor - break categories into single category per article... |
41 | - $category = $this->postService->getCategories($menuItem['article_id'])->current(); |
|
41 | + $category = $this->postService->getCategories($menuItem[ 'article_id' ])->current(); |
|
42 | 42 | |
43 | - if($category){ |
|
44 | - $params = ['segment_1' => $category->slug, 'segment_2' => $menuItem['article_slug']]; |
|
43 | + if ($category) { |
|
44 | + $params = [ 'segment_1' => $category->slug, 'segment_2' => $menuItem[ 'article_slug' ] ]; |
|
45 | 45 | } |
46 | - else{ |
|
47 | - $params = ['segment_1' => $menuItem['article_slug']]; |
|
46 | + else { |
|
47 | + $params = [ 'segment_1' => $menuItem[ 'article_slug' ] ]; |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | return $this->url->__invoke('post', $params); |
51 | 51 | } |
52 | - elseif($menuItem['category_slug']) { |
|
53 | - return $this->url->__invoke('category', ['category' => $menuItem['category_slug']]); |
|
52 | + elseif ($menuItem[ 'category_slug' ]) { |
|
53 | + return $this->url->__invoke('category', [ 'category' => $menuItem[ 'category_slug' ] ]); |
|
54 | 54 | } |
55 | 55 | else { |
56 | 56 | return '#'; |
@@ -35,24 +35,20 @@ |
||
35 | 35 | { |
36 | 36 | if($menuItem['href']) { |
37 | 37 | return strpos($menuItem['href'], 'http') === 0 ? $menuItem['href'] : '/' . $menuItem['href']; |
38 | - } |
|
39 | - elseif($menuItem['article_slug']) { |
|
38 | + } elseif($menuItem['article_slug']) { |
|
40 | 39 | // @todo refactor - break categories into single category per article... |
41 | 40 | $category = $this->postService->getCategories($menuItem['article_id'])->current(); |
42 | 41 | |
43 | 42 | if($category){ |
44 | 43 | $params = ['segment_1' => $category->slug, 'segment_2' => $menuItem['article_slug']]; |
45 | - } |
|
46 | - else{ |
|
44 | + } else{ |
|
47 | 45 | $params = ['segment_1' => $menuItem['article_slug']]; |
48 | 46 | } |
49 | 47 | |
50 | 48 | return $this->url->__invoke('post', $params); |
51 | - } |
|
52 | - elseif($menuItem['category_slug']) { |
|
49 | + } elseif($menuItem['category_slug']) { |
|
53 | 50 | return $this->url->__invoke('category', ['category' => $menuItem['category_slug']]); |
54 | - } |
|
55 | - else { |
|
51 | + } else { |
|
56 | 52 | return '#'; |
57 | 53 | } |
58 | 54 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Web\Action; |
6 | 6 |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Web\Action; |
6 | 6 |
@@ -12,36 +12,36 @@ |
||
12 | 12 | |
13 | 13 | public function getInputFilter() |
14 | 14 | { |
15 | - if(!$this->inputFilter) { |
|
15 | + if (!$this->inputFilter) { |
|
16 | 16 | $inputFilter = new InputFilter(); |
17 | 17 | |
18 | 18 | $inputFilter->add([ |
19 | 19 | 'name' => 'slug', |
20 | 20 | 'required' => true, |
21 | - 'filters' => [['name' => 'StringTrim', 'options' => ['charlist' => '/']]], |
|
21 | + 'filters' => [ [ 'name' => 'StringTrim', 'options' => [ 'charlist' => '/' ] ] ], |
|
22 | 22 | 'validators' => [ |
23 | - ['name' => 'NotEmpty'], |
|
24 | - ['name' => 'StringLength', 'options' => ['min' => 2, 'max' => 100]], |
|
23 | + [ 'name' => 'NotEmpty' ], |
|
24 | + [ 'name' => 'StringLength', 'options' => [ 'min' => 2, 'max' => 100 ] ], |
|
25 | 25 | ], |
26 | 26 | ]); |
27 | 27 | |
28 | 28 | $inputFilter->add([ |
29 | 29 | 'name' => 'published_at', |
30 | 30 | 'required' => true, |
31 | - 'filters' => [['name' => 'StringTrim']], |
|
32 | - 'validators' => [['name' => 'NotEmpty'], ['name' => 'Date', 'options' => ['format' => 'Y-m-d H:i:s']]] |
|
31 | + 'filters' => [ [ 'name' => 'StringTrim' ] ], |
|
32 | + 'validators' => [ [ 'name' => 'NotEmpty' ], [ 'name' => 'Date', 'options' => [ 'format' => 'Y-m-d H:i:s' ] ] ] |
|
33 | 33 | ]); |
34 | 34 | |
35 | 35 | $inputFilter->add([ |
36 | 36 | 'name' => 'status', |
37 | 37 | 'required' => false, |
38 | - 'filters' => [['name' => 'Boolean']], |
|
38 | + 'filters' => [ [ 'name' => 'Boolean' ] ], |
|
39 | 39 | ]); |
40 | 40 | |
41 | 41 | $inputFilter->add([ |
42 | 42 | 'name' => 'is_wysiwyg_editor', |
43 | 43 | 'required' => false, |
44 | - 'filters' => [['name' => 'Boolean']], |
|
44 | + 'filters' => [ [ 'name' => 'Boolean' ] ], |
|
45 | 45 | ]); |
46 | 46 | |
47 | 47 | $this->inputFilter = $inputFilter; |
@@ -6,19 +6,19 @@ |
||
6 | 6 | { |
7 | 7 | public function up() |
8 | 8 | { |
9 | - $this->table('articles', ['id' => false, 'primary_key' => 'article_uuid']) |
|
10 | - ->addColumn('article_uuid', 'binary', ['limit' => 16]) |
|
9 | + $this->table('articles', [ 'id' => false, 'primary_key' => 'article_uuid' ]) |
|
10 | + ->addColumn('article_uuid', 'binary', [ 'limit' => 16 ]) |
|
11 | 11 | ->addColumn('article_id', 'text') |
12 | - ->addColumn('slug', 'text', ['null' => true]) |
|
13 | - ->addColumn('created_at', 'datetime', ['default' => 'CURRENT_TIMESTAMP']) |
|
14 | - ->addColumn('published_at', 'datetime', ['default' => 'CURRENT_TIMESTAMP']) |
|
12 | + ->addColumn('slug', 'text', [ 'null' => true ]) |
|
13 | + ->addColumn('created_at', 'datetime', [ 'default' => 'CURRENT_TIMESTAMP' ]) |
|
14 | + ->addColumn('published_at', 'datetime', [ 'default' => 'CURRENT_TIMESTAMP' ]) |
|
15 | 15 | ->addColumn('type', 'integer')// see Core\Entity\ArticleType |
16 | 16 | ->addColumn('status', 'integer')// active, not active, ... |
17 | - ->addColumn('admin_user_uuid', 'binary', ['limit' => 16]) |
|
18 | - ->addColumn('is_wysiwyg_editor', 'boolean', ['default' => false]) |
|
19 | - ->addForeignKey('admin_user_uuid', 'admin_users', 'admin_user_uuid', ['delete' => 'NO_ACTION', 'update' => 'NO_ACTION']) |
|
20 | - ->addIndex('type', ['name' => 'type_INDEX']) |
|
21 | - ->addIndex('published_at', ['name' => 'published_at_INDEX']) |
|
17 | + ->addColumn('admin_user_uuid', 'binary', [ 'limit' => 16 ]) |
|
18 | + ->addColumn('is_wysiwyg_editor', 'boolean', [ 'default' => false ]) |
|
19 | + ->addForeignKey('admin_user_uuid', 'admin_users', 'admin_user_uuid', [ 'delete' => 'NO_ACTION', 'update' => 'NO_ACTION' ]) |
|
20 | + ->addIndex('type', [ 'name' => 'type_INDEX' ]) |
|
21 | + ->addIndex('published_at', [ 'name' => 'published_at_INDEX' ]) |
|
22 | 22 | ->create(); |
23 | 23 | } |
24 | 24 |
@@ -203,6 +203,9 @@ |
||
203 | 203 | return $this->articleMapper->getCategories($articleId); |
204 | 204 | } |
205 | 205 | |
206 | + /** |
|
207 | + * @param integer $limit |
|
208 | + */ |
|
206 | 209 | public function getLatestWeb($limit) |
207 | 210 | { |
208 | 211 | return $this->articlePostsMapper->getLatest($limit); |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Article\Service; |
6 | 6 | |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | { |
72 | 72 | $article = $this->articlePostsMapper->getBySlug($slug); |
73 | 73 | |
74 | - if($article) { |
|
75 | - $article['categories'] = $this->getCategoryIds($article->article_id); |
|
74 | + if ($article) { |
|
75 | + $article[ 'categories' ] = $this->getCategoryIds($article->article_id); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | return $article; |
@@ -82,8 +82,8 @@ discard block |
||
82 | 82 | { |
83 | 83 | $article = $this->articlePostsMapper->get($articleId); |
84 | 84 | |
85 | - if($article) { |
|
86 | - $article['categories'] = $this->getCategoryIds($articleId); |
|
85 | + if ($article) { |
|
86 | + $article[ 'categories' ] = $this->getCategoryIds($articleId); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | return $article; |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | $articleFilter = $this->articleFilter->getInputFilter()->setData($data); |
103 | 103 | $postFilter = $this->postFilter->getInputFilter()->setData($data); |
104 | 104 | |
105 | - if(!$articleFilter->isValid() || !$postFilter->isValid()) { |
|
105 | + if (!$articleFilter->isValid() || !$postFilter->isValid()) { |
|
106 | 106 | throw new FilterException($articleFilter->getMessages() + $postFilter->getMessages()); |
107 | 107 | } |
108 | 108 | |
@@ -119,19 +119,19 @@ discard block |
||
119 | 119 | $post = $postFilter->getValues() + [ |
120 | 120 | 'featured_img' => $this->upload->uploadImage($data, 'featured_img'), |
121 | 121 | 'main_img' => $this->upload->uploadImage($data, 'main_img'), |
122 | - 'article_uuid' => $article['article_uuid'] |
|
122 | + 'article_uuid' => $article[ 'article_uuid' ] |
|
123 | 123 | ]; |
124 | 124 | |
125 | - if($post['is_homepage']) { |
|
126 | - $this->articlePostsMapper->update(['is_homepage' => false]); |
|
125 | + if ($post[ 'is_homepage' ]) { |
|
126 | + $this->articlePostsMapper->update([ 'is_homepage' => false ]); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | $this->articleMapper->insert($article); |
130 | 130 | $this->articlePostsMapper->insert($post); |
131 | 131 | |
132 | - if(isset($data['categories']) && $data['categories']) { |
|
133 | - $categories = $this->categoryMapper->select(['category_id' => $data['categories']]); |
|
134 | - $this->articleMapper->insertCategories($categories, $article['article_uuid']); |
|
132 | + if (isset($data[ 'categories' ]) && $data[ 'categories' ]) { |
|
133 | + $categories = $this->categoryMapper->select([ 'category_id' => $data[ 'categories' ] ]); |
|
134 | + $this->articleMapper->insertCategories($categories, $article[ 'article_uuid' ]); |
|
135 | 135 | } |
136 | 136 | } |
137 | 137 | |
@@ -141,36 +141,36 @@ discard block |
||
141 | 141 | $articleFilter = $this->articleFilter->getInputFilter()->setData($data); |
142 | 142 | $postFilter = $this->postFilter->getInputFilter()->setData($data); |
143 | 143 | |
144 | - if(!$articleFilter->isValid() || !$postFilter->isValid()) { |
|
144 | + if (!$articleFilter->isValid() || !$postFilter->isValid()) { |
|
145 | 145 | throw new FilterException($articleFilter->getMessages() + $postFilter->getMessages()); |
146 | 146 | } |
147 | 147 | |
148 | - $article = $articleFilter->getValues() + ['article_uuid' => $article->article_uuid]; |
|
148 | + $article = $articleFilter->getValues() + [ 'article_uuid' => $article->article_uuid ]; |
|
149 | 149 | $post = $postFilter->getValues() + [ |
150 | 150 | 'featured_img' => $this->upload->uploadImage($data, 'featured_img'), |
151 | 151 | 'main_img' => $this->upload->uploadImage($data, 'main_img') |
152 | 152 | ]; |
153 | 153 | |
154 | 154 | // We dont want to force user to re-upload image on edit |
155 | - if(!$post['featured_img']) { |
|
156 | - unset($post['featured_img']); |
|
155 | + if (!$post[ 'featured_img' ]) { |
|
156 | + unset($post[ 'featured_img' ]); |
|
157 | 157 | } |
158 | 158 | |
159 | - if(!$post['main_img']) { |
|
160 | - unset($post['main_img']); |
|
159 | + if (!$post[ 'main_img' ]) { |
|
160 | + unset($post[ 'main_img' ]); |
|
161 | 161 | } |
162 | 162 | |
163 | - if($post['is_homepage']) { |
|
164 | - $this->articlePostsMapper->update(['is_homepage' => false]); |
|
163 | + if ($post[ 'is_homepage' ]) { |
|
164 | + $this->articlePostsMapper->update([ 'is_homepage' => false ]); |
|
165 | 165 | } |
166 | 166 | |
167 | - $this->articleMapper->update($article, ['article_uuid' => $article['article_uuid']]); |
|
168 | - $this->articlePostsMapper->update($post, ['article_uuid' => $article['article_uuid']]); |
|
169 | - $this->articleMapper->deleteCategories($article['article_uuid']); |
|
167 | + $this->articleMapper->update($article, [ 'article_uuid' => $article[ 'article_uuid' ] ]); |
|
168 | + $this->articlePostsMapper->update($post, [ 'article_uuid' => $article[ 'article_uuid' ] ]); |
|
169 | + $this->articleMapper->deleteCategories($article[ 'article_uuid' ]); |
|
170 | 170 | |
171 | - if(isset($data['categories']) && $data['categories']) { |
|
172 | - $categories = $this->categoryMapper->select(['category_id' => $data['categories']]); |
|
173 | - $this->articleMapper->insertCategories($categories, $article['article_uuid']); |
|
171 | + if (isset($data[ 'categories' ]) && $data[ 'categories' ]) { |
|
172 | + $categories = $this->categoryMapper->select([ 'category_id' => $data[ 'categories' ] ]); |
|
173 | + $this->articleMapper->insertCategories($categories, $article[ 'article_uuid' ]); |
|
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
@@ -178,11 +178,11 @@ discard block |
||
178 | 178 | { |
179 | 179 | $post = $this->articlePostsMapper->get($id); |
180 | 180 | |
181 | - if(!$post) { |
|
181 | + if (!$post) { |
|
182 | 182 | throw new \Exception('Article not found!'); |
183 | 183 | } |
184 | 184 | |
185 | - $this->articlePostsMapper->delete(['article_uuid' => $post->article_uuid]); |
|
185 | + $this->articlePostsMapper->delete([ 'article_uuid' => $post->article_uuid ]); |
|
186 | 186 | $this->delete($post->article_uuid); |
187 | 187 | } |
188 | 188 |
@@ -31,6 +31,9 @@ discard block |
||
31 | 31 | $this->adapter = $adapter; |
32 | 32 | } |
33 | 33 | |
34 | + /** |
|
35 | + * @param string $id |
|
36 | + */ |
|
34 | 37 | public function get($id) |
35 | 38 | { |
36 | 39 | return $this->select(['admin_user_id' => $id])->current(); |
@@ -40,7 +43,7 @@ discard block |
||
40 | 43 | * Get admin user by email. |
41 | 44 | * |
42 | 45 | * @param string $email email |
43 | - * @return array|\ArrayObject|null |
|
46 | + * @return string |
|
44 | 47 | */ |
45 | 48 | public function getByEmail(string $email) |
46 | 49 | { |
@@ -50,7 +53,6 @@ discard block |
||
50 | 53 | /** |
51 | 54 | * Updates login data. |
52 | 55 | * |
53 | - * @param string $uuid admin user id |
|
54 | 56 | * @return int number of affected rows |
55 | 57 | */ |
56 | 58 | public function updateLogin(string $userId): int |
@@ -58,6 +60,9 @@ discard block |
||
58 | 60 | return $this->update(['last_login' => date('Y-m-d H:i:s')], ['admin_user_id' => $userId]); |
59 | 61 | } |
60 | 62 | |
63 | + /** |
|
64 | + * @param string $userId |
|
65 | + */ |
|
61 | 66 | public function getPaginationSelect($userId) |
62 | 67 | { |
63 | 68 | $select = $this->getSql()->select()->order(['created_at' => 'desc']); |
@@ -67,6 +72,9 @@ discard block |
||
67 | 72 | return $select; |
68 | 73 | } |
69 | 74 | |
75 | + /** |
|
76 | + * @param integer $limit |
|
77 | + */ |
|
70 | 78 | public function getRandom($limit) |
71 | 79 | { |
72 | 80 | $select = $this->getSql()->select() |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -declare(strict_types=1); |
|
2 | +declare(strict_types = 1); |
|
3 | 3 | |
4 | 4 | namespace Core\Mapper; |
5 | 5 | |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | |
34 | 34 | public function get($id) |
35 | 35 | { |
36 | - return $this->select(['admin_user_id' => $id])->current(); |
|
36 | + return $this->select([ 'admin_user_id' => $id ])->current(); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | */ |
45 | 45 | public function getByEmail(string $email) |
46 | 46 | { |
47 | - return $this->select(['email' => $email])->current(); |
|
47 | + return $this->select([ 'email' => $email ])->current(); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
@@ -55,12 +55,12 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public function updateLogin(string $userId): int |
57 | 57 | { |
58 | - return $this->update(['last_login' => date('Y-m-d H:i:s')], ['admin_user_id' => $userId]); |
|
58 | + return $this->update([ 'last_login' => date('Y-m-d H:i:s') ], [ 'admin_user_id' => $userId ]); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | public function getPaginationSelect($userId) |
62 | 62 | { |
63 | - $select = $this->getSql()->select()->order(['created_at' => 'desc']); |
|
63 | + $select = $this->getSql()->select()->order([ 'created_at' => 'desc' ]); |
|
64 | 64 | |
65 | 65 | $select->where->notEqualTo('admin_user_id', $userId); |
66 | 66 | |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | public function getRandom($limit) |
71 | 71 | { |
72 | 72 | $select = $this->getSql()->select() |
73 | - ->where(['status' => 1]) |
|
73 | + ->where([ 'status' => 1 ]) |
|
74 | 74 | ->order(new Expression('rand()')) |
75 | 75 | ->limit($limit); |
76 | 76 |
@@ -13,8 +13,8 @@ |
||
13 | 13 | 'article/pagination' => 'templates/partial/pagination.phtml', |
14 | 14 | ], |
15 | 15 | 'paths' => [ |
16 | - 'templates' => ['templates'], |
|
17 | - 'web' => ['templates/web'], |
|
16 | + 'templates' => [ 'templates' ], |
|
17 | + 'web' => [ 'templates/web' ], |
|
18 | 18 | ], |
19 | 19 | ], |
20 | 20 |