OSDN Git Service

立ち絵背景時、文字の背景を半透明透かしに変更
[trpgtools-onweb/cake-frame.git] / app / views / helpers / profiledisp.php
1 <?php
2 /* 
3  * プロフィール表示用Helper
4  * i18n対応
5  */
6 class ProfiledispHelper extends Helper {
7         var $helpers = array(
8                 'Html',
9                 'Form',
10         );
11
12         var $i18n_profile_types = array();
13
14         var $profile_type = array();
15
16         var $character_has_profile_num = 0;
17         var $character_has_profile_cols = 0;
18
19         var $form_id = 0;
20
21         /**
22          * profile_typeの設定をview表示形式に変換
23          */
24         function get_i18n_profile_type($profile_type, $profile_types)
25         {
26                 if (empty($profile_type)) {
27                         return null;
28                 }
29
30                 if (empty($this->i18n_profile_types)) {
31                         $this->i18n_profile_types = $this->set_profile_type($profile_types);
32                 }
33
34                 return $this->i18n_profile_types[$profile_type];
35         }
36         /**
37          * profile_typeの選択プルダウン出力
38          * i18n対応
39          */
40         function create_profile_type_select($profile_types = array(), $fieldName = 'profile_type', $options = array('type' => 'select'))
41         {
42                 if (!isset($options['type'])) {
43                         $options['type'] = 'select';
44                 }
45                 if (!isset($options['options'])) {
46                         $options['options'] = array();
47                 }
48                 $options['options'] = $this->set_profile_type($profile_types, $options['options']);
49
50                 return $this->Form->input($fieldName, $options);
51         }
52         /* profile_typeの設定を、key->value(多言語化対応)に変換 */
53         function set_profile_type($profile_types = array(), $options = array())
54         {
55                 if (!empty($options)) {
56                         $this->i18n_profile_types = $options;
57                 }
58
59                 if (empty($profile_types)) {
60                         App::import('Model', 'Profile');
61                         $Profile = new ProfileModel;
62                         $profile_types = $Profile->profile_type;
63                 }
64
65                 foreach ($profile_types as $k => $v) {
66                         if ($v == 'input') {
67                                 $this->i18n_profile_types[$v] = __('input', true);
68                         } elseif($v == 'textarea') {
69                                 $this->i18n_profile_types[$v] = __('textarea', true);
70                         } elseif($v == 'select') {
71                                 $this->i18n_profile_types[$v] = __('select', true);
72                         } elseif($v == 'radio') {
73                                 $this->i18n_profile_types[$v] = __('radio', true);
74                         } elseif($v == 'checkbox') {
75                                 $this->i18n_profile_types[$v] = __('checkbox', true);
76                         } elseif($v == 'm-input') {
77                                 $this->i18n_profile_types[$v] = __('multi input', true);
78                         } elseif($v == 'table') {
79                                 $this->i18n_profile_types[$v] = __('table', true);
80                         } elseif($v == 's-table') {
81                                 $this->i18n_profile_types[$v] = __('static table', true);
82                         } else {
83                                 $this->i18n_profile_types[$v] = $v;
84                         }
85                 }
86
87                 return $this->i18n_profile_types;
88         }
89
90         /* profileの設定をフォームで出力 */
91         function disp_form4profile($profile, $label = false, $option = array())
92         {
93                 if ($profile['profile_type'] == 'textarea') {
94                         $option['type'] = 'textarea';
95                 } else {
96                         $option['type'] = 'text';
97                 }
98
99                 if (!CorePlus::is_valid($profile, 'CharactersHasProfile.0.value')) {
100                         $profile['CharactersHasProfile'][0]['value'] = null;
101                 }
102
103                 foreach ($profile['CharactersHasProfile'] as $v) {
104                         echo $this->_get_profile_tag($profile['id'], $v['value'], $label, $option);
105                         $this->character_has_profile_num++;
106                 }
107
108                 if ($this->profile_type['is_multi']) {
109                         for ($i=0;$i<2;$i++) {
110                                 echo $this->_get_profile_tag($profile['id'], null, false, $option);
111                                 $this->character_has_profile_num++;
112                         }
113                 }
114         }
115         function _get_profile_tag($profile_id, $value = null, $label = false, $option = array())
116         {
117                 if (empty($profile_id)) {
118                         return null;
119                 }
120
121                 $name1 = sprintf('CharactersHasProfile.%s.value', $this->character_has_profile_num);
122                 $name2 = sprintf('CharactersHasProfile.%s.profile_id', $this->character_has_profile_num);
123                 $option = array_merge(array(
124                         'label' => $label,
125                         'value' => $value,
126                         ), $option
127                 );
128
129                 $profile_tag = 
130                         $this->Form->input($name1, $option).
131                         $this->Form->input($name2, array(
132                                 'type' => 'hidden',
133                                 'value' => $profile_id,
134                         ));
135
136                 return $profile_tag;
137         }
138
139         /* profile_selectsの設定を出力 */
140         function disp4profile_selects($profile_selects, $option = array())
141         {
142                 foreach ($profile_selects as $k => $v) {
143                         $options[stripcslashes($v['value'])] = stripcslashes($v['value']);
144                 }
145                 $option = array_merge(
146                         array(
147                         'type' => 'select',
148                         'options' => $options,
149                         ),
150                         $option
151                 );
152
153                 $profile_select_tag = 
154                          $this->Form->input('CharactersHasProfile.'.$this->character_has_profile_num.'.value', $option).
155                          $this->Form->input('CharactersHasProfile.'.$this->character_has_profile_num.'.profile_id', array(
156                                 'type' => 'hidden',
157                                 'value' => $profile_selects[0]['profile_id'],
158                         )).
159                          $this->Form->input('CharactersHasProfile.'.$this->character_has_profile_num.'.profile_select_id', array(
160                                 'type' => 'hidden',
161                                 'value' => $profile_selects[0]['id'],
162                         ));
163                 echo $profile_select_tag;
164                 $this->character_has_profile_num++;
165         }
166
167
168         /* profile_selectsの設定をプルダウンで出力 */
169         function disp_select4profile_selects($profile_selects, $characters_has_profile = array(), $option = array(), $label = false, $legend = false)
170         {
171                 if (empty($profile_selects)) {
172                         return null;
173                 }
174
175                 $selected = $this->set_form_value($profile_selects, $characters_has_profile);
176
177                 $option = array_merge(
178                         array(
179                                 'type' => 'select',
180                                 'label' => $label,
181                                 'legend' => $legend,
182                                 'selected' => $selected['value'],
183                         ),
184                         $option
185                 );
186
187                 $this->disp4profile_selects($profile_selects, $option);
188         }
189
190         /* profile_selectsの設定をラジオボタンで出力 */
191         function disp_radio4profile_selects($profile_selects, $characters_has_profile = array(), $label = false, $legend = false)
192         {
193                 if (empty($profile_selects)) {
194                         return null;
195                 }
196
197                 $selected = $this->set_form_value($profile_selects, $characters_has_profile);
198                 if ($selected['value']) {
199                         $selected_value = $selected['value'];
200                 } else {
201                         $first = reset($profile_selects);
202                         $selected_value = $first['value'];
203                 }
204
205                 $option = array(
206                         'type' => 'radio',
207                         'value' => $selected_value,
208                         'label' => $label,
209                         'legend' => $legend,
210                         'div' => array(
211                                 'class' => 'input radio inline'
212                         ),
213                 );
214
215                 return $this->disp4profile_selects($profile_selects, $option);
216
217         }
218
219         /* profile_selectsの設定をチェックボックスで出力 */
220         function disp_checkbox4profile_selects($profile_selects, $characters_has_profile = array(), $label = false, $legend = false)
221         {
222                 if (empty($profile_selects)) {
223                         return null;
224                 }
225
226                 foreach($profile_selects as $k => $v) {
227                         if (empty($v)) {
228                                 continue;
229                         }
230
231                         $profile_select[0] = $v;
232                         $has_profile[0] = $this->get_selected_profile($v, $characters_has_profile);
233                         $this->disp_select4profile_selects(
234                                 $profile_select, 
235                                 $has_profile,
236                                 array(
237                                         'multiple' => 'checkbox',
238                                         'label' => $label,
239                                         'legend' => $legend,
240                                         'div' => array(
241                                                 'class' => 'input checkbox inline'
242                                         ),
243                                 )
244                         );
245                 }
246         }
247
248         /* profile_tablesの設定からtableHeadersを出力 */
249         function disp_th4profile_tables($profile_tables, $tableId = null, $tr_options = array(), $th_options = array())
250         {
251                 if (empty($profile_tables)) {
252                         return null;
253                 }
254
255                 $values = array();
256                 $style_options = array();
257                 $i = 1;
258                 foreach ($profile_tables as $k => $v) {
259                         $values[$k] = $v['title'];
260
261                         if ($v['width']) {
262                                 $key = '#'.$tableId.' td.column-' . $i;
263                                 $style_options[$key] = array('width' => $v['width']."px");
264                                 $key = '#'.$tableId.' td.column-' . $i. ' input';
265                                 $style_options[$key] = array('width' => $v['width']."px");
266                         }
267                         $i++;
268                 }
269
270                 if (!empty($style_options)) {
271                         echo '<style type="text/css"><!--'."\n";
272                         foreach($style_options as $k => $v) {
273                                 echo $k. " {\n";
274                                 echo $this->Html->style($v);
275                                 echo "}\n";
276                         }
277                         echo '--></style>';
278                 }
279
280                 $table_header = $this->Html->tableHeaders(
281                         $values,
282                         $tr_options,
283                         $th_options
284                 );
285
286                 $table_header = '<thead>'.$table_header.'</thead>';
287
288                 echo $table_header;
289         }
290
291         /* characters_has_profilesの設定からtableCellsを出力 */
292         function disp_td4characters_has_profiles($characters_has_profiles, $oddTrOptions = null, $evenTrOptions = null, $useCount = false, $continueOddEven = true)
293         {
294                 if (empty($characters_has_profiles)) {
295                         return null;
296                 }
297                 if (isset($characters_has_profiles[0]['ProfileTableStatic'])) {
298                         $statics = $characters_has_profiles[0]['ProfileTableStatic'];
299                 }
300
301                 $values = array();
302                 foreach ($characters_has_profiles as $k => $v) {
303                         if (is_string($v)) {
304                                 $values[$k] = $v;
305                         } else {
306                                 $values[$k] = $v['value'];
307                         }
308                 }
309
310                 $table_cells = $this->Html->tableCells($values, $oddTrOptions, $evenTrOptions, $useCount, $continueOddEven);
311
312                 echo $table_cells;
313         }
314
315         /* characters_has_profileからtable td出力 */
316         function disp_tds4characters_has_profiles($characters_has_profile, $type = 'view', $oddTrOptions = null, $evenTrOptions = null, $useCount = false, $continueOddEven = true)
317         {
318                 $i = 1;
319                 $profile_num = 0;
320                 $profiles[$i] = array();
321                 $profile_id = null;
322                 foreach($characters_has_profile as $k => $v) {
323                         if (is_null($profile_id) && CorePlus::is_valid($v, 'profile_id')) {
324                                 $profile_id = $v['profile_id'];
325                         }
326                         if (!CorePlus::is_valid($v, 'profile_id')) {
327                                 if (!is_null($profile_id) && !CorePlus::is_valid($v, 'profile_id')) {
328                                         $v['profile_id'] = $profile_id;
329                                 } else {
330                                         continue;
331                                 }
332                         }
333
334                         if (!CorePlus::is_valid($v, 'profile_table_id')) {
335                                 if (!isset($ProfileTable)) {
336                                         App::import('Model', 'ProfileTable');
337                                         $ProfileTable = new ProfileTable;
338                                 }
339                                 $prof_table_ids = $ProfileTable->find('list', array(
340                                         'ProfileTable.profile_id' => $profile_id,
341                                         'fields' => array('ProfileTable.id'),
342                                         'order' => 'ProfileTable.sort_order'
343                                 ));
344
345                                 if (!empty($prof_table_ids)) {
346                                         $v['profile_table_id'] = current(array_slice($prof_table_ids, $profile_num+1, 1));
347                                         $v['value'] = null;
348                                 } else {
349                                         __('Disable');
350                                         continue;
351                                 }
352                         }
353
354                         $v['id'] = $v['profile_table_id'];
355
356                         if (isset($profiles[$i][$v['profile_table_id']])) {
357                                 $i++;
358                         }
359                         $profiles[$i][$v['profile_table_id']] = $v;
360
361                         $profile_num++;
362                 }
363                 $forms = array();
364
365                 foreach($profiles as $k => $v) {
366                         if ($type == 'form') {
367                                 $tds = $this->disp_form4profile_tables($v, null, null, true);
368                         } else {
369                                 $tds = $this->disp_value4profile_tables($v, null, null, true);
370                         }
371                 }
372
373                 $this->disp_td4characters_has_profiles($tds, $oddTrOptions, $evenTrOptions, $useCount, $continueOddEven);
374         }
375
376
377         /* characters_has_profileからvalue出力 */
378         function disp_value_td4characters_has_profiles($characters_has_profile)
379         {
380                 $this->disp_tds4characters_has_profiles($characters_has_profile, 'view', null, null, true);
381         }
382
383         /* characters_has_profileからtdフォーム出力 */
384         function disp_form_td4characters_has_profiles($characters_has_profile)
385         {
386                 $this->disp_tds4characters_has_profiles($characters_has_profile, 'form', null, null, true);
387         }
388
389         /* profile_tablesの設定からView表示を出力 */
390         function disp_value4profile_tables($profile_tables, $oddTrOptions = null, $evenTrOptions = null, $useCount = false, $continueOddEven = true)
391         {
392                 if (empty($profile_tables)) {
393                         return null;
394                 }
395
396                 $tds = array();
397                 foreach ($profile_tables as $k => $v) {
398                         if (!Set::check($v, 'value')) {
399                                 $v['value'] = null;
400                         }
401                         $tds[] = $v['value'];
402                 }
403                 $this->disp_td4characters_has_profiles($tds, $oddTrOptions, $evenTrOptions, $useCount, $continueOddEven);
404         }
405
406         /* profile_tablesの設定から入力フォームを出力 */
407         function disp_form4profile_tables($profile_tables, $oddTrOptions = null, $evenTrOptions = null, $useCount = false, $continueOddEven = true)
408         {
409                 if (empty($profile_tables)) {
410                         return null;
411                 }
412                 $first = reset($profile_tables);
413                 if (isset($first['ProfileTableStatic'])) {
414                         $statics = $first['ProfileTableStatic'];
415                 }
416
417                 $forms = array();
418                 $i = 0;
419                 foreach ($profile_tables as $k => $v) {
420                         if (!Set::check($v, 'profile_id')) {
421                                 continue;
422                         }
423                         if (!Set::check($v, 'id')) {
424                                 if (Set::check($v, 'profile_table_id')) {
425                                         $v['id'] = $v['profile_table_id'];
426                                 } else {
427                                         continue;
428                                 }
429                         }
430
431                         if (!Set::check($v, 'value')) {
432                                 $v['value'] = null;
433                         }
434
435                         if ($i == 0 && (isset($statics[$this->character_has_profile_cols]) || isset($v['profile_table_static_id']))) {
436                                 $value = isset($v['profile_table_static_id']) ? $v['value']: $statics[$this->character_has_profile_cols]['title']; 
437                                 $form = '<span class="staticHead">'.$value.'</span>'.
438                                         $this->Form->input('CharactersHasProfile.'.$this->character_has_profile_num.'.value', array(
439                                                 'type' => 'hidden',
440                                                 'value' => $value,
441                                         ));
442                         } else {
443                                 $form = $this->Form->input('CharactersHasProfile.'.$this->character_has_profile_num.'.value', array(
444                                         'type' => 'text',
445                                         'label' => false,
446                                         'value' => $v['value'],
447                                 ));
448                         }
449
450                         if (isset($v['profile_table_static_id'])) {
451                                 $profile_table_static_id = $v['profile_table_static_id'];
452                         } elseif (isset($profile_tables[0]['ProfileTableStatic'][$this->character_has_profile_cols]['id'])) {
453                                 $profile_table_static_id = $profile_tables[0]['ProfileTableStatic'][$this->character_has_profile_cols]['id'];
454                         } else {
455                                 $profile_table_static_id = null;
456                         }
457
458                         $forms[] = 
459                                 $form.
460                                 $this->Form->input('CharactersHasProfile.'.$this->character_has_profile_num.'.profile_id', array(
461                                         'type' => 'hidden',
462                                         'value' => $v['profile_id'],
463                                 )).
464                                 $this->Form->input('CharactersHasProfile.'.$this->character_has_profile_num.'.profile_table_id', array(
465                                         'type' => 'hidden',
466                                         'value' => $v['id'],
467                                 )).
468                                 $this->Form->input('CharactersHasProfile.'.$this->character_has_profile_num.'.profile_table_static_id', array(
469                                         'type' => 'hidden',
470                                         'value' => $profile_table_static_id,
471                                 ));
472                         $this->character_has_profile_num++;
473                         $i++;
474                 }
475                 $this->character_has_profile_cols++;
476
477                 $this->disp_td4characters_has_profiles($forms, $oddTrOptions, $evenTrOptions, $useCount, $continueOddEven);
478         }
479
480         /* profile_tablesの設定からブランクのtableCellsを出力 */
481         function disp_blank_td4profile_tables($profile_tables, $num = 2, $oddTrOptions = null, $evenTrOptions = null, $useCount = false, $continueOddEven = true)
482         {
483                 if (empty($profile_tables)) {
484                         return null;
485                 }
486
487                 $blank = array_fill(0, count($profile_tables), $this->Html->div('blank', " "));
488
489                 for ($i=0; $i<$num; $i++) {
490                         $this->disp_td4characters_has_profiles($blank, $oddTrOptions, $evenTrOptions, $useCount, $continueOddEven);
491                 }
492         }
493
494         /* Profile種類を判断 */
495         function set_profile_type4view($profile)
496         {
497                 $this->profile_type = array(
498                         'is_subsetting' => false,
499                         'is_select' => false,
500                         'is_radio' => false,
501                         'is_checkbox' => false,
502                         'is_table' => false,
503                         'is_multi' => false,
504                 );
505
506                 if ($profile['profile_type'] == 'select' || $profile['profile_type'] == 'radio' || $profile['profile_type'] == 'checkbox'  || $profile['profile_type'] == 'table' ) {
507                         $this->profile_type['is_subsetting'] = true;
508                 }
509                 if ($profile['profile_type'] == 'select') {
510                         $this->profile_type['is_select'] = true;
511                 }
512                 if ($profile['profile_type'] == 'radio') {
513                         $this->profile_type['is_radio'] = true;
514                 }
515                 if ($profile['profile_type'] == 'checkbox') {
516                         $this->profile_type['is_checkbox'] = true;
517                 }
518                 if ($profile['profile_type'] == 'table' || $profile['profile_type'] == 's-table') {
519                         $this->profile_type['is_table'] = true;
520                 }
521                 if ($profile['profile_type'] == 'm-input') {
522                         $this->profile_type['is_multi'] = true;
523                 }
524         }
525
526         /* profile_typeの設定に応じてフォーム表示
527          * set_profile_type4view($profile)チェック済み前提。
528          */
529         function disp_forms4profile_type($profile, $form_num = 2, $table_blank = 2, $disp_add_link = false, $character_id = null)
530         {
531                 if (!isset($profile['CharactersHasProfile'])) {
532                         $profile['CharactersHasProfile'] = array();
533                 }
534
535                 if ($this->profile_type['is_select'] || $this->profile_type['is_radio'] || $this->profile_type['is_checkbox']) {
536                         if ($this->profile_type['is_select']) {
537                                 $this->disp_select4profile_selects($profile['ProfileSelect'], $profile['CharactersHasProfile']);
538                         } elseif ($this->profile_type['is_radio']) {
539                                 $this->disp_radio4profile_selects($profile['ProfileSelect'], $profile['CharactersHasProfile']);
540                         } elseif ($this->profile_type['is_checkbox']) {
541                                 $this->disp_checkbox4profile_selects($profile['ProfileSelect'], $profile['CharactersHasProfile']);
542                         }
543                 } elseif ($this->profile_type['is_table']) {
544                         if (isset($profile['id'])) {
545                                 $tableId = 'TableProfileId'. $profile['id'];
546                         } else {
547                                 $tableId = 'TableProfileId'. $profile['Profile']['id'];
548                         }
549                         echo '<table id="'.$tableId.'">';
550                         $this->disp_th4profile_tables($profile['ProfileTable'], $tableId);
551                         echo '<tbody>';
552                         if (!empty($profile['CharactersHasProfile'])) {
553                                 $this->disp_form_td4characters_has_profiles($profile['CharactersHasProfile']);
554
555                         }
556                         if (intval($form_num) > 0 
557                                 && ((isset ($profile['Profile']['profile_type']) && $profile['Profile']['profile_type'] != 's-table') || (isset($profile['profile_type']) && $profile['profile_type'] != 's-table'))
558                                 || empty($profile['CharactersHasProfile'])) {
559                                 for ($i=0; $i<$form_num; $i++) {
560                                         $this->disp_form4profile_tables($profile['ProfileTable'], null, null, true);
561                                 }
562                         }
563                         if (intval($table_blank) > 0 && $profile['profile_type'] != 's-table') {
564                                 $this->disp_blank_td4profile_tables($profile['ProfileTable'], intval($table_blank));
565                         }
566                         echo '</tbody>';
567                         echo '</table>';
568                         if ($disp_add_link) {
569                                 echo $this->Html->div(
570                                         'editLink text', 
571                                         $this->Html->link(
572                                                 __('Edit Data', true),
573                                                 array(
574                                                         'action' => 'add_milti_profiles',
575                                                         $character_id.
576                                                         '/profile_id:'.$profile['id']
577                                                 ),
578                                                 null,
579                                                 __('If some data have been changed, you should save before click it. OK?', true)
580                                         )
581                                 );
582                         }
583                 } else {
584                         $this->disp_form4profile($profile);
585                 }
586         }
587
588         /* characters_has_profilesの設定に応じてView表示
589          * set_profile_type4view($profile)チェック済み前提。
590          * $profileのkeyはprofilesのkey_name
591          */
592         function disp_values4characters_has_profiles($profile, $table_blank = 2, $disp_add_link = false, $character_id = null)
593         {
594                 if (!isset($profile['CharactersHasProfile']) && !$this->profile_type['is_table']) {
595                         $profile['CharactersHasProfile'] = array();
596                 }
597
598                 if (!$this->profile_type['is_table']) {
599                         $num = 0;
600                         foreach ($profile['CharactersHasProfile'] as $v) {
601                                 if (!empty($v['value'])) {
602                                         if ($num > 0) {
603                                                 echo "&nbsp;";
604                                         }
605
606                                         echo $this->Html->tag('span', $v['value']);
607                                         $num++;
608                                 }
609                         }
610                 } else {
611                         $tableId = 'TableProfileId'. $profile['id'];
612                         echo '<table id="'.$tableId.'">';
613                         if (isset($profile['ProfileTable'])) {
614                                 $this->disp_th4profile_tables($profile['ProfileTable'], $tableId);
615                                 echo '<tbody>';
616                                 if (!empty($profile['CharactersHasProfile'])) {
617                                         $this->disp_value_td4characters_has_profiles($profile['CharactersHasProfile']);
618                                 } else {
619                                         if (intval($table_blank) > 0) {
620                                                 $this->disp_blank_td4profile_tables($profile['ProfileTable'], intval($table_blank));
621                                         }
622                                 }
623                                 echo '</tbody>';
624                         }
625                         echo '</table>';
626                         if ($disp_add_link) {
627                                 echo $this->Html->div(
628                                         'editLink text', 
629                                         $this->Html->link(
630                                                 __('Edit Data', true),
631                                                 array(
632                                                         'action' => 'add_milti_profiles',
633                                                         $character_id.
634                                                         '/profile_id:'.$profile['id'],
635                                                 )
636                                         )
637                                 );
638                         }
639                 }
640         }
641
642         /* フォームに値入力 */
643         function set_form_value($profile_selects, $characters_has_profile)
644         {
645                 $this->form_id++;
646
647                 if ($this->profile_type['is_select'] || $this->profile_type['is_radio'] || $this->profile_type['is_checkbox']) {
648                         return $this->set_form_value_select($profile_selects, $characters_has_profile);
649                 } elseif ($this->profile_type['is_table']) {
650                         return $this->set_form_value_table($characters_has_profile);
651                 } else {
652                         return $this->set_form_value_profile($profile_selects, $characters_has_profile);
653                 }
654
655         }
656
657         /* profile_select */
658         /* profile_select_id->profile_idで抽出 */
659         function set_form_value_select($profile_selects, $characters_has_profile)
660         {
661                 if (isset($characters_has_profile[0]['id'])) {
662                         $selected = array(
663                                 'value' => $characters_has_profile[0]['value'],
664                                 'public_flag' => $characters_has_profile[0]['public_flag'],
665                                 'link_value' => $characters_has_profile[0]['link_value'],
666                         );
667                 } else {
668                         $selected = array(
669                                 'value' => '',
670                                 'public_flag' => '',
671                                 'link_value' => '',
672                         );
673                 }
674
675                 return $selected;
676         }
677         /* profile_table */
678         function set_form_value_table($profile_selects, $characters_has_profile)
679         {
680         }
681
682         /* postからprofile_select_id->profile_idで抽出 */
683         function get_selected_profile($profile_select, $characters_has_profile)
684         {
685                 $profile = array(
686                         'profile_select_id' => $profile_select['id'],
687                         'profile_id' => $profile_select['profile_id'],
688                         'value' => $profile_select['value'],
689                 );
690
691                 foreach ($characters_has_profile as $v) {
692                         if (Set::contains($v, $profile)) {
693                                 return $v;
694                         }
695                 }
696
697                 return array();
698
699         }
700
701 }
702