CC-4090: Make code style PSR compliant - part 4

-forms directory
This commit is contained in:
Martin Konecny 2012-08-28 23:04:55 -04:00
parent 481616a0d6
commit b2327472e8
29 changed files with 505 additions and 519 deletions

View file

@ -1,5 +1,6 @@
<?php
class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm
{
private $prefix;
private $setting;
private $stream_types;
@ -10,23 +11,28 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
}
public function setPrefix($prefix){
public function setPrefix($prefix)
{
$this->prefix = $prefix;
}
public function setSetting($setting){
public function setSetting($setting)
{
$this->setting = $setting;
}
public function setStreamTypes($stream_types){
public function setStreamTypes($stream_types)
{
$this->stream_types = $stream_types;
}
public function setStreamBitrates($stream_bitrates){
public function setStreamBitrates($stream_bitrates)
{
$this->stream_bitrates = $stream_bitrates;
}
public function startForm(){
public function startForm()
{
$prefix = "s".$this->prefix;
$stream_number = $this->prefix;
$setting = $this->setting;
@ -36,16 +42,13 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
$this->setIsArray(true);
$this->setElementsBelongTo($prefix."_data");
$disable_all = false;
if(Application_Model_Preference::GetEnableStreamConf() == "false"){
$disable_all = true;
}
$disable_all = Application_Model_Preference::GetEnableStreamConf() == "false";
$enable = new Zend_Form_Element_Checkbox('enable');
$enable->setLabel('Enabled:')
->setValue($setting[$prefix.'_enable'] == 'true' ? 1 : 0)
->setDecorators(array('ViewHelper'));
if($disable_all){
if ($disable_all) {
$enable->setAttrib("disabled", "disabled");
}
$this->addElement($enable);
@ -55,7 +58,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
->setMultiOptions($stream_types)
->setValue(isset($setting[$prefix.'_type'])?$setting[$prefix.'_type']:0)
->setDecorators(array('ViewHelper'));
if($disable_all){
if ($disable_all) {
$type->setAttrib("disabled", "disabled");
}
$this->addElement($type);
@ -65,7 +68,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
->setMultiOptions($stream_bitrates)
->setValue(isset($setting[$prefix.'_bitrate'])?$setting[$prefix.'_bitrate']:0)
->setDecorators(array('ViewHelper'));
if($disable_all){
if ($disable_all) {
$bitrate->setAttrib("disabled", "disabled");
}
$this->addElement($bitrate);
@ -75,7 +78,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
->setMultiOptions(array("icecast"=>"Icecast", "shoutcast"=>"SHOUTcast"))
->setValue(isset($setting[$prefix.'_output'])?$setting[$prefix.'_output']:"icecast")
->setDecorators(array('ViewHelper'));
if($disable_all){
if ($disable_all) {
$output->setAttrib("disabled", "disabled");
}
$this->addElement($output);
@ -86,7 +89,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
->setValidators(array(
array('regex', false, array('/^[0-9a-zA-Z-_.]+$/', 'messages' => 'Invalid character entered'))))
->setDecorators(array('ViewHelper'));
if($disable_all){
if ($disable_all) {
$host->setAttrib("disabled", "disabled");
}
$host->setAttrib('alt', 'domain');
@ -98,7 +101,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
->setValidators(array(new Zend_Validate_Between(array('min'=>0, 'max'=>99999))))
->addValidator('regex', false, array('pattern'=>'/^[0-9]+$/', 'messages'=>array('regexNotMatch'=>'Only numbers are allowed.')))
->setDecorators(array('ViewHelper'));
if($disable_all){
if ($disable_all) {
$port->setAttrib("disabled", "disabled");
}
$this->addElement($port);
@ -109,7 +112,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
->setValidators(array(
array('regex', false, array('/^[^ &<>]+$/', 'messages' => 'Invalid character entered'))))
->setDecorators(array('ViewHelper'));
if($disable_all){
if ($disable_all) {
$pass->setAttrib("disabled", "disabled");
}
$pass->setAttrib('alt', 'regular_text');
@ -119,7 +122,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
$genre->setLabel("Genre")
->setValue(isset($setting[$prefix.'_genre'])?$setting[$prefix.'_genre']:"")
->setDecorators(array('ViewHelper'));
if($disable_all){
if ($disable_all) {
$genre->setAttrib("disabled", "disabled");
}
$this->addElement($genre);
@ -130,7 +133,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
->setValidators(array(
array('regex', false, array('/^[0-9a-zA-Z\-_.:\/]+$/', 'messages' => 'Invalid character entered'))))
->setDecorators(array('ViewHelper'));
if($disable_all){
if ($disable_all) {
$url->setAttrib("disabled", "disabled");
}
$url->setAttrib('alt', 'url');
@ -140,7 +143,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
$name->setLabel("Name")
->setValue(isset($setting[$prefix.'_name'])?$setting[$prefix.'_name']:"")
->setDecorators(array('ViewHelper'));
if($disable_all){
if ($disable_all) {
$name->setAttrib("disabled", "disabled");
}
$this->addElement($name);
@ -149,7 +152,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
$description->setLabel("Description")
->setValue(isset($setting[$prefix.'_description'])?$setting[$prefix.'_description']:"")
->setDecorators(array('ViewHelper'));
if($disable_all){
if ($disable_all) {
$description->setAttrib("disabled", "disabled");
}
$this->addElement($description);
@ -160,7 +163,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
->setValidators(array(
array('regex', false, array('/^[^ &<>]+$/', 'messages' => 'Invalid character entered'))))
->setDecorators(array('ViewHelper'));
if($disable_all){
if ($disable_all) {
$mount->setAttrib("disabled", "disabled");
}
$mount->setAttrib('alt', 'regular_text');
@ -172,7 +175,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
->setValidators(array(
array('regex', false, array('/^[^ &<>]+$/', 'messages' => 'Invalid character entered'))))
->setDecorators(array('ViewHelper'));
if($disable_all){
if ($disable_all) {
$user->setAttrib("disabled", "disabled");
}
$user->setAttrib('alt', 'regular_text');
@ -185,28 +188,30 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
));
}
public function isValid ($data){
public function isValid ($data)
{
$f_data = $data['s'.$this->prefix."_data"];
$isValid = parent::isValid($f_data);
if($f_data['enable'] == 1){
if($f_data['host'] == ''){
if ($f_data['enable'] == 1) {
if ($f_data['host'] == '') {
$element = $this->getElement("host");
$element->addError("Server cannot be empty.");
$isValid = false;
}
if($f_data['port'] == ''){
if ($f_data['port'] == '') {
$element = $this->getElement("port");
$element->addError("Port cannot be empty.");
$isValid = false;
}
if($f_data['output'] == 'icecast'){
if($f_data['mount'] == ''){
if ($f_data['output'] == 'icecast') {
if ($f_data['mount'] == '') {
$element = $this->getElement("mount");
$element->addError("Mount cannot be empty with Icecast server.");
$isValid = false;
}
}
}
return $isValid;
}
}