Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

доработка sitemap #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions config/admin/menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
return (bool) (\Yii::$app->request->getUrl() == $adminMenuItem->getUrl());
},
],
[
"label" => \Yii::t('app', "Sitemap"),
"url" => ["seo/admin-sitemap-task"],
"img" => ['\skeeks\cms\modules\admin\assets\AdminAsset', 'images/icons/settings-big.png'],
],
],
],
]
Expand Down
31 changes: 31 additions & 0 deletions controllers/AdminSitemapTaskController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
/**
* created by Ekilei <ekilei@rusoft.ru>
*/
namespace skeeks\cms\seo\controllers;

use skeeks\cms\modules\admin\controllers\AdminModelEditorController;
use skeeks\cms\seo\models\SeoSitemapTask;
use skeeks\modules\cms\form2\models\Form2Form;
use yii\helpers\ArrayHelper;

class AdminSitemapTaskController extends AdminModelEditorController
{
public function init()
{
$this->name = \Yii::t('skeeks/seo',"Managing Sitemap Task");
$this->modelShowAttribute = "id";
$this->modelClassName = SeoSitemapTask::className();

parent::init();
}

public function actions()
{
return ArrayHelper::merge(parent::actions(),
[

]
);
}
}
15 changes: 15 additions & 0 deletions messages/ru/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,19 @@
'The minimum length of the keyword, which is listed by the key (automatic generation)' => 'Минимальная длина ключевого слова, которое попадает в список ключевых (при автоматической генерации)',
'The maximum length of the string of keywords (automatic generation)' => 'Максимальная длина строки ключевых слов (при автоматической генерации)',
'This value is added to the automatically generated file robots.txt, in the case where it is not physically created on the server' => 'Это значение будет добавлено в автоматически сгенерированный файл robots.txt, в том случае если его не будет физически создано на сервере',
'from smallest to largest' => 'от меньшего к большему',
'from highest to lowest' => 'от большего к меньшему',
'Created By' => 'Выбор записей пользователей',
'Added' => 'Добавлен',
'Site' => 'Сайт',
'File Path' => 'Путь к файлу',
'Active' => 'Активность',
'On' => 'Вкл',
'Off' => 'Выкл',
'Tree' => 'Дерево',
'Contents' => 'Контенты',
'Display' => 'Отображение',
'Pagination' => 'Постраничная навигация',
'Basic information' => 'Основная информация',
'Additional information' => 'Дополнительная информация',
];
53 changes: 53 additions & 0 deletions migrations/m160809_161616_create_table__seo_sitemap_task.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php
class m160809_161616_create_table__seo_sitemap_task extends yii\db\Migration
{
const TABLE_NAME = '{{%seo_sitemap_task}}';
public function up()
{
$tableOptions = null;
$tableExist = $this->db->getTableSchema(self::TABLE_NAME, true);
if ($tableExist)
{
return true;
}
$tableOptions = null;
if ($this->db->driverName === 'mysql') {
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
}
$this->createTable(self::TABLE_NAME, [
'id' => $this->primaryKey(),
'created_by' => $this->integer(),
'updated_by' => $this->integer(),
'created_at' => $this->integer(),
'updated_at' => $this->integer(),

'cms_site_id' => $this->integer()->notNull(),
'file_path' => $this->string(255)->defaultValue("sitemap.xml")->notNull()->unique(),
'is_tree' => $this->integer(1)->unsigned()->notNull()->defaultValue(1)->comment('0-off,1-on'),
'content_ids' => $this->text(),
'active' => $this->integer(1)->unsigned()->notNull()->defaultValue(1)->comment('0-off,1-on'),
], $tableOptions);

$this->addForeignKey(
'seo_sitemap_task__created_by', self::TABLE_NAME,
'created_by', '{{%cms_user}}', 'id', 'SET NULL', 'SET NULL'
);

$this->addForeignKey(
'seo_sitemap_task__updated_by', self::TABLE_NAME,
'updated_by', '{{%cms_user}}', 'id', 'SET NULL', 'SET NULL'
);

$this->addForeignKey(
'seo_sitemap_task__cms_site_id', self::TABLE_NAME,
'cms_site_id', '{{%cms_site}}', 'id', 'RESTRICT', 'RESTRICT'
);
}
public function down()
{
$this->dropIndex('seo_sitemap_task__created_by', self::TABLE_NAME);
$this->dropIndex('seo_sitemap_task__updated_by', self::TABLE_NAME);
$this->dropIndex('seo_sitemap_task__cms_site_id', self::TABLE_NAME);
$this->dropTable(self::TABLE_NAME);
}
}
86 changes: 86 additions & 0 deletions models/SeoSitemapTask.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?php
/**
* created by Ekilei <ekilei@rusoft.ru>
*/
namespace skeeks\cms\seo\models;

use skeeks\cms\models\CmsContentType;
use skeeks\cms\models\CmsSite;
use yii\helpers\ArrayHelper;

/**
* This is the model class for table "{{%seo_sitemap_task}}".
*
* @property integer $id
* @property integer $created_by
* @property integer $updated_by
* @property integer $created_at
* @property integer $updated_at
*
* @property integer $cms_site_id
* @property string $file_path
* @property integer $is_tree
* @property string $content_ids
* @property integer $active
*
* @property User $processedBy
* @property CmsContent $content
* @property User $createdBy
* @property CmsContentElement $element
* @property CmsSite $siteCode
* @property CmsSite $site
*/

class SeoSitemapTask extends \skeeks\cms\models\Core
{
public $verifyCode;

CONST ON = 1;
CONST OFF = 0;

/**
* @inheritdoc
*/
public static function tableName()
{
return '{{%seo_sitemap_task}}';
}

static public function getActive()
{
return [
self::ON => \Yii::t('skeeks/seo',"On"),
self::OFF => \Yii::t('skeeks/seo',"Off"),
];
}

public function rules()
{
return ArrayHelper::merge(parent::rules(), [
[['file_path','content_ids'],'string'],
[['cms_site_id','is_tree','active'],'integer'],
[['file_path'],'unique'],
]);
}

/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => \Yii::t('skeeks/seo', 'ID'),
'created_by' => \Yii::t('skeeks/seo', 'Created By'),
'updated_by' => \Yii::t('skeeks/seo', 'Updated By'),
'created_at' => \Yii::t('skeeks/seo', 'Created At'),
'updated_at' => \Yii::t('skeeks/seo', 'Updated At'),
'cms_site_id' => \Yii::t('skeeks/seo', 'Site'),
'file_path' => \Yii::t('skeeks/seo', 'File Path'),
'is_tree' => \Yii::t('skeeks/seo', 'Tree'),
'content_ids' => \Yii::t('skeeks/seo', 'Contents'),
'active' => \Yii::t('skeeks/seo', 'Active'),
];
}


}
104 changes: 104 additions & 0 deletions views/admin-sitemap-task/_form.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?php

use yii\helpers\Html;
use skeeks\cms\modules\admin\widgets\form\ActiveFormUseTab as ActiveForm;
use skeeks\cms\seo\models\SeoSitemapTask;
/* @var $this yii\web\View */
/* @var $action \skeeks\cms\modules\admin\actions\modelEditor\AdminOneModelEditAction */
/* @var $model \skeeks\cms\seo\models\SeoSitemapTask */

?>

<? $form = ActiveForm::begin(); ?>

<?= $form->fieldSet(\Yii::t('skeeks/seo','Basic information')); ?>

<?= $form->field($model, 'active')->checkbox(); ?>

<?= $form->field($model, 'cms_site_id')->dropDownList(\yii\helpers\ArrayHelper::map(
\skeeks\cms\models\CmsSite::find()->all(), 'id', 'name'
));
?>

<?= $form->field($model, 'file_path')->textInput(['maxlength' => 255]) ?>

<?= $form->field($model, 'is_tree')->checkbox(); ?>

<?= $form->fieldSelectMulti($model, 'content_ids', \skeeks\cms\models\CmsContent::getDataForSelect()); ?>



<?= $form->fieldSetEnd(); ?>

<? if (!$model->isNewRecord) : ?>
<?= $form->fieldSet(\Yii::t('skeeks/seo','Additional information')); ?>
<?= \yii\widgets\DetailView::widget([
'model' => $model,
'attributes' =>
[
[
'attribute' => 'id',
'label' => \Yii::t('skeeks/seo','Id'),
],

[
'attribute' => 'created_at',
'value' => \Yii::$app->formatter->asDatetime($model->created_at, 'medium') . "(" . \Yii::$app->formatter->asRelativeTime($model->created_at) . ")",
],

]
]); ?>

<?= $form->fieldSetEnd(); ?>



<?= $form->fieldSet(\Yii::t('skeeks/seo','For developers')); ?>

<div class="sx-block">
<h3><?=\Yii::t('skeeks/seo','Additional information that may be useful in some cases, the developers.');?></h3>
<small><?=\Yii::t('skeeks/seo','For the convenience of viewing the data, you can use the service');?>: <a href="http://jsonformatter.curiousconcept.com/#" target="_blank">http://jsonformatter.curiousconcept.com/#</a></small>
</div>
<hr />


<?= \yii\widgets\DetailView::widget([
'model' => $model,
'attributes' =>
[
[
'attribute' => 'data_server',
'format' => 'raw',
'label' => 'SERVER',
'value' => "<textarea class='form-control' rows=\"10\">" . \yii\helpers\Json::encode($model->data_server) . "</textarea>"
],

[
'attribute' => 'data_cookie',
'format' => 'raw',
'label' => 'COOKIE',
'value' => "<textarea class='form-control' rows=\"5\">" . \yii\helpers\Json::encode($model->data_cookie) . "</textarea>"
],

[
'attribute' => 'data_session',
'format' => 'raw',
'label' => 'SESSION',
'value' => "<textarea class='form-control' rows=\"5\">" . \yii\helpers\Json::encode($model->data_session) . "</textarea>"
],

[
'attribute' => 'data_request',
'format' => 'raw',
'label' => 'REQUEST',
'value' => "<textarea class='form-control' rows=\"10\">" . \yii\helpers\Json::encode($model->data_request) . "</textarea>"
],

]
]); ?>

<?= $form->fieldSetEnd(); ?>
<? endif; ?>
<?= $form->buttonsStandart($model); ?>

<? ActiveForm::end(); ?>
27 changes: 27 additions & 0 deletions views/admin-sitemap-task/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
/**
* created by Ekilei <ekilei@rusoft.ru>
*/
?>
<?= \skeeks\cms\modules\admin\widgets\GridViewStandart::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'adminController' => $controller,
'isOpenNewWindow' => $isOpenNewWindow ? true : false,
'columns' => [
[
'class' => \skeeks\cms\grid\CreatedAtColumn::className(),
'label' => \Yii::t('skeeks/seo','Added')
],
[
'class' => \skeeks\cms\grid\CreatedByColumn::className(),
],

[
'attribute' => 'cms_site_id',
'class' => \skeeks\cms\grid\SiteColumn::className(),
],
['attribute' => 'file_path'],
['attribute' => 'active'],
],
]); ?>