/** * Конструктор * @return bool */ protected function beforeAction() { $this->layout = 'start_page'; $this->topMenu = Mainmenu::getMenu('top', 'site'); $this->middleMenu = Mainmenu::getMenu('middle', 'site'); $this->listChat = Chat::getListChat(); $this->randomArt = Articles::getRandomArticles(10); $this->tags = Tags::getMenu(Tags::model()->findAll()); $settingChat = Settings::model()->findByAttributes(array('parameter' => Yii::app()->params['parameter']['chat'])); $this->stateChat = null != $settingChat ? (int) $settingChat->value : 0; if (!Yii::app()->user->isGuest) { $this->_user = Users::model()->findByPk(Yii::app()->user->id); } else { $this->_loginModel = new LoginForm(); } return true; }
/** * Возвращает строку или массив из тегов * @param $tags * @param bool $arr * @return array|string */ public static function getTagsList($tags, $arr = true) { if ($arr) { $tagsArray = array(); foreach ($tags as $key => $tag) { if (!empty($tag['idTag0']['textTag'])) { $tagsArray[$key]['idTag'] = $tag['idTag0']['idTag']; $tagsArray[$key]['textTag'] = $tag['idTag0']['textTag']; } } $resultArray = Tags::getMenu($tagsArray); return $resultArray; } else { $tmpArray = array(); foreach ($tags as $tag) { if (!empty($tag['idTag0']['textTag'])) { $tmpArray[] = $tag['idTag0']['textTag']; } } $tagsString = implode(",", $tmpArray); return $tagsString; } }