@@ -25,7 +25,7 @@ |
||
| 25 | 25 | */ |
| 26 | 26 | public function get() |
| 27 | 27 | { |
| 28 | - return App::$Alias->scriptUrl . '/api/captcha/gregwar?time=' . microtime(true) . '&lang=' . App::$Request->getLanguage(); |
|
| 28 | + return App::$Alias->scriptUrl.'/api/captcha/gregwar?time='.microtime(true).'&lang='.App::$Request->getLanguage(); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | /** |
@@ -39,9 +39,9 @@ discard block |
||
| 39 | 39 | public function get() |
| 40 | 40 | { |
| 41 | 41 | // build google captcha ;) |
| 42 | - $html = '<div class="g-recaptcha" data-sitekey="' . self::$siteKey . '"></div> |
|
| 42 | + $html = '<div class="g-recaptcha" data-sitekey="'.self::$siteKey.'"></div> |
|
| 43 | 43 | <script type="text/javascript" |
| 44 | - src="https://www.google.com/recaptcha/api.js?hl=' . App::$Request->getLanguage() . '"> |
|
| 44 | + src="https://www.google.com/recaptcha/api.js?hl=' . App::$Request->getLanguage().'"> |
|
| 45 | 45 | </script>'; |
| 46 | 46 | return $html; |
| 47 | 47 | } |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | ]); |
| 65 | 65 | |
| 66 | 66 | // make request and parse response |
| 67 | - $url = $request->getSchemeAndHttpHost() . $request->getRequestUri(); |
|
| 67 | + $url = $request->getSchemeAndHttpHost().$request->getRequestUri(); |
|
| 68 | 68 | $response = Url::getRemoteContent($url); |
| 69 | 69 | $object = json_decode($response); |
| 70 | 70 | |
@@ -58,6 +58,9 @@ |
||
| 58 | 58 | ]); |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | + /** |
|
| 62 | + * @return string |
|
| 63 | + */ |
|
| 61 | 64 | private function makeQuery() |
| 62 | 65 | { |
| 63 | 66 | return TagRecord::select([ |
@@ -10,12 +10,12 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | class Contenttag extends AbstractWidget |
| 12 | 12 | { |
| 13 | - use OopTools; |
|
| 13 | + use OopTools; |
|
| 14 | 14 | |
| 15 | - public $count; |
|
| 16 | - public $cache; |
|
| 15 | + public $count; |
|
| 16 | + public $cache; |
|
| 17 | 17 | |
| 18 | - public $tpl = 'widgets/contenttag/default'; |
|
| 18 | + public $tpl = 'widgets/contenttag/default'; |
|
| 19 | 19 | |
| 20 | 20 | public function init() |
| 21 | 21 | { |
@@ -33,39 +33,39 @@ discard block |
||
| 33 | 33 | public function display() |
| 34 | 34 | { |
| 35 | 35 | // get special properties hash |
| 36 | - $classHash = $this->createStringClassSnapshotHash(); |
|
| 36 | + $classHash = $this->createStringClassSnapshotHash(); |
|
| 37 | 37 | |
| 38 | - // get records rows from cache or directly from db |
|
| 39 | - $records = null; |
|
| 40 | - if ($this->cache === 0) { |
|
| 41 | - $records = $this->makeQuery(); |
|
| 42 | - } else { |
|
| 43 | - $records === App::$Cache->get('widget.contenttag.' . $classHash); |
|
| 44 | - if ($records === null) { |
|
| 45 | - $records = $this->makeQuery(); |
|
| 46 | - App::$Cache->set('widget.contenttag' . $classHash, $records, $this->cache); |
|
| 47 | - } |
|
| 48 | - } |
|
| 38 | + // get records rows from cache or directly from db |
|
| 39 | + $records = null; |
|
| 40 | + if ($this->cache === 0) { |
|
| 41 | + $records = $this->makeQuery(); |
|
| 42 | + } else { |
|
| 43 | + $records === App::$Cache->get('widget.contenttag.' . $classHash); |
|
| 44 | + if ($records === null) { |
|
| 45 | + $records = $this->makeQuery(); |
|
| 46 | + App::$Cache->set('widget.contenttag' . $classHash, $records, $this->cache); |
|
| 47 | + } |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - // check if result is not empty |
|
| 50 | + // check if result is not empty |
|
| 51 | 51 | if ($records === null || $records->count() < 1) { |
| 52 | 52 | return __('Content tags is not found'); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | // render view |
| 56 | - return App::$View->render($this->tpl, [ |
|
| 57 | - 'records' => $records |
|
| 58 | - ]); |
|
| 56 | + return App::$View->render($this->tpl, [ |
|
| 57 | + 'records' => $records |
|
| 58 | + ]); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | private function makeQuery() |
| 62 | 62 | { |
| 63 | 63 | return TagRecord::select([ |
| 64 | - App::$Database->getConnection()->raw('SQL_CALC_FOUND_ROWS tag'), |
|
| 65 | - App::$Database->getConnection()->raw('COUNT(*) AS count') |
|
| 66 | - ])->groupBy('tag') |
|
| 67 | - ->orderBy('count', 'DESC') |
|
| 68 | - ->take($this->count) |
|
| 69 | - ->get(); |
|
| 64 | + App::$Database->getConnection()->raw('SQL_CALC_FOUND_ROWS tag'), |
|
| 65 | + App::$Database->getConnection()->raw('COUNT(*) AS count') |
|
| 66 | + ])->groupBy('tag') |
|
| 67 | + ->orderBy('count', 'DESC') |
|
| 68 | + ->take($this->count) |
|
| 69 | + ->get(); |
|
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | \ No newline at end of file |
@@ -22,11 +22,11 @@ discard block |
||
| 22 | 22 | $cfg = $this->getConfigs(); |
| 23 | 23 | // check cache is defined |
| 24 | 24 | if ($this->cache === null || !Obj::isLikeInt($this->cache)) { |
| 25 | - $this->cache = (int)$cfg['cache']; |
|
| 25 | + $this->cache = (int) $cfg['cache']; |
|
| 26 | 26 | } |
| 27 | 27 | // check tag count is defined |
| 28 | 28 | if ($this->count === null || !Obj::isLikeInt($this->count)) { |
| 29 | - $this->count = (int)$cfg['count']; |
|
| 29 | + $this->count = (int) $cfg['count']; |
|
| 30 | 30 | } |
| 31 | 31 | } |
| 32 | 32 | |
@@ -40,10 +40,10 @@ discard block |
||
| 40 | 40 | if ($this->cache === 0) { |
| 41 | 41 | $records = $this->makeQuery(); |
| 42 | 42 | } else { |
| 43 | - $records === App::$Cache->get('widget.contenttag.' . $classHash); |
|
| 43 | + $records === App::$Cache->get('widget.contenttag.'.$classHash); |
|
| 44 | 44 | if ($records === null) { |
| 45 | 45 | $records = $this->makeQuery(); |
| 46 | - App::$Cache->set('widget.contenttag' . $classHash, $records, $this->cache); |
|
| 46 | + App::$Cache->set('widget.contenttag'.$classHash, $records, $this->cache); |
|
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | // this environment is based on json response type |
| 13 | 13 | define('env_type', 'json'); |
| 14 | 14 | |
| 15 | -require_once(root . '/Loader/Autoload.php'); |
|
| 15 | +require_once(root.'/Loader/Autoload.php'); |
|
| 16 | 16 | |
| 17 | 17 | // make fast-access alias \App::$Object |
| 18 | 18 | // class_alias('Ffcms\Core\App', 'App'); |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | // this environment is based on json response type |
| 13 | 13 | define('env_type', 'json'); |
| 14 | 14 | |
| 15 | -require_once(root . '/Loader/Autoload.php'); |
|
| 15 | +require_once(root.'/Loader/Autoload.php'); |
|
| 16 | 16 | |
| 17 | 17 | // make fast-access alias \App::$Object |
| 18 | 18 | // class_alias('Ffcms\Core\App', 'App'); |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | // this environment is based on json response type |
| 13 | 13 | define('env_type', 'json'); |
| 14 | 14 | |
| 15 | -require_once(root . '/Loader/Autoload.php'); |
|
| 15 | +require_once(root.'/Loader/Autoload.php'); |
|
| 16 | 16 | |
| 17 | 17 | // make fast-access alias \App::$Object |
| 18 | 18 | // class_alias('Ffcms\Core\App', 'App'); |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | |
| 30 | 30 | // render view output |
| 31 | 31 | return App::$View->render('index', [ |
| 32 | - 'model' => $model |
|
| 32 | + 'model' => $model |
|
| 33 | 33 | ]); |
| 34 | 34 | } |
| 35 | 35 | } |
| 36 | 36 | \ No newline at end of file |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | |
| 31 | 31 | <?php if ($useCaptcha === true) { |
| 32 | 32 | if (\App::$Captcha->isFull()) { |
| 33 | - echo '<div class="col-md-offset-3 col-md-9">' . \App::$Captcha->get() . '</div>'; |
|
| 33 | + echo '<div class="col-md-offset-3 col-md-9">'.\App::$Captcha->get().'</div>'; |
|
| 34 | 34 | } else { |
| 35 | 35 | echo $form->field('captcha', 'captcha', ['class' => 'form-control'], __('Enter data from security image to prove that you are human. If you can\'t read symbols - click on image to reload')); |
| 36 | 36 | } |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | |
| 31 | 31 | <?php if ($useCaptcha === true) { |
| 32 | 32 | if (\App::$Captcha->isFull()) { |
| 33 | - echo '<div class="col-md-offset-3 col-md-9">' . \App::$Captcha->get() . '</div>'; |
|
| 33 | + echo '<div class="col-md-offset-3 col-md-9">'.\App::$Captcha->get().'</div>'; |
|
| 34 | 34 | } else { |
| 35 | 35 | echo $form->field('captcha', 'captcha', ['class' => 'form-control'], __('Enter data from security image to prove that you are human. If you can\'t read symbols - click on image to reload')); |
| 36 | 36 | } |