@@ -26,9 +26,9 @@ discard block |
||
26 | 26 | $tag = URLDecode::getPiece(2); |
27 | 27 | $tag = str_replace('-', ' ', $tag); |
28 | 28 | |
29 | - global $container; |
|
30 | - $repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']); |
|
31 | - $tag_result = $repository->findTagByTitle($tag); |
|
29 | + global $container; |
|
30 | + $repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']); |
|
31 | + $tag_result = $repository->findTagByTitle($tag); |
|
32 | 32 | |
33 | 33 | if($tag_result === false) |
34 | 34 | $this->eject(); |
@@ -64,9 +64,9 @@ discard block |
||
64 | 64 | |
65 | 65 | if($this->page == 1) |
66 | 66 | { |
67 | - global $container; |
|
68 | - $repository = new Jacobemerick\Web\Domain\Blog\Introduction\MysqlIntroductionRepository($container['db_connection_locator']); |
|
69 | - $introduction_result = $repository->findByType('tag', $this->tag['tag']); |
|
67 | + global $container; |
|
68 | + $repository = new Jacobemerick\Web\Domain\Blog\Introduction\MysqlIntroductionRepository($container['db_connection_locator']); |
|
69 | + $introduction_result = $repository->findByType('tag', $this->tag['tag']); |
|
70 | 70 | |
71 | 71 | if($introduction_result !== false) |
72 | 72 | { |
@@ -96,9 +96,9 @@ discard block |
||
96 | 96 | |
97 | 97 | protected function get_list_results() |
98 | 98 | { |
99 | - global $container; |
|
100 | - $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
|
101 | - return $repository->getActivePostsByTag($this->tag['id'], self::$POSTS_PER_PAGE, $this->offset); |
|
99 | + global $container; |
|
100 | + $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
|
101 | + return $repository->getActivePostsByTag($this->tag['id'], self::$POSTS_PER_PAGE, $this->offset); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | protected function get_list_description() |
@@ -129,10 +129,10 @@ discard block |
||
129 | 129 | protected function get_total_post_count() |
130 | 130 | { |
131 | 131 | if(!isset($this->total_post_count)) { |
132 | - global $container; |
|
133 | - $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
|
134 | - $this->total_post_count = $repository->getActivePostsCountByTag($this->tag['id']); |
|
135 | - } |
|
132 | + global $container; |
|
133 | + $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
|
134 | + $this->total_post_count = $repository->getActivePostsCountByTag($this->tag['id']); |
|
135 | + } |
|
136 | 136 | |
137 | 137 | return $this->total_post_count; |
138 | 138 | } |
@@ -115,9 +115,9 @@ discard block |
||
115 | 115 | { |
116 | 116 | if($this->page == 1) |
117 | 117 | { |
118 | - global $container; |
|
119 | - $repository = new Jacobemerick\Web\Domain\Blog\Introduction\MysqlIntroductionRepository($container['db_connection_locator']); |
|
120 | - $introduction_result = $repository->findByType('category', $this->category->link); |
|
118 | + global $container; |
|
119 | + $repository = new Jacobemerick\Web\Domain\Blog\Introduction\MysqlIntroductionRepository($container['db_connection_locator']); |
|
120 | + $introduction_result = $repository->findByType('category', $this->category->link); |
|
121 | 121 | |
122 | 122 | $introduction = array(); |
123 | 123 | $introduction['title'] = $introduction_result['title']; |
@@ -141,9 +141,9 @@ discard block |
||
141 | 141 | |
142 | 142 | protected function get_list_results() |
143 | 143 | { |
144 | - global $container; |
|
145 | - $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
|
146 | - return $repository->getActivePostsByCategory($this->category->link, self::$POSTS_PER_PAGE, $this->offset); |
|
144 | + global $container; |
|
145 | + $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
|
146 | + return $repository->getActivePostsByCategory($this->category->link, self::$POSTS_PER_PAGE, $this->offset); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | protected function get_list_description() |
@@ -174,10 +174,10 @@ discard block |
||
174 | 174 | protected function get_total_post_count() |
175 | 175 | { |
176 | 176 | if(!isset($this->total_post_count)) { |
177 | - global $container; |
|
178 | - $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
|
179 | - $this->total_post_count = $repository->getActivePostsCountByCategory($this->category->link); |
|
180 | - } |
|
177 | + global $container; |
|
178 | + $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
|
179 | + $this->total_post_count = $repository->getActivePostsCountByCategory($this->category->link); |
|
180 | + } |
|
181 | 181 | return $this->total_post_count; |
182 | 182 | } |
183 | 183 |
@@ -33,9 +33,9 @@ |
||
33 | 33 | |
34 | 34 | protected function get_introduction() |
35 | 35 | { |
36 | - global $container; |
|
37 | - $repository = new Jacobemerick\Web\Domain\Blog\Introduction\MysqlIntroductionRepository($container['db_connection_locator']); |
|
38 | - $introduction_result = $repository->findByType('about'); |
|
36 | + global $container; |
|
37 | + $repository = new Jacobemerick\Web\Domain\Blog\Introduction\MysqlIntroductionRepository($container['db_connection_locator']); |
|
38 | + $introduction_result = $repository->findByType('about'); |
|
39 | 39 | |
40 | 40 | if($introduction_result !== null) |
41 | 41 | { |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | { |
35 | 35 | $query = URLDecode::getPiece(2); |
36 | 36 | $query = urldecode($query); |
37 | - $query = str_replace('-', ' ', $query); |
|
37 | + $query = str_replace('-', ' ', $query); |
|
38 | 38 | |
39 | 39 | $this->query = $query; |
40 | 40 | |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | { |
88 | 88 | if(!isset($this->search_result)) |
89 | 89 | { |
90 | - global $container; |
|
91 | - $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
|
92 | - $posts = $repository->getActivePosts(); |
|
90 | + global $container; |
|
91 | + $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
|
92 | + $posts = $repository->getActivePosts(); |
|
93 | 93 | |
94 | 94 | $this->search_result = Search::instance() |
95 | 95 | ->setQuery($this->query) |
@@ -7,163 +7,163 @@ discard block |
||
7 | 7 | class MysqlPostRepository implements PostRepositoryInterface |
8 | 8 | { |
9 | 9 | |
10 | - /** @var Aura\Sql\ConnectionLocator */ |
|
11 | - protected $connections; |
|
12 | - |
|
13 | - /** |
|
14 | - * @param Aura\Sql\ConnectionLocator $connections |
|
15 | - */ |
|
16 | - public function __construct(ConnectionLocator $connections) |
|
17 | - { |
|
18 | - $this->connections = $connections; |
|
19 | - } |
|
20 | - |
|
21 | - /** |
|
22 | - * @param string $path |
|
23 | - * |
|
24 | - * @return array|false |
|
25 | - */ |
|
26 | - public function findPostByPath($path) |
|
27 | - { |
|
28 | - $query = " |
|
10 | + /** @var Aura\Sql\ConnectionLocator */ |
|
11 | + protected $connections; |
|
12 | + |
|
13 | + /** |
|
14 | + * @param Aura\Sql\ConnectionLocator $connections |
|
15 | + */ |
|
16 | + public function __construct(ConnectionLocator $connections) |
|
17 | + { |
|
18 | + $this->connections = $connections; |
|
19 | + } |
|
20 | + |
|
21 | + /** |
|
22 | + * @param string $path |
|
23 | + * |
|
24 | + * @return array|false |
|
25 | + */ |
|
26 | + public function findPostByPath($path) |
|
27 | + { |
|
28 | + $query = " |
|
29 | 29 | SELECT `id`, `title`, `path`, `date`, `body`, `category` |
30 | 30 | FROM `jpemeric_blog`.`post` |
31 | 31 | WHERE `path` = :path AND `display` = :is_active |
32 | 32 | LIMIT 1"; |
33 | - $bindings = [ |
|
34 | - 'path' => $path, |
|
35 | - 'is_active' => 1, |
|
36 | - ]; |
|
37 | - |
|
38 | - return $this |
|
39 | - ->connections |
|
40 | - ->getRead() |
|
41 | - ->fetchOne($query, $bindings); |
|
42 | - } |
|
43 | - |
|
44 | - public function getActivePosts($limit = null, $offset = 0) |
|
45 | - { |
|
46 | - $query = " |
|
33 | + $bindings = [ |
|
34 | + 'path' => $path, |
|
35 | + 'is_active' => 1, |
|
36 | + ]; |
|
37 | + |
|
38 | + return $this |
|
39 | + ->connections |
|
40 | + ->getRead() |
|
41 | + ->fetchOne($query, $bindings); |
|
42 | + } |
|
43 | + |
|
44 | + public function getActivePosts($limit = null, $offset = 0) |
|
45 | + { |
|
46 | + $query = " |
|
47 | 47 | SELECT `id`, `title`, `path`, `date`, `body`, `category` |
48 | 48 | FROM `jpemeric_blog`.`post` |
49 | 49 | WHERE `display` = :is_active |
50 | 50 | ORDER BY `date` DESC"; |
51 | - if ($limit != null) { |
|
52 | - $query .= " |
|
51 | + if ($limit != null) { |
|
52 | + $query .= " |
|
53 | 53 | LIMIT {$offset}, {$limit}"; |
54 | - } |
|
54 | + } |
|
55 | 55 | |
56 | - $bindings = [ |
|
57 | - 'is_active' => 1, |
|
58 | - ]; |
|
56 | + $bindings = [ |
|
57 | + 'is_active' => 1, |
|
58 | + ]; |
|
59 | 59 | |
60 | - return $this |
|
61 | - ->connections |
|
62 | - ->getRead() |
|
63 | - ->fetchAll($query, $bindings); |
|
64 | - } |
|
60 | + return $this |
|
61 | + ->connections |
|
62 | + ->getRead() |
|
63 | + ->fetchAll($query, $bindings); |
|
64 | + } |
|
65 | 65 | |
66 | - public function getActivePostsCount() |
|
67 | - { |
|
68 | - $query = " |
|
66 | + public function getActivePostsCount() |
|
67 | + { |
|
68 | + $query = " |
|
69 | 69 | SELECT COUNT(1) AS `count` |
70 | 70 | FROM `jpemeric_blog`.`post` |
71 | 71 | WHERE `display` = :is_active"; |
72 | - $bindings = [ |
|
73 | - 'is_active' => 1, |
|
74 | - ]; |
|
75 | - |
|
76 | - return $this |
|
77 | - ->connections |
|
78 | - ->getRead() |
|
79 | - ->fetchValue($query, $bindings); |
|
80 | - } |
|
81 | - |
|
82 | - public function getActivePostsByTag($tag, $limit = null, $offset = 0) |
|
83 | - { |
|
84 | - $query = " |
|
72 | + $bindings = [ |
|
73 | + 'is_active' => 1, |
|
74 | + ]; |
|
75 | + |
|
76 | + return $this |
|
77 | + ->connections |
|
78 | + ->getRead() |
|
79 | + ->fetchValue($query, $bindings); |
|
80 | + } |
|
81 | + |
|
82 | + public function getActivePostsByTag($tag, $limit = null, $offset = 0) |
|
83 | + { |
|
84 | + $query = " |
|
85 | 85 | SELECT `id`, `title`, `path`, `date`, `body`, `category` |
86 | 86 | FROM `jpemeric_blog`.`post` |
87 | 87 | INNER JOIN `jpemeric_blog`.`ptlink` ON `ptlink`.`post_id` = `post`.`id` AND |
88 | 88 | `ptlink`.`tag_id` = :tag_id |
89 | 89 | WHERE `display` = :is_active"; |
90 | - if ($limit != null) { |
|
91 | - $query .= " |
|
90 | + if ($limit != null) { |
|
91 | + $query .= " |
|
92 | 92 | LIMIT {$offset}, {$limit}"; |
93 | - } |
|
94 | - |
|
95 | - $bindings = [ |
|
96 | - 'tag_id' => $tag, |
|
97 | - 'is_active' => 1, |
|
98 | - ]; |
|
99 | - |
|
100 | - return $this |
|
101 | - ->connections |
|
102 | - ->getRead() |
|
103 | - ->fetchAll($query, $bindings); |
|
104 | - } |
|
105 | - |
|
106 | - public function getActivePostsCountByTag($tag) |
|
107 | - { |
|
108 | - $query = " |
|
93 | + } |
|
94 | + |
|
95 | + $bindings = [ |
|
96 | + 'tag_id' => $tag, |
|
97 | + 'is_active' => 1, |
|
98 | + ]; |
|
99 | + |
|
100 | + return $this |
|
101 | + ->connections |
|
102 | + ->getRead() |
|
103 | + ->fetchAll($query, $bindings); |
|
104 | + } |
|
105 | + |
|
106 | + public function getActivePostsCountByTag($tag) |
|
107 | + { |
|
108 | + $query = " |
|
109 | 109 | SELECT COUNT(1) AS `count` |
110 | 110 | FROM `jpemeric_blog`.`post` |
111 | 111 | INNER JOIN `jpemeric_blog`.`ptlink` ON `ptlink`.`post_id` = `post`.`id` AND |
112 | 112 | `ptlink`.`tag_id` = :tag_id |
113 | 113 | WHERE `display` = :is_active"; |
114 | - $bindings = [ |
|
115 | - 'tag_id' => $tag, |
|
116 | - 'is_active' => 1, |
|
117 | - ]; |
|
118 | - |
|
119 | - return $this |
|
120 | - ->connections |
|
121 | - ->getRead() |
|
122 | - ->fetchValue($query, $bindings); |
|
123 | - } |
|
124 | - |
|
125 | - public function getActivePostsByCategory($category, $limit = null, $offset = 0) |
|
126 | - { |
|
127 | - $query = " |
|
114 | + $bindings = [ |
|
115 | + 'tag_id' => $tag, |
|
116 | + 'is_active' => 1, |
|
117 | + ]; |
|
118 | + |
|
119 | + return $this |
|
120 | + ->connections |
|
121 | + ->getRead() |
|
122 | + ->fetchValue($query, $bindings); |
|
123 | + } |
|
124 | + |
|
125 | + public function getActivePostsByCategory($category, $limit = null, $offset = 0) |
|
126 | + { |
|
127 | + $query = " |
|
128 | 128 | SELECT `id`, `title`, `path`, `date`, `body`, `category` |
129 | 129 | FROM `jpemeric_blog`.`post` |
130 | 130 | WHERE `category` = :category AND `display` = :is_active"; |
131 | - if ($limit != null) { |
|
132 | - $query .= " |
|
131 | + if ($limit != null) { |
|
132 | + $query .= " |
|
133 | 133 | LIMIT {$offset}, {$limit}"; |
134 | - } |
|
135 | - |
|
136 | - $bindings = [ |
|
137 | - 'category' => $category, |
|
138 | - 'is_active' => 1, |
|
139 | - ]; |
|
140 | - |
|
141 | - return $this |
|
142 | - ->connections |
|
143 | - ->getRead() |
|
144 | - ->fetchAll($query, $bindings); |
|
145 | - } |
|
146 | - |
|
147 | - public function getActivePostsCountByCategory($category) |
|
148 | - { |
|
149 | - $query = " |
|
134 | + } |
|
135 | + |
|
136 | + $bindings = [ |
|
137 | + 'category' => $category, |
|
138 | + 'is_active' => 1, |
|
139 | + ]; |
|
140 | + |
|
141 | + return $this |
|
142 | + ->connections |
|
143 | + ->getRead() |
|
144 | + ->fetchAll($query, $bindings); |
|
145 | + } |
|
146 | + |
|
147 | + public function getActivePostsCountByCategory($category) |
|
148 | + { |
|
149 | + $query = " |
|
150 | 150 | SELECT COUNT(1) AS `count` |
151 | 151 | FROM `jpemeric_blog`.`post` |
152 | 152 | WHERE `category` = :category AND `display` = :is_active"; |
153 | - $bindings = [ |
|
154 | - 'category' => $category, |
|
155 | - 'is_active' => 1, |
|
156 | - ]; |
|
157 | - |
|
158 | - return $this |
|
159 | - ->connections |
|
160 | - ->getRead() |
|
161 | - ->fetchValue($query, $bindings); |
|
162 | - } |
|
163 | - |
|
164 | - public function getActivePostsByRelatedTags($post, $limit = 4) |
|
165 | - { |
|
166 | - $query = " |
|
153 | + $bindings = [ |
|
154 | + 'category' => $category, |
|
155 | + 'is_active' => 1, |
|
156 | + ]; |
|
157 | + |
|
158 | + return $this |
|
159 | + ->connections |
|
160 | + ->getRead() |
|
161 | + ->fetchValue($query, $bindings); |
|
162 | + } |
|
163 | + |
|
164 | + public function getActivePostsByRelatedTags($post, $limit = 4) |
|
165 | + { |
|
166 | + $query = " |
|
167 | 167 | SELECT `id`, `title`, `path`, `date`, `body`, `category`, COUNT(1) AS `count` |
168 | 168 | FROM `jpemeric_blog`.`post` |
169 | 169 | INNER JOIN `jpemeric_blog`.`ptlink` ON `ptlink`.`post_id` = `post`.`id` AND |
@@ -183,14 +183,14 @@ discard block |
||
183 | 183 | GROUP BY `id` |
184 | 184 | ORDER BY `count` DESC |
185 | 185 | LIMIT {$limit}"; |
186 | - $bindings = [ |
|
187 | - 'post' => $post, |
|
188 | - 'is_active' => 1, |
|
189 | - ]; |
|
190 | - |
|
191 | - return $this |
|
192 | - ->connections |
|
193 | - ->getRead() |
|
194 | - ->fetchAll($query, $bindings); |
|
195 | - } |
|
186 | + $bindings = [ |
|
187 | + 'post' => $post, |
|
188 | + 'is_active' => 1, |
|
189 | + ]; |
|
190 | + |
|
191 | + return $this |
|
192 | + ->connections |
|
193 | + ->getRead() |
|
194 | + ->fetchAll($query, $bindings); |
|
195 | + } |
|
196 | 196 | } |
@@ -4,12 +4,12 @@ |
||
4 | 4 | |
5 | 5 | interface PostRepositoryInterface |
6 | 6 | { |
7 | - public function findPostByPath($path); |
|
8 | - public function getActivePosts($limit = null, $offset= 0); |
|
9 | - public function getActivePostsCount(); |
|
10 | - public function getActivePostsByTag($tag, $limit = null, $offset = 0); |
|
11 | - public function getActivePostsCountByTag($tag); |
|
12 | - public function getActivePostsByCategory($category, $limit = null, $offset = 0); |
|
13 | - public function getActivePostsCountByCategory($category); |
|
14 | - public function getActivePostsByRelatedTags($post, $limit = 4); |
|
7 | + public function findPostByPath($path); |
|
8 | + public function getActivePosts($limit = null, $offset= 0); |
|
9 | + public function getActivePostsCount(); |
|
10 | + public function getActivePostsByTag($tag, $limit = null, $offset = 0); |
|
11 | + public function getActivePostsCountByTag($tag); |
|
12 | + public function getActivePostsByCategory($category, $limit = null, $offset = 0); |
|
13 | + public function getActivePostsCountByCategory($category); |
|
14 | + public function getActivePostsByRelatedTags($post, $limit = 4); |
|
15 | 15 | } |
@@ -32,9 +32,9 @@ discard block |
||
32 | 32 | switch($type) |
33 | 33 | { |
34 | 34 | case 'blog' : |
35 | - global $container; |
|
36 | - $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
|
37 | - $post = $repository->findPostByPath($uri); |
|
35 | + global $container; |
|
36 | + $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
|
37 | + $post = $repository->findPostByPath($uri); |
|
38 | 38 | |
39 | 39 | if($post === NULL) |
40 | 40 | return; |
@@ -73,38 +73,38 @@ discard block |
||
73 | 73 | |
74 | 74 | break; |
75 | 75 | case 'falls' : |
76 | - $pieces = explode('/', $uri); |
|
77 | - if (count($pieces) == 1) { |
|
78 | - Loader::load('collector', 'waterfall/WatercourseCollector'); |
|
79 | - list ($watercourse_alias) = $pieces; |
|
80 | - $watercourse = WatercourseCollector::getByAlias($watercourse_alias); |
|
76 | + $pieces = explode('/', $uri); |
|
77 | + if (count($pieces) == 1) { |
|
78 | + Loader::load('collector', 'waterfall/WatercourseCollector'); |
|
79 | + list ($watercourse_alias) = $pieces; |
|
80 | + $watercourse = WatercourseCollector::getByAlias($watercourse_alias); |
|
81 | 81 | |
82 | - if ($watercourse == null) { |
|
83 | - return; |
|
84 | - } |
|
82 | + if ($watercourse == null) { |
|
83 | + return; |
|
84 | + } |
|
85 | 85 | |
86 | - $link .= ($is_absolute) ? Loader::getRootURL('waterfalls') : '/'; |
|
87 | - $link .= "{$watercourse->alias}/"; |
|
86 | + $link .= ($is_absolute) ? Loader::getRootURL('waterfalls') : '/'; |
|
87 | + $link .= "{$watercourse->alias}/"; |
|
88 | 88 | |
89 | - if ($anchor == '') { |
|
90 | - $anchor = $watercourse->name; |
|
91 | - } |
|
92 | - } else if (count($pieces) == 2) { |
|
93 | - Loader::load('collector', 'waterfall/WaterfallCollector'); |
|
94 | - list ($watercourse_alias, $waterfall_alias) = $pieces; |
|
95 | - $waterfall = WaterfallCollector::getByAlias($watercourse_alias, $waterfall_alias); |
|
89 | + if ($anchor == '') { |
|
90 | + $anchor = $watercourse->name; |
|
91 | + } |
|
92 | + } else if (count($pieces) == 2) { |
|
93 | + Loader::load('collector', 'waterfall/WaterfallCollector'); |
|
94 | + list ($watercourse_alias, $waterfall_alias) = $pieces; |
|
95 | + $waterfall = WaterfallCollector::getByAlias($watercourse_alias, $waterfall_alias); |
|
96 | 96 | |
97 | - if ($waterfall == null) { |
|
98 | - return; |
|
99 | - } |
|
97 | + if ($waterfall == null) { |
|
98 | + return; |
|
99 | + } |
|
100 | 100 | |
101 | - $link .= ($is_absolute) ? Loader::getRootURL('waterfalls') : '/'; |
|
102 | - $link .= "{$waterfall->watercourse_alias}/{$waterfall->alias}/"; |
|
101 | + $link .= ($is_absolute) ? Loader::getRootURL('waterfalls') : '/'; |
|
102 | + $link .= "{$waterfall->watercourse_alias}/{$waterfall->alias}/"; |
|
103 | 103 | |
104 | - if ($anchor == '') { |
|
105 | - $anchor = $waterfall->name; |
|
106 | - } |
|
107 | - } |
|
104 | + if ($anchor == '') { |
|
105 | + $anchor = $waterfall->name; |
|
106 | + } |
|
107 | + } |
|
108 | 108 | break; |
109 | 109 | default : |
110 | 110 | break; |
@@ -24,21 +24,21 @@ |
||
24 | 24 | |
25 | 25 | self::$array['host'] = $host; |
26 | 26 | |
27 | - if ( |
|
28 | - $host == 'www.waterfallsofthekeweenaw.com' || |
|
29 | - $host == 'waterfallsofthekeweenaw.com' |
|
30 | - ) { |
|
27 | + if ( |
|
28 | + $host == 'www.waterfallsofthekeweenaw.com' || |
|
29 | + $host == 'waterfallsofthekeweenaw.com' |
|
30 | + ) { |
|
31 | 31 | self::$array['site'] = 'waterfalls'; |
32 | 32 | } else { |
33 | 33 | self::$array['site'] = substr($host, 0, strpos($host, '.')); |
34 | 34 | } |
35 | 35 | |
36 | - $base = ''; |
|
37 | - $base .= (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http'; |
|
38 | - $base .= '://'; |
|
39 | - $base .= (!Loader::isLive()) ? 'dev.' : ''; |
|
40 | - $base .= $host; |
|
41 | - $base .= '/'; |
|
36 | + $base = ''; |
|
37 | + $base .= (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http'; |
|
38 | + $base .= '://'; |
|
39 | + $base .= (!Loader::isLive()) ? 'dev.' : ''; |
|
40 | + $base .= $host; |
|
41 | + $base .= '/'; |
|
42 | 42 | |
43 | 43 | self::$array['base'] = $base; |
44 | 44 | self::$array['uri'] = '/' . implode('/', $uri_array); |
@@ -5,92 +5,92 @@ |
||
5 | 5 | class ContactController extends DefaultPageController |
6 | 6 | { |
7 | 7 | |
8 | - protected function set_head_data() |
|
9 | - { |
|
10 | - $this->set_title("Contact Page | Jacob Emerick's Portfolio"); |
|
11 | - $this->set_description("Contact page for Jacob Emerick's Portfolio"); |
|
12 | - $this->set_keywords([ |
|
13 | - 'portfolio', |
|
14 | - 'programming portfolio', |
|
15 | - 'contact', |
|
16 | - 'Jacob Emerick', |
|
17 | - 'information', |
|
18 | - 'freelance', |
|
19 | - ]); |
|
20 | - } |
|
8 | + protected function set_head_data() |
|
9 | + { |
|
10 | + $this->set_title("Contact Page | Jacob Emerick's Portfolio"); |
|
11 | + $this->set_description("Contact page for Jacob Emerick's Portfolio"); |
|
12 | + $this->set_keywords([ |
|
13 | + 'portfolio', |
|
14 | + 'programming portfolio', |
|
15 | + 'contact', |
|
16 | + 'Jacob Emerick', |
|
17 | + 'information', |
|
18 | + 'freelance', |
|
19 | + ]); |
|
20 | + } |
|
21 | 21 | |
22 | - protected function set_body_data() |
|
23 | - { |
|
24 | - $this->set_body('body_view', 'Contact'); |
|
22 | + protected function set_body_data() |
|
23 | + { |
|
24 | + $this->set_body('body_view', 'Contact'); |
|
25 | 25 | |
26 | - $body_data = []; |
|
27 | - if (!empty($_POST)) { |
|
28 | - $body_data = $this->process_form_data(); |
|
29 | - } |
|
30 | - $body_data['domain_container'] = $this->get_domain_container(); |
|
31 | - $this->set_body('body_data', $body_data); |
|
26 | + $body_data = []; |
|
27 | + if (!empty($_POST)) { |
|
28 | + $body_data = $this->process_form_data(); |
|
29 | + } |
|
30 | + $body_data['domain_container'] = $this->get_domain_container(); |
|
31 | + $this->set_body('body_data', $body_data); |
|
32 | 32 | |
33 | - parent::set_body_data(); |
|
34 | - } |
|
33 | + parent::set_body_data(); |
|
34 | + } |
|
35 | 35 | |
36 | - private function process_form_data() |
|
37 | - { |
|
38 | - $errors = []; |
|
36 | + private function process_form_data() |
|
37 | + { |
|
38 | + $errors = []; |
|
39 | 39 | |
40 | - if ( |
|
41 | - empty($_POST['name']) || |
|
42 | - !is_string($_POST['name']) || |
|
43 | - strlen($_POST['name']) > 100 |
|
44 | - ) { |
|
45 | - $errors['name'] = 'Please enter a valid name.'; |
|
46 | - } |
|
40 | + if ( |
|
41 | + empty($_POST['name']) || |
|
42 | + !is_string($_POST['name']) || |
|
43 | + strlen($_POST['name']) > 100 |
|
44 | + ) { |
|
45 | + $errors['name'] = 'Please enter a valid name.'; |
|
46 | + } |
|
47 | 47 | |
48 | - if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { |
|
49 | - $errors['email'] = 'Please enter a valid email.'; |
|
50 | - } |
|
48 | + if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { |
|
49 | + $errors['email'] = 'Please enter a valid email.'; |
|
50 | + } |
|
51 | 51 | |
52 | - if ( |
|
53 | - empty($_POST['message']) || |
|
54 | - !is_string($_POST['message']) || |
|
55 | - strlen($_POST['message']) > 10000 |
|
56 | - ) { |
|
57 | - $errors['message'] = 'Please enter a valid message.'; |
|
58 | - } |
|
52 | + if ( |
|
53 | + empty($_POST['message']) || |
|
54 | + !is_string($_POST['message']) || |
|
55 | + strlen($_POST['message']) > 10000 |
|
56 | + ) { |
|
57 | + $errors['message'] = 'Please enter a valid message.'; |
|
58 | + } |
|
59 | 59 | |
60 | - if (!empty($errors)) { |
|
61 | - $values = $_POST; |
|
62 | - $values = array_intersect_key($values, array_flip([ |
|
63 | - 'name', |
|
64 | - 'email', |
|
65 | - 'message', |
|
66 | - ])); |
|
60 | + if (!empty($errors)) { |
|
61 | + $values = $_POST; |
|
62 | + $values = array_intersect_key($values, array_flip([ |
|
63 | + 'name', |
|
64 | + 'email', |
|
65 | + 'message', |
|
66 | + ])); |
|
67 | 67 | |
68 | - return [ |
|
69 | - 'errors' => $errors, |
|
70 | - 'values' => $values, |
|
71 | - ]; |
|
72 | - } |
|
68 | + return [ |
|
69 | + 'errors' => $errors, |
|
70 | + 'values' => $values, |
|
71 | + ]; |
|
72 | + } |
|
73 | 73 | |
74 | - $message = [ |
|
75 | - "Name: {$_POST['name']}", |
|
76 | - "Email: {$_POST['email']}", |
|
77 | - '', |
|
78 | - 'Message:', |
|
79 | - $_POST['message'], |
|
80 | - ]; |
|
81 | - $message = implode("\n", $message); |
|
74 | + $message = [ |
|
75 | + "Name: {$_POST['name']}", |
|
76 | + "Email: {$_POST['email']}", |
|
77 | + '', |
|
78 | + 'Message:', |
|
79 | + $_POST['message'], |
|
80 | + ]; |
|
81 | + $message = implode("\n", $message); |
|
82 | 82 | |
83 | - global $container; |
|
84 | - $container['mail'] |
|
85 | - ->addTo($container['config']->admin_email) |
|
86 | - ->setSubject('Portfolio Contact') |
|
87 | - ->setPlainMessage($message) |
|
88 | - ->send(); |
|
83 | + global $container; |
|
84 | + $container['mail'] |
|
85 | + ->addTo($container['config']->admin_email) |
|
86 | + ->setSubject('Portfolio Contact') |
|
87 | + ->setPlainMessage($message) |
|
88 | + ->send(); |
|
89 | 89 | |
90 | - return [ |
|
91 | - 'success' => |
|
92 | - "Thank you for your message, {$_POST['name']}! " . |
|
93 | - "I'll get back to you as soon as possible." |
|
94 | - ]; |
|
95 | - } |
|
90 | + return [ |
|
91 | + 'success' => |
|
92 | + "Thank you for your message, {$_POST['name']}! " . |
|
93 | + "I'll get back to you as soon as possible." |
|
94 | + ]; |
|
95 | + } |
|
96 | 96 | } |