Commit 73f3c29d by semenov

new module

parent 2e4e323d
<?php
/**
* Module
*
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010-2014 SkeekS (Sx)
* @date 31.10.2014
* @since 1.0.0
* @copyright 2010 SkeekS (СкикС)
* @date 07.03.2015
*/
namespace skeeks\modules\cms\game;
namespace skeeks\modules\cms\form;
use skeeks\cms\base\Module as CmsModule;
use skeeks\cms\App;
use yii\helpers\Inflector;
/**
* Class Module
......@@ -30,22 +25,6 @@ class Module extends CmsModule
return array_merge(parent::_descriptor(), [
"name" => "Модуль форм",
"description" => "Модуль прорабатывает модель данных игрового портала. Поставляет модели Игра, Игровой жанр, Игровая платформа, Игровая компания (разработчик, издатель)",
"admin" =>
[
"items" =>
[
[
"label" => "Конструктор форм",
"route" => ["form/admin-form"]
],
[
"label" => "Сообщения с форм",
"route" => ["form/admin-form"]
],
]
]
]);
}
......
<?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 07.03.2015
*/
return [];
\ No newline at end of file
<?php
/**
* main
*
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010-2014 SkeekS (Sx)
* @date 20.01.2015
* @since 1.0.0
*/
return [
'components' =>
[
'adminMenu' =>
[
'groups' =>
[
'form' =>
[
'label' => 'Конструктор форм',
'priority' => 0,
'items' =>
[
[
"label" => "Формы",
"url" => ["form/admin-form"]
],
[
"label" => "Сообщения с форм",
"url" => ["form/admin-message"]
],
]
]
]
]
],
'modules' =>
[
'form' => [
'class' => '\skeeks\modules\cms\form\Module',
]
]
];
\ No newline at end of file
<?php
/**
* AdminInfoblockController
*
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010-2014 SkeekS (Sx)
* @date 09.11.2014
* @since 1.0.0
*/
namespace skeeks\modules\cms\form\controllers;
use skeeks\cms\modules\admin\controllers\AdminModelEditorSmartController;
use skeeks\modules\cms\form\models\Form;
/**
* Class AdminFormController
* @package skeeks\modules\cms\form\controllers
*/
class AdminFormController extends AdminModelEditorSmartController
{
public function init()
{
$this->_label = "Управление формами";
$this->_modelShowAttribute = "name";
$this->_modelClassName = Form::className();
$this->modelValidate = true;
$this->enableScenarios = true;
parent::init();
}
}
\ No newline at end of file
<?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 07.03.2015
*/
use yii\db\Schema;
use yii\db\Migration;
class m150307_162718_create_form_table extends Migration
{
public function up()
{
$tableExist = $this->db->getTableSchema("{{%form_form}}", true);
if ($tableExist)
{
return true;
}
$tableOptions = null;
if ($this->db->driverName === 'mysql') {
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
}
$this->createTable("{{%form_form}}", [
'id' => Schema::TYPE_PK,
'created_by' => Schema::TYPE_INTEGER . ' NULL',
'updated_by' => Schema::TYPE_INTEGER . ' NULL',
'created_at' => Schema::TYPE_INTEGER . ' NULL',
'updated_at' => Schema::TYPE_INTEGER . ' NULL',
'name' => Schema::TYPE_STRING . '(255) NOT NULL',
'description' => Schema::TYPE_TEXT . ' NULL',
'emails' => Schema::TYPE_TEXT . ' NULL',
'phones' => Schema::TYPE_TEXT . ' NULL',
], $tableOptions);
$this->execute("ALTER TABLE {{%form_form}} ADD INDEX(updated_by);");
$this->execute("ALTER TABLE {{%form_form}} ADD INDEX(created_by);");
$this->execute("ALTER TABLE {{%form_form}} ADD INDEX(created_at);");
$this->execute("ALTER TABLE {{%form_form}} ADD INDEX(updated_at);");
$this->execute("ALTER TABLE {{%form_form}} ADD INDEX(name);");
$this->execute("ALTER TABLE {{%form_form}} COMMENT = 'Конструктор форм';");
$this->addForeignKey(
'form_form_created_by', "{{%form_form}}",
'created_by', '{{%cms_user}}', 'id', 'RESTRICT', 'RESTRICT'
);
$this->addForeignKey(
'form_form_updated_by', "{{%form_form}}",
'updated_by', '{{%cms_user}}', 'id', 'RESTRICT', 'RESTRICT'
);
}
public function down()
{
$this->dropForeignKey("form_form_created_by", "{{%form_form}}");
$this->dropForeignKey("form_form_updated_by", "{{%form_form}}");
$this->dropTable("{{%form_form}}");
}
}
<?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 07.03.2015
*/
namespace skeeks\modules\cms\form\models;
use skeeks\cms\base\db\ActiveRecord;
use skeeks\cms\models\behaviors\HasDescriptionsBehavior;
use skeeks\cms\models\behaviors\HasStatus;
use skeeks\cms\models\behaviors\Implode;
use skeeks\cms\models\Core;
/**
* Class Form
* @package skeeks\modules\cms\form\models
*/
class Form extends Core
{
/**
* @inheritdoc
*/
public static function tableName()
{
return '{{%form_form}}';
}
/**
* @inheritdoc
*/
public function behaviors()
{
return array_merge(parent::behaviors(), [
[
"class" => Implode::className(),
'fields' => ['emails', 'phones']
],
]);
}
/**
* @inheritdoc
*/
public function rules()
{
return array_merge(parent::rules(), [
[['name'], 'required'],
[['name', 'description'], 'string'],
[['emails', 'phones'], 'safe'],
]);
}
public function scenarios()
{
$scenarios = parent::scenarios();
$scenarios['create'] = ['name', 'description', 'emails', 'phones'];
$scenarios['update'] = ['name', 'description', 'emails', 'phones'];
return $scenarios;
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return array_merge(parent::attributeLabels(), [
'id' => \Yii::t('app', 'ID'),
'name' => \Yii::t('app', 'Name'),
'description' => \Yii::t('app', 'Description'),
]);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment