You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

62 lines
2.4 KiB

  1. <?php
  2. /**
  3. * Class helper_plugin_bureaucracy_fieldmultiselect
  4. *
  5. * Creates a multiselect box
  6. */
  7. class helper_plugin_bureaucracy_fieldmultiselect extends helper_plugin_bureaucracy_fieldselect {
  8. /**
  9. * Arguments:
  10. * - cmd
  11. * - label
  12. * - option1|option2|etc
  13. * - ^ (optional)
  14. *
  15. * @param array $args The tokenized definition, only split at spaces
  16. */
  17. public function initialize($args) {
  18. $this->init($args);
  19. $this->opt['args'] = array_map('trim', explode('|',array_shift($args)));
  20. $this->standardArgs($args);
  21. if (isset($this->opt['value'])) {
  22. $this->opt['value'] = array_map('trim', explode(',', $this->opt['value']));
  23. } else {
  24. $this->opt['value'] = array();
  25. }
  26. }
  27. /**
  28. * Render the field as XHTML
  29. *
  30. * Outputs the represented field using the passed Doku_Form object.
  31. * Additional parameters (CSS class & HTML name) are passed in $params.
  32. *
  33. * @params array $params Additional HTML specific parameters
  34. * @params Doku_Form $form The target Doku_Form object
  35. * @params int $formid unique identifier of the form which contains this field
  36. */
  37. public function renderfield($params, Doku_Form $form, $formid) {
  38. $this->_handlePreload();
  39. if(!$form->_infieldset){
  40. $form->startFieldset('');
  41. }
  42. if ($this->error) {
  43. $params['class'] = 'bureaucracy_error';
  44. }
  45. $params = array_merge($this->opt, $params);
  46. $form->addElement(call_user_func_array('form_makeListboxField',
  47. $this->_parse_tpl(
  48. array(
  49. '@@NAME@@[]',
  50. $params['args'],
  51. $this->opt['value'],
  52. '@@DISPLAY@@',
  53. '@@ID@@',
  54. '@@CLASS@@',
  55. array('multiple' => 'multiple')
  56. ),
  57. $params
  58. )));
  59. }
  60. }