Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
form_question_type_option_list_edit_fns.inc
1 <?php
18 require_once dirname(__FILE__).'/../form_question_type_tickbox_list/form_question_type_tickbox_list_edit_fns.inc';
19 
20 
33 {
34 
35 
41  {
43 
44  }//end constructor
45 
46 
57  function paintDefault(&$asset, &$o, $prefix)
58  {
59  if (!$asset->writeAccess('attributes')) return FALSE;
60 
61  // default entry to have no default value
62  $none = Array('none');
63  $options = $asset->getOptions();
64  $options = array_merge($none, $options);
65 
66  echo "<table cellpadding=\"0\" cellspacing=\"0\">\n";
67  $defaults = $asset->attr('default');
68 
69  if (!empty($options[1])) {
70 
71  foreach ($options as $ref => $option) {
72  if (!trim($option)) continue;
73  echo '<tr><td>';
74  $name = $prefix.'default[]';
75 
76  if ($option == 'none') {
77  $checked = (empty($defaults)) ? TRUE : FALSE;
78  } else {
79  $checked = (in_array($ref - 1, $defaults)) ? TRUE : FALSE;
80  }
81 
82  if ($ref == 0) {
83  radio_button($name, 'none', $checked);
84  } else {
85  radio_button($name, ($ref - 1), $checked);
86  }
87 
88  echo '&nbsp;<span onclick="this.previousSibling.previousSibling.checked = (!this.previousSibling.previousSibling.checked || this.previousSibling.previousSibling.type==\'radio\')">'.$option.'</span>';
89  echo '</td></tr>';
90  }
91 
92  }//end if
93  echo '</table>';
94 
95  return TRUE;
96 
97  }//end paintDefault()
98 
99 
100 }//end class
101 
102 ?>