advanced_settings.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * Class HTML_QuickForm_advanced_settings
  4. */
  5. class HTML_QuickForm_advanced_settings extends HTML_QuickForm_static
  6. {
  7. /**
  8. * Class constructor
  9. *
  10. * @param string $name
  11. * @param string $label
  12. */
  13. public function __construct($name = '', $label = '')
  14. {
  15. if (empty($label)) {
  16. $label = get_lang('Advanced settings');
  17. }
  18. $this->updateAttributes(
  19. array(
  20. 'label' => $label,
  21. 'name' => $name
  22. )
  23. );
  24. $this->_type = 'html';
  25. }
  26. /**
  27. * Accepts a renderer
  28. *
  29. * @param HTML_QuickForm_Renderer renderer object (only works with Default renderer!)
  30. * @access public
  31. * @return void
  32. */
  33. function accept(&$renderer, $required = false, $error = null)
  34. {
  35. $renderer->renderHtml($this);
  36. }
  37. /**
  38. * @return string
  39. */
  40. public function toHtml()
  41. {
  42. $name = $this->getAttribute('name');
  43. $text = $this->getAttribute('label');
  44. $label = is_array($text) ? $text[0] : $text;
  45. $html = '<div class="form-group row"><label class="col-sm-2 col-form-label"></label>';
  46. if (is_array($text) && isset($text[1])) {
  47. $html .= '<span class="clearfix">'.$text[1].'</span>';
  48. }
  49. $html .= '
  50. <div class="col-sm-10">
  51. <button id="'.$name.'" type="button" class="btn btn-secondary advanced_options"
  52. data-toggle="button" aria-pressed="false" autocomplete="off">
  53. <em class="fa fa-bars"></em> '.$label.'
  54. </button>
  55. </div>
  56. ';
  57. if (is_array($text) && isset($text[2])) {
  58. $html .= '<div class="help-block">'.$text[2].'</div>';
  59. }
  60. $html .= '</div>';
  61. return $html;
  62. }
  63. }