3 class CharactersController extends AppController {
5 var $name = 'Characters';
17 var $actionMapPlus = array(
18 'add_milti_profiles' => 'update',
19 'change_system' => 'update',
20 'set_status' => 'update',
23 var $disableTokenActions = array();
24 var $post_data = array();
28 function beforeFilter() {
30 parent::beforeFilter();
33 $this->AuthPlus->allow('view');
34 $this->AuthPlus->allow('index');
37 function beforeRender()
39 parent::beforeRender();
41 $this->set_public_flag4view();
42 $this->set_status4view();
48 function index($id = null) {
52 function view($id = null) {
54 $this->Session->setFlash(__('Invalid Character.', true));
55 $this->redirect(array('action'=>'index'));
58 $character = $this->_view($id, array(), false);
60 if (!$this->check_public_flag($character['System'])) {
61 unset($character['System']['Profile']);
64 $this->set('maxPictures', $this->check_character_picture_max(count($character['CharacterPicture'])));
67 if ($this->isOwner($character['Character'], $this->user_id)) {
70 $this->set('isOwner', $isOwner);
72 // キャラ画像のpublic_flagチェック
73 if ($isOwner !== true && !empty($character['CharacterPicture'])) {
74 foreach($character['CharacterPicture'] as $k => $v) {
75 if (!$this->check_public_flag2($v)) {
76 unset($character['CharacterPicture'][$k]);
81 $this->set('character', $this->HtmlEscape->nl2br_escaped($character));
85 $systems = $this->_get_systems();
87 if (!empty($this->data)) {
88 $this->data['Character']['user_id'] = $this->user_id;
90 $this->Character->create();
91 if ($this->Character->save($this->data, array('fieldList' => $this->Character->fields['add']))) {
94 $this->Session->setFlash(sprintf(__('%s has been saved.', true), $this->data['Character']['name']));
95 $this->redirect(array('controller' => 'characters', 'action'=>'view', $this->Character->id));
97 $this->Session->setFlash(__('The data could not be saved. Please, try again.', true));
101 $this->set('systems', $systems);
102 $this->set('isOwner', false);
105 function edit($id = null) {
106 if (!$id && empty($this->data)) {
107 $this->Session->setFlash(__('Invalid ID.', true));
108 $this->redirect(array('action'=>'index'));
112 $this->Character->System->hasMany['Profile']['fields'] = '';
113 $this->Character->System->Profile->hasMany['CharactersHasProfile']['fields'] = '';
114 unset($this->Character->hasMany['CharacterProfileArchive']);
116 $character = $this->_get_character($id, array(), false);
117 if (!$this->isOwner($character['Character'], $this->user_id)) {
118 $this->Session->setFlash(__('No Permission', true));
119 $this->redirect(array('action'=>'index'));
123 if (!$this->check_public_flag($character['System'])) {
124 $this->redirect(array('action'=>'change_system', $id));
127 if (empty($this->data)) {
128 $character['System']['Profile'] = $this->_set_profile_table2characters_has_profiles($character['System']['Profile']);
131 if (!empty($this->data)) {
132 $this->post_data = $this->data;
134 if (isset($this->data['CharactersHasProfile'])) {
135 $this->data['CharactersHasProfile'] = $this->_set_new_characters_has_profile($this->data['CharactersHasProfile']);
139 $this->_set_validate4characters_has_profile($character['System']['id']);
140 if ($this->Character->saveAll($this->data, array('validate' => 'only'))) {
143 $this->Character->CharactersHasProfile->deleteAll(array(
144 'CharactersHasProfile.character_id' => $id
148 $this->data['Character']['id'] = $id;
149 $this->Character->create();
151 if ($this->Character->saveAll($this->data, array(
153 'fieldList' => array_merge(
154 $this->Character->fields['edit'],
155 $this->Character->CharactersHasProfile->fields['add']
161 if (isset($this->data['Character']['archive']) && $this->data['Character']['archive'] == 1) {
162 $this->Character->saveCharacterProfile($this->Character->id, $this->data);
165 $this->Session->setFlash(sprintf(__('%s has been saved.', true), $this->data['Character']['name']));
166 $this->redirect(array('action'=>'view', $id));
170 $this->data = array_merge($character, $this->data);
171 $this->data['Character'] = $this->post_data['Character'];
172 $this->data['Character']['id'] = $id;
174 foreach($this->data['System']['Profile'] as $k1 => $profile) {
175 foreach($profile['CharactersHasProfile'] as $k2 => $v) {
176 $postdata = array_shift($this->post_data['CharactersHasProfile']);
177 if (isset($v['profile_select_id']) && !isset($postdata['profile_select_id'])) {
178 array_unshift($this->post_data['CharactersHasProfile'], $postdata);
181 if (is_array($postdata['value'])) {
182 $postdata['value'] = $postdata['value'][0];
184 $this->data['System']['Profile'][$k1]['CharactersHasProfile'][$k2]['value'] = $postdata['value'];
185 if (isset($postdata['profile_select_id'])) {
186 $this->data['System']['Profile'][$k1]['CharactersHasProfile'][$k2]['profile_select_id'] = $postdata['profile_select_id'];
192 if (empty($this->data)) {
193 $this->data = $character;
194 $this->data['Character'] = $this->_restore_html_character($this->data['Character'], true);
196 $this->data['System']['Profile'] = $this->_restore_html_characters_has_profiles($this->data['System']['Profile'], true);
198 $this->set('isOwner', true);
201 function add_milti_profiles($id = null) {
202 if (!$id || !CorePlus::is_valid($this->params['named'], 'profile_id')) {
203 $this->Session->setFlash(__('Invalid ID.', true));
204 $this->redirect(array('action'=>'index'));
208 $this->Character->System->hasMany['Profile']['fields'] = '';
209 $this->Character->System->Profile->hasMany['CharactersHasProfile']['fields'] = '';
210 unset($this->Character->hasMany['CharacterProfileArchive']);
212 $character = $this->_get_character($id);
213 if (!$this->isOwner($character['Character'], $this->user_id)) {
214 $this->Session->setFlash(__('No Permission', true));
215 $this->redirect(array('action'=>'index'));
218 if (!$this->check_public_flag($character['System'])) {
219 $this->redirect(array('action'=>'change_system', $id));
223 if (empty($character['System']['Profile'])) {
224 $this->Session->setFlash(__('Invalid Profile.', true));
225 $this->redirect(array('action'=>'view', $id));
228 $profile_id = $this->params['named']['profile_id'];
230 if (empty($this->data)) {
232 foreach ($character['System']['Profile'] as $profile) {
233 if ($profile['id'] == $profile_id) {
240 $this->Session->setFlash(__('No Profile.', true));
241 $this->redirect(array('action'=>'view', $id));
244 $character['System']['Profile'] = array();
245 $character['System']['Profile'][0] = $target;
247 $character['System']['Profile'] = $this->_set_profile_table2characters_has_profiles($character['System']['Profile']);
250 if (!empty($this->data)) {
251 $this->post_data = $this->data;
253 $this->data['Character'] = array_merge($character['Character'], $this->data['Character']);
254 $this->data['Character'] = $this->_restore_html_character($this->data['Character']);
255 $this->data['Character']['__Token'] = $this->post_data['Character']['__Token'];
256 $this->data['Character']['modified'] = null;
259 $this->data['CharactersHasProfile'] = $this->_set_new_characters_has_profile($this->data['CharactersHasProfile'], $profile_id, $character['System']['Profile']);
262 $this->_set_validate4characters_has_profile($character['System']['id']);
263 if ($this->Character->saveAll($this->data, array('validate' => 'only'))) {
266 $this->Character->CharactersHasProfile->deleteAll(array(
267 'CharactersHasProfile.character_id' => $id
271 $this->Character->create();
272 if ($this->Character->saveAll($this->data, array(
274 'fieldList' => array_merge(
275 $this->Character->CharactersHasProfile->fields['add']
281 if (isset($this->data['Character']['archive']) && $this->data['Character']['archive'] == 1) {
282 $this->Character->saveCharacterProfile($this->Character->id, $this->data);
285 $this->Session->setFlash(sprintf(__('%s has been saved.', true), $this->data['Character']['name']));
287 $this->redirect(array('action'=>'view', $id));
289 $this->data = array_merge($character, $this->data);
293 $this->data = $character;
294 $this->data['Character'] = $this->post_data['Character'];
295 $this->data['Character']['id'] = $id;
299 if (empty($this->data)) {
300 $this->data = $character;
301 $this->data['System']['Profile'] = $this->_restore_html_characters_has_profiles($this->data['System']['Profile']);
304 $this->set('isOwner', true);
307 function change_system($id = null) {
309 $this->Session->setFlash(__('Invalid ID.', true));
310 $this->redirect(array('action'=>'index'));
314 $this->Character->System->hasMany['Profile']['fields'] = '';
315 $this->Character->System->Profile->hasMany['CharactersHasProfile']['fields'] = '';
317 $character = $this->_get_character($id);
318 if (!$this->isOwner($character['Character'], $this->user_id)) {
319 $this->Session->setFlash(__('No Permission', true));
320 $this->redirect(array('action'=>'index'));
324 if (isset($character['System']) && !empty($character['System'])) {
326 if ($this->check_public_flag($character['System'])) {
327 $this->redirect(array('action'=>'edit', $id));
330 $this->set('isChange', true);
334 if (!empty($this->data)) {
335 $this->data['Character']['id'] = $id;
337 // validateはsystem_idのみ
338 $this->Cahracter['validate'] = array(
339 'system_id' => array(
340 'validSystemId' => array(
341 'rule' => array('validSystemId', true),
342 'allowEmpty' => false,
347 if ($this->Character->save(
351 'fieldList' => array('system_id'),
354 $this->Session->setFlash(__('The new system has been saved', true));
356 $this->redirect(array('action'=>'view', $id));
358 $this->Session->setFlash(__('The data could not be saved. Please, try again.', true));
362 $this->set('isOwner', true);
363 $this->set('character', $character);
365 $systems = $this->_get_systems();
366 $this->set('systems', $systems);
370 function set_status($id = null) {
371 if (!$id || !isset($this->params['named']['mode'])) {
372 $this->Session->setFlash(__('Invalid ID.', true));
373 $this->redirect(array('controller' => 'characters', 'action'=>'index'));
376 $character = $this->_get_character4character_id($id, $this->user_id, 'public');
378 if ($this->params['named']['mode'] != 'main_picture' && $this->params['named']['mode'] != 'full_length') {
379 $this->Session->setFlash(__('Invalid URL.', true));
380 $this->redirect(array('controller' => 'character_pictures', 'action'=>'index', $id));
384 $new_character_picture = null;
385 if (isset($this->params['named']['new_picture_id']) && $this->params['named']['new_picture_id'] != 'null') {
386 if ($character['CharacterPicture']) {
387 foreach($character['CharacterPicture'] as $k => $v) {
388 if ($v['id'] == $this->params['named']['new_picture_id']) {
389 $new_character_picture = CorePlus::get_value($v, 'Attachment.0.basename');
394 if (!$new_character_picture) {
395 $this->Session->setFlash(__('Invalid data.', true));
396 $this->redirect(array('controller' => 'character_pictures', 'action'=>'index', $id));
401 $this->Character->id = $id;
402 $this->data['Character'][$this->params['named']['mode']] = $new_character_picture;
403 $this->Character->save(
406 'fieldList' => array(
407 $this->params['named']['mode']
412 $this->Session->setFlash(__('CharacterPicture Configuration has been saved.', true));
413 $this->redirect(array('controller' => 'character_pictures', 'action' => 'index', $id));
416 function delete($id = null) {
418 $this->Session->setFlash(__('Invalid id for Character', true));
419 $this->redirect(array('action'=>'index'));
422 if ($this->_delete($id)) {
423 $this->redirect(array('controller' => 'users', 'action'=>'index'));
428 function admin_index($id = null) {
429 unset($this->Character->belongsTo['System']['conditions']['System.public_flag']);
430 $this->_index($id, array('isAdmin' => true));
433 function admin_view($id = null) {
435 $this->Session->setFlash(__('Invalid Character.', true));
436 $this->redirect(array('action' => 'admin_index'));
439 $character = $this->_view($id, array(), true);
441 $this->set('character', $this->HtmlEscape->nl2br_escaped($character));
444 function admin_edit($id = null) {
445 if (!$id && empty($this->data)) {
446 $this->Session->setFlash(__('Invalid ID.', true));
447 $this->redirect(array('action'=>'index'));
451 $this->Character->System->hasMany['Profile']['fields'] = '';
452 $this->Character->System->Profile->hasMany['CharactersHasProfile']['fields'] = '';
453 unset($this->Character->hasMany['CharacterProfileArchive']);
455 $character = $this->_get_character($id, array(), true);
457 $this->Session->setFlash(__('No Character', true));
458 $this->redirect(array('action'=>'index'));
461 if (empty($this->data)) {
462 $character['System']['Profile'] = $this->_set_profile_table2characters_has_profiles($character['System']['Profile']);
465 if (!empty($this->data)) {
466 if (isset($this->data['Character']['mode']) && $this->data['Character']['mode'] == 'set_private') {
467 $this->data['Character']['public_flag'] = 'private';
468 } elseif (isset($this->data['Character']['mode']) && $this->data['Character']['mode'] == 'set_public') {
469 $this->data['Character']['public_flag'] = 'public';
470 } elseif (isset($this->data['Character']['mode']) && $this->data['Character']['mode'] == 'delete_confirm') {
471 $this->redirect(array('controller' => 'characters', 'action'=>'admin_delete', $id));
473 $this->Session->setFlash(sprintf(__('Invalid data.', true), $this->data['Character']['name']));
474 $this->redirect(array('action'=>'view', $id));
477 $this->data['Character']['id'] = $id;
478 $this->Character->create();
479 if ($this->Character->save($this->data, array(
481 'fieldList' => array(
487 $this->Session->setFlash(sprintf(__('%s has been saved.', true), $character['Character']['name']));
488 $this->redirect(array('action'=>'view', $id));
491 $this->data = array_merge($character, $this->data);
492 $this->data['Character']['id'] = $id;
495 if (empty($this->data)) {
496 $this->data = $character;
497 $this->data['Character'] = $this->_restore_html_character($this->data['Character'], true);
499 $this->data['System']['Profile'] = $this->_restore_html_characters_has_profiles($this->data['System']['Profile'], true);
503 function admin_delete($id = null) {
505 $this->Session->setFlash(__('Invalid id for Character', true));
506 $this->redirect(array('action'=>'index'));
509 if ($this->_delete($id, array(), true)) {
510 $this->redirect(array('action'=>'index'));
516 function _index($id, $conditions = array(), $limit = 20, $fields = array(), $contain = array(), $order = array(), $page = 1) {
517 if (isset($conditions['isAdmin']) && $conditions['isAdmin'] === true) {
522 unset($conditions['isAdmin']);
525 if (isset($this->params['named']['system']) && intval($this->params['named']['system'])) {
527 $conditions['System.id'] = $this->params['named']['system'];
528 if ($isAdmin === false) {
529 $conditions['System.public_flag'] = 'public';
532 $this_system = $this->Character->System->find('first', array(
533 'conditions' => $conditions,
537 if (!isset($this_system['System'])) {
538 $this->Session->setFlash(__('Invalid System.', true));
539 $this->redirect(array('controller' => 'systems', 'action' => 'index'));
541 $this_system = $this->_restore_html_system($this_system);
543 $this->set('this_system', $this_system);
545 $contain = array_merge(array('System'), (array)$contain);
551 $conditions = array('User.id' => $id);
553 $user = $this->Character->User->find('first', array(
554 'conditions' => $conditions,
563 $this->Session->setFlash(__('Invalid Id.', true));
564 $this->redirect(array('action'=>'index'));
567 $contain = array_merge($contain, array('User'));
569 $this->set('userSet', $user);
572 if ($user['User']['id'] == $this->user_id) {
577 $conditions = array();
579 $conditions['Character.user_id'] = $id;
581 if ($isAdmin === true) {
582 $conditions['isAdmin'] = true;
584 if (isset($this->params['named']['system']) && intval($this->params['named']['system'])) {
585 $conditions['Character.system_id'] = $this->params['named']['system'];
587 $characters = $this->HtmlEscape->nl_unescape($this->_get_characters_page4user_id($id, $conditions, $limit, $fields, $contain, $order, $page));
589 $this->set('characters', $characters);
591 $this->set('isOwner', false);
592 $this->set('isOwner_userSet', $isOwner);
595 function _view($id, $conditions = array(), $isAdmin = false) {
596 $this->helpers[] = 'CharacterSheet';
599 if (isset($this->params['named']['mode']) && !empty($this->params['named']['mode'])) {
600 $this->view = 'Theme';
601 $this->theme = $this->params['named']['mode'];
605 $orig_character = $this->_get_character($id, $conditions, $isAdmin);
606 $character = $this->Character->set_profiles2view($orig_character);
608 Configure::write('isOwner', false);
609 if ($isAdmin || CorePlus::isOwner($character['Character'], $this->user_id)) {
610 Configure::write('isOwner', true);
614 $this->set('systemValid', 'public');
615 if (!$character['System']) {
616 $this->set('systemValid', false);
618 if (!$this->check_public_flag($character['System'])) {
619 $this->set('systemValid', 'unpublic');
621 $character = $this->_restore_html_system($character);
626 function _delete($id = null, $conditions = array(), $isAdmin = false) {
628 $this->Session->setFlash(__('Invalid id for Character', true));
629 $this->redirect(array('action'=>'index'));
632 $character = $this->_view($id, $conditions, $isAdmin);
633 if (empty($character)) {
634 $this->Session->setFlash(__('No Character', true));
635 $this->redirect(array('action'=>'index'));
637 $this->set('character', $character);
639 if (!$isAdmin && !$this->isOwner($character['Character'], $this->user_id)) {
640 $this->Session->setFlash(__('No Permission', true));
641 $this->redirect(array('action'=>'index'));
643 $this->set('isOwner', true);
645 if (!empty($this->data)) {
646 if ($this->data['Character']['confirm'] == 'yes') {
648 $this->data['Character']['id'] = $id;
649 $this->data['Character']['main_picture'] = null;
650 $this->data['Character']['full_length'] = null;
651 $this->data['Character']['deleted'] = true;
652 $this->data['Character']['deleted_date'] = date('Y-m-d H:i:s');
654 $this->Character->create();
655 if ($this->Character->save(
659 'fieldList' => array(
668 // CharactersHasProfiles
669 $this->Character->CharactersHasProfile->updateAll(
671 'CharactersHasProfile.public_flag' => "'private'",
674 'CharactersHasProfile.character_id' => $id
678 // CharacterProfileArchives
679 $date = date('Y-m-d H:i:s');
680 $this->Character->CharacterProfileArchive->updateAll(
682 'CharacterProfileArchive.deleted' => true,
683 'CharacterProfileArchive.deleted_date' => "'$date'",
686 'CharacterProfileArchive.character_id' => $id
691 if (isset($character['CharacterPicture']) && !empty($character['CharacterPicture'])) {
692 foreach ($character['CharacterPicture'] as $picture) {
693 $this->Character->CharacterPicture->delete($picture['id']);
697 $this->Session->setFlash(__('Character deleted', true));
701 $this->Session->setFlash(__('The Character could not be deleted.', true));
710 function _get_character($id, $conditions = array(), $isAdmin = false)
712 $character = $this->Character->get_character($id, $conditions, $isAdmin);
714 if (empty($character)) {
715 $this->Session->setFlash(__('No Character', true));
716 $this->redirect(array('action'=>'index'));
719 if ($isAdmin === false && !$this->check_public_flag($character['Character'])) {
720 $this->Session->setFlash(__('No Permission', true));
721 $this->redirect(array('action'=>'index'));
727 // ProfileTableをCharacterHasProfilesのTableの形式にセット
728 function _set_profile_table2characters_has_profiles($profile)
730 if (!empty($profile[0]['CharactersHasProfile'])) {
734 foreach($profile as $k => $v) {
735 if (empty($v['ProfileTable'])) {
739 $rows = count($v['CharactersHasProfile']);
740 for($i=0; $i<$rows; $i++) {
741 foreach($v['ProfileTable'] as $k2 => $v2) {
742 if (isset($v2['CharactersHasProfile'][$i])) {
743 $tmp[] = $v2['CharactersHasProfile'][$i];
744 } elseif (isset($v['CharactersHasProfile'][$i])) {
745 $tmp[] = $v['CharactersHasProfile'][$i];
753 $profile[$k]['CharactersHasProfile'] = $tmp;
759 /* POSTのCharactersHasProfileを処理 */
760 function _set_new_characters_has_profile($characters_has_profiles, $profile_id = null, $now_data = array())
762 $prev_profile_id = null;
763 $profileTable_tmp = array();
766 foreach ($characters_has_profiles as $k => $v) {
767 if (!empty($character_id)) {
768 $characters_has_profiles[$k]['character_id'] = $character_id;
771 if (is_array($v['value'])) {
772 $characters_has_profiles[$k]['value'] = $v['value'][0];
776 $characters_has_profiles[$k]['value'] = Sanitize::html($characters_has_profiles[$k]['value']);
777 $characters_has_profiles[$k]['value'] = preg_replace('/[\\\n]/', '', $characters_has_profiles[$k]['value']);
778 $characters_has_profiles[$k]['value'] = preg_replace('/[\\\r]/', '', $characters_has_profiles[$k]['value']);
780 if (isset($v['is_textarea']) && $v['is_textarea'] == 1) {
781 $characters_has_profiles[$k]['value'] = str_replace(array("\n\r", '\n', "\r"), '<br />', $characters_has_profiles[$k]['value']);
782 $characters_has_profiles[$k]['value'] = str_replace("\\", '', $characters_has_profiles[$k]['value']);
784 $characters_has_profiles[$k]['value'] = Sanitize::stripAll($characters_has_profiles[$k]['value']);
786 // 空の値処理, public_flag
787 // table: 一時保管して全項目空の場合行削除
788 if (CorePlus::is_valid($v, 'profile_table_id')) {
789 if (isset($profileTable_tmp[$v['profile_id']][$i][$v['profile_table_id']])) {
795 if ($public == null && isset($characters_has_profiles[$k]['public_flag'])) {
796 $public = $v['public_flag'];
798 if ($v['profile_table_static_id']) {
799 $characters_has_profiles[$k]['public_flag'] = 'public';
802 $characters_has_profiles[$k]['public_flag'] = $public;
805 $profileTable_tmp[$v['profile_id']][$i][$v['profile_table_id']] = array($characters_has_profiles[$k], $k);
807 } elseif (empty($v['value'])) {
808 unset($characters_has_profiles[$k]);
812 // table: 空行削除、不正profile_table_idデータ削除
813 if (!empty($profileTable_tmp)) {
814 if (!isset($this->Character->ProfileTable)) {
815 $this->Character->ProfileTable = CorePlus::set_model('ProfileTable');
817 foreach($profileTable_tmp as $profile_id => $v) {
818 $profile_table_columns = $this->Character->ProfileTable->find('list', array(
819 'conditions' => array('ProfileTable.profile_id' => $profile_id),
820 'fields' => array('ProfileTable.id'),
821 'order' => array('ProfileTable.sort_order' => 'asc'),
825 foreach ($v as $i => $profile_tables) {
827 $diff_keys = array_diff_key($profile_tables, $profile_table_columns);
828 if (!empty($diff_keys)) {
829 foreach($diff_keys as $dvalue) {
830 unset($characters_has_profiles[$dvalue[1]]);
836 foreach($profile_table_columns as $k2 => $columns) {
837 if (CorePlus::is_valid($profile_tables, $columns.'.0.value')) {
842 if ($delete_flg === true) {
843 foreach ($profile_tables as $delk) {
844 unset($characters_has_profiles[$delk[1]]);
852 if (!is_null($profile_id) && !empty($now_data)) {
855 foreach($now_data as $k => $v) {
856 if ($v['id'] == $profile_id) {
857 $v['CharactersHasProfile'] = $characters_has_profiles;
860 foreach ($v['CharactersHasProfile'] as $k2 => $v2) {
862 if (isset($tmp[$i]['id'])) {
863 unset($tmp[$i]['id']);
865 if (isset($tmp[$i]['character_id'])) {
866 unset($tmp[$i]['character_id']);
873 $characters_has_profiles = $tmp;
876 return $characters_has_profiles;
879 // CharactersHasProfileの追加valiadte設定
880 function _set_validate4characters_has_profile($system_id)
882 $this->Character->CharactersHasProfile->validate['profile_id']['validProfileId'] = array(
883 'rule' => array('validProfileId', $system_id),
885 $this->Character->CharactersHasProfile->validate['profile_select_id']['validProfileSelectId'] = array(
886 'rule' => array('validProfileSelectId', $system_id),
887 'allowEmpty' => true,
889 $this->Character->CharactersHasProfile->validate['profile_table_id']['validProfiletableId'] = array(
890 'rule' => array('validProfiletableId', $system_id),
891 'allowEmpty' => true,
896 function _restore_html_character($data, $nl2br = false) {
897 $data['name'] = $this->{$this->modelClass}->restore_html($data['name'], false, false, false);
898 $data['notes'] = $this->{$this->modelClass}->restore_html($data['notes'], false, false, false);
900 $data['notes'] = str_replace('<br />', "\n", $data['notes']);
906 function _restore_html_characters_has_profiles($profile, $nl2br = false) {
907 if (empty($profile)) {
911 foreach($profile as $k => $v) {
912 if (empty($v['CharactersHasProfile'])) {
915 $profile[$k]['CharactersHasProfile'] = $this->__restore_html_characters_has_profiles($v['CharactersHasProfile'], $nl2br, $v['profile_type']);
920 function __restore_html_characters_has_profiles($data, $nl2br = false, $profile_type = null) {
925 foreach ($data as $k => $v) {
926 if (isset($v['value'])) {
927 $data[$k]['value'] = $this->{$this->modelClass}->restore_html($v['value'], false, false, false);
928 if ($nl2br && $profile_type == 'textarea') {
929 $data[$k]['value'] = str_replace('<br />', "\n", $data[$k]['value']);