Skip to content

Commit

Permalink
Merge pull request #109 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 16, 2017
2 parents 59e5740 + cbfcb15 commit 16581ed
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Config/Migration/001_plugin_records.php
Expand Up @@ -45,6 +45,8 @@ class PluginRecords extends NetCommonsMigration {
//日本語
array(
'language_id' => '2',
'is_origin' => true,
'is_translation' => true,
'key' => 'bbses',
'namespace' => 'netcommons/bbses',
'name' => '掲示板',
Expand All @@ -58,6 +60,8 @@ class PluginRecords extends NetCommonsMigration {
//英語
array(
'language_id' => '1',
'is_origin' => false,
'is_translation' => true,
'key' => 'bbses',
'namespace' => 'netcommons/bbses',
'name' => 'BBS',
Expand Down
71 changes: 71 additions & 0 deletions Config/Migration/1484544861_add_is_original_copy.php
@@ -0,0 +1,71 @@
<?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\Bbses\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(
'bbs_articles' => array(
'is_original_copy' => array('type' => 'boolean', 'null' => false, 'default' => '0', 'comment' => 'オリジナルのコピー。言語を新たに追加したときに使用する', 'after' => 'is_translation'),
),
'bbses' => array(
'is_original_copy' => array('type' => 'boolean', 'null' => false, 'default' => '0', 'comment' => 'オリジナルのコピー。言語を新たに追加したときに使用する', 'after' => 'is_translation'),
),
),
),
'down' => array(
'drop_field' => array(
'bbs_articles' => array('is_original_copy'),
'bbses' => 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;
}
}
2 changes: 2 additions & 0 deletions Config/Schema/schema.php
Expand Up @@ -86,6 +86,7 @@ public function after($event = array()) {
'is_latest' => array('type' => 'boolean', 'null' => false, 'default' => '0', 'comment' => '最新コンテンツかどうか 0:最新でない 1:最新'),
'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' => 'オリジナルのコピー。言語を新たに追加したときに使用する'),
'key' => array('type' => 'string', 'null' => false, 'default' => null, 'key' => 'index', 'collate' => 'utf8_general_ci', 'comment' => 'キー', 'charset' => 'utf8'),
'title' => array('type' => 'string', 'null' => false, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'タイトル', 'charset' => 'utf8'),
'title_icon' => array('type' => 'string', 'null' => true, 'default' => null, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
Expand Down Expand Up @@ -134,6 +135,7 @@ public function after($event = array()) {
'language_id' => array('type' => 'integer', 'null' => false, 'default' => '2', 'length' => 6, 'unsigned' => false, 'comment' => '言語ID'),
'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' => 'オリジナルのコピー。言語を新たに追加したときに使用する'),
'name' => array('type' => 'string', 'null' => false, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => '掲示板名称', 'charset' => 'utf8'),
'bbs_article_modified' => array('type' => 'datetime', 'null' => true, 'default' => null, 'comment' => '記事の最終更新日時'),
'created_user' => array('type' => 'integer', 'null' => true, 'default' => '0', 'unsigned' => false, 'comment' => '作成者'),
Expand Down

0 comments on commit 16581ed

Please sign in to comment.