Commit 3edf9a09 by semenov

new module

parent f446ae03
<?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;
use skeeks\modules\cms\form\models\FormEmail;
/**
* Class AdminFormEmailController
* @package skeeks\modules\cms\form\controllers
*/
class AdminFormEmailController extends AdminModelEditorSmartController
{
public function init()
{
$this->_label = "Управление email форм";
$this->_modelShowAttribute = "value";
$this->_modelClassName = FormEmail::className();
$this->modelValidate = true;
$this->enableScenarios = true;
parent::init();
}
}
\ 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;
use skeeks\modules\cms\form\models\FormEmail;
use skeeks\modules\cms\form\models\FormField;
use skeeks\modules\cms\form\models\FormPhone;
/**
* Class AdminFormEmailController
* @package skeeks\modules\cms\form\controllers
*/
class AdminFormFieldController extends AdminModelEditorSmartController
{
public function init()
{
$this->_label = "Управление email форм";
$this->_modelShowAttribute = "value";
$this->_modelClassName = FormField::className();
$this->modelValidate = true;
$this->enableScenarios = true;
parent::init();
}
}
\ 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;
use skeeks\modules\cms\form\models\FormEmail;
use skeeks\modules\cms\form\models\FormPhone;
/**
* Class AdminFormEmailController
* @package skeeks\modules\cms\form\controllers
*/
class AdminFormPhoneController extends AdminModelEditorSmartController
{
public function init()
{
$this->_label = "Управление email форм";
$this->_modelShowAttribute = "value";
$this->_modelClassName = FormPhone::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_162720_create_form_email_table extends Migration
{
public function up()
{
$tableExist = $this->db->getTableSchema("{{%form_email}}", 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_email}}", [
'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',
'value' => Schema::TYPE_STRING . '(255) NOT NULL',
'form_id' => Schema::TYPE_INTEGER . '(255) NOT NULL',
], $tableOptions);
$this->execute("ALTER TABLE {{%form_email}} ADD INDEX(updated_by);");
$this->execute("ALTER TABLE {{%form_email}} ADD INDEX(created_by);");
$this->execute("ALTER TABLE {{%form_email}} ADD INDEX(created_at);");
$this->execute("ALTER TABLE {{%form_email}} ADD INDEX(updated_at);");
$this->execute("ALTER TABLE {{%form_email}} ADD INDEX(value);");
$this->execute("ALTER TABLE {{%form_email}} ADD UNIQUE(form_id,value);");
$this->execute("ALTER TABLE {{%form_email}} COMMENT = 'Email адреса форм';");
$this->addForeignKey(
'form_email_created_by', "{{%form_email}}",
'created_by', '{{%cms_user}}', 'id', 'SET NULL', 'SET NULL'
);
$this->addForeignKey(
'form_email_updated_by', "{{%form_email}}",
'updated_by', '{{%cms_user}}', 'id', 'SET NULL', 'SET NULL'
);
$this->addForeignKey(
'form_email_form_id', "{{%form_email}}",
'form_id', '{{%form_form}}', 'id', 'CASCADE', 'CASCADE'
);
}
public function down()
{
$this->dropForeignKey("form_email_created_by", "{{%form_email}}");
$this->dropForeignKey("form_email_updated_by", "{{%form_email}}");
$this->dropForeignKey("form_email_form_id", "{{%form_email}}");
$this->dropTable("{{%form_email}}");
}
}
<?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_162725_create_form_phone_table extends Migration
{
public function up()
{
$tableExist = $this->db->getTableSchema("{{%form_phone}}", 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_phone}}", [
'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',
'value' => Schema::TYPE_STRING . '(255) NOT NULL',
'form_id' => Schema::TYPE_INTEGER . '(255) NOT NULL',
], $tableOptions);
$this->execute("ALTER TABLE {{%form_phone}} ADD INDEX(updated_by);");
$this->execute("ALTER TABLE {{%form_phone}} ADD INDEX(created_by);");
$this->execute("ALTER TABLE {{%form_phone}} ADD INDEX(created_at);");
$this->execute("ALTER TABLE {{%form_phone}} ADD INDEX(updated_at);");
$this->execute("ALTER TABLE {{%form_phone}} ADD INDEX(value);");
$this->execute("ALTER TABLE {{%form_phone}} ADD UNIQUE(form_id,value);");
$this->execute("ALTER TABLE {{%form_phone}} COMMENT = 'Телефоны форм';");
$this->addForeignKey(
'form_phone_created_by', "{{%form_phone}}",
'created_by', '{{%cms_user}}', 'id', 'SET NULL', 'SET NULL'
);
$this->addForeignKey(
'form_phone_updated_by', "{{%form_phone}}",
'updated_by', '{{%cms_user}}', 'id', 'SET NULL', 'SET NULL'
);
$this->addForeignKey(
'form_phone_form_id', "{{%form_phone}}",
'form_id', '{{%form_form}}', 'id', 'CASCADE', 'CASCADE'
);
}
public function down()
{
$this->dropForeignKey("form_phone_created_by", "{{%form_phone}}");
$this->dropForeignKey("form_phone_updated_by", "{{%form_phone}}");
$this->dropForeignKey("form_phone_form_id", "{{%form_phone}}");
$this->dropTable("{{%form_phone}}");
}
}
<?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_162735_create_form_field_table extends Migration
{
public function up()
{
$tableExist = $this->db->getTableSchema("{{%form_field}}", 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_field}}", [
'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',
'label' => Schema::TYPE_STRING . '(255) NULL',
'hint' => Schema::TYPE_TEXT . ' NULL',
'widget' => Schema::TYPE_TEXT . ' NULL',
'rules' => Schema::TYPE_TEXT . ' NULL',
'attribute' => Schema::TYPE_STRING . '(255) NOT NULL',
'form_id' => Schema::TYPE_INTEGER . '(255) NOT NULL',
], $tableOptions);
$this->execute("ALTER TABLE {{%form_field}} ADD INDEX(updated_by);");
$this->execute("ALTER TABLE {{%form_field}} ADD INDEX(created_by);");
$this->execute("ALTER TABLE {{%form_field}} ADD INDEX(created_at);");
$this->execute("ALTER TABLE {{%form_field}} ADD INDEX(updated_at);");
$this->execute("ALTER TABLE {{%form_field}} ADD INDEX(label);");
$this->execute("ALTER TABLE {{%form_field}} ADD UNIQUE(attribute,form_id);");
$this->execute("ALTER TABLE {{%form_field}} COMMENT = 'Элементы форм';");
$this->addForeignKey(
'form_field_created_by', "{{%form_field}}",
'created_by', '{{%cms_user}}', 'id', 'SET NULL', 'SET NULL'
);
$this->addForeignKey(
'form_field_updated_by', "{{%form_field}}",
'updated_by', '{{%cms_user}}', 'id', 'SET NULL', 'SET NULL'
);
$this->addForeignKey(
'form_field_form_id', "{{%form_field}}",
'form_id', '{{%form_form}}', 'id', 'CASCADE', 'CASCADE'
);
}
public function down()
{
$this->dropForeignKey("form_field_created_by", "{{%form_field}}");
$this->dropForeignKey("form_field_updated_by", "{{%form_field}}");
$this->dropForeignKey("form_field_form_id", "{{%form_field}}");
$this->dropTable("{{%form_field}}");
}
}
<?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_162740_create_form_send_messages_table extends Migration
{
public function up()
{
$tableExist = $this->db->getTableSchema("{{%form_send_message}}", 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_send_message}}", [
'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',
'data' => Schema::TYPE_TEXT . ' NULL',
'additional_data' => Schema::TYPE_TEXT . ' NULL',
'form_id' => Schema::TYPE_INTEGER . '(255) NULL',
], $tableOptions);
$this->execute("ALTER TABLE {{%form_send_message}} ADD INDEX(updated_by);");
$this->execute("ALTER TABLE {{%form_send_message}} ADD INDEX(created_by);");
$this->execute("ALTER TABLE {{%form_send_message}} ADD INDEX(created_at);");
$this->execute("ALTER TABLE {{%form_send_message}} ADD INDEX(updated_at);");
$this->execute("ALTER TABLE {{%form_send_message}} ADD INDEX(form_id);");
$this->execute("ALTER TABLE {{%form_send_message}} COMMENT = 'Сообщения с форм';");
$this->addForeignKey(
'form_send_message_created_by', "{{%form_send_message}}",
'created_by', '{{%cms_user}}', 'id', 'SET NULL', 'SET NULL'
);
$this->addForeignKey(
'form_send_message_updated_by', "{{%form_send_message}}",
'updated_by', '{{%cms_user}}', 'id', 'SET NULL', 'SET NULL'
);
$this->addForeignKey(
'form_send_message_form_id', "{{%form_send_message}}",
'form_id', '{{%form_form}}', 'id', 'SET NULL', 'SET NULL'
);
}
public function down()
{
$this->dropForeignKey("form_send_message_created_by", "{{%form_send_message}}");
$this->dropForeignKey("form_send_message_updated_by", "{{%form_send_message}}");
$this->dropForeignKey("form_send_message_form_id", "{{%form_send_message}}");
$this->dropTable("{{%form_send_message}}");
}
}
......@@ -8,7 +8,7 @@
use yii\db\Schema;
use yii\db\Migration;
class m150312_162718_create_form_table extends Migration
class m150307_162718_create_form_table extends Migration
{
public function up()
{
......@@ -34,11 +34,9 @@ class m150312_162718_create_form_table extends Migration
'name' => Schema::TYPE_STRING . '(255) NOT NULL',
'description' => Schema::TYPE_TEXT . ' NULL',
'template' => Schema::TYPE_TEXT . ' NULL',
'emails' => Schema::TYPE_TEXT . ' NULL',
'phones' => Schema::TYPE_TEXT . ' NULL',
'elements' => Schema::TYPE_TEXT . ' NULL',
'code' => Schema::TYPE_STRING . '(32) NULL',
], $tableOptions);
......@@ -49,6 +47,7 @@ class m150312_162718_create_form_table extends Migration
$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}} ADD UNIQUE(code);");
$this->execute("ALTER TABLE {{%form_form}} COMMENT = 'Конструктор форм';");
......
<?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 FormEmail
* @package skeeks\modules\cms\form\models
*/
class FormField extends Core
{
/**
* @inheritdoc
*/
public static function tableName()
{
return '{{%form_field}}';
}
/**
* @inheritdoc
*/
public function behaviors()
{
return array_merge(parent::behaviors(), []);
}
/**
* @inheritdoc
*/
public function rules()
{
return array_merge(parent::rules(), [
[['created_by', 'updated_by', 'created_at', 'updated_at', 'form_id'], 'integer'],
[['hint', 'widget', 'rules'], 'string'],
[['attribute', 'form_id'], 'required'],
[['label', 'attribute'], 'string', 'max' => 255],
[['attribute', 'form_id'], 'unique', 'targetAttribute' => ['attribute', 'form_id'], 'message' => 'Этот элемент уже привязан к форме']
]);
}
public function scenarios()
{
$scenarios = parent::scenarios();
$scenarios['create'] = $scenarios[self::SCENARIO_DEFAULT];
$scenarios['update'] = $scenarios[self::SCENARIO_DEFAULT];
return $scenarios;
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return array_merge(parent::attributeLabels(), [
'id' => \Yii::t('app', 'ID'),
'value' => \Yii::t('app', 'Email'),
'form_id' => \Yii::t('app', 'Форма'),
]);
}
}
\ No newline at end of file
<?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 FormPhone
* @package skeeks\modules\cms\form\models
*/
class FormPhone extends Core
{
/**
* @inheritdoc
*/
public static function tableName()
{
return '{{%form_phone}}';
}
/**
* @inheritdoc
*/
public function behaviors()
{
return array_merge(parent::behaviors(), []);
}
/**
* @inheritdoc
*/
public function rules()
{
return array_merge(parent::rules(), [
[['value', 'form_id'], 'required'],
[['value'], 'string', 'max' => 255],
[['form_id', 'value'], 'unique', 'targetAttribute' => ['form_id', 'value'], 'message' => 'Этот телефон уже привязан к этой форме'],
]);
}
public function scenarios()
{
$scenarios = parent::scenarios();
$scenarios['create'] = $scenarios[self::SCENARIO_DEFAULT];
$scenarios['update'] = $scenarios[self::SCENARIO_DEFAULT];
return $scenarios;
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return array_merge(parent::attributeLabels(), [
'id' => \Yii::t('app', 'ID'),
'value' => \Yii::t('app', 'Телефон'),
'form_id' => \Yii::t('app', 'Форма'),
]);
}
}
\ No newline at end of file
<?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 FormSendMessage
* @package skeeks\modules\cms\form\models
*/
class FormSendMessage extends Core
{
/**
* @inheritdoc
*/
public static function tableName()
{
return '{{%form_send_message}}';
}
/**
* @inheritdoc
*/
public function behaviors()
{
return array_merge(parent::behaviors(), []);
}
/**
* @inheritdoc
*/
public function rules()
{
return array_merge(parent::rules(), [
[['created_by', 'updated_by', 'created_at', 'updated_at', 'form_id'], 'integer'],
[['data', 'additional_data'], 'string']
]);
}
public function scenarios()
{
$scenarios = parent::scenarios();
$scenarios['create'] = $scenarios[self::SCENARIO_DEFAULT];
$scenarios['update'] = $scenarios[self::SCENARIO_DEFAULT];
return $scenarios;
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return array_merge(parent::attributeLabels(), [
'id' => \Yii::t('app', 'ID'),
'value' => \Yii::t('app', 'Телефон'),
'form_id' => \Yii::t('app', 'Форма'),
]);
}
}
\ 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