public static function seoManagerCreate($controller, $action, $item_id)
 {
     $seo = Seo::model()->findByAttributes(array('controller' => $controller, 'action' => $action, 'item_id' => $item_id));
     if (!$seo) {
         $model = new Seo();
         $model->controller = $controller;
         $model->action = $action;
         $model->item_id = $item_id;
         $model->save();
     }
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Seo();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Seo'])) {
         $model->attributes = $_POST['Seo'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->Objid));
         }
     }
     $this->render('create', array('model' => $model));
 }
 public function actionSeo()
 {
     //empty object by default
     $seo = null;
     //find all seo in db
     $seoArr = Seo::model()->findAll();
     //if array not empty
     if (!empty($seoArr)) {
         //get first
         $seo = $seoArr[0];
     } else {
         //create new array
         $seo = new Seo();
         $seo->save();
     }
     //render form
     $this->render('seo', array('seo' => $seo));
 }
Exemple #4
0
 public function checkUrl($url)
 {
     $seo = array();
     if (!empty($url)) {
         if (Seo::model()->countByAttributes(array('url' => $url)) <= 0) {
             $new = new Seo();
             $new->url = $url;
             $new->save();
             $seo['title'] = CHtml::encode($this->pageTitle) . ' - Happy Momments';
             $seo['keywords'] = 'праздник, фотограф, свадьба, видеооператор, HM Агент';
             $seo['description'] = 'Все для организации праздника';
             $seo['top_text'] = '';
             $seo['bottom_text'] = '';
             return $seo;
         } else {
             $meta = Seo::model()->findByAttributes(array('url' => $url));
             if (!is_null($meta->title)) {
                 $seo['title'] = CHtml::encode($meta->title) . ' - Happy Momments';
             } else {
                 $seo['title'] = CHtml::encode($this->pageTitle) . ' - Happy Momments';
             }
             if (!is_null($meta->keywords)) {
                 $seo['keywords'] = CHtml::encode($meta->keywords);
             } else {
                 $seo['keywords'] = 'праздник, фотограф, свадьба, видеооператор, HM Агент';
             }
             if (!is_null($meta->description)) {
                 $seo['description'] = CHtml::encode($meta->description);
             } else {
                 $seo['description'] = 'Все для организации праздника';
             }
             if (!is_null($meta->description)) {
                 $seo['top_text'] = CHtml::encode($meta->top_text);
             } else {
                 $seo['top_text'] = '';
             }
             if (!is_null($meta->description)) {
                 $seo['bottom_text'] = CHtml::encode($meta->bottom_text);
             } else {
                 $seo['bottom_text'] = '';
             }
             return $seo;
         }
     } else {
         $seo['title'] = CHtml::encode($this->pageTitle) . ' - Happy Momments';
         $seo['keywords'] = 'праздник, фотограф, свадьба, видеооператор, HM Агент';
         $seo['description'] = 'Все для организации праздника';
         $seo['top_text'] = '';
         $seo['bottom_text'] = '';
         return $seo;
     }
 }