-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #107 from s-nakajima/master
多言語対応
- Loading branch information
Showing
30 changed files
with
514 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?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 AddFieldsForM17n extends NetCommonsMigration { | ||
|
||
/** | ||
* Migration description | ||
* | ||
* @var string | ||
*/ | ||
public $description = 'add_fields_for_m17n'; | ||
|
||
/** | ||
* Actions to be performed | ||
* | ||
* @var array $migration | ||
*/ | ||
public $migration = array( | ||
'up' => array( | ||
'create_field' => array( | ||
'bbs_articles' => array( | ||
'is_origin' => array('type' => 'boolean', 'null' => false, 'default' => '1', 'comment' => 'オリジナルかどうか', 'after' => 'is_latest'), | ||
'is_translation' => array('type' => 'boolean', 'null' => false, 'default' => '0', 'comment' => '翻訳したかどうか', 'after' => 'is_origin'), | ||
), | ||
'bbses' => array( | ||
'language_id' => array('type' => 'integer', 'null' => false, 'default' => '2', 'length' => 6, 'unsigned' => false, 'comment' => '言語ID', 'after' => 'block_id'), | ||
'is_origin' => array('type' => 'boolean', 'null' => false, 'default' => '1', 'comment' => 'オリジナルかどうか', 'after' => 'language_id'), | ||
'is_translation' => array('type' => 'boolean', 'null' => false, 'default' => '0', 'comment' => '翻訳したかどうか', 'after' => 'is_origin'), | ||
), | ||
), | ||
), | ||
'down' => array( | ||
'drop_field' => array( | ||
'bbs_articles' => array('is_origin', 'is_translation'), | ||
'bbses' => array('language_id', 'is_origin', 'is_translation'), | ||
), | ||
), | ||
); | ||
|
||
/** | ||
* 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; | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
Config/Migration/1481005012_modified_from_bbs_id_to_bbs_key.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
/** | ||
* 多言語化対応のためbbs_keyに変更 | ||
* | ||
* @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'); | ||
|
||
/** | ||
* 多言語化対応のためbbs_keyに変更 | ||
* | ||
* @author Shohei Nakajima <nakajimashouhei@gmail.com> | ||
* @package NetCommons\Bbses\Config\Migration | ||
*/ | ||
class ModifiedFromBbsIdToBbsKey extends CakeMigration { | ||
|
||
/** | ||
* Migration description | ||
* | ||
* @var string | ||
*/ | ||
public $description = 'modified_from_bbs_id_to_bbs_key'; | ||
|
||
/** | ||
* Actions to be performed | ||
* | ||
* @var array $migration | ||
*/ | ||
public $migration = array( | ||
'up' => array( | ||
'create_field' => array( | ||
'bbs_articles' => array( | ||
'bbs_key' => array('type' => 'string', 'null' => true, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => '掲示板Key', 'charset' => 'utf8', 'after' => 'bbs_id'), | ||
), | ||
), | ||
), | ||
'down' => array( | ||
'drop_field' => array( | ||
'bbs_articles' => array('bbs_key'), | ||
), | ||
), | ||
); | ||
|
||
/** | ||
* 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; | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
Config/Migration/1481005013_modified_from_bbs_id_to_bbs_key_1.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
/** | ||
* 多言語化対応のためbbs_keyに変更 | ||
* | ||
* @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'); | ||
|
||
/** | ||
* 多言語化対応のためbbs_keyに変更 | ||
* | ||
* @author Shohei Nakajima <nakajimashouhei@gmail.com> | ||
* @package NetCommons\Bbses\Config\Migration | ||
*/ | ||
class ModifiedFromBbsIdToBbsKey1 extends CakeMigration { | ||
|
||
/** | ||
* Migration description | ||
* | ||
* @var string | ||
*/ | ||
public $description = 'modified_from_bbs_id_to_bbs_key_1'; | ||
|
||
/** | ||
* Actions to be performed | ||
* | ||
* @var array $migration | ||
*/ | ||
public $migration = array( | ||
'up' => array( | ||
), | ||
'down' => array( | ||
), | ||
); | ||
|
||
/** | ||
* 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) { | ||
$BbsArticle = $this->generateModel('BbsArticle'); | ||
|
||
$bbsTable = $BbsArticle->tablePrefix . 'bbses Bbs'; | ||
$bbsArticleTable = $BbsArticle->tablePrefix . 'bbs_articles BbsArticle'; | ||
|
||
if ($direction === 'up') { | ||
$sql = 'UPDATE ' . $bbsTable . ', ' . $bbsArticleTable . | ||
' SET BbsArticle.bbs_key = Bbs.key' . | ||
' WHERE BbsArticle.bbs_id' . ' = Bbs.id' . | ||
''; | ||
} else { | ||
$sql = 'UPDATE ' . $bbsTable . ', ' . $bbsArticleTable . | ||
' SET BbsArticle.bbs_id = Bbs.id' . | ||
' WHERE BbsArticle.bbs_key' . ' = Bbs.key' . | ||
' AND BbsArticle.language_id' . ' = Bbs.language_id' . | ||
''; | ||
} | ||
$BbsArticle->query($sql); | ||
return true; | ||
} | ||
} |
90 changes: 90 additions & 0 deletions
90
Config/Migration/1481006697_modified_from_bbs_id_to_bbs_key_2.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?php | ||
/** | ||
* 多言語化対応のためbbs_keyに変更 | ||
* | ||
* @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'); | ||
|
||
/** | ||
* 多言語化対応のためbbs_keyに変更 | ||
* | ||
* @author Shohei Nakajima <nakajimashouhei@gmail.com> | ||
* @package NetCommons\Bbses\Config\Migration | ||
*/ | ||
class ModifiedFromBbsIdToBbsKey2 extends NetCommonsMigration { | ||
|
||
/** | ||
* Migration description | ||
* | ||
* @var string | ||
*/ | ||
public $description = 'modified_from_bbs_id_to_bbs_key_2'; | ||
|
||
/** | ||
* Actions to be performed | ||
* | ||
* @var array $migration | ||
*/ | ||
public $migration = array( | ||
'up' => array( | ||
'drop_field' => array( | ||
'bbs_articles' => array('bbs_id', 'indexes' => array('bbs_id')), | ||
), | ||
'alter_field' => array( | ||
'bbs_articles' => array( | ||
'bbs_key' => array('type' => 'string', 'null' => true, 'default' => null, 'key' => 'index', 'collate' => 'utf8_general_ci', 'comment' => '掲示板Key', 'charset' => 'utf8'), | ||
), | ||
), | ||
'create_field' => array( | ||
'bbs_articles' => array( | ||
'indexes' => array( | ||
'bbs_key' => array('column' => array('bbs_key', 'language_id'), 'unique' => 0), | ||
), | ||
), | ||
), | ||
), | ||
'down' => array( | ||
'create_field' => array( | ||
'bbs_articles' => array( | ||
'bbs_id' => array('type' => 'integer', 'null' => true, 'default' => null, 'unsigned' => false, 'key' => 'index', 'comment' => '記事のID'), | ||
'indexes' => array( | ||
'bbs_id' => array('column' => 'bbs_id', 'unique' => 0), | ||
), | ||
), | ||
), | ||
'alter_field' => array( | ||
'bbs_articles' => array( | ||
'bbs_key' => array('type' => 'string', 'null' => true, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => '掲示板Key', 'charset' => 'utf8'), | ||
), | ||
), | ||
'drop_field' => array( | ||
'bbs_articles' => array('indexes' => array('bbs_key')), | ||
), | ||
), | ||
); | ||
|
||
/** | ||
* 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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.