@@ -106,6 +106,10 @@ |
||
| 106 | 106 | $this->out("Generated $i users."); |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | + /** |
|
| 110 | + * @param integer $i |
|
| 111 | + * @param integer $off |
|
| 112 | + */ |
|
| 109 | 113 | protected function _progress($i, $off) { |
| 110 | 114 | if ($i < 1) { |
| 111 | 115 | return; |
@@ -31,11 +31,11 @@ discard block |
||
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | public function generate() { |
| 34 | - $nPostings = (int)$this->in('Number of postings to generate?', null, 100); |
|
| 34 | + $nPostings = (int) $this->in('Number of postings to generate?', null, 100); |
|
| 35 | 35 | if ($nPostings === 0) { |
| 36 | 36 | return; |
| 37 | 37 | } |
| 38 | - $ratio = (int)$this->in('Average answers per thread?', null, 10); |
|
| 38 | + $ratio = (int) $this->in('Average answers per thread?', null, 10); |
|
| 39 | 39 | $seed = $nPostings / $ratio; |
| 40 | 40 | |
| 41 | 41 | new Saito\Markup\Settings([ |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | } |
| 65 | 65 | $entry = $this->Entry->createPosting(['Entry' => $entry]); |
| 66 | 66 | if (empty($entry)) { |
| 67 | - throw new RuntimeException('Could not create entry: ' . $entry); |
|
| 67 | + throw new RuntimeException('Could not create entry: '.$entry); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | $this->_progress($i, $nPostings); |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | |
| 80 | 80 | public function user() { |
| 81 | 81 | $max = count($this->_users); |
| 82 | - $n = (int)$this->in("Number of users to generate (max: $max)?", null, 0); |
|
| 82 | + $n = (int) $this->in("Number of users to generate (max: $max)?", null, 0); |
|
| 83 | 83 | if ($n === 0) { |
| 84 | 84 | return; |
| 85 | 85 | } |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | } |
| 113 | 113 | $this->out('.', 0); |
| 114 | 114 | if ($i > 1 && !($i % 50)) { |
| 115 | - $percent = (int)floor($i / $off * 100); |
|
| 115 | + $percent = (int) floor($i / $off * 100); |
|
| 116 | 116 | $this->out(sprintf(' %3s%%', $percent), 1); |
| 117 | 117 | } |
| 118 | 118 | } |
@@ -42,12 +42,18 @@ |
||
| 42 | 42 | exec($command); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | + /** |
|
| 46 | + * @param string $urlFilePath |
|
| 47 | + */ |
|
| 45 | 48 | protected function _cleanup($urlFilePath) { |
| 46 | 49 | if (file_exists($urlFilePath)) { |
| 47 | 50 | unlink($urlFilePath); |
| 48 | 51 | } |
| 49 | 52 | } |
| 50 | 53 | |
| 54 | + /** |
|
| 55 | + * @param string[] $out |
|
| 56 | + */ |
|
| 51 | 57 | protected function _generateEntriesIndex(&$out) { |
| 52 | 58 | for ($i = 0; $i < 400; $i++) { |
| 53 | 59 | $out[] = $this->_prefix . 'entries/index/page:' . rand(1, 2); |
@@ -11,12 +11,12 @@ discard block |
||
| 11 | 11 | public function main() { |
| 12 | 12 | $out = []; |
| 13 | 13 | $base = rtrim($this->args[0], '/'); |
| 14 | - $in = $this->in('Base URL is: ' . $base, ['y', 'n'], 'y'); |
|
| 14 | + $in = $this->in('Base URL is: '.$base, ['y', 'n'], 'y'); |
|
| 15 | 15 | if ($in !== 'y') { |
| 16 | 16 | $this->out('Aborting.'); |
| 17 | 17 | return; |
| 18 | 18 | } |
| 19 | - $out[] = 'HOST=' . $base; |
|
| 19 | + $out[] = 'HOST='.$base; |
|
| 20 | 20 | $this->_generateEntriesIndex($out); |
| 21 | 21 | $this->_generateEntriesMix($out); |
| 22 | 22 | $this->_generateEntriesView($out); |
@@ -34,11 +34,11 @@ discard block |
||
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | protected function _siege(&$out) { |
| 37 | - $urlFilePath = TMP . 'url.txt'; |
|
| 37 | + $urlFilePath = TMP.'url.txt'; |
|
| 38 | 38 | $this->_cleanup($urlFilePath); |
| 39 | 39 | $this->createFile($urlFilePath, implode("\n", $out)); |
| 40 | - $command = 'siege -R ' . APP . '..' . DS . ".siegerc -f $urlFilePath"; |
|
| 41 | - $this->out('<info>Running: ' . $command . '</info>', 1, 'info'); |
|
| 40 | + $command = 'siege -R '.APP.'..'.DS.".siegerc -f $urlFilePath"; |
|
| 41 | + $this->out('<info>Running: '.$command.'</info>', 1, 'info'); |
|
| 42 | 42 | exec($command); |
| 43 | 43 | } |
| 44 | 44 | |
@@ -50,10 +50,10 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | protected function _generateEntriesIndex(&$out) { |
| 52 | 52 | for ($i = 0; $i < 400; $i++) { |
| 53 | - $out[] = $this->_prefix . 'entries/index/page:' . rand(1, 2); |
|
| 53 | + $out[] = $this->_prefix.'entries/index/page:'.rand(1, 2); |
|
| 54 | 54 | } |
| 55 | 55 | for ($i = 0; $i < 400; $i++) { |
| 56 | - $out[] = $this->_prefix . 'entries/index/page:' . rand(5, 10); |
|
| 56 | + $out[] = $this->_prefix.'entries/index/page:'.rand(5, 10); |
|
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | 59 | |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | ]); |
| 67 | 67 | |
| 68 | 68 | foreach ($entries as $entry) { |
| 69 | - $out[] = $this->_prefix . 'entries/mix/' . $entry['Entry']['id']; |
|
| 69 | + $out[] = $this->_prefix.'entries/mix/'.$entry['Entry']['id']; |
|
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | ]); |
| 80 | 80 | |
| 81 | 81 | foreach ($entries as $entry) { |
| 82 | - $out[] = $this->_prefix . 'entries/view/' . $entry['Entry']['id']; |
|
| 82 | + $out[] = $this->_prefix.'entries/view/'.$entry['Entry']['id']; |
|
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | 85 | |
@@ -104,6 +104,10 @@ discard block |
||
| 104 | 104 | return $this->_countYearStats(['fields' => ['COUNT(DISTINCT `user_id`) AS `count`']]); |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | + /** |
|
| 108 | + * @param string $model |
|
| 109 | + * @param string $field |
|
| 110 | + */ |
|
| 107 | 111 | protected function _getYearStats($model, $field) { |
| 108 | 112 | return $this->_countYearStats(['fields' => ['COUNT(*) AS `count`']], |
| 109 | 113 | [], $model, $field); |
@@ -147,6 +151,10 @@ discard block |
||
| 147 | 151 | return $this->_wrapData($data); |
| 148 | 152 | } |
| 149 | 153 | |
| 154 | + /** |
|
| 155 | + * @param string $model |
|
| 156 | + * @param string $field |
|
| 157 | + */ |
|
| 150 | 158 | protected function _getMonthStats($model, $field) { |
| 151 | 159 | $results = $this->_countYearStats( |
| 152 | 160 | ['fields' => ['COUNT(*) AS `count`']], |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | // order here is output order in frontend |
| 24 | 24 | $_logsToRead = ['error', 'debug']; |
| 25 | 25 | |
| 26 | - $_logsToRead = glob(LOGS . '*.log'); |
|
| 26 | + $_logsToRead = glob(LOGS.'*.log'); |
|
| 27 | 27 | if (!$_logsToRead) { |
| 28 | 28 | return; |
| 29 | 29 | } |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | $results = Hash::extract($results, '{n}.{n}'); |
| 143 | 143 | $data = []; |
| 144 | 144 | foreach ($results as $d) { |
| 145 | - $data[] = [(string)$d['date'], $d['count']]; |
|
| 145 | + $data[] = [(string) $d['date'], $d['count']]; |
|
| 146 | 146 | } |
| 147 | 147 | return $this->_wrapData($data); |
| 148 | 148 | } |
@@ -162,9 +162,9 @@ discard block |
||
| 162 | 162 | $diff = []; |
| 163 | 163 | $sum = 0; |
| 164 | 164 | foreach ($results as $reg) { |
| 165 | - $sum += (int)$reg[0]['count']; |
|
| 165 | + $sum += (int) $reg[0]['count']; |
|
| 166 | 166 | $cumulated[] = array($reg[0]['date'] * 1000, $sum); |
| 167 | - $diff[] = array($reg[0]['date'] * 1000, (int)$reg[0]['count']); |
|
| 167 | + $diff[] = array($reg[0]['date'] * 1000, (int) $reg[0]['count']); |
|
| 168 | 168 | } |
| 169 | 169 | return [ |
| 170 | 170 | $this->_wrapData($diff, ['label' => __('New')]), |
@@ -15,6 +15,9 @@ |
||
| 15 | 15 | return $hashWithSalt; |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | + /** |
|
| 19 | + * @param integer $maxLength |
|
| 20 | + */ |
|
| 18 | 21 | protected static function _generateRandomString($maxLength = null) { |
| 19 | 22 | $string = Security::generateAuthKey(); |
| 20 | 23 | if ($maxLength) { |
@@ -10,8 +10,8 @@ discard block |
||
| 10 | 10 | public function hash($password) { |
| 11 | 11 | // compare to includes/functions.inc.php generate_pw_hash() mlf 2.3 |
| 12 | 12 | $salt = self::_generateRandomString(10); |
| 13 | - $saltedHash = sha1($password . $salt); |
|
| 14 | - $hashWithSalt = $saltedHash . $salt; |
|
| 13 | + $saltedHash = sha1($password.$salt); |
|
| 14 | + $hashWithSalt = $saltedHash.$salt; |
|
| 15 | 15 | return $hashWithSalt; |
| 16 | 16 | } |
| 17 | 17 | |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | // compare to includes/functions.inc.php is_pw_correct() mlf 2.3 |
| 29 | 29 | $saltedHash = substr($hash, 0, 40); |
| 30 | 30 | $salt = substr($hash, 40, 10); |
| 31 | - if (sha1($password . $salt) == $saltedHash) : |
|
| 31 | + if (sha1($password.$salt) == $saltedHash) : |
|
| 32 | 32 | $out = true; |
| 33 | 33 | endif; |
| 34 | 34 | return $out; |
@@ -268,6 +268,7 @@ |
||
| 268 | 268 | |
| 269 | 269 | /** |
| 270 | 270 | * write the settings to the session, so that they are available on next request |
| 271 | + * @param Controller $controller |
|
| 271 | 272 | */ |
| 272 | 273 | protected function _writeSession(&$controller) { |
| 273 | 274 | if ($controller->action !== 'logout' && $controller->Auth->user()): |
@@ -305,8 +305,10 @@ |
||
| 305 | 305 | |
| 306 | 306 | if ($this->isLoggedIn()): |
| 307 | 307 | $this->_Controller->Auth->allow(); |
| 308 | - else: |
|
| 308 | + else { |
|
| 309 | + : |
|
| 309 | 310 | $this->_Controller->Auth->deny(); |
| 311 | + } |
|
| 310 | 312 | endif; |
| 311 | 313 | |
| 312 | 314 | $this->_Controller->Auth->autoRedirect = false; // don't redirect after Auth->login() |
@@ -203,6 +203,9 @@ |
||
| 203 | 203 | $this->_CakeEmail->config('saito'); |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | + /** |
|
| 207 | + * @param string $type |
|
| 208 | + */ |
|
| 206 | 209 | public function getPredefinedSender($type) { |
| 207 | 210 | $this->_init(); |
| 208 | 211 | return ['User' => [ |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | } |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - $this->_emailConfigExists = file_exists(APP . 'Config' . DS . 'email' . '.php'); |
|
| 71 | + $this->_emailConfigExists = file_exists(APP.'Config'.DS.'email'.'.php'); |
|
| 72 | 72 | |
| 73 | 73 | $this->_forumName = Configure::read('Saito.Settings.forum_name'); |
| 74 | 74 | |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | protected function _config($params = []) { |
| 113 | 113 | $defaults = [ |
| 114 | 114 | 'viewVars' => [ |
| 115 | - 'webroot' => Router::fullBaseUrl() . $this->_webroot, |
|
| 115 | + 'webroot' => Router::fullBaseUrl().$this->_webroot, |
|
| 116 | 116 | ], |
| 117 | 117 | ]; |
| 118 | 118 | $params = array_merge_recursive($defaults, $params); |
@@ -650,7 +650,7 @@ discard block |
||
| 650 | 650 | * @param null $id |
| 651 | 651 | * @param null $toggle |
| 652 | 652 | * |
| 653 | - * @return translated |
|
| 653 | + * @return null|string |
|
| 654 | 654 | */ |
| 655 | 655 | public function ajax_toggle($id = null, $toggle = null) { |
| 656 | 656 | $this->autoLayout = false; |
@@ -781,6 +781,9 @@ discard block |
||
| 781 | 781 | } |
| 782 | 782 | } |
| 783 | 783 | |
| 784 | + /** |
|
| 785 | + * @param string $type |
|
| 786 | + */ |
|
| 784 | 787 | protected function _incrementViews($entry, $type = null) { |
| 785 | 788 | if ($this->CurrentUser->isBot()) { |
| 786 | 789 | return; |
@@ -947,6 +950,9 @@ discard block |
||
| 947 | 950 | $this->set('rootEntry', $_rootEntry); |
| 948 | 951 | } |
| 949 | 952 | |
| 953 | + /** |
|
| 954 | + * @param string $type |
|
| 955 | + */ |
|
| 950 | 956 | protected function _setTitleFromEntry($entry, $type = null) { |
| 951 | 957 | if ($type === null) { |
| 952 | 958 | $template = __(':subject | :category'); |
@@ -43,8 +43,8 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | $currentPage = 1; |
| 45 | 45 | if (isset($this->request->named['page']) && $this->request->named['page'] != 1) { |
| 46 | - $currentPage = (int)$this->request->named['page']; |
|
| 47 | - $this->set('title_for_layout', __('page') . ' ' . $currentPage); |
|
| 46 | + $currentPage = (int) $this->request->named['page']; |
|
| 47 | + $this->set('title_for_layout', __('page').' '.$currentPage); |
|
| 48 | 48 | } |
| 49 | 49 | if ($currentPage === 1 && $this->CurrentUser->isLoggedIn() |
| 50 | 50 | && $this->CurrentUser['user_automaticaly_mark_as_read'] |
@@ -146,11 +146,11 @@ discard block |
||
| 146 | 146 | public function source($id = null) { |
| 147 | 147 | $this->autoRender = false; |
| 148 | 148 | |
| 149 | - $data = $this->requestAction('/entries/view/' . $id); |
|
| 149 | + $data = $this->requestAction('/entries/view/'.$id); |
|
| 150 | 150 | |
| 151 | 151 | $out = array(); |
| 152 | 152 | $out[] = '<pre style="white-space: pre-wrap;">'; |
| 153 | - $out[] = $data['Entry']['subject'] . "\n"; |
|
| 153 | + $out[] = $data['Entry']['subject']."\n"; |
|
| 154 | 154 | $out[] = $data['Entry']['text']; |
| 155 | 155 | $out[] = '</pre>'; |
| 156 | 156 | return implode("\n", $out); |
@@ -233,9 +233,9 @@ discard block |
||
| 233 | 233 | |
| 234 | 234 | return json_encode( |
| 235 | 235 | [ |
| 236 | - 'id' => (int)$newPosting['Entry']['id'], |
|
| 237 | - 'pid' => (int)$newPosting['Entry']['pid'], |
|
| 238 | - 'tid' => (int)$newPosting['Entry']['tid'] |
|
| 236 | + 'id' => (int) $newPosting['Entry']['id'], |
|
| 237 | + 'pid' => (int) $newPosting['Entry']['pid'], |
|
| 238 | + 'tid' => (int) $newPosting['Entry']['tid'] |
|
| 239 | 239 | ] |
| 240 | 240 | ); |
| 241 | 241 | } else { |
@@ -336,8 +336,8 @@ discard block |
||
| 336 | 336 | } |
| 337 | 337 | } |
| 338 | 338 | |
| 339 | - $this->set('is_answer', (int)$this->request->data['Entry']['pid'] !== 0); |
|
| 340 | - $this->set('is_inline', (int)$this->request->data['Entry']['pid'] !== 0); |
|
| 339 | + $this->set('is_answer', (int) $this->request->data['Entry']['pid'] !== 0); |
|
| 340 | + $this->set('is_inline', (int) $this->request->data['Entry']['pid'] !== 0); |
|
| 341 | 341 | $this->set('form_id', $this->request->data['Entry']['pid']); |
| 342 | 342 | $this->_setAddViewVars(); |
| 343 | 343 | } |
@@ -439,7 +439,7 @@ discard block |
||
| 439 | 439 | ); |
| 440 | 440 | $this->set('notis', $notis); |
| 441 | 441 | |
| 442 | - $this->set('is_answer', (int)$this->request->data['Entry']['pid'] !== 0); |
|
| 442 | + $this->set('is_answer', (int) $this->request->data['Entry']['pid'] !== 0); |
|
| 443 | 443 | $this->set('is_inline', false); |
| 444 | 444 | $this->set('form_id', $this->request->data['Entry']['pid']); |
| 445 | 445 | |
@@ -487,7 +487,7 @@ discard block |
||
| 487 | 487 | $this->redirect('/'); |
| 488 | 488 | } else { |
| 489 | 489 | $this->Session->setFlash(__('delete_subtree_success'), 'flash/success'); |
| 490 | - $this->redirect('/entries/view/' . $entry['Entry']['pid']); |
|
| 490 | + $this->redirect('/entries/view/'.$entry['Entry']['pid']); |
|
| 491 | 491 | } |
| 492 | 492 | } else { |
| 493 | 493 | $this->Session->setFlash(__('delete_tree_error'), 'flash/error'); |
@@ -587,16 +587,16 @@ discard block |
||
| 587 | 587 | else : |
| 588 | 588 | // validation errors |
| 589 | 589 | foreach ($errors as $field => $error) { |
| 590 | - $message = __d('nondynamic', $field) . ": " . __d( 'nondynamic', $error[0]); |
|
| 590 | + $message = __d('nondynamic', $field).": ".__d('nondynamic', $error[0]); |
|
| 591 | 591 | $this->JsData->addAppJsMessage( |
| 592 | 592 | $message, |
| 593 | 593 | [ |
| 594 | 594 | 'type' => 'error', |
| 595 | 595 | 'channel' => 'form', |
| 596 | - 'element' => '#Entry' . array_reduce( |
|
| 596 | + 'element' => '#Entry'.array_reduce( |
|
| 597 | 597 | explode('_', $field), |
| 598 | - function ($carry, $item) { |
|
| 599 | - return $carry . ucfirst($item); |
|
| 598 | + function($carry, $item) { |
|
| 599 | + return $carry.ucfirst($item); |
|
| 600 | 600 | }, |
| 601 | 601 | '' |
| 602 | 602 | ) |
@@ -626,7 +626,7 @@ discard block |
||
| 626 | 626 | $this->Entry->contain(); |
| 627 | 627 | $data = $this->Entry->findById($id); |
| 628 | 628 | |
| 629 | - if (!$data || (int)$data['Entry']['pid'] !== 0) { |
|
| 629 | + if (!$data || (int) $data['Entry']['pid'] !== 0) { |
|
| 630 | 630 | throw new NotFoundException(); |
| 631 | 631 | } |
| 632 | 632 | |
@@ -635,7 +635,7 @@ discard block |
||
| 635 | 635 | $targetId = $this->request->data['Entry']['targetId']; |
| 636 | 636 | $this->Entry->id = $id; |
| 637 | 637 | if ($this->Entry->threadMerge($targetId)) { |
| 638 | - $this->redirect('/entries/view/' . $id); |
|
| 638 | + $this->redirect('/entries/view/'.$id); |
|
| 639 | 639 | return; |
| 640 | 640 | } else { |
| 641 | 641 | $this->Session->setFlash(__("Error"), 'flash/error'); |
@@ -676,10 +676,10 @@ discard block |
||
| 676 | 676 | //* let's toggle |
| 677 | 677 | $this->Entry->id = $id; |
| 678 | 678 | $this->request->data = $this->Entry->toggle($toggle); |
| 679 | - return ($this->request->data == 0) ? __d('nondynamic', $toggle . '_set_entry_link') : __d('nondynamic', $toggle . '_unset_entry_link'); |
|
| 679 | + return ($this->request->data == 0) ? __d('nondynamic', $toggle.'_set_entry_link') : __d('nondynamic', $toggle.'_unset_entry_link'); |
|
| 680 | 680 | } |
| 681 | 681 | |
| 682 | - $this->set('json_data', (string)$this->request->data); |
|
| 682 | + $this->set('json_data', (string) $this->request->data); |
|
| 683 | 683 | $this->render('/Elements/json/json_data'); |
| 684 | 684 | } |
| 685 | 685 | |
@@ -925,7 +925,7 @@ discard block |
||
| 925 | 925 | // … directly in entries/mix |
| 926 | 926 | || $this->request->action === 'mix' |
| 927 | 927 | // … inline viewing … on entries/index. |
| 928 | - || ( $this->localReferer('controller') === 'entries' && $this->localReferer('action') === 'index') |
|
| 928 | + || ($this->localReferer('controller') === 'entries' && $this->localReferer('action') === 'index') |
|
| 929 | 929 | ): |
| 930 | 930 | $showAnsweringPanel = true; |
| 931 | 931 | endif; |
@@ -934,7 +934,7 @@ discard block |
||
| 934 | 934 | } |
| 935 | 935 | |
| 936 | 936 | protected function _setRootEntry($entry) { |
| 937 | - if ((int)$entry['Entry']['pid'] !== 0) { |
|
| 937 | + if ((int) $entry['Entry']['pid'] !== 0) { |
|
| 938 | 938 | $_rootEntry = $this->Entry->find('first', |
| 939 | 939 | [ |
| 940 | 940 | 'contain' => false, |
@@ -949,9 +949,9 @@ discard block |
||
| 949 | 949 | |
| 950 | 950 | protected function _setTitleFromEntry($entry, $type = null) { |
| 951 | 951 | if ($type === null) { |
| 952 | - $template = __(':subject | :category'); |
|
| 952 | + $template = __(':subject | :category'); |
|
| 953 | 953 | } else { |
| 954 | - $template = __(':subject (:type) | :category'); |
|
| 954 | + $template = __(':subject (:type) | :category'); |
|
| 955 | 955 | } |
| 956 | 956 | $this->set('title_for_layout', |
| 957 | 957 | CakeText::insert($template, |
@@ -242,7 +242,8 @@ discard block |
||
| 242 | 242 | $this->_stop(); |
| 243 | 243 | } |
| 244 | 244 | // answering through POST request |
| 245 | - else : |
|
| 245 | + else { |
|
| 246 | + : |
|
| 246 | 247 | if ($this->localReferer('action') === 'mix') { |
| 247 | 248 | // answer request came from mix ansicht |
| 248 | 249 | $this->redirect( |
@@ -253,6 +254,7 @@ discard block |
||
| 253 | 254 | '#' => $this->Entry->id |
| 254 | 255 | ] |
| 255 | 256 | ); |
| 257 | + } |
|
| 256 | 258 | |
| 257 | 259 | } else { |
| 258 | 260 | // normal posting from entries/add or entries/view |
@@ -267,7 +269,8 @@ discard block |
||
| 267 | 269 | } |
| 268 | 270 | return; |
| 269 | 271 | endif; |
| 270 | - else : |
|
| 272 | + else { |
|
| 273 | + : |
|
| 271 | 274 | // Error while trying to save a post |
| 272 | 275 | if (count($this->Entry->validationErrors) === 0) { |
| 273 | 276 | $this->Session->setFlash( |
@@ -276,6 +279,7 @@ discard block |
||
| 276 | 279 | ), |
| 277 | 280 | 'flash/error' |
| 278 | 281 | ); |
| 282 | + } |
|
| 279 | 283 | } |
| 280 | 284 | endif; |
| 281 | 285 | |
@@ -584,10 +588,12 @@ discard block |
||
| 584 | 588 | ); |
| 585 | 589 | $entry = $this->dic->newInstance('\Saito\Posting\Posting', ['rawData' => $newEntry]); |
| 586 | 590 | $this->set('entry', $entry); |
| 587 | - else : |
|
| 591 | + else { |
|
| 592 | + : |
|
| 588 | 593 | // validation errors |
| 589 | 594 | foreach ($errors as $field => $error) { |
| 590 | 595 | $message = __d('nondynamic', $field) . ": " . __d( 'nondynamic', $error[0]); |
| 596 | + } |
|
| 591 | 597 | $this->JsData->addAppJsMessage( |
| 592 | 598 | $message, |
| 593 | 599 | [ |
@@ -176,10 +176,16 @@ |
||
| 176 | 176 | $this->set(compact('month', 'year')); |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | + /** |
|
| 180 | + * @param string $string |
|
| 181 | + */ |
|
| 179 | 182 | protected function _sanitize($string) { |
| 180 | 183 | return Sanitize::escape($string, $this->Entry->useDbConfig); |
| 181 | 184 | } |
| 182 | 185 | |
| 186 | + /** |
|
| 187 | + * @param string[] $params |
|
| 188 | + */ |
|
| 183 | 189 | protected function _filterQuery($params) { |
| 184 | 190 | $this->request->query = array_intersect_key($this->request->query, |
| 185 | 191 | array_fill_keys($params, 1)); |
@@ -79,8 +79,8 @@ discard block |
||
| 79 | 79 | $order = '`Entry`.`time` DESC'; |
| 80 | 80 | $fields = '*'; |
| 81 | 81 | if ($query['order'] === 'rank') { |
| 82 | - $order = 'rating DESC, ' . $order; |
|
| 83 | - $fields = $fields . ", (MATCH (Entry.subject) AGAINST ('$q' IN BOOLEAN MODE)*2) + (MATCH (Entry.text) AGAINST ('$q' IN BOOLEAN MODE)) + (MATCH (Entry.name) AGAINST ('$q' IN BOOLEAN MODE)*4) AS rating"; |
|
| 82 | + $order = 'rating DESC, '.$order; |
|
| 83 | + $fields = $fields.", (MATCH (Entry.subject) AGAINST ('$q' IN BOOLEAN MODE)*2) + (MATCH (Entry.text) AGAINST ('$q' IN BOOLEAN MODE)) + (MATCH (Entry.name) AGAINST ('$q' IN BOOLEAN MODE)*4) AS rating"; |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | // query |
@@ -152,8 +152,8 @@ discard block |
||
| 152 | 152 | 'Y-m-d H:i:s', |
| 153 | 153 | mktime(0, 0, 0, $month, 1, $year)); |
| 154 | 154 | |
| 155 | - if (isset($query['category_id']) && (int)$query['category_id'] !== 0) { |
|
| 156 | - if (!isset($categories[(int)$query['category_id']])) { |
|
| 155 | + if (isset($query['category_id']) && (int) $query['category_id'] !== 0) { |
|
| 156 | + if (!isset($categories[(int) $query['category_id']])) { |
|
| 157 | 157 | throw new NotFoundException; |
| 158 | 158 | } |
| 159 | 159 | } else { |
@@ -28,6 +28,9 @@ discard block |
||
| 28 | 28 | } |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | + /** |
|
| 32 | + * @param string $data |
|
| 33 | + */ |
|
| 31 | 34 | protected function _statusAsEventStream($data) { |
| 32 | 35 | // time in ms to next request |
| 33 | 36 | $_retry = '10000'; |
@@ -40,6 +43,9 @@ discard block |
||
| 40 | 43 | return $_out; |
| 41 | 44 | } |
| 42 | 45 | |
| 46 | + /** |
|
| 47 | + * @param string $data |
|
| 48 | + */ |
|
| 43 | 49 | protected function _statusAsJson($data) { |
| 44 | 50 | if ($this->request->is('ajax') === false) { |
| 45 | 51 | throw new BadRequestException(); |
@@ -36,7 +36,7 @@ |
||
| 36 | 36 | $this->response->disableCache(); |
| 37 | 37 | $_out = ''; |
| 38 | 38 | $_out .= "retry: $_retry\n"; |
| 39 | - $_out .= 'data: ' . $data . "\n\n"; |
|
| 39 | + $_out .= 'data: '.$data."\n\n"; |
|
| 40 | 40 | return $_out; |
| 41 | 41 | } |
| 42 | 42 | |