OSDN Git Service

プロフィールのデフォルト入力機能追加
authorCake <cake_67@users.sourceforge.jp>
Fri, 7 Jan 2011 11:44:17 +0000 (20:44 +0900)
committerCake <cake_67@users.sourceforge.jp>
Fri, 7 Jan 2011 11:44:32 +0000 (20:44 +0900)
22 files changed:
app/config/sql/install/upgrade/bto1_0/upgrade.sql [new file with mode: 0644]
app/controllers/app_controller.php
app/controllers/characters_controller.php
app/controllers/default_profiles_controller.php [new file with mode: 0644]
app/controllers/systems_controller.php
app/locale/jpn/LC_MESSAGES/default.po
app/models/app_model.php
app/models/character.php
app/models/characters_has_profile.php
app/models/default_profile.php [new file with mode: 0644]
app/models/profile.php
app/models/profile_select.php
app/models/profile_table.php
app/tests/cases/controllers/default_profiles_controller.test.php [new file with mode: 0644]
app/tests/cases/models/default_profile.test.php [new file with mode: 0644]
app/tests/fixtures/default_profile_fixture.php [new file with mode: 0644]
app/views/characters/edit.ctp
app/views/default_profiles/admin_edit.ctp [new file with mode: 0644]
app/views/elements/system_view.ctp
app/views/helpers/profiledisp.php
app/views/layouts/admin_default.ctp
app/webroot/css/character-sheet.css

diff --git a/app/config/sql/install/upgrade/bto1_0/upgrade.sql b/app/config/sql/install/upgrade/bto1_0/upgrade.sql
new file mode 100644 (file)
index 0000000..06e5928
--- /dev/null
@@ -0,0 +1,24 @@
+/*!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;
+
index 59858d6..3a191fc 100644 (file)
@@ -807,6 +807,125 @@ class AppController extends Controller
                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');
index 9267fa0..ad5ed55 100644 (file)
@@ -229,6 +229,7 @@ class CharactersController extends AppController {
 
                        /* 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']);
@@ -260,9 +261,12 @@ class CharactersController extends AppController {
                                                $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'];
@@ -308,7 +312,7 @@ class CharactersController extends AppController {
                                        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);
                                        }
                                }
                        }
@@ -381,14 +385,18 @@ class CharactersController extends AppController {
                        );
 
                        $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'))) {
@@ -423,6 +431,9 @@ class CharactersController extends AppController {
                                        }
                                } else {
                                }
+                       } else {
+                               $validate_error = current(current(current($this->Character->validationErrors)));
+                               $this->Session->setFlash($validate_error);
                        }
 
                        $this->data = array_merge($character, $this->data);
@@ -1267,125 +1278,6 @@ class CharactersController extends AppController {
 
                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)
        {
diff --git a/app/controllers/default_profiles_controller.php b/app/controllers/default_profiles_controller.php
new file mode 100644 (file)
index 0000000..98abb53
--- /dev/null
@@ -0,0 +1,206 @@
+<?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;
+       }
+}
+
index 4e4756b..a392bcd 100644 (file)
@@ -291,6 +291,7 @@ class SystemsController extends AppController {
                                        'ProfileTable' => array(
                                                'ProfileTableStatic',
                                        ),
+                                       'DefaultProfile',
                                ),
                                'Attachment',
                        );
index 3646c97..fd15565 100644 (file)
@@ -2196,6 +2196,9 @@ msgstr "カスタムCSS"
 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 "未ログイン"
 
@@ -2568,3 +2571,15 @@ 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 "デフォルト入力値設定の保存に失敗しました。"
+
index 1ea1e19..a11a5f8 100644 (file)
@@ -239,6 +239,37 @@ class AppModel extends Model {
                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) 
        {
index 6f72f35..67bf0a1 100644 (file)
@@ -255,6 +255,7 @@ class Character extends AppModel {
                                                        'ProfileTableStatic',
                                                ),
                                                'CharactersHasProfile',
+                                               'DefaultProfile',
                                        ),
                                ),
                                'CharacterProfileArchive',
index f57b99b..3b2a217 100644 (file)
@@ -97,36 +97,4 @@ class CharactersHasProfile extends AppModel {
                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,
-                       ),
-               ));
-       }
-
 }
diff --git a/app/models/default_profile.php b/app/models/default_profile.php
new file mode 100644 (file)
index 0000000..08f8e5d
--- /dev/null
@@ -0,0 +1,87 @@
+<?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;
+       }
+
+}
index 3368cf6..61cf857 100644 (file)
@@ -158,6 +158,19 @@ class Profile extends AppModel {
                        'finderQuery' => '',
                        'deleteQuery' => '',
                        'insertQuery' => ''
+               ),
+               'DefaultProfile' => array(
+                       'className' => 'DefaultProfile',
+                       'foreignKey' => 'profile_id',
+                       'dependent' => true,
+                       'conditions' => '',
+                       'fields' => '',
+                       'order' => '', // Using filesortの原因
+                       'limit' => '',
+                       'offset' => '',
+                       'exclusive' => '',
+                       'finderQuery' => '',
+                       'counterQuery' => ''
                )
        );
 
index fcf964f..45575cc 100644 (file)
@@ -65,6 +65,19 @@ class ProfileSelect extends AppModel {
                        'finderQuery' => '',
                        'deleteQuery' => '',
                        'insertQuery' => ''
+               ),
+               'DefaultProfile' => array(
+                       'className' => 'DefaultProfile',
+                       'foreignKey' => 'profile_select_id',
+                       'dependent' => true,
+                       'conditions' => '',
+                       'fields' => '',
+                       'order' => '', // Using filesortの原因
+                       'limit' => '',
+                       'offset' => '',
+                       'exclusive' => '',
+                       'finderQuery' => '',
+                       'counterQuery' => ''
                )
        );
 
index d6fdba2..d1c34f1 100644 (file)
@@ -118,6 +118,19 @@ class ProfileTable extends AppModel {
                        'finderQuery' => '',
                        'deleteQuery' => '',
                        'insertQuery' => ''
+               ),
+               'DefaultProfile' => array(
+                       'className' => 'DefaultProfile',
+                       'foreignKey' => 'profile_table_id',
+                       'dependent' => true,
+                       'conditions' => '',
+                       'fields' => '',
+                       'order' => '', // Using filesortの原因
+                       'limit' => '',
+                       'offset' => '',
+                       'exclusive' => '',
+                       'finderQuery' => '',
+                       'counterQuery' => ''
                )
        );
 
diff --git a/app/tests/cases/controllers/default_profiles_controller.test.php b/app/tests/cases/controllers/default_profiles_controller.test.php
new file mode 100644 (file)
index 0000000..93da5af
--- /dev/null
@@ -0,0 +1,67 @@
+<?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
diff --git a/app/tests/cases/models/default_profile.test.php b/app/tests/cases/models/default_profile.test.php
new file mode 100644 (file)
index 0000000..9f433ad
--- /dev/null
@@ -0,0 +1,18 @@
+<?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
diff --git a/app/tests/fixtures/default_profile_fixture.php b/app/tests/fixtures/default_profile_fixture.php
new file mode 100644 (file)
index 0000000..4de7357
--- /dev/null
@@ -0,0 +1,26 @@
+<?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
index 80538f3..0249951 100644 (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>
diff --git a/app/views/default_profiles/admin_edit.ctp b/app/views/default_profiles/admin_edit.ctp
new file mode 100644 (file)
index 0000000..958cfcb
--- /dev/null
@@ -0,0 +1,63 @@
+<?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>
index 4b37db4..2b484ec 100644 (file)
@@ -355,7 +355,16 @@ foreach ($system['Profile'] as $profile):
        } else {
                $rows = 2;
        }
-       $profiledisp->disp_forms4profile_type($profile, $rows, 0);
+       $profiledisp->disp_forms4profile_type(
+               $profile, 
+               $rows, 
+               0,
+               false,
+               null,
+               true,
+               array(),
+               true
+       );
 ?>
 </td>
 </tr>
@@ -383,6 +392,10 @@ foreach ($system['Profile'] as $profile):
                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'])
        );
index c71b600..bca6eea 100644 (file)
@@ -265,13 +265,13 @@ class ProfiledispHelper extends Helper {
 
 
        /* 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'])) {
@@ -328,7 +328,7 @@ class ProfiledispHelper extends Helper {
        }
 
        /* 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;
@@ -340,7 +340,7 @@ class ProfiledispHelper extends Helper {
                        }
 
                        $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,
@@ -351,7 +351,7 @@ class ProfiledispHelper extends Helper {
                                        'div' => array(
                                                'class' => 'input checkbox inline'
                                        ),
-                               ), $label, $legend, $disp_public
+                               ), $label, $legend, $disp_public, $isProfileDefault
                        );
                }
        }
@@ -429,7 +429,7 @@ class ProfiledispHelper extends Helper {
        }
 
        /* 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;
@@ -450,7 +450,6 @@ class ProfiledispHelper extends Helper {
                        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;
@@ -474,9 +473,9 @@ class ProfiledispHelper extends Helper {
 
                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;
@@ -492,18 +491,18 @@ class ProfiledispHelper extends Helper {
        }
 
        /* 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;
@@ -530,7 +529,7 @@ class ProfiledispHelper extends Helper {
        }
 
        /* 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;
@@ -604,7 +603,12 @@ class ProfiledispHelper extends Helper {
                }
 
                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++;
@@ -661,10 +665,15 @@ class ProfiledispHelper extends Helper {
        /* 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']) {
@@ -673,7 +682,7 @@ class ProfiledispHelper extends Helper {
                        } 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) {
@@ -691,7 +700,7 @@ class ProfiledispHelper extends Helper {
                        $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 
@@ -859,15 +868,16 @@ class ProfiledispHelper extends Helper {
        }
 
        /* フォームに値入力 */
-       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);
                }
 
@@ -875,7 +885,7 @@ class ProfiledispHelper extends Helper {
 
        /* 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(
@@ -903,14 +913,18 @@ class ProfiledispHelper extends Helper {
        }
 
        /* 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;
index 0a3f916..ba3daee 100644 (file)
@@ -138,6 +138,7 @@ switch ($this->params["controller"]) {
        case 'systems':
        case 'character_sheets':
        case 'profiles':
+       case 'default_profiles':
        case 'profile_selects':
        case 'profile_tables':
        case 'profile_table_statics':
index c12817c..03e475f 100644 (file)
 }
 
 /* テーブル表示 */
+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;
@@ -47,6 +51,7 @@ table.CharacterSheet tr td.table {
        padding: 0;
        margin: 0;
 }
+div#defaultProfilesEdit table,
 table.CharacterSheet tr td.SystemRow table,
 table.CharacterSheet tr td.table table {
        padding: 0;
@@ -54,6 +59,7 @@ table.CharacterSheet tr td.table table {
        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, 
@@ -61,11 +67,13 @@ table.CharacterSheet tr td.table td
 {
        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,
@@ -138,7 +146,9 @@ table.CharacterSheet td.CharacterProfileData div.blank {
 form table.CharacterSheet div.text {
        display: inline;
 }
-
+/* デフォルト入力設定 */
+div#defaultProfilesEdit table {
+       display:block;
 }
 
 /* キャラ画像 */
@@ -196,7 +206,6 @@ div.view div.attachments {
 /* プロフィール公開選択 */
 .profilePublic {
        display: inline;
-       margin-bottom: 3px;
        vertical-align: top;
        padding-left: 0;
        margin-right: 8px;