public function actionView($id)
 {
     if (Yii::app()->user->checkAccess('viewInternalLinkKeyword') == false) {
         throw new CHttpException(403);
     }
     $internalLinkKeyword = InternalLinkKeyword::model()->findByPk($id);
     if (is_null($internalLinkKeyword)) {
         throw new CHttpException(404);
     }
     $relatedList = $internalLinkKeyword->getRelatedList();
     $this->breadcrumbs = array('内链关键词' => array('index'), '查看');
     $this->render('view', array('internalLinkKeyword' => $internalLinkKeyword, 'relatedList' => $relatedList));
 }
示例#2
0
 public function actionSetting()
 {
     if (Yii::app()->user->checkAccess('updateSetting') == false) {
         throw new CHttpException(403);
     }
     $normalCodes = array('system_maintaining', 'footer_js', 'google_analytics_account', 'google_analytics_password', 'google_analytics_report_id');
     $multilangCodes = array('home_title', 'home_internal_link_keywords', 'inside_title', 'magazine_footer', 'copyright', 'address', 'email', 'meta_keywords', 'meta_description');
     $models = array();
     foreach ($normalCodes as $code) {
         $models[$code] = Setting::model()->findByAttributes(array('code' => $code));
     }
     foreach ($multilangCodes as $code) {
         $models[$code] = Setting::model()->multilingual()->findByAttributes(array('code' => $code));
     }
     // robots.txt
     $robotsFilePath = Helper::mediaPath('robots.txt', FRONTEND);
     if (file_exists($robotsFilePath)) {
         $robots = file_get_contents($robotsFilePath);
     } else {
         if (is_writable($robotsFilePath)) {
             $handle = fopen($robotsFilePath, 'a');
             if ($handle != false) {
                 $fp = fopen($robotsFilePath, 'w');
                 fclose($fp);
             }
             $robots = '';
         } else {
             $robots = '';
         }
     }
     if ($_POST) {
         foreach (array_merge($normalCodes, $multilangCodes) as $code) {
             if (isset($_POST[$code])) {
                 $models[$code]->setAttributes($_POST[$code]);
             } else {
                 $models[$code]->setAttributes(array('value' => ''));
             }
         }
         if (isset($models['home_internal_link_keywords'])) {
             $models['home_internal_link_keywords']['value'] = Helper::arrangeKeywords($_POST['home_internal_link_keywords']['value']);
         }
         foreach ($models as $model) {
             $model->save();
         }
         // 首页内链关键词
         if (isset($models['home_internal_link_keywords'])) {
             foreach (I18nHelper::getFrontendLanguages(false) as $lang => $attr) {
                 if ($lang == I18nHelper::getFrontendSourceLanguage()) {
                     InternalLinkKeyword::model()->insertOrUpdate('home', 0, $lang, $models['home_internal_link_keywords']['value']);
                 } else {
                     InternalLinkKeyword::model()->insertOrUpdate('home', 0, $lang, $models['home_internal_link_keywords']->i18nFormData['value_' . $lang]);
                 }
             }
         }
         // robots.txt
         if (is_writable($robotsFilePath)) {
             $robots = Yii::app()->request->getPost('robots');
             $handle = fopen($robotsFilePath, 'a');
             if ($handle != false) {
                 $fp = fopen($robotsFilePath, 'w');
                 fwrite($handle, $robots);
                 fclose($fp);
             }
         }
         $this->setFlashMessage('系统设置已保存');
         $this->redirect($this->getReturnUrl());
     }
     $this->breadcrumbs = array('系统设置');
     $this->render('setting', array('models' => $models, 'robots' => $robots, 'returnUrl' => $this->getReturnUrl()));
 }
示例#3
0
 protected function afterDelete()
 {
     // 删除内链关键词
     InternalLinkKeyword::model()->deleteAllByAttributes(array('related_type' => 'page', 'related_id' => $this->page_id));
     parent::afterDelete();
 }