@@ -37,8 +37,9 @@ 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]; |
@@ -49,8 +50,9 @@ discard block |
||
| 49 | 50 | } |
| 50 | 51 | |
| 51 | 52 | $domain = '/'; |
| 52 | - if($is_absolute) |
|
| 53 | - $domain = Loader::getRootUrl('blog'); |
|
| 53 | + if($is_absolute) {
|
|
| 54 | + $domain = Loader::getRootUrl('blog');
|
|
| 55 | + } |
|
| 54 | 56 | |
| 55 | 57 | return sprintf(self::$PHOTO_CONTENT, $domain, $category, $photo, $size, $height, $width, $description, $description); |
| 56 | 58 | } |
@@ -10,64 +10,65 @@ |
||
| 10 | 10 | $previous_time = strtotime($this->content); |
| 11 | 11 | $current_time = time(); |
| 12 | 12 | |
| 13 | - if($current_time <= $previous_time) |
|
| 14 | - $this->content = 'few seconds ago'; |
|
| 15 | - else if(($current_time - $previous_time) < 30) |
|
| 16 | - $this->content = 'few seconds ago'; |
|
| 17 | - else if(($current_time - $previous_time) < 1.5 * 60) |
|
| 18 | - $this->content = 'a minute ago'; |
|
| 19 | - else if(($current_time - $previous_time) < 4 * 60) |
|
| 20 | - $this->content = 'few minutes ago'; |
|
| 21 | - else if(($current_time - $previous_time) < 7 * 60) |
|
| 22 | - $this->content = 'five minutes ago'; |
|
| 23 | - else if(($current_time - $previous_time) < 12 * 60) |
|
| 24 | - $this->content = 'ten minutes ago'; |
|
| 25 | - else if(($current_time - $previous_time) < 17 * 60) |
|
| 26 | - $this->content = 'fifteen minutes ago'; |
|
| 27 | - else if(($current_time - $previous_time) < 22 * 60) |
|
| 28 | - $this->content = 'twenty minutes ago'; |
|
| 29 | - else if(($current_time - $previous_time) < 37 * 60) |
|
| 30 | - $this->content = 'half hour ago'; |
|
| 31 | - else if(($current_time - $previous_time) < 52 * 60) |
|
| 32 | - $this->content = 'forty-five minutes ago'; |
|
| 33 | - else if(($current_time - $previous_time) < 1.5 * 60 * 60) |
|
| 34 | - $this->content = 'an hour ago'; |
|
| 35 | - else if(($current_time - $previous_time) < 2.5 * 60 * 60) |
|
| 36 | - $this->content = 'two hours ago'; |
|
| 37 | - else if(($current_time - $previous_time) < 3.5 * 60 * 60) |
|
| 38 | - $this->content = 'three hours ago'; |
|
| 39 | - else if(($current_time - $previous_time) < 4.5 * 60 * 60) |
|
| 40 | - $this->content = 'few hours ago'; |
|
| 41 | - else if(($current_time - $previous_time) < 1 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) && date('a', $previous_time) == 'pm') |
|
| 42 | - $this->content = 'this afternoon'; |
|
| 43 | - else if(($current_time - $previous_time) < 1 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) && date('a', $previous_time) == 'am') |
|
| 44 | - $this->content = 'this morning'; |
|
| 45 | - else if(($current_time - $previous_time) < 2 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 1 && date('a', $previous_time) == 'pm' && date('G', $previous_time) >= 17) |
|
| 46 | - $this->content = 'yesterday evening'; |
|
| 47 | - else if(($current_time - $previous_time) < 2 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 1 && date('a', $previous_time) == 'pm') |
|
| 48 | - $this->content = 'yesterday afternoon'; |
|
| 49 | - else if(($current_time - $previous_time) < 2 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 1 && date('a', $previous_time) == 'am') |
|
| 50 | - $this->content = 'yesterday morning'; |
|
| 51 | - else if(($current_time - $previous_time) < 3 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 2) |
|
| 52 | - $this->content = 'two days ago'; |
|
| 53 | - else if(($current_time - $previous_time) < 4 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 3) |
|
| 54 | - $this->content = 'three days ago'; |
|
| 55 | - else if(($current_time - $previous_time) < 1 * 7 * 24 * 60 * 60 && date('W', $current_time) == date('W', $previous_time)) |
|
| 56 | - $this->content = 'earlier this week'; |
|
| 57 | - else if(($current_time - $previous_time) < 2 * 7 * 24 * 60 * 60 && date('W', $current_time) == date('W', $previous_time) + 1 && date('w', $previous_time) >= 3) |
|
| 58 | - $this->content = 'late last week'; |
|
| 59 | - else if(($current_time - $previous_time) < 2 * 7 * 24 * 60 * 60 && date('W', $current_time) == date('W', $previous_time) + 1) |
|
| 60 | - $this->content = 'early last week'; |
|
| 61 | - else if(($current_time - $previous_time) < 3 * 7 * 24 * 60 * 60) |
|
| 62 | - $this->content = 'few weeks ago'; |
|
| 63 | - else if(($current_time - $previous_time) < 1.25* 4 * 7 * 24 * 60 * 60 && date('n', $current_time) == date('n', $previous_time)) |
|
| 64 | - $this->content = 'earlier this month'; |
|
| 65 | - else if(($current_time - $previous_time) < 2 * 4 * 7 * 24 * 60 * 60 && date('n', $current_time) == date('n', $previous_time) + 1) |
|
| 66 | - $this->content = 'last month'; |
|
| 67 | - else if(($current_time - $previous_time) < 4 * 4 * 7 * 24 * 60 * 60) |
|
| 68 | - $this->content = 'several months ago'; |
|
| 69 | - else |
|
| 70 | - $this->content = 'long ago'; |
|
| 13 | + if($current_time <= $previous_time) {
|
|
| 14 | + $this->content = 'few seconds ago'; |
|
| 15 | + } else if(($current_time - $previous_time) < 30) {
|
|
| 16 | + $this->content = 'few seconds ago'; |
|
| 17 | + } else if(($current_time - $previous_time) < 1.5 * 60) {
|
|
| 18 | + $this->content = 'a minute ago'; |
|
| 19 | + } else if(($current_time - $previous_time) < 4 * 60) {
|
|
| 20 | + $this->content = 'few minutes ago'; |
|
| 21 | + } else if(($current_time - $previous_time) < 7 * 60) {
|
|
| 22 | + $this->content = 'five minutes ago'; |
|
| 23 | + } else if(($current_time - $previous_time) < 12 * 60) {
|
|
| 24 | + $this->content = 'ten minutes ago'; |
|
| 25 | + } else if(($current_time - $previous_time) < 17 * 60) {
|
|
| 26 | + $this->content = 'fifteen minutes ago'; |
|
| 27 | + } else if(($current_time - $previous_time) < 22 * 60) {
|
|
| 28 | + $this->content = 'twenty minutes ago'; |
|
| 29 | + } else if(($current_time - $previous_time) < 37 * 60) {
|
|
| 30 | + $this->content = 'half hour ago'; |
|
| 31 | + } else if(($current_time - $previous_time) < 52 * 60) {
|
|
| 32 | + $this->content = 'forty-five minutes ago'; |
|
| 33 | + } else if(($current_time - $previous_time) < 1.5 * 60 * 60) {
|
|
| 34 | + $this->content = 'an hour ago'; |
|
| 35 | + } else if(($current_time - $previous_time) < 2.5 * 60 * 60) {
|
|
| 36 | + $this->content = 'two hours ago'; |
|
| 37 | + } else if(($current_time - $previous_time) < 3.5 * 60 * 60) {
|
|
| 38 | + $this->content = 'three hours ago'; |
|
| 39 | + } else if(($current_time - $previous_time) < 4.5 * 60 * 60) {
|
|
| 40 | + $this->content = 'few hours ago'; |
|
| 41 | + } else if(($current_time - $previous_time) < 1 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) && date('a', $previous_time) == 'pm') {
|
|
| 42 | + $this->content = 'this afternoon'; |
|
| 43 | + } else if(($current_time - $previous_time) < 1 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) && date('a', $previous_time) == 'am') {
|
|
| 44 | + $this->content = 'this morning'; |
|
| 45 | + } else if(($current_time - $previous_time) < 2 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 1 && date('a', $previous_time) == 'pm' && date('G', $previous_time) >= 17) {
|
|
| 46 | + $this->content = 'yesterday evening'; |
|
| 47 | + } else if(($current_time - $previous_time) < 2 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 1 && date('a', $previous_time) == 'pm') {
|
|
| 48 | + $this->content = 'yesterday afternoon'; |
|
| 49 | + } else if(($current_time - $previous_time) < 2 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 1 && date('a', $previous_time) == 'am') {
|
|
| 50 | + $this->content = 'yesterday morning'; |
|
| 51 | + } else if(($current_time - $previous_time) < 3 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 2) {
|
|
| 52 | + $this->content = 'two days ago'; |
|
| 53 | + } else if(($current_time - $previous_time) < 4 * 24 * 60 * 60 && date('j', $current_time) == date('j', $previous_time) + 3) {
|
|
| 54 | + $this->content = 'three days ago'; |
|
| 55 | + } else if(($current_time - $previous_time) < 1 * 7 * 24 * 60 * 60 && date('W', $current_time) == date('W', $previous_time)) {
|
|
| 56 | + $this->content = 'earlier this week'; |
|
| 57 | + } else if(($current_time - $previous_time) < 2 * 7 * 24 * 60 * 60 && date('W', $current_time) == date('W', $previous_time) + 1 && date('w', $previous_time) >= 3) {
|
|
| 58 | + $this->content = 'late last week'; |
|
| 59 | + } else if(($current_time - $previous_time) < 2 * 7 * 24 * 60 * 60 && date('W', $current_time) == date('W', $previous_time) + 1) {
|
|
| 60 | + $this->content = 'early last week'; |
|
| 61 | + } else if(($current_time - $previous_time) < 3 * 7 * 24 * 60 * 60) {
|
|
| 62 | + $this->content = 'few weeks ago'; |
|
| 63 | + } else if(($current_time - $previous_time) < 1.25* 4 * 7 * 24 * 60 * 60 && date('n', $current_time) == date('n', $previous_time)) {
|
|
| 64 | + $this->content = 'earlier this month'; |
|
| 65 | + } else if(($current_time - $previous_time) < 2 * 4 * 7 * 24 * 60 * 60 && date('n', $current_time) == date('n', $previous_time) + 1) {
|
|
| 66 | + $this->content = 'last month'; |
|
| 67 | + } else if(($current_time - $previous_time) < 4 * 4 * 7 * 24 * 60 * 60) {
|
|
| 68 | + $this->content = 'several months ago'; |
|
| 69 | + } else {
|
|
| 70 | + $this->content = 'long ago'; |
|
| 71 | + } |
|
| 71 | 72 | } |
| 72 | 73 | |
| 73 | 74 | } |
| 74 | 75 | \ No newline at end of file |
@@ -11,10 +11,11 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | protected function execute($is_absolute = false, $size = 'thumb') |
| 13 | 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; |
|
| 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 | |
@@ -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(); |
|
| 47 | + if($is_absolute) {
|
|
| 48 | + $domain = Loader::getRootUrl(); |
|
| 49 | + } |
|
| 47 | 50 | |
| 48 | 51 | return sprintf(self::$IMAGE_NODE, $domain, $category, $photo, $size, $extension, $height, $width, $description); |
| 49 | 52 | } |
@@ -40,8 +40,9 @@ discard block |
||
| 40 | 40 | { |
| 41 | 41 | $match_count = preg_match_all($pattern, $this->content, $matches, PREG_SET_ORDER); |
| 42 | 42 | |
| 43 | - if($match_count < 1) |
|
| 44 | - return; |
|
| 43 | + if($match_count < 1) {
|
|
| 44 | + return; |
|
| 45 | + } |
|
| 45 | 46 | |
| 46 | 47 | foreach($matches as $match) |
| 47 | 48 | { |
@@ -79,8 +80,9 @@ discard block |
||
| 79 | 80 | { |
| 80 | 81 | $match_count = preg_match_all($pattern, $this->content, $matches, PREG_SET_ORDER); |
| 81 | 82 | |
| 82 | - if($match_count < 1) |
|
| 83 | - return; |
|
| 83 | + if($match_count < 1) {
|
|
| 84 | + return; |
|
| 85 | + } |
|
| 84 | 86 | |
| 85 | 87 | foreach($matches as $match) |
| 86 | 88 | { |
@@ -33,8 +33,7 @@ |
||
| 33 | 33 | $query = sprintf(self::$UPDATE_COMMENTS_QUERY, $comments, $blog_result->id); |
| 34 | 34 | Database::execute($query); |
| 35 | 35 | } |
| 36 | - } |
|
| 37 | - else |
|
| 36 | + } else |
|
| 38 | 37 | { |
| 39 | 38 | $title = Database::escape($post->title); |
| 40 | 39 | $category = Database::escape($post->category); |
@@ -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 = ''; |
@@ -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 | } |
@@ -13,10 +13,11 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | function __construct() |
| 15 | 15 | { |
| 16 | - if(Loader::isLive()) |
|
| 17 | - $handle[] = self::$live_root; |
|
| 18 | - else |
|
| 19 | - $handle[] = self::$test_root; |
|
| 16 | + if(Loader::isLive()) {
|
|
| 17 | + $handle[] = self::$live_root; |
|
| 18 | + } else {
|
|
| 19 | + $handle[] = self::$test_root; |
|
| 20 | + } |
|
| 20 | 21 | |
| 21 | 22 | $i = 0; |
| 22 | 23 | while(isset($handle[$i])) |
@@ -27,10 +28,12 @@ discard block |
||
| 27 | 28 | { |
| 28 | 29 | if($file != '.' && $file != '..') |
| 29 | 30 | { |
| 30 | - if(is_dir("{$path}/{$file}")) |
|
| 31 | - $handle[] = "{$path}/{$file}"; |
|
| 32 | - if($file == 'error.log') |
|
| 33 | - $this->error_files[] = "{$path}/{$file}"; |
|
| 31 | + if(is_dir("{$path}/{$file}")) {
|
|
| 32 | + $handle[] = "{$path}/{$file}";
|
|
| 33 | + } |
|
| 34 | + if($file == 'error.log') {
|
|
| 35 | + $this->error_files[] = "{$path}/{$file}";
|
|
| 36 | + } |
|
| 34 | 37 | } |
| 35 | 38 | } |
| 36 | 39 | closedir($fh); |
@@ -50,9 +53,9 @@ discard block |
||
| 50 | 53 | $contents = file_get_contents($error_file); |
| 51 | 54 | $message .= "{$error_file}\n{$contents}\n\n"; |
| 52 | 55 | } |
| 53 | - } |
|
| 54 | - else |
|
| 55 | - $message = 'No errors found in the flat-files!'; |
|
| 56 | + } else {
|
|
| 57 | + $message = 'No errors found in the flat-files!'; |
|
| 58 | + } |
|
| 56 | 59 | |
| 57 | 60 | $mail = new Mail(); |
| 58 | 61 | $mail->setToAddress('EMAIL', 'Jacob Emerick'); |
@@ -19,13 +19,15 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | public function activate() |
| 21 | 21 | { |
| 22 | - if(!$this->xml) |
|
| 23 | - return $this->error('Could not connect to feed.'); |
|
| 22 | + if(!$this->xml) {
|
|
| 23 | + return $this->error('Could not connect to feed.');
|
|
| 24 | + } |
|
| 24 | 25 | |
| 25 | 26 | foreach($this->xml->channel->item as $item) |
| 26 | 27 | { |
| 27 | - if(strtotime($item->user_read_at) <= 0) |
|
| 28 | - continue; |
|
| 28 | + if(strtotime($item->user_read_at) <= 0) {
|
|
| 29 | + continue; |
|
| 30 | + } |
|
| 29 | 31 | |
| 30 | 32 | $title = $item->title; |
| 31 | 33 | $title = trim($title); |
@@ -42,8 +44,9 @@ discard block |
||
| 42 | 44 | $date_added = date('Y-m-d H:i:s', strtotime($item->user_date_created)); |
| 43 | 45 | |
| 44 | 46 | $book_result = BookCollector::getBookByFields($title, $author); |
| 45 | - if($book_result !== null) |
|
| 46 | - continue; |
|
| 47 | + if($book_result !== null) {
|
|
| 48 | + continue; |
|
| 49 | + } |
|
| 47 | 50 | |
| 48 | 51 | $query = sprintf(self::$QUERY, $title, $author, $link, $description, $image, $date_read, $date_added); |
| 49 | 52 | Database::execute($query); |