@@ -2,11 +2,11 @@ discard block |
||
2 | 2 | |
3 | 3 | Loader::load('controller', 'portfolio/DefaultPageController'); |
4 | 4 | |
5 | -class ContactController extends DefaultPageController |
|
6 | -{ |
|
5 | +class ContactController extends DefaultPageController |
|
6 | +{ |
|
7 | 7 | |
8 | - protected function set_head_data() |
|
9 | - { |
|
8 | + protected function set_head_data() |
|
9 | + { |
|
10 | 10 | $this->set_title("Contact Page | Jacob Emerick's Portfolio"); |
11 | 11 | $this->set_description("Contact page for Jacob Emerick's Portfolio"); |
12 | 12 | $this->set_keywords([ |
@@ -19,8 +19,8 @@ discard block |
||
19 | 19 | ]); |
20 | 20 | } |
21 | 21 | |
22 | - protected function set_body_data() |
|
23 | - { |
|
22 | + protected function set_body_data() |
|
23 | + { |
|
24 | 24 | $this->set_body('body_view', 'Contact'); |
25 | 25 | |
26 | 26 | $body_data = []; |
@@ -33,8 +33,8 @@ discard block |
||
33 | 33 | parent::set_body_data(); |
34 | 34 | } |
35 | 35 | |
36 | - private function process_form_data() |
|
37 | - { |
|
36 | + private function process_form_data() |
|
37 | + { |
|
38 | 38 | $errors = []; |
39 | 39 | |
40 | 40 | if ( |
@@ -2,11 +2,11 @@ discard block |
||
2 | 2 | |
3 | 3 | Loader::load('controller', 'portfolio/DefaultPageController'); |
4 | 4 | |
5 | -class AboutController extends DefaultPageController |
|
6 | -{ |
|
5 | +class AboutController extends DefaultPageController |
|
6 | +{ |
|
7 | 7 | |
8 | - protected function set_head_data() |
|
9 | - { |
|
8 | + protected function set_head_data() |
|
9 | + { |
|
10 | 10 | $this->set_title("Jacob Emerick's Portfolio"); |
11 | 11 | $this->set_description("Jacob Emerick's Portfolio - collection of programming projects and resume"); |
12 | 12 | $this->set_keywords([ |
@@ -20,8 +20,8 @@ discard block |
||
20 | 20 | ]); |
21 | 21 | } |
22 | 22 | |
23 | - protected function set_body_data() |
|
24 | - { |
|
23 | + protected function set_body_data() |
|
24 | + { |
|
25 | 25 | $this->set_body('body_view', 'About'); |
26 | 26 | $this->set_body('body_data', []); |
27 | 27 |
@@ -2,16 +2,20 @@ |
||
2 | 2 | |
3 | 3 | Loader::load('controller', '/PageController'); |
4 | 4 | |
5 | -class Error303Controller extends PageController |
|
6 | -{ |
|
5 | +class Error303Controller extends PageController |
|
6 | +{ |
|
7 | 7 | |
8 | - public function __construct($uri) |
|
9 | - { |
|
8 | + public function __construct($uri) |
|
9 | + { |
|
10 | 10 | Header::redirect($uri, 303); |
11 | 11 | exit; |
12 | 12 | } |
13 | 13 | |
14 | - protected function set_head_data() {} |
|
15 | - protected function set_body_data() {} |
|
14 | + protected function set_head_data() |
|
15 | + { |
|
16 | +} |
|
17 | + protected function set_body_data() |
|
18 | + { |
|
19 | +} |
|
16 | 20 | |
17 | 21 | } |
@@ -4,8 +4,8 @@ discard block |
||
4 | 4 | 'Header', |
5 | 5 | 'Request')); |
6 | 6 | |
7 | -abstract class AJAXController |
|
8 | -{ |
|
7 | +abstract class AJAXController |
|
8 | +{ |
|
9 | 9 | |
10 | 10 | private static $RESPONSE_HEADER = 'sendJSON'; |
11 | 11 | |
@@ -13,18 +13,20 @@ discard block |
||
13 | 13 | |
14 | 14 | abstract protected function set_data(); |
15 | 15 | |
16 | - function __construct() {} |
|
16 | + function __construct() |
|
17 | + { |
|
18 | +} |
|
17 | 19 | |
18 | - public function activate() |
|
19 | - { |
|
20 | + public function activate() |
|
21 | + { |
|
20 | 22 | call_user_func(array('Header', self::$RESPONSE_HEADER)); |
21 | 23 | |
22 | 24 | $this->set_data(); |
23 | 25 | echo $this->response_as_json(); |
24 | 26 | } |
25 | 27 | |
26 | - protected function set_response($message, $type = 'internal') |
|
27 | - { |
|
28 | + protected function set_response($message, $type = 'internal') |
|
29 | + { |
|
28 | 30 | switch($type) |
29 | 31 | { |
30 | 32 | case 'internal' : |
@@ -38,21 +40,21 @@ discard block |
||
38 | 40 | } |
39 | 41 | } |
40 | 42 | |
41 | - protected function fail_response($message) |
|
42 | - { |
|
43 | + protected function fail_response($message) |
|
44 | + { |
|
43 | 45 | $this->set_response($message, 'error'); |
44 | 46 | return false; |
45 | 47 | } |
46 | 48 | |
47 | - protected function eject($message) |
|
48 | - { |
|
49 | + protected function eject($message) |
|
50 | + { |
|
49 | 51 | $this->fail_response($message); |
50 | 52 | echo $this->response_as_json(); |
51 | 53 | exit(); |
52 | 54 | } |
53 | 55 | |
54 | - private function response_as_json() |
|
55 | - { |
|
56 | + private function response_as_json() |
|
57 | + { |
|
56 | 58 | return json_encode($this->response); |
57 | 59 | } |
58 | 60 |
@@ -2,16 +2,20 @@ |
||
2 | 2 | |
3 | 3 | Loader::load('controller', '/PageController'); |
4 | 4 | |
5 | -class Error301Controller extends PageController |
|
6 | -{ |
|
5 | +class Error301Controller extends PageController |
|
6 | +{ |
|
7 | 7 | |
8 | - public function __construct($uri) |
|
9 | - { |
|
8 | + public function __construct($uri) |
|
9 | + { |
|
10 | 10 | Header::redirect($uri); |
11 | 11 | exit; |
12 | 12 | } |
13 | 13 | |
14 | - protected function set_head_data() {} |
|
15 | - protected function set_body_data() {} |
|
14 | + protected function set_head_data() |
|
15 | + { |
|
16 | +} |
|
17 | + protected function set_body_data() |
|
18 | + { |
|
19 | +} |
|
16 | 20 | |
17 | 21 | } |
@@ -5,8 +5,8 @@ discard block |
||
5 | 5 | Loader::load('controller', 'home/DefaultPageController'); |
6 | 6 | Loader::load('utility', 'Content'); |
7 | 7 | |
8 | -final class HomeController extends DefaultPageController |
|
9 | -{ |
|
8 | +final class HomeController extends DefaultPageController |
|
9 | +{ |
|
10 | 10 | |
11 | 11 | private static $TITLE = "Jacob Emerick's Home | Web Developer, Hiker, Innovator"; |
12 | 12 | private static $DESCRIPTION = 'Home page for Jacob Emerick, with links to his blog, waterfall site, and other side projects'; |
@@ -24,8 +24,8 @@ discard block |
||
24 | 24 | private static $POST_LENGTH_SHORT = 160; |
25 | 25 | private static $POST_LENGTH_LONG = 240; |
26 | 26 | |
27 | - protected function set_head_data() |
|
28 | - { |
|
27 | + protected function set_head_data() |
|
28 | + { |
|
29 | 29 | $this->set_title(self::$TITLE); |
30 | 30 | $this->set_description(self::$DESCRIPTION); |
31 | 31 | $this->set_keywords(self::$KEYWORD_ARRAY); |
@@ -33,16 +33,16 @@ discard block |
||
33 | 33 | parent::set_head_data(); |
34 | 34 | } |
35 | 35 | |
36 | - protected function set_body_data() |
|
37 | - { |
|
36 | + protected function set_body_data() |
|
37 | + { |
|
38 | 38 | $this->set_body('post_array', $this->get_recent_posts()); |
39 | 39 | $this->set_body_view('Home'); |
40 | 40 | |
41 | 41 | parent::set_body_data(); |
42 | 42 | } |
43 | 43 | |
44 | - private function get_recent_posts() |
|
45 | - { |
|
44 | + private function get_recent_posts() |
|
45 | + { |
|
46 | 46 | global $container; |
47 | 47 | $postRepository = new MysqlPostRepository($container['db_connection_locator']); |
48 | 48 | $recentPosts = $postRepository->getActivePosts(3); |
@@ -2,15 +2,15 @@ discard block |
||
2 | 2 | |
3 | 3 | Loader::load('utility', 'Content'); |
4 | 4 | |
5 | -final class FixPhotoContent extends Content |
|
6 | -{ |
|
5 | +final class FixPhotoContent extends Content |
|
6 | +{ |
|
7 | 7 | |
8 | 8 | private static $PHOTO_PLACEHOLDER_MATCH = '@{{photo="(.*)"}}@'; |
9 | 9 | private static $ERROR_CONTENT = '<div class="photo-holder"><p class="photo-caption">Image (%s) could not be found!</p></div>'; |
10 | 10 | private static $PHOTO_CONTENT = '<div class="photo-holder"><img src="%sphoto/%s/%s-size-%s.jpg" height="%d" width="%d" alt="%s" /><p class="photo-caption">%s</p></div>'; |
11 | 11 | |
12 | - protected function execute($is_absolute = false, $size = 'medium') |
|
13 | - { |
|
12 | + protected function execute($is_absolute = false, $size = 'medium') |
|
13 | + { |
|
14 | 14 | preg_match_all(self::$PHOTO_PLACEHOLDER_MATCH, $this->content, $matches); |
15 | 15 | foreach($matches[1] as $key => $match) |
16 | 16 | { |
@@ -20,14 +20,14 @@ discard block |
||
20 | 20 | return; |
21 | 21 | } |
22 | 22 | |
23 | - private function get_file_path($category, $photo, $size, $extension) |
|
24 | - { |
|
23 | + private function get_file_path($category, $photo, $size, $extension) |
|
24 | + { |
|
25 | 25 | $path = "{$category}/{$photo}-size-{$size}.{$extension}"; |
26 | 26 | return Loader::getImagePath('photo', $path); |
27 | 27 | } |
28 | 28 | |
29 | - private function get_photo_content($string, $size, $is_absolute) |
|
30 | - { |
|
29 | + private function get_photo_content($string, $size, $is_absolute) |
|
30 | + { |
|
31 | 31 | list($category, $file_name) = explode('/', $string); |
32 | 32 | list($photo, $extension) = explode('.', $file_name); |
33 | 33 | |
@@ -37,16 +37,18 @@ discard block |
||
37 | 37 | |
38 | 38 | Loader::load('collector', 'image/PhotoCollector'); |
39 | 39 | $photo_result = PhotoCollector::fetchRow($category, $photo); |
40 | - if($photo_result == false) |
|
41 | - return ''; |
|
40 | + if($photo_result == false) { |
|
41 | + return ''; |
|
42 | + } |
|
42 | 43 | |
43 | 44 | $height = $file_size[1]; |
44 | 45 | $width = $file_size[0]; |
45 | 46 | $description = $photo_result->description; |
46 | 47 | |
47 | 48 | $domain = '/'; |
48 | - if($is_absolute) |
|
49 | - $domain = Loader::getRootUrl('blog'); |
|
49 | + if($is_absolute) { |
|
50 | + $domain = Loader::getRootUrl('blog'); |
|
51 | + } |
|
50 | 52 | |
51 | 53 | return sprintf(self::$PHOTO_CONTENT, $domain, $category, $photo, $size, $height, $width, $description, $description); |
52 | 54 | } |
@@ -2,30 +2,31 @@ discard block |
||
2 | 2 | |
3 | 3 | Loader::load('utility', 'Content'); |
4 | 4 | |
5 | -final class FetchFirstPhotoContent extends Content |
|
6 | -{ |
|
5 | +final class FetchFirstPhotoContent extends Content |
|
6 | +{ |
|
7 | 7 | |
8 | 8 | private static $PHOTO_PLACEHOLDER_MATCH = '@{{photo="(.*)"}}@'; |
9 | 9 | private static $IMAGE_NODE = '<img src="%sphoto/%s/%s-size-%s.%s" height="%d" width="%d" alt="%s" />'; |
10 | 10 | private static $DEFAULT_RETURN = ''; |
11 | 11 | |
12 | - protected function execute($is_absolute = false, $size = 'thumb') |
|
13 | - { |
|
14 | - if(preg_match(self::$PHOTO_PLACEHOLDER_MATCH, $this->content, $match) === 1) |
|
15 | - $this->content = $this->get_thumb($match[1], $is_absolute, $size); |
|
16 | - else |
|
17 | - $this->content = self::$DEFAULT_RETURN; |
|
12 | + protected function execute($is_absolute = false, $size = 'thumb') |
|
13 | + { |
|
14 | + if(preg_match(self::$PHOTO_PLACEHOLDER_MATCH, $this->content, $match) === 1) { |
|
15 | + $this->content = $this->get_thumb($match[1], $is_absolute, $size); |
|
16 | + } else { |
|
17 | + $this->content = self::$DEFAULT_RETURN; |
|
18 | + } |
|
18 | 19 | return; |
19 | 20 | } |
20 | 21 | |
21 | - private function get_file_path($category, $photo, $size, $extension) |
|
22 | - { |
|
22 | + private function get_file_path($category, $photo, $size, $extension) |
|
23 | + { |
|
23 | 24 | $path = "{$category}/{$photo}-size-{$size}.{$extension}"; |
24 | 25 | return Loader::getImagePath('photo', $path); |
25 | 26 | } |
26 | 27 | |
27 | - private function get_thumb($string, $is_absolute, $size) |
|
28 | - { |
|
28 | + private function get_thumb($string, $is_absolute, $size) |
|
29 | + { |
|
29 | 30 | list($category, $file_name) = explode('/', $string); |
30 | 31 | list($photo, $extension) = explode('.', $file_name); |
31 | 32 | |
@@ -34,16 +35,18 @@ discard block |
||
34 | 35 | |
35 | 36 | Loader::load('collector', 'image/PhotoCollector'); |
36 | 37 | $photo_result = PhotoCollector::fetchRow($category, $photo); |
37 | - if($photo_result == false) |
|
38 | - return ''; |
|
38 | + if($photo_result == false) { |
|
39 | + return ''; |
|
40 | + } |
|
39 | 41 | |
40 | 42 | $height = $file_size[1]; |
41 | 43 | $width = $file_size[0]; |
42 | 44 | $description = $photo_result->description; |
43 | 45 | |
44 | 46 | $domain = '/'; |
45 | - if($is_absolute) |
|
46 | - $domain = Loader::getRootURL(URLDecode::getSite()); |
|
47 | + if($is_absolute) { |
|
48 | + $domain = Loader::getRootURL(URLDecode::getSite()); |
|
49 | + } |
|
47 | 50 | |
48 | 51 | return sprintf(self::$IMAGE_NODE, $domain, $category, $photo, $size, $extension, $height, $width, $description); |
49 | 52 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -final class Loader |
|
4 | -{ |
|
3 | +final class Loader |
|
4 | +{ |
|
5 | 5 | |
6 | 6 | private $root; |
7 | 7 | private $is_live; |
@@ -9,21 +9,22 @@ discard block |
||
9 | 9 | |
10 | 10 | private static $instance; |
11 | 11 | |
12 | - private function __construct() |
|
13 | - { |
|
12 | + private function __construct() |
|
13 | + { |
|
14 | 14 | $this->is_live = (isset($_SERVER['HTTP_HOST']) && substr($_SERVER['HTTP_HOST'], 0, 4) !== 'dev.'); |
15 | 15 | return $this; |
16 | 16 | } |
17 | 17 | |
18 | - public static function instance() |
|
19 | - { |
|
20 | - if(!isset(self::$instance)) |
|
21 | - self::$instance = new Loader(); |
|
18 | + public static function instance() |
|
19 | + { |
|
20 | + if(!isset(self::$instance)) { |
|
21 | + self::$instance = new Loader(); |
|
22 | + } |
|
22 | 23 | return self::$instance; |
23 | 24 | } |
24 | 25 | |
25 | - private function get_root() |
|
26 | - { |
|
26 | + private function get_root() |
|
27 | + { |
|
27 | 28 | if(!isset($this->root)) |
28 | 29 | { |
29 | 30 | $current_directory = dirname(__FILE__); |
@@ -34,24 +35,24 @@ discard block |
||
34 | 35 | return $this->root; |
35 | 36 | } |
36 | 37 | |
37 | - private function get_delimiter() |
|
38 | - { |
|
38 | + private function get_delimiter() |
|
39 | + { |
|
39 | 40 | return (true || $this->is_live) ? '/' : '\\'; |
40 | 41 | } |
41 | 42 | |
42 | - private function check_delimiters($path) |
|
43 | - { |
|
43 | + private function check_delimiters($path) |
|
44 | + { |
|
44 | 45 | return (true || $this->is_live) ? $path : str_replace('/', '\\', $path); |
45 | 46 | } |
46 | 47 | |
47 | - private static function get_class_name($path) |
|
48 | - { |
|
48 | + private static function get_class_name($path) |
|
49 | + { |
|
49 | 50 | $path_array = explode('/', $path); |
50 | 51 | return array_pop($path_array); |
51 | 52 | } |
52 | 53 | |
53 | - private static function get_extension($type) |
|
54 | - { |
|
54 | + private static function get_extension($type) |
|
55 | + { |
|
55 | 56 | switch($type) |
56 | 57 | { |
57 | 58 | case 'collector' : |
@@ -69,8 +70,8 @@ discard block |
||
69 | 70 | return $extension; |
70 | 71 | } |
71 | 72 | |
72 | - public static function getImagePath($type, $file) |
|
73 | - { |
|
73 | + public static function getImagePath($type, $file) |
|
74 | + { |
|
74 | 75 | $path = self::instance()->get_root(); |
75 | 76 | $path .= 'public'; |
76 | 77 | $path .= self::instance()->get_delimiter(); |
@@ -81,8 +82,8 @@ discard block |
||
81 | 82 | return $path; |
82 | 83 | } |
83 | 84 | |
84 | - private static function get_path($type, $file) |
|
85 | - { |
|
85 | + private static function get_path($type, $file) |
|
86 | + { |
|
86 | 87 | $path = self::instance()->get_root(); |
87 | 88 | $path .= $type; |
88 | 89 | $path .= self::instance()->get_delimiter(); |
@@ -92,23 +93,24 @@ discard block |
||
92 | 93 | return $path; |
93 | 94 | } |
94 | 95 | |
95 | - private function get_included_files() |
|
96 | - { |
|
96 | + private function get_included_files() |
|
97 | + { |
|
97 | 98 | return $this->included_files; |
98 | 99 | } |
99 | 100 | |
100 | - private function add_included_file($path) |
|
101 | - { |
|
101 | + private function add_included_file($path) |
|
102 | + { |
|
102 | 103 | $this->included_files[] = $path; |
103 | 104 | } |
104 | 105 | |
105 | - public static function load($type, $files, $data = array()) |
|
106 | - { |
|
106 | + public static function load($type, $files, $data = array()) |
|
107 | + { |
|
107 | 108 | foreach((array) $files as $file) |
108 | 109 | { |
109 | 110 | $file_path = self::instance()->get_path($type, $file); |
110 | - if(in_array($file_path, self::instance()->get_included_files()) && $type !== 'view') |
|
111 | - continue; |
|
111 | + if(in_array($file_path, self::instance()->get_included_files()) && $type !== 'view') { |
|
112 | + continue; |
|
113 | + } |
|
112 | 114 | |
113 | 115 | self::instance()->add_included_file($file_path); |
114 | 116 | |
@@ -130,14 +132,14 @@ discard block |
||
130 | 132 | } |
131 | 133 | } |
132 | 134 | |
133 | - private static function create_reflection_class($file) |
|
134 | - { |
|
135 | + private static function create_reflection_class($file) |
|
136 | + { |
|
135 | 137 | $class_name = self::instance()->get_class_name($file); |
136 | 138 | return new ReflectionClass($class_name); |
137 | 139 | } |
138 | 140 | |
139 | - public static function loadInstance($type, $file) |
|
140 | - { |
|
141 | + public static function loadInstance($type, $file) |
|
142 | + { |
|
141 | 143 | self::load($type, $file); |
142 | 144 | |
143 | 145 | $reflectionObject = self::create_reflection_class($file); |
@@ -151,30 +153,31 @@ discard block |
||
151 | 153 | trigger_error("Requested class cannot be instance'd: {$type}, {$file}"); |
152 | 154 | } |
153 | 155 | |
154 | - public static function loadNew($type, $file, $data = array()) |
|
155 | - { |
|
156 | + public static function loadNew($type, $file, $data = array()) |
|
157 | + { |
|
156 | 158 | self::load($type, $file); |
157 | 159 | |
158 | 160 | $reflectionObject = self::create_reflection_class($file); |
159 | 161 | |
160 | - if($reflectionObject->hasMethod('__construct')) |
|
161 | - return $reflectionObject->newInstanceArgs($data); |
|
162 | - else |
|
163 | - return $reflectionObject->newInstance(); |
|
162 | + if($reflectionObject->hasMethod('__construct')) { |
|
163 | + return $reflectionObject->newInstanceArgs($data); |
|
164 | + } else { |
|
165 | + return $reflectionObject->newInstance(); |
|
166 | + } |
|
164 | 167 | } |
165 | 168 | |
166 | - public static function getRoot() |
|
167 | - { |
|
169 | + public static function getRoot() |
|
170 | + { |
|
168 | 171 | return self::instance()->get_root(); |
169 | 172 | } |
170 | 173 | |
171 | - public static function isLive() |
|
172 | - { |
|
174 | + public static function isLive() |
|
175 | + { |
|
173 | 176 | return self::instance()->is_live; |
174 | 177 | } |
175 | 178 | |
176 | - public static function getRootURL($site = '') |
|
177 | - { |
|
179 | + public static function getRootURL($site = '') |
|
180 | + { |
|
178 | 181 | if (strlen($site) > 0) { |
179 | 182 | $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http'; |
180 | 183 | if ($site == 'waterfalls' && self::instance()->is_live) { |