Skip to content

Commit

Permalink
dev
Browse files Browse the repository at this point in the history
  • Loading branch information
skeeks-semenov committed Oct 4, 2019
1 parent f91d9ac commit 15de4ce
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 4 deletions.
9 changes: 9 additions & 0 deletions src/config/console.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,16 @@
'baseUrl' => '',
//'hostInfo' => 'https://demo.ru'
]
],

'controllerMap' => [
'migrate' => [
'class' => 'yii\console\controllers\MigrateController',
'migrationPath' => [
'@app/migrations',
'@skeeks/cms/migrations',
],
],
]
];

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 28.08.2015
*/

use yii\db\Schema;
use yii\db\Migration;

class m191004_015515__alter_table__cms_content_element extends Migration
{

public function safeUp()
{
$this->addColumn("{{%cms_content_element}}", "seo_h1", $this->string(255)->notNull());
$this->createIndex("seo_h1", "{{%cms_content_element}}", "seo_h1");
}

public function safeDown()
{
echo "m191004_015515__alter_table__cms_content_element cannot be reverted.\n";
return false;
}
}
26 changes: 26 additions & 0 deletions src/migrations/m191004_015615__alter_table__cms_tree.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 28.08.2015
*/

use yii\db\Schema;
use yii\db\Migration;

class m191004_015615__alter_table__cms_tree extends Migration
{

public function safeUp()
{
$this->addColumn("{{%cms_tree}}", "seo_h1", $this->string(255)->notNull());
$this->createIndex("seo_h1", "{{%cms_tree}}", "seo_h1");
}

public function safeDown()
{
echo "m191004_015515__alter_table__cms_content_element cannot be reverted.\n";
return false;
}
}
20 changes: 20 additions & 0 deletions src/models/CmsContentElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
* @property string $meta_title
* @property string $meta_description
* @property string $meta_keywords
* @property string $seo_h1
*
* @property integer $parent_content_element_id version > 2.4.8
*
Expand Down Expand Up @@ -87,6 +88,7 @@
*
* @property CmsContentElement2cmsUser[] $cmsContentElement2cmsUsers
* @property CmsUser[] $usersToFavorites
* @property string $seoName
*
*/
class CmsContentElement extends RelatedElementModel
Expand Down Expand Up @@ -224,6 +226,7 @@ public function attributeLabels()
'treeIds' => Yii::t('skeeks/cms', 'Additional sections'),
'parent_content_element_id' => Yii::t('skeeks/cms', 'Parent element'),
'show_counter' => Yii::t('skeeks/cms', 'Number of views'),
'seo_h1' => Yii::t('skeeks/cms', 'SEO заголовок h1'),
]);
}
/**
Expand All @@ -233,6 +236,7 @@ public function attributeHints()
{
return array_merge(parent::attributeHints(), [
'treeIds' => Yii::t('skeeks/cms', 'You can specify some additional sections that will show your records.'),
'seo_h1' => 'Заголовок будет показан на детальной странице, в случае если его использование задано в шаблоне.'
]);
}
/**
Expand Down Expand Up @@ -261,6 +265,7 @@ public function rules()
[['description_short', 'description_full'], 'string'],
[['active'], 'string', 'max' => 1],
[['name', 'code'], 'string', 'max' => 255],
[['seo_h1'], 'string', 'max' => 255],
[
['content_id', 'code'],
'unique',
Expand Down Expand Up @@ -667,6 +672,21 @@ public function copy()
throw $e;
}
}

/**
* Полное название
*
* @return string
*/
public function getSeoName()
{
$result = "";
if ($this->seo_h1) {
return $this->seo_h1;
} else {
return $this->name;
}
}
}


Expand Down
34 changes: 32 additions & 2 deletions src/models/Tree.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
* @property integer $redirect_code
* @property string $name_hidden
* @property string $view_file
* @property string $seo_h1
*
* ***
*
Expand Down Expand Up @@ -94,7 +95,8 @@
* @property CmsContentProperty2tree[] $cmsContentProperty2trees
* @property CmsContentProperty[] $cmsContentProperties
*
*
* @property string $seoName
*
* @property Tree $parent
* @property Tree[] $parents
* @property Tree[] $children
Expand Down Expand Up @@ -269,6 +271,16 @@ public function afterUpdateTree(AfterSaveEvent $event)
}


/**
* @inheritdoc
*/
public function attributeHints()
{
return array_merge(parent::attributeHints(), [
'seo_h1' => 'Заголовок будет показан на детальной странице, в случае если его использование задано в шаблоне.'
]);
}

/**
* @inheritdoc
*/
Expand Down Expand Up @@ -307,6 +319,7 @@ public function attributeLabels()
'redirect_code' => Yii::t('skeeks/cms', 'Redirect Code'),
'name_hidden' => Yii::t('skeeks/cms', 'Hidden Name'),
'view_file' => Yii::t('skeeks/cms', 'Template'),
'seo_h1' => Yii::t('skeeks/cms', 'SEO заголовок h1'),
]);
}

Expand All @@ -326,6 +339,7 @@ public function rules()
[['priority', 'tree_type_id', 'redirect_tree_id', 'redirect_code'], 'integer'],
[['code'], 'string', 'max' => 64],
[['name'], 'string', 'max' => 255],
[['seo_h1'], 'string', 'max' => 255],
[['meta_title', 'meta_description', 'meta_keywords'], 'string'],
[['meta_title'], 'string', 'max' => 500],
[['cms_site_id'], 'integer'],
Expand Down Expand Up @@ -764,7 +778,7 @@ public function gethas_children()
*
* @return string
*/
public function getfullName($glue = " / ")
public function getFullName($glue = " / ")
{
$paths = [];

Expand All @@ -790,6 +804,22 @@ public function getActiveChildren()
{
return $this->getChildren()->active();
}

/**
* Полное название
*
* @return string
*/
public function getSeoName()
{
$result = "";
if ($this->seo_h1) {
return $this->seo_h1;
} else {
return $this->name;
}
}

}


Expand Down
1 change: 1 addition & 0 deletions src/views/admin-cms-content-element/_form-seo.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/* @var $relatedModel \skeeks\cms\relatedProperties\models\RelatedPropertiesModel */
?>
<?= $form->fieldSet(\Yii::t('skeeks/cms', 'SEO')); ?>
<?= $form->field($model, 'seo_h1'); ?>
<?= $form->field($model, 'meta_title')->textarea(); ?>
<?= $form->field($model, 'meta_description')->textarea(); ?>
<?= $form->field($model, 'meta_keywords')->textarea(); ?>
Expand Down
4 changes: 3 additions & 1 deletion src/views/admin-cms-content-element/_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
<div class="row">
<div class="col-md-12">
<div class="pull-right">
<a href='<?= $model->url; ?>' target='_blank' class="btn btn-default btn-sm" title="<?= \Yii::t('skeeks/cms', 'Watch to site (opens new window)'); ?>"><i class="glyphicon glyphicon-arrow-right"></i></a>
<a href='<?= $model->url; ?>' target='_blank' class="btn btn-default btn-sm" title="<?= \Yii::t('skeeks/cms', 'Watch to site (opens new window)'); ?>">
<i class="fas fa-external-link-alt"></i>
</a>
</div>

</div>
Expand Down
6 changes: 5 additions & 1 deletion src/views/admin-tree/_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@
</a>
</div>
<div class="pull-right">

<a href="<?= $model->url ?>" target="_blank" class="btn-xs btn btn-secondary btn-default"
title="<?= Yii::t('skeeks/cms', 'Watch to site (opens new window)') ?>">
<i class="fas fa-external-link-alt"></i>
</a>
</div>
</div>
</div>
Expand Down Expand Up @@ -258,6 +261,7 @@
<?= $form->fieldSetEnd() ?>

<?= $form->fieldSet(\Yii::t('skeeks/cms', 'SEO')); ?>
<?= $form->field($model, 'seo_h1'); ?>
<?= $form->field($model, 'meta_title')->textarea(); ?>
<?= $form->field($model, 'meta_description')->textarea(); ?>
<?= $form->field($model, 'meta_keywords')->textarea(); ?>
Expand Down

0 comments on commit 15de4ce

Please sign in to comment.