@@ -7,6 +7,9 @@ |
||
| 7 | 7 | |
| 8 | 8 | abstract public function activate(); |
| 9 | 9 | |
| 10 | + /** |
|
| 11 | + * @param string $value |
|
| 12 | + */ |
|
| 10 | 13 | protected function error($value) |
| 11 | 14 | {
|
| 12 | 15 | trigger_error("Cron failed: {$value}");
|
@@ -59,6 +59,9 @@ discard block |
||
| 59 | 59 | $this->add_posts($youtube_result, 'youtube'); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | + /** |
|
| 63 | + * @param string $type |
|
| 64 | + */ |
|
| 62 | 65 | private function remove_existing($result, $type) |
| 63 | 66 | {
|
| 64 | 67 | foreach($result as $key => $row) |
@@ -70,6 +73,9 @@ discard block |
||
| 70 | 73 | return $result; |
| 71 | 74 | } |
| 72 | 75 | |
| 76 | + /** |
|
| 77 | + * @param string $type |
|
| 78 | + */ |
|
| 73 | 79 | private function add_posts($result, $type) |
| 74 | 80 | {
|
| 75 | 81 | foreach($result as $row) |
@@ -61,10 +61,10 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | private function remove_existing($result, $type) |
| 63 | 63 | { |
| 64 | - foreach($result as $key => $row) |
|
| 64 | + foreach ($result as $key => $row) |
|
| 65 | 65 | { |
| 66 | 66 | $stream_result = ActivityCollector::getPostByFields($row->id, $type); |
| 67 | - if($stream_result) |
|
| 67 | + if ($stream_result) |
|
| 68 | 68 | unset($result[$key]); |
| 69 | 69 | } |
| 70 | 70 | return $result; |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | private function add_posts($result, $type) |
| 74 | 74 | { |
| 75 | - foreach($result as $row) |
|
| 75 | + foreach ($result as $row) |
|
| 76 | 76 | { |
| 77 | 77 | $query = sprintf(self::$QUERY, $type, $row->id, $row->date); |
| 78 | 78 | Database::execute($query); |
@@ -64,8 +64,9 @@ |
||
| 64 | 64 | foreach($result as $key => $row) |
| 65 | 65 | { |
| 66 | 66 | $stream_result = ActivityCollector::getPostByFields($row->id, $type); |
| 67 | - if($stream_result) |
|
| 68 | - unset($result[$key]); |
|
| 67 | + if($stream_result) {
|
|
| 68 | + unset($result[$key]); |
|
| 69 | + } |
|
| 69 | 70 | } |
| 70 | 71 | return $result; |
| 71 | 72 | } |
@@ -239,6 +239,9 @@ |
||
| 239 | 239 | return $text; |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | + /** |
|
| 243 | + * @param string $type |
|
| 244 | + */ |
|
| 242 | 245 | private function get_replace_text($entity_type, $entity, $type) |
| 243 | 246 | {
|
| 244 | 247 | switch($entity_type) |
@@ -20,21 +20,21 @@ |
||
| 20 | 20 | private static $USER_MENTION_LINK = '<a href="https://twitter.com/%1$s" rel="nofollow" target="_blank" title="%2$s (%1$s) on Twitter">@%1$s</a>'; |
| 21 | 21 | private static $MEDIA_LINK = '<a class="photo" href="%s" rel="nofollow" target="_blank" title="%s"><img src="%s:%s" alt="%s" height="%s" width="%s" /></a>'; |
| 22 | 22 | |
| 23 | - private $consumer_key; |
|
| 24 | - private $consumer_secret; |
|
| 25 | - private $access_token; |
|
| 26 | - private $access_secret; |
|
| 23 | + private $consumer_key; |
|
| 24 | + private $consumer_secret; |
|
| 25 | + private $access_token; |
|
| 26 | + private $access_secret; |
|
| 27 | 27 | |
| 28 | 28 | private $json; |
| 29 | 29 | |
| 30 | 30 | public function __construct() |
| 31 | 31 | { |
| 32 | - global $config; |
|
| 32 | + global $config; |
|
| 33 | 33 | |
| 34 | - $this->consumer_key = $config->twitter->consumer_key; |
|
| 35 | - $this->consumer_secret = $config->twitter->consumer_secret; |
|
| 36 | - $this->access_token = $config->twitter->access_token; |
|
| 37 | - $this->access_secret = $config->twitter->access_secret; |
|
| 34 | + $this->consumer_key = $config->twitter->consumer_key; |
|
| 35 | + $this->consumer_secret = $config->twitter->consumer_secret; |
|
| 36 | + $this->access_token = $config->twitter->access_token; |
|
| 37 | + $this->access_secret = $config->twitter->access_secret; |
|
| 38 | 38 | |
| 39 | 39 | $json = $this->get_data(); |
| 40 | 40 | |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | private $oauth_array; |
| 84 | 84 | private function get_oauth_array() |
| 85 | 85 | { |
| 86 | - if(!isset($this->oauth_array)) |
|
| 86 | + if (!isset($this->oauth_array)) |
|
| 87 | 87 | { |
| 88 | 88 | $this->oauth_array = array( |
| 89 | 89 | 'screen_name' => self::$SCREEN_NAME, |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | { |
| 117 | 117 | $encoded_array = array(); |
| 118 | 118 | ksort($array); |
| 119 | - foreach($array as $key => $value) |
|
| 119 | + foreach ($array as $key => $value) |
|
| 120 | 120 | { |
| 121 | 121 | $value = rawurlencode($value); |
| 122 | 122 | $value = ($wrap_values) ? '"' . $value . '"' : $value; |
@@ -127,27 +127,27 @@ discard block |
||
| 127 | 127 | |
| 128 | 128 | public function activate() |
| 129 | 129 | { |
| 130 | - if(!$this->json) |
|
| 130 | + if (!$this->json) |
|
| 131 | 131 | return $this->error('Could not connect to twitter json feed.'); |
| 132 | 132 | |
| 133 | 133 | $count = 0; |
| 134 | - foreach($this->json as $status) |
|
| 134 | + foreach ($this->json as $status) |
|
| 135 | 135 | { |
| 136 | 136 | $text = Database::escape($status->text); |
| 137 | 137 | $date = date('Y-m-d H:i:s', strtotime($status->created_at)); |
| 138 | 138 | |
| 139 | 139 | $tweet_result = TwitterCollector::getTweetByFields($date, $text); |
| 140 | - if($tweet_result !== null) |
|
| 140 | + if ($tweet_result !== null) |
|
| 141 | 141 | { |
| 142 | 142 | $favorites = (int) $status->favorite_count; |
| 143 | - if($favorites != 0 && $tweet_result->favorites != $favorites) |
|
| 143 | + if ($favorites != 0 && $tweet_result->favorites != $favorites) |
|
| 144 | 144 | { |
| 145 | 145 | $query = sprintf(self::$UPDATE_FAVORITES_QUERY, $favorites, $tweet_result->id); |
| 146 | 146 | Database::execute($query); |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | $retweets = (int) $status->retweet_count; |
| 150 | - if($retweets != 0 && $tweet_result->retweets != $retweets) |
|
| 150 | + if ($retweets != 0 && $tweet_result->retweets != $retweets) |
|
| 151 | 151 | { |
| 152 | 152 | $query = sprintf(self::$UPDATE_RETWEETS_QUERY, $retweets, $tweet_result->id); |
| 153 | 153 | Database::execute($query); |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | { |
| 158 | 158 | $twitter_id = (string) $status->id_str; |
| 159 | 159 | |
| 160 | - if(isset($status->retweeted_status)) |
|
| 160 | + if (isset($status->retweeted_status)) |
|
| 161 | 161 | { |
| 162 | 162 | $text_formatted = $this->get_formatted($status->retweeted_status->text, $status->retweeted_status->entities); |
| 163 | 163 | $text_formatted_full = $this->get_formatted($status->retweeted_status->text, $status->retweeted_status->entities, 'full'); |
@@ -200,9 +200,9 @@ discard block |
||
| 200 | 200 | |
| 201 | 201 | private function get_source($source) |
| 202 | 202 | { |
| 203 | - if(stristr($source, 'tweetdeck')) |
|
| 203 | + if (stristr($source, 'tweetdeck')) |
|
| 204 | 204 | return 'tweetdeck'; |
| 205 | - if(stristr($source, 'windows phone')) |
|
| 205 | + if (stristr($source, 'windows phone')) |
|
| 206 | 206 | return 'phone'; |
| 207 | 207 | else |
| 208 | 208 | return ''; |
@@ -211,9 +211,9 @@ discard block |
||
| 211 | 211 | private function get_formatted($text, $entities, $type = 'short') |
| 212 | 212 | { |
| 213 | 213 | $holder = array(); |
| 214 | - foreach($entities as $entity_type => $entity_collection) |
|
| 214 | + foreach ($entities as $entity_type => $entity_collection) |
|
| 215 | 215 | { |
| 216 | - foreach($entity_collection as $entity) |
|
| 216 | + foreach ($entity_collection as $entity) |
|
| 217 | 217 | { |
| 218 | 218 | $start = $entity->indices[0]; |
| 219 | 219 | $end = $entity->indices[1]; |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | |
| 229 | 229 | krsort($holder); |
| 230 | 230 | |
| 231 | - foreach($holder as $entity) |
|
| 231 | + foreach ($holder as $entity) |
|
| 232 | 232 | { |
| 233 | 233 | $text = mb_substr($text, 0, $entity->start, 'UTF-8') . $entity->replace . mb_substr($text, $entity->end, 5000, 'UTF-8'); |
| 234 | 234 | } |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | |
| 242 | 242 | private function get_replace_text($entity_type, $entity, $type) |
| 243 | 243 | { |
| 244 | - switch($entity_type) |
|
| 244 | + switch ($entity_type) |
|
| 245 | 245 | { |
| 246 | 246 | case 'hashtags' : |
| 247 | 247 | $replace = sprintf(self::$HASHTAG_LINK, $entity->text); |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | $replace = sprintf(self::$USER_MENTION_LINK, $entity->screen_name, $entity->name); |
| 254 | 254 | break; |
| 255 | 255 | case 'media' : |
| 256 | - if($type == 'full') |
|
| 256 | + if ($type == 'full') |
|
| 257 | 257 | $replace = sprintf(self::$MEDIA_LINK, $entity->url, $entity->display_url, $entity->media_url, 'large', 'Photo from Twitter', $entity->sizes->large->h, $entity->sizes->large->w); |
| 258 | 258 | else |
| 259 | 259 | $replace = sprintf(self::$URL_LINK, $entity->url, $entity->expanded_url, $entity->display_url); |
@@ -127,8 +127,9 @@ discard block |
||
| 127 | 127 | |
| 128 | 128 | public function activate() |
| 129 | 129 | { |
| 130 | - if(!$this->json) |
|
| 131 | - return $this->error('Could not connect to twitter json feed.'); |
|
| 130 | + if(!$this->json) {
|
|
| 131 | + return $this->error('Could not connect to twitter json feed.');
|
|
| 132 | + } |
|
| 132 | 133 | |
| 133 | 134 | $count = 0; |
| 134 | 135 | foreach($this->json as $status) |
@@ -152,8 +153,7 @@ discard block |
||
| 152 | 153 | $query = sprintf(self::$UPDATE_RETWEETS_QUERY, $retweets, $tweet_result->id); |
| 153 | 154 | Database::execute($query); |
| 154 | 155 | } |
| 155 | - } |
|
| 156 | - else |
|
| 156 | + } else |
|
| 157 | 157 | { |
| 158 | 158 | $twitter_id = (string) $status->id_str; |
| 159 | 159 | |
@@ -164,8 +164,7 @@ discard block |
||
| 164 | 164 | |
| 165 | 165 | $text_formatted = $this->prepend_original_user($status->retweeted_status->user, $text_formatted); |
| 166 | 166 | $text_formatted_full = $this->prepend_original_user($status->retweeted_status->user, $text_formatted_full); |
| 167 | - } |
|
| 168 | - else |
|
| 167 | + } else |
|
| 169 | 168 | { |
| 170 | 169 | $text_formatted = $this->get_formatted($status->text, $status->entities); |
| 171 | 170 | $text_formatted_full = $this->get_formatted($status->text, $status->entities, 'full'); |
@@ -200,12 +199,14 @@ discard block |
||
| 200 | 199 | |
| 201 | 200 | private function get_source($source) |
| 202 | 201 | { |
| 203 | - if(stristr($source, 'tweetdeck')) |
|
| 204 | - return 'tweetdeck'; |
|
| 205 | - if(stristr($source, 'windows phone')) |
|
| 206 | - return 'phone'; |
|
| 207 | - else |
|
| 208 | - return ''; |
|
| 202 | + if(stristr($source, 'tweetdeck')) {
|
|
| 203 | + return 'tweetdeck'; |
|
| 204 | + } |
|
| 205 | + if(stristr($source, 'windows phone')) {
|
|
| 206 | + return 'phone'; |
|
| 207 | + } else {
|
|
| 208 | + return ''; |
|
| 209 | + } |
|
| 209 | 210 | } |
| 210 | 211 | |
| 211 | 212 | private function get_formatted($text, $entities, $type = 'short') |
@@ -253,10 +254,11 @@ discard block |
||
| 253 | 254 | $replace = sprintf(self::$USER_MENTION_LINK, $entity->screen_name, $entity->name); |
| 254 | 255 | break; |
| 255 | 256 | case 'media' : |
| 256 | - if($type == 'full') |
|
| 257 | - $replace = sprintf(self::$MEDIA_LINK, $entity->url, $entity->display_url, $entity->media_url, 'large', 'Photo from Twitter', $entity->sizes->large->h, $entity->sizes->large->w); |
|
| 258 | - else |
|
| 259 | - $replace = sprintf(self::$URL_LINK, $entity->url, $entity->expanded_url, $entity->display_url); |
|
| 257 | + if($type == 'full') {
|
|
| 258 | + $replace = sprintf(self::$MEDIA_LINK, $entity->url, $entity->display_url, $entity->media_url, 'large', 'Photo from Twitter', $entity->sizes->large->h, $entity->sizes->large->w); |
|
| 259 | + } else {
|
|
| 260 | + $replace = sprintf(self::$URL_LINK, $entity->url, $entity->expanded_url, $entity->display_url); |
|
| 261 | + } |
|
| 260 | 262 | break; |
| 261 | 263 | default : |
| 262 | 264 | $replace = ''; |
@@ -28,6 +28,9 @@ |
||
| 28 | 28 | return self::$instance; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | + /** |
|
| 32 | + * @param string $message |
|
| 33 | + */ |
|
| 31 | 34 | public static function log($message) |
| 32 | 35 | {
|
| 33 | 36 | self::instance()->console->logError('Gah, this is using Debugger::log()!');
|
@@ -18,8 +18,8 @@ discard block |
||
| 18 | 18 | private function __construct() |
| 19 | 19 | { |
| 20 | 20 | $this->console = new Console(); |
| 21 | - $this->profiler = new PhpQuickProfiler(); |
|
| 22 | - $this->profiler->setConsole($this->console); |
|
| 21 | + $this->profiler = new PhpQuickProfiler(); |
|
| 22 | + $this->profiler->setConsole($this->console); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | public static function instance() |
@@ -82,29 +82,29 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | public static function display() |
| 84 | 84 | { |
| 85 | - if ($_COOKIE['debugger'] == 'display' && self::instance()->display) { |
|
| 86 | - $pdo = ''; |
|
| 87 | - global $container; |
|
| 88 | - if (!empty($container) && !empty($container['db_connection_locator'])) { |
|
| 89 | - $pdo = $container['db_connection_locator']->getRead(); |
|
| 90 | - } |
|
| 91 | - if (!empty($pdo)) { |
|
| 92 | - $profiles = $pdo->getProfiler()->getProfiles(); |
|
| 93 | - $profiles = array_filter($profiles, function ($profile) { |
|
| 94 | - return $profile['function'] == 'perform'; |
|
| 95 | - }); |
|
| 96 | - $profiles = array_map(function ($profile) { |
|
| 97 | - return array( |
|
| 98 | - 'sql' => trim(preg_replace('/\s+/', ' ', $profile['statement'])), |
|
| 99 | - 'parameters' => $profile['bind_values'], |
|
| 100 | - 'time' => $profile['duration'] |
|
| 101 | - ); |
|
| 102 | - }, $profiles); |
|
| 103 | - self::instance()->profiler->setProfiledQueries($profiles); |
|
| 104 | - } |
|
| 105 | - self::instance()->profiler->setDisplay(new Particletree\Pqp\Display()); |
|
| 106 | - self::instance()->profiler->display($pdo); |
|
| 107 | - } |
|
| 85 | + if ($_COOKIE['debugger'] == 'display' && self::instance()->display) { |
|
| 86 | + $pdo = ''; |
|
| 87 | + global $container; |
|
| 88 | + if (!empty($container) && !empty($container['db_connection_locator'])) { |
|
| 89 | + $pdo = $container['db_connection_locator']->getRead(); |
|
| 90 | + } |
|
| 91 | + if (!empty($pdo)) { |
|
| 92 | + $profiles = $pdo->getProfiler()->getProfiles(); |
|
| 93 | + $profiles = array_filter($profiles, function ($profile) { |
|
| 94 | + return $profile['function'] == 'perform'; |
|
| 95 | + }); |
|
| 96 | + $profiles = array_map(function ($profile) { |
|
| 97 | + return array( |
|
| 98 | + 'sql' => trim(preg_replace('/\s+/', ' ', $profile['statement'])), |
|
| 99 | + 'parameters' => $profile['bind_values'], |
|
| 100 | + 'time' => $profile['duration'] |
|
| 101 | + ); |
|
| 102 | + }, $profiles); |
|
| 103 | + self::instance()->profiler->setProfiledQueries($profiles); |
|
| 104 | + } |
|
| 105 | + self::instance()->profiler->setDisplay(new Particletree\Pqp\Display()); |
|
| 106 | + self::instance()->profiler->display($pdo); |
|
| 107 | + } |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | } |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | private static $UNKNOWN_ERROR_FILE = 'Unknown File'; |
| 10 | 10 | private static $UNKNOWN_ERROR_LINE = 'Unknown Line'; |
| 11 | - private static $UNKNOWN_ERROR_CONTEXT = 'Unknown Context'; |
|
| 11 | + private static $UNKNOWN_ERROR_CONTEXT = 'Unknown Context'; |
|
| 12 | 12 | |
| 13 | 13 | private $profiler; |
| 14 | 14 | private $display = true; |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | public static function instance() |
| 26 | 26 | { |
| 27 | - if(!isset(self::$instance)) |
|
| 27 | + if (!isset(self::$instance)) |
|
| 28 | 28 | self::$instance = new Debugger(); |
| 29 | 29 | return self::$instance; |
| 30 | 30 | } |
@@ -52,11 +52,11 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | public static function internal_error($code, $string, $file = null, $line = null, $context = null) |
| 54 | 54 | { |
| 55 | - if($file == null) |
|
| 55 | + if ($file == null) |
|
| 56 | 56 | $file = self::$UNKNOWN_ERROR_FILE; |
| 57 | - if($line == null) |
|
| 57 | + if ($line == null) |
|
| 58 | 58 | $line = self::$UNKNOWN_ERROR_LINE; |
| 59 | - if($context == null) |
|
| 59 | + if ($context == null) |
|
| 60 | 60 | $context = self::$UNKNOWN_ERROR_CONTEXT; |
| 61 | 61 | |
| 62 | 62 | self::instance()->console->logError(new Exception($string), "{$string}... TYPE: {$code}"); |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | { |
| 69 | 69 | $error = error_get_last(); |
| 70 | 70 | |
| 71 | - if(isset($error)) |
|
| 71 | + if (isset($error)) |
|
| 72 | 72 | self::internal_error($error['type'], $error['message'], $error['file'], $error['line']); |
| 73 | 73 | |
| 74 | 74 | self::display(); |
@@ -90,10 +90,10 @@ discard block |
||
| 90 | 90 | } |
| 91 | 91 | if (!empty($pdo)) { |
| 92 | 92 | $profiles = $pdo->getProfiler()->getProfiles(); |
| 93 | - $profiles = array_filter($profiles, function ($profile) { |
|
| 93 | + $profiles = array_filter($profiles, function($profile) { |
|
| 94 | 94 | return $profile['function'] == 'perform'; |
| 95 | 95 | }); |
| 96 | - $profiles = array_map(function ($profile) { |
|
| 96 | + $profiles = array_map(function($profile) { |
|
| 97 | 97 | return array( |
| 98 | 98 | 'sql' => trim(preg_replace('/\s+/', ' ', $profile['statement'])), |
| 99 | 99 | 'parameters' => $profile['bind_values'], |
@@ -24,8 +24,9 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | public static function instance() |
| 26 | 26 | { |
| 27 | - if(!isset(self::$instance)) |
|
| 28 | - self::$instance = new Debugger(); |
|
| 27 | + if(!isset(self::$instance)) {
|
|
| 28 | + self::$instance = new Debugger(); |
|
| 29 | + } |
|
| 29 | 30 | return self::$instance; |
| 30 | 31 | } |
| 31 | 32 | |
@@ -52,12 +53,15 @@ discard block |
||
| 52 | 53 | |
| 53 | 54 | public static function internal_error($code, $string, $file = null, $line = null, $context = null) |
| 54 | 55 | { |
| 55 | - if($file == null) |
|
| 56 | - $file = self::$UNKNOWN_ERROR_FILE; |
|
| 57 | - if($line == null) |
|
| 58 | - $line = self::$UNKNOWN_ERROR_LINE; |
|
| 59 | - if($context == null) |
|
| 60 | - $context = self::$UNKNOWN_ERROR_CONTEXT; |
|
| 56 | + if($file == null) {
|
|
| 57 | + $file = self::$UNKNOWN_ERROR_FILE; |
|
| 58 | + } |
|
| 59 | + if($line == null) {
|
|
| 60 | + $line = self::$UNKNOWN_ERROR_LINE; |
|
| 61 | + } |
|
| 62 | + if($context == null) {
|
|
| 63 | + $context = self::$UNKNOWN_ERROR_CONTEXT; |
|
| 64 | + } |
|
| 61 | 65 | |
| 62 | 66 | self::instance()->console->logError(new Exception($string), "{$string}... TYPE: {$code}"); |
| 63 | 67 | |
@@ -68,8 +72,9 @@ discard block |
||
| 68 | 72 | { |
| 69 | 73 | $error = error_get_last(); |
| 70 | 74 | |
| 71 | - if(isset($error)) |
|
| 72 | - self::internal_error($error['type'], $error['message'], $error['file'], $error['line']); |
|
| 75 | + if(isset($error)) {
|
|
| 76 | + self::internal_error($error['type'], $error['message'], $error['file'], $error['line']); |
|
| 77 | + } |
|
| 73 | 78 | |
| 74 | 79 | self::display(); |
| 75 | 80 | return true; |
@@ -74,6 +74,9 @@ discard block |
||
| 74 | 74 | self::send($array); |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | + /** |
|
| 78 | + * @param integer $timestamp |
|
| 79 | + */ |
|
| 77 | 80 | public static function sendCSS($timestamp) |
| 78 | 81 | {
|
| 79 | 82 | $array = array( |
@@ -184,6 +187,9 @@ discard block |
||
| 184 | 187 | self::send($array); |
| 185 | 188 | } |
| 186 | 189 | |
| 190 | + /** |
|
| 191 | + * @param string[] $array |
|
| 192 | + */ |
|
| 187 | 193 | private static function send($array, $gzip = true) |
| 188 | 194 | {
|
| 189 | 195 | if($gzip) |
@@ -205,7 +205,7 @@ |
||
| 205 | 205 | private static function start_gzipping() |
| 206 | 206 | { |
| 207 | 207 | if(!ob_start('ob_gzhandler')) |
| 208 | - ob_start(); |
|
| 208 | + ob_start(); |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | } |
| 212 | 212 | \ No newline at end of file |
@@ -186,10 +186,10 @@ discard block |
||
| 186 | 186 | |
| 187 | 187 | private static function send($array, $gzip = true) |
| 188 | 188 | { |
| 189 | - if($gzip) |
|
| 189 | + if ($gzip) |
|
| 190 | 190 | self::start_gzipping(); |
| 191 | 191 | |
| 192 | - foreach($array as $row) |
|
| 192 | + foreach ($array as $row) |
|
| 193 | 193 | { |
| 194 | 194 | header($row, TRUE); |
| 195 | 195 | } |
@@ -197,14 +197,14 @@ discard block |
||
| 197 | 197 | |
| 198 | 198 | private static function get_date($timestamp = false) |
| 199 | 199 | { |
| 200 | - if($timestamp == 0) |
|
| 200 | + if ($timestamp == 0) |
|
| 201 | 201 | $timestamp = time(); |
| 202 | 202 | return gmdate('D, d M Y H:i:s \G\M\T', $timestamp); |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | private static function start_gzipping() |
| 206 | 206 | { |
| 207 | - if(!ob_start('ob_gzhandler')) |
|
| 207 | + if (!ob_start('ob_gzhandler')) |
|
| 208 | 208 | ob_start(); |
| 209 | 209 | } |
| 210 | 210 | |
@@ -186,8 +186,9 @@ discard block |
||
| 186 | 186 | |
| 187 | 187 | private static function send($array, $gzip = true) |
| 188 | 188 | { |
| 189 | - if($gzip) |
|
| 190 | - self::start_gzipping(); |
|
| 189 | + if($gzip) {
|
|
| 190 | + self::start_gzipping(); |
|
| 191 | + } |
|
| 191 | 192 | |
| 192 | 193 | foreach($array as $row) |
| 193 | 194 | { |
@@ -197,15 +198,17 @@ discard block |
||
| 197 | 198 | |
| 198 | 199 | private static function get_date($timestamp = false) |
| 199 | 200 | { |
| 200 | - if($timestamp == 0) |
|
| 201 | - $timestamp = time(); |
|
| 201 | + if($timestamp == 0) {
|
|
| 202 | + $timestamp = time(); |
|
| 203 | + } |
|
| 202 | 204 | return gmdate('D, d M Y H:i:s \G\M\T', $timestamp); |
| 203 | 205 | } |
| 204 | 206 | |
| 205 | 207 | private static function start_gzipping() |
| 206 | 208 | { |
| 207 | - if(!ob_start('ob_gzhandler')) |
|
| 208 | - ob_start(); |
|
| 209 | + if(!ob_start('ob_gzhandler')) {
|
|
| 210 | + ob_start(); |
|
| 211 | + } |
|
| 209 | 212 | } |
| 210 | 213 | |
| 211 | 214 | } |
| 212 | 215 | \ No newline at end of file |
@@ -69,6 +69,9 @@ discard block |
||
| 69 | 69 | return $extension; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | + /** |
|
| 73 | + * @param string $type |
|
| 74 | + */ |
|
| 72 | 75 | public static function getImagePath($type, $file) |
| 73 | 76 | {
|
| 74 | 77 | if($type == 'photo') |
@@ -142,6 +145,10 @@ discard block |
||
| 142 | 145 | return new ReflectionClass($class_name); |
| 143 | 146 | } |
| 144 | 147 | |
| 148 | + /** |
|
| 149 | + * @param string $type |
|
| 150 | + * @param string $file |
|
| 151 | + */ |
|
| 145 | 152 | public static function loadInstance($type, $file) |
| 146 | 153 | {
|
| 147 | 154 | self::load($type, $file); |
@@ -157,6 +164,9 @@ discard block |
||
| 157 | 164 | trigger_error("Requested class cannot be instance'd: {$type}, {$file}");
|
| 158 | 165 | } |
| 159 | 166 | |
| 167 | + /** |
|
| 168 | + * @param string $type |
|
| 169 | + */ |
|
| 160 | 170 | public static function loadNew($type, $file, $data = array()) |
| 161 | 171 | {
|
| 162 | 172 | self::load($type, $file); |
@@ -179,16 +179,16 @@ |
||
| 179 | 179 | return self::instance()->is_live; |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | - public static function getRootURL($site = '') |
|
| 183 | - { |
|
| 184 | - if (strlen($site) > 0) { |
|
| 185 | - if ($site == 'waterfalls' && self::instance()->is_live) { |
|
| 186 | - return 'http://www.waterfallsofthekeweenaw.com/'; |
|
| 187 | - } else { |
|
| 188 | - return 'http://' . (self::instance()->is_live ? '' : 'dev.') . $site . '.jacobemerick.com/'; |
|
| 189 | - } |
|
| 190 | - } |
|
| 191 | - return '/'; |
|
| 192 | - } |
|
| 182 | + public static function getRootURL($site = '') |
|
| 183 | + { |
|
| 184 | + if (strlen($site) > 0) { |
|
| 185 | + if ($site == 'waterfalls' && self::instance()->is_live) { |
|
| 186 | + return 'http://www.waterfallsofthekeweenaw.com/'; |
|
| 187 | + } else { |
|
| 188 | + return 'http://' . (self::instance()->is_live ? '' : 'dev.') . $site . '.jacobemerick.com/'; |
|
| 189 | + } |
|
| 190 | + } |
|
| 191 | + return '/'; |
|
| 192 | + } |
|
| 193 | 193 | |
| 194 | 194 | } |
@@ -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(); |
@@ -17,8 +17,9 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | public static function instance() |
| 19 | 19 | { |
| 20 | - if(!isset(self::$instance)) |
|
| 21 | - self::$instance = new Loader(); |
|
| 20 | + if(!isset(self::$instance)) {
|
|
| 21 | + self::$instance = new Loader(); |
|
| 22 | + } |
|
| 22 | 23 | return self::$instance; |
| 23 | 24 | } |
| 24 | 25 | |
@@ -71,8 +72,9 @@ discard block |
||
| 71 | 72 | |
| 72 | 73 | public static function getImagePath($type, $file) |
| 73 | 74 | { |
| 74 | - if($type == 'photo') |
|
| 75 | - $type = 'photo/processed'; |
|
| 75 | + if($type == 'photo') {
|
|
| 76 | + $type = 'photo/processed'; |
|
| 77 | + } |
|
| 76 | 78 | |
| 77 | 79 | $path = self::instance()->get_root(); |
| 78 | 80 | $path .= 'images'; |
@@ -110,11 +112,13 @@ discard block |
||
| 110 | 112 | foreach((array) $files as $file) |
| 111 | 113 | { |
| 112 | 114 | $file_path = self::instance()->get_path($type, $file); |
| 113 | - if(in_array($file_path, self::instance()->get_included_files()) && $type !== 'view') |
|
| 114 | - continue; |
|
| 115 | + if(in_array($file_path, self::instance()->get_included_files()) && $type !== 'view') {
|
|
| 116 | + continue; |
|
| 117 | + } |
|
| 115 | 118 | |
| 116 | - if(!file_exists($file_path)) |
|
| 117 | - Debugger::logMessage("Requested file does not exist: {$type}, {$file}"); |
|
| 119 | + if(!file_exists($file_path)) {
|
|
| 120 | + Debugger::logMessage("Requested file does not exist: {$type}, {$file}");
|
|
| 121 | + } |
|
| 118 | 122 | |
| 119 | 123 | self::instance()->add_included_file($file_path); |
| 120 | 124 | |
@@ -163,10 +167,11 @@ discard block |
||
| 163 | 167 | |
| 164 | 168 | $reflectionObject = self::create_reflection_class($file); |
| 165 | 169 | |
| 166 | - if($reflectionObject->hasMethod('__construct')) |
|
| 167 | - return $reflectionObject->newInstanceArgs($data); |
|
| 168 | - else |
|
| 169 | - return $reflectionObject->newInstance(); |
|
| 170 | + if($reflectionObject->hasMethod('__construct')) {
|
|
| 171 | + return $reflectionObject->newInstanceArgs($data); |
|
| 172 | + } else {
|
|
| 173 | + return $reflectionObject->newInstance(); |
|
| 174 | + } |
|
| 170 | 175 | } |
| 171 | 176 | |
| 172 | 177 | public static function getRoot() |
@@ -18,6 +18,9 @@ discard block |
||
| 18 | 18 | $this->headers['Bcc'] = "Jacob <{$config->admin_email}>";
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | + /** |
|
| 22 | + * @param string $person |
|
| 23 | + */ |
|
| 21 | 24 | public function setToAddress($email, $person = null) |
| 22 | 25 | {
|
| 23 | 26 | if($person) |
@@ -27,12 +30,18 @@ discard block |
||
| 27 | 30 | return $this; |
| 28 | 31 | } |
| 29 | 32 | |
| 33 | + /** |
|
| 34 | + * @param string $subject |
|
| 35 | + */ |
|
| 30 | 36 | public function setSubject($subject) |
| 31 | 37 | {
|
| 32 | 38 | $this->subject = $subject; |
| 33 | 39 | return $this; |
| 34 | 40 | } |
| 35 | 41 | |
| 42 | + /** |
|
| 43 | + * @param string $message |
|
| 44 | + */ |
|
| 36 | 45 | public function setMessage($message) |
| 37 | 46 | {
|
| 38 | 47 | $this->message = $message; |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | |
| 13 | 13 | public function __construct() |
| 14 | 14 | { |
| 15 | - global $config; |
|
| 15 | + global $config; |
|
| 16 | 16 | $this->headers['From'] = self::$FROM; |
| 17 | 17 | $this->headers['Reply-To'] = "Jacob <{$config->admin_email}>"; |
| 18 | 18 | $this->headers['Bcc'] = "Jacob <{$config->admin_email}>"; |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | public function setToAddress($email, $person = null) |
| 22 | 22 | { |
| 23 | - if($person) |
|
| 23 | + if ($person) |
|
| 24 | 24 | $this->to[] = "{$person} <{$email}>"; |
| 25 | 25 | else |
| 26 | 26 | $this->to[] = "{$email}"; |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | public function send() |
| 43 | 43 | { |
| 44 | - if(!Loader::isLive()) |
|
| 44 | + if (!Loader::isLive()) |
|
| 45 | 45 | { |
| 46 | 46 | Debugger::logMessage("Email Failed:\n\n{$this->message}"); |
| 47 | 47 | return; |
@@ -51,14 +51,14 @@ discard block |
||
| 51 | 51 | $subject = $this->subject; |
| 52 | 52 | $message = $this->message; |
| 53 | 53 | |
| 54 | - if(empty($to) || empty($subject) || empty($message)) |
|
| 54 | + if (empty($to) || empty($subject) || empty($message)) |
|
| 55 | 55 | { |
| 56 | 56 | Debugger::logMessage("Attempted to send an email without all of the required fields."); |
| 57 | 57 | return; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | $header = ''; |
| 61 | - foreach($this->headers as $key => $value) |
|
| 61 | + foreach ($this->headers as $key => $value) |
|
| 62 | 62 | { |
| 63 | 63 | $header .= "{$key}: {$value}\r\n"; |
| 64 | 64 | } |
@@ -20,10 +20,11 @@ |
||
| 20 | 20 | |
| 21 | 21 | public function setToAddress($email, $person = null) |
| 22 | 22 | { |
| 23 | - if($person) |
|
| 24 | - $this->to[] = "{$person} <{$email}>"; |
|
| 25 | - else |
|
| 26 | - $this->to[] = "{$email}"; |
|
| 23 | + if($person) {
|
|
| 24 | + $this->to[] = "{$person} <{$email}>";
|
|
| 25 | + } else {
|
|
| 26 | + $this->to[] = "{$email}";
|
|
| 27 | + } |
|
| 27 | 28 | return $this; |
| 28 | 29 | } |
| 29 | 30 | |
@@ -34,6 +34,9 @@ |
||
| 34 | 34 | return false; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | + /** |
|
| 38 | + * @param string $key |
|
| 39 | + */ |
|
| 37 | 40 | static function getGet($key = null) |
| 38 | 41 | {
|
| 39 | 42 | if($key) |
@@ -18,9 +18,9 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | static function getServer($key = null) |
| 20 | 20 | { |
| 21 | - if($key) |
|
| 21 | + if ($key) |
|
| 22 | 22 | { |
| 23 | - if(isset(self::$server[$key])) |
|
| 23 | + if (isset(self::$server[$key])) |
|
| 24 | 24 | return self::$server[$key]; |
| 25 | 25 | return false; |
| 26 | 26 | } |
@@ -29,16 +29,16 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | static function isAjax() |
| 31 | 31 | { |
| 32 | - if(self::getServer(self::$AJAX_REQUEST)) |
|
| 32 | + if (self::getServer(self::$AJAX_REQUEST)) |
|
| 33 | 33 | return true; |
| 34 | 34 | return false; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | static function getGet($key = null) |
| 38 | 38 | { |
| 39 | - if($key) |
|
| 39 | + if ($key) |
|
| 40 | 40 | { |
| 41 | - if(isset(self::$get[$key])) |
|
| 41 | + if (isset(self::$get[$key])) |
|
| 42 | 42 | return self::$get[$key]; |
| 43 | 43 | return false; |
| 44 | 44 | } |
@@ -47,9 +47,9 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | static function getPost($key = null) |
| 49 | 49 | { |
| 50 | - if($key) |
|
| 50 | + if ($key) |
|
| 51 | 51 | { |
| 52 | - if(isset(self::$post[$key])) |
|
| 52 | + if (isset(self::$post[$key])) |
|
| 53 | 53 | return self::$post[$key]; |
| 54 | 54 | return false; |
| 55 | 55 | } |
@@ -20,8 +20,9 @@ discard block |
||
| 20 | 20 | { |
| 21 | 21 | if($key) |
| 22 | 22 | { |
| 23 | - if(isset(self::$server[$key])) |
|
| 24 | - return self::$server[$key]; |
|
| 23 | + if(isset(self::$server[$key])) {
|
|
| 24 | + return self::$server[$key]; |
|
| 25 | + } |
|
| 25 | 26 | return false; |
| 26 | 27 | } |
| 27 | 28 | return self::$server; |
@@ -29,8 +30,9 @@ discard block |
||
| 29 | 30 | |
| 30 | 31 | static function isAjax() |
| 31 | 32 | { |
| 32 | - if(self::getServer(self::$AJAX_REQUEST)) |
|
| 33 | - return true; |
|
| 33 | + if(self::getServer(self::$AJAX_REQUEST)) {
|
|
| 34 | + return true; |
|
| 35 | + } |
|
| 34 | 36 | return false; |
| 35 | 37 | } |
| 36 | 38 | |
@@ -38,8 +40,9 @@ discard block |
||
| 38 | 40 | { |
| 39 | 41 | if($key) |
| 40 | 42 | { |
| 41 | - if(isset(self::$get[$key])) |
|
| 42 | - return self::$get[$key]; |
|
| 43 | + if(isset(self::$get[$key])) {
|
|
| 44 | + return self::$get[$key]; |
|
| 45 | + } |
|
| 43 | 46 | return false; |
| 44 | 47 | } |
| 45 | 48 | return self::$get; |
@@ -49,8 +52,9 @@ discard block |
||
| 49 | 52 | { |
| 50 | 53 | if($key) |
| 51 | 54 | { |
| 52 | - if(isset(self::$post[$key])) |
|
| 53 | - return self::$post[$key]; |
|
| 55 | + if(isset(self::$post[$key])) {
|
|
| 56 | + return self::$post[$key]; |
|
| 57 | + } |
|
| 54 | 58 | return false; |
| 55 | 59 | } |
| 56 | 60 | return self::$post; |
@@ -38,6 +38,9 @@ discard block |
||
| 38 | 38 | self::$array['pieces'] = (array) $uri_array; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | + /** |
|
| 42 | + * @return string |
|
| 43 | + */ |
|
| 41 | 44 | static function getSite() |
| 42 | 45 | {
|
| 43 | 46 | return self::$array['site']; |
@@ -66,6 +69,9 @@ discard block |
||
| 66 | 69 | return substr($file, strrpos($file, '.') + 1);; |
| 67 | 70 | } |
| 68 | 71 | |
| 72 | + /** |
|
| 73 | + * @param integer $piece |
|
| 74 | + */ |
|
| 69 | 75 | static function getPiece($piece = null) |
| 70 | 76 | {
|
| 71 | 77 | if(!$piece) |
@@ -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 | } |
@@ -15,12 +15,14 @@ discard block |
||
| 15 | 15 | static private function form_url_array($host, $uri) |
| 16 | 16 | { |
| 17 | 17 | $uri = substr($uri, 1); |
| 18 | - if(strpos($uri, '?')) |
|
| 19 | - $uri = substr($uri, 0, strpos($uri, '?')); |
|
| 18 | + if(strpos($uri, '?')) {
|
|
| 19 | + $uri = substr($uri, 0, strpos($uri, '?')); |
|
| 20 | + } |
|
| 20 | 21 | $uri_array = explode('/', $uri); |
| 21 | 22 | |
| 22 | - if(!Loader::isLive()) |
|
| 23 | - $host = substr($host, strpos($host, '.') + 1); |
|
| 23 | + if(!Loader::isLive()) {
|
|
| 24 | + $host = substr($host, strpos($host, '.') + 1); |
|
| 25 | + } |
|
| 24 | 26 | |
| 25 | 27 | self::$array['host'] = $host; |
| 26 | 28 | |
@@ -33,8 +35,9 @@ discard block |
||
| 33 | 35 | self::$array['base'] = 'http://' . (!Loader::isLive() ? 'dev.' : '') . $host . '/'; |
| 34 | 36 | self::$array['uri'] = '/' . implode('/', $uri_array); |
| 35 | 37 | |
| 36 | - if(end($uri_array) == '') |
|
| 37 | - $uri_array = array_slice($uri_array, 0, count($uri_array) - 1); |
|
| 38 | + if(end($uri_array) == '') {
|
|
| 39 | + $uri_array = array_slice($uri_array, 0, count($uri_array) - 1); |
|
| 40 | + } |
|
| 38 | 41 | self::$array['pieces'] = (array) $uri_array; |
| 39 | 42 | } |
| 40 | 43 | |
@@ -61,22 +64,26 @@ discard block |
||
| 61 | 64 | static function getExtension() |
| 62 | 65 | { |
| 63 | 66 | $file = self::getPiece(-1); |
| 64 | - if(substr($file, -1) == '/') |
|
| 65 | - return false; |
|
| 67 | + if(substr($file, -1) == '/') {
|
|
| 68 | + return false; |
|
| 69 | + } |
|
| 66 | 70 | return substr($file, strrpos($file, '.') + 1);; |
| 67 | 71 | } |
| 68 | 72 | |
| 69 | 73 | static function getPiece($piece = null) |
| 70 | 74 | { |
| 71 | - if(!$piece) |
|
| 72 | - return self::$array['pieces']; |
|
| 75 | + if(!$piece) {
|
|
| 76 | + return self::$array['pieces']; |
|
| 77 | + } |
|
| 73 | 78 | |
| 74 | - if($piece == -1) |
|
| 75 | - return end(self::$array['pieces']); |
|
| 79 | + if($piece == -1) {
|
|
| 80 | + return end(self::$array['pieces']); |
|
| 81 | + } |
|
| 76 | 82 | |
| 77 | 83 | $piece = $piece - 1; |
| 78 | - if(array_key_exists($piece, self::$array['pieces'])) |
|
| 79 | - return self::$array['pieces'][$piece]; |
|
| 84 | + if(array_key_exists($piece, self::$array['pieces'])) {
|
|
| 85 | + return self::$array['pieces'][$piece]; |
|
| 86 | + } |
|
| 80 | 87 | return; |
| 81 | 88 | } |
| 82 | 89 | |