@@ -9,8 +9,9 @@ |
||
| 9 | 9 | |
| 10 | 10 | public function __construct($user_agent = null) |
| 11 | 11 | { |
| 12 | - if(!isset($user_agent)) |
|
| 13 | - $user_agent = Request::getServer('HTTP_USER_AGENT'); |
|
| 12 | + if(!isset($user_agent)) {
|
|
| 13 | + $user_agent = Request::getServer('HTTP_USER_AGENT');
|
|
| 14 | + } |
|
| 14 | 15 | $this->user_agent = $user_agent; |
| 15 | 16 | } |
| 16 | 17 | |
@@ -36,8 +36,9 @@ discard block |
||
| 36 | 36 | $mysqli = new mysqli($host, $username, $password); |
| 37 | 37 | |
| 38 | 38 | $has_connection_error = $mysqli->connect_error; |
| 39 | - if(isset($has_connection_error)) |
|
| 40 | - $this->has_connection_error = true; |
|
| 39 | + if(isset($has_connection_error)) {
|
|
| 40 | + $this->has_connection_error = true; |
|
| 41 | + } |
|
| 41 | 42 | |
| 42 | 43 | return $mysqli; |
| 43 | 44 | } |
@@ -67,8 +68,9 @@ discard block |
||
| 67 | 68 | { |
| 68 | 69 | self::instance()->log_query($query, $start); |
| 69 | 70 | $array = array(); |
| 70 | - while($row = $result->fetch_object()) |
|
| 71 | - $array[] = $row; |
|
| 71 | + while($row = $result->fetch_object()) {
|
|
| 72 | + $array[] = $row; |
|
| 73 | + } |
|
| 72 | 74 | $result->close(); |
| 73 | 75 | return $array; |
| 74 | 76 | } |
@@ -79,8 +81,9 @@ discard block |
||
| 79 | 81 | public static function selectRow($query) |
| 80 | 82 | { |
| 81 | 83 | $result = self::select($query); |
| 82 | - if(is_array($result)) |
|
| 83 | - return array_pop($result); |
|
| 84 | + if(is_array($result)) {
|
|
| 85 | + return array_pop($result); |
|
| 86 | + } |
|
| 84 | 87 | return false; |
| 85 | 88 | } |
| 86 | 89 | |
@@ -99,8 +102,9 @@ discard block |
||
| 99 | 102 | public static function lastInsertID() |
| 100 | 103 | { |
| 101 | 104 | $id = self::instance()->write_connection->insert_id; |
| 102 | - if($id == 0) |
|
| 103 | - return false; |
|
| 105 | + if($id == 0) {
|
|
| 106 | + return false; |
|
| 107 | + } |
|
| 104 | 108 | return $id; |
| 105 | 109 | } |
| 106 | 110 | |
@@ -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 | |
@@ -21,8 +21,9 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | public function setValue($value) |
| 23 | 23 | { |
| 24 | - if(!$this->is_loaded) |
|
| 25 | - $this->load(); |
|
| 24 | + if(!$this->is_loaded) {
|
|
| 25 | + $this->load(); |
|
| 26 | + } |
|
| 26 | 27 | |
| 27 | 28 | $this->value = $value; |
| 28 | 29 | return $this; |
@@ -30,8 +31,9 @@ discard block |
||
| 30 | 31 | |
| 31 | 32 | public function getValue() |
| 32 | 33 | { |
| 33 | - if(!$this->is_loaded) |
|
| 34 | - $this->load(); |
|
| 34 | + if(!$this->is_loaded) {
|
|
| 35 | + $this->load(); |
|
| 36 | + } |
|
| 35 | 37 | return $this->value; |
| 36 | 38 | } |
| 37 | 39 | |
@@ -42,24 +44,26 @@ discard block |
||
| 42 | 44 | |
| 43 | 45 | public function exists() |
| 44 | 46 | { |
| 45 | - if(!$this->is_loaded) |
|
| 46 | - $this->load(); |
|
| 47 | + if(!$this->is_loaded) {
|
|
| 48 | + $this->load(); |
|
| 49 | + } |
|
| 47 | 50 | return $this->exists; |
| 48 | 51 | } |
| 49 | 52 | |
| 50 | 53 | private final function load() |
| 51 | 54 | { |
| 52 | 55 | $name = $this->getName(); |
| 53 | - if(isset($_COOKIE[$name])) |
|
| 54 | - $value = $_COOKIE[$name]; |
|
| 56 | + if(isset($_COOKIE[$name])) {
|
|
| 57 | + $value = $_COOKIE[$name]; |
|
| 58 | + } |
|
| 55 | 59 | |
| 56 | 60 | if(isset($value)) |
| 57 | 61 | { |
| 58 | 62 | $this->value = $value; |
| 59 | 63 | $this->exists = true; |
| 60 | - } |
|
| 61 | - else |
|
| 62 | - $this->exists = false; |
|
| 64 | + } else {
|
|
| 65 | + $this->exists = false; |
|
| 66 | + } |
|
| 63 | 67 | |
| 64 | 68 | $this->is_loaded = true; |
| 65 | 69 | } |
@@ -84,24 +88,29 @@ discard block |
||
| 84 | 88 | private final function check_values() |
| 85 | 89 | { |
| 86 | 90 | $name = $this->getName(); |
| 87 | - if(empty($name) || strlen($name) < 1) |
|
| 88 | - return false; |
|
| 91 | + if(empty($name) || strlen($name) < 1) {
|
|
| 92 | + return false; |
|
| 93 | + } |
|
| 89 | 94 | |
| 90 | 95 | $value = $this->getValue(); |
| 91 | - if(!isset($value) || strlen($value) < 1) |
|
| 92 | - return false; |
|
| 96 | + if(!isset($value) || strlen($value) < 1) {
|
|
| 97 | + return false; |
|
| 98 | + } |
|
| 93 | 99 | |
| 94 | 100 | $expiration = $this->getExpiration(); |
| 95 | - if(!isset($expiration) || !is_int($expiration)) |
|
| 96 | - return false; |
|
| 101 | + if(!isset($expiration) || !is_int($expiration)) {
|
|
| 102 | + return false; |
|
| 103 | + } |
|
| 97 | 104 | |
| 98 | 105 | $domain = $this->getDomain(); |
| 99 | - if(!isset($domain) || strlen($domain) < 1) |
|
| 100 | - return false; |
|
| 106 | + if(!isset($domain) || strlen($domain) < 1) {
|
|
| 107 | + return false; |
|
| 108 | + } |
|
| 101 | 109 | |
| 102 | 110 | $path = $this->getPath(); |
| 103 | - if(!isset($path) || strlen($path) < 1) |
|
| 104 | - return false; |
|
| 111 | + if(!isset($path) || strlen($path) < 1) {
|
|
| 112 | + return false; |
|
| 113 | + } |
|
| 105 | 114 | |
| 106 | 115 | return true; |
| 107 | 116 | } |
@@ -10,8 +10,9 @@ |
||
| 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) |
|
| 14 | - return; |
|
| 13 | + if(count($matches[1]) == 0) {
|
|
| 14 | + return; |
|
| 15 | + } |
|
| 15 | 16 | |
| 16 | 17 | foreach($matches[3] as $key => $match) |
| 17 | 18 | { |
@@ -14,10 +14,11 @@ discard block |
||
| 14 | 14 | preg_match_all(self::$LINK_PLACEHOLDER_MATCH, $this->content, $matches); |
| 15 | 15 | foreach($matches[1] as $key => $match) |
| 16 | 16 | { |
| 17 | - if(isset($matches[3][$key])) |
|
| 18 | - $link_content = $this->get_link($match, $is_absolute, $matches[3][$key]); |
|
| 19 | - else |
|
| 20 | - $link_content = $this->get_link($match, $is_absolute); |
|
| 17 | + if(isset($matches[3][$key])) {
|
|
| 18 | + $link_content = $this->get_link($match, $is_absolute, $matches[3][$key]); |
|
| 19 | + } else {
|
|
| 20 | + $link_content = $this->get_link($match, $is_absolute); |
|
| 21 | + } |
|
| 21 | 22 | $this->content = str_replace($matches[0][$key], $link_content, $this->content); |
| 22 | 23 | } |
| 23 | 24 | return; |
@@ -35,14 +36,16 @@ discard block |
||
| 35 | 36 | Loader::load('collector', 'blog/PostCollector'); |
| 36 | 37 | $post = PostCollector::getPostByURI($uri); |
| 37 | 38 | |
| 38 | - if($post === NULL) |
|
| 39 | - return; |
|
| 39 | + if($post === NULL) {
|
|
| 40 | + return; |
|
| 41 | + } |
|
| 40 | 42 | |
| 41 | 43 | $link .= ($is_absolute) ? Loader::getRootURL('blog') : '/'; |
| 42 | 44 | $link .= "{$post->category}/{$post->path}/"; |
| 43 | 45 | |
| 44 | - if($anchor == '') |
|
| 45 | - $anchor = $post->title; |
|
| 46 | + if($anchor == '') {
|
|
| 47 | + $anchor = $post->title; |
|
| 48 | + } |
|
| 46 | 49 | |
| 47 | 50 | break; |
| 48 | 51 | case 'blog-tag' : |
@@ -61,14 +64,16 @@ discard block |
||
| 61 | 64 | Loader::load('collector', 'waterfall/LogCollector'); |
| 62 | 65 | $log = LogCollector::getByAlias($uri); |
| 63 | 66 | |
| 64 | - if($log === NULL) |
|
| 65 | - return; |
|
| 67 | + if($log === NULL) {
|
|
| 68 | + return; |
|
| 69 | + } |
|
| 66 | 70 | |
| 67 | 71 | $link .= ($is_absolute) ? Loader::getRootURL('waterfalls') : '/'; |
| 68 | 72 | $link .= "journal/{$log->alias}/"; |
| 69 | 73 | |
| 70 | - if($anchor == '') |
|
| 71 | - $anchor = $log->title; |
|
| 74 | + if($anchor == '') {
|
|
| 75 | + $anchor = $log->title; |
|
| 76 | + } |
|
| 72 | 77 | |
| 73 | 78 | break; |
| 74 | 79 | case 'falls' : |
@@ -33,17 +33,19 @@ discard block |
||
| 33 | 33 | return; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - if(count($args) == 2) |
|
| 37 | - $etc = $args[1]; |
|
| 38 | - else |
|
| 39 | - $etc = self::$ETC; |
|
| 36 | + if(count($args) == 2) {
|
|
| 37 | + $etc = $args[1]; |
|
| 38 | + } else {
|
|
| 39 | + $etc = self::$ETC; |
|
| 40 | + } |
|
| 40 | 41 | |
| 41 | 42 | $length = $args[0]; |
| 42 | 43 | |
| 43 | - if($length < strlen($this->content)) |
|
| 44 | - $this->trim_string($length); |
|
| 45 | - else |
|
| 46 | - $etc = ''; |
|
| 44 | + if($length < strlen($this->content)) {
|
|
| 45 | + $this->trim_string($length); |
|
| 46 | + } else {
|
|
| 47 | + $etc = ''; |
|
| 48 | + } |
|
| 47 | 49 | $this->check_exclude_tags(); |
| 48 | 50 | $this->close_tags($etc); |
| 49 | 51 | } |
@@ -54,8 +56,9 @@ discard block |
||
| 54 | 56 | |
| 55 | 57 | $last_right_bracket_position = strripos($content, self::$RIGHT_BRACKET); |
| 56 | 58 | $last_left_bracket_position = strripos($content, self::$LEFT_BRACKET); |
| 57 | - if($last_left_bracket_position > $last_right_bracket_position) |
|
| 58 | - $content = substr($content, 0, $last_left_bracket_position); |
|
| 59 | + if($last_left_bracket_position > $last_right_bracket_position) {
|
|
| 60 | + $content = substr($content, 0, $last_left_bracket_position); |
|
| 61 | + } |
|
| 59 | 62 | $content = trim($content); |
| 60 | 63 | |
| 61 | 64 | $this->content = $content; |
@@ -76,14 +79,16 @@ discard block |
||
| 76 | 79 | foreach($matches[0] as $match) |
| 77 | 80 | { |
| 78 | 81 | $max_length += strlen($match[0]); |
| 79 | - if($max_length <= $match[1]) |
|
| 80 | - break; |
|
| 82 | + if($max_length <= $match[1]) {
|
|
| 83 | + break; |
|
| 84 | + } |
|
| 81 | 85 | |
| 82 | 86 | $content = substr($content, 0, $match[1]) . $match[0] . substr($content, $match[1]); |
| 83 | 87 | } |
| 84 | 88 | |
| 85 | - if(substr($content, -7) == '</p><p>') |
|
| 86 | - $content = substr($content, 0, -7); |
|
| 89 | + if(substr($content, -7) == '</p><p>') {
|
|
| 90 | + $content = substr($content, 0, -7); |
|
| 91 | + } |
|
| 87 | 92 | |
| 88 | 93 | return $content; |
| 89 | 94 | } |
@@ -118,9 +123,9 @@ discard block |
||
| 118 | 123 | { |
| 119 | 124 | $key = array_search($tag, $open_tags); |
| 120 | 125 | unset($open_tags[$key]); |
| 121 | - } |
|
| 122 | - else |
|
| 123 | - $open_tags[] = $tag; |
|
| 126 | + } else {
|
|
| 127 | + $open_tags[] = $tag; |
|
| 128 | + } |
|
| 124 | 129 | } |
| 125 | 130 | |
| 126 | 131 | $open_tags = array_reverse($open_tags); |
@@ -128,13 +133,14 @@ discard block |
||
| 128 | 133 | { |
| 129 | 134 | foreach($open_tags as $key => $open_tag) |
| 130 | 135 | { |
| 131 | - if($key == count($open_tags) - 1) |
|
| 132 | - $content .= $etc; |
|
| 136 | + if($key == count($open_tags) - 1) {
|
|
| 137 | + $content .= $etc; |
|
| 138 | + } |
|
| 133 | 139 | $content .= "</{$open_tag}>"; |
| 134 | 140 | } |
| 135 | - } |
|
| 136 | - else |
|
| 137 | - $content .= $etc; |
|
| 141 | + } else {
|
|
| 142 | + $content .= $etc; |
|
| 143 | + } |
|
| 138 | 144 | |
| 139 | 145 | $this->content = $content; |
| 140 | 146 | } |
@@ -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 |