@@ -83,6 +83,9 @@ |
||
| 83 | 83 | return self::run_query($query); |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | + /** |
|
| 87 | + * @param integer $count |
|
| 88 | + */ |
|
| 86 | 89 | public static function getRecentBlogComments($count) |
| 87 | 90 | {
|
| 88 | 91 | $query = " |
@@ -163,7 +163,7 @@ |
||
| 163 | 163 | { |
| 164 | 164 | $path = self::escape($path); |
| 165 | 165 | |
| 166 | - if($commenter != 0) |
|
| 166 | + if ($commenter != 0) |
|
| 167 | 167 | $trusted_commenter_clause = "(`commenter`.`trusted` = '1' || `commenter`.`id` = '{$commenter}')"; |
| 168 | 168 | else |
| 169 | 169 | $trusted_commenter_clause = "`commenter`.`trusted` = '1'"; |
@@ -5,13 +5,13 @@ discard block |
||
| 5 | 5 | final class CommentCollector extends Collector |
| 6 | 6 | { |
| 7 | 7 | |
| 8 | - public static function getCommenterByFields($name, $email, $website) |
|
| 9 | - { |
|
| 10 | - $name = self::escape($name); |
|
| 11 | - $email = self::escape($email); |
|
| 12 | - $website = self::escape($website); |
|
| 8 | + public static function getCommenterByFields($name, $email, $website) |
|
| 9 | + { |
|
| 10 | + $name = self::escape($name); |
|
| 11 | + $email = self::escape($email); |
|
| 12 | + $website = self::escape($website); |
|
| 13 | 13 | |
| 14 | - $query = " |
|
| 14 | + $query = " |
|
| 15 | 15 | SELECT |
| 16 | 16 | * |
| 17 | 17 | FROM |
@@ -22,14 +22,14 @@ discard block |
||
| 22 | 22 | `url` = '{$website}' |
| 23 | 23 | LIMIT 1"; |
| 24 | 24 | |
| 25 | - return self::run_row_query($query); |
|
| 26 | - } |
|
| 25 | + return self::run_row_query($query); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - public static function getCommentByBody($body) |
|
| 29 | - { |
|
| 30 | - $body = self::escape($body); |
|
| 28 | + public static function getCommentByBody($body) |
|
| 29 | + { |
|
| 30 | + $body = self::escape($body); |
|
| 31 | 31 | |
| 32 | - $query = " |
|
| 32 | + $query = " |
|
| 33 | 33 | SELECT |
| 34 | 34 | * |
| 35 | 35 | FROM |
@@ -38,14 +38,14 @@ discard block |
||
| 38 | 38 | `body` = '{$body}' |
| 39 | 39 | LIMIT 1"; |
| 40 | 40 | |
| 41 | - return self::run_row_query($query); |
|
| 42 | - } |
|
| 41 | + return self::run_row_query($query); |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - public static function getCommentPageByURL($path, $site) |
|
| 45 | - { |
|
| 46 | - $path = self::escape($path); |
|
| 44 | + public static function getCommentPageByURL($path, $site) |
|
| 45 | + { |
|
| 46 | + $path = self::escape($path); |
|
| 47 | 47 | |
| 48 | - $query = " |
|
| 48 | + $query = " |
|
| 49 | 49 | SELECT |
| 50 | 50 | * |
| 51 | 51 | FROM |
@@ -56,12 +56,12 @@ discard block |
||
| 56 | 56 | LIMIT |
| 57 | 57 | 1"; |
| 58 | 58 | |
| 59 | - return self::run_row_query($query); |
|
| 60 | - } |
|
| 59 | + return self::run_row_query($query); |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - public static function getNotificationForPage($comment_page) |
|
| 63 | - { |
|
| 64 | - $query = " |
|
| 62 | + public static function getNotificationForPage($comment_page) |
|
| 63 | + { |
|
| 64 | + $query = " |
|
| 65 | 65 | SELECT |
| 66 | 66 | `name`, |
| 67 | 67 | `email` |
@@ -80,12 +80,12 @@ discard block |
||
| 80 | 80 | ORDER BY |
| 81 | 81 | `date` DESC"; |
| 82 | 82 | |
| 83 | - return self::run_query($query); |
|
| 84 | - } |
|
| 83 | + return self::run_query($query); |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - public static function getRecentBlogComments($count) |
|
| 87 | - { |
|
| 88 | - $query = " |
|
| 86 | + public static function getRecentBlogComments($count) |
|
| 87 | + { |
|
| 88 | + $query = " |
|
| 89 | 89 | SELECT |
| 90 | 90 | `comment_meta`.`id`, |
| 91 | 91 | `post`.`category`, |
@@ -111,8 +111,8 @@ discard block |
||
| 111 | 111 | `comment_meta`.`date` DESC |
| 112 | 112 | LIMIT {$count}"; |
| 113 | 113 | |
| 114 | - return self::run_query($query); |
|
| 115 | - } |
|
| 114 | + return self::run_query($query); |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | 117 | public static function getRecentWaterfallComments($count = 5) |
| 118 | 118 | { |
@@ -159,16 +159,16 @@ discard block |
||
| 159 | 159 | return self::run_query($query); |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - public static function getCommentsForURL($site, $path, $commenter = 0) |
|
| 163 | - { |
|
| 164 | - $path = self::escape($path); |
|
| 162 | + public static function getCommentsForURL($site, $path, $commenter = 0) |
|
| 163 | + { |
|
| 164 | + $path = self::escape($path); |
|
| 165 | 165 | |
| 166 | - if($commenter != 0) |
|
| 167 | - $trusted_commenter_clause = "(`commenter`.`trusted` = '1' || `commenter`.`id` = '{$commenter}')"; |
|
| 168 | - else |
|
| 169 | - $trusted_commenter_clause = "`commenter`.`trusted` = '1'"; |
|
| 166 | + if($commenter != 0) |
|
| 167 | + $trusted_commenter_clause = "(`commenter`.`trusted` = '1' || `commenter`.`id` = '{$commenter}')"; |
|
| 168 | + else |
|
| 169 | + $trusted_commenter_clause = "`commenter`.`trusted` = '1'"; |
|
| 170 | 170 | |
| 171 | - $query = " |
|
| 171 | + $query = " |
|
| 172 | 172 | SELECT |
| 173 | 173 | `comment_meta`.`id`, |
| 174 | 174 | `comment_meta`.`reply`, |
@@ -194,14 +194,14 @@ discard block |
||
| 194 | 194 | ORDER BY |
| 195 | 195 | `comment_meta`.`date`"; |
| 196 | 196 | |
| 197 | - return self::run_query($query); |
|
| 198 | - } |
|
| 197 | + return self::run_query($query); |
|
| 198 | + } |
|
| 199 | 199 | |
| 200 | - public static function getCommentCountForURL($site, $path) |
|
| 201 | - { |
|
| 202 | - $path = self::escape($path); |
|
| 200 | + public static function getCommentCountForURL($site, $path) |
|
| 201 | + { |
|
| 202 | + $path = self::escape($path); |
|
| 203 | 203 | |
| 204 | - $query = " |
|
| 204 | + $query = " |
|
| 205 | 205 | SELECT |
| 206 | 206 | COUNT(1) AS `count` |
| 207 | 207 | FROM |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | ORDER BY |
| 219 | 219 | `comment_meta`.`date`"; |
| 220 | 220 | |
| 221 | - return self::get_count($query); |
|
| 222 | - } |
|
| 221 | + return self::get_count($query); |
|
| 222 | + } |
|
| 223 | 223 | |
| 224 | 224 | } |
| 225 | 225 | \ No newline at end of file |
@@ -2,11 +2,10 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | Loader::load('collector', 'Collector'); |
| 4 | 4 | |
| 5 | -final class CommentCollector extends Collector |
|
| 6 | -{ |
|
| 5 | +final class CommentCollector extends Collector |
|
| 6 | +{
|
|
| 7 | 7 | |
| 8 | - public static function getCommenterByFields($name, $email, $website) |
|
| 9 | - { |
|
| 8 | + public static function getCommenterByFields($name, $email, $website) {
|
|
| 10 | 9 | $name = self::escape($name); |
| 11 | 10 | $email = self::escape($email); |
| 12 | 11 | $website = self::escape($website); |
@@ -25,8 +24,7 @@ discard block |
||
| 25 | 24 | return self::run_row_query($query); |
| 26 | 25 | } |
| 27 | 26 | |
| 28 | - public static function getCommentByBody($body) |
|
| 29 | - { |
|
| 27 | + public static function getCommentByBody($body) {
|
|
| 30 | 28 | $body = self::escape($body); |
| 31 | 29 | |
| 32 | 30 | $query = " |
@@ -41,8 +39,7 @@ discard block |
||
| 41 | 39 | return self::run_row_query($query); |
| 42 | 40 | } |
| 43 | 41 | |
| 44 | - public static function getCommentPageByURL($path, $site) |
|
| 45 | - { |
|
| 42 | + public static function getCommentPageByURL($path, $site) {
|
|
| 46 | 43 | $path = self::escape($path); |
| 47 | 44 | |
| 48 | 45 | $query = " |
@@ -59,8 +56,7 @@ discard block |
||
| 59 | 56 | return self::run_row_query($query); |
| 60 | 57 | } |
| 61 | 58 | |
| 62 | - public static function getNotificationForPage($comment_page) |
|
| 63 | - { |
|
| 59 | + public static function getNotificationForPage($comment_page) {
|
|
| 64 | 60 | $query = " |
| 65 | 61 | SELECT |
| 66 | 62 | `name`, |
@@ -83,8 +79,7 @@ discard block |
||
| 83 | 79 | return self::run_query($query); |
| 84 | 80 | } |
| 85 | 81 | |
| 86 | - public static function getRecentBlogComments($count) |
|
| 87 | - { |
|
| 82 | + public static function getRecentBlogComments($count) {
|
|
| 88 | 83 | $query = " |
| 89 | 84 | SELECT |
| 90 | 85 | `comment_meta`.`id`, |
@@ -114,8 +109,7 @@ discard block |
||
| 114 | 109 | return self::run_query($query); |
| 115 | 110 | } |
| 116 | 111 | |
| 117 | - public static function getRecentWaterfallComments($count = 5) |
|
| 118 | - { |
|
| 112 | + public static function getRecentWaterfallComments($count = 5) {
|
|
| 119 | 113 | $query = " |
| 120 | 114 | SELECT |
| 121 | 115 | `comment_meta`.`id`, |
@@ -159,14 +153,14 @@ discard block |
||
| 159 | 153 | return self::run_query($query); |
| 160 | 154 | } |
| 161 | 155 | |
| 162 | - public static function getCommentsForURL($site, $path, $commenter = 0) |
|
| 163 | - { |
|
| 156 | + public static function getCommentsForURL($site, $path, $commenter = 0) {
|
|
| 164 | 157 | $path = self::escape($path); |
| 165 | 158 | |
| 166 | - if($commenter != 0) |
|
| 167 | - $trusted_commenter_clause = "(`commenter`.`trusted` = '1' || `commenter`.`id` = '{$commenter}')"; |
|
| 168 | - else |
|
| 169 | - $trusted_commenter_clause = "`commenter`.`trusted` = '1'"; |
|
| 159 | + if($commenter != 0) {
|
|
| 160 | + $trusted_commenter_clause = "(`commenter`.`trusted` = '1' || `commenter`.`id` = '{$commenter}')";
|
|
| 161 | + } else {
|
|
| 162 | + $trusted_commenter_clause = "`commenter`.`trusted` = '1'"; |
|
| 163 | + } |
|
| 170 | 164 | |
| 171 | 165 | $query = " |
| 172 | 166 | SELECT |
@@ -197,8 +191,7 @@ discard block |
||
| 197 | 191 | return self::run_query($query); |
| 198 | 192 | } |
| 199 | 193 | |
| 200 | - public static function getCommentCountForURL($site, $path) |
|
| 201 | - { |
|
| 194 | + public static function getCommentCountForURL($site, $path) {
|
|
| 202 | 195 | $path = self::escape($path); |
| 203 | 196 | |
| 204 | 197 | $query = " |
@@ -34,6 +34,9 @@ discard block |
||
| 34 | 34 | return self::run_query($query); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | + /** |
|
| 38 | + * @param integer $total |
|
| 39 | + */ |
|
| 37 | 40 | public static function getRecentList($total) |
| 38 | 41 | {
|
| 39 | 42 | $query = " |
@@ -178,6 +181,9 @@ discard block |
||
| 178 | 181 | return self::run_row_query($query); |
| 179 | 182 | } |
| 180 | 183 | |
| 184 | + /** |
|
| 185 | + * @param string $date |
|
| 186 | + */ |
|
| 181 | 187 | public static function getByDate($date) |
| 182 | 188 | {
|
| 183 | 189 | $date = self::escape($date); |
@@ -5,9 +5,9 @@ discard block |
||
| 5 | 5 | final class LogCollector extends Collector |
| 6 | 6 | { |
| 7 | 7 | |
| 8 | - public static function getList($total, $offset = 0) |
|
| 9 | - { |
|
| 10 | - $query = " |
|
| 8 | + public static function getList($total, $offset = 0) |
|
| 9 | + { |
|
| 10 | + $query = " |
|
| 11 | 11 | SELECT |
| 12 | 12 | `log`.`id`, |
| 13 | 13 | `log`.`title`, |
@@ -31,8 +31,8 @@ discard block |
||
| 31 | 31 | `log`.`date` DESC |
| 32 | 32 | LIMIT |
| 33 | 33 | {$offset}, {$total}"; |
| 34 | - return self::run_query($query); |
|
| 35 | - } |
|
| 34 | + return self::run_query($query); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | 37 | public static function getRecentList($total) |
| 38 | 38 | { |
@@ -62,21 +62,21 @@ discard block |
||
| 62 | 62 | return self::run_query($query); |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - public static function getListCount() |
|
| 66 | - { |
|
| 67 | - $query = " |
|
| 65 | + public static function getListCount() |
|
| 66 | + { |
|
| 67 | + $query = " |
|
| 68 | 68 | SELECT |
| 69 | 69 | COUNT(1) AS `count` |
| 70 | 70 | FROM |
| 71 | 71 | `jpemeric_waterfall`.`log` |
| 72 | 72 | WHERE |
| 73 | 73 | `is_public` = '1'"; |
| 74 | - return self::get_count($query); |
|
| 75 | - } |
|
| 74 | + return self::get_count($query); |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - public static function getCompanionListForLog($log) |
|
| 78 | - { |
|
| 79 | - $query = " |
|
| 77 | + public static function getCompanionListForLog($log) |
|
| 78 | + { |
|
| 79 | + $query = " |
|
| 80 | 80 | SELECT |
| 81 | 81 | `companion`.`name`, |
| 82 | 82 | `companion`.`alias` |
@@ -87,12 +87,12 @@ discard block |
||
| 87 | 87 | ON `log_companion_map`.`companion` = `companion`.`id` |
| 88 | 88 | WHERE |
| 89 | 89 | `log_companion_map`.`log` = '{$log}'"; |
| 90 | - return self::run_query($query); |
|
| 91 | - } |
|
| 90 | + return self::run_query($query); |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - public static function getWaterfallListForLog($log) |
|
| 94 | - { |
|
| 95 | - $query = " |
|
| 93 | + public static function getWaterfallListForLog($log) |
|
| 94 | + { |
|
| 95 | + $query = " |
|
| 96 | 96 | SELECT |
| 97 | 97 | `waterfall`.`name`, |
| 98 | 98 | `waterfall`.`alias`, |
@@ -110,12 +110,12 @@ discard block |
||
| 110 | 110 | `waterfall`.`is_public` = '1' |
| 111 | 111 | ORDER BY |
| 112 | 112 | `log_waterfall_map`.`order`"; |
| 113 | - return self::run_query($query); |
|
| 114 | - } |
|
| 113 | + return self::run_query($query); |
|
| 114 | + } |
|
| 115 | 115 | |
| 116 | - public static function getLogListForWaterfall($waterfall) |
|
| 117 | - { |
|
| 118 | - $query = " |
|
| 116 | + public static function getLogListForWaterfall($waterfall) |
|
| 117 | + { |
|
| 118 | + $query = " |
|
| 119 | 119 | SELECT |
| 120 | 120 | `log`.`title`, |
| 121 | 121 | `log`.`alias`, |
@@ -130,12 +130,12 @@ discard block |
||
| 130 | 130 | `log`.`is_public` = '1' |
| 131 | 131 | ORDER BY |
| 132 | 132 | `log`.`date`"; |
| 133 | - return self::run_query($query); |
|
| 134 | - } |
|
| 133 | + return self::run_query($query); |
|
| 134 | + } |
|
| 135 | 135 | |
| 136 | - public static function getTagListForLog($log) |
|
| 137 | - { |
|
| 138 | - $query = " |
|
| 136 | + public static function getTagListForLog($log) |
|
| 137 | + { |
|
| 138 | + $query = " |
|
| 139 | 139 | SELECT |
| 140 | 140 | `tag`.`name`, |
| 141 | 141 | `tag`.`alias` |
@@ -144,14 +144,14 @@ discard block |
||
| 144 | 144 | INNER JOIN |
| 145 | 145 | `jpemeric_waterfall`.`log_tag_map` |
| 146 | 146 | ON `log_tag_map`.`tag` = `tag`.`id` && `log_tag_map`.`log` = '{$log}'"; |
| 147 | - return self::run_query($query); |
|
| 148 | - } |
|
| 147 | + return self::run_query($query); |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | - public static function getByAlias($alias) |
|
| 151 | - { |
|
| 152 | - $alias = self::escape($alias); |
|
| 150 | + public static function getByAlias($alias) |
|
| 151 | + { |
|
| 152 | + $alias = self::escape($alias); |
|
| 153 | 153 | |
| 154 | - $query = " |
|
| 154 | + $query = " |
|
| 155 | 155 | SELECT |
| 156 | 156 | `log`.`id`, |
| 157 | 157 | `log`.`title`, |
@@ -175,8 +175,8 @@ discard block |
||
| 175 | 175 | `log`.`is_public` = '1' |
| 176 | 176 | LIMIT 1"; |
| 177 | 177 | |
| 178 | - return self::run_row_query($query); |
|
| 179 | - } |
|
| 178 | + return self::run_row_query($query); |
|
| 179 | + } |
|
| 180 | 180 | |
| 181 | 181 | public static function getByDate($date) |
| 182 | 182 | { |
@@ -195,9 +195,9 @@ discard block |
||
| 195 | 195 | return self::run_row_query($query); |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | - public static function getById($log) |
|
| 199 | - { |
|
| 200 | - $query = " |
|
| 198 | + public static function getById($log) |
|
| 199 | + { |
|
| 200 | + $query = " |
|
| 201 | 201 | SELECT |
| 202 | 202 | `title`, |
| 203 | 203 | `date`, |
@@ -208,12 +208,12 @@ discard block |
||
| 208 | 208 | `id` = '{$log}' AND |
| 209 | 209 | `is_public` = '1' |
| 210 | 210 | LIMIT 1"; |
| 211 | - return self::run_row_query($query); |
|
| 212 | - } |
|
| 211 | + return self::run_row_query($query); |
|
| 212 | + } |
|
| 213 | 213 | |
| 214 | - public static function getPreviousLog($log) |
|
| 215 | - { |
|
| 216 | - $query = " |
|
| 214 | + public static function getPreviousLog($log) |
|
| 215 | + { |
|
| 216 | + $query = " |
|
| 217 | 217 | SELECT |
| 218 | 218 | `title`, |
| 219 | 219 | `date`, |
@@ -233,12 +233,12 @@ discard block |
||
| 233 | 233 | `date` DESC |
| 234 | 234 | LIMIT 1"; |
| 235 | 235 | |
| 236 | - return self::run_row_query($query); |
|
| 237 | - } |
|
| 236 | + return self::run_row_query($query); |
|
| 237 | + } |
|
| 238 | 238 | |
| 239 | - public static function getNextLog($log) |
|
| 240 | - { |
|
| 241 | - $query = " |
|
| 239 | + public static function getNextLog($log) |
|
| 240 | + { |
|
| 241 | + $query = " |
|
| 242 | 242 | SELECT |
| 243 | 243 | `title`, |
| 244 | 244 | `date`, |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | `date` ASC |
| 259 | 259 | LIMIT 1"; |
| 260 | 260 | |
| 261 | - return self::run_row_query($query); |
|
| 262 | - } |
|
| 261 | + return self::run_row_query($query); |
|
| 262 | + } |
|
| 263 | 263 | |
| 264 | 264 | } |
@@ -2,11 +2,10 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | Loader::load('collector', 'Collector'); |
| 4 | 4 | |
| 5 | -final class LogCollector extends Collector |
|
| 6 | -{ |
|
| 5 | +final class LogCollector extends Collector |
|
| 6 | +{
|
|
| 7 | 7 | |
| 8 | - public static function getList($total, $offset = 0) |
|
| 9 | - { |
|
| 8 | + public static function getList($total, $offset = 0) {
|
|
| 10 | 9 | $query = " |
| 11 | 10 | SELECT |
| 12 | 11 | `log`.`id`, |
@@ -34,8 +33,7 @@ discard block |
||
| 34 | 33 | return self::run_query($query); |
| 35 | 34 | } |
| 36 | 35 | |
| 37 | - public static function getRecentList($total) |
|
| 38 | - { |
|
| 36 | + public static function getRecentList($total) {
|
|
| 39 | 37 | $query = " |
| 40 | 38 | SELECT |
| 41 | 39 | `log`.`title`, |
@@ -62,8 +60,7 @@ discard block |
||
| 62 | 60 | return self::run_query($query); |
| 63 | 61 | } |
| 64 | 62 | |
| 65 | - public static function getListCount() |
|
| 66 | - { |
|
| 63 | + public static function getListCount() {
|
|
| 67 | 64 | $query = " |
| 68 | 65 | SELECT |
| 69 | 66 | COUNT(1) AS `count` |
@@ -74,8 +71,7 @@ discard block |
||
| 74 | 71 | return self::get_count($query); |
| 75 | 72 | } |
| 76 | 73 | |
| 77 | - public static function getCompanionListForLog($log) |
|
| 78 | - { |
|
| 74 | + public static function getCompanionListForLog($log) {
|
|
| 79 | 75 | $query = " |
| 80 | 76 | SELECT |
| 81 | 77 | `companion`.`name`, |
@@ -90,8 +86,7 @@ discard block |
||
| 90 | 86 | return self::run_query($query); |
| 91 | 87 | } |
| 92 | 88 | |
| 93 | - public static function getWaterfallListForLog($log) |
|
| 94 | - { |
|
| 89 | + public static function getWaterfallListForLog($log) {
|
|
| 95 | 90 | $query = " |
| 96 | 91 | SELECT |
| 97 | 92 | `waterfall`.`name`, |
@@ -113,8 +108,7 @@ discard block |
||
| 113 | 108 | return self::run_query($query); |
| 114 | 109 | } |
| 115 | 110 | |
| 116 | - public static function getLogListForWaterfall($waterfall) |
|
| 117 | - { |
|
| 111 | + public static function getLogListForWaterfall($waterfall) {
|
|
| 118 | 112 | $query = " |
| 119 | 113 | SELECT |
| 120 | 114 | `log`.`title`, |
@@ -133,8 +127,7 @@ discard block |
||
| 133 | 127 | return self::run_query($query); |
| 134 | 128 | } |
| 135 | 129 | |
| 136 | - public static function getTagListForLog($log) |
|
| 137 | - { |
|
| 130 | + public static function getTagListForLog($log) {
|
|
| 138 | 131 | $query = " |
| 139 | 132 | SELECT |
| 140 | 133 | `tag`.`name`, |
@@ -147,8 +140,7 @@ discard block |
||
| 147 | 140 | return self::run_query($query); |
| 148 | 141 | } |
| 149 | 142 | |
| 150 | - public static function getByAlias($alias) |
|
| 151 | - { |
|
| 143 | + public static function getByAlias($alias) {
|
|
| 152 | 144 | $alias = self::escape($alias); |
| 153 | 145 | |
| 154 | 146 | $query = " |
@@ -178,8 +170,7 @@ discard block |
||
| 178 | 170 | return self::run_row_query($query); |
| 179 | 171 | } |
| 180 | 172 | |
| 181 | - public static function getByDate($date) |
|
| 182 | - { |
|
| 173 | + public static function getByDate($date) {
|
|
| 183 | 174 | $date = self::escape($date); |
| 184 | 175 | |
| 185 | 176 | $query = " |
@@ -195,8 +186,7 @@ discard block |
||
| 195 | 186 | return self::run_row_query($query); |
| 196 | 187 | } |
| 197 | 188 | |
| 198 | - public static function getById($log) |
|
| 199 | - { |
|
| 189 | + public static function getById($log) {
|
|
| 200 | 190 | $query = " |
| 201 | 191 | SELECT |
| 202 | 192 | `title`, |
@@ -211,8 +201,7 @@ discard block |
||
| 211 | 201 | return self::run_row_query($query); |
| 212 | 202 | } |
| 213 | 203 | |
| 214 | - public static function getPreviousLog($log) |
|
| 215 | - { |
|
| 204 | + public static function getPreviousLog($log) {
|
|
| 216 | 205 | $query = " |
| 217 | 206 | SELECT |
| 218 | 207 | `title`, |
@@ -236,8 +225,7 @@ discard block |
||
| 236 | 225 | return self::run_row_query($query); |
| 237 | 226 | } |
| 238 | 227 | |
| 239 | - public static function getNextLog($log) |
|
| 240 | - { |
|
| 228 | + public static function getNextLog($log) {
|
|
| 241 | 229 | $query = " |
| 242 | 230 | SELECT |
| 243 | 231 | `title`, |
@@ -117,6 +117,9 @@ |
||
| 117 | 117 | return self::run_query($query); |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | + /** |
|
| 121 | + * @param string $alias |
|
| 122 | + */ |
|
| 120 | 123 | public static function getByOldAlias($alias) |
| 121 | 124 | {
|
| 122 | 125 | $alias = self::escape($alias); |
@@ -5,9 +5,9 @@ discard block |
||
| 5 | 5 | final class WaterfallCollector extends Collector |
| 6 | 6 | { |
| 7 | 7 | |
| 8 | - public static function getList($total, $offset = 0) |
|
| 9 | - { |
|
| 10 | - $query = " |
|
| 8 | + public static function getList($total, $offset = 0) |
|
| 9 | + { |
|
| 10 | + $query = " |
|
| 11 | 11 | SELECT |
| 12 | 12 | `waterfall`.`id`, |
| 13 | 13 | `waterfall`.`name`, |
@@ -40,8 +40,8 @@ discard block |
||
| 40 | 40 | `watercourse`.`name` |
| 41 | 41 | LIMIT |
| 42 | 42 | {$offset}, {$total}"; |
| 43 | - return self::run_query($query); |
|
| 44 | - } |
|
| 43 | + return self::run_query($query); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | 46 | public static function getMapList() |
| 47 | 47 | { |
@@ -74,9 +74,9 @@ discard block |
||
| 74 | 74 | return self::run_query($query); |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - public static function getListCount() |
|
| 78 | - { |
|
| 79 | - $query = " |
|
| 77 | + public static function getListCount() |
|
| 78 | + { |
|
| 79 | + $query = " |
|
| 80 | 80 | SELECT |
| 81 | 81 | COUNT(1) AS `count` |
| 82 | 82 | FROM |
@@ -89,8 +89,8 @@ discard block |
||
| 89 | 89 | ON `county`.`id` = `waterfall`.`county` |
| 90 | 90 | WHERE |
| 91 | 91 | `waterfall`.`is_public` = '1'"; |
| 92 | - return self::get_count($query); |
|
| 93 | - } |
|
| 92 | + return self::get_count($query); |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | 95 | public static function getNearbyList($waterfall) |
| 96 | 96 | { |
@@ -137,12 +137,12 @@ discard block |
||
| 137 | 137 | return self::run_row_query($query); |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - public static function getByAlias($watercourse, $waterfall) |
|
| 141 | - { |
|
| 142 | - $watercourse = self::escape($watercourse); |
|
| 143 | - $waterfall = self::escape($waterfall); |
|
| 140 | + public static function getByAlias($watercourse, $waterfall) |
|
| 141 | + { |
|
| 142 | + $watercourse = self::escape($watercourse); |
|
| 143 | + $waterfall = self::escape($waterfall); |
|
| 144 | 144 | |
| 145 | - $query = " |
|
| 145 | + $query = " |
|
| 146 | 146 | SELECT |
| 147 | 147 | `waterfall`.`id` AS `id`, |
| 148 | 148 | `waterfall`.`name`, |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | `waterfall`.`is_public` = '1' |
| 193 | 193 | LIMIT 1"; |
| 194 | 194 | |
| 195 | - return self::run_row_query($query); |
|
| 196 | - } |
|
| 195 | + return self::run_row_query($query); |
|
| 196 | + } |
|
| 197 | 197 | |
| 198 | 198 | } |
| 199 | 199 | \ No newline at end of file |
@@ -2,11 +2,10 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | Loader::load('collector', 'Collector'); |
| 4 | 4 | |
| 5 | -final class WaterfallCollector extends Collector |
|
| 6 | -{ |
|
| 5 | +final class WaterfallCollector extends Collector |
|
| 6 | +{
|
|
| 7 | 7 | |
| 8 | - public static function getList($total, $offset = 0) |
|
| 9 | - { |
|
| 8 | + public static function getList($total, $offset = 0) {
|
|
| 10 | 9 | $query = " |
| 11 | 10 | SELECT |
| 12 | 11 | `waterfall`.`id`, |
@@ -43,8 +42,7 @@ discard block |
||
| 43 | 42 | return self::run_query($query); |
| 44 | 43 | } |
| 45 | 44 | |
| 46 | - public static function getMapList() |
|
| 47 | - { |
|
| 45 | + public static function getMapList() {
|
|
| 48 | 46 | $query = " |
| 49 | 47 | SELECT |
| 50 | 48 | `waterfall`.`name`, |
@@ -74,8 +72,7 @@ discard block |
||
| 74 | 72 | return self::run_query($query); |
| 75 | 73 | } |
| 76 | 74 | |
| 77 | - public static function getListCount() |
|
| 78 | - { |
|
| 75 | + public static function getListCount() {
|
|
| 79 | 76 | $query = " |
| 80 | 77 | SELECT |
| 81 | 78 | COUNT(1) AS `count` |
@@ -92,8 +89,7 @@ discard block |
||
| 92 | 89 | return self::get_count($query); |
| 93 | 90 | } |
| 94 | 91 | |
| 95 | - public static function getNearbyList($waterfall) |
|
| 96 | - { |
|
| 92 | + public static function getNearbyList($waterfall) {
|
|
| 97 | 93 | $query = " |
| 98 | 94 | SELECT |
| 99 | 95 | `waterfall`.`name`, |
@@ -117,8 +113,7 @@ discard block |
||
| 117 | 113 | return self::run_query($query); |
| 118 | 114 | } |
| 119 | 115 | |
| 120 | - public static function getByOldAlias($alias) |
|
| 121 | - { |
|
| 116 | + public static function getByOldAlias($alias) {
|
|
| 122 | 117 | $alias = self::escape($alias); |
| 123 | 118 | |
| 124 | 119 | $query = " |
@@ -137,8 +132,7 @@ discard block |
||
| 137 | 132 | return self::run_row_query($query); |
| 138 | 133 | } |
| 139 | 134 | |
| 140 | - public static function getByAlias($watercourse, $waterfall) |
|
| 141 | - { |
|
| 135 | + public static function getByAlias($watercourse, $waterfall) {
|
|
| 142 | 136 | $watercourse = self::escape($watercourse); |
| 143 | 137 | $waterfall = self::escape($waterfall); |
| 144 | 138 | |
@@ -97,6 +97,9 @@ |
||
| 97 | 97 | return $tag_array; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | + /** |
|
| 101 | + * @param boolean $trim |
|
| 102 | + */ |
|
| 100 | 103 | final private function get_body_for_post($post, $trim) |
| 101 | 104 | {
|
| 102 | 105 | $body = $post->body; |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | Loader::load('collector', 'image/PhotoCollector'); |
| 42 | 42 | $photo_result = PhotoCollector::getRow($id); |
| 43 | 43 | |
| 44 | - if($photo_result == null) |
|
| 44 | + if ($photo_result == null) |
|
| 45 | 45 | return; |
| 46 | 46 | |
| 47 | 47 | $name = $photo_result->name; |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | $tag_result = $repository->getTagsForPost($post['id']); |
| 93 | 93 | |
| 94 | 94 | $tag_array = array(); |
| 95 | - foreach($tag_result as $tag) |
|
| 95 | + foreach ($tag_result as $tag) |
|
| 96 | 96 | { |
| 97 | 97 | $tag_object = new stdclass(); |
| 98 | 98 | $tag_object->name = $tag['tag']; |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | { |
| 107 | 107 | $body = $post['body']; |
| 108 | 108 | |
| 109 | - if($trim) |
|
| 109 | + if ($trim) |
|
| 110 | 110 | $body = Content::instance('SmartTrim', $body)->activate(self::$LENGTH_OF_TRIMMED_POST); |
| 111 | 111 | |
| 112 | 112 | $body = Content::instance('FixPhoto', $body)->activate(false, 'standard'); |
@@ -132,9 +132,9 @@ discard block |
||
| 132 | 132 | $maximum_tag_count = $this->get_maximum_tag_count($tag_result); |
| 133 | 133 | |
| 134 | 134 | $cloud_array = array(); |
| 135 | - foreach($tag_result as $tag) |
|
| 135 | + foreach ($tag_result as $tag) |
|
| 136 | 136 | { |
| 137 | - if($tag['count'] < self::$MINIMUM_TAG_COUNT) |
|
| 137 | + if ($tag['count'] < self::$MINIMUM_TAG_COUNT) |
|
| 138 | 138 | continue; |
| 139 | 139 | |
| 140 | 140 | $tag_object = new stdclass(); |
@@ -151,9 +151,9 @@ discard block |
||
| 151 | 151 | { |
| 152 | 152 | $maximum = 1; |
| 153 | 153 | |
| 154 | - foreach($tag_result as $tag) |
|
| 154 | + foreach ($tag_result as $tag) |
|
| 155 | 155 | { |
| 156 | - if($tag['count'] > $maximum) |
|
| 156 | + if ($tag['count'] > $maximum) |
|
| 157 | 157 | $maximum = $tag['count']; |
| 158 | 158 | } |
| 159 | 159 | return $maximum; |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | $comment_array = CommentCollector::getRecentBlogComments(self::$RECENT_COMMENT_COUNT); |
| 165 | 165 | |
| 166 | 166 | $array = array(); |
| 167 | - foreach($comment_array as $comment) |
|
| 167 | + foreach ($comment_array as $comment) |
|
| 168 | 168 | { |
| 169 | 169 | $body = $comment->body; |
| 170 | 170 | $body = strip_tags($body); |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | $comment_obj = new stdclass(); |
| 173 | 173 | $comment_obj->description = Content::instance('SmartTrim', $body)->activate(30); |
| 174 | 174 | $comment_obj->commenter = $comment->name; |
| 175 | - $comment_obj->link = Loader::getRootURL() . "{$comment->category}/{$comment->path}/#comment-{$comment->id}"; |
|
| 175 | + $comment_obj->link = Loader::getRootURL()."{$comment->category}/{$comment->path}/#comment-{$comment->id}"; |
|
| 176 | 176 | $array[] = $comment_obj; |
| 177 | 177 | } |
| 178 | 178 | |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | $comment_response = $api->getComments(1, self::$RECENT_COMMENT_COUNT, '-date', 'blog.jacobemerick.com'); |
| 202 | 202 | |
| 203 | 203 | $array = array(); |
| 204 | - foreach($comment_response as $comment) |
|
| 204 | + foreach ($comment_response as $comment) |
|
| 205 | 205 | { |
| 206 | 206 | $body = $comment->getBody(); |
| 207 | 207 | $body = strip_tags($body); |
@@ -8,81 +8,81 @@ discard block |
||
| 8 | 8 | abstract class DefaultPageController extends PageController |
| 9 | 9 | { |
| 10 | 10 | |
| 11 | - private static $RECENT_COMMENT_COUNT = 10; |
|
| 12 | - private static $MINIMUM_TAG_COUNT = 10; |
|
| 13 | - protected static $LENGTH_OF_TRIMMED_POST = 300; |
|
| 11 | + private static $RECENT_COMMENT_COUNT = 10; |
|
| 12 | + private static $MINIMUM_TAG_COUNT = 10; |
|
| 13 | + protected static $LENGTH_OF_TRIMMED_POST = 300; |
|
| 14 | 14 | |
| 15 | - protected static $BLOG_SITE_ID = 2; |
|
| 15 | + protected static $BLOG_SITE_ID = 2; |
|
| 16 | 16 | |
| 17 | - private static $INTRODUCTION_IMAGE_PATTERN = '<img src="/photo/%s/%s-size-%s.jpg" height="%d" width="%d" alt="%s" />'; |
|
| 17 | + private static $INTRODUCTION_IMAGE_PATTERN = '<img src="/photo/%s/%s-size-%s.jpg" height="%d" width="%d" alt="%s" />'; |
|
| 18 | 18 | |
| 19 | - protected function set_head_data() |
|
| 20 | - { |
|
| 19 | + protected function set_head_data() |
|
| 20 | + { |
|
| 21 | 21 | $this->set_head('rss_link', [ |
| 22 | - 'title' => 'Jacob Emerick Blog Feed', |
|
| 23 | - 'url' => '/rss.xml' |
|
| 22 | + 'title' => 'Jacob Emerick Blog Feed', |
|
| 23 | + 'url' => '/rss.xml' |
|
| 24 | 24 | ]); |
| 25 | 25 | $this->set_head('rss_comment_link', [ |
| 26 | - 'title' => 'Jacob Emerick Blog Comment Feed', |
|
| 27 | - 'url' => '/rss-comments.xml' |
|
| 26 | + 'title' => 'Jacob Emerick Blog Comment Feed', |
|
| 27 | + 'url' => '/rss-comments.xml' |
|
| 28 | 28 | ]); |
| 29 | 29 | |
| 30 | - $this->add_css('normalize'); |
|
| 31 | - $this->add_css('blog'); |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - protected function get_introduction() |
|
| 35 | - { |
|
| 36 | - return; |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - protected function get_introduction_image($id) |
|
| 40 | - { |
|
| 41 | - Loader::load('collector', 'image/PhotoCollector'); |
|
| 42 | - $photo_result = PhotoCollector::getRow($id); |
|
| 30 | + $this->add_css('normalize'); |
|
| 31 | + $this->add_css('blog'); |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + protected function get_introduction() |
|
| 35 | + { |
|
| 36 | + return; |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + protected function get_introduction_image($id) |
|
| 40 | + { |
|
| 41 | + Loader::load('collector', 'image/PhotoCollector'); |
|
| 42 | + $photo_result = PhotoCollector::getRow($id); |
|
| 43 | 43 | |
| 44 | - if($photo_result == null) |
|
| 45 | - return; |
|
| 44 | + if($photo_result == null) |
|
| 45 | + return; |
|
| 46 | 46 | |
| 47 | - $name = $photo_result->name; |
|
| 48 | - $category = $photo_result->category; |
|
| 49 | - $size = 'medium'; |
|
| 50 | - $height = 375; |
|
| 51 | - $width = 500; |
|
| 52 | - $description = $photo_result->description; |
|
| 47 | + $name = $photo_result->name; |
|
| 48 | + $category = $photo_result->category; |
|
| 49 | + $size = 'medium'; |
|
| 50 | + $height = 375; |
|
| 51 | + $width = 500; |
|
| 52 | + $description = $photo_result->description; |
|
| 53 | 53 | |
| 54 | - return sprintf(self::$INTRODUCTION_IMAGE_PATTERN, $category, $name, $size, $height, $width, $description); |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - protected function set_body_data() |
|
| 58 | - { |
|
| 59 | - $this->set_body('introduction', $this->get_introduction()); |
|
| 60 | - $this->set_body('right_side', $this->get_right_side()); |
|
| 61 | - $this->set_body('activity_array', $this->get_recent_activity()); |
|
| 54 | + return sprintf(self::$INTRODUCTION_IMAGE_PATTERN, $category, $name, $size, $height, $width, $description); |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + protected function set_body_data() |
|
| 58 | + { |
|
| 59 | + $this->set_body('introduction', $this->get_introduction()); |
|
| 60 | + $this->set_body('right_side', $this->get_right_side()); |
|
| 61 | + $this->set_body('activity_array', $this->get_recent_activity()); |
|
| 62 | 62 | |
| 63 | - $this->set_body_view('Page'); |
|
| 64 | - } |
|
| 63 | + $this->set_body_view('Page'); |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - final protected function format_post($post, $trim = false) |
|
| 67 | - { |
|
| 68 | - $post_object = new stdclass(); |
|
| 66 | + final protected function format_post($post, $trim = false) |
|
| 67 | + { |
|
| 68 | + $post_object = new stdclass(); |
|
| 69 | 69 | |
| 70 | - $post_object->title = $post['title']; |
|
| 71 | - $post_object->path = "/{$post['category']}/{$post['path']}/"; |
|
| 72 | - $post_object->category = ucwords(str_replace('-', ' ', $post['category'])); |
|
| 73 | - $post_object->category_link = "/{$post['category']}/"; |
|
| 74 | - // $post_object->comment_count = $this->get_comments_for_post($post); |
|
| 75 | - $post_object->tags = $this->get_tags_for_post($post); |
|
| 76 | - $post_object->image = Content::instance('FetchFirstPhoto', $post['body'])->activate(false, 'small'); |
|
| 77 | - $post_object->body = $this->get_body_for_post($post, $trim); |
|
| 78 | - $post_object->date = $this->get_parsed_date($post['date']); |
|
| 79 | - |
|
| 80 | - return $post_object; |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - final private function get_comments_for_post($post) |
|
| 84 | - { |
|
| 85 | - $count = CommentCollector::getCommentCountForURL(self::$BLOG_SITE_ID, $post['path']); |
|
| 70 | + $post_object->title = $post['title']; |
|
| 71 | + $post_object->path = "/{$post['category']}/{$post['path']}/"; |
|
| 72 | + $post_object->category = ucwords(str_replace('-', ' ', $post['category'])); |
|
| 73 | + $post_object->category_link = "/{$post['category']}/"; |
|
| 74 | + // $post_object->comment_count = $this->get_comments_for_post($post); |
|
| 75 | + $post_object->tags = $this->get_tags_for_post($post); |
|
| 76 | + $post_object->image = Content::instance('FetchFirstPhoto', $post['body'])->activate(false, 'small'); |
|
| 77 | + $post_object->body = $this->get_body_for_post($post, $trim); |
|
| 78 | + $post_object->date = $this->get_parsed_date($post['date']); |
|
| 79 | + |
|
| 80 | + return $post_object; |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + final private function get_comments_for_post($post) |
|
| 84 | + { |
|
| 85 | + $count = CommentCollector::getCommentCountForURL(self::$BLOG_SITE_ID, $post['path']); |
|
| 86 | 86 | $count_from_service = $this->get_comments_for_post_from_service($post); |
| 87 | 87 | |
| 88 | 88 | if ($count_from_service !== null && $count_from_service != $count) { |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | $container['console']->log("{$count}, {$count_from_service} in service"); |
| 92 | 92 | } |
| 93 | 93 | return $count; |
| 94 | - } |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | 96 | final private function get_comments_for_post_from_service($post) |
| 97 | 97 | { |
@@ -127,106 +127,106 @@ discard block |
||
| 127 | 127 | return count($comment_response); |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - final private function get_tags_for_post($post) |
|
| 131 | - { |
|
| 130 | + final private function get_tags_for_post($post) |
|
| 131 | + { |
|
| 132 | 132 | global $container; |
| 133 | 133 | $repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']); |
| 134 | 134 | $tag_result = $repository->getTagsForPost($post['id']); |
| 135 | 135 | |
| 136 | 136 | $tag_array = array(); |
| 137 | - foreach($tag_result as $tag) |
|
| 138 | - { |
|
| 139 | - $tag_object = new stdclass(); |
|
| 140 | - $tag_object->name = $tag['tag']; |
|
| 141 | - $tag_object->link = Content::instance('URLSafe', "/tag/{$tag['tag']}/")->activate(); |
|
| 142 | - $tag_array[] = $tag_object; |
|
| 143 | - } |
|
| 144 | - return $tag_array; |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - final private function get_body_for_post($post, $trim) |
|
| 148 | - { |
|
| 149 | - $body = $post['body']; |
|
| 137 | + foreach($tag_result as $tag) |
|
| 138 | + { |
|
| 139 | + $tag_object = new stdclass(); |
|
| 140 | + $tag_object->name = $tag['tag']; |
|
| 141 | + $tag_object->link = Content::instance('URLSafe', "/tag/{$tag['tag']}/")->activate(); |
|
| 142 | + $tag_array[] = $tag_object; |
|
| 143 | + } |
|
| 144 | + return $tag_array; |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + final private function get_body_for_post($post, $trim) |
|
| 148 | + { |
|
| 149 | + $body = $post['body']; |
|
| 150 | 150 | |
| 151 | - if($trim) |
|
| 152 | - $body = Content::instance('SmartTrim', $body)->activate(self::$LENGTH_OF_TRIMMED_POST); |
|
| 151 | + if($trim) |
|
| 152 | + $body = Content::instance('SmartTrim', $body)->activate(self::$LENGTH_OF_TRIMMED_POST); |
|
| 153 | 153 | |
| 154 | - $body = Content::instance('FixPhoto', $body)->activate(false, 'standard'); |
|
| 155 | - $body = Content::instance('MarkupCode', $body)->activate(); |
|
| 154 | + $body = Content::instance('FixPhoto', $body)->activate(false, 'standard'); |
|
| 155 | + $body = Content::instance('MarkupCode', $body)->activate(); |
|
| 156 | 156 | |
| 157 | - return $body; |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - final protected function get_right_side() |
|
| 161 | - { |
|
| 162 | - $side_array = array(); |
|
| 163 | - $side_array['tags'] = $this->get_tag_cloud(); |
|
| 164 | - $side_array['comments'] = $this->get_comments(); |
|
| 165 | - return $side_array; |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - final private function get_tag_cloud() |
|
| 169 | - { |
|
| 157 | + return $body; |
|
| 158 | + } |
|
| 159 | + |
|
| 160 | + final protected function get_right_side() |
|
| 161 | + { |
|
| 162 | + $side_array = array(); |
|
| 163 | + $side_array['tags'] = $this->get_tag_cloud(); |
|
| 164 | + $side_array['comments'] = $this->get_comments(); |
|
| 165 | + return $side_array; |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + final private function get_tag_cloud() |
|
| 169 | + { |
|
| 170 | 170 | global $container; |
| 171 | 171 | $repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']); |
| 172 | 172 | $tag_result = $repository->getTagCloud(); |
| 173 | 173 | |
| 174 | - $maximum_tag_count = $this->get_maximum_tag_count($tag_result); |
|
| 174 | + $maximum_tag_count = $this->get_maximum_tag_count($tag_result); |
|
| 175 | 175 | |
| 176 | - $cloud_array = array(); |
|
| 177 | - foreach($tag_result as $tag) |
|
| 178 | - { |
|
| 179 | - if($tag['count'] < self::$MINIMUM_TAG_COUNT) |
|
| 180 | - continue; |
|
| 176 | + $cloud_array = array(); |
|
| 177 | + foreach($tag_result as $tag) |
|
| 178 | + { |
|
| 179 | + if($tag['count'] < self::$MINIMUM_TAG_COUNT) |
|
| 180 | + continue; |
|
| 181 | 181 | |
| 182 | - $tag_object = new stdclass(); |
|
| 183 | - $tag_object->name = $tag['tag']; |
|
| 184 | - $tag_object->link = Content::instance('URLSafe', "/tag/{$tag['tag']}/")->activate(); |
|
| 185 | - $tag_object->scalar = floor(($tag['count'] - 1) * (9 / ($maximum_tag_count - self::$MINIMUM_TAG_COUNT))); |
|
| 186 | - $cloud_array[] = $tag_object; |
|
| 187 | - } |
|
| 182 | + $tag_object = new stdclass(); |
|
| 183 | + $tag_object->name = $tag['tag']; |
|
| 184 | + $tag_object->link = Content::instance('URLSafe', "/tag/{$tag['tag']}/")->activate(); |
|
| 185 | + $tag_object->scalar = floor(($tag['count'] - 1) * (9 / ($maximum_tag_count - self::$MINIMUM_TAG_COUNT))); |
|
| 186 | + $cloud_array[] = $tag_object; |
|
| 187 | + } |
|
| 188 | 188 | |
| 189 | - return $cloud_array; |
|
| 190 | - } |
|
| 189 | + return $cloud_array; |
|
| 190 | + } |
|
| 191 | 191 | |
| 192 | - final private function get_maximum_tag_count($tag_result) |
|
| 193 | - { |
|
| 194 | - $maximum = 1; |
|
| 192 | + final private function get_maximum_tag_count($tag_result) |
|
| 193 | + { |
|
| 194 | + $maximum = 1; |
|
| 195 | 195 | |
| 196 | - foreach($tag_result as $tag) |
|
| 197 | - { |
|
| 198 | - if($tag['count'] > $maximum) |
|
| 199 | - $maximum = $tag['count']; |
|
| 200 | - } |
|
| 201 | - return $maximum; |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - final private function get_comments() |
|
| 205 | - { |
|
| 206 | - $comment_array = CommentCollector::getRecentBlogComments(self::$RECENT_COMMENT_COUNT); |
|
| 196 | + foreach($tag_result as $tag) |
|
| 197 | + { |
|
| 198 | + if($tag['count'] > $maximum) |
|
| 199 | + $maximum = $tag['count']; |
|
| 200 | + } |
|
| 201 | + return $maximum; |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + final private function get_comments() |
|
| 205 | + { |
|
| 206 | + $comment_array = CommentCollector::getRecentBlogComments(self::$RECENT_COMMENT_COUNT); |
|
| 207 | 207 | |
| 208 | - $array = array(); |
|
| 209 | - foreach($comment_array as $comment) |
|
| 210 | - { |
|
| 211 | - $body = $comment->body; |
|
| 212 | - $body = strip_tags($body); |
|
| 208 | + $array = array(); |
|
| 209 | + foreach($comment_array as $comment) |
|
| 210 | + { |
|
| 211 | + $body = $comment->body; |
|
| 212 | + $body = strip_tags($body); |
|
| 213 | 213 | |
| 214 | - $comment_obj = new stdclass(); |
|
| 215 | - $comment_obj->description = Content::instance('SmartTrim', $body)->activate(30); |
|
| 216 | - $comment_obj->commenter = $comment->name; |
|
| 217 | - $comment_obj->link = Loader::getRootURL() . "{$comment->category}/{$comment->path}/#comment-{$comment->id}"; |
|
| 218 | - $array[] = $comment_obj; |
|
| 219 | - } |
|
| 214 | + $comment_obj = new stdclass(); |
|
| 215 | + $comment_obj->description = Content::instance('SmartTrim', $body)->activate(30); |
|
| 216 | + $comment_obj->commenter = $comment->name; |
|
| 217 | + $comment_obj->link = Loader::getRootURL() . "{$comment->category}/{$comment->path}/#comment-{$comment->id}"; |
|
| 218 | + $array[] = $comment_obj; |
|
| 219 | + } |
|
| 220 | 220 | |
| 221 | 221 | $comment_service_array = $this->get_comments_from_service(); |
| 222 | 222 | if ($comment_service_array !== null && $comment_service_array !== $array) { |
| 223 | - global $container; |
|
| 224 | - $container['console']->log('Mismatch between comment service and legacy db'); |
|
| 225 | - $container['console']->log($comment_service_array[0]); |
|
| 226 | - $container['console']->log($array[0]); |
|
| 223 | + global $container; |
|
| 224 | + $container['console']->log('Mismatch between comment service and legacy db'); |
|
| 225 | + $container['console']->log($comment_service_array[0]); |
|
| 226 | + $container['console']->log($array[0]); |
|
| 227 | + } |
|
| 228 | + return $array; |
|
| 227 | 229 | } |
| 228 | - return $array; |
|
| 229 | - } |
|
| 230 | 230 | |
| 231 | 231 | final private function get_comments_from_service() |
| 232 | 232 | { |
@@ -5,8 +5,8 @@ discard block |
||
| 5 | 5 | Loader::load('controller', '/PageController'); |
| 6 | 6 | Loader::load('utility', 'Content'); |
| 7 | 7 | |
| 8 | -abstract class DefaultPageController extends PageController |
|
| 9 | -{ |
|
| 8 | +abstract class DefaultPageController extends PageController |
|
| 9 | +{
|
|
| 10 | 10 | |
| 11 | 11 | private static $RECENT_COMMENT_COUNT = 10; |
| 12 | 12 | private static $MINIMUM_TAG_COUNT = 10; |
@@ -16,8 +16,7 @@ discard block |
||
| 16 | 16 | |
| 17 | 17 | private static $INTRODUCTION_IMAGE_PATTERN = '<img src="/photo/%s/%s-size-%s.jpg" height="%d" width="%d" alt="%s" />'; |
| 18 | 18 | |
| 19 | - protected function set_head_data() |
|
| 20 | - { |
|
| 19 | + protected function set_head_data() {
|
|
| 21 | 20 | $this->set_head('rss_link', [ |
| 22 | 21 | 'title' => 'Jacob Emerick Blog Feed', |
| 23 | 22 | 'url' => '/rss.xml' |
@@ -31,18 +30,17 @@ discard block |
||
| 31 | 30 | $this->add_css('blog'); |
| 32 | 31 | } |
| 33 | 32 | |
| 34 | - protected function get_introduction() |
|
| 35 | - { |
|
| 33 | + protected function get_introduction() {
|
|
| 36 | 34 | return; |
| 37 | 35 | } |
| 38 | 36 | |
| 39 | - protected function get_introduction_image($id) |
|
| 40 | - { |
|
| 37 | + protected function get_introduction_image($id) {
|
|
| 41 | 38 | Loader::load('collector', 'image/PhotoCollector'); |
| 42 | 39 | $photo_result = PhotoCollector::getRow($id); |
| 43 | 40 | |
| 44 | - if($photo_result == null) |
|
| 45 | - return; |
|
| 41 | + if($photo_result == null) {
|
|
| 42 | + return; |
|
| 43 | + } |
|
| 46 | 44 | |
| 47 | 45 | $name = $photo_result->name; |
| 48 | 46 | $category = $photo_result->category; |
@@ -54,8 +52,7 @@ discard block |
||
| 54 | 52 | return sprintf(self::$INTRODUCTION_IMAGE_PATTERN, $category, $name, $size, $height, $width, $description); |
| 55 | 53 | } |
| 56 | 54 | |
| 57 | - protected function set_body_data() |
|
| 58 | - { |
|
| 55 | + protected function set_body_data() {
|
|
| 59 | 56 | $this->set_body('introduction', $this->get_introduction()); |
| 60 | 57 | $this->set_body('right_side', $this->get_right_side()); |
| 61 | 58 | $this->set_body('activity_array', $this->get_recent_activity()); |
@@ -63,8 +60,7 @@ discard block |
||
| 63 | 60 | $this->set_body_view('Page'); |
| 64 | 61 | } |
| 65 | 62 | |
| 66 | - final protected function format_post($post, $trim = false) |
|
| 67 | - { |
|
| 63 | + final protected function format_post($post, $trim = false) {
|
|
| 68 | 64 | $post_object = new stdclass(); |
| 69 | 65 | |
| 70 | 66 | $post_object->title = $post['title']; |
@@ -80,8 +76,7 @@ discard block |
||
| 80 | 76 | return $post_object; |
| 81 | 77 | } |
| 82 | 78 | |
| 83 | - final private function get_comments_for_post($post) |
|
| 84 | - { |
|
| 79 | + final private function get_comments_for_post($post) {
|
|
| 85 | 80 | $count = CommentCollector::getCommentCountForURL(self::$BLOG_SITE_ID, $post['path']); |
| 86 | 81 | $count_from_service = $this->get_comments_for_post_from_service($post); |
| 87 | 82 | |
@@ -93,8 +88,7 @@ discard block |
||
| 93 | 88 | return $count; |
| 94 | 89 | } |
| 95 | 90 | |
| 96 | - final private function get_comments_for_post_from_service($post) |
|
| 97 | - { |
|
| 91 | + final private function get_comments_for_post_from_service($post) {
|
|
| 98 | 92 | global $config; |
| 99 | 93 | $configuration = new Jacobemerick\CommentService\Configuration(); |
| 100 | 94 | $configuration->setUsername($config->comments->user); |
@@ -127,8 +121,7 @@ discard block |
||
| 127 | 121 | return count($comment_response); |
| 128 | 122 | } |
| 129 | 123 | |
| 130 | - final private function get_tags_for_post($post) |
|
| 131 | - { |
|
| 124 | + final private function get_tags_for_post($post) {
|
|
| 132 | 125 | global $container; |
| 133 | 126 | $repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']); |
| 134 | 127 | $tag_result = $repository->getTagsForPost($post['id']); |
@@ -144,12 +137,12 @@ discard block |
||
| 144 | 137 | return $tag_array; |
| 145 | 138 | } |
| 146 | 139 | |
| 147 | - final private function get_body_for_post($post, $trim) |
|
| 148 | - { |
|
| 140 | + final private function get_body_for_post($post, $trim) {
|
|
| 149 | 141 | $body = $post['body']; |
| 150 | 142 | |
| 151 | - if($trim) |
|
| 152 | - $body = Content::instance('SmartTrim', $body)->activate(self::$LENGTH_OF_TRIMMED_POST); |
|
| 143 | + if($trim) {
|
|
| 144 | + $body = Content::instance('SmartTrim', $body)->activate(self::$LENGTH_OF_TRIMMED_POST);
|
|
| 145 | + } |
|
| 153 | 146 | |
| 154 | 147 | $body = Content::instance('FixPhoto', $body)->activate(false, 'standard'); |
| 155 | 148 | $body = Content::instance('MarkupCode', $body)->activate(); |
@@ -157,16 +150,14 @@ discard block |
||
| 157 | 150 | return $body; |
| 158 | 151 | } |
| 159 | 152 | |
| 160 | - final protected function get_right_side() |
|
| 161 | - { |
|
| 153 | + final protected function get_right_side() {
|
|
| 162 | 154 | $side_array = array(); |
| 163 | 155 | $side_array['tags'] = $this->get_tag_cloud(); |
| 164 | 156 | $side_array['comments'] = $this->get_comments(); |
| 165 | 157 | return $side_array; |
| 166 | 158 | } |
| 167 | 159 | |
| 168 | - final private function get_tag_cloud() |
|
| 169 | - { |
|
| 160 | + final private function get_tag_cloud() {
|
|
| 170 | 161 | global $container; |
| 171 | 162 | $repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']); |
| 172 | 163 | $tag_result = $repository->getTagCloud(); |
@@ -176,8 +167,9 @@ discard block |
||
| 176 | 167 | $cloud_array = array(); |
| 177 | 168 | foreach($tag_result as $tag) |
| 178 | 169 | { |
| 179 | - if($tag['count'] < self::$MINIMUM_TAG_COUNT) |
|
| 180 | - continue; |
|
| 170 | + if($tag['count'] < self::$MINIMUM_TAG_COUNT) {
|
|
| 171 | + continue; |
|
| 172 | + } |
|
| 181 | 173 | |
| 182 | 174 | $tag_object = new stdclass(); |
| 183 | 175 | $tag_object->name = $tag['tag']; |
@@ -189,20 +181,19 @@ discard block |
||
| 189 | 181 | return $cloud_array; |
| 190 | 182 | } |
| 191 | 183 | |
| 192 | - final private function get_maximum_tag_count($tag_result) |
|
| 193 | - { |
|
| 184 | + final private function get_maximum_tag_count($tag_result) {
|
|
| 194 | 185 | $maximum = 1; |
| 195 | 186 | |
| 196 | 187 | foreach($tag_result as $tag) |
| 197 | 188 | { |
| 198 | - if($tag['count'] > $maximum) |
|
| 199 | - $maximum = $tag['count']; |
|
| 189 | + if($tag['count'] > $maximum) {
|
|
| 190 | + $maximum = $tag['count']; |
|
| 191 | + } |
|
| 200 | 192 | } |
| 201 | 193 | return $maximum; |
| 202 | 194 | } |
| 203 | 195 | |
| 204 | - final private function get_comments() |
|
| 205 | - { |
|
| 196 | + final private function get_comments() {
|
|
| 206 | 197 | $comment_array = CommentCollector::getRecentBlogComments(self::$RECENT_COMMENT_COUNT); |
| 207 | 198 | |
| 208 | 199 | $array = array(); |
@@ -228,8 +219,7 @@ discard block |
||
| 228 | 219 | return $array; |
| 229 | 220 | } |
| 230 | 221 | |
| 231 | - final private function get_comments_from_service() |
|
| 232 | - { |
|
| 222 | + final private function get_comments_from_service() {
|
|
| 233 | 223 | global $config; |
| 234 | 224 | $configuration = new Jacobemerick\CommentService\Configuration(); |
| 235 | 225 | $configuration->setUsername($config->comments->user); |
@@ -204,6 +204,9 @@ discard block |
||
| 204 | 204 | exit; |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | + /** |
|
| 208 | + * @param string $method |
|
| 209 | + */ |
|
| 207 | 210 | protected function set_header_method($method) |
| 208 | 211 | {
|
| 209 | 212 | $this->headers = $method; |
@@ -214,6 +217,9 @@ discard block |
||
| 214 | 217 | $this->set_head('title', $value);
|
| 215 | 218 | } |
| 216 | 219 | |
| 220 | + /** |
|
| 221 | + * @param string $value |
|
| 222 | + */ |
|
| 217 | 223 | protected function set_author($value) |
| 218 | 224 | {
|
| 219 | 225 | $this->set_head('author', $value);
|
@@ -229,26 +235,41 @@ discard block |
||
| 229 | 235 | $this->set_head('keywords', implode(', ', $array));
|
| 230 | 236 | } |
| 231 | 237 | |
| 238 | + /** |
|
| 239 | + * @param string $url |
|
| 240 | + */ |
|
| 232 | 241 | protected function set_canonical($url) |
| 233 | 242 | {
|
| 234 | 243 | $this->set_head('canonical', $url);
|
| 235 | 244 | } |
| 236 | 245 | |
| 246 | + /** |
|
| 247 | + * @param string $set |
|
| 248 | + */ |
|
| 237 | 249 | protected function set_head($set, $value) |
| 238 | 250 | {
|
| 239 | 251 | $this->data_array['head'][$set] = $value; |
| 240 | 252 | } |
| 241 | 253 | |
| 254 | + /** |
|
| 255 | + * @param string $set |
|
| 256 | + */ |
|
| 242 | 257 | protected function set_body($set, $value) |
| 243 | 258 | {
|
| 244 | 259 | $this->data_array['body'][$set] = $value; |
| 245 | 260 | } |
| 246 | 261 | |
| 262 | + /** |
|
| 263 | + * @param string $file |
|
| 264 | + */ |
|
| 247 | 265 | protected function add_css($file) |
| 248 | 266 | {
|
| 249 | 267 | $this->css_array[] = $file; |
| 250 | 268 | } |
| 251 | 269 | |
| 270 | + /** |
|
| 271 | + * @param string $file |
|
| 272 | + */ |
|
| 252 | 273 | protected function add_js($file) |
| 253 | 274 | {
|
| 254 | 275 | $this->js_array[] = $file; |
@@ -271,6 +292,9 @@ discard block |
||
| 271 | 292 | $this->set_head('js_link_array', $js_array);
|
| 272 | 293 | } |
| 273 | 294 | |
| 295 | + /** |
|
| 296 | + * @param string $view |
|
| 297 | + */ |
|
| 274 | 298 | protected function set_body_view($view) |
| 275 | 299 | {
|
| 276 | 300 | $this->body_view_array[] = $view; |
@@ -315,6 +339,10 @@ discard block |
||
| 315 | 339 | } |
| 316 | 340 | |
| 317 | 341 | private $comment_errors; |
| 342 | + |
|
| 343 | + /** |
|
| 344 | + * @param string $redirect_url |
|
| 345 | + */ |
|
| 318 | 346 | protected function handle_comment_submit($site_id, $path, $redirect_url, $page_title) |
| 319 | 347 | {
|
| 320 | 348 | if(Request::hasPost() && Request::getPost('submit') == 'Submit Comment')
|
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | $post_result = $activityRepository->getActivities(5); |
| 65 | 65 | |
| 66 | 66 | $post_array = array(); |
| 67 | - foreach($post_result as $row) { |
|
| 67 | + foreach ($post_result as $row) { |
|
| 68 | 68 | array_push($post_array, $this->expand_post($row)); |
| 69 | 69 | } |
| 70 | 70 | |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | ]; |
| 81 | 81 | |
| 82 | 82 | if ($format != 'short') { |
| 83 | - $post['url'] = Loader::getRootUrl('lifestream') . "{$raw_post['type']}/{$raw_post['id']}/"; |
|
| 83 | + $post['url'] = Loader::getRootUrl('lifestream')."{$raw_post['type']}/{$raw_post['id']}/"; |
|
| 84 | 84 | |
| 85 | 85 | $metadata = json_decode($raw_post['metadata'], true); |
| 86 | 86 | $post = array_merge($post, $metadata); |
@@ -100,12 +100,12 @@ discard block |
||
| 100 | 100 | $headers = $this->headers; |
| 101 | 101 | Header::$headers(); |
| 102 | 102 | Loader::load('view', '/Head', $this->data_array['head']); |
| 103 | - foreach($this->body_view_array as $view) |
|
| 103 | + foreach ($this->body_view_array as $view) |
|
| 104 | 104 | { |
| 105 | - if(substr($view, 0, 1) == '/') |
|
| 105 | + if (substr($view, 0, 1) == '/') |
|
| 106 | 106 | Loader::load('view', $view, $this->data_array['body']); |
| 107 | 107 | else |
| 108 | - Loader::load('view', URLDecode::getSite() . '/' . $view, $this->data_array['body']); |
|
| 108 | + Loader::load('view', URLDecode::getSite().'/'.$view, $this->data_array['body']); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | if (URLDecode::getSite() == 'waterfalls') { |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | Loader::load('view', '/Foot', array('tracking_code' => self::$TRACKING_CODE)); |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - if($view == '/404' || $view == '/503') |
|
| 117 | + if ($view == '/404' || $view == '/503') |
|
| 118 | 118 | exit; |
| 119 | 119 | } |
| 120 | 120 | |
@@ -170,14 +170,14 @@ discard block |
||
| 170 | 170 | |
| 171 | 171 | private function load_assets() |
| 172 | 172 | { |
| 173 | - $css_array = array_map(function ($stylesheet) { |
|
| 173 | + $css_array = array_map(function($stylesheet) { |
|
| 174 | 174 | $path = "/css/{$stylesheet[0]}.css"; |
| 175 | 175 | if ($stylesheet[1] > 1) { |
| 176 | 176 | $path .= "?v={$stylesheet[1]}"; |
| 177 | 177 | } |
| 178 | 178 | return $path; |
| 179 | 179 | }, $this->css_array); |
| 180 | - $js_array = array_map(function ($script) { |
|
| 180 | + $js_array = array_map(function($script) { |
|
| 181 | 181 | if (substr($script, 0, 4) == 'http') { |
| 182 | 182 | return $script; |
| 183 | 183 | } |
@@ -195,26 +195,26 @@ discard block |
||
| 195 | 195 | |
| 196 | 196 | protected function eject() |
| 197 | 197 | { |
| 198 | - if(get_class($this) !== 'Error404Controller') |
|
| 198 | + if (get_class($this) !== 'Error404Controller') |
|
| 199 | 199 | Loader::loadNew('controller', '/Error404Controller')->activate(); |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | protected function unavailable() |
| 203 | 203 | { |
| 204 | - if(get_class($this) !== 'Error503Controller') |
|
| 204 | + if (get_class($this) !== 'Error503Controller') |
|
| 205 | 205 | Loader::loadNew('controller', '/Error503Controller')->activate(); |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | protected function redirect($uri, $method = 301) |
| 209 | 209 | { |
| 210 | - switch($method) |
|
| 210 | + switch ($method) |
|
| 211 | 211 | { |
| 212 | 212 | case 301 : |
| 213 | - if(get_class($this) !== 'Error301Controller') |
|
| 213 | + if (get_class($this) !== 'Error301Controller') |
|
| 214 | 214 | Loader::loadNew('controller', '/Error301Controller', array($uri))->activate(); |
| 215 | 215 | break; |
| 216 | 216 | case 303 : |
| 217 | - if(get_class($this) !== 'Error303Controller') |
|
| 217 | + if (get_class($this) !== 'Error303Controller') |
|
| 218 | 218 | Loader::loadNew('controller', '/Error303Controller', array($uri))->activate(); |
| 219 | 219 | break; |
| 220 | 220 | } |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | private $comment_errors; |
| 235 | 235 | protected function handle_comment_submit($site_id, $path, $redirect_url, $page_title) |
| 236 | 236 | { |
| 237 | - if(Request::hasPost() && Request::getPost('submit') == 'Submit Comment') |
|
| 237 | + if (Request::hasPost() && Request::getPost('submit') == 'Submit Comment') |
|
| 238 | 238 | { |
| 239 | 239 | $parameters = array($site_id, $path, $redirect_url, $page_title); |
| 240 | 240 | $this->comment_errors = Loader::loadNew('module', 'form/CommentSubmitModule', $parameters)->activate(); |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | $comment_array = array(); |
| 253 | 253 | $comment_result = CommentCollector::getCommentsForURL($site, $path, $commenter->id); |
| 254 | 254 | |
| 255 | - foreach($comment_result as $comment) |
|
| 255 | + foreach ($comment_result as $comment) |
|
| 256 | 256 | { |
| 257 | 257 | $comment_object = new stdclass(); |
| 258 | 258 | $comment_object->id = $comment->id; |
@@ -262,12 +262,12 @@ discard block |
||
| 262 | 262 | $comment_object->url = $comment->url; |
| 263 | 263 | $comment_object->trusted = $comment->trusted; |
| 264 | 264 | |
| 265 | - if($comment->reply == 0 && Request::getPost('type') == $comment->id) |
|
| 265 | + if ($comment->reply == 0 && Request::getPost('type') == $comment->id) |
|
| 266 | 266 | $comment_object->errors = $this->comment_errors; |
| 267 | 267 | else |
| 268 | 268 | $comment_object->errors = array(); |
| 269 | 269 | |
| 270 | - if($comment->reply == 0) |
|
| 270 | + if ($comment->reply == 0) |
|
| 271 | 271 | { |
| 272 | 272 | $comment_object->replies = array(); |
| 273 | 273 | $comment_array[$comment->id] = $comment_object; |
@@ -302,15 +302,15 @@ discard block |
||
| 302 | 302 | |
| 303 | 303 | $commenter_cookie_value = json_decode($_COOKIE['commenter']); |
| 304 | 304 | |
| 305 | - if($commenter_cookie_value === NULL) |
|
| 305 | + if ($commenter_cookie_value === NULL) |
|
| 306 | 306 | return $commenter; |
| 307 | 307 | |
| 308 | - if(!isset($commenter_cookie_value->name) || !isset($commenter_cookie_value->email)) |
|
| 308 | + if (!isset($commenter_cookie_value->name) || !isset($commenter_cookie_value->email)) |
|
| 309 | 309 | return $commenter; |
| 310 | 310 | |
| 311 | 311 | $commenter_object = CommentCollector::getCommenterByFields($commenter_cookie_value->name, $commenter_cookie_value->email, (isset($commenter_cookie_value->website) ? $commenter_cookie_value->website : '')); |
| 312 | 312 | |
| 313 | - if($commenter_object === NULL) |
|
| 313 | + if ($commenter_object === NULL) |
|
| 314 | 314 | return $commenter; |
| 315 | 315 | |
| 316 | 316 | $commenter->id = $commenter_object->id; |
@@ -5,52 +5,52 @@ discard block |
||
| 5 | 5 | abstract class PageController |
| 6 | 6 | { |
| 7 | 7 | |
| 8 | - private static $TRACKING_CODE = 'UA-11745070-1'; |
|
| 8 | + private static $TRACKING_CODE = 'UA-11745070-1'; |
|
| 9 | 9 | |
| 10 | - protected static $DEPRECATED_BLOGS = array( |
|
| 11 | - 10 => 63, |
|
| 12 | - 55 => 67, |
|
| 13 | - ); |
|
| 14 | - |
|
| 15 | - private $headers; |
|
| 16 | - private $css_array = array(); |
|
| 17 | - private $font_css_array = array(); |
|
| 18 | - private $js_array = array(); |
|
| 19 | - |
|
| 20 | - private $data_array = array(); |
|
| 21 | - private $body_view_array = array(); |
|
| 22 | - |
|
| 23 | - protected function set_head_data() {} |
|
| 24 | - protected function set_body_data() {} |
|
| 25 | - protected function set_data() {} |
|
| 26 | - |
|
| 27 | - public function __construct() |
|
| 28 | - { |
|
| 29 | - $this->set_header_method('sendHTML'); |
|
| 10 | + protected static $DEPRECATED_BLOGS = array( |
|
| 11 | + 10 => 63, |
|
| 12 | + 55 => 67, |
|
| 13 | + ); |
|
| 14 | + |
|
| 15 | + private $headers; |
|
| 16 | + private $css_array = array(); |
|
| 17 | + private $font_css_array = array(); |
|
| 18 | + private $js_array = array(); |
|
| 19 | + |
|
| 20 | + private $data_array = array(); |
|
| 21 | + private $body_view_array = array(); |
|
| 22 | + |
|
| 23 | + protected function set_head_data() {} |
|
| 24 | + protected function set_body_data() {} |
|
| 25 | + protected function set_data() {} |
|
| 26 | + |
|
| 27 | + public function __construct() |
|
| 28 | + { |
|
| 29 | + $this->set_header_method('sendHTML'); |
|
| 30 | 30 | |
| 31 | - $this->set_head('google_verification', 'sgAISiuoWfK54KXnOfm2oU4vQdad8eyNCQX7LkZ1OxM'); |
|
| 32 | - $this->set_head('bing_verification', 'AF1A4CEA30A7589590E9294C4B512607'); |
|
| 31 | + $this->set_head('google_verification', 'sgAISiuoWfK54KXnOfm2oU4vQdad8eyNCQX7LkZ1OxM'); |
|
| 32 | + $this->set_head('bing_verification', 'AF1A4CEA30A7589590E9294C4B512607'); |
|
| 33 | 33 | |
| 34 | - $this->set_body('domain_container', $this->get_domain_container()); |
|
| 35 | - $this->set_body('footer', array( |
|
| 36 | - 'link' => Loader::getRootUrl('site'), |
|
| 37 | - 'anchor' => 'jacobemerick.com', |
|
| 38 | - 'date' => date('Y'))); |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - protected function get_domain_container() |
|
| 42 | - { |
|
| 43 | - $domain_container = new stdclass(); |
|
| 34 | + $this->set_body('domain_container', $this->get_domain_container()); |
|
| 35 | + $this->set_body('footer', array( |
|
| 36 | + 'link' => Loader::getRootUrl('site'), |
|
| 37 | + 'anchor' => 'jacobemerick.com', |
|
| 38 | + 'date' => date('Y'))); |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + protected function get_domain_container() |
|
| 42 | + { |
|
| 43 | + $domain_container = new stdclass(); |
|
| 44 | 44 | |
| 45 | - $domain_container->blog = Loader::getRootUrl('blog'); |
|
| 46 | - $domain_container->home = Loader::getRootUrl('home'); |
|
| 47 | - $domain_container->lifestream = Loader::getRootUrl('lifestream'); |
|
| 48 | - $domain_container->map = Loader::getRootUrl('map'); |
|
| 49 | - $domain_container->portfolio = Loader::getRootUrl('portfolio'); |
|
| 50 | - $domain_container->waterfalls = Loader::getRootUrl('waterfalls'); |
|
| 45 | + $domain_container->blog = Loader::getRootUrl('blog'); |
|
| 46 | + $domain_container->home = Loader::getRootUrl('home'); |
|
| 47 | + $domain_container->lifestream = Loader::getRootUrl('lifestream'); |
|
| 48 | + $domain_container->map = Loader::getRootUrl('map'); |
|
| 49 | + $domain_container->portfolio = Loader::getRootUrl('portfolio'); |
|
| 50 | + $domain_container->waterfalls = Loader::getRootUrl('waterfalls'); |
|
| 51 | 51 | |
| 52 | - return $domain_container; |
|
| 53 | - } |
|
| 52 | + return $domain_container; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | 55 | protected function get_recent_activity() |
| 56 | 56 | { |
@@ -84,24 +84,24 @@ discard block |
||
| 84 | 84 | return (object) $post; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - public function activate() |
|
| 88 | - { |
|
| 89 | - $this->set_head_data(); |
|
| 90 | - $this->set_body_data(); |
|
| 91 | - $this->set_data(); |
|
| 87 | + public function activate() |
|
| 88 | + { |
|
| 89 | + $this->set_head_data(); |
|
| 90 | + $this->set_body_data(); |
|
| 91 | + $this->set_data(); |
|
| 92 | 92 | |
| 93 | - $this->load_assets(); |
|
| 93 | + $this->load_assets(); |
|
| 94 | 94 | |
| 95 | - $headers = $this->headers; |
|
| 96 | - Header::$headers(); |
|
| 97 | - Loader::load('view', '/Head', $this->data_array['head']); |
|
| 98 | - foreach($this->body_view_array as $view) |
|
| 99 | - { |
|
| 100 | - if(substr($view, 0, 1) == '/') |
|
| 101 | - Loader::load('view', $view, $this->data_array['body']); |
|
| 102 | - else |
|
| 103 | - Loader::load('view', URLDecode::getSite() . '/' . $view, $this->data_array['body']); |
|
| 104 | - } |
|
| 95 | + $headers = $this->headers; |
|
| 96 | + Header::$headers(); |
|
| 97 | + Loader::load('view', '/Head', $this->data_array['head']); |
|
| 98 | + foreach($this->body_view_array as $view) |
|
| 99 | + { |
|
| 100 | + if(substr($view, 0, 1) == '/') |
|
| 101 | + Loader::load('view', $view, $this->data_array['body']); |
|
| 102 | + else |
|
| 103 | + Loader::load('view', URLDecode::getSite() . '/' . $view, $this->data_array['body']); |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | 106 | if (URLDecode::getSite() == 'waterfalls') { |
| 107 | 107 | Loader::load('view', '/WaterfallFoot'); |
@@ -109,211 +109,211 @@ discard block |
||
| 109 | 109 | Loader::load('view', '/Foot', array('tracking_code' => self::$TRACKING_CODE)); |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - if($view == '/404' || $view == '/503') |
|
| 113 | - exit; |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - protected function set_header_method($method) |
|
| 117 | - { |
|
| 118 | - $this->headers = $method; |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - protected function set_title($value) |
|
| 122 | - { |
|
| 123 | - $this->set_head('title', $value); |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - protected function set_author($value) |
|
| 127 | - { |
|
| 128 | - $this->set_head('author', $value); |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - protected function set_description($value) |
|
| 132 | - { |
|
| 133 | - $this->set_head('description', $value); |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - protected function set_keywords($array) |
|
| 137 | - { |
|
| 138 | - $this->set_head('keywords', implode(', ', $array)); |
|
| 139 | - } |
|
| 112 | + if($view == '/404' || $view == '/503') |
|
| 113 | + exit; |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + protected function set_header_method($method) |
|
| 117 | + { |
|
| 118 | + $this->headers = $method; |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + protected function set_title($value) |
|
| 122 | + { |
|
| 123 | + $this->set_head('title', $value); |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + protected function set_author($value) |
|
| 127 | + { |
|
| 128 | + $this->set_head('author', $value); |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + protected function set_description($value) |
|
| 132 | + { |
|
| 133 | + $this->set_head('description', $value); |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + protected function set_keywords($array) |
|
| 137 | + { |
|
| 138 | + $this->set_head('keywords', implode(', ', $array)); |
|
| 139 | + } |
|
| 140 | 140 | |
| 141 | - protected function set_canonical($url) |
|
| 142 | - { |
|
| 143 | - $this->set_head('canonical', $url); |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - protected function set_head($set, $value) |
|
| 147 | - { |
|
| 148 | - $this->data_array['head'][$set] = $value; |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - protected function set_body($set, $value) |
|
| 152 | - { |
|
| 153 | - $this->data_array['body'][$set] = $value; |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - protected function add_css($file, $version = 1) |
|
| 157 | - { |
|
| 158 | - $this->css_array[] = [$file, $version]; |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - protected function add_js($file) |
|
| 162 | - { |
|
| 163 | - $this->js_array[] = $file; |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - private function load_assets() |
|
| 167 | - { |
|
| 141 | + protected function set_canonical($url) |
|
| 142 | + { |
|
| 143 | + $this->set_head('canonical', $url); |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + protected function set_head($set, $value) |
|
| 147 | + { |
|
| 148 | + $this->data_array['head'][$set] = $value; |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + protected function set_body($set, $value) |
|
| 152 | + { |
|
| 153 | + $this->data_array['body'][$set] = $value; |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + protected function add_css($file, $version = 1) |
|
| 157 | + { |
|
| 158 | + $this->css_array[] = [$file, $version]; |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + protected function add_js($file) |
|
| 162 | + { |
|
| 163 | + $this->js_array[] = $file; |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + private function load_assets() |
|
| 167 | + { |
|
| 168 | 168 | $css_array = array_map(function ($stylesheet) { |
| 169 | - $path = "/css/{$stylesheet[0]}.css"; |
|
| 170 | - if ($stylesheet[1] > 1) { |
|
| 169 | + $path = "/css/{$stylesheet[0]}.css"; |
|
| 170 | + if ($stylesheet[1] > 1) { |
|
| 171 | 171 | $path .= "?v={$stylesheet[1]}"; |
| 172 | - } |
|
| 173 | - return $path; |
|
| 172 | + } |
|
| 173 | + return $path; |
|
| 174 | 174 | }, $this->css_array); |
| 175 | 175 | $js_array = array_map(function ($script) { |
| 176 | - if (substr($script, 0, 4) == 'http') { |
|
| 176 | + if (substr($script, 0, 4) == 'http') { |
|
| 177 | 177 | return $script; |
| 178 | - } |
|
| 179 | - return "/js/{$script}.min.js"; |
|
| 178 | + } |
|
| 179 | + return "/js/{$script}.min.js"; |
|
| 180 | 180 | }, $this->js_array); |
| 181 | 181 | |
| 182 | - $this->set_head('css_link_array', $css_array); |
|
| 183 | - $this->set_head('js_link_array', $js_array); |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - protected function set_body_view($view) |
|
| 187 | - { |
|
| 188 | - $this->body_view_array[] = $view; |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - protected function eject() |
|
| 192 | - { |
|
| 193 | - if(get_class($this) !== 'Error404Controller') |
|
| 194 | - Loader::loadNew('controller', '/Error404Controller')->activate(); |
|
| 195 | - } |
|
| 196 | - |
|
| 197 | - protected function unavailable() |
|
| 198 | - { |
|
| 199 | - if(get_class($this) !== 'Error503Controller') |
|
| 200 | - Loader::loadNew('controller', '/Error503Controller')->activate(); |
|
| 201 | - } |
|
| 202 | - |
|
| 203 | - protected function redirect($uri, $method = 301) |
|
| 204 | - { |
|
| 205 | - switch($method) |
|
| 206 | - { |
|
| 207 | - case 301 : |
|
| 208 | - if(get_class($this) !== 'Error301Controller') |
|
| 209 | - Loader::loadNew('controller', '/Error301Controller', array($uri))->activate(); |
|
| 210 | - break; |
|
| 211 | - case 303 : |
|
| 212 | - if(get_class($this) !== 'Error303Controller') |
|
| 213 | - Loader::loadNew('controller', '/Error303Controller', array($uri))->activate(); |
|
| 214 | - break; |
|
| 215 | - } |
|
| 216 | - } |
|
| 217 | - |
|
| 218 | - final protected function get_parsed_date($date) |
|
| 219 | - { |
|
| 220 | - $parsed_date = new stdclass(); |
|
| 182 | + $this->set_head('css_link_array', $css_array); |
|
| 183 | + $this->set_head('js_link_array', $js_array); |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + protected function set_body_view($view) |
|
| 187 | + { |
|
| 188 | + $this->body_view_array[] = $view; |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + protected function eject() |
|
| 192 | + { |
|
| 193 | + if(get_class($this) !== 'Error404Controller') |
|
| 194 | + Loader::loadNew('controller', '/Error404Controller')->activate(); |
|
| 195 | + } |
|
| 196 | + |
|
| 197 | + protected function unavailable() |
|
| 198 | + { |
|
| 199 | + if(get_class($this) !== 'Error503Controller') |
|
| 200 | + Loader::loadNew('controller', '/Error503Controller')->activate(); |
|
| 201 | + } |
|
| 202 | + |
|
| 203 | + protected function redirect($uri, $method = 301) |
|
| 204 | + { |
|
| 205 | + switch($method) |
|
| 206 | + { |
|
| 207 | + case 301 : |
|
| 208 | + if(get_class($this) !== 'Error301Controller') |
|
| 209 | + Loader::loadNew('controller', '/Error301Controller', array($uri))->activate(); |
|
| 210 | + break; |
|
| 211 | + case 303 : |
|
| 212 | + if(get_class($this) !== 'Error303Controller') |
|
| 213 | + Loader::loadNew('controller', '/Error303Controller', array($uri))->activate(); |
|
| 214 | + break; |
|
| 215 | + } |
|
| 216 | + } |
|
| 217 | + |
|
| 218 | + final protected function get_parsed_date($date) |
|
| 219 | + { |
|
| 220 | + $parsed_date = new stdclass(); |
|
| 221 | 221 | |
| 222 | - $parsed_date->stamp = date('c', strtotime($date)); |
|
| 223 | - $parsed_date->friendly = date('F j, Y', strtotime($date)); |
|
| 224 | - $parsed_date->elapsed = Content::instance('ElapsedTime', $date)->activate(); |
|
| 222 | + $parsed_date->stamp = date('c', strtotime($date)); |
|
| 223 | + $parsed_date->friendly = date('F j, Y', strtotime($date)); |
|
| 224 | + $parsed_date->elapsed = Content::instance('ElapsedTime', $date)->activate(); |
|
| 225 | 225 | |
| 226 | - return $parsed_date; |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - private $comment_errors; |
|
| 230 | - protected function handle_comment_submit($site_id, $path, $redirect_url, $page_title) |
|
| 231 | - { |
|
| 232 | - if(Request::hasPost() && Request::getPost('submit') == 'Submit Comment') |
|
| 233 | - { |
|
| 234 | - $parameters = array($site_id, $path, $redirect_url, $page_title); |
|
| 235 | - $this->comment_errors = Loader::loadNew('module', 'form/CommentSubmitModule', $parameters)->activate(); |
|
| 236 | - } |
|
| 226 | + return $parsed_date; |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + private $comment_errors; |
|
| 230 | + protected function handle_comment_submit($site_id, $path, $redirect_url, $page_title) |
|
| 231 | + { |
|
| 232 | + if(Request::hasPost() && Request::getPost('submit') == 'Submit Comment') |
|
| 233 | + { |
|
| 234 | + $parameters = array($site_id, $path, $redirect_url, $page_title); |
|
| 235 | + $this->comment_errors = Loader::loadNew('module', 'form/CommentSubmitModule', $parameters)->activate(); |
|
| 236 | + } |
|
| 237 | 237 | |
| 238 | - return; |
|
| 239 | - } |
|
| 238 | + return; |
|
| 239 | + } |
|
| 240 | 240 | |
| 241 | - protected function get_comment_array($site, $path) |
|
| 242 | - { |
|
| 243 | - Loader::load('collector', 'comment/CommentCollector'); |
|
| 241 | + protected function get_comment_array($site, $path) |
|
| 242 | + { |
|
| 243 | + Loader::load('collector', 'comment/CommentCollector'); |
|
| 244 | 244 | |
| 245 | - $commenter = $this->get_commenter(); |
|
| 245 | + $commenter = $this->get_commenter(); |
|
| 246 | 246 | |
| 247 | - $comment_array = array(); |
|
| 248 | - $comment_result = CommentCollector::getCommentsForURL($site, $path, $commenter->id); |
|
| 247 | + $comment_array = array(); |
|
| 248 | + $comment_result = CommentCollector::getCommentsForURL($site, $path, $commenter->id); |
|
| 249 | 249 | |
| 250 | - foreach($comment_result as $comment) |
|
| 251 | - { |
|
| 252 | - $comment_object = new stdclass(); |
|
| 253 | - $comment_object->id = $comment->id; |
|
| 254 | - $comment_object->body = $comment->body_format; |
|
| 255 | - $comment_object->date = date("M j, 'y", strtotime($comment->date)); |
|
| 256 | - $comment_object->name = $comment->name; |
|
| 257 | - $comment_object->url = $comment->url; |
|
| 258 | - $comment_object->trusted = $comment->trusted; |
|
| 250 | + foreach($comment_result as $comment) |
|
| 251 | + { |
|
| 252 | + $comment_object = new stdclass(); |
|
| 253 | + $comment_object->id = $comment->id; |
|
| 254 | + $comment_object->body = $comment->body_format; |
|
| 255 | + $comment_object->date = date("M j, 'y", strtotime($comment->date)); |
|
| 256 | + $comment_object->name = $comment->name; |
|
| 257 | + $comment_object->url = $comment->url; |
|
| 258 | + $comment_object->trusted = $comment->trusted; |
|
| 259 | 259 | |
| 260 | - if($comment->reply == 0 && Request::getPost('type') == $comment->id) |
|
| 261 | - $comment_object->errors = $this->comment_errors; |
|
| 262 | - else |
|
| 263 | - $comment_object->errors = array(); |
|
| 260 | + if($comment->reply == 0 && Request::getPost('type') == $comment->id) |
|
| 261 | + $comment_object->errors = $this->comment_errors; |
|
| 262 | + else |
|
| 263 | + $comment_object->errors = array(); |
|
| 264 | 264 | |
| 265 | - if($comment->reply == 0) |
|
| 266 | - { |
|
| 267 | - $comment_object->replies = array(); |
|
| 268 | - $comment_array[$comment->id] = $comment_object; |
|
| 269 | - } |
|
| 270 | - else |
|
| 271 | - $comment_array[$comment->reply]->replies[$comment->id] = $comment_object; |
|
| 272 | - } |
|
| 265 | + if($comment->reply == 0) |
|
| 266 | + { |
|
| 267 | + $comment_object->replies = array(); |
|
| 268 | + $comment_array[$comment->id] = $comment_object; |
|
| 269 | + } |
|
| 270 | + else |
|
| 271 | + $comment_array[$comment->reply]->replies[$comment->id] = $comment_object; |
|
| 272 | + } |
|
| 273 | 273 | |
| 274 | - $comment_count = CommentCollector::getCommentCountForURL($site, $path); |
|
| 274 | + $comment_count = CommentCollector::getCommentCountForURL($site, $path); |
|
| 275 | 275 | |
| 276 | - return array( |
|
| 277 | - 'comments' => $comment_array, |
|
| 278 | - 'commenter' => $commenter, |
|
| 279 | - 'errors' => $this->comment_errors, |
|
| 280 | - 'comment_count' => $comment_count); |
|
| 281 | - } |
|
| 276 | + return array( |
|
| 277 | + 'comments' => $comment_array, |
|
| 278 | + 'commenter' => $commenter, |
|
| 279 | + 'errors' => $this->comment_errors, |
|
| 280 | + 'comment_count' => $comment_count); |
|
| 281 | + } |
|
| 282 | 282 | |
| 283 | - private function get_commenter() |
|
| 284 | - { |
|
| 285 | - Loader::load('collector', 'comment/CommentCollector'); |
|
| 283 | + private function get_commenter() |
|
| 284 | + { |
|
| 285 | + Loader::load('collector', 'comment/CommentCollector'); |
|
| 286 | 286 | |
| 287 | - $commenter = new stdclass(); |
|
| 287 | + $commenter = new stdclass(); |
|
| 288 | 288 | |
| 289 | - $commenter->id = 0; |
|
| 290 | - $commenter->name = ''; |
|
| 291 | - $commenter->email = ''; |
|
| 292 | - $commenter->website = ''; |
|
| 289 | + $commenter->id = 0; |
|
| 290 | + $commenter->name = ''; |
|
| 291 | + $commenter->email = ''; |
|
| 292 | + $commenter->website = ''; |
|
| 293 | 293 | |
| 294 | 294 | if (!isset($_COOKIE['commenter'])) { |
| 295 | - return $commenter; |
|
| 295 | + return $commenter; |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | - $commenter_cookie_value = json_decode($_COOKIE['commenter']); |
|
| 298 | + $commenter_cookie_value = json_decode($_COOKIE['commenter']); |
|
| 299 | 299 | |
| 300 | - if($commenter_cookie_value === NULL) |
|
| 301 | - return $commenter; |
|
| 300 | + if($commenter_cookie_value === NULL) |
|
| 301 | + return $commenter; |
|
| 302 | 302 | |
| 303 | - if(!isset($commenter_cookie_value->name) || !isset($commenter_cookie_value->email)) |
|
| 304 | - return $commenter; |
|
| 303 | + if(!isset($commenter_cookie_value->name) || !isset($commenter_cookie_value->email)) |
|
| 304 | + return $commenter; |
|
| 305 | 305 | |
| 306 | - $commenter_object = CommentCollector::getCommenterByFields($commenter_cookie_value->name, $commenter_cookie_value->email, (isset($commenter_cookie_value->website) ? $commenter_cookie_value->website : '')); |
|
| 306 | + $commenter_object = CommentCollector::getCommenterByFields($commenter_cookie_value->name, $commenter_cookie_value->email, (isset($commenter_cookie_value->website) ? $commenter_cookie_value->website : '')); |
|
| 307 | 307 | |
| 308 | - if($commenter_object === NULL) |
|
| 309 | - return $commenter; |
|
| 308 | + if($commenter_object === NULL) |
|
| 309 | + return $commenter; |
|
| 310 | 310 | |
| 311 | - $commenter->id = $commenter_object->id; |
|
| 312 | - $commenter->name = $commenter_object->name; |
|
| 313 | - $commenter->email = $commenter_object->email; |
|
| 314 | - $commenter->website = $commenter_object->url; |
|
| 311 | + $commenter->id = $commenter_object->id; |
|
| 312 | + $commenter->name = $commenter_object->name; |
|
| 313 | + $commenter->email = $commenter_object->email; |
|
| 314 | + $commenter->website = $commenter_object->url; |
|
| 315 | 315 | |
| 316 | - return $commenter; |
|
| 317 | - } |
|
| 316 | + return $commenter; |
|
| 317 | + } |
|
| 318 | 318 | |
| 319 | 319 | } |
@@ -2,8 +2,8 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | Loader::load('utility', 'Header'); |
| 4 | 4 | |
| 5 | -abstract class PageController |
|
| 6 | -{ |
|
| 5 | +abstract class PageController |
|
| 6 | +{
|
|
| 7 | 7 | |
| 8 | 8 | private static $TRACKING_CODE = 'UA-11745070-1'; |
| 9 | 9 | |
@@ -24,8 +24,7 @@ discard block |
||
| 24 | 24 | protected function set_body_data() {} |
| 25 | 25 | protected function set_data() {} |
| 26 | 26 | |
| 27 | - public function __construct() |
|
| 28 | - { |
|
| 27 | + public function __construct() {
|
|
| 29 | 28 | $this->set_header_method('sendHTML'); |
| 30 | 29 | |
| 31 | 30 | $this->set_head('google_verification', 'sgAISiuoWfK54KXnOfm2oU4vQdad8eyNCQX7LkZ1OxM'); |
@@ -38,8 +37,7 @@ discard block |
||
| 38 | 37 | 'date' => date('Y'))); |
| 39 | 38 | } |
| 40 | 39 | |
| 41 | - protected function get_domain_container() |
|
| 42 | - { |
|
| 40 | + protected function get_domain_container() {
|
|
| 43 | 41 | $domain_container = new stdclass(); |
| 44 | 42 | |
| 45 | 43 | $domain_container->blog = Loader::getRootUrl('blog'); |
@@ -52,8 +50,7 @@ discard block |
||
| 52 | 50 | return $domain_container; |
| 53 | 51 | } |
| 54 | 52 | |
| 55 | - protected function get_recent_activity() |
|
| 56 | - { |
|
| 53 | + protected function get_recent_activity() {
|
|
| 57 | 54 | global $container; |
| 58 | 55 | $activityRepository = new Jacobemerick\Web\Domain\Stream\Activity\MysqlActivityRepository($container['db_connection_locator']); |
| 59 | 56 | $post_result = $activityRepository->getActivities(5); |
@@ -66,8 +63,7 @@ discard block |
||
| 66 | 63 | return $post_array; |
| 67 | 64 | } |
| 68 | 65 | |
| 69 | - protected function expand_post($raw_post, $format = 'short') |
|
| 70 | - { |
|
| 66 | + protected function expand_post($raw_post, $format = 'short') {
|
|
| 71 | 67 | $post = [ |
| 72 | 68 | 'type' => $raw_post['type'], |
| 73 | 69 | 'title' => ($format == 'short') ? $raw_post['message'] : $raw_post['message_long'], |
@@ -84,8 +80,7 @@ discard block |
||
| 84 | 80 | return (object) $post; |
| 85 | 81 | } |
| 86 | 82 | |
| 87 | - public function activate() |
|
| 88 | - { |
|
| 83 | + public function activate() {
|
|
| 89 | 84 | $this->set_head_data(); |
| 90 | 85 | $this->set_body_data(); |
| 91 | 86 | $this->set_data(); |
@@ -97,10 +92,11 @@ discard block |
||
| 97 | 92 | Loader::load('view', '/Head', $this->data_array['head']); |
| 98 | 93 | foreach($this->body_view_array as $view) |
| 99 | 94 | { |
| 100 | - if(substr($view, 0, 1) == '/') |
|
| 101 | - Loader::load('view', $view, $this->data_array['body']); |
|
| 102 | - else |
|
| 103 | - Loader::load('view', URLDecode::getSite() . '/' . $view, $this->data_array['body']); |
|
| 95 | + if(substr($view, 0, 1) == '/') {
|
|
| 96 | + Loader::load('view', $view, $this->data_array['body']);
|
|
| 97 | + } else {
|
|
| 98 | + Loader::load('view', URLDecode::getSite() . '/' . $view, $this->data_array['body']);
|
|
| 99 | + } |
|
| 104 | 100 | } |
| 105 | 101 | |
| 106 | 102 | if (URLDecode::getSite() == 'waterfalls') { |
@@ -109,62 +105,52 @@ discard block |
||
| 109 | 105 | Loader::load('view', '/Foot', array('tracking_code' => self::$TRACKING_CODE)); |
| 110 | 106 | } |
| 111 | 107 | |
| 112 | - if($view == '/404' || $view == '/503') |
|
| 113 | - exit; |
|
| 108 | + if($view == '/404' || $view == '/503') {
|
|
| 109 | + exit; |
|
| 110 | + } |
|
| 114 | 111 | } |
| 115 | 112 | |
| 116 | - protected function set_header_method($method) |
|
| 117 | - { |
|
| 113 | + protected function set_header_method($method) {
|
|
| 118 | 114 | $this->headers = $method; |
| 119 | 115 | } |
| 120 | 116 | |
| 121 | - protected function set_title($value) |
|
| 122 | - { |
|
| 117 | + protected function set_title($value) {
|
|
| 123 | 118 | $this->set_head('title', $value); |
| 124 | 119 | } |
| 125 | 120 | |
| 126 | - protected function set_author($value) |
|
| 127 | - { |
|
| 121 | + protected function set_author($value) {
|
|
| 128 | 122 | $this->set_head('author', $value); |
| 129 | 123 | } |
| 130 | 124 | |
| 131 | - protected function set_description($value) |
|
| 132 | - { |
|
| 125 | + protected function set_description($value) {
|
|
| 133 | 126 | $this->set_head('description', $value); |
| 134 | 127 | } |
| 135 | 128 | |
| 136 | - protected function set_keywords($array) |
|
| 137 | - { |
|
| 129 | + protected function set_keywords($array) {
|
|
| 138 | 130 | $this->set_head('keywords', implode(', ', $array)); |
| 139 | 131 | } |
| 140 | 132 | |
| 141 | - protected function set_canonical($url) |
|
| 142 | - { |
|
| 133 | + protected function set_canonical($url) {
|
|
| 143 | 134 | $this->set_head('canonical', $url); |
| 144 | 135 | } |
| 145 | 136 | |
| 146 | - protected function set_head($set, $value) |
|
| 147 | - { |
|
| 137 | + protected function set_head($set, $value) {
|
|
| 148 | 138 | $this->data_array['head'][$set] = $value; |
| 149 | 139 | } |
| 150 | 140 | |
| 151 | - protected function set_body($set, $value) |
|
| 152 | - { |
|
| 141 | + protected function set_body($set, $value) {
|
|
| 153 | 142 | $this->data_array['body'][$set] = $value; |
| 154 | 143 | } |
| 155 | 144 | |
| 156 | - protected function add_css($file, $version = 1) |
|
| 157 | - { |
|
| 145 | + protected function add_css($file, $version = 1) {
|
|
| 158 | 146 | $this->css_array[] = [$file, $version]; |
| 159 | 147 | } |
| 160 | 148 | |
| 161 | - protected function add_js($file) |
|
| 162 | - { |
|
| 149 | + protected function add_js($file) {
|
|
| 163 | 150 | $this->js_array[] = $file; |
| 164 | 151 | } |
| 165 | 152 | |
| 166 | - private function load_assets() |
|
| 167 | - { |
|
| 153 | + private function load_assets() {
|
|
| 168 | 154 | $css_array = array_map(function ($stylesheet) { |
| 169 | 155 | $path = "/css/{$stylesheet[0]}.css"; |
| 170 | 156 | if ($stylesheet[1] > 1) { |
@@ -183,40 +169,39 @@ discard block |
||
| 183 | 169 | $this->set_head('js_link_array', $js_array); |
| 184 | 170 | } |
| 185 | 171 | |
| 186 | - protected function set_body_view($view) |
|
| 187 | - { |
|
| 172 | + protected function set_body_view($view) {
|
|
| 188 | 173 | $this->body_view_array[] = $view; |
| 189 | 174 | } |
| 190 | 175 | |
| 191 | - protected function eject() |
|
| 192 | - { |
|
| 193 | - if(get_class($this) !== 'Error404Controller') |
|
| 194 | - Loader::loadNew('controller', '/Error404Controller')->activate(); |
|
| 176 | + protected function eject() {
|
|
| 177 | + if(get_class($this) !== 'Error404Controller') {
|
|
| 178 | + Loader::loadNew('controller', '/Error404Controller')->activate();
|
|
| 179 | + } |
|
| 195 | 180 | } |
| 196 | 181 | |
| 197 | - protected function unavailable() |
|
| 198 | - { |
|
| 199 | - if(get_class($this) !== 'Error503Controller') |
|
| 200 | - Loader::loadNew('controller', '/Error503Controller')->activate(); |
|
| 182 | + protected function unavailable() {
|
|
| 183 | + if(get_class($this) !== 'Error503Controller') {
|
|
| 184 | + Loader::loadNew('controller', '/Error503Controller')->activate();
|
|
| 185 | + } |
|
| 201 | 186 | } |
| 202 | 187 | |
| 203 | - protected function redirect($uri, $method = 301) |
|
| 204 | - { |
|
| 188 | + protected function redirect($uri, $method = 301) {
|
|
| 205 | 189 | switch($method) |
| 206 | 190 | { |
| 207 | 191 | case 301 : |
| 208 | - if(get_class($this) !== 'Error301Controller') |
|
| 209 | - Loader::loadNew('controller', '/Error301Controller', array($uri))->activate(); |
|
| 192 | + if(get_class($this) !== 'Error301Controller') {
|
|
| 193 | + Loader::loadNew('controller', '/Error301Controller', array($uri))->activate();
|
|
| 194 | + } |
|
| 210 | 195 | break; |
| 211 | 196 | case 303 : |
| 212 | - if(get_class($this) !== 'Error303Controller') |
|
| 213 | - Loader::loadNew('controller', '/Error303Controller', array($uri))->activate(); |
|
| 197 | + if(get_class($this) !== 'Error303Controller') {
|
|
| 198 | + Loader::loadNew('controller', '/Error303Controller', array($uri))->activate();
|
|
| 199 | + } |
|
| 214 | 200 | break; |
| 215 | 201 | } |
| 216 | 202 | } |
| 217 | 203 | |
| 218 | - final protected function get_parsed_date($date) |
|
| 219 | - { |
|
| 204 | + final protected function get_parsed_date($date) {
|
|
| 220 | 205 | $parsed_date = new stdclass(); |
| 221 | 206 | |
| 222 | 207 | $parsed_date->stamp = date('c', strtotime($date)); |
@@ -227,8 +212,7 @@ discard block |
||
| 227 | 212 | } |
| 228 | 213 | |
| 229 | 214 | private $comment_errors; |
| 230 | - protected function handle_comment_submit($site_id, $path, $redirect_url, $page_title) |
|
| 231 | - { |
|
| 215 | + protected function handle_comment_submit($site_id, $path, $redirect_url, $page_title) {
|
|
| 232 | 216 | if(Request::hasPost() && Request::getPost('submit') == 'Submit Comment') |
| 233 | 217 | { |
| 234 | 218 | $parameters = array($site_id, $path, $redirect_url, $page_title); |
@@ -238,8 +222,7 @@ discard block |
||
| 238 | 222 | return; |
| 239 | 223 | } |
| 240 | 224 | |
| 241 | - protected function get_comment_array($site, $path) |
|
| 242 | - { |
|
| 225 | + protected function get_comment_array($site, $path) {
|
|
| 243 | 226 | Loader::load('collector', 'comment/CommentCollector'); |
| 244 | 227 | |
| 245 | 228 | $commenter = $this->get_commenter(); |
@@ -257,18 +240,19 @@ discard block |
||
| 257 | 240 | $comment_object->url = $comment->url; |
| 258 | 241 | $comment_object->trusted = $comment->trusted; |
| 259 | 242 | |
| 260 | - if($comment->reply == 0 && Request::getPost('type') == $comment->id) |
|
| 261 | - $comment_object->errors = $this->comment_errors; |
|
| 262 | - else |
|
| 263 | - $comment_object->errors = array(); |
|
| 243 | + if($comment->reply == 0 && Request::getPost('type') == $comment->id) {
|
|
| 244 | + $comment_object->errors = $this->comment_errors; |
|
| 245 | + } else {
|
|
| 246 | + $comment_object->errors = array(); |
|
| 247 | + } |
|
| 264 | 248 | |
| 265 | 249 | if($comment->reply == 0) |
| 266 | 250 | { |
| 267 | 251 | $comment_object->replies = array(); |
| 268 | 252 | $comment_array[$comment->id] = $comment_object; |
| 269 | - } |
|
| 270 | - else |
|
| 271 | - $comment_array[$comment->reply]->replies[$comment->id] = $comment_object; |
|
| 253 | + } else {
|
|
| 254 | + $comment_array[$comment->reply]->replies[$comment->id] = $comment_object; |
|
| 255 | + } |
|
| 272 | 256 | } |
| 273 | 257 | |
| 274 | 258 | $comment_count = CommentCollector::getCommentCountForURL($site, $path); |
@@ -280,8 +264,7 @@ discard block |
||
| 280 | 264 | 'comment_count' => $comment_count); |
| 281 | 265 | } |
| 282 | 266 | |
| 283 | - private function get_commenter() |
|
| 284 | - { |
|
| 267 | + private function get_commenter() {
|
|
| 285 | 268 | Loader::load('collector', 'comment/CommentCollector'); |
| 286 | 269 | |
| 287 | 270 | $commenter = new stdclass(); |
@@ -297,16 +280,19 @@ discard block |
||
| 297 | 280 | |
| 298 | 281 | $commenter_cookie_value = json_decode($_COOKIE['commenter']); |
| 299 | 282 | |
| 300 | - if($commenter_cookie_value === NULL) |
|
| 301 | - return $commenter; |
|
| 283 | + if($commenter_cookie_value === NULL) {
|
|
| 284 | + return $commenter; |
|
| 285 | + } |
|
| 302 | 286 | |
| 303 | - if(!isset($commenter_cookie_value->name) || !isset($commenter_cookie_value->email)) |
|
| 304 | - return $commenter; |
|
| 287 | + if(!isset($commenter_cookie_value->name) || !isset($commenter_cookie_value->email)) {
|
|
| 288 | + return $commenter; |
|
| 289 | + } |
|
| 305 | 290 | |
| 306 | 291 | $commenter_object = CommentCollector::getCommenterByFields($commenter_cookie_value->name, $commenter_cookie_value->email, (isset($commenter_cookie_value->website) ? $commenter_cookie_value->website : '')); |
| 307 | 292 | |
| 308 | - if($commenter_object === NULL) |
|
| 309 | - return $commenter; |
|
| 293 | + if($commenter_object === NULL) {
|
|
| 294 | + return $commenter; |
|
| 295 | + } |
|
| 310 | 296 | |
| 311 | 297 | $commenter->id = $commenter_object->id; |
| 312 | 298 | $commenter->name = $commenter_object->name; |
@@ -25,6 +25,9 @@ discard block |
||
| 25 | 25 | return; |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | + /** |
|
| 29 | + * @param string $content |
|
| 30 | + */ |
|
| 28 | 31 | private function wrap_in_list($content) |
| 29 | 32 | {
|
| 30 | 33 | $content_array = explode("\n", $content);
|
@@ -44,6 +47,9 @@ discard block |
||
| 44 | 47 | return $content; |
| 45 | 48 | } |
| 46 | 49 | |
| 50 | + /** |
|
| 51 | + * @param string $type |
|
| 52 | + */ |
|
| 47 | 53 | private function highlight_code($content, $type) |
| 48 | 54 | {
|
| 49 | 55 | switch($type) |
@@ -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; |
@@ -5,53 +5,53 @@ |
||
| 5 | 5 | final class MarkupCodeContent extends Content |
| 6 | 6 | { |
| 7 | 7 | |
| 8 | - private static $MARKUP_DELIMITER = '@<pre( rel="(.*?)")?>(.*?)</pre>@s'; |
|
| 8 | + private static $MARKUP_DELIMITER = '@<pre( rel="(.*?)")?>(.*?)</pre>@s'; |
|
| 9 | 9 | |
| 10 | - protected function execute($title = '') |
|
| 11 | - { |
|
| 12 | - preg_match_all(self::$MARKUP_DELIMITER, $this->content, $matches); |
|
| 13 | - if(count($matches[1]) == 0) |
|
| 14 | - return; |
|
| 10 | + protected function execute($title = '') |
|
| 11 | + { |
|
| 12 | + preg_match_all(self::$MARKUP_DELIMITER, $this->content, $matches); |
|
| 13 | + if(count($matches[1]) == 0) |
|
| 14 | + return; |
|
| 15 | 15 | |
| 16 | - foreach($matches[3] as $key => $match) |
|
| 17 | - { |
|
| 18 | - $replacement = $match; |
|
| 19 | - $replacement = $this->wrap_in_list($replacement); |
|
| 20 | - $replacement = $this->highlight_code($replacement, $matches[2][$key]); |
|
| 16 | + foreach($matches[3] as $key => $match) |
|
| 17 | + { |
|
| 18 | + $replacement = $match; |
|
| 19 | + $replacement = $this->wrap_in_list($replacement); |
|
| 20 | + $replacement = $this->highlight_code($replacement, $matches[2][$key]); |
|
| 21 | 21 | |
| 22 | - $this->content = str_replace($match, $replacement, $this->content); |
|
| 23 | - } |
|
| 22 | + $this->content = str_replace($match, $replacement, $this->content); |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - return; |
|
| 26 | - } |
|
| 25 | + return; |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - private function wrap_in_list($content) |
|
| 29 | - { |
|
| 30 | - $content_array = explode("\n", $content); |
|
| 28 | + private function wrap_in_list($content) |
|
| 29 | + { |
|
| 30 | + $content_array = explode("\n", $content); |
|
| 31 | 31 | |
| 32 | - foreach($content_array as $key => $row) |
|
| 33 | - { |
|
| 34 | - $new_row = ($key % 2 == 0) ? '<li class="even">' : '<li class="odd">'; |
|
| 35 | - $new_row .= '<p>'; |
|
| 36 | - $new_row .= $row; |
|
| 37 | - $new_row .= '</p>'; |
|
| 38 | - $new_row .= '</li>'; |
|
| 39 | - $content_array[$key] = $new_row; |
|
| 40 | - } |
|
| 32 | + foreach($content_array as $key => $row) |
|
| 33 | + { |
|
| 34 | + $new_row = ($key % 2 == 0) ? '<li class="even">' : '<li class="odd">'; |
|
| 35 | + $new_row .= '<p>'; |
|
| 36 | + $new_row .= $row; |
|
| 37 | + $new_row .= '</p>'; |
|
| 38 | + $new_row .= '</li>'; |
|
| 39 | + $content_array[$key] = $new_row; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - $content = implode($content_array); |
|
| 43 | - $content = "<ol>{$content}</ol>"; |
|
| 44 | - return $content; |
|
| 45 | - } |
|
| 42 | + $content = implode($content_array); |
|
| 43 | + $content = "<ol>{$content}</ol>"; |
|
| 44 | + return $content; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - private function highlight_code($content, $type) |
|
| 48 | - { |
|
| 49 | - switch($type) |
|
| 50 | - { |
|
| 51 | - default : |
|
| 52 | - return $content; |
|
| 53 | - break; |
|
| 54 | - } |
|
| 55 | - } |
|
| 47 | + private function highlight_code($content, $type) |
|
| 48 | + { |
|
| 49 | + switch($type) |
|
| 50 | + { |
|
| 51 | + default : |
|
| 52 | + return $content; |
|
| 53 | + break; |
|
| 54 | + } |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | 57 | } |
| 58 | 58 | \ No newline at end of file |
@@ -2,16 +2,16 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | Loader::load('utility', 'Content'); |
| 4 | 4 | |
| 5 | -final class MarkupCodeContent extends Content |
|
| 6 | -{ |
|
| 5 | +final class MarkupCodeContent extends Content |
|
| 6 | +{
|
|
| 7 | 7 | |
| 8 | 8 | private static $MARKUP_DELIMITER = '@<pre( rel="(.*?)")?>(.*?)</pre>@s'; |
| 9 | 9 | |
| 10 | - protected function execute($title = '') |
|
| 11 | - { |
|
| 10 | + protected function execute($title = '') {
|
|
| 12 | 11 | preg_match_all(self::$MARKUP_DELIMITER, $this->content, $matches); |
| 13 | - if(count($matches[1]) == 0) |
|
| 14 | - return; |
|
| 12 | + if(count($matches[1]) == 0) {
|
|
| 13 | + return; |
|
| 14 | + } |
|
| 15 | 15 | |
| 16 | 16 | foreach($matches[3] as $key => $match) |
| 17 | 17 | { |
@@ -25,8 +25,7 @@ discard block |
||
| 25 | 25 | return; |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | - private function wrap_in_list($content) |
|
| 29 | - { |
|
| 28 | + private function wrap_in_list($content) {
|
|
| 30 | 29 | $content_array = explode("\n", $content); |
| 31 | 30 | |
| 32 | 31 | foreach($content_array as $key => $row) |
@@ -44,8 +43,7 @@ discard block |
||
| 44 | 43 | return $content; |
| 45 | 44 | } |
| 46 | 45 | |
| 47 | - private function highlight_code($content, $type) |
|
| 48 | - { |
|
| 46 | + private function highlight_code($content, $type) {
|
|
| 49 | 47 | switch($type) |
| 50 | 48 | { |
| 51 | 49 | default : |
@@ -62,6 +62,9 @@ |
||
| 62 | 62 | $this->is_trimmed = true; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | + /** |
|
| 66 | + * @param string $content |
|
| 67 | + */ |
|
| 65 | 68 | private function trim_html_string($content, $length) |
| 66 | 69 | {
|
| 67 | 70 | $content = preg_replace(self::$PHOTO_PLACEHOLDER_MATCH, '', $content); |
@@ -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 | - $content = substr($content, 0, $match[1]) . $match[0] . substr($content, $match[1]); |
|
| 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 | } |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | |
| 142 | 142 | private function get_tags_preg($tag_array) |
| 143 | 143 | { |
| 144 | - return '@</?(' . implode('|', $tag_array) . ')@'; |
|
| 144 | + return '@</?('.implode('|', $tag_array).')@'; |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | } |
@@ -5,143 +5,143 @@ |
||
| 5 | 5 | class SmartTrimContent extends Content |
| 6 | 6 | { |
| 7 | 7 | |
| 8 | - private static $EXCLUDE_TAGS = array( |
|
| 9 | - 'a', |
|
| 10 | - 'div', |
|
| 11 | - 'h4', |
|
| 12 | - 'pre'); |
|
| 13 | - private static $INCLUDE_TAGS = array( |
|
| 14 | - 'li', |
|
| 15 | - 'ol', |
|
| 16 | - 'p', |
|
| 17 | - 'ul'); |
|
| 18 | - private static $PHOTO_PLACEHOLDER_MATCH = '/{{photo="(.*)"}}/'; |
|
| 19 | - private static $HTML_TAG_PATTERN = '/<[^>]+>/'; |
|
| 20 | - private static $CUT_MARKER = '/*/ CUT HERE /*/'; |
|
| 21 | - private static $RIGHT_BRACKET = '>'; |
|
| 22 | - private static $LEFT_BRACKET = '<'; |
|
| 23 | - private static $ETC = '…'; |
|
| 8 | + private static $EXCLUDE_TAGS = array( |
|
| 9 | + 'a', |
|
| 10 | + 'div', |
|
| 11 | + 'h4', |
|
| 12 | + 'pre'); |
|
| 13 | + private static $INCLUDE_TAGS = array( |
|
| 14 | + 'li', |
|
| 15 | + 'ol', |
|
| 16 | + 'p', |
|
| 17 | + 'ul'); |
|
| 18 | + private static $PHOTO_PLACEHOLDER_MATCH = '/{{photo="(.*)"}}/'; |
|
| 19 | + private static $HTML_TAG_PATTERN = '/<[^>]+>/'; |
|
| 20 | + private static $CUT_MARKER = '/*/ CUT HERE /*/'; |
|
| 21 | + private static $RIGHT_BRACKET = '>'; |
|
| 22 | + private static $LEFT_BRACKET = '<'; |
|
| 23 | + private static $ETC = '…'; |
|
| 24 | 24 | |
| 25 | - private $is_trimmed; |
|
| 25 | + private $is_trimmed; |
|
| 26 | 26 | |
| 27 | - protected function execute() |
|
| 28 | - { |
|
| 29 | - $args = func_get_args(); |
|
| 30 | - if(count($args) < 1) |
|
| 31 | - { |
|
| 32 | - trigger_error('Someone called SmartTrimContent w/o defining a length... bad!'); |
|
| 33 | - return; |
|
| 34 | - } |
|
| 27 | + protected function execute() |
|
| 28 | + { |
|
| 29 | + $args = func_get_args(); |
|
| 30 | + if(count($args) < 1) |
|
| 31 | + { |
|
| 32 | + trigger_error('Someone called SmartTrimContent w/o defining a length... bad!'); |
|
| 33 | + return; |
|
| 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 | - $length = $args[0]; |
|
| 41 | + $length = $args[0]; |
|
| 42 | 42 | |
| 43 | - if($length < strlen($this->content)) |
|
| 44 | - $this->trim_string($length); |
|
| 43 | + if($length < strlen($this->content)) |
|
| 44 | + $this->trim_string($length); |
|
| 45 | 45 | else |
| 46 | 46 | $etc = ''; |
| 47 | - $this->check_exclude_tags(); |
|
| 48 | - $this->close_tags($etc); |
|
| 49 | - } |
|
| 47 | + $this->check_exclude_tags(); |
|
| 48 | + $this->close_tags($etc); |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - private function trim_string($length) |
|
| 52 | - { |
|
| 53 | - $content = $this->trim_html_string($this->content, $length); |
|
| 51 | + private function trim_string($length) |
|
| 52 | + { |
|
| 53 | + $content = $this->trim_html_string($this->content, $length); |
|
| 54 | 54 | |
| 55 | - $last_right_bracket_position = strripos($content, self::$RIGHT_BRACKET); |
|
| 56 | - $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 | - $content = trim($content); |
|
| 55 | + $last_right_bracket_position = strripos($content, self::$RIGHT_BRACKET); |
|
| 56 | + $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 | + $content = trim($content); |
|
| 60 | 60 | |
| 61 | - $this->content = $content; |
|
| 62 | - $this->is_trimmed = true; |
|
| 63 | - } |
|
| 61 | + $this->content = $content; |
|
| 62 | + $this->is_trimmed = true; |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - private function trim_html_string($content, $length) |
|
| 66 | - { |
|
| 67 | - $content = preg_replace(self::$PHOTO_PLACEHOLDER_MATCH, '', $content); |
|
| 68 | - preg_match_all(self::$HTML_TAG_PATTERN, $content, $matches, PREG_OFFSET_CAPTURE); |
|
| 69 | - $content = strip_tags($content); |
|
| 65 | + private function trim_html_string($content, $length) |
|
| 66 | + { |
|
| 67 | + $content = preg_replace(self::$PHOTO_PLACEHOLDER_MATCH, '', $content); |
|
| 68 | + preg_match_all(self::$HTML_TAG_PATTERN, $content, $matches, PREG_OFFSET_CAPTURE); |
|
| 69 | + $content = strip_tags($content); |
|
| 70 | 70 | |
| 71 | - $content = wordwrap($content, $length, self::$CUT_MARKER); |
|
| 72 | - $content = explode(self::$CUT_MARKER, $content); |
|
| 73 | - $content = current($content); |
|
| 71 | + $content = wordwrap($content, $length, self::$CUT_MARKER); |
|
| 72 | + $content = explode(self::$CUT_MARKER, $content); |
|
| 73 | + $content = current($content); |
|
| 74 | 74 | |
| 75 | - $max_length = $length; |
|
| 76 | - foreach($matches[0] as $match) |
|
| 77 | - { |
|
| 78 | - $max_length += strlen($match[0]); |
|
| 79 | - if($max_length <= $match[1]) |
|
| 80 | - break; |
|
| 75 | + $max_length = $length; |
|
| 76 | + foreach($matches[0] as $match) |
|
| 77 | + { |
|
| 78 | + $max_length += strlen($match[0]); |
|
| 79 | + if($max_length <= $match[1]) |
|
| 80 | + break; |
|
| 81 | 81 | |
| 82 | - $content = substr($content, 0, $match[1]) . $match[0] . substr($content, $match[1]); |
|
| 83 | - } |
|
| 82 | + $content = substr($content, 0, $match[1]) . $match[0] . substr($content, $match[1]); |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - if(substr($content, -7) == '</p><p>') |
|
| 86 | - $content = substr($content, 0, -7); |
|
| 85 | + if(substr($content, -7) == '</p><p>') |
|
| 86 | + $content = substr($content, 0, -7); |
|
| 87 | 87 | |
| 88 | - return $content; |
|
| 89 | - } |
|
| 88 | + return $content; |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | - private function check_exclude_tags() |
|
| 92 | - { |
|
| 93 | - $content = $this->content; |
|
| 94 | - $tags_preg = $this->get_tags_preg(self::$EXCLUDE_TAGS); |
|
| 95 | - preg_match_all($tags_preg, $content, $matches, PREG_OFFSET_CAPTURE); |
|
| 91 | + private function check_exclude_tags() |
|
| 92 | + { |
|
| 93 | + $content = $this->content; |
|
| 94 | + $tags_preg = $this->get_tags_preg(self::$EXCLUDE_TAGS); |
|
| 95 | + preg_match_all($tags_preg, $content, $matches, PREG_OFFSET_CAPTURE); |
|
| 96 | 96 | |
| 97 | - if(count($matches[1]) % 2 == 1) |
|
| 98 | - { |
|
| 99 | - $cut_tag = end($matches[1]); |
|
| 100 | - $cut_tag_position = $cut_tag[1] - 1; |
|
| 101 | - $content = substr($content, 0, $cut_tag_position); |
|
| 102 | - } |
|
| 103 | - $content = trim($content); |
|
| 97 | + if(count($matches[1]) % 2 == 1) |
|
| 98 | + { |
|
| 99 | + $cut_tag = end($matches[1]); |
|
| 100 | + $cut_tag_position = $cut_tag[1] - 1; |
|
| 101 | + $content = substr($content, 0, $cut_tag_position); |
|
| 102 | + } |
|
| 103 | + $content = trim($content); |
|
| 104 | 104 | |
| 105 | - $this->content = $content; |
|
| 106 | - } |
|
| 105 | + $this->content = $content; |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | - private function close_tags($etc) |
|
| 109 | - { |
|
| 110 | - $content = $this->content; |
|
| 111 | - $tags_preg = $this->get_tags_preg(self::$INCLUDE_TAGS); |
|
| 112 | - preg_match_all($tags_preg, $content, $matches); |
|
| 113 | - $open_tags = array(); |
|
| 108 | + private function close_tags($etc) |
|
| 109 | + { |
|
| 110 | + $content = $this->content; |
|
| 111 | + $tags_preg = $this->get_tags_preg(self::$INCLUDE_TAGS); |
|
| 112 | + preg_match_all($tags_preg, $content, $matches); |
|
| 113 | + $open_tags = array(); |
|
| 114 | 114 | |
| 115 | - foreach($matches[1] as $tag) |
|
| 116 | - { |
|
| 117 | - if(in_array($tag, $open_tags)) |
|
| 118 | - { |
|
| 119 | - $key = array_search($tag, $open_tags); |
|
| 120 | - unset($open_tags[$key]); |
|
| 121 | - } |
|
| 122 | - else |
|
| 123 | - $open_tags[] = $tag; |
|
| 124 | - } |
|
| 115 | + foreach($matches[1] as $tag) |
|
| 116 | + { |
|
| 117 | + if(in_array($tag, $open_tags)) |
|
| 118 | + { |
|
| 119 | + $key = array_search($tag, $open_tags); |
|
| 120 | + unset($open_tags[$key]); |
|
| 121 | + } |
|
| 122 | + else |
|
| 123 | + $open_tags[] = $tag; |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - $open_tags = array_reverse($open_tags); |
|
| 127 | - if(count($open_tags) > 0) |
|
| 128 | - { |
|
| 129 | - foreach($open_tags as $key => $open_tag) |
|
| 130 | - { |
|
| 131 | - if($key == count($open_tags) - 1) |
|
| 132 | - $content .= $etc; |
|
| 133 | - $content .= "</{$open_tag}>"; |
|
| 134 | - } |
|
| 135 | - } |
|
| 136 | - else |
|
| 137 | - $content .= $etc; |
|
| 126 | + $open_tags = array_reverse($open_tags); |
|
| 127 | + if(count($open_tags) > 0) |
|
| 128 | + { |
|
| 129 | + foreach($open_tags as $key => $open_tag) |
|
| 130 | + { |
|
| 131 | + if($key == count($open_tags) - 1) |
|
| 132 | + $content .= $etc; |
|
| 133 | + $content .= "</{$open_tag}>"; |
|
| 134 | + } |
|
| 135 | + } |
|
| 136 | + else |
|
| 137 | + $content .= $etc; |
|
| 138 | 138 | |
| 139 | - $this->content = $content; |
|
| 140 | - } |
|
| 139 | + $this->content = $content; |
|
| 140 | + } |
|
| 141 | 141 | |
| 142 | - private function get_tags_preg($tag_array) |
|
| 143 | - { |
|
| 144 | - return '@</?(' . implode('|', $tag_array) . ')@'; |
|
| 145 | - } |
|
| 142 | + private function get_tags_preg($tag_array) |
|
| 143 | + { |
|
| 144 | + return '@</?(' . implode('|', $tag_array) . ')@'; |
|
| 145 | + } |
|
| 146 | 146 | |
| 147 | 147 | } |
@@ -2,8 +2,8 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | Loader::load('utility', 'Content'); |
| 4 | 4 | |
| 5 | -class SmartTrimContent extends Content |
|
| 6 | -{ |
|
| 5 | +class SmartTrimContent extends Content |
|
| 6 | +{
|
|
| 7 | 7 | |
| 8 | 8 | private static $EXCLUDE_TAGS = array( |
| 9 | 9 | 'a', |
@@ -24,8 +24,7 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | private $is_trimmed; |
| 26 | 26 | |
| 27 | - protected function execute() |
|
| 28 | - { |
|
| 27 | + protected function execute() {
|
|
| 29 | 28 | $args = func_get_args(); |
| 30 | 29 | if(count($args) < 1) |
| 31 | 30 | { |
@@ -33,37 +32,38 @@ discard block |
||
| 33 | 32 | return; |
| 34 | 33 | } |
| 35 | 34 | |
| 36 | - if(count($args) == 2) |
|
| 37 | - $etc = $args[1]; |
|
| 38 | - else |
|
| 39 | - $etc = self::$ETC; |
|
| 35 | + if(count($args) == 2) {
|
|
| 36 | + $etc = $args[1]; |
|
| 37 | + } else {
|
|
| 38 | + $etc = self::$ETC; |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | 41 | $length = $args[0]; |
| 42 | 42 | |
| 43 | - if($length < strlen($this->content)) |
|
| 44 | - $this->trim_string($length); |
|
| 45 | - else |
|
| 46 | - $etc = ''; |
|
| 43 | + if($length < strlen($this->content)) {
|
|
| 44 | + $this->trim_string($length); |
|
| 45 | + } else {
|
|
| 46 | + $etc = ''; |
|
| 47 | + } |
|
| 47 | 48 | $this->check_exclude_tags(); |
| 48 | 49 | $this->close_tags($etc); |
| 49 | 50 | } |
| 50 | 51 | |
| 51 | - private function trim_string($length) |
|
| 52 | - { |
|
| 52 | + private function trim_string($length) {
|
|
| 53 | 53 | $content = $this->trim_html_string($this->content, $length); |
| 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) |
|
| 58 | - $content = substr($content, 0, $last_left_bracket_position); |
|
| 57 | + if($last_left_bracket_position > $last_right_bracket_position) {
|
|
| 58 | + $content = substr($content, 0, $last_left_bracket_position); |
|
| 59 | + } |
|
| 59 | 60 | $content = trim($content); |
| 60 | 61 | |
| 61 | 62 | $this->content = $content; |
| 62 | 63 | $this->is_trimmed = true; |
| 63 | 64 | } |
| 64 | 65 | |
| 65 | - private function trim_html_string($content, $length) |
|
| 66 | - { |
|
| 66 | + private function trim_html_string($content, $length) {
|
|
| 67 | 67 | $content = preg_replace(self::$PHOTO_PLACEHOLDER_MATCH, '', $content); |
| 68 | 68 | preg_match_all(self::$HTML_TAG_PATTERN, $content, $matches, PREG_OFFSET_CAPTURE); |
| 69 | 69 | $content = strip_tags($content); |
@@ -76,20 +76,21 @@ discard block |
||
| 76 | 76 | foreach($matches[0] as $match) |
| 77 | 77 | { |
| 78 | 78 | $max_length += strlen($match[0]); |
| 79 | - if($max_length <= $match[1]) |
|
| 80 | - break; |
|
| 79 | + if($max_length <= $match[1]) {
|
|
| 80 | + break; |
|
| 81 | + } |
|
| 81 | 82 | |
| 82 | 83 | $content = substr($content, 0, $match[1]) . $match[0] . substr($content, $match[1]); |
| 83 | 84 | } |
| 84 | 85 | |
| 85 | - if(substr($content, -7) == '</p><p>') |
|
| 86 | - $content = substr($content, 0, -7); |
|
| 86 | + if(substr($content, -7) == '</p><p>') {
|
|
| 87 | + $content = substr($content, 0, -7); |
|
| 88 | + } |
|
| 87 | 89 | |
| 88 | 90 | return $content; |
| 89 | 91 | } |
| 90 | 92 | |
| 91 | - private function check_exclude_tags() |
|
| 92 | - { |
|
| 93 | + private function check_exclude_tags() {
|
|
| 93 | 94 | $content = $this->content; |
| 94 | 95 | $tags_preg = $this->get_tags_preg(self::$EXCLUDE_TAGS); |
| 95 | 96 | preg_match_all($tags_preg, $content, $matches, PREG_OFFSET_CAPTURE); |
@@ -105,8 +106,7 @@ discard block |
||
| 105 | 106 | $this->content = $content; |
| 106 | 107 | } |
| 107 | 108 | |
| 108 | - private function close_tags($etc) |
|
| 109 | - { |
|
| 109 | + private function close_tags($etc) {
|
|
| 110 | 110 | $content = $this->content; |
| 111 | 111 | $tags_preg = $this->get_tags_preg(self::$INCLUDE_TAGS); |
| 112 | 112 | preg_match_all($tags_preg, $content, $matches); |
@@ -118,9 +118,9 @@ discard block |
||
| 118 | 118 | { |
| 119 | 119 | $key = array_search($tag, $open_tags); |
| 120 | 120 | unset($open_tags[$key]); |
| 121 | - } |
|
| 122 | - else |
|
| 123 | - $open_tags[] = $tag; |
|
| 121 | + } else {
|
|
| 122 | + $open_tags[] = $tag; |
|
| 123 | + } |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | $open_tags = array_reverse($open_tags); |
@@ -128,19 +128,19 @@ discard block |
||
| 128 | 128 | { |
| 129 | 129 | foreach($open_tags as $key => $open_tag) |
| 130 | 130 | { |
| 131 | - if($key == count($open_tags) - 1) |
|
| 132 | - $content .= $etc; |
|
| 131 | + if($key == count($open_tags) - 1) {
|
|
| 132 | + $content .= $etc; |
|
| 133 | + } |
|
| 133 | 134 | $content .= "</{$open_tag}>"; |
| 134 | 135 | } |
| 135 | - } |
|
| 136 | - else |
|
| 137 | - $content .= $etc; |
|
| 136 | + } else {
|
|
| 137 | + $content .= $etc; |
|
| 138 | + } |
|
| 138 | 139 | |
| 139 | 140 | $this->content = $content; |
| 140 | 141 | } |
| 141 | 142 | |
| 142 | - private function get_tags_preg($tag_array) |
|
| 143 | - { |
|
| 143 | + private function get_tags_preg($tag_array) {
|
|
| 144 | 144 | return '@</?(' . implode('|', $tag_array) . ')@'; |
| 145 | 145 | } |
| 146 | 146 | |
@@ -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 | } |
@@ -3,78 +3,78 @@ |
||
| 3 | 3 | class Request |
| 4 | 4 | { |
| 5 | 5 | |
| 6 | - private static $server = array(); |
|
| 7 | - private static $get = array(); |
|
| 8 | - private static $post = array(); |
|
| 6 | + private static $server = array(); |
|
| 7 | + private static $get = array(); |
|
| 8 | + private static $post = array(); |
|
| 9 | 9 | |
| 10 | - private static $AJAX_REQUEST = 'HTTP_X_REQUESTED_WITH'; |
|
| 10 | + private static $AJAX_REQUEST = 'HTTP_X_REQUESTED_WITH'; |
|
| 11 | 11 | |
| 12 | - static function init() |
|
| 13 | - { |
|
| 14 | - self::make_server(); |
|
| 15 | - self::make_get(); |
|
| 16 | - self::make_post(); |
|
| 17 | - } |
|
| 12 | + static function init() |
|
| 13 | + { |
|
| 14 | + self::make_server(); |
|
| 15 | + self::make_get(); |
|
| 16 | + self::make_post(); |
|
| 17 | + } |
|
| 18 | 18 | |
| 19 | - static function getServer($key = null) |
|
| 20 | - { |
|
| 21 | - if($key) |
|
| 22 | - { |
|
| 23 | - if(isset(self::$server[$key])) |
|
| 24 | - return self::$server[$key]; |
|
| 25 | - return false; |
|
| 26 | - } |
|
| 27 | - return self::$server; |
|
| 28 | - } |
|
| 19 | + static function getServer($key = null) |
|
| 20 | + { |
|
| 21 | + if($key) |
|
| 22 | + { |
|
| 23 | + if(isset(self::$server[$key])) |
|
| 24 | + return self::$server[$key]; |
|
| 25 | + return false; |
|
| 26 | + } |
|
| 27 | + return self::$server; |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - static function isAjax() |
|
| 31 | - { |
|
| 32 | - if(self::getServer(self::$AJAX_REQUEST)) |
|
| 33 | - return true; |
|
| 34 | - return false; |
|
| 35 | - } |
|
| 30 | + static function isAjax() |
|
| 31 | + { |
|
| 32 | + if(self::getServer(self::$AJAX_REQUEST)) |
|
| 33 | + return true; |
|
| 34 | + return false; |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - static function getGet($key = null) |
|
| 38 | - { |
|
| 39 | - if($key) |
|
| 40 | - { |
|
| 41 | - if(isset(self::$get[$key])) |
|
| 42 | - return self::$get[$key]; |
|
| 43 | - return false; |
|
| 44 | - } |
|
| 45 | - return self::$get; |
|
| 46 | - } |
|
| 37 | + static function getGet($key = null) |
|
| 38 | + { |
|
| 39 | + if($key) |
|
| 40 | + { |
|
| 41 | + if(isset(self::$get[$key])) |
|
| 42 | + return self::$get[$key]; |
|
| 43 | + return false; |
|
| 44 | + } |
|
| 45 | + return self::$get; |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - static function getPost($key = null) |
|
| 49 | - { |
|
| 50 | - if($key) |
|
| 51 | - { |
|
| 52 | - if(isset(self::$post[$key])) |
|
| 53 | - return self::$post[$key]; |
|
| 54 | - return false; |
|
| 55 | - } |
|
| 56 | - return self::$post; |
|
| 57 | - } |
|
| 48 | + static function getPost($key = null) |
|
| 49 | + { |
|
| 50 | + if($key) |
|
| 51 | + { |
|
| 52 | + if(isset(self::$post[$key])) |
|
| 53 | + return self::$post[$key]; |
|
| 54 | + return false; |
|
| 55 | + } |
|
| 56 | + return self::$post; |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - public static function hasPost() |
|
| 60 | - { |
|
| 61 | - return is_array(self::$post) && !empty(self::$post); |
|
| 62 | - } |
|
| 59 | + public static function hasPost() |
|
| 60 | + { |
|
| 61 | + return is_array(self::$post) && !empty(self::$post); |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - static function make_server() |
|
| 65 | - { |
|
| 66 | - self::$server = $_SERVER; |
|
| 67 | - } |
|
| 64 | + static function make_server() |
|
| 65 | + { |
|
| 66 | + self::$server = $_SERVER; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - static function make_get() |
|
| 70 | - { |
|
| 71 | - self::$get = $_GET; |
|
| 72 | - } |
|
| 69 | + static function make_get() |
|
| 70 | + { |
|
| 71 | + self::$get = $_GET; |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - static function make_post() |
|
| 75 | - { |
|
| 76 | - self::$post = $_POST; |
|
| 77 | - } |
|
| 74 | + static function make_post() |
|
| 75 | + { |
|
| 76 | + self::$post = $_POST; |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | 79 | } |
| 80 | 80 | |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -class Request |
|
| 4 | -{ |
|
| 3 | +class Request |
|
| 4 | +{
|
|
| 5 | 5 | |
| 6 | 6 | private static $server = array(); |
| 7 | 7 | private static $get = array(); |
@@ -9,70 +9,65 @@ discard block |
||
| 9 | 9 | |
| 10 | 10 | private static $AJAX_REQUEST = 'HTTP_X_REQUESTED_WITH'; |
| 11 | 11 | |
| 12 | - static function init() |
|
| 13 | - { |
|
| 12 | + static function init() {
|
|
| 14 | 13 | self::make_server(); |
| 15 | 14 | self::make_get(); |
| 16 | 15 | self::make_post(); |
| 17 | 16 | } |
| 18 | 17 | |
| 19 | - static function getServer($key = null) |
|
| 20 | - { |
|
| 18 | + static function getServer($key = null) {
|
|
| 21 | 19 | if($key) |
| 22 | 20 | { |
| 23 | - if(isset(self::$server[$key])) |
|
| 24 | - return self::$server[$key]; |
|
| 21 | + if(isset(self::$server[$key])) {
|
|
| 22 | + return self::$server[$key]; |
|
| 23 | + } |
|
| 25 | 24 | return false; |
| 26 | 25 | } |
| 27 | 26 | return self::$server; |
| 28 | 27 | } |
| 29 | 28 | |
| 30 | - static function isAjax() |
|
| 31 | - { |
|
| 32 | - if(self::getServer(self::$AJAX_REQUEST)) |
|
| 33 | - return true; |
|
| 29 | + static function isAjax() {
|
|
| 30 | + if(self::getServer(self::$AJAX_REQUEST)) {
|
|
| 31 | + return true; |
|
| 32 | + } |
|
| 34 | 33 | return false; |
| 35 | 34 | } |
| 36 | 35 | |
| 37 | - static function getGet($key = null) |
|
| 38 | - { |
|
| 36 | + static function getGet($key = null) {
|
|
| 39 | 37 | if($key) |
| 40 | 38 | { |
| 41 | - if(isset(self::$get[$key])) |
|
| 42 | - return self::$get[$key]; |
|
| 39 | + if(isset(self::$get[$key])) {
|
|
| 40 | + return self::$get[$key]; |
|
| 41 | + } |
|
| 43 | 42 | return false; |
| 44 | 43 | } |
| 45 | 44 | return self::$get; |
| 46 | 45 | } |
| 47 | 46 | |
| 48 | - static function getPost($key = null) |
|
| 49 | - { |
|
| 47 | + static function getPost($key = null) {
|
|
| 50 | 48 | if($key) |
| 51 | 49 | { |
| 52 | - if(isset(self::$post[$key])) |
|
| 53 | - return self::$post[$key]; |
|
| 50 | + if(isset(self::$post[$key])) {
|
|
| 51 | + return self::$post[$key]; |
|
| 52 | + } |
|
| 54 | 53 | return false; |
| 55 | 54 | } |
| 56 | 55 | return self::$post; |
| 57 | 56 | } |
| 58 | 57 | |
| 59 | - public static function hasPost() |
|
| 60 | - { |
|
| 58 | + public static function hasPost() {
|
|
| 61 | 59 | return is_array(self::$post) && !empty(self::$post); |
| 62 | 60 | } |
| 63 | 61 | |
| 64 | - static function make_server() |
|
| 65 | - { |
|
| 62 | + static function make_server() {
|
|
| 66 | 63 | self::$server = $_SERVER; |
| 67 | 64 | } |
| 68 | 65 | |
| 69 | - static function make_get() |
|
| 70 | - { |
|
| 66 | + static function make_get() {
|
|
| 71 | 67 | self::$get = $_GET; |
| 72 | 68 | } |
| 73 | 69 | |
| 74 | - static function make_post() |
|
| 75 | - { |
|
| 70 | + static function make_post() {
|
|
| 76 | 71 | self::$post = $_POST; |
| 77 | 72 | } |
| 78 | 73 | |
@@ -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; |
@@ -41,9 +41,9 @@ discard block |
||
| 41 | 41 | $base .= '/'; |
| 42 | 42 | |
| 43 | 43 | self::$array['base'] = $base; |
| 44 | - self::$array['uri'] = '/' . implode('/', $uri_array); |
|
| 44 | + self::$array['uri'] = '/'.implode('/', $uri_array); |
|
| 45 | 45 | |
| 46 | - if(end($uri_array) == '') |
|
| 46 | + if (end($uri_array) == '') |
|
| 47 | 47 | $uri_array = array_slice($uri_array, 0, count($uri_array) - 1); |
| 48 | 48 | self::$array['pieces'] = (array) $uri_array; |
| 49 | 49 | } |
@@ -71,21 +71,21 @@ discard block |
||
| 71 | 71 | static function getExtension() |
| 72 | 72 | { |
| 73 | 73 | $file = self::getPiece(-1); |
| 74 | - if(substr($file, -1) == '/') |
|
| 74 | + if (substr($file, -1) == '/') |
|
| 75 | 75 | return false; |
| 76 | - return substr($file, strrpos($file, '.') + 1);; |
|
| 76 | + return substr($file, strrpos($file, '.') + 1); ; |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | static function getPiece($piece = null) |
| 80 | 80 | { |
| 81 | - if(!$piece) |
|
| 81 | + if (!$piece) |
|
| 82 | 82 | return self::$array['pieces']; |
| 83 | 83 | |
| 84 | - if($piece == -1) |
|
| 84 | + if ($piece == -1) |
|
| 85 | 85 | return end(self::$array['pieces']); |
| 86 | 86 | |
| 87 | 87 | $piece = $piece - 1; |
| 88 | - if(array_key_exists($piece, self::$array['pieces'])) |
|
| 88 | + if (array_key_exists($piece, self::$array['pieces'])) |
|
| 89 | 89 | return self::$array['pieces'][$piece]; |
| 90 | 90 | return; |
| 91 | 91 | } |
@@ -3,35 +3,35 @@ discard block |
||
| 3 | 3 | class URLDecode |
| 4 | 4 | { |
| 5 | 5 | |
| 6 | - private static $array = array(); |
|
| 6 | + private static $array = array(); |
|
| 7 | 7 | |
| 8 | - static function init() |
|
| 9 | - { |
|
| 10 | - $host = $_SERVER['HTTP_HOST']; |
|
| 11 | - $uri = $_SERVER['REQUEST_URI']; |
|
| 12 | - self::form_url_array($host, $uri); |
|
| 13 | - } |
|
| 8 | + static function init() |
|
| 9 | + { |
|
| 10 | + $host = $_SERVER['HTTP_HOST']; |
|
| 11 | + $uri = $_SERVER['REQUEST_URI']; |
|
| 12 | + self::form_url_array($host, $uri); |
|
| 13 | + } |
|
| 14 | 14 | |
| 15 | - static private function form_url_array($host, $uri) |
|
| 16 | - { |
|
| 17 | - $uri = substr($uri, 1); |
|
| 18 | - if(strpos($uri, '?')) |
|
| 19 | - $uri = substr($uri, 0, strpos($uri, '?')); |
|
| 20 | - $uri_array = explode('/', $uri); |
|
| 15 | + static private function form_url_array($host, $uri) |
|
| 16 | + { |
|
| 17 | + $uri = substr($uri, 1); |
|
| 18 | + if(strpos($uri, '?')) |
|
| 19 | + $uri = substr($uri, 0, strpos($uri, '?')); |
|
| 20 | + $uri_array = explode('/', $uri); |
|
| 21 | 21 | |
| 22 | - if(!Loader::isLive()) |
|
| 23 | - $host = substr($host, strpos($host, '.') + 1); |
|
| 22 | + if(!Loader::isLive()) |
|
| 23 | + $host = substr($host, strpos($host, '.') + 1); |
|
| 24 | 24 | |
| 25 | - self::$array['host'] = $host; |
|
| 25 | + self::$array['host'] = $host; |
|
| 26 | 26 | |
| 27 | 27 | if ( |
| 28 | - $host == 'www.waterfallsofthekeweenaw.com' || |
|
| 28 | + $host == 'www.waterfallsofthekeweenaw.com' || |
|
| 29 | 29 | $host == 'waterfallsofthekeweenaw.com' |
| 30 | 30 | ) { |
| 31 | - self::$array['site'] = 'waterfalls'; |
|
| 32 | - } else { |
|
| 33 | - self::$array['site'] = substr($host, 0, strpos($host, '.')); |
|
| 34 | - } |
|
| 31 | + self::$array['site'] = 'waterfalls'; |
|
| 32 | + } else { |
|
| 33 | + self::$array['site'] = substr($host, 0, strpos($host, '.')); |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | 36 | $base = ''; |
| 37 | 37 | $base .= (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http'; |
@@ -40,55 +40,55 @@ discard block |
||
| 40 | 40 | $base .= $host; |
| 41 | 41 | $base .= '/'; |
| 42 | 42 | |
| 43 | - self::$array['base'] = $base; |
|
| 44 | - self::$array['uri'] = '/' . implode('/', $uri_array); |
|
| 43 | + self::$array['base'] = $base; |
|
| 44 | + self::$array['uri'] = '/' . implode('/', $uri_array); |
|
| 45 | 45 | |
| 46 | - if(end($uri_array) == '') |
|
| 47 | - $uri_array = array_slice($uri_array, 0, count($uri_array) - 1); |
|
| 48 | - self::$array['pieces'] = (array) $uri_array; |
|
| 49 | - } |
|
| 46 | + if(end($uri_array) == '') |
|
| 47 | + $uri_array = array_slice($uri_array, 0, count($uri_array) - 1); |
|
| 48 | + self::$array['pieces'] = (array) $uri_array; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - static function getSite() |
|
| 52 | - { |
|
| 53 | - return self::$array['site']; |
|
| 54 | - } |
|
| 51 | + static function getSite() |
|
| 52 | + { |
|
| 53 | + return self::$array['site']; |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - static function getHost() |
|
| 57 | - { |
|
| 58 | - return self::$array['host']; |
|
| 59 | - } |
|
| 56 | + static function getHost() |
|
| 57 | + { |
|
| 58 | + return self::$array['host']; |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - static function getBase() |
|
| 62 | - { |
|
| 63 | - return self::$array['base']; |
|
| 64 | - } |
|
| 61 | + static function getBase() |
|
| 62 | + { |
|
| 63 | + return self::$array['base']; |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - static function getURI() |
|
| 67 | - { |
|
| 68 | - return self::$array['uri']; |
|
| 69 | - } |
|
| 66 | + static function getURI() |
|
| 67 | + { |
|
| 68 | + return self::$array['uri']; |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - static function getExtension() |
|
| 72 | - { |
|
| 73 | - $file = self::getPiece(-1); |
|
| 74 | - if(substr($file, -1) == '/') |
|
| 75 | - return false; |
|
| 76 | - return substr($file, strrpos($file, '.') + 1);; |
|
| 77 | - } |
|
| 71 | + static function getExtension() |
|
| 72 | + { |
|
| 73 | + $file = self::getPiece(-1); |
|
| 74 | + if(substr($file, -1) == '/') |
|
| 75 | + return false; |
|
| 76 | + return substr($file, strrpos($file, '.') + 1);; |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - static function getPiece($piece = null) |
|
| 80 | - { |
|
| 81 | - if(!$piece) |
|
| 82 | - return self::$array['pieces']; |
|
| 79 | + static function getPiece($piece = null) |
|
| 80 | + { |
|
| 81 | + if(!$piece) |
|
| 82 | + return self::$array['pieces']; |
|
| 83 | 83 | |
| 84 | - if($piece == -1) |
|
| 85 | - return end(self::$array['pieces']); |
|
| 84 | + if($piece == -1) |
|
| 85 | + return end(self::$array['pieces']); |
|
| 86 | 86 | |
| 87 | - $piece = $piece - 1; |
|
| 88 | - if(array_key_exists($piece, self::$array['pieces'])) |
|
| 89 | - return self::$array['pieces'][$piece]; |
|
| 90 | - return; |
|
| 91 | - } |
|
| 87 | + $piece = $piece - 1; |
|
| 88 | + if(array_key_exists($piece, self::$array['pieces'])) |
|
| 89 | + return self::$array['pieces'][$piece]; |
|
| 90 | + return; |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | 93 | } |
| 94 | 94 | |
@@ -1,26 +1,26 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -class URLDecode |
|
| 4 | -{ |
|
| 3 | +class URLDecode |
|
| 4 | +{
|
|
| 5 | 5 | |
| 6 | 6 | private static $array = array(); |
| 7 | 7 | |
| 8 | - static function init() |
|
| 9 | - { |
|
| 8 | + static function init() {
|
|
| 10 | 9 | $host = $_SERVER['HTTP_HOST']; |
| 11 | 10 | $uri = $_SERVER['REQUEST_URI']; |
| 12 | 11 | self::form_url_array($host, $uri); |
| 13 | 12 | } |
| 14 | 13 | |
| 15 | - static private function form_url_array($host, $uri) |
|
| 16 | - { |
|
| 14 | + static private function form_url_array($host, $uri) {
|
|
| 17 | 15 | $uri = substr($uri, 1); |
| 18 | - if(strpos($uri, '?')) |
|
| 19 | - $uri = substr($uri, 0, strpos($uri, '?')); |
|
| 16 | + if(strpos($uri, '?')) {
|
|
| 17 | + $uri = substr($uri, 0, strpos($uri, '?')); |
|
| 18 | + } |
|
| 20 | 19 | $uri_array = explode('/', $uri); |
| 21 | 20 | |
| 22 | - if(!Loader::isLive()) |
|
| 23 | - $host = substr($host, strpos($host, '.') + 1); |
|
| 21 | + if(!Loader::isLive()) {
|
|
| 22 | + $host = substr($host, strpos($host, '.') + 1); |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | 25 | self::$array['host'] = $host; |
| 26 | 26 | |
@@ -43,50 +43,49 @@ discard block |
||
| 43 | 43 | self::$array['base'] = $base; |
| 44 | 44 | self::$array['uri'] = '/' . implode('/', $uri_array); |
| 45 | 45 | |
| 46 | - if(end($uri_array) == '') |
|
| 47 | - $uri_array = array_slice($uri_array, 0, count($uri_array) - 1); |
|
| 46 | + if(end($uri_array) == '') {
|
|
| 47 | + $uri_array = array_slice($uri_array, 0, count($uri_array) - 1); |
|
| 48 | + } |
|
| 48 | 49 | self::$array['pieces'] = (array) $uri_array; |
| 49 | 50 | } |
| 50 | 51 | |
| 51 | - static function getSite() |
|
| 52 | - { |
|
| 52 | + static function getSite() {
|
|
| 53 | 53 | return self::$array['site']; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - static function getHost() |
|
| 57 | - { |
|
| 56 | + static function getHost() {
|
|
| 58 | 57 | return self::$array['host']; |
| 59 | 58 | } |
| 60 | 59 | |
| 61 | - static function getBase() |
|
| 62 | - { |
|
| 60 | + static function getBase() {
|
|
| 63 | 61 | return self::$array['base']; |
| 64 | 62 | } |
| 65 | 63 | |
| 66 | - static function getURI() |
|
| 67 | - { |
|
| 64 | + static function getURI() {
|
|
| 68 | 65 | return self::$array['uri']; |
| 69 | 66 | } |
| 70 | 67 | |
| 71 | - static function getExtension() |
|
| 72 | - { |
|
| 68 | + static function getExtension() {
|
|
| 73 | 69 | $file = self::getPiece(-1); |
| 74 | - if(substr($file, -1) == '/') |
|
| 75 | - return false; |
|
| 70 | + if(substr($file, -1) == '/') {
|
|
| 71 | + return false; |
|
| 72 | + } |
|
| 76 | 73 | return substr($file, strrpos($file, '.') + 1);; |
| 77 | 74 | } |
| 78 | 75 | |
| 79 | - static function getPiece($piece = null) |
|
| 80 | - { |
|
| 81 | - if(!$piece) |
|
| 82 | - return self::$array['pieces']; |
|
| 76 | + static function getPiece($piece = null) {
|
|
| 77 | + if(!$piece) {
|
|
| 78 | + return self::$array['pieces']; |
|
| 79 | + } |
|
| 83 | 80 | |
| 84 | - if($piece == -1) |
|
| 85 | - return end(self::$array['pieces']); |
|
| 81 | + if($piece == -1) {
|
|
| 82 | + return end(self::$array['pieces']); |
|
| 83 | + } |
|
| 86 | 84 | |
| 87 | 85 | $piece = $piece - 1; |
| 88 | - if(array_key_exists($piece, self::$array['pieces'])) |
|
| 89 | - return self::$array['pieces'][$piece]; |
|
| 86 | + if(array_key_exists($piece, self::$array['pieces'])) {
|
|
| 87 | + return self::$array['pieces'][$piece]; |
|
| 88 | + } |
|
| 90 | 89 | return; |
| 91 | 90 | } |
| 92 | 91 | |