@@ -2,9 +2,7 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace Apps\ActiveRecord; |
| 4 | 4 | |
| 5 | -use Ffcms\Core\App; |
|
| 6 | 5 | use Ffcms\Core\Arch\ActiveModel; |
| 7 | -use Ffcms\Core\Helper\Date; |
|
| 8 | 6 | |
| 9 | 7 | /** |
| 10 | 8 | * Class UserLog. Active record model. |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | $this->cache = $cfg['cache']; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - $this->_cacheName = 'widget.newcomment.' . $this->createStringClassSnapshotHash(); |
|
| 42 | + $this->_cacheName = 'widget.newcomment.'.$this->createStringClassSnapshotHash(); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /** |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | { |
| 54 | 54 | // work with cache and make query |
| 55 | 55 | $records = null; |
| 56 | - if ((int)$this->cache > 0) { |
|
| 56 | + if ((int) $this->cache > 0) { |
|
| 57 | 57 | if (App::$Cache->get($this->_cacheName) !== null) { |
| 58 | 58 | $records = App::$Cache->get($this->_cacheName); |
| 59 | 59 | } else { |
@@ -10,21 +10,21 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | class Contenttag extends AbstractWidget |
| 12 | 12 | { |
| 13 | - use ClassTools; |
|
| 13 | + use ClassTools; |
|
| 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 | - private $_lang; |
|
| 20 | + private $_lang; |
|
| 21 | 21 | private $_cacheName; |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Set default configurations if not defined |
|
| 25 | - * {@inheritDoc} |
|
| 26 | - * @see \Ffcms\Core\Arch\Widget::init() |
|
| 27 | - */ |
|
| 23 | + /** |
|
| 24 | + * Set default configurations if not defined |
|
| 25 | + * {@inheritDoc} |
|
| 26 | + * @see \Ffcms\Core\Arch\Widget::init() |
|
| 27 | + */ |
|
| 28 | 28 | public function init() |
| 29 | 29 | { |
| 30 | 30 | $cfg = $this->getConfigs(); |
@@ -50,27 +50,27 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | public function display() |
| 52 | 52 | { |
| 53 | - // get records rows from cache or directly from db |
|
| 54 | - $records = null; |
|
| 55 | - if ($this->cache === 0) { |
|
| 56 | - $records = $this->makeQuery(); |
|
| 57 | - } else { |
|
| 58 | - $records = App::$Cache->get($this->_cacheName); |
|
| 53 | + // get records rows from cache or directly from db |
|
| 54 | + $records = null; |
|
| 55 | + if ($this->cache === 0) { |
|
| 56 | + $records = $this->makeQuery(); |
|
| 57 | + } else { |
|
| 58 | + $records = App::$Cache->get($this->_cacheName); |
|
| 59 | 59 | if ($records === null) { |
| 60 | - $records = $this->makeQuery(); |
|
| 61 | - App::$Cache->set($this->_cacheName, $records, $this->cache); |
|
| 62 | - } |
|
| 63 | - } |
|
| 60 | + $records = $this->makeQuery(); |
|
| 61 | + App::$Cache->set($this->_cacheName, $records, $this->cache); |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - // check if result is not empty |
|
| 65 | + // check if result is not empty |
|
| 66 | 66 | if ($records === null || $records->count() < 1) { |
| 67 | 67 | return __('Content tags is not found'); |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | // render view |
| 71 | - return App::$View->render($this->tpl, [ |
|
| 72 | - 'records' => $records |
|
| 73 | - ]); |
|
| 71 | + return App::$View->render($this->tpl, [ |
|
| 72 | + 'records' => $records |
|
| 73 | + ]); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | /** |
@@ -80,12 +80,12 @@ discard block |
||
| 80 | 80 | private function makeQuery() |
| 81 | 81 | { |
| 82 | 82 | return TagRecord::select([ |
| 83 | - App::$Database->getConnection()->raw('SQL_CALC_FOUND_ROWS tag'), |
|
| 84 | - App::$Database->getConnection()->raw('COUNT(*) AS count') |
|
| 85 | - ])->where('lang', '=', $this->_lang) |
|
| 83 | + App::$Database->getConnection()->raw('SQL_CALC_FOUND_ROWS tag'), |
|
| 84 | + App::$Database->getConnection()->raw('COUNT(*) AS count') |
|
| 85 | + ])->where('lang', '=', $this->_lang) |
|
| 86 | 86 | ->groupBy('tag') |
| 87 | - ->orderBy('count', 'DESC') |
|
| 88 | - ->take($this->count) |
|
| 89 | - ->get(); |
|
| 87 | + ->orderBy('count', 'DESC') |
|
| 88 | + ->take($this->count) |
|
| 89 | + ->get(); |
|
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | 92 | \ No newline at end of file |
@@ -30,15 +30,15 @@ |
||
| 30 | 30 | $cfg = $this->getConfigs(); |
| 31 | 31 | // check cache is defined |
| 32 | 32 | if ($this->cache === null || !Obj::isLikeInt($this->cache)) { |
| 33 | - $this->cache = (int)$cfg['cache']; |
|
| 33 | + $this->cache = (int) $cfg['cache']; |
|
| 34 | 34 | } |
| 35 | 35 | // check tag count is defined |
| 36 | 36 | if ($this->count === null || !Obj::isLikeInt($this->count)) { |
| 37 | - $this->count = (int)$cfg['count']; |
|
| 37 | + $this->count = (int) $cfg['count']; |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | $this->_lang = App::$Request->getLanguage(); |
| 41 | - $this->_cacheName = 'widget.contenttag.' . $this->createStringClassSnapshotHash(); |
|
| 41 | + $this->_cacheName = 'widget.contenttag.'.$this->createStringClassSnapshotHash(); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /** |
@@ -34,14 +34,14 @@ |
||
| 34 | 34 | } |
| 35 | 35 | // check cache is defined |
| 36 | 36 | if ($this->cache === null || !Obj::isLikeInt($this->cache)) { |
| 37 | - $this->cache = (int)$cfg['cache']; |
|
| 37 | + $this->cache = (int) $cfg['cache']; |
|
| 38 | 38 | } |
| 39 | 39 | // check item count is defined |
| 40 | 40 | if ($this->count === null || !Obj::isLikeInt($this->count)) { |
| 41 | - $this->count = (int)$cfg['count']; |
|
| 41 | + $this->count = (int) $cfg['count']; |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - $this->_cacheName = 'widget.newcontent.' . $this->createStringClassSnapshotHash(); |
|
| 44 | + $this->_cacheName = 'widget.newcontent.'.$this->createStringClassSnapshotHash(); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
@@ -1,7 +1,7 @@ |
||
| 1 | 1 | <?php return [ |
| 2 | - 'instances' => [ |
|
| 3 | - 'Apps\Controller\Front\Content::buildSitemapSchedule' => 10800, |
|
| 4 | - 'Apps\Controller\Front\Profile::buildSitemapSchedule' => 10800, |
|
| 5 | - 'Apps\Controller\Front\Profile::cleanupTablesSchedule' => 86400 |
|
| 6 | - ] |
|
| 2 | + 'instances' => [ |
|
| 3 | + 'Apps\Controller\Front\Content::buildSitemapSchedule' => 10800, |
|
| 4 | + 'Apps\Controller\Front\Profile::buildSitemapSchedule' => 10800, |
|
| 5 | + 'Apps\Controller\Front\Profile::cleanupTablesSchedule' => 86400 |
|
| 6 | + ] |
|
| 7 | 7 | ]; |
| 8 | 8 | \ No newline at end of file |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | /** set default locale */ |
| 15 | 15 | $_GET['lang'] = 'en'; |
| 16 | 16 | |
| 17 | -require_once(root . '/Loader/Autoload.php'); |
|
| 17 | +require_once(root.'/Loader/Autoload.php'); |
|
| 18 | 18 | |
| 19 | 19 | // make fast-access alias \App::$Object |
| 20 | 20 | // class_alias('Ffcms\Core\App', 'App'); |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | $cronManager = new \Ffcms\Core\Managers\CronManager(\App::$Properties->getAll('Cron')); |
| 42 | 42 | $logs = $cronManager->run(); |
| 43 | 43 | if ($logs !== null && \Ffcms\Core\Helper\Type\Obj::isArray($logs) && count($logs) > 0) { |
| 44 | - echo 'Run cron tasks: ' . PHP_EOL . implode(PHP_EOL, $logs); |
|
| 44 | + echo 'Run cron tasks: '.PHP_EOL.implode(PHP_EOL, $logs); |
|
| 45 | 45 | } else { |
| 46 | 46 | echo 'No tasks runned'; |
| 47 | 47 | } |