Skip to content

Commit

Permalink
Merge pull request #201 from s-nakajima/master
Browse files Browse the repository at this point in the history
多言語化対応(is_original_copyフィールド追加)
  • Loading branch information
s-nakajima committed Jan 17, 2017
2 parents ac5dfef + 3ef6ac8 commit dd36f47
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Config/Migration/001_plugin_records.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class PluginRecords extends NetCommonsMigration {
//日本語
array(
'language_id' => '2',
'is_origin' => true,
'is_translation' => true,
'key' => 'questionnaires',
'namespace' => 'netcommons/questionnaires',
'default_action' => 'questionnaires/index',
Expand All @@ -57,6 +59,8 @@ class PluginRecords extends NetCommonsMigration {
//英語
array(
'language_id' => '1',
'is_origin' => false,
'is_translation' => true,
'key' => 'questionnaires',
'namespace' => 'netcommons/questionnaires',
'default_action' => 'questionnaires/index',
Expand Down
79 changes: 79 additions & 0 deletions Config/Migration/1484546423_add_is_original_copy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php
/**
* 多言語化対応
*
* @author Shohei Nakajima <nakajimashouhei@gmail.com>
* @link http://www.netcommons.org NetCommons Project
* @license http://www.netcommons.org/license.txt NetCommons License
* @copyright Copyright 2014, NetCommons Project
*/

App::uses('NetCommonsMigration', 'NetCommons.Config/Migration');

/**
* 多言語化対応
*
* @author Shohei Nakajima <nakajimashouhei@gmail.com>
* @package NetCommons\Questionnaires\Config\Migration
*/
class AddIsOriginalCopy extends NetCommonsMigration {

/**
* Migration description
*
* @var string
*/
public $description = 'add_is_original_copy';

/**
* Actions to be performed
*
* @var array $migration
*/
public $migration = array(
'up' => array(
'create_field' => array(
'questionnaire_choices' => array(
'is_original_copy' => array('type' => 'boolean', 'null' => false, 'default' => '0', 'comment' => 'オリジナルのコピー。言語を新たに追加したときに使用する', 'after' => 'is_translation'),
),
'questionnaire_pages' => array(
'is_original_copy' => array('type' => 'boolean', 'null' => false, 'default' => '0', 'comment' => 'オリジナルのコピー。言語を新たに追加したときに使用する', 'after' => 'is_translation'),
),
'questionnaire_questions' => array(
'is_original_copy' => array('type' => 'boolean', 'null' => false, 'default' => '0', 'comment' => 'オリジナルのコピー。言語を新たに追加したときに使用する', 'after' => 'is_translation'),
),
'questionnaires' => array(
'is_original_copy' => array('type' => 'boolean', 'null' => false, 'default' => '0', 'comment' => 'オリジナルのコピー。言語を新たに追加したときに使用する', 'after' => 'is_translation'),
),
),
),
'down' => array(
'drop_field' => array(
'questionnaire_choices' => array('is_original_copy'),
'questionnaire_pages' => array('is_original_copy'),
'questionnaire_questions' => array('is_original_copy'),
'questionnaires' => array('is_original_copy'),
),
),
);

/**
* Before migration callback
*
* @param string $direction Direction of migration process (up or down)
* @return bool Should process continue
*/
public function before($direction) {
return true;
}

/**
* After migration callback
*
* @param string $direction Direction of migration process (up or down)
* @return bool Should process continue
*/
public function after($direction) {
return true;
}
}
4 changes: 4 additions & 0 deletions Config/Schema/schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public function after($event = array()) {
'language_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => false),
'is_origin' => array('type' => 'boolean', 'null' => false, 'default' => '1', 'comment' => 'オリジナルかどうか'),
'is_translation' => array('type' => 'boolean', 'null' => false, 'default' => '0', 'comment' => '翻訳したかどうか'),
'is_original_copy' => array('type' => 'boolean', 'null' => false, 'default' => '0', 'comment' => 'オリジナルのコピー。言語を新たに追加したときに使用する'),
'matrix_type' => array('type' => 'integer', 'null' => true, 'default' => null, 'length' => 4, 'unsigned' => false, 'comment' => 'マトリックスタイプの場合の行列区分 | 0:行 | 1:列'),
'other_choice_type' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => 4, 'unsigned' => false, 'comment' => 'その他欄か否か、また、その他欄の入力エリアタイプ | 0:その他欄でない | 1:テキストタイプを伴ったその他欄 | 2:テキストエリアタイプを伴ったその他欄
Expand Down Expand Up @@ -184,6 +185,7 @@ public function after($event = array()) {
'language_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => false),
'is_origin' => array('type' => 'boolean', 'null' => false, 'default' => '1', 'comment' => 'オリジナルかどうか'),
'is_translation' => array('type' => 'boolean', 'null' => false, 'default' => '0', 'comment' => '翻訳したかどうか'),
'is_original_copy' => array('type' => 'boolean', 'null' => false, 'default' => '0', 'comment' => 'オリジナルのコピー。言語を新たに追加したときに使用する'),
'questionnaire_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => false, 'key' => 'index'),
'page_title' => array('type' => 'string', 'null' => true, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'ページ名', 'charset' => 'utf8'),
'route_number' => array('type' => 'integer', 'null' => false, 'default' => '0', 'unsigned' => false),
Expand All @@ -210,6 +212,7 @@ public function after($event = array()) {
'language_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => false),
'is_origin' => array('type' => 'boolean', 'null' => false, 'default' => '1', 'comment' => 'オリジナルかどうか'),
'is_translation' => array('type' => 'boolean', 'null' => false, 'default' => '0', 'comment' => '翻訳したかどうか'),
'is_original_copy' => array('type' => 'boolean', 'null' => false, 'default' => '0', 'comment' => 'オリジナルのコピー。言語を新たに追加したときに使用する'),
'question_sequence' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => false, 'comment' => '質問表示順'),
'question_value' => array('type' => 'string', 'null' => true, 'default' => null, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
'question_type' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 4, 'unsigned' => false, 'comment' => '質問タイプ | 1:択一選択 | 2:複数選択 | 3:テキスト | 4:テキストエリア | 5:マトリクス(択一) | 6:マトリクス(複数) | 7:日付・時刻 | 8:リスト
Expand Down Expand Up @@ -250,6 +253,7 @@ public function after($event = array()) {
'language_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => false),
'is_origin' => array('type' => 'boolean', 'null' => false, 'default' => '1', 'comment' => 'オリジナルかどうか'),
'is_translation' => array('type' => 'boolean', 'null' => false, 'default' => '0', 'comment' => '翻訳したかどうか'),
'is_original_copy' => array('type' => 'boolean', 'null' => false, 'default' => '0', 'comment' => 'オリジナルのコピー。言語を新たに追加したときに使用する'),
'is_active' => array('type' => 'boolean', 'null' => false, 'default' => '0', 'comment' => '公開中データか否か'),
'is_latest' => array('type' => 'boolean', 'null' => false, 'default' => '0', 'comment' => '最新編集データであるか否か'),
'block_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => false, 'key' => 'index'),
Expand Down
1 change: 1 addition & 0 deletions TestSuite/QuestionnairesSaveTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public function testSave($data) {
'id' => $id,
'is_origin' => true,
'is_translation' => false,
'is_original_copy' => false,
)
);
$expected[$this->$model->alias] = Hash::remove($expected[$this->$model->alias], 'modified');
Expand Down

0 comments on commit dd36f47

Please sign in to comment.