Ejemplo n.º 1
0
 public function __construct($id, $module = null)
 {
     $language = Yii::app()->request->getParam('language', DEFAULT_LANGUAGE);
     DwHelper::SetLanguage($language);
     //set meta data
     $this->keywords = LuxSeo::getParam('keywords');
     $this->title = LuxSeo::getParam('title');
     $this->description = LuxSeo::getParam('description');
     parent::__construct($id, $module);
 }
Ejemplo n.º 2
0
 public static function getParam($type = 'title')
 {
     /* @var $seo LuxSeo */
     $seoArr = LuxSeo::model()->findAll();
     $seo = $seoArr[0];
     $result = "";
     if ($seo != null) {
         switch ($type) {
             case 'title':
                 $jsonArr = $seo->site_title;
                 $arr = json_decode($jsonArr, true);
                 $result = $arr[$language = Yii::app()->language];
                 break;
             case 'keywords':
                 $jsonArr = $seo->site_keywords;
                 $arr = json_decode($jsonArr, true);
                 $result = $arr[$language = Yii::app()->language];
                 break;
             case 'description':
                 $jsonArr = $seo->site_description;
                 $arr = json_decode($jsonArr, true);
                 $result = $arr[$language = Yii::app()->language];
                 break;
         }
     }
     return $result;
 }
Ejemplo n.º 3
0
 public function actionUpdateseo()
 {
     /* @var $seo LuxSeo*/
     //get id from request
     $id = Yii::app()->request->getParam('id', null);
     //get params from request
     $keywords = Yii::app()->request->getParam('keywords', null);
     $title = Yii::app()->request->getParam('title', null);
     $description = Yii::app()->request->getParam('description', null);
     $keywords_json = json_encode($keywords);
     $title_json = json_encode($title);
     $description_json = json_encode($description);
     //if id not given - redirect to index
     if ($id == null) {
         $this->redirect($this->createUrl('/admin/inlux/index'));
     }
     //find record by id
     $seo = LuxSeo::model()->findByPk($id);
     //if error by some mysterious reasons - send user to index
     if ($seo == null) {
         $this->redirect($this->createUrl('/admin/inlux/index'));
     }
     //update
     $seo->site_description = $description_json;
     $seo->site_title = $title_json;
     $seo->site_keywords = $keywords_json;
     $seo->update();
     //redirect back
     $this->redirect($this->createUrl('/admin/inlux/seo'));
 }