--- /dev/null
+/*!40101 SET NAMES utf8 */;
+
+/* Add Table */
+DROP TABLE IF EXISTS `default_profiles`;
+
+CREATE TABLE `default_profiles` (
+ `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
+ `profile_id` INTEGER UNSIGNED NOT NULL,
+ `profile_select_id` INTEGER UNSIGNED NULL,
+ `profile_table_id` INTEGER UNSIGNED NULL,
+ `profile_table_static_id` INTEGER UNSIGNED NULL,
+ `value` TEXT NOT NULL,
+ `public_flag` ENUM('public', 'private') NOT NULL DEFAULT 'public',
+ PRIMARY KEY(`id`),
+ CONSTRAINT `fk_profiles-default_profiles`
+ FOREIGN KEY (`profile_id`) REFERENCES `profiles` (`id`) ON DELETE CASCADE,
+ CONSTRAINT `fk_profile_selects-default_profiles`
+ FOREIGN KEY (`profile_select_id`) REFERENCES `profile_selects` (`id`) ON DELETE CASCADE,
+ CONSTRAINT `fk_profile_tables-default_profiles`
+ FOREIGN KEY (`profile_table_id`) REFERENCES `profile_tables` (`id`) ON DELETE CASCADE,
+ CONSTRAINT `fk_profile_table_statics-default_profiles`
+ FOREIGN KEY (`profile_table_static_id`) REFERENCES `profile_table_statics` (`id`) ON DELETE CASCADE
+) TYPE=InnoDB DEFAULT CHARSET=utf8;
+
return true;
}
+
+ /* POSTのCharactersHasProfileを処理 */
+ function _set_new_characters_has_profile($characters_has_profiles, $profile_id = null, $now_data = array(), $allow_blank = false)
+ {
+ $prev_profile_id = null;
+ $profileTable_tmp = array();
+ $i = 0;
+ $public = null;
+ foreach ($characters_has_profiles as $k => $v) {
+ if (!empty($character_id)) {
+ $characters_has_profiles[$k]['character_id'] = $character_id;
+ }
+ // 配列valueの処理
+ if (is_array($v['value'])) {
+ $characters_has_profiles[$k]['value'] = $v['value'][0];
+ }
+
+ // サニタイズ
+ $characters_has_profiles[$k]['value'] = preg_replace('/[\\\n]/', '', $characters_has_profiles[$k]['value']);
+ $characters_has_profiles[$k]['value'] = preg_replace('/[\\\r]/', '', $characters_has_profiles[$k]['value']);
+ // textarea改行処理
+ if (isset($v['is_textarea']) && $v['is_textarea'] == 1) {
+// $characters_has_profiles[$k]['value'] = str_replace(array("\n\r", '\n', "\r"), '<br />', $characters_has_profiles[$k]['value']);
+ $characters_has_profiles[$k]['value'] = str_replace("\\", '', $characters_has_profiles[$k]['value']);
+ }
+
+ // 空の値処理, public_flag
+ // table: 一時保管して全項目空の場合行削除
+ if (CorePlus::is_valid($v, 'profile_table_id')) {
+ if (isset($profileTable_tmp[$v['profile_id']][$i][$v['profile_table_id']])) {
+ $i++;
+ $public = null;
+ }
+
+ // 行単位public_flag
+ if ($public == null && isset($characters_has_profiles[$k]['public_flag'])) {
+ $public = $v['public_flag'];
+ // Static設定タイトルは公開
+ if ($v['profile_table_static_id']) {
+ $characters_has_profiles[$k]['public_flag'] = 'public';
+ }
+ } else {
+ $characters_has_profiles[$k]['public_flag'] = $public;
+ }
+
+ $profileTable_tmp[$v['profile_id']][$i][$v['profile_table_id']] = array($characters_has_profiles[$k], $k);
+ // $allow_blank = falseならそれ以外は削除
+ } elseif (empty($v['value']) && empty($allow_blank)) {
+ unset($characters_has_profiles[$k]);
+ }
+ }
+
+ // table: 空行削除、不正profile_table_idデータ削除
+ if (!empty($profileTable_tmp)) {
+ if (!isset($this->Character->ProfileTable)) {
+ $this->Character->ProfileTable = CorePlus::set_model('ProfileTable');
+ }
+ foreach($profileTable_tmp as $profile_id => $v) {
+ $profile_table_columns = $this->Character->ProfileTable->find('list', array(
+ 'conditions' => array('ProfileTable.profile_id' => $profile_id),
+ 'fields' => array('ProfileTable.id'),
+ 'order' => array('ProfileTable.sort_order' => 'asc'),
+ 'recursive' => -1,
+ ));
+
+ foreach ($v as $i => $profile_tables) {
+ // 不正POSTの削除
+ $diff_keys = array_diff_key($profile_tables, $profile_table_columns);
+ if (!empty($diff_keys)) {
+ foreach($diff_keys as $dvalue) {
+ unset($characters_has_profiles[$dvalue[1]]);
+ }
+ }
+
+ // 空行削除
+ $delete_flg = true;
+ foreach($profile_table_columns as $k2 => $columns) {
+ if (CorePlus::is_valid($profile_tables, $columns.'.0.value')) {
+ $delete_flg = false;
+ break;
+ }
+ }
+ if ($delete_flg === true) {
+ foreach ($profile_tables as $delk) {
+ unset($characters_has_profiles[$delk[1]]);
+ }
+ }
+ }
+ }
+ }
+
+ // 指定データのみ変更
+ if (!is_null($profile_id) && !empty($now_data)) {
+ $tmp = array();
+ $i = 0;
+ foreach($now_data as $k => $v) {
+ if ($v['id'] == $profile_id) {
+ $v['CharactersHasProfile'] = $characters_has_profiles;
+ }
+
+ foreach ($v['CharactersHasProfile'] as $k2 => $v2) {
+ $tmp[$i] = $v2;
+ if (isset($tmp[$i]['id'])) {
+ unset($tmp[$i]['id']);
+ }
+ if (isset($tmp[$i]['character_id'])) {
+ unset($tmp[$i]['character_id']);
+ }
+
+ $i++;
+ }
+ }
+
+ $characters_has_profiles = $tmp;
+ }
+
+ return $characters_has_profiles;
+ }
+
// 最新のお知らせ
function get_news($limit = 5) {
$this->News = CorePlus::set_model('News');
/* validate */
$this->_set_validate4characters_has_profile($character['System']['id']);
+
if ($this->Character->saveAll($this->data, array('validate' => 'only'))) {
// requiredのチェック
$requiredCheck = $this->_checkRequiredProfile($character['System']['Profile']);
$this->redirect(array('action'=>'view', $id));
}
}
+ } else {
+ $validate_error = current(current(current($this->Character->validationErrors)));
+ $this->Session->setFlash($validate_error);
}
- $this->data = array_merge($character, $this->data);
+ $this->data = array_merge($character, $this->post_data);
$this->data['Character'] = $this->post_data['Character'];
$this->data['Character']['main_picture'] = $character['Character']['main_picture'];
$this->data['Character']['system_id'] = $character['Character']['system_id'];
if (isset($postdata[$i])) {
$this->data['System']['Profile'][$k1]['CharactersHasProfile'][$i] = array_merge($profile['CharactersHasProfile'][$i], $postdata[$i]);
} else {
- $this->data['System']['Profile'][$k1]['CharactersHasProfile'][$i] = array_merge($profile['CharactersHasProfile'][$i], $postdata);
+ $this->data['System']['Profile'][$k1]['CharactersHasProfile'][$i] = array_merge($profile['CharactersHasProfile'][$i], (array)$postdata);
}
}
}
);
$this->post_data = $this->data;
-
- $this->data['Character'] = array_merge($character['Character'], $this->data['Character']);
+ $this->data = array();
+ if (isset($this->post_data['Character'])) {
+ $this->data['Character'] = array_merge($character['Character'], $this->post_data['Character']);
+ } else {
+ $this->data['Character'] = $character['Character'];
+ }
$this->data['Character'] = $this->_restore_html_character($this->data['Character']);
$this->data['Character']['__Token'] = $this->post_data['Character']['__Token'];
$this->data['Character']['modified'] = null;
// 新hasProfile処理
- $this->data['CharactersHasProfile'] = $this->_set_new_characters_has_profile($this->data['CharactersHasProfile'], $profile_id, $character['System']['Profile']);
+ $this->data['CharactersHasProfile'] = $this->_set_new_characters_has_profile($this->post_data['CharactersHasProfile'], $profile_id, $character['System']['Profile']);
/* validate */
$this->_set_validate4characters_has_profile($character['System']['id']);
if ($this->Character->saveAll($this->data, array('validate' => 'only'))) {
}
} else {
}
+ } else {
+ $validate_error = current(current(current($this->Character->validationErrors)));
+ $this->Session->setFlash($validate_error);
}
$this->data = array_merge($character, $this->data);
return $profile;
}
-
- /* POSTのCharactersHasProfileを処理 */
- function _set_new_characters_has_profile($characters_has_profiles, $profile_id = null, $now_data = array())
- {
- $prev_profile_id = null;
- $profileTable_tmp = array();
- $i = 0;
- $public = null;
- foreach ($characters_has_profiles as $k => $v) {
- if (!empty($character_id)) {
- $characters_has_profiles[$k]['character_id'] = $character_id;
- }
- // 配列valueの処理
- if (is_array($v['value'])) {
- $characters_has_profiles[$k]['value'] = $v['value'][0];
- }
-
- // サニタイズ
- $characters_has_profiles[$k]['value'] = preg_replace('/[\\\n]/', '', $characters_has_profiles[$k]['value']);
- $characters_has_profiles[$k]['value'] = preg_replace('/[\\\r]/', '', $characters_has_profiles[$k]['value']);
- // textarea改行処理
- if (isset($v['is_textarea']) && $v['is_textarea'] == 1) {
-// $characters_has_profiles[$k]['value'] = str_replace(array("\n\r", '\n', "\r"), '<br />', $characters_has_profiles[$k]['value']);
- $characters_has_profiles[$k]['value'] = str_replace("\\", '', $characters_has_profiles[$k]['value']);
- }
-
- // 空の値処理, public_flag
- // table: 一時保管して全項目空の場合行削除
- if (CorePlus::is_valid($v, 'profile_table_id')) {
- if (isset($profileTable_tmp[$v['profile_id']][$i][$v['profile_table_id']])) {
- $i++;
- $public = null;
- }
-
- // 行単位public_flag
- if ($public == null && isset($characters_has_profiles[$k]['public_flag'])) {
- $public = $v['public_flag'];
- // Static設定タイトルは公開
- if ($v['profile_table_static_id']) {
- $characters_has_profiles[$k]['public_flag'] = 'public';
- }
- } else {
- $characters_has_profiles[$k]['public_flag'] = $public;
- }
-
- $profileTable_tmp[$v['profile_id']][$i][$v['profile_table_id']] = array($characters_has_profiles[$k], $k);
- // それ以外は削除
- } elseif (empty($v['value'])) {
- unset($characters_has_profiles[$k]);
- }
- }
-
- // table: 空行削除、不正profile_table_idデータ削除
- if (!empty($profileTable_tmp)) {
- if (!isset($this->Character->ProfileTable)) {
- $this->Character->ProfileTable = CorePlus::set_model('ProfileTable');
- }
- foreach($profileTable_tmp as $profile_id => $v) {
- $profile_table_columns = $this->Character->ProfileTable->find('list', array(
- 'conditions' => array('ProfileTable.profile_id' => $profile_id),
- 'fields' => array('ProfileTable.id'),
- 'order' => array('ProfileTable.sort_order' => 'asc'),
- 'recursive' => -1,
- ));
-
- foreach ($v as $i => $profile_tables) {
- // 不正POSTの削除
- $diff_keys = array_diff_key($profile_tables, $profile_table_columns);
- if (!empty($diff_keys)) {
- foreach($diff_keys as $dvalue) {
- unset($characters_has_profiles[$dvalue[1]]);
- }
- }
-
- // 空行削除
- $delete_flg = true;
- foreach($profile_table_columns as $k2 => $columns) {
- if (CorePlus::is_valid($profile_tables, $columns.'.0.value')) {
- $delete_flg = false;
- break;
- }
- }
- if ($delete_flg === true) {
- foreach ($profile_tables as $delk) {
- unset($characters_has_profiles[$delk[1]]);
- }
- }
- }
- }
- }
-
- // 指定データのみ変更
- if (!is_null($profile_id) && !empty($now_data)) {
- $tmp = array();
- $i = 0;
- foreach($now_data as $k => $v) {
- if ($v['id'] == $profile_id) {
- $v['CharactersHasProfile'] = $characters_has_profiles;
- }
-
- foreach ($v['CharactersHasProfile'] as $k2 => $v2) {
- $tmp[$i] = $v2;
- if (isset($tmp[$i]['id'])) {
- unset($tmp[$i]['id']);
- }
- if (isset($tmp[$i]['character_id'])) {
- unset($tmp[$i]['character_id']);
- }
-
- $i++;
- }
- }
-
- $characters_has_profiles = $tmp;
- }
-
- return $characters_has_profiles;
- }
-
// CharactersHasProfileの追加valiadte設定
function _set_validate4characters_has_profile($system_id)
{
--- /dev/null
+<?php
+/*
+ * PHP version 5
+ *
+ * @copyright Copyright 2010, Cake. (http://trpgtools-onweb.sourceforge.jp/)
+ * @category Controller
+ * @package TRPG Data Bank
+ * @version beta
+ * @author Cake <cake_67@users.sourceforge.jp>
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ * @link http://trpgtools-onweb.sourceforge.jp/
+ */
+
+class DefaultProfilesController extends AppController {
+
+ var $name = 'DefaultProfiles';
+
+ var $helpers = array(
+ 'Profiledisp',
+ 'Select',
+ );
+
+ var $disableTokenActions = array();
+
+ /* メソッド */
+
+ function beforeFilter() {
+ parent::beforeFilter();
+
+ // Cache
+ $this->cacheAction = array(
+ );
+
+ // 認証なしアクセス可
+ }
+
+ function beforeRender()
+ {
+ parent::beforeRender();
+
+ $this->set_public_flag4view();
+ }
+
+ /* アクションメソッド */
+ function admin_edit($profile_id = null) {
+ if (!$profile_id ) {
+ $this->Session->setFlash(__('Invalid data.', true));
+ $this->redirect(array('controller' => 'systems', 'action'=>'admin_index'));
+ }
+
+ $profile = $this->get_profile4profile_id($profile_id);
+ if (empty($profile)) {
+ $this->Session->setFlash(__('Invalid Profile', true));
+ $this->redirect(array('controller' => 'systems', 'action'=>'admin_index'));
+ }
+
+ // 「その他」システム設定
+ $this->checkEditOtherSystem($profile['Profile']['system_id']);
+
+ if (!empty($this->data)) {
+ $this->post_data = $this->data;
+ $this->data = array();
+
+ $allow_blank = false;
+ if ($profile['Profile']['profile_type'] == 'checkbox') {
+ $allow_blank = true;
+ }
+ $this->data['CharactersHasProfile'] = $this->_set_new_characters_has_profile($this->post_data['CharactersHasProfile'], $profile_id, array(), $allow_blank);
+
+ foreach ($this->data['CharactersHasProfile'] as $k => $v) {
+ $this->data['DefaultProfile'][$k]['profile_id'] = $profile_id;
+ if (!empty($v['profile_select_id'])) {
+ $this->data['DefaultProfile'][$k]['profile_select_id'] = $v['profile_select_id'];
+ }
+ if (!empty($v['profile_table_id'])) {
+ $this->data['DefaultProfile'][$k]['profile_table_id'] = $v['profile_table_id'];
+ }
+ if (!empty($v['profile_table_static_id'])) {
+ $this->data['DefaultProfile'][$k]['profile_table_static_id'] = $v['profile_table_static_id'];
+ }
+
+ if (!isset($v['value'])) {
+ $this->data['DefaultProfile'][$k]['value'] = '';
+ } else {
+ $this->data['DefaultProfile'][$k]['value'] = $v['value'];
+ }
+
+ if (!isset($v['public_flag'])) {
+ $this->data['DefaultProfile'][$k]['public_flag'] = 'public';
+ } else {
+ $this->data['DefaultProfile'][$k]['public_flag'] = $v['public_flag'];
+ }
+ }
+ unset($this->data["CharactersHasProfile"]);
+
+// $this->data['DefaultProfile']['__Token'] = $this->post_data['DefaultProfile']['__Token'];
+
+ /* validate */
+ if ($this->DefaultProfile->saveAll($this->data['DefaultProfile'], array('validate' => 'only'))) {
+
+ // 現在のdefault_profiles削除
+ $this->DefaultProfile->deleteAll(array(
+ 'DefaultProfile.profile_id' => $profile_id
+ ));
+
+ /* データ保存 */
+ $this->DefaultProfile->create();
+ if ($this->DefaultProfile->saveAll($this->data['DefaultProfile'], array(
+ 'validate' => false,
+ 'fieldList' => $this->DefaultProfile->fields['edit'],
+ ))) {
+ $this->Session->setFlash(__('The default profile has been saved', true));
+// $this->redirect(array('controller' => 'systems', 'action' => 'view', $profile['Profile']['system_id']));
+ $this->redirect(array('action' => 'edit', $profile_id));
+ }
+
+ $this->Session->setFlash(__('The default profile could not be saved. Please, try again.', true));
+ $this->data = $this->post_data;
+ }
+ }
+
+ $this->data['System'] = $profile['System'];
+ unset($profile['System']);
+
+ $profile['Profile']['CharactersHasProfile'] = $profile['DefaultProfile'];
+
+ $profile['Profile']['ProfileSelect'] = $profile['ProfileSelect'];
+ unset($profile['ProfileSelect']);
+
+ $profile['Profile']['ProfileTable'] = $profile['ProfileTable'];
+ unset($profile['ProfileTable']);
+
+ $this->data['System']['Profile'][0] = $profile['Profile'];
+
+ $this->set('form_nums', count($profile['Profile']['CharactersHasProfile']) + 3);
+
+ $this->set('title_for_layout', " - ". sprintf(__('DefaultProfile for %s %s', true), $this->data['System']['name'], $this->data['System']['Profile'][0]['name']));
+
+ }
+
+ function admin_delete($id = null) {
+ if (!$id) {
+ $this->Session->setFlash(__('Invalid id for default profile', true));
+ $this->redirect(array('action'=>'index'));
+ }
+ if ($this->DefaultProfile->delete($id)) {
+ $this->Session->setFlash(__('Default profile deleted', true));
+ $this->redirect(array('action'=>'index'));
+ }
+ $this->Session->setFlash(__('Default profile was not deleted', true));
+ $this->redirect(array('action' => 'index'));
+ }
+
+
+ function get_profile4profile_id($profile_id)
+ {
+ if (!$profile_id) {
+ $this->Session->setFlash(__('Invalid ProfileTable.', true));
+ $this->redirect(array('controller' => 'systems', 'action'=>'admin_index'));
+ }
+
+ $profile = $this->DefaultProfile->Profile->find('first', array(
+ 'conditions' => array(
+ 'Profile.id' => $profile_id,
+ ),
+ 'contain' => array(
+ 'System',
+ 'DefaultProfile',
+ 'ProfileSelect',
+ 'ProfileTable' => array(
+ 'ProfileTableStatic',
+ ),
+ ),
+ ));
+
+ if (!empty($profile['ProfileSelect'])) {
+ foreach ($profile['ProfileSelect'] as $k => $v) {
+
+ if (isset($v['sort_order']) && !empty($v['sort_order'])) {
+ $sort_order[$k] = $v['sort_order'];
+ } else {
+ $sort_order[$k] = 0;
+ }
+ }
+ if (!empty($sort_order)) {
+ $profile['ProfileSelect'] = $this->sort4sort_order($profile['ProfileSelect'], $sort_order);
+ }
+ }
+ if (!empty($profile['ProfileTable'])) {
+ foreach ($profile['ProfileTable'] as $k => $v) {
+
+ if (isset($v['sort_order']) && !empty($v['sort_order'])) {
+ $sort_order[$k] = $v['sort_order'];
+ } else {
+ $sort_order[$k] = 0;
+ }
+ }
+ if (!empty($sort_order)) {
+ $profile['ProfileTable'] = $this->sort4sort_order($profile['ProfileTable'], $sort_order);
+ }
+ }
+
+ return $profile;
+ }
+}
+
'ProfileTable' => array(
'ProfileTableStatic',
),
+ 'DefaultProfile',
),
'Attachment',
);
msgid "Insert HTML"
msgstr "HTML挿入"
+msgid "Insert HTML add the Blog parts, Adsense code and so on. It displays the RAW code as you setting."
+msgstr "HTML挿入機能は、ブログパーツや広告などを表示するための機能です。設定したコードをそのままサイトに表示します。"
+
msgid "Before Login"
msgstr "未ログイン"
msgid "Invalid date."
msgstr "正しい日付を入力してください。"
+msgid "DefaultProfile for %s %s"
+msgstr "%s %sのデフォルト入力値設定"
+
+msgid "Set Default Profile"
+msgstr "デフォルト入力値設定"
+
+msgid "The default profile has been saved"
+msgstr "デフォルト入力値設定を保存しました。"
+
+msgid "The default profile could not be saved. Please, try again."
+msgstr "デフォルト入力値設定の保存に失敗しました。"
+
return (bool)$system_id;
}
+ function validProfileId($data, $system_id)
+ {
+ return (bool)$this->Profile->find('count', array(
+ 'conditions' => array(
+ 'Profile.id' => $data['profile_id'],
+ 'Profile.system_id' => $system_id,
+ ),
+ 'recursive' => -1,
+ ));
+ }
+
+ function validProfileSelectId($data, $system_id)
+ {
+ return $this->Profile->ProfileSelect->find('count', array(
+ 'conditions' => array(
+ 'ProfileSelect.id' => $data['profile_select_id'],
+ 'Profile.system_id' => $system_id,
+ ),
+ ));
+ }
+
+ function validProfiletableId($data, $system_id)
+ {
+ return $this->Profile->ProfileTable->find('count', array(
+ 'conditions' => array(
+ 'ProfileTable.id' => $data['profile_table_id'],
+ 'Profile.system_id' => $system_id,
+ ),
+ ));
+ }
+
/* keyName (number, small letter and underline) */
function keyName($data)
{
'ProfileTableStatic',
),
'CharactersHasProfile',
+ 'DefaultProfile',
),
),
'CharacterProfileArchive',
return $this->data;
}
- /* Validation */
- function validProfileId($data, $system_id)
- {
- return (bool)$this->Profile->find('count', array(
- 'conditions' => array(
- 'Profile.id' => $data['profile_id'],
- 'Profile.system_id' => $system_id,
- ),
- 'recursive' => -1,
- ));
- }
-
- function validProfileSelectId($data, $system_id)
- {
- return $this->Profile->ProfileSelect->find('count', array(
- 'conditions' => array(
- 'ProfileSelect.id' => $data['profile_select_id'],
- 'Profile.system_id' => $system_id,
- ),
- ));
- }
-
- function validProfiletableId($data, $system_id)
- {
- return $this->Profile->ProfileTable->find('count', array(
- 'conditions' => array(
- 'ProfileTable.id' => $data['profile_table_id'],
- 'Profile.system_id' => $system_id,
- ),
- ));
- }
-
}
--- /dev/null
+<?php
+/*
+ * PHP version 5
+ *
+ * @copyright Copyright 2010, Cake. (http://trpgtools-onweb.sourceforge.jp/)
+ * @category Model
+ * @package TRPG Data Bank
+ * @version beta
+ * @author Cake <cake_67@users.sourceforge.jp>
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ * @link http://trpgtools-onweb.sourceforge.jp/
+ */
+
+class DefaultProfile extends AppModel {
+ var $name = 'DefaultProfile';
+ var $displayField = 'value';
+
+ var $fields = array(
+ 'edit' => array('profile_id', 'profile_select_id', 'profile_table_id', 'profile_table_static_id', 'value', 'public_flag'),
+ 'escape' => array(
+ 'value' => array(
+ 'html' => true,
+ 'tags' => true,
+ 'images' => true,
+ 'sctipts' => true,
+ ),
+ ),
+ );
+
+ var $validate = array(
+ 'public_flag' => array(
+ 'publicFlag' => array(
+ 'rule' => 'publicFlag',
+ 'allowEmpty' => true,
+ ),
+ ),
+ //'message' => 'Your custom message here',
+ //'allowEmpty' => false,
+ //'required' => false,
+ //'last' => false, // Stop validation after this rule
+ //'on' => 'create', // Limit validation to 'create' or 'update' operations
+ );
+
+ //The Associations below have been created with all possible keys, those that are not needed can be removed
+ var $belongsTo = array(
+ 'Profile' => array(
+ 'className' => 'Profile',
+ 'foreignKey' => 'profile_id',
+ 'conditions' => '',
+ 'fields' => '',
+ ),
+ 'ProfileSelect' => array(
+ 'className' => 'ProfileSelect',
+ 'foreignKey' => 'profile_select_id',
+ 'conditions' => '',
+ 'fields' => '',
+ ),
+ 'ProfileTable' => array(
+ 'className' => 'ProfileTable',
+ 'foreignKey' => 'profile_table_id',
+ 'conditions' => '',
+ 'fields' => '',
+ ),
+ 'ProfileTableStatic' => array(
+ 'className' => 'ProfileTableStatic',
+ 'foreignKey' => 'profile_table_static_id',
+ 'conditions' => '',
+ 'fields' => '',
+ ),
+ );
+
+ function beforeSave($options = array())
+ {
+ // $fieldsの設定でSanitize
+ if (isset($this->data[$this->name])) {
+ $this->data[$this->name] = $this->_sanitizeByFields($this->data[$this->name]);
+ }
+
+ // Sanitize(不正コード、SQL Injection)
+ if (isset($this->data)) {
+ $this->data = $this->_sanitizeBasic($this->data);
+ }
+
+ return $this->data;
+ }
+
+}
'finderQuery' => '',
'deleteQuery' => '',
'insertQuery' => ''
+ ),
+ 'DefaultProfile' => array(
+ 'className' => 'DefaultProfile',
+ 'foreignKey' => 'profile_id',
+ 'dependent' => true,
+ 'conditions' => '',
+ 'fields' => '',
+ 'order' => '', // Using filesortの原因
+ 'limit' => '',
+ 'offset' => '',
+ 'exclusive' => '',
+ 'finderQuery' => '',
+ 'counterQuery' => ''
)
);
'finderQuery' => '',
'deleteQuery' => '',
'insertQuery' => ''
+ ),
+ 'DefaultProfile' => array(
+ 'className' => 'DefaultProfile',
+ 'foreignKey' => 'profile_select_id',
+ 'dependent' => true,
+ 'conditions' => '',
+ 'fields' => '',
+ 'order' => '', // Using filesortの原因
+ 'limit' => '',
+ 'offset' => '',
+ 'exclusive' => '',
+ 'finderQuery' => '',
+ 'counterQuery' => ''
)
);
'finderQuery' => '',
'deleteQuery' => '',
'insertQuery' => ''
+ ),
+ 'DefaultProfile' => array(
+ 'className' => 'DefaultProfile',
+ 'foreignKey' => 'profile_table_id',
+ 'dependent' => true,
+ 'conditions' => '',
+ 'fields' => '',
+ 'order' => '', // Using filesortの原因
+ 'limit' => '',
+ 'offset' => '',
+ 'exclusive' => '',
+ 'finderQuery' => '',
+ 'counterQuery' => ''
)
);
--- /dev/null
+<?php
+/* DefaultProfiles Test cases generated on: 2011-01-05 16:01:01 : 1294212781*/
+App::import('Controller', 'DefaultProfiles');
+
+class TestDefaultProfilesController extends DefaultProfilesController {
+ var $autoRender = false;
+
+ function redirect($url, $status = null, $exit = true) {
+ $this->redirectUrl = $url;
+ }
+}
+
+class DefaultProfilesControllerTestCase extends CakeTestCase {
+ var $fixtures = array('app.default_profile', 'app.profile', 'app.system', 'app.character', 'app.user', 'app.group', 'app.attachment_ex', 'app.character_sheet', 'app.character_picture', 'app.characters_has_profile', 'app.profile_select', 'app.profile_table', 'app.profile_table_static', 'app.character_profile_archive');
+
+ function startTest() {
+ $this->DefaultProfiles =& new TestDefaultProfilesController();
+ $this->DefaultProfiles->constructClasses();
+ }
+
+ function endTest() {
+ unset($this->DefaultProfiles);
+ ClassRegistry::flush();
+ }
+
+ function testIndex() {
+
+ }
+
+ function testView() {
+
+ }
+
+ function testAdd() {
+
+ }
+
+ function testEdit() {
+
+ }
+
+ function testDelete() {
+
+ }
+
+ function testAdminIndex() {
+
+ }
+
+ function testAdminView() {
+
+ }
+
+ function testAdminAdd() {
+
+ }
+
+ function testAdminEdit() {
+
+ }
+
+ function testAdminDelete() {
+
+ }
+
+}
+?>
\ No newline at end of file
--- /dev/null
+<?php
+/* DefaultProfile Test cases generated on: 2011-01-05 16:01:10 : 1294212730*/
+App::import('Model', 'DefaultProfile');
+
+class DefaultProfileTestCase extends CakeTestCase {
+ var $fixtures = array('app.default_profile', 'app.profile', 'app.system', 'app.character', 'app.user', 'app.group', 'app.attachment_ex', 'app.character_sheet', 'app.character_picture', 'app.characters_has_profile', 'app.profile_select', 'app.profile_table', 'app.profile_table_static', 'app.character_profile_archive');
+
+ function startTest() {
+ $this->DefaultProfile =& ClassRegistry::init('DefaultProfile');
+ }
+
+ function endTest() {
+ unset($this->DefaultProfile);
+ ClassRegistry::flush();
+ }
+
+}
+?>
\ No newline at end of file
--- /dev/null
+<?php
+/* DefaultProfile Fixture generated on: 2011-01-05 16:01:10 : 1294212730 */
+class DefaultProfileFixture extends CakeTestFixture {
+ var $name = 'DefaultProfile';
+
+ var $fields = array(
+ 'id' => array('type' => 'integer', 'null' => false, 'default' => NULL, 'length' => 20, 'key' => 'primary'),
+ 'profile_id' => array('type' => 'integer', 'null' => false, 'default' => NULL, 'length' => 10, 'key' => 'index'),
+ 'profile_select_id' => array('type' => 'integer', 'null' => true, 'default' => NULL, 'length' => 10, 'key' => 'index'),
+ 'profile_table_id' => array('type' => 'integer', 'null' => true, 'default' => NULL, 'length' => 10, 'key' => 'index'),
+ 'value' => array('type' => 'text', 'null' => false, 'default' => NULL, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
+ 'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1), 'fk_profiles-default_profiles' => array('column' => 'profile_id', 'unique' => 0), 'fk_profile_selects-default_profiles' => array('column' => 'profile_select_id', 'unique' => 0), 'fk_profile_tables-default_profiles' => array('column' => 'profile_table_id', 'unique' => 0)),
+ 'tableParameters' => array('charset' => 'utf8', 'collate' => 'utf8_general_ci', 'engine' => 'InnoDB')
+ );
+
+ var $records = array(
+ array(
+ 'id' => 1,
+ 'profile_id' => 1,
+ 'profile_select_id' => 1,
+ 'profile_table_id' => 1,
+ 'value' => 'Lorem ipsum dolor sit amet, aliquet feugiat. Convallis morbi fringilla gravida, phasellus feugiat dapibus velit nunc, pulvinar eget sollicitudin venenatis cum nullam, vivamus ut a sed, mollitia lectus. Nulla vestibulum massa neque ut et, id hendrerit sit, feugiat in taciti enim proin nibh, tempor dignissim, rhoncus duis vestibulum nunc mattis convallis.'
+ ),
+ );
+}
+?>
\ No newline at end of file
}
$disp_add_link = true;
}
- $profiledisp->disp_forms4profile_type($profile, $form_num, 0, $disp_add_link, $this->data['Character']['id'], true);
+ $profiledisp->disp_forms4profile_type(
+ $profile,
+ $form_num,
+ 0,
+ $disp_add_link,
+ $this->data['Character']['id'],
+ true,
+ array(),
+ true
+ );
?>
</div>
</td>
--- /dev/null
+<?php
+$profile = $this->data['System']['Profile'][0];
+ ?>
+<div class="box">
+<div class="boxHeader">
+<h3><?php echo $html->link($this->data['System']['name'], array('controller' => 'systems', 'action' => 'admin_view', $this->data['System']['id']), array('escape' => false), false, false). ' '. $profile['name']. ' '. __('Set Default Profile', true);?></h3>
+</div>
+<div class="boxBody">
+<div id="defaultProfilesEdit">
+
+<?php
+$profiledisp->set_profile_type4view($profile);
+$num = $form_nums + 3;
+
+echo $form->create('DefaultProfile', array('url' => array(
+ 'controller' => 'default_profiles',
+ 'action' => 'admin_edit',
+ $this->data['System']['Profile'][0]['id']
+)));
+?>
+
+<?php
+if ($profile['profile_type'] == 's-table') {
+ $count = count($profile['ProfileTable'][0]['ProfileTableStatic']);
+} else {
+ $count = $form_nums;
+}
+
+$profiledisp->disp_forms4profile_type(
+ $profile,
+ $count,
+ 0,
+ false,
+ null,
+ true,
+ array(
+ 'div' => array(
+ 'class' => 'input text inline'
+ )
+ ),
+ true
+);
+
+echo $token->create();
+echo $this->Form->end(__('Submit', true));
+?>
+
+<p>
+<?php
+echo $form->create(
+ '', array(
+ 'url' => array(
+ 'controller' => 'systems', 'action' => 'admin_view', $this->data['System']['id']),
+ 'type' => 'GET',
+ 'id' => 'CancelButton'
+));
+echo $form->end(array('label' => __('Back', true)));
+?>
+</p>
+</div>
+</div>
+
+</div>
} else {
$rows = 2;
}
- $profiledisp->disp_forms4profile_type($profile, $rows, 0);
+ $profiledisp->disp_forms4profile_type(
+ $profile,
+ $rows,
+ 0,
+ false,
+ null,
+ true,
+ array(),
+ true
+ );
?>
</td>
</tr>
array('controller' => 'profiles', 'action' => 'edit', $profile['id'])
);
echo $html->link(
+ __('Set Default Profile', true),
+ array('controller' => 'default_profiles', 'action' => 'edit', $profile['id'])
+ );
+ echo $html->link(
__('Delete', true),
array('controller' => 'profiles', 'action' => 'delete', $profile['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $profile['name'])
);
/* profile_selectsの設定をプルダウンで出力 */
- function disp_select4profile_selects($profile_selects, $characters_has_profile = array(), $options = array(), $label = false, $legend = false, $disp_public = false)
+ function disp_select4profile_selects($profile_selects, $characters_has_profile = array(), $options = array(), $label = false, $legend = false, $disp_public = false, $isProfileDefault = false)
{
if (empty($profile_selects)) {
return null;
}
- $selected = $this->set_form_value($profile_selects, $characters_has_profile);
+ $selected = $this->set_form_value($profile_selects, $characters_has_profile, $isProfileDefault);
$public_flag = null;
if (isset($characters_has_profile[0]['public_flag'])) {
}
/* profile_selectsの設定をチェックボックスで出力 */
- function disp_checkbox4profile_selects($profile_selects, $characters_has_profile = array(), $label = false, $legend = false, $disp_public = false)
+ function disp_checkbox4profile_selects($profile_selects, $characters_has_profile = array(), $label = false, $legend = false, $disp_public = false, $isProfileDefault = false)
{
if (empty($profile_selects)) {
return null;
}
$profile_select[0] = $v;
- $has_profile[0] = $this->get_selected_profile($v, $characters_has_profile);
+ $has_profile[0] = $this->get_selected_profile($v, $characters_has_profile, $isProfileDefault);
$this->disp_select4profile_selects(
$profile_select,
$has_profile,
'div' => array(
'class' => 'input checkbox inline'
),
- ), $label, $legend, $disp_public
+ ), $label, $legend, $disp_public, $isProfileDefault
);
}
}
}
/* characters_has_profileからtable td出力 */
- function disp_tds4characters_has_profiles($characters_has_profile, $type = 'view', $publicOnly = true, $profile_type = null, $oddTrOptions = null, $evenTrOptions = null, $useCount = false, $continueOddEven = true)
+ function disp_tds4characters_has_profiles($characters_has_profile, $type = 'view', $publicOnly = true, $profile_type = null, $oddTrOptions = null, $evenTrOptions = null, $useCount = false, $continueOddEven = true, $isProfileDefault = false)
{
$i = 1;
$profile_num = 0;
if (!CorePlus::is_valid($v, 'profile_table_id')) {
$profile_table_ids = array_keys(Set::combine($characters_has_profile, '{n}.profile_table_id'));
-
if (!empty($prof_table_ids)) {
$v['profile_table_id'] = current(array_slice($prof_table_ids, $profile_num+1, 1));
$v['value'] = null;
foreach($profiles as $k => $v) {
if ($type == 'form') {
- $tds = $this->disp_form4profile_tables($v, $publicOnly, $oddTrOptions, $evenTrOptions, true);
+ $tds = $this->disp_form4profile_tables($v, $publicOnly, $oddTrOptions, $evenTrOptions, true, true, $isProfileDefault);
} else {
- $tds = $this->disp_value4profile_tables($v, $publicOnly, $profile_type, null, null, true);
+ $tds = $this->disp_value4profile_tables($v, $publicOnly, $profile_type, null, null, true, $isProfileDefault);
}
}
$this->character_has_profile_cols = 0;
}
/* characters_has_profileからtdフォーム出力 */
- function disp_form_td4characters_has_profiles($characters_has_profile, $disp_public = false, $profile_type = null)
+ function disp_form_td4characters_has_profiles($characters_has_profile, $disp_public = false, $profile_type = null, $isProfileDefault = false)
{
if ($disp_public === true) {
$publicOnly = false;
} else {
$publicOnly = true;
}
- $this->disp_tds4characters_has_profiles($characters_has_profile, 'form', $publicOnly, $profile_type, null, null, true);
+ $this->disp_tds4characters_has_profiles($characters_has_profile, 'form', $publicOnly, $profile_type, null, null, true, true, $isProfileDefault);
}
/* profile_tablesの設定からView表示を出力 */
- function disp_value4profile_tables($profile_tables, $publicOnly = true, $profile_type = null, $oddTrOptions = null, $evenTrOptions = null, $useCount = false, $continueOddEven = true)
+ function disp_value4profile_tables($profile_tables, $publicOnly = true, $profile_type = null, $oddTrOptions = null, $evenTrOptions = null, $useCount = false, $continueOddEven = true, $isProfileDefault = false)
{
if (empty($profile_tables)) {
return null;
}
/* profile_tablesの設定から入力フォームを出力 */
- function disp_form4profile_tables($profile_tables, $publicOnly = true, $oddTrOptions = null, $evenTrOptions = null, $useCount = false, $continueOddEven = true)
+ function disp_form4profile_tables($profile_tables, $publicOnly = true, $oddTrOptions = null, $evenTrOptions = null, $useCount = false, $continueOddEven = true, $isProfileDefault = false)
{
if (empty($profile_tables)) {
return null;
}
if ($publicOnly === false) {
- $forms[] = $this->dispPublicFlag4Profile(null, $first_num, $first, false);
+ if ($isProfileDefault && isset($last["public_flag"])) {
+ $last = end($profile_tables);
+ $forms[] = $this->dispPublicFlag4Profile(null, $first_num, $last["public_flag"], false);
+ } else {
+ $forms[] = $this->dispPublicFlag4Profile(null, $first_num, $first, false);
+ }
}
$this->character_has_profile_cols++;
/* profile_typeの設定に応じてフォーム表示
* set_profile_type4view($profile)チェック済み前提。
*/
- function disp_forms4profile_type($profile, $form_num = 2, $table_blank = 2, $disp_add_link = false, $character_id = null, $disp_public = false, $options = array())
+ function disp_forms4profile_type($profile, $form_num = 2, $table_blank = 2, $disp_add_link = false, $character_id = null, $disp_public = false, $options = array(), $isProfileDefault = false)
{
- if (!isset($profile['CharactersHasProfile'])) {
- $profile['CharactersHasProfile'] = array();
+ if (!isset($profile['CharactersHasProfile']) || empty($profile['CharactersHasProfile'])) {
+ if (isset($profile['DefaultProfile']) && !empty($profile['DefaultProfile'])) {
+ $profile['CharactersHasProfile'] = $profile['DefaultProfile'];
+ $form_num = $form_num - count($profile['DefaultProfile']) +1;
+ } else {
+ $profile['CharactersHasProfile'] = array();
+ }
}
if ($this->profile_type['is_select'] || $this->profile_type['is_radio'] || $this->profile_type['is_checkbox']) {
} elseif ($this->profile_type['is_radio']) {
$this->disp_radio4profile_selects($profile['ProfileSelect'], $profile['CharactersHasProfile'], false, false, $disp_public);
} elseif ($this->profile_type['is_checkbox']) {
- $this->disp_checkbox4profile_selects($profile['ProfileSelect'], $profile['CharactersHasProfile'], false, false, $disp_public);
+ $this->disp_checkbox4profile_selects($profile['ProfileSelect'], $profile['CharactersHasProfile'], false, false, $disp_public, $isProfileDefault);
}
} elseif ($this->profile_type['is_table']) {
if ($disp_public == true) {
$this->disp_th4profile_tables($profile['ProfileTable'], $tableId, $disp_public);
echo '<tbody>';
if (!empty($profile['CharactersHasProfile'])) {
- $this->disp_form_td4characters_has_profiles($profile['CharactersHasProfile'], $disp_public);
+ $this->disp_form_td4characters_has_profiles($profile['CharactersHasProfile'], $disp_public, null, $isProfileDefault);
}
if (intval($form_num) > 0
}
/* フォームに値入力 */
- function set_form_value($profile_selects, $characters_has_profile)
+ function set_form_value($profile_selects, $characters_has_profile, $isProfileDefault = false)
{
$this->form_id++;
if ($this->profile_type['is_select'] || $this->profile_type['is_radio'] || $this->profile_type['is_checkbox']) {
- return $this->set_form_value_select($profile_selects, $characters_has_profile);
+ return $this->set_form_value_select($profile_selects, $characters_has_profile, $isProfileDefault);
} elseif ($this->profile_type['is_table']) {
return $this->set_form_value_table($characters_has_profile);
} else {
+// return $profile_selects;
return $this->set_form_value_profile($profile_selects, $characters_has_profile);
}
/* profile_select */
/* profile_select_id->profile_idで抽出 */
- function set_form_value_select($profile_selects, $characters_has_profile)
+ function set_form_value_select($profile_selects, $characters_has_profile, $isProfileDefault = false)
{
if (isset($characters_has_profile[0]['value'])) {
$selected = array(
}
/* postからprofile_select_id->profile_idで抽出 */
- function get_selected_profile($profile_select, $characters_has_profile)
+ function get_selected_profile($profile_select, $characters_has_profile, $isProfileDefault = false)
{
$profile = array(
'profile_select_id' => $profile_select['id'],
'profile_id' => $profile_select['profile_id'],
- 'value' => $profile_select['value'],
);
+ if (!empty($isProfileDefault)) {
+ } else {
+ $profile['value'] = $profile_select['value'];
+ }
+
foreach ($characters_has_profile as $v) {
if (Set::contains($v, $profile)) {
return $v;
case 'systems':
case 'character_sheets':
case 'profiles':
+ case 'default_profiles':
case 'profile_selects':
case 'profile_tables':
case 'profile_table_statics':
}
/* テーブル表示 */
+div#defaultProfilesEdit table,
table.CharacterSheet {
width: 780px;
background-color: #FFF;
}
+div#defaultProfilesEdit table,
table.CharacterSheet table {
border-left: 1px solid #CCCCCC;
}
+div#defaultProfilesEdit table tr th,
+div#defaultProfilesEdit table tr td,
table.CharacterSheet tr th,
table.CharacterSheet tr td {
border-right: 1px solid #CCCCCC;
padding: 0;
margin: 0;
}
+div#defaultProfilesEdit table,
table.CharacterSheet tr td.SystemRow table,
table.CharacterSheet tr td.table table {
padding: 0;
border-top: 0 none;
background-color: transparent;
}
+div#defaultProfilesEdit tr td,
tr td.table th,
tr td.table td,
table.CharacterSheet tr td.table th,
{
overflow: hidden;
}
+div#defaultProfilesEdit tr td input,
tr td.table tr td input,
table.CharacterSheet tr td.table tr td input
{
width: auto;
}
+div#defaultProfilesEdit tr td,
tr td.edit tr td,
tr td.edit tr td div.input,
table.CharacterSheet tr td.edit tr td,
form table.CharacterSheet div.text {
display: inline;
}
-
+/* デフォルト入力設定 */
+div#defaultProfilesEdit table {
+ display:block;
}
/* キャラ画像 */
/* プロフィール公開選択 */
.profilePublic {
display: inline;
- margin-bottom: 3px;
vertical-align: top;
padding-left: 0;
margin-right: 8px;