SupportSettings.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <?php
  2. class Application_Form_SupportSettings extends Zend_Form
  3. {
  4. public function init()
  5. {
  6. $country_list = Application_Model_Preference::GetCountryList();
  7. $notEmptyValidator = Application_Form_Helper_ValidationTypes::overrideNotEmptyValidator();
  8. $this->setDecorators(array(
  9. array('ViewScript', array('viewScript' => 'form/support-setting.phtml')),
  10. array('File', array('viewScript' => 'form/support-setting.phtml', 'placement' => false)))
  11. );
  12. //Station name
  13. $this->addElement('text', 'stationName', array(
  14. 'class' => 'input_text',
  15. 'label' => _('Station Name'),
  16. 'required' => true,
  17. 'filters' => array('StringTrim'),
  18. 'validators' => array($notEmptyValidator),
  19. 'value' => Application_Model_Preference::GetStationName(),
  20. 'decorators' => array(
  21. 'ViewHelper'
  22. )
  23. ));
  24. // Phone number
  25. $this->addElement('text', 'Phone', array(
  26. 'class' => 'input_text',
  27. 'label' => _('Phone:'),
  28. 'required' => false,
  29. 'filters' => array('StringTrim'),
  30. 'value' => Application_Model_Preference::GetPhone(),
  31. 'decorators' => array(
  32. 'ViewHelper'
  33. )
  34. ));
  35. //Email
  36. $this->addElement('text', 'Email', array(
  37. 'class' => 'input_text',
  38. 'label' => _('Email:'),
  39. 'required' => false,
  40. 'filters' => array('StringTrim'),
  41. 'value' => Application_Model_Preference::GetEmail(),
  42. 'decorators' => array(
  43. 'ViewHelper'
  44. )
  45. ));
  46. // Station Web Site
  47. $this->addElement('text', 'StationWebSite', array(
  48. 'label' => _('Station Web Site:'),
  49. 'required' => false,
  50. 'class' => 'input_text',
  51. 'value' => Application_Model_Preference::GetStationWebSite(),
  52. 'decorators' => array(
  53. 'ViewHelper'
  54. )
  55. ));
  56. // county list dropdown
  57. $this->addElement('select', 'Country', array(
  58. 'label' => _('Country:'),
  59. 'required' => false,
  60. 'value' => Application_Model_Preference::GetStationCountry(),
  61. 'multiOptions' => $country_list,
  62. 'decorators' => array(
  63. 'ViewHelper'
  64. )
  65. ));
  66. // Station city
  67. $this->addElement('text', 'City', array(
  68. 'label' => _('City:'),
  69. 'required' => false,
  70. 'class' => 'input_text',
  71. 'value' => Application_Model_Preference::GetStationCity(),
  72. 'decorators' => array(
  73. 'ViewHelper'
  74. )
  75. ));
  76. // Station Description
  77. $description = new Zend_Form_Element_Textarea('Description');
  78. $description->class = 'input_text_area';
  79. $description->setLabel(_('Station Description:'))
  80. ->setRequired(false)
  81. ->setValue(Application_Model_Preference::GetStationDescription())
  82. ->setDecorators(array('ViewHelper'))
  83. ->setAttrib('ROWS','2')
  84. ->setAttrib('COLS','58');
  85. $this->addElement($description);
  86. //enable support feedback
  87. $this->addElement('checkbox', 'SupportFeedback', array(
  88. 'label' => _('Send support feedback'),
  89. 'required' => false,
  90. 'value' => Application_Model_Preference::GetSupportFeedback(),
  91. 'decorators' => array(
  92. 'ViewHelper'
  93. )
  94. ));
  95. // checkbox for publicise
  96. $checkboxPublicise = new Zend_Form_Element_Checkbox("Publicise");
  97. $checkboxPublicise->setLabel(sprintf(_('Promote my station on %s'), COMPANY_SITE))
  98. ->setRequired(false)
  99. ->setDecorators(array('ViewHelper'))
  100. ->setValue(Application_Model_Preference::GetPublicise());
  101. if (Application_Model_Preference::GetSupportFeedback() == '0') {
  102. $checkboxPublicise->setAttrib("disabled", "disabled");
  103. }
  104. $this->addElement($checkboxPublicise);
  105. // text area for sending detail
  106. $this->addElement('textarea', 'SendInfo', array(
  107. 'class' => 'sending_textarea',
  108. 'required' => false,
  109. 'filters' => array('StringTrim'),
  110. 'readonly' => true,
  111. 'cols' => 61,
  112. 'rows' => 5,
  113. 'value' => Application_Model_Preference::GetSystemInfo(false, true),
  114. 'decorators' => array(
  115. 'ViewHelper'
  116. )
  117. ));
  118. $privacyPolicyAnchorOpen = "<a id='link_to_privacy' href='" . PRIVACY_POLICY_URL
  119. . "' onclick='window.open(this.href); return false;'>";
  120. // checkbox for privacy policy
  121. $checkboxPrivacy = new Zend_Form_Element_Checkbox("Privacy");
  122. $checkboxPrivacy->setLabel(
  123. sprintf(_('By checking this box, I agree to %s\'s %sprivacy policy%s.'),
  124. COMPANY_NAME,
  125. $privacyPolicyAnchorOpen,
  126. "</a>"))
  127. ->setDecorators(array('ViewHelper'));
  128. $this->addElement($checkboxPrivacy);
  129. // submit button
  130. $submit = new Zend_Form_Element_Submit("submit");
  131. $submit->class = 'btn right-floated';
  132. $submit->setIgnore(true)
  133. ->setLabel(_("Save"))
  134. ->setDecorators(array('ViewHelper'));
  135. $this->addElement($submit);
  136. }
  137. // overriding isValid function
  138. public function isValid ($data)
  139. {
  140. $isValid = parent::isValid($data);
  141. if (isset($data["Privacy"])) {
  142. $checkPrivacy = $this->getElement('Privacy');
  143. if ($data["SupportFeedback"] == "1" && $data["Privacy"] != "1") {
  144. $checkPrivacy->addError(_("You have to agree to privacy policy."));
  145. $isValid = false;
  146. }
  147. }
  148. return $isValid;
  149. }
  150. }