GeneralPreferences.php 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <?php
  2. require_once 'customfilters/ImageSize.php';
  3. class Application_Form_GeneralPreferences extends Zend_Form_SubForm
  4. {
  5. public function init()
  6. {
  7. $maxLens = Application_Model_Show::getMaxLengths();
  8. $this->setEnctype(Zend_Form::ENCTYPE_MULTIPART);
  9. $notEmptyValidator = Application_Form_Helper_ValidationTypes::overrideNotEmptyValidator();
  10. $rangeValidator = Application_Form_Helper_ValidationTypes::overrideBetweenValidator(0, 59.9);
  11. $this->setDecorators(array(
  12. array('ViewScript', array('viewScript' => 'form/preferences_general.phtml'))
  13. ));
  14. $defaultFadeIn = Application_Model_Preference::GetDefaultFadeIn();
  15. $defaultFadeOut = Application_Model_Preference::GetDefaultFadeOut();
  16. //Station name
  17. $this->addElement('text', 'stationName', array(
  18. 'class' => 'input_text',
  19. 'label' => _('Station Name'),
  20. 'required' => false,
  21. 'filters' => array('StringTrim'),
  22. 'value' => Application_Model_Preference::GetStationName(),
  23. ));
  24. // Station description
  25. $stationDescription = new Zend_Form_Element_Textarea("stationDescription");
  26. $stationDescription->setLabel(_('Station Description'));
  27. $stationDescription->setValue(Application_Model_Preference::GetStationDescription());
  28. $stationDescription->setRequired(false);
  29. $stationDescription->setValidators(array(array('StringLength', false, array(0, $maxLens['description']))));
  30. $stationDescription->setAttrib('rows', 4);
  31. $this->addElement($stationDescription);
  32. // Station Logo
  33. $stationLogoUpload = new Zend_Form_Element_File('stationLogo');
  34. $stationLogoUpload->setLabel(_('Station Logo:'))
  35. ->setDescription(_("Note: Anything larger than 600x600 will be resized."))
  36. ->setRequired(false)
  37. ->addValidator('Count', false, 1)
  38. ->addValidator('Extension', false, 'jpg,jpeg,png,gif')
  39. ->setMaxFileSize(1000000)
  40. ->addFilter('ImageSize');
  41. $stationLogoUpload->setAttrib('accept', 'image/*');
  42. $this->addElement($stationLogoUpload);
  43. $stationLogoRemove = new Zend_Form_Element_Button('stationLogoRemove');
  44. $stationLogoRemove->setLabel(_('Remove'));
  45. $stationLogoRemove->setAttrib('class', 'btn');
  46. $stationLogoRemove->setAttrib('id', 'logo-remove-btn');
  47. $stationLogoRemove->setAttrib('onclick', 'removeLogo();');
  48. $this->addElement($stationLogoRemove);
  49. //Default station crossfade duration
  50. $this->addElement('text', 'stationDefaultCrossfadeDuration', array(
  51. 'class' => 'input_text',
  52. 'label' => _('Default Crossfade Duration (s):'),
  53. 'required' => true,
  54. 'filters' => array('StringTrim'),
  55. 'validators' => array(
  56. $rangeValidator,
  57. $notEmptyValidator,
  58. array('regex', false, array('/^[0-9]+(\.\d+)?$/', 'messages' => _('Please enter a time in seconds (eg. 0.5)')))
  59. ),
  60. 'value' => Application_Model_Preference::GetDefaultCrossfadeDuration(),
  61. ));
  62. //Default station fade in
  63. $this->addElement('text', 'stationDefaultFadeIn', array(
  64. 'class' => 'input_text',
  65. 'label' => _('Default Fade In (s):'),
  66. 'required' => true,
  67. 'filters' => array('StringTrim'),
  68. 'validators' => array(
  69. $rangeValidator,
  70. $notEmptyValidator,
  71. array('regex', false, array('/^[0-9]+(\.\d+)?$/', 'messages' => _('Please enter a time in seconds (eg. 0.5)')))
  72. ),
  73. 'value' => $defaultFadeIn,
  74. ));
  75. //Default station fade out
  76. $this->addElement('text', 'stationDefaultFadeOut', array(
  77. 'class' => 'input_text',
  78. 'label' => _('Default Fade Out (s):'),
  79. 'required' => true,
  80. 'filters' => array('StringTrim'),
  81. 'validators' => array(
  82. $rangeValidator,
  83. $notEmptyValidator,
  84. array('regex', false, array('/^[0-9]+(\.\d+)?$/', 'messages' => _('Please enter a time in seconds (eg. 0.5)')))
  85. ),
  86. 'value' => $defaultFadeOut,
  87. ));
  88. $third_party_api = new Zend_Form_Element_Radio('thirdPartyApi');
  89. $third_party_api->setLabel(_('Public Airtime API'));
  90. $third_party_api->setDescription(_('Required for embeddable schedule widget.'));
  91. $third_party_api->setMultiOptions(array(
  92. _("Disabled"),
  93. _("Enabled"),
  94. ));
  95. $third_party_api->setValue(Application_Model_Preference::GetAllow3rdPartyApi());
  96. $third_party_api->setDescription(_('Enabling this feature will allow Airtime to provide schedule data
  97. to external widgets that can be embedded in your website. Enable this
  98. feature to reveal the embeddable code.'));
  99. $third_party_api->setSeparator(' '); //No <br> between radio buttons
  100. //$third_party_api->addDecorator(new Zend_Form_Decorator_Label(array('tag' => 'dd', 'class' => 'radio-inline-list')));
  101. $third_party_api->addDecorator('HtmlTag', array('tag' => 'dd',
  102. 'id'=>"thirdPartyApi-element",
  103. 'class' => 'radio-inline-list',
  104. ));
  105. $this->addElement($third_party_api);
  106. $locale = new Zend_Form_Element_Select("locale");
  107. $locale->setLabel(_("Default Language"));
  108. $locale->setMultiOptions(Application_Model_Locale::getLocales());
  109. $locale->setValue(Application_Model_Preference::GetDefaultLocale());
  110. $this->addElement($locale);
  111. /* Form Element for setting the Timezone */
  112. $timezone = new Zend_Form_Element_Select("timezone");
  113. $timezone->setLabel(_("Station Timezone"));
  114. $timezone->setMultiOptions(Application_Common_Timezone::getTimezones());
  115. $timezone->setValue(Application_Model_Preference::GetDefaultTimezone());
  116. $this->addElement($timezone);
  117. /* Form Element for setting which day is the start of the week */
  118. $week_start_day = new Zend_Form_Element_Select("weekStartDay");
  119. $week_start_day->setLabel(_("Week Starts On"));
  120. $week_start_day->setMultiOptions($this->getWeekStartDays());
  121. $week_start_day->setValue(Application_Model_Preference::GetWeekStartDay());
  122. $this->addElement($week_start_day);
  123. }
  124. private function getWeekStartDays()
  125. {
  126. $days = array(
  127. _('Sunday'),
  128. _('Monday'),
  129. _('Tuesday'),
  130. _('Wednesday'),
  131. _('Thursday'),
  132. _('Friday'),
  133. _('Saturday')
  134. );
  135. return $days;
  136. }
  137. }