Esempio n. 1
0
    public function metaTags()
    {
        $key = get_class($this->owner) . '_' . $this->owner->primaryKey;
        if (!isset(self::$_meta_tags[$key]))
        {
            $meta_tags = array(
                "title"       => "",
                "description" => "",
                "keywords"    => ""
            );

            $meta_data = MetaTag::model()->findByAttributes(array(
                'object_id' => $this->owner->primaryKey,
                'model_id'  => get_class($this->owner)
            ));

            if ($meta_data)
            {
                $meta_tags["title"]       = $meta_data->title;
                $meta_tags["description"] = $meta_data->description;
                $meta_tags["keywords"]    = $meta_data->keywords;
            }

            self::$_meta_tags[$key] = $meta_tags;
        }

        return self::$_meta_tags[$key];
    }
Esempio n. 2
0
    protected function preFilter($filterChain)
    {
        $controller = $filterChain->controller;
        if ($this instanceof AdminController)
        {
            return true;
        }

        if ($id = Yii::app()->request->getParam("id"))
        {
            $class = $controller->getModelClass();

            $meta_tag = MetaTag::model()->findByAttributes(array(
                'model_id'  => $class,
                'object_id' => $id
            ));

            if ($meta_tag)
            {
                $controller->meta_title       = $meta_tag->title;
                $controller->meta_keywords    = $meta_tag->keywords;
                $controller->meta_description = $meta_tag->description;
            }
        }
        return true;
    }
Esempio n. 3
0
 public function setMetaTags($model)
 {
     $meta_tag = MetaTag::model()->findByAttributes(array('model_id' => get_class($model), 'object_id' => $model->id));
     if ($meta_tag) {
         $this->meta_title = $meta_tag->title;
         $this->meta_keywords = $meta_tag->keywords;
         $this->meta_description = $meta_tag->description;
     }
 }
Esempio n. 4
0
 public function run()
 {
     $model = new MetaTag();
     if (!$this->model->isNewRecord) {
         $meta_tag = MetaTag::model()->findByAttributes(array('object_id' => $this->model->id, 'model_id' => get_class($this->model)));
         if ($meta_tag) {
             $model = $meta_tag;
         }
     }
     $this->renderDialog('MetaTags', array('model' => $model, 'dialogOptions' => array('title' => 'Мета-Теги'), 'linkOptions' => array('class' => 'btn btn-info')));
 }
Esempio n. 5
0
 public function afterDelete($event)
 {
     MetaTag::model()->deleteAllByAttributes(array('object_id' => $this->owner->id, 'model_id' => get_class($this->owner)));
     return parent::afterDelete($event);
 }
 public function actionGetMetaTagData($model_id, $object_id, $tag)
 {
     echo CJSON::encode(MetaTag::model()->findByAttributes(array('model_id' => $model_id, 'object_id' => $object_id, 'tag' => $tag)));
 }
Esempio n. 7
0
<?php

$this->page_title = t('Просмотр страницы');
$this->tabs = ['редактировать' => $this->createUrl('update', ['id' => $model->id]), 'список страниц' => $this->createUrl('manage')];
$languages = Language::getList();
$this->widget('AdminDetailView', ['data' => $model, 'attributes' => ['title', 'url', ['name' => 'date_create', 'value' => date('d.m.Y h:i', strtotime($model->date_create))], ['label' => t('Мета-теги'), 'value' => MetaTag::model()->html($model->id, get_class($model)), 'type' => 'raw'], ['name' => 'language', 'value' => $languages[$model->language]], ['name' => 'text', 'type' => 'raw', 'value' => $model->text], ['label' => 'Тэги', 'type' => 'raw', 'value' => Tag::getString(get_class($model), $model->id)]]]);
Esempio n. 8
0
 public function setMetaTags($modelOrConfig)
 {
     if ($modelOrConfig instanceof CActiveRecord)
     {
         $meta_tag = MetaTag::model()->findByAttributes(array(
             'model_id'  => get_class($modelOrConfig),
             'object_id' => $modelOrConfig->getPrimaryKey()
         ));
         if ($meta_tag)
         {
             $meta_tag = array(
                 'title'       => $meta_tag->title,
                 'description' => $meta_tag->description,
                 'keywords'    => $meta_tag->keywords
             );
         }
     }
     else
     {
         $meta_tag = $modelOrConfig;
     }
     foreach ((array)$meta_tag as $key => $val)
     {
         if (is_string($val))
         {
             Yii::app()->clientScript->registerMetaTag($val, $key);
         }
     }
 }