RegisterAirtime.php 6.2 KB

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