<?php
+
class CharactersController extends AppController {
var $name = 'Characters';
}
if (!empty($this->data)) {
+ $this->post_data = $this->data;
// 新hasProfile処理
if ($this->data['CharactersHasProfile']) {
unset($this->data['CharactersHasProfile'][$k]);
continue;
}
-
- // select設定のvalue
- if (isset($v['profile_select_id'])) {
- if (!isset($this->Character->ProfileSelect)) {
- $this->Character->set_model('ProfileSelect');
-
- }
- $selected_profile_value = $this->Character->ProfileSelect->find('list', array('conditions' => array('ProfileSelect.id' => $v['value']), 'fields' => array('ProfileSelect.value')));
if (is_array($v['value'])) {
$this->data['CharactersHasProfile'][$k]['value'] = $v['value'][0];
- }
- $this->data['CharactersHasProfile'][$k]['profile_select_id'] = $this->data['CharactersHasProfile'][$k]['value'];
- $this->data['CharactersHasProfile'][$k]['value'] = current($selected_profile_value);
}
}
}
$this->redirect(array('action'=>'view', $id));
}
}
- $this->post_data = $this->data;
$this->data = $character;
$this->data['Character'] = $this->post_data['Character'];
$this->data['Character']['id'] = $id;
+
+ foreach($this->data['System']['Profile'] as $k1 => $profile) {
+ foreach($profile['CharactersHasProfile'] as $k2 => $v) {
+ $postdata = array_shift($this->post_data['CharactersHasProfile']);
+ if (isset($v['profile_select_id']) && !isset($postdata['profile_select_id'])) {
+ array_unshift($this->post_data['CharactersHasProfile'], $postdata);
+ continue;
+ }
+ if (is_array($postdata['value'])) {
+ $postdata['value'] = $postdata['value'][0];
+ }
+ $this->data['System']['Profile'][$k1]['CharactersHasProfile'][$k2]['value'] = $postdata['value'];
+ if (isset($postdata['profile_select_id'])) {
+ $this->data['System']['Profile'][$k1]['CharactersHasProfile'][$k2]['profile_select_id'] = $postdata['profile_select_id'];
+ }
+ }
+ }
}
if (empty($this->data)) {
function disp4profile_selects($profile_selects, $option = array())
{
foreach ($profile_selects as $k => $v) {
- $options[$v['id']] = stripcslashes($v['value']);
+ $options[stripcslashes($v['value'])] = stripcslashes($v['value']);
}
$option = array_merge(
array(
$selected_value = $selected['value'];
} else {
$first = reset($profile_selects);
- $selected_value = $first['id'];
+ $selected_value = $first['value'];
}
$option = array(
echo $table_cells;
}
+
+ /* characters_has_profileからtdフォーム出力 */
+ function disp_form_td4characters_has_profiles($characters_has_profile)
+ {
+ if (!isset($this->ProfileTable)) {
+ App::import('Model', 'ProfileTable');
+ $this->ProfileTable = new ProfileTable;
+ }
+ $profileTable_columns = $this->ProfileTable->find('list', array(
+ 'conditions' => array('ProfileTable.profile_id' => $characters_has_profile[0]['profile_id']),
+ 'fields' => array('ProfileTable.id'),
+ 'recursive' => -1,
+ ));
+
+ $i = 1;
+ $profiles[$i] = array();
+ foreach($characters_has_profile as $k => $v) {
+ if (isset($profiles[$i][$v['profile_table_id']])) {
+ $i++;
+
+ foreach($profileTable_columns as $v2) {
+ if ($v['profile_table_id'] != $v2) {
+ break;
+ }
+ $profiles[$i][$v2] = array();
+ }
+ }
+
+ $profiles[$i][$v['profile_table_id']] = $v;
+ }
+
+ $forms = array();
+ foreach($profiles as $v) {
+ $forms = $this->disp_form4profile_tables($v);
+ }
+
+/* if (!isset($characters_has_profile['profile_table_id'])|| empty($characters_has_profile['profile_table_id'])) {
+ return null;
+ }
+
+ if (!isset($this->ProfileTable)) {
+ App::import('Model', 'ProfileTable');
+ $this->ProfileTable = new ProfileTable;
+ }
+ $profileTable = $this->ProfileTable->find('first', array(
+ 'conditions' => array('ProfileTable.id' => $characters_has_profile['profile_table_id']),
+ 'recursive' => -1,
+ ));
+ $form = $this->disp_form4profile_tables($profileTable);
+*/
+
+// var_dump($profileTable);
+ $this->disp_td4characters_has_profiles($forms);
+ }
+
/* profile_tablesの設定から入力フォームを出力 */
function disp_form4profile_tables($profile_tables, $tr_options = array(), $td_options = array())
{
if ($profile['profile_type'] == 'table') {
$this->profile_type['is_table'] = true;
}
- if ($profile['profile_type'] == 'm-select' || $profile['profile_type'] == 'm-table') {
+ if ($profile['profile_type'] == 'm-select' || $profile['profile_type'] == 'm-input') {
$this->profile_type['is_multi'] = true;
}
}
*/
function disp_forms4profile_type($profile, $admin = false, $form_num = 2, $table_blank = 2)
{
+
if ($this->profile_type['is_select'] || $this->profile_type['is_radio'] || $this->profile_type['is_checkbox']) {
if ($this->profile_type['is_select']) {
$this->disp_select4profile_selects($profile['ProfileSelect'], $profile['CharactersHasProfile']);
} elseif ($this->profile_type['is_table']) {
echo '<table>';
$this->disp_th4profile_tables($profile['ProfileTable'], $profile['CharactersHasProfile']);
+ echo '<tbody>';
+ if (!empty($profile['CharactersHasProfile'])) {
+ $this->disp_form_td4characters_has_profiles($profile['CharactersHasProfile']);
+ }
+
if (empty($profile['CharacterHasProfile'])) {
- echo '<tbody>';
- if (!empty($profile['CharactersHasProfile'])) {
- foreach($profile['CharactersHasProfile'] as $v) {
- $this->disp_form4profile_tables($profile['ProfileTable'], $v);
- }
- }
if (intval($form_num) > 0) {
for ($i=0; $i<$form_num; $i++) {
$this->disp_form4profile_tables($profile['ProfileTable']);
if (intval($table_blank) > 0) {
$this->disp_blank_td4profile_tables($profile['ProfileTable'], intval($table_blank));
}
- echo '</tbody>';
}
+ echo '</tbody>';
echo '</table>';
if ($admin === true) {
echo '<div class="edit_link">'.$this->Html->link(__('Edit Table', true), array('controller' => 'profile_tables', 'action' => 'admin_listview', $profile['id'])).'</div>';
/* フォームに値入力 */
function set_form_value($profile_selects, $characters_has_profile)
{
- echo $this->form_id;
-
$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);
} elseif ($this->profile_type['is_table']) {
- return $this->set_form_value_table($profile_selects, $characters_has_profile);
+ return $this->set_form_value_table($characters_has_profile);
} else {
return $this->set_form_value_profile($profile_selects, $characters_has_profile);
}
{
if (isset($characters_has_profile[0]['id'])) {
$selected = array(
- 'value' => $characters_has_profile[0]['profile_select_id'],
+ 'value' => $characters_has_profile[0]['value'],
'public_flag' => $characters_has_profile[0]['public_flag'],
'link_value' => $characters_has_profile[0]['link_value'],
);
}
return array();
+
}
}