@@ -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 = " |
@@ -2,11 +2,11 @@ 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) |
|
| 9 | + {
|
|
| 10 | 10 | $name = self::escape($name); |
| 11 | 11 | $email = self::escape($email); |
| 12 | 12 | $website = self::escape($website); |
@@ -25,8 +25,8 @@ discard block |
||
| 25 | 25 | return self::run_row_query($query); |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | - public static function getCommentByBody($body) |
|
| 29 | - { |
|
| 28 | + public static function getCommentByBody($body) |
|
| 29 | + {
|
|
| 30 | 30 | $body = self::escape($body); |
| 31 | 31 | |
| 32 | 32 | $query = " |
@@ -41,8 +41,8 @@ discard block |
||
| 41 | 41 | return self::run_row_query($query); |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - public static function getCommentPageByURL($path, $site) |
|
| 45 | - { |
|
| 44 | + public static function getCommentPageByURL($path, $site) |
|
| 45 | + {
|
|
| 46 | 46 | $path = self::escape($path); |
| 47 | 47 | |
| 48 | 48 | $query = " |
@@ -59,8 +59,8 @@ discard block |
||
| 59 | 59 | return self::run_row_query($query); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - public static function getNotificationForPage($comment_page) |
|
| 63 | - { |
|
| 62 | + public static function getNotificationForPage($comment_page) |
|
| 63 | + {
|
|
| 64 | 64 | $query = " |
| 65 | 65 | SELECT |
| 66 | 66 | `name`, |
@@ -83,8 +83,8 @@ discard block |
||
| 83 | 83 | return self::run_query($query); |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - public static function getRecentBlogComments($count) |
|
| 87 | - { |
|
| 86 | + public static function getRecentBlogComments($count) |
|
| 87 | + {
|
|
| 88 | 88 | $query = " |
| 89 | 89 | SELECT |
| 90 | 90 | `comment_meta`.`id`, |
@@ -114,8 +114,8 @@ discard block |
||
| 114 | 114 | return self::run_query($query); |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - public static function getRecentWaterfallComments($count = 5) |
|
| 118 | - { |
|
| 117 | + public static function getRecentWaterfallComments($count = 5) |
|
| 118 | + {
|
|
| 119 | 119 | $query = " |
| 120 | 120 | SELECT |
| 121 | 121 | `comment_meta`.`id`, |
@@ -159,14 +159,15 @@ discard block |
||
| 159 | 159 | return self::run_query($query); |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - public static function getCommentsForURL($site, $path, $commenter = 0) |
|
| 163 | - { |
|
| 162 | + public static function getCommentsForURL($site, $path, $commenter = 0) |
|
| 163 | + {
|
|
| 164 | 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 | |
| 171 | 172 | $query = " |
| 172 | 173 | SELECT |
@@ -197,8 +198,8 @@ discard block |
||
| 197 | 198 | return self::run_query($query); |
| 198 | 199 | } |
| 199 | 200 | |
| 200 | - public static function getCommentCountForURL($site, $path) |
|
| 201 | - { |
|
| 201 | + public static function getCommentCountForURL($site, $path) |
|
| 202 | + {
|
|
| 202 | 203 | $path = self::escape($path); |
| 203 | 204 | |
| 204 | 205 | $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); |
@@ -2,11 +2,11 @@ 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) |
|
| 9 | + {
|
|
| 10 | 10 | $query = " |
| 11 | 11 | SELECT |
| 12 | 12 | `log`.`id`, |
@@ -34,8 +34,8 @@ discard block |
||
| 34 | 34 | return self::run_query($query); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - public static function getRecentList($total) |
|
| 38 | - { |
|
| 37 | + public static function getRecentList($total) |
|
| 38 | + {
|
|
| 39 | 39 | $query = " |
| 40 | 40 | SELECT |
| 41 | 41 | `log`.`title`, |
@@ -62,8 +62,8 @@ discard block |
||
| 62 | 62 | return self::run_query($query); |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - public static function getListCount() |
|
| 66 | - { |
|
| 65 | + public static function getListCount() |
|
| 66 | + {
|
|
| 67 | 67 | $query = " |
| 68 | 68 | SELECT |
| 69 | 69 | COUNT(1) AS `count` |
@@ -74,8 +74,8 @@ discard block |
||
| 74 | 74 | return self::get_count($query); |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - public static function getCompanionListForLog($log) |
|
| 78 | - { |
|
| 77 | + public static function getCompanionListForLog($log) |
|
| 78 | + {
|
|
| 79 | 79 | $query = " |
| 80 | 80 | SELECT |
| 81 | 81 | `companion`.`name`, |
@@ -90,8 +90,8 @@ discard block |
||
| 90 | 90 | return self::run_query($query); |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - public static function getWaterfallListForLog($log) |
|
| 94 | - { |
|
| 93 | + public static function getWaterfallListForLog($log) |
|
| 94 | + {
|
|
| 95 | 95 | $query = " |
| 96 | 96 | SELECT |
| 97 | 97 | `waterfall`.`name`, |
@@ -113,8 +113,8 @@ discard block |
||
| 113 | 113 | return self::run_query($query); |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - public static function getLogListForWaterfall($waterfall) |
|
| 117 | - { |
|
| 116 | + public static function getLogListForWaterfall($waterfall) |
|
| 117 | + {
|
|
| 118 | 118 | $query = " |
| 119 | 119 | SELECT |
| 120 | 120 | `log`.`title`, |
@@ -133,8 +133,8 @@ discard block |
||
| 133 | 133 | return self::run_query($query); |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - public static function getTagListForLog($log) |
|
| 137 | - { |
|
| 136 | + public static function getTagListForLog($log) |
|
| 137 | + {
|
|
| 138 | 138 | $query = " |
| 139 | 139 | SELECT |
| 140 | 140 | `tag`.`name`, |
@@ -147,8 +147,8 @@ discard block |
||
| 147 | 147 | return self::run_query($query); |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - public static function getByAlias($alias) |
|
| 151 | - { |
|
| 150 | + public static function getByAlias($alias) |
|
| 151 | + {
|
|
| 152 | 152 | $alias = self::escape($alias); |
| 153 | 153 | |
| 154 | 154 | $query = " |
@@ -178,8 +178,8 @@ discard block |
||
| 178 | 178 | return self::run_row_query($query); |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - public static function getByDate($date) |
|
| 182 | - { |
|
| 181 | + public static function getByDate($date) |
|
| 182 | + {
|
|
| 183 | 183 | $date = self::escape($date); |
| 184 | 184 | |
| 185 | 185 | $query = " |
@@ -195,8 +195,8 @@ discard block |
||
| 195 | 195 | return self::run_row_query($query); |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | - public static function getById($log) |
|
| 199 | - { |
|
| 198 | + public static function getById($log) |
|
| 199 | + {
|
|
| 200 | 200 | $query = " |
| 201 | 201 | SELECT |
| 202 | 202 | `title`, |
@@ -211,8 +211,8 @@ discard block |
||
| 211 | 211 | return self::run_row_query($query); |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | - public static function getPreviousLog($log) |
|
| 215 | - { |
|
| 214 | + public static function getPreviousLog($log) |
|
| 215 | + {
|
|
| 216 | 216 | $query = " |
| 217 | 217 | SELECT |
| 218 | 218 | `title`, |
@@ -236,8 +236,8 @@ discard block |
||
| 236 | 236 | return self::run_row_query($query); |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | - public static function getNextLog($log) |
|
| 240 | - { |
|
| 239 | + public static function getNextLog($log) |
|
| 240 | + {
|
|
| 241 | 241 | $query = " |
| 242 | 242 | SELECT |
| 243 | 243 | `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); |
@@ -2,11 +2,11 @@ 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) |
|
| 9 | + {
|
|
| 10 | 10 | $query = " |
| 11 | 11 | SELECT |
| 12 | 12 | `waterfall`.`id`, |
@@ -43,8 +43,8 @@ discard block |
||
| 43 | 43 | return self::run_query($query); |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - public static function getMapList() |
|
| 47 | - { |
|
| 46 | + public static function getMapList() |
|
| 47 | + {
|
|
| 48 | 48 | $query = " |
| 49 | 49 | SELECT |
| 50 | 50 | `waterfall`.`name`, |
@@ -74,8 +74,8 @@ discard block |
||
| 74 | 74 | return self::run_query($query); |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - public static function getListCount() |
|
| 78 | - { |
|
| 77 | + public static function getListCount() |
|
| 78 | + {
|
|
| 79 | 79 | $query = " |
| 80 | 80 | SELECT |
| 81 | 81 | COUNT(1) AS `count` |
@@ -92,8 +92,8 @@ discard block |
||
| 92 | 92 | return self::get_count($query); |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - public static function getNearbyList($waterfall) |
|
| 96 | - { |
|
| 95 | + public static function getNearbyList($waterfall) |
|
| 96 | + {
|
|
| 97 | 97 | $query = " |
| 98 | 98 | SELECT |
| 99 | 99 | `waterfall`.`name`, |
@@ -117,8 +117,8 @@ discard block |
||
| 117 | 117 | return self::run_query($query); |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - public static function getByOldAlias($alias) |
|
| 121 | - { |
|
| 120 | + public static function getByOldAlias($alias) |
|
| 121 | + {
|
|
| 122 | 122 | $alias = self::escape($alias); |
| 123 | 123 | |
| 124 | 124 | $query = " |
@@ -137,8 +137,8 @@ discard block |
||
| 137 | 137 | return self::run_row_query($query); |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - public static function getByAlias($watercourse, $waterfall) |
|
| 141 | - { |
|
| 140 | + public static function getByAlias($watercourse, $waterfall) |
|
| 141 | + {
|
|
| 142 | 142 | $watercourse = self::escape($watercourse); |
| 143 | 143 | $waterfall = self::escape($waterfall); |
| 144 | 144 | |
@@ -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; |
@@ -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,8 @@ 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() |
|
| 20 | + {
|
|
| 21 | 21 | $this->set_head('rss_link', [ |
| 22 | 22 | 'title' => 'Jacob Emerick Blog Feed', |
| 23 | 23 | 'url' => '/rss.xml' |
@@ -31,18 +31,19 @@ discard block |
||
| 31 | 31 | $this->add_css('blog'); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - protected function get_introduction() |
|
| 35 | - { |
|
| 34 | + protected function get_introduction() |
|
| 35 | + {
|
|
| 36 | 36 | return; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - protected function get_introduction_image($id) |
|
| 40 | - { |
|
| 39 | + protected function get_introduction_image($id) |
|
| 40 | + {
|
|
| 41 | 41 | Loader::load('collector', 'image/PhotoCollector'); |
| 42 | 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 | |
| 47 | 48 | $name = $photo_result->name; |
| 48 | 49 | $category = $photo_result->category; |
@@ -54,8 +55,8 @@ discard block |
||
| 54 | 55 | return sprintf(self::$INTRODUCTION_IMAGE_PATTERN, $category, $name, $size, $height, $width, $description); |
| 55 | 56 | } |
| 56 | 57 | |
| 57 | - protected function set_body_data() |
|
| 58 | - { |
|
| 58 | + protected function set_body_data() |
|
| 59 | + {
|
|
| 59 | 60 | $this->set_body('introduction', $this->get_introduction()); |
| 60 | 61 | $this->set_body('right_side', $this->get_right_side()); |
| 61 | 62 | $this->set_body('activity_array', $this->get_recent_activity()); |
@@ -63,8 +64,8 @@ discard block |
||
| 63 | 64 | $this->set_body_view('Page'); |
| 64 | 65 | } |
| 65 | 66 | |
| 66 | - final protected function format_post($post, $trim = false) |
|
| 67 | - { |
|
| 67 | + final protected function format_post($post, $trim = false) |
|
| 68 | + {
|
|
| 68 | 69 | $post_object = new stdclass(); |
| 69 | 70 | |
| 70 | 71 | $post_object->title = $post['title']; |
@@ -80,8 +81,8 @@ discard block |
||
| 80 | 81 | return $post_object; |
| 81 | 82 | } |
| 82 | 83 | |
| 83 | - final private function get_comments_for_post($post) |
|
| 84 | - { |
|
| 84 | + final private function get_comments_for_post($post) |
|
| 85 | + {
|
|
| 85 | 86 | $count = CommentCollector::getCommentCountForURL(self::$BLOG_SITE_ID, $post['path']); |
| 86 | 87 | $count_from_service = $this->get_comments_for_post_from_service($post); |
| 87 | 88 | |
@@ -93,8 +94,8 @@ discard block |
||
| 93 | 94 | return $count; |
| 94 | 95 | } |
| 95 | 96 | |
| 96 | - final private function get_comments_for_post_from_service($post) |
|
| 97 | - { |
|
| 97 | + final private function get_comments_for_post_from_service($post) |
|
| 98 | + {
|
|
| 98 | 99 | global $config; |
| 99 | 100 | $configuration = new Jacobemerick\CommentService\Configuration(); |
| 100 | 101 | $configuration->setUsername($config->comments->user); |
@@ -127,8 +128,8 @@ discard block |
||
| 127 | 128 | return count($comment_response); |
| 128 | 129 | } |
| 129 | 130 | |
| 130 | - final private function get_tags_for_post($post) |
|
| 131 | - { |
|
| 131 | + final private function get_tags_for_post($post) |
|
| 132 | + {
|
|
| 132 | 133 | global $container; |
| 133 | 134 | $repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']); |
| 134 | 135 | $tag_result = $repository->getTagsForPost($post['id']); |
@@ -144,12 +145,13 @@ discard block |
||
| 144 | 145 | return $tag_array; |
| 145 | 146 | } |
| 146 | 147 | |
| 147 | - final private function get_body_for_post($post, $trim) |
|
| 148 | - { |
|
| 148 | + final private function get_body_for_post($post, $trim) |
|
| 149 | + {
|
|
| 149 | 150 | $body = $post['body']; |
| 150 | 151 | |
| 151 | - if($trim) |
|
| 152 | - $body = Content::instance('SmartTrim', $body)->activate(self::$LENGTH_OF_TRIMMED_POST); |
|
| 152 | + if($trim) {
|
|
| 153 | + $body = Content::instance('SmartTrim', $body)->activate(self::$LENGTH_OF_TRIMMED_POST);
|
|
| 154 | + } |
|
| 153 | 155 | |
| 154 | 156 | $body = Content::instance('FixPhoto', $body)->activate(false, 'standard'); |
| 155 | 157 | $body = Content::instance('MarkupCode', $body)->activate(); |
@@ -157,16 +159,16 @@ discard block |
||
| 157 | 159 | return $body; |
| 158 | 160 | } |
| 159 | 161 | |
| 160 | - final protected function get_right_side() |
|
| 161 | - { |
|
| 162 | + final protected function get_right_side() |
|
| 163 | + {
|
|
| 162 | 164 | $side_array = array(); |
| 163 | 165 | $side_array['tags'] = $this->get_tag_cloud(); |
| 164 | 166 | $side_array['comments'] = $this->get_comments(); |
| 165 | 167 | return $side_array; |
| 166 | 168 | } |
| 167 | 169 | |
| 168 | - final private function get_tag_cloud() |
|
| 169 | - { |
|
| 170 | + final private function get_tag_cloud() |
|
| 171 | + {
|
|
| 170 | 172 | global $container; |
| 171 | 173 | $repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']); |
| 172 | 174 | $tag_result = $repository->getTagCloud(); |
@@ -176,8 +178,9 @@ discard block |
||
| 176 | 178 | $cloud_array = array(); |
| 177 | 179 | foreach($tag_result as $tag) |
| 178 | 180 | { |
| 179 | - if($tag['count'] < self::$MINIMUM_TAG_COUNT) |
|
| 180 | - continue; |
|
| 181 | + if($tag['count'] < self::$MINIMUM_TAG_COUNT) {
|
|
| 182 | + continue; |
|
| 183 | + } |
|
| 181 | 184 | |
| 182 | 185 | $tag_object = new stdclass(); |
| 183 | 186 | $tag_object->name = $tag['tag']; |
@@ -189,20 +192,21 @@ discard block |
||
| 189 | 192 | return $cloud_array; |
| 190 | 193 | } |
| 191 | 194 | |
| 192 | - final private function get_maximum_tag_count($tag_result) |
|
| 193 | - { |
|
| 195 | + final private function get_maximum_tag_count($tag_result) |
|
| 196 | + {
|
|
| 194 | 197 | $maximum = 1; |
| 195 | 198 | |
| 196 | 199 | foreach($tag_result as $tag) |
| 197 | 200 | { |
| 198 | - if($tag['count'] > $maximum) |
|
| 199 | - $maximum = $tag['count']; |
|
| 201 | + if($tag['count'] > $maximum) {
|
|
| 202 | + $maximum = $tag['count']; |
|
| 203 | + } |
|
| 200 | 204 | } |
| 201 | 205 | return $maximum; |
| 202 | 206 | } |
| 203 | 207 | |
| 204 | - final private function get_comments() |
|
| 205 | - { |
|
| 208 | + final private function get_comments() |
|
| 209 | + {
|
|
| 206 | 210 | $comment_array = CommentCollector::getRecentBlogComments(self::$RECENT_COMMENT_COUNT); |
| 207 | 211 | |
| 208 | 212 | $array = array(); |
@@ -228,8 +232,8 @@ discard block |
||
| 228 | 232 | return $array; |
| 229 | 233 | } |
| 230 | 234 | |
| 231 | - final private function get_comments_from_service() |
|
| 232 | - { |
|
| 235 | + final private function get_comments_from_service() |
|
| 236 | + {
|
|
| 233 | 237 | global $config; |
| 234 | 238 | $configuration = new Jacobemerick\CommentService\Configuration(); |
| 235 | 239 | $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')
|
@@ -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 | |
@@ -20,12 +20,18 @@ discard block |
||
| 20 | 20 | private $data_array = array(); |
| 21 | 21 | private $body_view_array = array(); |
| 22 | 22 | |
| 23 | - protected function set_head_data() {} |
|
| 24 | - protected function set_body_data() {} |
|
| 25 | - protected function set_data() {} |
|
| 23 | + protected function set_head_data() |
|
| 24 | + {
|
|
| 25 | +} |
|
| 26 | + protected function set_body_data() |
|
| 27 | + {
|
|
| 28 | +} |
|
| 29 | + protected function set_data() |
|
| 30 | + {
|
|
| 31 | +} |
|
| 26 | 32 | |
| 27 | - public function __construct() |
|
| 28 | - { |
|
| 33 | + public function __construct() |
|
| 34 | + {
|
|
| 29 | 35 | $this->set_header_method('sendHTML'); |
| 30 | 36 | |
| 31 | 37 | $this->set_head('google_verification', 'sgAISiuoWfK54KXnOfm2oU4vQdad8eyNCQX7LkZ1OxM'); |
@@ -38,8 +44,8 @@ discard block |
||
| 38 | 44 | 'date' => date('Y'))); |
| 39 | 45 | } |
| 40 | 46 | |
| 41 | - protected function get_domain_container() |
|
| 42 | - { |
|
| 47 | + protected function get_domain_container() |
|
| 48 | + {
|
|
| 43 | 49 | $domain_container = new stdclass(); |
| 44 | 50 | |
| 45 | 51 | $domain_container->blog = Loader::getRootUrl('blog'); |
@@ -52,8 +58,8 @@ discard block |
||
| 52 | 58 | return $domain_container; |
| 53 | 59 | } |
| 54 | 60 | |
| 55 | - protected function get_recent_activity() |
|
| 56 | - { |
|
| 61 | + protected function get_recent_activity() |
|
| 62 | + {
|
|
| 57 | 63 | global $container; |
| 58 | 64 | $activityRepository = new Jacobemerick\Web\Domain\Stream\Activity\MysqlActivityRepository($container['db_connection_locator']); |
| 59 | 65 | $post_result = $activityRepository->getActivities(5); |
@@ -66,8 +72,8 @@ discard block |
||
| 66 | 72 | return $post_array; |
| 67 | 73 | } |
| 68 | 74 | |
| 69 | - protected function expand_post($raw_post, $format = 'short') |
|
| 70 | - { |
|
| 75 | + protected function expand_post($raw_post, $format = 'short') |
|
| 76 | + {
|
|
| 71 | 77 | $post = [ |
| 72 | 78 | 'type' => $raw_post['type'], |
| 73 | 79 | 'title' => ($format == 'short') ? $raw_post['message'] : $raw_post['message_long'], |
@@ -84,8 +90,8 @@ discard block |
||
| 84 | 90 | return (object) $post; |
| 85 | 91 | } |
| 86 | 92 | |
| 87 | - public function activate() |
|
| 88 | - { |
|
| 93 | + public function activate() |
|
| 94 | + {
|
|
| 89 | 95 | $this->set_head_data(); |
| 90 | 96 | $this->set_body_data(); |
| 91 | 97 | $this->set_data(); |
@@ -97,10 +103,11 @@ discard block |
||
| 97 | 103 | Loader::load('view', '/Head', $this->data_array['head']); |
| 98 | 104 | foreach($this->body_view_array as $view) |
| 99 | 105 | { |
| 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']); |
|
| 106 | + if(substr($view, 0, 1) == '/') {
|
|
| 107 | + Loader::load('view', $view, $this->data_array['body']);
|
|
| 108 | + } else {
|
|
| 109 | + Loader::load('view', URLDecode::getSite() . '/' . $view, $this->data_array['body']);
|
|
| 110 | + } |
|
| 104 | 111 | } |
| 105 | 112 | |
| 106 | 113 | if (URLDecode::getSite() == 'waterfalls') { |
@@ -109,62 +116,63 @@ discard block |
||
| 109 | 116 | Loader::load('view', '/Foot', array('tracking_code' => self::$TRACKING_CODE)); |
| 110 | 117 | } |
| 111 | 118 | |
| 112 | - if($view == '/404' || $view == '/503') |
|
| 113 | - exit; |
|
| 119 | + if($view == '/404' || $view == '/503') {
|
|
| 120 | + exit; |
|
| 121 | + } |
|
| 114 | 122 | } |
| 115 | 123 | |
| 116 | - protected function set_header_method($method) |
|
| 117 | - { |
|
| 124 | + protected function set_header_method($method) |
|
| 125 | + {
|
|
| 118 | 126 | $this->headers = $method; |
| 119 | 127 | } |
| 120 | 128 | |
| 121 | - protected function set_title($value) |
|
| 122 | - { |
|
| 129 | + protected function set_title($value) |
|
| 130 | + {
|
|
| 123 | 131 | $this->set_head('title', $value); |
| 124 | 132 | } |
| 125 | 133 | |
| 126 | - protected function set_author($value) |
|
| 127 | - { |
|
| 134 | + protected function set_author($value) |
|
| 135 | + {
|
|
| 128 | 136 | $this->set_head('author', $value); |
| 129 | 137 | } |
| 130 | 138 | |
| 131 | - protected function set_description($value) |
|
| 132 | - { |
|
| 139 | + protected function set_description($value) |
|
| 140 | + {
|
|
| 133 | 141 | $this->set_head('description', $value); |
| 134 | 142 | } |
| 135 | 143 | |
| 136 | - protected function set_keywords($array) |
|
| 137 | - { |
|
| 144 | + protected function set_keywords($array) |
|
| 145 | + {
|
|
| 138 | 146 | $this->set_head('keywords', implode(', ', $array)); |
| 139 | 147 | } |
| 140 | 148 | |
| 141 | - protected function set_canonical($url) |
|
| 142 | - { |
|
| 149 | + protected function set_canonical($url) |
|
| 150 | + {
|
|
| 143 | 151 | $this->set_head('canonical', $url); |
| 144 | 152 | } |
| 145 | 153 | |
| 146 | - protected function set_head($set, $value) |
|
| 147 | - { |
|
| 154 | + protected function set_head($set, $value) |
|
| 155 | + {
|
|
| 148 | 156 | $this->data_array['head'][$set] = $value; |
| 149 | 157 | } |
| 150 | 158 | |
| 151 | - protected function set_body($set, $value) |
|
| 152 | - { |
|
| 159 | + protected function set_body($set, $value) |
|
| 160 | + {
|
|
| 153 | 161 | $this->data_array['body'][$set] = $value; |
| 154 | 162 | } |
| 155 | 163 | |
| 156 | - protected function add_css($file, $version = 1) |
|
| 157 | - { |
|
| 164 | + protected function add_css($file, $version = 1) |
|
| 165 | + {
|
|
| 158 | 166 | $this->css_array[] = [$file, $version]; |
| 159 | 167 | } |
| 160 | 168 | |
| 161 | - protected function add_js($file) |
|
| 162 | - { |
|
| 169 | + protected function add_js($file) |
|
| 170 | + {
|
|
| 163 | 171 | $this->js_array[] = $file; |
| 164 | 172 | } |
| 165 | 173 | |
| 166 | - private function load_assets() |
|
| 167 | - { |
|
| 174 | + private function load_assets() |
|
| 175 | + {
|
|
| 168 | 176 | $css_array = array_map(function ($stylesheet) { |
| 169 | 177 | $path = "/css/{$stylesheet[0]}.css"; |
| 170 | 178 | if ($stylesheet[1] > 1) { |
@@ -183,40 +191,44 @@ discard block |
||
| 183 | 191 | $this->set_head('js_link_array', $js_array); |
| 184 | 192 | } |
| 185 | 193 | |
| 186 | - protected function set_body_view($view) |
|
| 187 | - { |
|
| 194 | + protected function set_body_view($view) |
|
| 195 | + {
|
|
| 188 | 196 | $this->body_view_array[] = $view; |
| 189 | 197 | } |
| 190 | 198 | |
| 191 | - protected function eject() |
|
| 192 | - { |
|
| 193 | - if(get_class($this) !== 'Error404Controller') |
|
| 194 | - Loader::loadNew('controller', '/Error404Controller')->activate(); |
|
| 199 | + protected function eject() |
|
| 200 | + {
|
|
| 201 | + if(get_class($this) !== 'Error404Controller') {
|
|
| 202 | + Loader::loadNew('controller', '/Error404Controller')->activate();
|
|
| 203 | + } |
|
| 195 | 204 | } |
| 196 | 205 | |
| 197 | - protected function unavailable() |
|
| 198 | - { |
|
| 199 | - if(get_class($this) !== 'Error503Controller') |
|
| 200 | - Loader::loadNew('controller', '/Error503Controller')->activate(); |
|
| 206 | + protected function unavailable() |
|
| 207 | + {
|
|
| 208 | + if(get_class($this) !== 'Error503Controller') {
|
|
| 209 | + Loader::loadNew('controller', '/Error503Controller')->activate();
|
|
| 210 | + } |
|
| 201 | 211 | } |
| 202 | 212 | |
| 203 | - protected function redirect($uri, $method = 301) |
|
| 204 | - { |
|
| 213 | + protected function redirect($uri, $method = 301) |
|
| 214 | + {
|
|
| 205 | 215 | switch($method) |
| 206 | 216 | { |
| 207 | 217 | case 301 : |
| 208 | - if(get_class($this) !== 'Error301Controller') |
|
| 209 | - Loader::loadNew('controller', '/Error301Controller', array($uri))->activate(); |
|
| 218 | + if(get_class($this) !== 'Error301Controller') {
|
|
| 219 | + Loader::loadNew('controller', '/Error301Controller', array($uri))->activate();
|
|
| 220 | + } |
|
| 210 | 221 | break; |
| 211 | 222 | case 303 : |
| 212 | - if(get_class($this) !== 'Error303Controller') |
|
| 213 | - Loader::loadNew('controller', '/Error303Controller', array($uri))->activate(); |
|
| 223 | + if(get_class($this) !== 'Error303Controller') {
|
|
| 224 | + Loader::loadNew('controller', '/Error303Controller', array($uri))->activate();
|
|
| 225 | + } |
|
| 214 | 226 | break; |
| 215 | 227 | } |
| 216 | 228 | } |
| 217 | 229 | |
| 218 | - final protected function get_parsed_date($date) |
|
| 219 | - { |
|
| 230 | + final protected function get_parsed_date($date) |
|
| 231 | + {
|
|
| 220 | 232 | $parsed_date = new stdclass(); |
| 221 | 233 | |
| 222 | 234 | $parsed_date->stamp = date('c', strtotime($date)); |
@@ -227,8 +239,8 @@ discard block |
||
| 227 | 239 | } |
| 228 | 240 | |
| 229 | 241 | private $comment_errors; |
| 230 | - protected function handle_comment_submit($site_id, $path, $redirect_url, $page_title) |
|
| 231 | - { |
|
| 242 | + protected function handle_comment_submit($site_id, $path, $redirect_url, $page_title) |
|
| 243 | + {
|
|
| 232 | 244 | if(Request::hasPost() && Request::getPost('submit') == 'Submit Comment') |
| 233 | 245 | { |
| 234 | 246 | $parameters = array($site_id, $path, $redirect_url, $page_title); |
@@ -238,8 +250,8 @@ discard block |
||
| 238 | 250 | return; |
| 239 | 251 | } |
| 240 | 252 | |
| 241 | - protected function get_comment_array($site, $path) |
|
| 242 | - { |
|
| 253 | + protected function get_comment_array($site, $path) |
|
| 254 | + {
|
|
| 243 | 255 | Loader::load('collector', 'comment/CommentCollector'); |
| 244 | 256 | |
| 245 | 257 | $commenter = $this->get_commenter(); |
@@ -257,18 +269,19 @@ discard block |
||
| 257 | 269 | $comment_object->url = $comment->url; |
| 258 | 270 | $comment_object->trusted = $comment->trusted; |
| 259 | 271 | |
| 260 | - if($comment->reply == 0 && Request::getPost('type') == $comment->id) |
|
| 261 | - $comment_object->errors = $this->comment_errors; |
|
| 262 | - else |
|
| 263 | - $comment_object->errors = array(); |
|
| 272 | + if($comment->reply == 0 && Request::getPost('type') == $comment->id) {
|
|
| 273 | + $comment_object->errors = $this->comment_errors; |
|
| 274 | + } else {
|
|
| 275 | + $comment_object->errors = array(); |
|
| 276 | + } |
|
| 264 | 277 | |
| 265 | 278 | if($comment->reply == 0) |
| 266 | 279 | { |
| 267 | 280 | $comment_object->replies = array(); |
| 268 | 281 | $comment_array[$comment->id] = $comment_object; |
| 269 | - } |
|
| 270 | - else |
|
| 271 | - $comment_array[$comment->reply]->replies[$comment->id] = $comment_object; |
|
| 282 | + } else {
|
|
| 283 | + $comment_array[$comment->reply]->replies[$comment->id] = $comment_object; |
|
| 284 | + } |
|
| 272 | 285 | } |
| 273 | 286 | |
| 274 | 287 | $comment_count = CommentCollector::getCommentCountForURL($site, $path); |
@@ -280,8 +293,8 @@ discard block |
||
| 280 | 293 | 'comment_count' => $comment_count); |
| 281 | 294 | } |
| 282 | 295 | |
| 283 | - private function get_commenter() |
|
| 284 | - { |
|
| 296 | + private function get_commenter() |
|
| 297 | + {
|
|
| 285 | 298 | Loader::load('collector', 'comment/CommentCollector'); |
| 286 | 299 | |
| 287 | 300 | $commenter = new stdclass(); |
@@ -297,16 +310,19 @@ discard block |
||
| 297 | 310 | |
| 298 | 311 | $commenter_cookie_value = json_decode($_COOKIE['commenter']); |
| 299 | 312 | |
| 300 | - if($commenter_cookie_value === NULL) |
|
| 301 | - return $commenter; |
|
| 313 | + if($commenter_cookie_value === NULL) {
|
|
| 314 | + return $commenter; |
|
| 315 | + } |
|
| 302 | 316 | |
| 303 | - if(!isset($commenter_cookie_value->name) || !isset($commenter_cookie_value->email)) |
|
| 304 | - return $commenter; |
|
| 317 | + if(!isset($commenter_cookie_value->name) || !isset($commenter_cookie_value->email)) {
|
|
| 318 | + return $commenter; |
|
| 319 | + } |
|
| 305 | 320 | |
| 306 | 321 | $commenter_object = CommentCollector::getCommenterByFields($commenter_cookie_value->name, $commenter_cookie_value->email, (isset($commenter_cookie_value->website) ? $commenter_cookie_value->website : '')); |
| 307 | 322 | |
| 308 | - if($commenter_object === NULL) |
|
| 309 | - return $commenter; |
|
| 323 | + if($commenter_object === NULL) {
|
|
| 324 | + return $commenter; |
|
| 325 | + } |
|
| 310 | 326 | |
| 311 | 327 | $commenter->id = $commenter_object->id; |
| 312 | 328 | $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) |
@@ -2,16 +2,17 @@ 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 = '') |
|
| 11 | + {
|
|
| 12 | 12 | preg_match_all(self::$MARKUP_DELIMITER, $this->content, $matches); |
| 13 | - if(count($matches[1]) == 0) |
|
| 14 | - return; |
|
| 13 | + if(count($matches[1]) == 0) {
|
|
| 14 | + return; |
|
| 15 | + } |
|
| 15 | 16 | |
| 16 | 17 | foreach($matches[3] as $key => $match) |
| 17 | 18 | { |
@@ -25,8 +26,8 @@ discard block |
||
| 25 | 26 | return; |
| 26 | 27 | } |
| 27 | 28 | |
| 28 | - private function wrap_in_list($content) |
|
| 29 | - { |
|
| 29 | + private function wrap_in_list($content) |
|
| 30 | + {
|
|
| 30 | 31 | $content_array = explode("\n", $content); |
| 31 | 32 | |
| 32 | 33 | foreach($content_array as $key => $row) |
@@ -44,8 +45,8 @@ discard block |
||
| 44 | 45 | return $content; |
| 45 | 46 | } |
| 46 | 47 | |
| 47 | - private function highlight_code($content, $type) |
|
| 48 | - { |
|
| 48 | + private function highlight_code($content, $type) |
|
| 49 | + {
|
|
| 49 | 50 | switch($type) |
| 50 | 51 | { |
| 51 | 52 | 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); |
@@ -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,8 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | private $is_trimmed; |
| 26 | 26 | |
| 27 | - protected function execute() |
|
| 28 | - { |
|
| 27 | + protected function execute() |
|
| 28 | + {
|
|
| 29 | 29 | $args = func_get_args(); |
| 30 | 30 | if(count($args) < 1) |
| 31 | 31 | { |
@@ -33,37 +33,40 @@ discard block |
||
| 33 | 33 | return; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - if(count($args) == 2) |
|
| 37 | - $etc = $args[1]; |
|
| 38 | - else |
|
| 39 | - $etc = self::$ETC; |
|
| 36 | + if(count($args) == 2) {
|
|
| 37 | + $etc = $args[1]; |
|
| 38 | + } else {
|
|
| 39 | + $etc = self::$ETC; |
|
| 40 | + } |
|
| 40 | 41 | |
| 41 | 42 | $length = $args[0]; |
| 42 | 43 | |
| 43 | - if($length < strlen($this->content)) |
|
| 44 | - $this->trim_string($length); |
|
| 45 | - else |
|
| 46 | - $etc = ''; |
|
| 44 | + if($length < strlen($this->content)) {
|
|
| 45 | + $this->trim_string($length); |
|
| 46 | + } else {
|
|
| 47 | + $etc = ''; |
|
| 48 | + } |
|
| 47 | 49 | $this->check_exclude_tags(); |
| 48 | 50 | $this->close_tags($etc); |
| 49 | 51 | } |
| 50 | 52 | |
| 51 | - private function trim_string($length) |
|
| 52 | - { |
|
| 53 | + private function trim_string($length) |
|
| 54 | + {
|
|
| 53 | 55 | $content = $this->trim_html_string($this->content, $length); |
| 54 | 56 | |
| 55 | 57 | $last_right_bracket_position = strripos($content, self::$RIGHT_BRACKET); |
| 56 | 58 | $last_left_bracket_position = strripos($content, self::$LEFT_BRACKET); |
| 57 | - if($last_left_bracket_position > $last_right_bracket_position) |
|
| 58 | - $content = substr($content, 0, $last_left_bracket_position); |
|
| 59 | + if($last_left_bracket_position > $last_right_bracket_position) {
|
|
| 60 | + $content = substr($content, 0, $last_left_bracket_position); |
|
| 61 | + } |
|
| 59 | 62 | $content = trim($content); |
| 60 | 63 | |
| 61 | 64 | $this->content = $content; |
| 62 | 65 | $this->is_trimmed = true; |
| 63 | 66 | } |
| 64 | 67 | |
| 65 | - private function trim_html_string($content, $length) |
|
| 66 | - { |
|
| 68 | + private function trim_html_string($content, $length) |
|
| 69 | + {
|
|
| 67 | 70 | $content = preg_replace(self::$PHOTO_PLACEHOLDER_MATCH, '', $content); |
| 68 | 71 | preg_match_all(self::$HTML_TAG_PATTERN, $content, $matches, PREG_OFFSET_CAPTURE); |
| 69 | 72 | $content = strip_tags($content); |
@@ -76,20 +79,22 @@ discard block |
||
| 76 | 79 | foreach($matches[0] as $match) |
| 77 | 80 | { |
| 78 | 81 | $max_length += strlen($match[0]); |
| 79 | - if($max_length <= $match[1]) |
|
| 80 | - break; |
|
| 82 | + if($max_length <= $match[1]) {
|
|
| 83 | + break; |
|
| 84 | + } |
|
| 81 | 85 | |
| 82 | 86 | $content = substr($content, 0, $match[1]) . $match[0] . substr($content, $match[1]); |
| 83 | 87 | } |
| 84 | 88 | |
| 85 | - if(substr($content, -7) == '</p><p>') |
|
| 86 | - $content = substr($content, 0, -7); |
|
| 89 | + if(substr($content, -7) == '</p><p>') {
|
|
| 90 | + $content = substr($content, 0, -7); |
|
| 91 | + } |
|
| 87 | 92 | |
| 88 | 93 | return $content; |
| 89 | 94 | } |
| 90 | 95 | |
| 91 | - private function check_exclude_tags() |
|
| 92 | - { |
|
| 96 | + private function check_exclude_tags() |
|
| 97 | + {
|
|
| 93 | 98 | $content = $this->content; |
| 94 | 99 | $tags_preg = $this->get_tags_preg(self::$EXCLUDE_TAGS); |
| 95 | 100 | preg_match_all($tags_preg, $content, $matches, PREG_OFFSET_CAPTURE); |
@@ -105,8 +110,8 @@ discard block |
||
| 105 | 110 | $this->content = $content; |
| 106 | 111 | } |
| 107 | 112 | |
| 108 | - private function close_tags($etc) |
|
| 109 | - { |
|
| 113 | + private function close_tags($etc) |
|
| 114 | + {
|
|
| 110 | 115 | $content = $this->content; |
| 111 | 116 | $tags_preg = $this->get_tags_preg(self::$INCLUDE_TAGS); |
| 112 | 117 | preg_match_all($tags_preg, $content, $matches); |
@@ -118,9 +123,9 @@ discard block |
||
| 118 | 123 | { |
| 119 | 124 | $key = array_search($tag, $open_tags); |
| 120 | 125 | unset($open_tags[$key]); |
| 121 | - } |
|
| 122 | - else |
|
| 123 | - $open_tags[] = $tag; |
|
| 126 | + } else {
|
|
| 127 | + $open_tags[] = $tag; |
|
| 128 | + } |
|
| 124 | 129 | } |
| 125 | 130 | |
| 126 | 131 | $open_tags = array_reverse($open_tags); |
@@ -128,19 +133,20 @@ discard block |
||
| 128 | 133 | { |
| 129 | 134 | foreach($open_tags as $key => $open_tag) |
| 130 | 135 | { |
| 131 | - if($key == count($open_tags) - 1) |
|
| 132 | - $content .= $etc; |
|
| 136 | + if($key == count($open_tags) - 1) {
|
|
| 137 | + $content .= $etc; |
|
| 138 | + } |
|
| 133 | 139 | $content .= "</{$open_tag}>"; |
| 134 | 140 | } |
| 135 | - } |
|
| 136 | - else |
|
| 137 | - $content .= $etc; |
|
| 141 | + } else {
|
|
| 142 | + $content .= $etc; |
|
| 143 | + } |
|
| 138 | 144 | |
| 139 | 145 | $this->content = $content; |
| 140 | 146 | } |
| 141 | 147 | |
| 142 | - private function get_tags_preg($tag_array) |
|
| 143 | - { |
|
| 148 | + private function get_tags_preg($tag_array) |
|
| 149 | + {
|
|
| 144 | 150 | return '@</?(' . implode('|', $tag_array) . ')@'; |
| 145 | 151 | } |
| 146 | 152 | |
@@ -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) |
@@ -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,74 @@ 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() |
|
| 13 | + {
|
|
| 14 | 14 | self::make_server(); |
| 15 | 15 | self::make_get(); |
| 16 | 16 | self::make_post(); |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | - static function getServer($key = null) |
|
| 20 | - { |
|
| 19 | + static function getServer($key = null) |
|
| 20 | + {
|
|
| 21 | 21 | if($key) |
| 22 | 22 | { |
| 23 | - if(isset(self::$server[$key])) |
|
| 24 | - return self::$server[$key]; |
|
| 23 | + if(isset(self::$server[$key])) {
|
|
| 24 | + return self::$server[$key]; |
|
| 25 | + } |
|
| 25 | 26 | return false; |
| 26 | 27 | } |
| 27 | 28 | return self::$server; |
| 28 | 29 | } |
| 29 | 30 | |
| 30 | - static function isAjax() |
|
| 31 | - { |
|
| 32 | - if(self::getServer(self::$AJAX_REQUEST)) |
|
| 33 | - return true; |
|
| 31 | + static function isAjax() |
|
| 32 | + {
|
|
| 33 | + if(self::getServer(self::$AJAX_REQUEST)) {
|
|
| 34 | + return true; |
|
| 35 | + } |
|
| 34 | 36 | return false; |
| 35 | 37 | } |
| 36 | 38 | |
| 37 | - static function getGet($key = null) |
|
| 38 | - { |
|
| 39 | + static function getGet($key = null) |
|
| 40 | + {
|
|
| 39 | 41 | if($key) |
| 40 | 42 | { |
| 41 | - if(isset(self::$get[$key])) |
|
| 42 | - return self::$get[$key]; |
|
| 43 | + if(isset(self::$get[$key])) {
|
|
| 44 | + return self::$get[$key]; |
|
| 45 | + } |
|
| 43 | 46 | return false; |
| 44 | 47 | } |
| 45 | 48 | return self::$get; |
| 46 | 49 | } |
| 47 | 50 | |
| 48 | - static function getPost($key = null) |
|
| 49 | - { |
|
| 51 | + static function getPost($key = null) |
|
| 52 | + {
|
|
| 50 | 53 | if($key) |
| 51 | 54 | { |
| 52 | - if(isset(self::$post[$key])) |
|
| 53 | - return self::$post[$key]; |
|
| 55 | + if(isset(self::$post[$key])) {
|
|
| 56 | + return self::$post[$key]; |
|
| 57 | + } |
|
| 54 | 58 | return false; |
| 55 | 59 | } |
| 56 | 60 | return self::$post; |
| 57 | 61 | } |
| 58 | 62 | |
| 59 | - public static function hasPost() |
|
| 60 | - { |
|
| 63 | + public static function hasPost() |
|
| 64 | + {
|
|
| 61 | 65 | return is_array(self::$post) && !empty(self::$post); |
| 62 | 66 | } |
| 63 | 67 | |
| 64 | - static function make_server() |
|
| 65 | - { |
|
| 68 | + static function make_server() |
|
| 69 | + {
|
|
| 66 | 70 | self::$server = $_SERVER; |
| 67 | 71 | } |
| 68 | 72 | |
| 69 | - static function make_get() |
|
| 70 | - { |
|
| 73 | + static function make_get() |
|
| 74 | + {
|
|
| 71 | 75 | self::$get = $_GET; |
| 72 | 76 | } |
| 73 | 77 | |
| 74 | - static function make_post() |
|
| 75 | - { |
|
| 78 | + static function make_post() |
|
| 79 | + {
|
|
| 76 | 80 | self::$post = $_POST; |
| 77 | 81 | } |
| 78 | 82 | |
@@ -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) |
@@ -1,26 +1,28 @@ 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() |
|
| 9 | + {
|
|
| 10 | 10 | $host = $_SERVER['HTTP_HOST']; |
| 11 | 11 | $uri = $_SERVER['REQUEST_URI']; |
| 12 | 12 | self::form_url_array($host, $uri); |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | - static private function form_url_array($host, $uri) |
|
| 16 | - { |
|
| 15 | + static private function form_url_array($host, $uri) |
|
| 16 | + {
|
|
| 17 | 17 | $uri = substr($uri, 1); |
| 18 | - if(strpos($uri, '?')) |
|
| 19 | - $uri = substr($uri, 0, strpos($uri, '?')); |
|
| 18 | + if(strpos($uri, '?')) {
|
|
| 19 | + $uri = substr($uri, 0, strpos($uri, '?')); |
|
| 20 | + } |
|
| 20 | 21 | $uri_array = explode('/', $uri); |
| 21 | 22 | |
| 22 | - if(!Loader::isLive()) |
|
| 23 | - $host = substr($host, strpos($host, '.') + 1); |
|
| 23 | + if(!Loader::isLive()) {
|
|
| 24 | + $host = substr($host, strpos($host, '.') + 1); |
|
| 25 | + } |
|
| 24 | 26 | |
| 25 | 27 | self::$array['host'] = $host; |
| 26 | 28 | |
@@ -43,50 +45,55 @@ discard block |
||
| 43 | 45 | self::$array['base'] = $base; |
| 44 | 46 | self::$array['uri'] = '/' . implode('/', $uri_array); |
| 45 | 47 | |
| 46 | - if(end($uri_array) == '') |
|
| 47 | - $uri_array = array_slice($uri_array, 0, count($uri_array) - 1); |
|
| 48 | + if(end($uri_array) == '') {
|
|
| 49 | + $uri_array = array_slice($uri_array, 0, count($uri_array) - 1); |
|
| 50 | + } |
|
| 48 | 51 | self::$array['pieces'] = (array) $uri_array; |
| 49 | 52 | } |
| 50 | 53 | |
| 51 | - static function getSite() |
|
| 52 | - { |
|
| 54 | + static function getSite() |
|
| 55 | + {
|
|
| 53 | 56 | return self::$array['site']; |
| 54 | 57 | } |
| 55 | 58 | |
| 56 | - static function getHost() |
|
| 57 | - { |
|
| 59 | + static function getHost() |
|
| 60 | + {
|
|
| 58 | 61 | return self::$array['host']; |
| 59 | 62 | } |
| 60 | 63 | |
| 61 | - static function getBase() |
|
| 62 | - { |
|
| 64 | + static function getBase() |
|
| 65 | + {
|
|
| 63 | 66 | return self::$array['base']; |
| 64 | 67 | } |
| 65 | 68 | |
| 66 | - static function getURI() |
|
| 67 | - { |
|
| 69 | + static function getURI() |
|
| 70 | + {
|
|
| 68 | 71 | return self::$array['uri']; |
| 69 | 72 | } |
| 70 | 73 | |
| 71 | - static function getExtension() |
|
| 72 | - { |
|
| 74 | + static function getExtension() |
|
| 75 | + {
|
|
| 73 | 76 | $file = self::getPiece(-1); |
| 74 | - if(substr($file, -1) == '/') |
|
| 75 | - return false; |
|
| 77 | + if(substr($file, -1) == '/') {
|
|
| 78 | + return false; |
|
| 79 | + } |
|
| 76 | 80 | return substr($file, strrpos($file, '.') + 1);; |
| 77 | 81 | } |
| 78 | 82 | |
| 79 | - static function getPiece($piece = null) |
|
| 80 | - { |
|
| 81 | - if(!$piece) |
|
| 82 | - return self::$array['pieces']; |
|
| 83 | + static function getPiece($piece = null) |
|
| 84 | + {
|
|
| 85 | + if(!$piece) {
|
|
| 86 | + return self::$array['pieces']; |
|
| 87 | + } |
|
| 83 | 88 | |
| 84 | - if($piece == -1) |
|
| 85 | - return end(self::$array['pieces']); |
|
| 89 | + if($piece == -1) {
|
|
| 90 | + return end(self::$array['pieces']); |
|
| 91 | + } |
|
| 86 | 92 | |
| 87 | 93 | $piece = $piece - 1; |
| 88 | - if(array_key_exists($piece, self::$array['pieces'])) |
|
| 89 | - return self::$array['pieces'][$piece]; |
|
| 94 | + if(array_key_exists($piece, self::$array['pieces'])) {
|
|
| 95 | + return self::$array['pieces'][$piece]; |
|
| 96 | + } |
|
| 90 | 97 | return; |
| 91 | 98 | } |
| 92 | 99 | |