Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
form_question_rule_type_ends_with_edit_fns.inc
1 <?php
18 require_once dirname(__FILE__).'/../../form_question_rule/form_question_rule_edit_fns.inc';
19 
32 {
33 
34 
40  {
42 
43  }//end constructor
44 
45 
46  function paintRule(&$asset, &$o, $prefix, $rule_data, $write_access)
47  {
48  $operator_list = $asset->getOperators();
49 
50  if (!$write_access) {
51  $o->openField(translate('core_form_rule_details'));
52  if (($cq_id = array_get_index($rule_data, 'comparison_question_id', 0)) != 0) {
53  $q_asset = $GLOBALS['SQ_SYSTEM']->am->getAsset($cq_id);
54  $value = $q_asset->name;
55  } else {
56  $value = array_get_index($rule_data, 'value', '');
57  }
58 
59  echo translate('core_form_rule_ends_with_edit_'.(array_get_index($rule_data, 'operator', 1) ? 'true' : 'false').($cq_id ? '_q' : ''), $value);
60  $o->closeField();
61 
62  } else {
63 
64  $o->openField(translate('operator'));
65  // list of operators
66  combo_box($prefix.'[operator]', $operator_list, false, array_get_index($rule_data, 'operator', 1));
67  $o->closeField();
68 
69  $o->openField(translate('core_form_rule_static_value'));
70  // give a text box to write the comparison value in
71  text_box($prefix.'[value]', array_get_index($rule_data, 'value', ''), 30);
72  $o->closeField();
73 
74  $o->openField(translate('core_form_rule_or_value_of_question'));
75  // give a text box to write the comparison value in
76  asset_finder($prefix.'[asset]', array_get_index($rule_data, 'comparison_question_id', '0'), Array('form_question' => 'D'));
77  $o->closeField();
78 
79  $o->openField(translate('core_form_case_sensitive_question'));
80  // give a text box to write the comparison value in
81  check_box($prefix.'[case]', 1, array_get_index($rule_data, 'case_sensitive', 1));
82  $o->closeField();
83 
84  $o->sectionNote(translate('core_form_rule_static_or_question_note'));
85  }
86 
87  return $write_access;
88 
89  }//end paintRule()
90 
91 
98  function processRule(&$asset, &$o, $prefix, &$rule_data)
99  {
100  if (!isset($_POST[$prefix])) return false;
101 
102  $operator = array_get_index($_POST[$prefix], 'operator', 1);
103  $comparison = array_get_index($_POST[$prefix], 'value', null);
104  $comp_asset = array_get_index($_POST[$prefix], 'asset', null);
105  $case = array_get_index($_POST[$prefix], 'case', 0);
106 
107  $rule_data['operator'] = $operator;
108  $rule_data['case_sensitive'] = $case;
109  if (is_null($comp_asset) || ($comp_asset['assetid'] == '0')) {
110  $rule_data['value'] = $comparison;
111  $rule_data['comparison_question_id'] = '0';
112  } else {
113  $rule_data['comparison_question_id'] = $comp_asset['assetid'];
114  $rule_data['value'] = null;
115  }
116 
117  return true;
118 
119  }//end processRule()
120 
121 
122 }//end class
123 ?>