@@ -6,8 +6,8 @@ |
||
6 | 6 | { |
7 | 7 | |
8 | 8 | private static $COOKIE_NAME = 'commenter'; |
9 | - private static $COOKIE_DURATION = 31536000; // one year |
|
10 | - private static $COOKIE_DOMAIN = 'jacobemerick.com'; |
|
9 | + private static $COOKIE_DURATION = 31536000; // one year |
|
10 | + private static $COOKIE_DOMAIN = 'jacobemerick.com'; |
|
11 | 11 | private static $COOKIE_PATH = '/'; |
12 | 12 | |
13 | 13 | protected function getName() |
@@ -17,14 +17,14 @@ discard block |
||
17 | 17 | |
18 | 18 | public static function instance() |
19 | 19 | { |
20 | - if(!isset(self::$instance)) |
|
20 | + if (!isset(self::$instance)) |
|
21 | 21 | self::$instance = new Loader(); |
22 | 22 | return self::$instance; |
23 | 23 | } |
24 | 24 | |
25 | 25 | private function get_root() |
26 | 26 | { |
27 | - if(!isset($this->root)) |
|
27 | + if (!isset($this->root)) |
|
28 | 28 | { |
29 | 29 | $current_directory = dirname(__FILE__); |
30 | 30 | $current_directory = substr($current_directory, 0, -7); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | |
53 | 53 | private static function get_extension($type) |
54 | 54 | { |
55 | - switch($type) |
|
55 | + switch ($type) |
|
56 | 56 | { |
57 | 57 | case 'collector' : |
58 | 58 | case 'controller' : |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | |
72 | 72 | public static function getImagePath($type, $file) |
73 | 73 | { |
74 | - if($type == 'photo') |
|
74 | + if ($type == 'photo') |
|
75 | 75 | $type = 'photo/processed'; |
76 | 76 | |
77 | 77 | $path = self::instance()->get_root(); |
@@ -107,18 +107,18 @@ discard block |
||
107 | 107 | |
108 | 108 | public static function load($type, $files, $data = array()) |
109 | 109 | { |
110 | - foreach((array) $files as $file) |
|
110 | + foreach ((array) $files as $file) |
|
111 | 111 | { |
112 | 112 | $file_path = self::instance()->get_path($type, $file); |
113 | - if(in_array($file_path, self::instance()->get_included_files()) && $type !== 'view') |
|
113 | + if (in_array($file_path, self::instance()->get_included_files()) && $type !== 'view') |
|
114 | 114 | continue; |
115 | 115 | |
116 | - if(!file_exists($file_path)) |
|
116 | + if (!file_exists($file_path)) |
|
117 | 117 | Debugger::logMessage("Requested file does not exist: {$type}, {$file}"); |
118 | 118 | |
119 | 119 | self::instance()->add_included_file($file_path); |
120 | 120 | |
121 | - switch($type) |
|
121 | + switch ($type) |
|
122 | 122 | { |
123 | 123 | case 'images' : |
124 | 124 | case 'scripts' : |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | |
149 | 149 | $reflectionObject = self::create_reflection_class($file); |
150 | 150 | |
151 | - if( |
|
151 | + if ( |
|
152 | 152 | $reflectionObject->hasMethod('instance') && |
153 | 153 | $reflectionObject->getMethod('instance')->isStatic()) |
154 | 154 | { |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | |
164 | 164 | $reflectionObject = self::create_reflection_class($file); |
165 | 165 | |
166 | - if($reflectionObject->hasMethod('__construct')) |
|
166 | + if ($reflectionObject->hasMethod('__construct')) |
|
167 | 167 | return $reflectionObject->newInstanceArgs($data); |
168 | 168 | else |
169 | 169 | return $reflectionObject->newInstance(); |
@@ -15,11 +15,11 @@ discard block |
||
15 | 15 | static private function form_url_array($host, $uri) |
16 | 16 | { |
17 | 17 | $uri = substr($uri, 1); |
18 | - if(strpos($uri, '?')) |
|
18 | + if (strpos($uri, '?')) |
|
19 | 19 | $uri = substr($uri, 0, strpos($uri, '?')); |
20 | 20 | $uri_array = explode('/', $uri); |
21 | 21 | |
22 | - if(!Loader::isLive()) |
|
22 | + if (!Loader::isLive()) |
|
23 | 23 | $host = substr($host, strpos($host, '.') + 1); |
24 | 24 | |
25 | 25 | self::$array['host'] = $host; |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | self::$array['base'] = 'http://' . (!Loader::isLive() ? 'dev.' : '') . $host . '/'; |
34 | 34 | self::$array['uri'] = '/' . implode('/', $uri_array); |
35 | 35 | |
36 | - if(end($uri_array) == '') |
|
36 | + if (end($uri_array) == '') |
|
37 | 37 | $uri_array = array_slice($uri_array, 0, count($uri_array) - 1); |
38 | 38 | self::$array['pieces'] = (array) $uri_array; |
39 | 39 | } |
@@ -61,21 +61,21 @@ discard block |
||
61 | 61 | static function getExtension() |
62 | 62 | { |
63 | 63 | $file = self::getPiece(-1); |
64 | - if(substr($file, -1) == '/') |
|
64 | + if (substr($file, -1) == '/') |
|
65 | 65 | return false; |
66 | - return substr($file, strrpos($file, '.') + 1);; |
|
66 | + return substr($file, strrpos($file, '.') + 1); ; |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | static function getPiece($piece = null) |
70 | 70 | { |
71 | - if(!$piece) |
|
71 | + if (!$piece) |
|
72 | 72 | return self::$array['pieces']; |
73 | 73 | |
74 | - if($piece == -1) |
|
74 | + if ($piece == -1) |
|
75 | 75 | return end(self::$array['pieces']); |
76 | 76 | |
77 | 77 | $piece = $piece - 1; |
78 | - if(array_key_exists($piece, self::$array['pieces'])) |
|
78 | + if (array_key_exists($piece, self::$array['pieces'])) |
|
79 | 79 | return self::$array['pieces'][$piece]; |
80 | 80 | return; |
81 | 81 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | |
22 | 22 | public function setValue($value) |
23 | 23 | { |
24 | - if(!$this->is_loaded) |
|
24 | + if (!$this->is_loaded) |
|
25 | 25 | $this->load(); |
26 | 26 | |
27 | 27 | $this->value = $value; |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | |
31 | 31 | public function getValue() |
32 | 32 | { |
33 | - if(!$this->is_loaded) |
|
33 | + if (!$this->is_loaded) |
|
34 | 34 | $this->load(); |
35 | 35 | return $this->value; |
36 | 36 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | |
43 | 43 | public function exists() |
44 | 44 | { |
45 | - if(!$this->is_loaded) |
|
45 | + if (!$this->is_loaded) |
|
46 | 46 | $this->load(); |
47 | 47 | return $this->exists; |
48 | 48 | } |
@@ -50,10 +50,10 @@ discard block |
||
50 | 50 | private final function load() |
51 | 51 | { |
52 | 52 | $name = $this->getName(); |
53 | - if(isset($_COOKIE[$name])) |
|
53 | + if (isset($_COOKIE[$name])) |
|
54 | 54 | $value = $_COOKIE[$name]; |
55 | 55 | |
56 | - if(isset($value)) |
|
56 | + if (isset($value)) |
|
57 | 57 | { |
58 | 58 | $this->value = $value; |
59 | 59 | $this->exists = true; |
@@ -66,13 +66,13 @@ discard block |
||
66 | 66 | |
67 | 67 | public final function save() |
68 | 68 | { |
69 | - if(!$this->check_values()) |
|
69 | + if (!$this->check_values()) |
|
70 | 70 | { |
71 | 71 | Debugger::error('Attempt to create a cookie without all of the values being set!'); |
72 | 72 | return false; |
73 | 73 | } |
74 | 74 | |
75 | - if(!$this->set_cookie()) |
|
75 | + if (!$this->set_cookie()) |
|
76 | 76 | { |
77 | 77 | Debugger::log('There was a problem saving the cookie.'); |
78 | 78 | return false; |
@@ -84,23 +84,23 @@ discard block |
||
84 | 84 | private final function check_values() |
85 | 85 | { |
86 | 86 | $name = $this->getName(); |
87 | - if(empty($name) || strlen($name) < 1) |
|
87 | + if (empty($name) || strlen($name) < 1) |
|
88 | 88 | return false; |
89 | 89 | |
90 | 90 | $value = $this->getValue(); |
91 | - if(!isset($value) || strlen($value) < 1) |
|
91 | + if (!isset($value) || strlen($value) < 1) |
|
92 | 92 | return false; |
93 | 93 | |
94 | 94 | $expiration = $this->getExpiration(); |
95 | - if(!isset($expiration) || !is_int($expiration)) |
|
95 | + if (!isset($expiration) || !is_int($expiration)) |
|
96 | 96 | return false; |
97 | 97 | |
98 | 98 | $domain = $this->getDomain(); |
99 | - if(!isset($domain) || strlen($domain) < 1) |
|
99 | + if (!isset($domain) || strlen($domain) < 1) |
|
100 | 100 | return false; |
101 | 101 | |
102 | 102 | $path = $this->getPath(); |
103 | - if(!isset($path) || strlen($path) < 1) |
|
103 | + if (!isset($path) || strlen($path) < 1) |
|
104 | 104 | return false; |
105 | 105 | |
106 | 106 | return true; |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | |
27 | 27 | public static function instance() |
28 | 28 | { |
29 | - if(!isset(self::$instance)) |
|
29 | + if (!isset(self::$instance)) |
|
30 | 30 | self::$instance = new Visitor(); |
31 | 31 | return self::$instance; |
32 | 32 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | public static function getBrowser() |
36 | 36 | { |
37 | 37 | Loader::load('utility', 'environment/BrowserEnvironment'); |
38 | - if(!isset(self::instance()->browser)) |
|
38 | + if (!isset(self::instance()->browser)) |
|
39 | 39 | self::instance()->browser = new BrowserEnvironment(); |
40 | 40 | return self::instance()->browser; |
41 | 41 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | public static function getPlatform() |
45 | 45 | { |
46 | 46 | Loader::load('utility', 'environment/PlatformEnvironment'); |
47 | - if(!isset(self::instance()->platform)) |
|
47 | + if (!isset(self::instance()->platform)) |
|
48 | 48 | self::instance()->platform = new PlatformEnvironment(); |
49 | 49 | return self::instance()->platform; |
50 | 50 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | public static function getIP() |
54 | 54 | { |
55 | 55 | Loader::load('utility', 'Request'); |
56 | - if(!isset(self::instance()->ip_address)) |
|
56 | + if (!isset(self::instance()->ip_address)) |
|
57 | 57 | self::instance()->ip_address = Request::getServer('REMOTE_ADDR'); |
58 | 58 | return self::instance()->ip_address; |
59 | 59 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | Loader::loadInstance('utility', 'Database'); |
80 | 80 | |
81 | 81 | $query = $this->get_tracking_query(); |
82 | - if(Database::execute($query) == true) |
|
82 | + if (Database::execute($query) == true) |
|
83 | 83 | { |
84 | 84 | $this->raw_visit_log_id = Database::lastInsertID(); |
85 | 85 | return true; |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | |
95 | 95 | $columns = '`'; |
96 | 96 | $values = "'"; |
97 | - foreach(self::$tracking_field_array as $field_column => $server_array_key) |
|
97 | + foreach (self::$tracking_field_array as $field_column => $server_array_key) |
|
98 | 98 | { |
99 | 99 | $value = Request::getServer($server_array_key); |
100 | 100 | $value = Database::escape($value); |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | $values .= "{$value}','"; |
104 | 104 | } |
105 | 105 | |
106 | - if(Request::hasPost()) |
|
106 | + if (Request::hasPost()) |
|
107 | 107 | { |
108 | 108 | $value = Request::getPost(); |
109 | 109 | $value = serialize($value); |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | |
122 | 122 | private function track_response_error($code) |
123 | 123 | { |
124 | - if(isset($this->raw_visit_log_id) && $this->raw_visit_log_id > 0) |
|
124 | + if (isset($this->raw_visit_log_id) && $this->raw_visit_log_id > 0) |
|
125 | 125 | { |
126 | 126 | $query = "UPDATE `jpemeric_stat`.`raw_visit_log` SET `code` = '{$code}' WHERE `id` = '{$this->raw_visit_log_id}' LIMIT 1"; |
127 | 127 | return Database::execute($query); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | |
53 | 53 | public function setSize($size) |
54 | 54 | { |
55 | - if($this->get_version() > 1) |
|
55 | + if ($this->get_version() > 1) |
|
56 | 56 | $position = strrpos($this->file, '-v'); |
57 | 57 | else |
58 | 58 | $position = strrpos($this->file, '.'); |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | |
63 | 63 | public function getDimensions() |
64 | 64 | { |
65 | - if(!$this->isValid()) |
|
65 | + if (!$this->isValid()) |
|
66 | 66 | return false; |
67 | 67 | $imageinfo = getimagesize($this->getInternalPath()); |
68 | 68 | return array($imageinfo[0], $imageinfo[1]); |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | |
86 | 86 | private function get_image($image) |
87 | 87 | { |
88 | - if(preg_match(self::$VERSION_PREG_MATCH, $image)) |
|
88 | + if (preg_match(self::$VERSION_PREG_MATCH, $image)) |
|
89 | 89 | return preg_replace(self::$VERSION_PREG_MATCH, '', $image); |
90 | 90 | else |
91 | 91 | return $image; |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | |
100 | 100 | private function get_file($image) |
101 | 101 | { |
102 | - if($this->get_version() > 1) |
|
102 | + if ($this->get_version() > 1) |
|
103 | 103 | { |
104 | 104 | $position = strrpos($image, '.'); |
105 | 105 | return substr($image, 0, $position) . '-v' . $this->get_version() . substr($image, $position); |
@@ -111,14 +111,14 @@ discard block |
||
111 | 111 | private $version; |
112 | 112 | private function get_version() |
113 | 113 | { |
114 | - if(!$this->version) |
|
114 | + if (!$this->version) |
|
115 | 115 | { |
116 | - $path = Loader::getRoot() .'/images/' . substr($this->image, 0, strrpos($this->image, '.')) . '*'; |
|
116 | + $path = Loader::getRoot() . '/images/' . substr($this->image, 0, strrpos($this->image, '.')) . '*'; |
|
117 | 117 | $files = glob($path); |
118 | - if(count($files) > 0) |
|
118 | + if (count($files) > 0) |
|
119 | 119 | { |
120 | 120 | preg_match(self::$VERSION_PREG_MATCH, $files[0], $matches); |
121 | - if(count($matches)) |
|
121 | + if (count($matches)) |
|
122 | 122 | $this->version = $matches[1]; |
123 | 123 | else |
124 | 124 | $this->version = 1; |
@@ -10,10 +10,10 @@ discard block |
||
10 | 10 | protected function execute($title = '') |
11 | 11 | { |
12 | 12 | preg_match_all(self::$MARKUP_DELIMITER, $this->content, $matches); |
13 | - if(count($matches[1]) == 0) |
|
13 | + if (count($matches[1]) == 0) |
|
14 | 14 | return; |
15 | 15 | |
16 | - foreach($matches[3] as $key => $match) |
|
16 | + foreach ($matches[3] as $key => $match) |
|
17 | 17 | { |
18 | 18 | $replacement = $match; |
19 | 19 | $replacement = $this->wrap_in_list($replacement); |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | { |
30 | 30 | $content_array = explode("\n", $content); |
31 | 31 | |
32 | - foreach($content_array as $key => $row) |
|
32 | + foreach ($content_array as $key => $row) |
|
33 | 33 | { |
34 | 34 | $new_row = ($key % 2 == 0) ? '<li class="even">' : '<li class="odd">'; |
35 | 35 | $new_row .= '<p>'; |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | |
47 | 47 | private function highlight_code($content, $type) |
48 | 48 | { |
49 | - switch($type) |
|
49 | + switch ($type) |
|
50 | 50 | { |
51 | 51 | default : |
52 | 52 | return $content; |
@@ -12,9 +12,9 @@ discard block |
||
12 | 12 | protected function execute($is_absolute = true) |
13 | 13 | { |
14 | 14 | preg_match_all(self::$LINK_PLACEHOLDER_MATCH, $this->content, $matches); |
15 | - foreach($matches[1] as $key => $match) |
|
15 | + foreach ($matches[1] as $key => $match) |
|
16 | 16 | { |
17 | - if(isset($matches[3][$key])) |
|
17 | + if (isset($matches[3][$key])) |
|
18 | 18 | $link_content = $this->get_link($match, $is_absolute, $matches[3][$key]); |
19 | 19 | else |
20 | 20 | $link_content = $this->get_link($match, $is_absolute); |
@@ -29,19 +29,19 @@ discard block |
||
29 | 29 | |
30 | 30 | $link = ''; |
31 | 31 | |
32 | - switch($type) |
|
32 | + switch ($type) |
|
33 | 33 | { |
34 | 34 | case 'blog' : |
35 | 35 | Loader::load('collector', 'blog/PostCollector'); |
36 | 36 | $post = PostCollector::getPostByURI($uri); |
37 | 37 | |
38 | - if($post === NULL) |
|
38 | + if ($post === NULL) |
|
39 | 39 | return; |
40 | 40 | |
41 | 41 | $link .= ($is_absolute) ? Loader::getRootURL('blog') : '/'; |
42 | 42 | $link .= "{$post->category}/{$post->path}/"; |
43 | 43 | |
44 | - if($anchor == '') |
|
44 | + if ($anchor == '') |
|
45 | 45 | $anchor = $post->title; |
46 | 46 | |
47 | 47 | break; |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | $link .= ($is_absolute) ? Loader::getRootURL('blog') : '/'; |
50 | 50 | $link .= "tag/{$uri}/"; |
51 | 51 | |
52 | - if($anchor == '') |
|
52 | + if ($anchor == '') |
|
53 | 53 | { |
54 | 54 | $anchor = $uri; |
55 | 55 | $anchor = str_replace('-', ' ', $anchor); |
@@ -61,13 +61,13 @@ discard block |
||
61 | 61 | Loader::load('collector', 'waterfall/LogCollector'); |
62 | 62 | $log = LogCollector::getByAlias($uri); |
63 | 63 | |
64 | - if($log === NULL) |
|
64 | + if ($log === NULL) |
|
65 | 65 | return; |
66 | 66 | |
67 | 67 | $link .= ($is_absolute) ? Loader::getRootURL('waterfalls') : '/'; |
68 | 68 | $link .= "journal/{$log->alias}/"; |
69 | 69 | |
70 | - if($anchor == '') |
|
70 | + if ($anchor == '') |
|
71 | 71 | $anchor = $log->title; |
72 | 72 | |
73 | 73 | break; |
@@ -27,20 +27,20 @@ discard block |
||
27 | 27 | protected function execute() |
28 | 28 | { |
29 | 29 | $args = func_get_args(); |
30 | - if(count($args) < 1) |
|
30 | + if (count($args) < 1) |
|
31 | 31 | { |
32 | 32 | trigger_error('Someone called SmartTrimContent w/o defining a length... bad!'); |
33 | 33 | return; |
34 | 34 | } |
35 | 35 | |
36 | - if(count($args) == 2) |
|
36 | + if (count($args) == 2) |
|
37 | 37 | $etc = $args[1]; |
38 | 38 | else |
39 | 39 | $etc = self::$ETC; |
40 | 40 | |
41 | 41 | $length = $args[0]; |
42 | 42 | |
43 | - if($length < strlen($this->content)) |
|
43 | + if ($length < strlen($this->content)) |
|
44 | 44 | $this->trim_string($length); |
45 | 45 | else |
46 | 46 | $etc = ''; |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | |
55 | 55 | $last_right_bracket_position = strripos($content, self::$RIGHT_BRACKET); |
56 | 56 | $last_left_bracket_position = strripos($content, self::$LEFT_BRACKET); |
57 | - if($last_left_bracket_position > $last_right_bracket_position) |
|
57 | + if ($last_left_bracket_position > $last_right_bracket_position) |
|
58 | 58 | $content = substr($content, 0, $last_left_bracket_position); |
59 | 59 | $content = trim($content); |
60 | 60 | |
@@ -73,16 +73,16 @@ discard block |
||
73 | 73 | $content = current($content); |
74 | 74 | |
75 | 75 | $max_length = $length; |
76 | - foreach($matches[0] as $match) |
|
76 | + foreach ($matches[0] as $match) |
|
77 | 77 | { |
78 | 78 | $max_length += strlen($match[0]); |
79 | - if($max_length <= $match[1]) |
|
79 | + if ($max_length <= $match[1]) |
|
80 | 80 | break; |
81 | 81 | |
82 | 82 | $content = substr($content, 0, $match[1]) . $match[0] . substr($content, $match[1]); |
83 | 83 | } |
84 | 84 | |
85 | - if(substr($content, -7) == '</p><p>') |
|
85 | + if (substr($content, -7) == '</p><p>') |
|
86 | 86 | $content = substr($content, 0, -7); |
87 | 87 | |
88 | 88 | return $content; |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | $tags_preg = $this->get_tags_preg(self::$EXCLUDE_TAGS); |
95 | 95 | preg_match_all($tags_preg, $content, $matches, PREG_OFFSET_CAPTURE); |
96 | 96 | |
97 | - if(count($matches[1]) % 2 == 1) |
|
97 | + if (count($matches[1]) % 2 == 1) |
|
98 | 98 | { |
99 | 99 | $cut_tag = end($matches[1]); |
100 | 100 | $cut_tag_position = $cut_tag[1] - 1; |
@@ -112,9 +112,9 @@ discard block |
||
112 | 112 | preg_match_all($tags_preg, $content, $matches); |
113 | 113 | $open_tags = array(); |
114 | 114 | |
115 | - foreach($matches[1] as $tag) |
|
115 | + foreach ($matches[1] as $tag) |
|
116 | 116 | { |
117 | - if(in_array($tag, $open_tags)) |
|
117 | + if (in_array($tag, $open_tags)) |
|
118 | 118 | { |
119 | 119 | $key = array_search($tag, $open_tags); |
120 | 120 | unset($open_tags[$key]); |
@@ -124,11 +124,11 @@ discard block |
||
124 | 124 | } |
125 | 125 | |
126 | 126 | $open_tags = array_reverse($open_tags); |
127 | - if(count($open_tags) > 0) |
|
127 | + if (count($open_tags) > 0) |
|
128 | 128 | { |
129 | - foreach($open_tags as $key => $open_tag) |
|
129 | + foreach ($open_tags as $key => $open_tag) |
|
130 | 130 | { |
131 | - if($key == count($open_tags) - 1) |
|
131 | + if ($key == count($open_tags) - 1) |
|
132 | 132 | $content .= $etc; |
133 | 133 | $content .= "</{$open_tag}>"; |
134 | 134 | } |