Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
form_question_type_datetime_edit_fns.inc
1 <?php
18 require_once dirname(__FILE__).'/../../form_question/form_question_edit_fns.inc';
19 
32 {
33 
34 
40  {
41  $this->Form_Question_Edit_Fns();
42 
43  }//end constructor
44 
45 
56  function paintInterface(&$asset, &$o, $prefix)
57  {
58  $elements = Array('d' => 'Day', 'm' => 'Month', 'y' => 'Year', 'h' => 'Hour', 'i' => 'Minute', 's' => 'Second', 'c' => 'Circa');
59 
60  $show_params = $asset->attr('show');
61  $text_params = $asset->attr('text');
62  $null_params = $asset->attr('null');
63 
64  $default_params = $asset->getDefaultParameters();
65 
66  $edit = FALSE; // editing flag
67  if ($asset->writeAccess('attributes')) $edit = TRUE;
68 
69  ?>
70  <table class="sq-backend-table">
71  <tr>
72  <td width="12%" align="center" class="sq-backend-table-header">&nbsp;</td>
73  <td width="11%" align="center" class="sq-backend-table-header"><?php
74  echo translate('circa');
75  ?></td>
76  <td width="11%" align="center" class="sq-backend-table-header"><?php
77  echo translate('day');
78  ?></td>
79  <td width="11%" align="center" class="sq-backend-table-header"><?php
80  echo translate('month'); ?>
81  </td>
82  <td width="11%" align="center" class="sq-backend-table-header"><?php
83  echo translate('year');
84  ?></td>
85  <td width="11%" align="center" class="sq-backend-table-header"><?php
86  echo translate('hour');
87  ?></td>
88  <td width="11%" align="center" class="sq-backend-table-header"><?php
89  echo translate('minute');
90  ?></td>
91  <td width="11%" align="center" class="sq-backend-table-header"><?php
92  echo translate('second');
93  ?></td>
94  <td width="11%" align="center" class="sq-backend-table-header"><?php
95  echo translate('core_form_datetime_12_hour_format');
96  ?></td>
97  </tr>
98  <tr>
99  <td class="sq-backend-table-cell"><?php
100  echo translate('show_question')
101  ?></td>
102  <td align="center" class="sq-backend-table-cell"><?php
103  if ($edit) {
104  check_box($prefix.'_c', '1', $show_params['c']);
105  } else {
106  echo $show_params['c'] ? 'X' : '';
107  }
108  ?></td>
109  <td align="center" class="sq-backend-table-cell"><?php
110  if ($edit) {
111  check_box($prefix.'_d', '1', $show_params['d']);
112  } else {
113  echo $show_params['d'] ? 'X' : '';
114  }
115  ?></td>
116  <td align="center" class="sq-backend-table-cell"><?php
117  if ($edit) {
118  check_box($prefix.'_m', '1', $show_params['m']);
119  } else {
120  echo $show_params['m'] ? 'X' : '';
121  }
122  ?></td>
123  <td align="center" class="sq-backend-table-cell"><?php
124  if ($edit) {
125  check_box($prefix.'_y', '1', $show_params['y']);
126  } else {
127  echo $show_params['y'] ? 'X' : '';
128  }
129  ?></td>
130  <td align="center" class="sq-backend-table-cell"><?php
131  if ($edit) {
132  check_box($prefix.'_h', '1', $show_params['h']);
133  } else {
134  echo $show_params['h'] ? 'X' : '';
135  }
136  ?></td>
137  <td align="center" class="sq-backend-table-cell"><?php
138  if ($edit) {
139  check_box($prefix.'_i', '1', $show_params['i']);
140  } else {
141  echo $show_params['i'] ? 'X' : '';
142  }
143  ?></td>
144  <td align="center" class="sq-backend-table-cell"><?php
145  if ($edit) {
146  check_box($prefix.'_s', '1', $show_params['s']);
147  } else {
148  echo $show_params['s'] ? 'X' : '';
149  }
150  ?></td>
151  <td align="center" class="sq-backend-table-cell"><?php
152  $show_params['a'] = (isset($show_params['a'])) ? $show_params['a'] : $default_params['show']['a'];
153  if ($edit) {
154  check_box($prefix.'_a', '1', $show_params['a']);
155  } else {
156  echo $show_params['a'] ? 'X' : '';
157  }
158  ?></td>
159  </tr>
160  <tr>
161  <td colspan="2" class="sq-backend-table-cell"><?php
162  echo translate('allow_blank_question');
163  ?></td>
164  <td align="center" class="sq-backend-table-cell"><?php
165  if ($edit) {
166  check_box($prefix.'_d_null', '1', $null_params['d']);
167  } else {
168  echo $null_params['d'] ? 'X' : '';
169  }
170  ?></td>
171  <td align="center" class="sq-backend-table-cell"><?php
172  if ($edit) {
173  check_box($prefix.'_m_null', '1', $null_params['m']);
174  } else {
175  echo $null_params['m'] ? 'X' : '';
176  }
177  ?></td>
178  <td align="center" class="sq-backend-table-cell"><?php
179  if ($edit) {
180  check_box($prefix.'_y_null', '1', $null_params['y']);
181  } else {
182  echo $null_params['y'] ? 'X' : '';
183  }
184  ?></td>
185  <td align="center" class="sq-backend-table-cell"><?php
186  if ($edit) {
187  check_box($prefix.'_h_null', '1', $null_params['h']);
188  } else {
189  echo $null_params['h'] ? 'X' : '';
190  }
191  ?></td>
192  <td align="center" class="sq-backend-table-cell"><?php
193  if ($edit) {
194  check_box($prefix.'_i_null', '1', $null_params['i']);
195  } else {
196  echo $null_params['i'] ? 'X' : '';
197  }
198  ?></td>
199  <td align="center" class="sq-backend-table-cell"><?php
200  if ($edit) {
201  check_box($prefix.'_s_null', '1', $null_params['s']);
202  } else {
203  echo $null_params['s'] ? 'X' : '';
204  }
205  ?></td>
206  <td align="center" class="sq-backend-table-cell">&nbsp;</td>
207  </tr>
208  <tr>
209  <td colspan="2" class="sq-backend-table-cell"><?php
210  echo translate('core_form_datetime_text_box_question');
211  ?></td>
212  <td align="center" class="sq-backend-table-cell"><?php
213  if ($edit) {
214  check_box($prefix.'_d_text', '1', $text_params['d']);
215  } else {
216  echo $text_params['d'] ? 'X' : '';
217  }
218  ?></td>
219  <td align="center" class="sq-backend-table-cell"><?php
220  if ($edit) {
221  check_box($prefix.'_m_text', '1', $text_params['m']);
222  } else {
223  echo $text_params['m'] ? 'X' : '';
224  }
225  ?></td>
226  <td align="center" class="sq-backend-table-cell"><?php
227  if ($edit) {
228  check_box($prefix.'_y_text', '1', $text_params['y']);
229  } else {
230  echo $text_params['y'] ? 'X' : '';
231  }
232  ?></td>
233  <td align="center" class="sq-backend-table-cell"><?php
234  if ($edit) {
235  check_box($prefix.'_h_text', '1', $text_params['h']);
236  } else {
237  echo $text_params['h'] ? 'X' : '';
238  }
239  ?></td>
240  <td align="center" class="sq-backend-table-cell"><?php
241  if ($edit) {
242  check_box($prefix.'_i_text', '1', $text_params['i']);
243  } else {
244  echo $text_params['i'] ? 'X' : '';
245  }
246  ?></td>
247  <td align="center" class="sq-backend-table-cell"><?php
248  if ($edit) {
249  check_box($prefix.'_s_text', '1', $text_params['s']);
250  } else {
251  echo $text_params['s'] ? 'X' : '';
252  }
253  ?></td>
254  <td align="center" class="sq-backend-table-cell">&nbsp;</td>
255  </tr>
256  </table>
257  <?php
258 
259  }//end paintInterface()
260 
261 
272  function processInterface(&$asset, &$o, $prefix)
273  {
274  $elements = Array('d', 'm', 'y', 'h', 'i', 's');
275 
276  $show_params = $asset->attr('show');
277  $text_params = $asset->attr('text');
278  $null_params = $asset->attr('null');
279 
280  foreach ($elements as $e) {
281  $entities = Array('', '_null', '_text');
282  foreach ($entities as $entity) {
283 
284  if ($entity == '_null') {
285  $current_param =& $null_params;
286  } else if ($entity == '_text') {
287  $current_param =& $text_params;
288  } else {
289  $current_param =& $show_params;
290  }
291 
292  if (isset($_POST[$prefix.'_'.$e.$entity])) {
293  $current_param[$e] = $_POST[$prefix.'_'.$e.$entity];
294  } else {
295  $current_param[$e] = '';
296  }
297  }
298  }
299 
300  if (isset($_POST[$prefix.'_c'])) {
301  $show_params['c'] = $_POST[$prefix.'_c'];
302  } else {
303  $show_params['c'] = '';
304  }
305 
306  if (isset($_POST[$prefix.'_a'])) {
307  $show_params['a'] = $_POST[$prefix.'_a'];
308  } else {
309  $show_params['a'] = '';
310  }
311 
312  if (!$asset->setAttrValue('show', $show_params)) {
313  return FALSE;
314  }
315  if (!$asset->setAttrValue('text', $text_params)) {
316  return FALSE;
317  }
318  if (!$asset->setAttrValue('null', $null_params)) {
319  return FALSE;
320  }
321 
322 
323 
324  return TRUE;
325 
326  }//end processInterface()
327 
328 
339  function paintExtras(&$asset, &$o, $prefix)
340  {
341  $extra_params = $asset->attr('extras');
342  $edit = ($asset->writeAccess('attributes')) ? TRUE : FALSE;
343  ?>
344  <table class="sq-backend-table">
345  <tr>
346  <td width="8%" class="sq-backend-table-header"><?php
347  echo translate('day');
348  ?></td>
349  <td class="sq-backend-table-cell"><?php
350  if ($edit) {
351  text_box($prefix.'_d_extras', $extra_params['d']);
352  } else {
353  echo $extra_params['d'];
354  }
355  ?></td>
356  </tr>
357 
358  <tr>
359  <td width="8%" class="sq-backend-table-header"><?php
360  echo translate('month'); ?>
361  </td>
362  <td class="sq-backend-table-cell"><?php
363  if ($edit) {
364  text_box($prefix.'_m_extras', $extra_params['m']);
365  } else {
366  echo $extra_params['m'];
367  }
368  ?></td>
369  </tr>
370  <tr>
371  <td width="8%" class="sq-backend-table-header"><?php
372  echo translate('year');
373  ?></td>
374  <td class="sq-backend-table-cell"><?php
375  if ($edit) {
376  text_box($prefix.'_y_extras', $extra_params['y']);
377  } else {
378  echo $extra_params['y'];
379  }
380  ?></td>
381  </tr>
382  <tr>
383  <td width="8%" class="sq-backend-table-header"><?php
384  echo translate('hour');
385  ?></td>
386  <td class="sq-backend-table-cell"><?php
387  if ($edit) {
388  text_box($prefix.'_h_extras', $extra_params['h']);
389  } else {
390  echo $extra_params['h'];
391  }
392  ?></td>
393  </tr>
394  <tr>
395  <td width="8%" class="sq-backend-table-header"><?php
396  echo translate('minute');
397  ?></td>
398  <td class="sq-backend-table-cell"><?php
399  if ($edit) {
400  text_box($prefix.'_i_extras', $extra_params['i']);
401  } else {
402  echo $extra_params['i'];
403  }
404  ?></td>
405  </tr>
406  <tr>
407  <td width="8%" class="sq-backend-table-header"><?php
408  echo translate('second');
409  ?></td>
410  <td class="sq-backend-table-cell"><?php
411  if ($edit) {
412  text_box($prefix.'_s_extras', $extra_params['s']);
413  } else {
414  echo $extra_params['s'];
415  }
416  ?></td>
417  </tr>
418  <tr>
419  <td width="8%" class="sq-backend-table-header"><?php
420  echo translate('core_form_datetime_12_hour_format');
421  ?></td>
422  <td class="sq-backend-table-cell"><?php
423  $extra_params['a'] = (isset($extra_params['a'])) ? $extra_params['a'] : '';
424  if ($edit) {
425  text_box($prefix.'_a_extras', $extra_params['a']);
426  } else {
427  echo $extra_params['a'];
428  }
429  ?></td>
430  </tr>
431  </table>
432  <?php
433 
434  }//end paintExtras()
435 
436 
447  function processExtras(&$asset, &$o, $prefix)
448  {
449  $elements = Array('d', 'm', 'y', 'h', 'i', 's', 'a');
450  $current_param = Array();
451 
452  foreach ($elements as $e) {
453  if (isset($_POST[$prefix.'_'.$e.'_extras'])) {
454  $current_param[$e] = $_POST[$prefix.'_'.$e.'_extras'];
455  } else {
456  $current_param[$e] = '';
457  }
458  }
459  if (!$asset->setAttrValue('extras', $current_param)) {
460  return FALSE;
461  }
462  return TRUE;
463 
464  }//end processExtras()
465 
466 
467 }//end class
468 ?>