diff --git a/controllers/backend/BlogCommentController.php b/controllers/backend/BlogCommentController.php index fb1447c..5510fa1 100644 --- a/controllers/backend/BlogCommentController.php +++ b/controllers/backend/BlogCommentController.php @@ -129,10 +129,14 @@ public function actionBulk() $selection = (array)Yii::$app->request->post('selection');//typecasting switch ($action) { case 'd': - if ($this->deleteAll($selection)) $message = Module::t('blog', 'Successfully delete'); + if ($this->deleteAll($selection)) { + $message = Module::t('blog', 'Successfully delete'); + } break; case 'c': - if ($this->confirmAll($selection)) $message = Module::t('blog', 'Successfully confirm'); + if ($this->confirmAll($selection)) { + $message = Module::t('blog', 'Successfully confirm'); + } break; default: $message = Module::t('blog', 'Action not found'); diff --git a/models/BlogCategory.php b/models/BlogCategory.php index 47e4e70..8096a19 100644 --- a/models/BlogCategory.php +++ b/models/BlogCategory.php @@ -103,8 +103,9 @@ static public function get($parentId = 0, $array = array(), $level = 0, $add = 2 } // i feel this is useless - if ($level > 0) + if ($level > 0) { $strRepeat .= ''; + } $newArray = array(); $tempArray = array(); @@ -112,10 +113,21 @@ static public function get($parentId = 0, $array = array(), $level = 0, $add = 2 //performance is not very good here foreach (( array )$array as $v) { if ($v['parent_id'] == $parentId) { - $newArray [] = array('id' => $v['id'], 'title' => $v['title'], 'parent_id' => $v['parent_id'], 'sort_order' => $v['sort_order'], + $newArray [] = array( + 'id' => $v['id'], + 'title' => $v['title'], + 'parent_id' => $v['parent_id'], + 'sort_order' => $v['sort_order'], 'banner' => $v->getThumbFileUrl('banner', 'thumb'), //'postsCount'=>$v['postsCount'], - 'is_nav' => $v['is_nav'], 'template' => $v['template'], - 'status' => $v->getStatus(), 'created_at' => $v['created_at'], 'updated_at' => $v['updated_at'], 'redirect_url' => $v['redirect_url'], 'str_repeat' => $strRepeat, 'str_label' => $strRepeat . $v['title'],); + 'is_nav' => $v['is_nav'], + 'template' => $v['template'], + 'status' => $v->getStatus(), + 'created_at' => $v['created_at'], + 'updated_at' => $v['updated_at'], + 'redirect_url' => $v['redirect_url'], + 'str_repeat' => $strRepeat, + 'str_label' => $strRepeat . $v['title'], + ); $tempArray = self::get($v['id'], $array, ($level + $add), $add, $repeat); if ($tempArray) { @@ -215,10 +227,11 @@ static public function getRootCategoryId($id = 0, $array = []) foreach ((array)$array as $v) { if ($v['id'] == $id) { $parentId = $v['parent_id']; - if (0 == $parentId) + if (0 == $parentId) { return $id; - else + } else { return self::getRootCategoryId($parentId, $array); + } } } } @@ -255,24 +268,27 @@ static public function getPathToRoot($id = 0, $array = array()) foreach ((array)$array as $v) { if ($v['id'] == $id) { $parent_id = $v['parent_id']; - if (self::PAGE_TYPE_LIST == $v['page_type']) + if (self::PAGE_TYPE_LIST == $v['page_type']) { $arrayResult = array($v['title'] => array('list', id => $v['id'])); - elseif (self::PAGE_TYPE_PAGE == $v['page_type']) + } elseif (self::PAGE_TYPE_PAGE == $v['page_type']) { $arrayResult = array($v['title'] => array('page', id => $v['id'])); + } } } if (0 < $parent_id) { $arrayTemp = self::getPathToRoot($parent_id, $array); - if (!empty($arrayTemp)) + if (!empty($arrayTemp)) { $arrayResult += $arrayTemp; + } } - if (!empty($arrayResult)) + if (!empty($arrayResult)) { return $arrayResult; - else + } else { return; + } } /** diff --git a/models/BlogComment.php b/models/BlogComment.php index 3dcf68e..9e2f0a1 100644 --- a/models/BlogComment.php +++ b/models/BlogComment.php @@ -131,10 +131,11 @@ public function getBlogPost() */ public function getAuthorLink() { - if (!empty($this->url)) + if (!empty($this->url)) { return Html::a(Html::encode($this->author), $this->url); - else + } else { return Html::encode($this->author); + } } /** @@ -143,8 +144,9 @@ public function getAuthorLink() */ public function getUrl($post = null) { - if ($post === null) + if ($post === null) { $post = $this->post; + } return $post->url . '#c' . $this->id; } diff --git a/models/BlogPost.php b/models/BlogPost.php index fdfe146..f1c85ed 100644 --- a/models/BlogPost.php +++ b/models/BlogPost.php @@ -234,8 +234,9 @@ public function getAbsoluteUrl() public function getTagLinks() { $links = []; - foreach (BlogTag::string2array($this->tags) as $tag) + foreach (BlogTag::string2array($this->tags) as $tag) { $links[] = Html::a($tag, Yii::$app->getUrlManager()->createUrl(['blog/default/index', 'tag' => $tag])); + } return $links; } diff --git a/models/BlogTag.php b/models/BlogTag.php index 3ee303d..487c343 100644 --- a/models/BlogTag.php +++ b/models/BlogTag.php @@ -97,8 +97,9 @@ public static function addTags($tags) public static function removeTags($tags) { - if (empty($tags)) + if (empty($tags)) { return; + } BlogTag::updateAllCounters(['frequency' => 1], 'name in ("' . implode('"," ', $tags) . '")'); BlogTag::deleteAll('frequency <= 0'); @@ -109,13 +110,15 @@ public static function findTagWeights($limit = 20) $models = BlogTag::find()->orderBy(['frequency' => SORT_DESC])->all(); $total = 0; - foreach ($models as $model) + foreach ($models as $model) { $total += $model->frequency; + } $tags = []; if ($total > 0) { - foreach ($models as $model) + foreach ($models as $model) { $tags[$model->name] = 8 + (int)(16 * $model->frequency / ($total + 10)); + } ksort($tags); } return $tags; diff --git a/views/backend/blog-comment/index.php b/views/backend/blog-comment/index.php index 8ea929f..c07f10f 100644 --- a/views/backend/blog-comment/index.php +++ b/views/backend/blog-comment/index.php @@ -84,8 +84,11 @@