@@ -20,15 +20,17 @@ discard block |
||
| 20 | 20 | $this->offset = ($this->page - 1) * $this->get_item_count_per_page(); |
| 21 | 21 | |
| 22 | 22 | $items = $this->get_items(); |
| 23 | - if(count($items) < 1) |
|
| 24 | - $this->eject(); |
|
| 23 | + if(count($items) < 1) {
|
|
| 24 | + $this->eject(); |
|
| 25 | + } |
|
| 25 | 26 | } |
| 26 | 27 | |
| 27 | 28 | final protected function get_page_number() |
| 28 | 29 | { |
| 29 | 30 | $page = $this->get_page_number_piece(); |
| 30 | - if(isset($page) && is_numeric($page)) |
|
| 31 | - return $page; |
|
| 31 | + if(isset($page) && is_numeric($page)) {
|
|
| 32 | + return $page; |
|
| 33 | + } |
|
| 32 | 34 | return 1; |
| 33 | 35 | } |
| 34 | 36 | |
@@ -41,8 +43,9 @@ discard block |
||
| 41 | 43 | |
| 42 | 44 | final private function get_introduction() |
| 43 | 45 | { |
| 44 | - if($this->page == 1) |
|
| 45 | - return $this->get_initial_introduction(); |
|
| 46 | + if($this->page == 1) {
|
|
| 47 | + return $this->get_initial_introduction(); |
|
| 48 | + } |
|
| 46 | 49 | |
| 47 | 50 | return $this->get_subsequent_introduction(); |
| 48 | 51 | } |
@@ -68,8 +71,9 @@ discard block |
||
| 68 | 71 | private $item_count; |
| 69 | 72 | final private function get_item_count() |
| 70 | 73 | { |
| 71 | - if(!isset($this->item_count)) |
|
| 72 | - $this->item_count = $this->get_item_count_result(); |
|
| 74 | + if(!isset($this->item_count)) {
|
|
| 75 | + $this->item_count = $this->get_item_count_result(); |
|
| 76 | + } |
|
| 73 | 77 | return $this->item_count; |
| 74 | 78 | } |
| 75 | 79 | |
@@ -82,10 +86,11 @@ discard block |
||
| 82 | 86 | $this->set_head('next_link', $this->get_list_next_link()); |
| 83 | 87 | $this->set_head('previous_link', $this->get_list_prev_link()); |
| 84 | 88 | |
| 85 | - if($this->page == 1) |
|
| 86 | - $meta_array = $this->get_initial_meta(); |
|
| 87 | - else |
|
| 88 | - $meta_array = $this->get_subsequent_meta(); |
|
| 89 | + if($this->page == 1) {
|
|
| 90 | + $meta_array = $this->get_initial_meta(); |
|
| 91 | + } else {
|
|
| 92 | + $meta_array = $this->get_subsequent_meta(); |
|
| 93 | + } |
|
| 89 | 94 | |
| 90 | 95 | $this->set_title($meta_array['title']); |
| 91 | 96 | $this->set_description($meta_array['description']); |
@@ -119,17 +124,20 @@ discard block |
||
| 119 | 124 | |
| 120 | 125 | final private function get_list_prev_link() |
| 121 | 126 | { |
| 122 | - if($this->page == 1) |
|
| 123 | - return; |
|
| 124 | - if($this->page == 2) |
|
| 125 | - return $this->get_list_link_root(); |
|
| 127 | + if($this->page == 1) {
|
|
| 128 | + return; |
|
| 129 | + } |
|
| 130 | + if($this->page == 2) {
|
|
| 131 | + return $this->get_list_link_root(); |
|
| 132 | + } |
|
| 126 | 133 | return $this->get_list_link_root() . ($this->page - 1) . '/'; |
| 127 | 134 | } |
| 128 | 135 | |
| 129 | 136 | final private function get_list_next_link() |
| 130 | 137 | { |
| 131 | - if(($this->page * $this->get_item_count_per_page()) >= $this->get_item_count()) |
|
| 132 | - return; |
|
| 138 | + if(($this->page * $this->get_item_count_per_page()) >= $this->get_item_count()) {
|
|
| 139 | + return; |
|
| 140 | + } |
|
| 133 | 141 | return $this->get_list_link_root() . ($this->page + 1) . '/'; |
| 134 | 142 | } |
| 135 | 143 | |
@@ -139,15 +147,17 @@ discard block |
||
| 139 | 147 | { |
| 140 | 148 | $link_array = array(); |
| 141 | 149 | |
| 142 | - if($this->get_item_count_per_page() >= $this->get_item_count()) |
|
| 143 | - return $link_array; |
|
| 150 | + if($this->get_item_count_per_page() >= $this->get_item_count()) {
|
|
| 151 | + return $link_array; |
|
| 152 | + } |
|
| 144 | 153 | |
| 145 | 154 | $link = new stdclass(); |
| 146 | 155 | $link->anchor = '« previous'; |
| 147 | - if($this->get_list_prev_link() !== null) |
|
| 148 | - $link->uri = $this->get_list_prev_link(); |
|
| 149 | - else |
|
| 150 | - $link->class = 'inactive'; |
|
| 156 | + if($this->get_list_prev_link() !== null) {
|
|
| 157 | + $link->uri = $this->get_list_prev_link(); |
|
| 158 | + } else {
|
|
| 159 | + $link->class = 'inactive'; |
|
| 160 | + } |
|
| 151 | 161 | $link_array[] = $link; |
| 152 | 162 | |
| 153 | 163 | for($i = 1; $i <= ceil($this->get_item_count() / $this->get_item_count_per_page()); $i++) |
@@ -155,14 +165,15 @@ discard block |
||
| 155 | 165 | $link = new stdclass(); |
| 156 | 166 | $link->anchor = $i; |
| 157 | 167 | |
| 158 | - if($i == $this->page) |
|
| 159 | - $link->class = 'current'; |
|
| 160 | - else |
|
| 168 | + if($i == $this->page) {
|
|
| 169 | + $link->class = 'current'; |
|
| 170 | + } else |
|
| 161 | 171 | { |
| 162 | - if($i == 1) |
|
| 163 | - $link->uri = $this->get_list_link_root(); |
|
| 164 | - else |
|
| 165 | - $link->uri = $this->get_list_link_root() . $i . '/'; |
|
| 172 | + if($i == 1) {
|
|
| 173 | + $link->uri = $this->get_list_link_root(); |
|
| 174 | + } else {
|
|
| 175 | + $link->uri = $this->get_list_link_root() . $i . '/'; |
|
| 176 | + } |
|
| 166 | 177 | } |
| 167 | 178 | |
| 168 | 179 | $link_array[] = $link; |
@@ -170,10 +181,11 @@ discard block |
||
| 170 | 181 | |
| 171 | 182 | $link = new stdclass(); |
| 172 | 183 | $link->anchor = 'next »'; |
| 173 | - if($this->get_list_next_link() !== null) |
|
| 174 | - $link->uri = $this->get_list_next_link(); |
|
| 175 | - else |
|
| 176 | - $link->class = 'inactive'; |
|
| 184 | + if($this->get_list_next_link() !== null) {
|
|
| 185 | + $link->uri = $this->get_list_next_link(); |
|
| 186 | + } else {
|
|
| 187 | + $link->class = 'inactive'; |
|
| 188 | + } |
|
| 177 | 189 | $link_array[] = $link; |
| 178 | 190 | |
| 179 | 191 | return $link_array; |
@@ -27,8 +27,9 @@ |
||
| 27 | 27 | $alias = URLDecode::getPiece(2); |
| 28 | 28 | $this->companion = CompanionCollector::getByAlias($alias); |
| 29 | 29 | |
| 30 | - if(!$this->companion) |
|
| 31 | - $this->eject(); |
|
| 30 | + if(!$this->companion) {
|
|
| 31 | + $this->eject(); |
|
| 32 | + } |
|
| 32 | 33 | |
| 33 | 34 | parent::__construct(); |
| 34 | 35 | } |
@@ -49,8 +49,7 @@ discard block |
||
| 49 | 49 | { |
| 50 | 50 | $this->set_title(sprintf(self::$TITLE_MAIN, ucwords($this->query))); |
| 51 | 51 | $this->set_description(sprintf(self::$DESCRIPTION_MAIN, ucwords($this->query))); |
| 52 | - } |
|
| 53 | - else |
|
| 52 | + } else |
|
| 54 | 53 | { |
| 55 | 54 | $this->set_title(sprintf(self::$TITLE_PAGINATED, ucwords($this->query), $this->page, $this->total_pages)); |
| 56 | 55 | $this->set_description(sprintf(self::$DESCRIPTION_PAGINATED, $this->page, $this->total_pages, ucwords($this->query))); |
@@ -63,22 +62,24 @@ discard block |
||
| 63 | 62 | |
| 64 | 63 | protected function get_introduction() |
| 65 | 64 | { |
| 66 | - if($this->total_pages > 1) |
|
| 67 | - return array( |
|
| 68 | - 'title' => "Posts from search '{$this->query}', page {$this->page} of {$this->total_pages}."); |
|
| 69 | - else if($this->total_pages == 1) |
|
| 70 | - return array( |
|
| 71 | - 'title' => "Posts from search '{$this->query}'."); |
|
| 72 | - else |
|
| 73 | - return array( |
|
| 74 | - 'title' => "Sorry, '{$this->query}' didn't return any posts."); |
|
| 65 | + if($this->total_pages > 1) {
|
|
| 66 | + return array( |
|
| 67 | + 'title' => "Posts from search '{$this->query}', page {$this->page} of {$this->total_pages}.");
|
|
| 68 | + } else if($this->total_pages == 1) {
|
|
| 69 | + return array( |
|
| 70 | + 'title' => "Posts from search '{$this->query}'.");
|
|
| 71 | + } else {
|
|
| 72 | + return array( |
|
| 73 | + 'title' => "Sorry, '{$this->query}' didn't return any posts.");
|
|
| 74 | + } |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | protected function get_page_number() |
| 78 | 78 | { |
| 79 | 79 | $page = URLDecode::getPiece(3); |
| 80 | - if(isset($page) && is_numeric($page)) |
|
| 81 | - return $page; |
|
| 80 | + if(isset($page) && is_numeric($page)) {
|
|
| 81 | + return $page; |
|
| 82 | + } |
|
| 82 | 83 | return 1; |
| 83 | 84 | } |
| 84 | 85 | |
@@ -113,25 +114,29 @@ discard block |
||
| 113 | 114 | |
| 114 | 115 | protected function get_list_next_link() |
| 115 | 116 | { |
| 116 | - if($this->page == 1) |
|
| 117 | - return; |
|
| 118 | - if($this->page == 2) |
|
| 119 | - return Content::instance('URLSafe', "/search/{$this->query}/")->activate(); |
|
| 117 | + if($this->page == 1) {
|
|
| 118 | + return; |
|
| 119 | + } |
|
| 120 | + if($this->page == 2) {
|
|
| 121 | + return Content::instance('URLSafe', "/search/{$this->query}/")->activate();
|
|
| 122 | + } |
|
| 120 | 123 | return Content::instance('URLSafe', "/search/{$this->query}/" . ($this->page - 1) . '/')->activate(); |
| 121 | 124 | } |
| 122 | 125 | |
| 123 | 126 | protected function get_list_prev_link() |
| 124 | 127 | { |
| 125 | - if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
| 126 | - return; |
|
| 128 | + if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) {
|
|
| 129 | + return; |
|
| 130 | + } |
|
| 127 | 131 | return Content::instance('URLSafe', "/search/{$this->query}/" . ($this->page + 1) . '/')->activate(); |
| 128 | 132 | } |
| 129 | 133 | |
| 130 | 134 | private $total_post_count; |
| 131 | 135 | protected function get_total_post_count() |
| 132 | 136 | { |
| 133 | - if(!isset($this->total_post_count)) |
|
| 134 | - $this->total_post_count = count($this->get_search_result()); |
|
| 137 | + if(!isset($this->total_post_count)) {
|
|
| 138 | + $this->total_post_count = count($this->get_search_result()); |
|
| 139 | + } |
|
| 135 | 140 | return $this->total_post_count; |
| 136 | 141 | } |
| 137 | 142 | |
@@ -60,8 +60,9 @@ |
||
| 60 | 60 | { |
| 61 | 61 | $post_array[] = $this->format_post($post, true); |
| 62 | 62 | } |
| 63 | - if(count($post_array) < 1 && URLDecode::getPiece(1) !== 'search') |
|
| 64 | - $this->eject(); |
|
| 63 | + if(count($post_array) < 1 && URLDecode::getPiece(1) !== 'search') {
|
|
| 64 | + $this->eject(); |
|
| 65 | + } |
|
| 65 | 66 | return $post_array; |
| 66 | 67 | } |
| 67 | 68 | |
@@ -56,14 +56,16 @@ |
||
| 56 | 56 | { |
| 57 | 57 | $current_uri = URLDecode::getPiece(1); |
| 58 | 58 | |
| 59 | - if(!isset($current_uri)) |
|
| 60 | - return 'About'; |
|
| 59 | + if(!isset($current_uri)) {
|
|
| 60 | + return 'About'; |
|
| 61 | + } |
|
| 61 | 62 | |
| 62 | 63 | $menu = self::$MENU; |
| 63 | 64 | foreach($menu as $link) |
| 64 | 65 | { |
| 65 | - if($link['uri'] == $current_uri) |
|
| 66 | - return $link['name']; |
|
| 66 | + if($link['uri'] == $current_uri) {
|
|
| 67 | + return $link['name']; |
|
| 68 | + } |
|
| 67 | 69 | } |
| 68 | 70 | |
| 69 | 71 | return 'About'; |
@@ -29,15 +29,19 @@ |
||
| 29 | 29 | |
| 30 | 30 | private function get_form_results() |
| 31 | 31 | { |
| 32 | - if(!Request::hasPost()) |
|
| 33 | - return array(); |
|
| 32 | + if(!Request::hasPost()) {
|
|
| 33 | + return array(); |
|
| 34 | + } |
|
| 34 | 35 | |
| 35 | - if(!Validate::checkRequest('post', 'name', 'string')) |
|
| 36 | - $error_message['name'] = 'Please enter a value for your name.'; |
|
| 37 | - if(!Validate::checkRequest('post', 'email', 'string')) |
|
| 38 | - $error_message['email'] = 'Please enter a valid email address.'; |
|
| 39 | - if(!Validate::checkRequest('post', 'message', 'string')) |
|
| 40 | - $error_message['message'] = 'Please enter a message.'; |
|
| 36 | + if(!Validate::checkRequest('post', 'name', 'string')) {
|
|
| 37 | + $error_message['name'] = 'Please enter a value for your name.'; |
|
| 38 | + } |
|
| 39 | + if(!Validate::checkRequest('post', 'email', 'string')) {
|
|
| 40 | + $error_message['email'] = 'Please enter a valid email address.'; |
|
| 41 | + } |
|
| 42 | + if(!Validate::checkRequest('post', 'message', 'string')) {
|
|
| 43 | + $error_message['message'] = 'Please enter a message.'; |
|
| 44 | + } |
|
| 41 | 45 | |
| 42 | 46 | if(!empty($error_message)) |
| 43 | 47 | { |
@@ -26,16 +26,20 @@ discard block |
||
| 26 | 26 | |
| 27 | 27 | public function activate() |
| 28 | 28 | { |
| 29 | - if(!Request::hasPost()) |
|
| 30 | - return false; |
|
| 31 | - if(!Request::getPost('submit') == 'Submit Comment') |
|
| 32 | - return false; |
|
| 29 | + if(!Request::hasPost()) {
|
|
| 30 | + return false; |
|
| 31 | + } |
|
| 32 | + if(!Request::getPost('submit') == 'Submit Comment') {
|
|
| 33 | + return false; |
|
| 34 | + } |
|
| 33 | 35 | |
| 34 | 36 | $errors = $this->fetch_errors(); |
| 35 | - if(count($errors) > 0) |
|
| 36 | - return $errors; |
|
| 37 | - if(Request::getPost('catch') !== '') |
|
| 38 | - return false; |
|
| 37 | + if(count($errors) > 0) {
|
|
| 38 | + return $errors; |
|
| 39 | + } |
|
| 40 | + if(Request::getPost('catch') !== '') {
|
|
| 41 | + return false; |
|
| 42 | + } |
|
| 39 | 43 | |
| 40 | 44 | $page_id = $this->save_comment_page(); |
| 41 | 45 | $commenter_id = $this->save_commenter(); |
@@ -50,18 +54,24 @@ discard block |
||
| 50 | 54 | private function fetch_errors() |
| 51 | 55 | { |
| 52 | 56 | $errors = array(); |
| 53 | - if(!Validate::checkRequest('post', 'name', 'name')) |
|
| 54 | - $errors['name'] = 'You must include a valid name'; |
|
| 55 | - if(!Validate::checkRequest('post', 'email', 'email')) |
|
| 56 | - $errors['email'] = 'You must include a valid email'; |
|
| 57 | - if(Request::getPost('website') && !Validate::checkRequest('post', 'website', 'url')) |
|
| 58 | - $errors['website'] = 'Please enter a valid website'; |
|
| 59 | - if(!Validate::checkRequest('post', 'comment', 'string')) |
|
| 60 | - $errors['comment'] = 'You must enter a comment'; |
|
| 61 | - if(Request::getPost('notify') && Request::getPost('notify') != 'check') |
|
| 62 | - $errors['notify'] = 'You entered an invalid notify request'; |
|
| 63 | - if(Request::getPost('reply') && !Validate::checkRequest('post', 'reply', 'integer')) |
|
| 64 | - $errors['reply'] = 'You entered an invalid reply request'; |
|
| 57 | + if(!Validate::checkRequest('post', 'name', 'name')) {
|
|
| 58 | + $errors['name'] = 'You must include a valid name'; |
|
| 59 | + } |
|
| 60 | + if(!Validate::checkRequest('post', 'email', 'email')) {
|
|
| 61 | + $errors['email'] = 'You must include a valid email'; |
|
| 62 | + } |
|
| 63 | + if(Request::getPost('website') && !Validate::checkRequest('post', 'website', 'url')) {
|
|
| 64 | + $errors['website'] = 'Please enter a valid website'; |
|
| 65 | + } |
|
| 66 | + if(!Validate::checkRequest('post', 'comment', 'string')) {
|
|
| 67 | + $errors['comment'] = 'You must enter a comment'; |
|
| 68 | + } |
|
| 69 | + if(Request::getPost('notify') && Request::getPost('notify') != 'check') {
|
|
| 70 | + $errors['notify'] = 'You entered an invalid notify request'; |
|
| 71 | + } |
|
| 72 | + if(Request::getPost('reply') && !Validate::checkRequest('post', 'reply', 'integer')) {
|
|
| 73 | + $errors['reply'] = 'You entered an invalid reply request'; |
|
| 74 | + } |
|
| 65 | 75 | |
| 66 | 76 | return $errors; |
| 67 | 77 | } |
@@ -69,8 +79,9 @@ discard block |
||
| 69 | 79 | private function save_comment_page() |
| 70 | 80 | { |
| 71 | 81 | $page_result = CommentCollector::getCommentPageByURL($this->path, $this->site); |
| 72 | - if($page_result !== null) |
|
| 73 | - return $page_result->id; |
|
| 82 | + if($page_result !== null) {
|
|
| 83 | + return $page_result->id; |
|
| 84 | + } |
|
| 74 | 85 | |
| 75 | 86 | $query = "INSERT INTO `jpemeric_comment`.`comment_page` (`site`, `path`) VALUES ('%d', '%s')"; |
| 76 | 87 | $query = sprintf($query, $this->site, $this->path); |
@@ -85,8 +96,9 @@ discard block |
||
| 85 | 96 | 'name' => Request::getPost('name'), |
| 86 | 97 | 'email' => Request::getPost('email')); |
| 87 | 98 | |
| 88 | - if(Request::getPost('website') != '') |
|
| 89 | - $cookie_value['website'] = Request::getPost('website'); |
|
| 99 | + if(Request::getPost('website') != '') {
|
|
| 100 | + $cookie_value['website'] = Request::getPost('website');
|
|
| 101 | + } |
|
| 90 | 102 | |
| 91 | 103 | $cookie_value = json_encode($cookie_value); |
| 92 | 104 | |
@@ -95,8 +107,9 @@ discard block |
||
| 95 | 107 | ->save(); |
| 96 | 108 | |
| 97 | 109 | $commenter_result = CommentCollector::getCommenterByFields(Request::getPost('name'), Request::getPost('email'), Request::getPost('website')); |
| 98 | - if($commenter_result !== null) |
|
| 99 | - return $commenter_result->id; |
|
| 110 | + if($commenter_result !== null) {
|
|
| 111 | + return $commenter_result->id; |
|
| 112 | + } |
|
| 100 | 113 | |
| 101 | 114 | $query = "INSERT INTO `jpemeric_comment`.`commenter` (`name`,`email`,`url`) VALUES ('%s','%s','%s')"; |
| 102 | 115 | |
@@ -112,8 +125,9 @@ discard block |
||
| 112 | 125 | private function save_comment() |
| 113 | 126 | { |
| 114 | 127 | $comment_result = CommentCollector::getCommentByBody(Request::getPost('comment')); |
| 115 | - if($comment_result !== null) |
|
| 116 | - return $comment_result->id; |
|
| 128 | + if($comment_result !== null) {
|
|
| 129 | + return $comment_result->id; |
|
| 130 | + } |
|
| 117 | 131 | |
| 118 | 132 | $query = "INSERT INTO `jpemeric_comment`.`comment` (`body`, `body_format`) VALUES ('%s', '%s')"; |
| 119 | 133 | |
@@ -133,8 +147,9 @@ discard block |
||
| 133 | 147 | $query = "INSERT INTO `jpemeric_comment`.`comment_meta` (`commenter`,`comment`,`reply`,`notify`,`comment_page`,`date`,`display`) VALUES ('%d','%d','%d','%d','%d','%s','%d')"; |
| 134 | 148 | |
| 135 | 149 | $reply = Database::escape(Request::getPost('type')); |
| 136 | - if($reply == 'new') |
|
| 137 | - $reply = 0; |
|
| 150 | + if($reply == 'new') {
|
|
| 151 | + $reply = 0; |
|
| 152 | + } |
|
| 138 | 153 | // else check to make sure value is legit |
| 139 | 154 | |
| 140 | 155 | $notify = (Request::getPost('notify') == 'check') ? 1 : 0; |
@@ -163,8 +178,9 @@ discard block |
||
| 163 | 178 | |
| 164 | 179 | foreach($notification_result as $notification_row) |
| 165 | 180 | { |
| 166 | - if($notification_row->email == Request::getPost('email')) |
|
| 167 | - continue; |
|
| 181 | + if($notification_row->email == Request::getPost('email')) {
|
|
| 182 | + continue; |
|
| 183 | + } |
|
| 168 | 184 | |
| 169 | 185 | $email_recipient_array[$notification_row->email] = array( |
| 170 | 186 | 'email' => $notification_row->email, |
@@ -36,8 +36,9 @@ discard block |
||
| 36 | 36 | $mysqli = new mysqli($host, $username, $password); |
| 37 | 37 | |
| 38 | 38 | $has_connection_error = $mysqli->connect_error; |
| 39 | - if(isset($has_connection_error)) |
|
| 40 | - $this->has_connection_error = true; |
|
| 39 | + if(isset($has_connection_error)) {
|
|
| 40 | + $this->has_connection_error = true; |
|
| 41 | + } |
|
| 41 | 42 | |
| 42 | 43 | return $mysqli; |
| 43 | 44 | } |
@@ -67,8 +68,9 @@ discard block |
||
| 67 | 68 | { |
| 68 | 69 | self::instance()->log_query($query, $start); |
| 69 | 70 | $array = array(); |
| 70 | - while($row = $result->fetch_object()) |
|
| 71 | - $array[] = $row; |
|
| 71 | + while($row = $result->fetch_object()) {
|
|
| 72 | + $array[] = $row; |
|
| 73 | + } |
|
| 72 | 74 | $result->close(); |
| 73 | 75 | return $array; |
| 74 | 76 | } |
@@ -79,8 +81,9 @@ discard block |
||
| 79 | 81 | public static function selectRow($query) |
| 80 | 82 | { |
| 81 | 83 | $result = self::select($query); |
| 82 | - if(is_array($result)) |
|
| 83 | - return array_pop($result); |
|
| 84 | + if(is_array($result)) {
|
|
| 85 | + return array_pop($result); |
|
| 86 | + } |
|
| 84 | 87 | return false; |
| 85 | 88 | } |
| 86 | 89 | |
@@ -99,8 +102,9 @@ discard block |
||
| 99 | 102 | public static function lastInsertID() |
| 100 | 103 | { |
| 101 | 104 | $id = self::instance()->write_connection->insert_id; |
| 102 | - if($id == 0) |
|
| 103 | - return false; |
|
| 105 | + if($id == 0) {
|
|
| 106 | + return false; |
|
| 107 | + } |
|
| 104 | 108 | return $id; |
| 105 | 109 | } |
| 106 | 110 | |
@@ -15,12 +15,14 @@ discard block |
||
| 15 | 15 | static private function form_url_array($host, $uri) |
| 16 | 16 | { |
| 17 | 17 | $uri = substr($uri, 1); |
| 18 | - if(strpos($uri, '?')) |
|
| 19 | - $uri = substr($uri, 0, strpos($uri, '?')); |
|
| 18 | + if(strpos($uri, '?')) {
|
|
| 19 | + $uri = substr($uri, 0, strpos($uri, '?')); |
|
| 20 | + } |
|
| 20 | 21 | $uri_array = explode('/', $uri); |
| 21 | 22 | |
| 22 | - if(!Loader::isLive()) |
|
| 23 | - $host = substr($host, strpos($host, '.') + 1); |
|
| 23 | + if(!Loader::isLive()) {
|
|
| 24 | + $host = substr($host, strpos($host, '.') + 1); |
|
| 25 | + } |
|
| 24 | 26 | |
| 25 | 27 | self::$array['host'] = $host; |
| 26 | 28 | |
@@ -33,8 +35,9 @@ discard block |
||
| 33 | 35 | self::$array['base'] = 'http://' . (!Loader::isLive() ? 'dev.' : '') . $host . '/'; |
| 34 | 36 | self::$array['uri'] = '/' . implode('/', $uri_array); |
| 35 | 37 | |
| 36 | - if(end($uri_array) == '') |
|
| 37 | - $uri_array = array_slice($uri_array, 0, count($uri_array) - 1); |
|
| 38 | + if(end($uri_array) == '') {
|
|
| 39 | + $uri_array = array_slice($uri_array, 0, count($uri_array) - 1); |
|
| 40 | + } |
|
| 38 | 41 | self::$array['pieces'] = (array) $uri_array; |
| 39 | 42 | } |
| 40 | 43 | |
@@ -61,22 +64,26 @@ discard block |
||
| 61 | 64 | static function getExtension() |
| 62 | 65 | { |
| 63 | 66 | $file = self::getPiece(-1); |
| 64 | - if(substr($file, -1) == '/') |
|
| 65 | - return false; |
|
| 67 | + if(substr($file, -1) == '/') {
|
|
| 68 | + return false; |
|
| 69 | + } |
|
| 66 | 70 | return substr($file, strrpos($file, '.') + 1);; |
| 67 | 71 | } |
| 68 | 72 | |
| 69 | 73 | static function getPiece($piece = null) |
| 70 | 74 | { |
| 71 | - if(!$piece) |
|
| 72 | - return self::$array['pieces']; |
|
| 75 | + if(!$piece) {
|
|
| 76 | + return self::$array['pieces']; |
|
| 77 | + } |
|
| 73 | 78 | |
| 74 | - if($piece == -1) |
|
| 75 | - return end(self::$array['pieces']); |
|
| 79 | + if($piece == -1) {
|
|
| 80 | + return end(self::$array['pieces']); |
|
| 81 | + } |
|
| 76 | 82 | |
| 77 | 83 | $piece = $piece - 1; |
| 78 | - if(array_key_exists($piece, self::$array['pieces'])) |
|
| 79 | - return self::$array['pieces'][$piece]; |
|
| 84 | + if(array_key_exists($piece, self::$array['pieces'])) {
|
|
| 85 | + return self::$array['pieces'][$piece]; |
|
| 86 | + } |
|
| 80 | 87 | return; |
| 81 | 88 | } |
| 82 | 89 | |