SAAS-908 - Break source URL strings into host/port/mount fields

This commit is contained in:
Duncan Sommerville 2015-06-30 12:14:33 -04:00
parent 04fe265538
commit f87fe11a24
4 changed files with 143 additions and 202 deletions

View file

@ -8,14 +8,12 @@ class Application_Form_AddShowLiveStream extends Zend_Form_SubForm
{ {
$cb_airtime_auth = new Zend_Form_Element_Checkbox("cb_airtime_auth"); $cb_airtime_auth = new Zend_Form_Element_Checkbox("cb_airtime_auth");
$cb_airtime_auth->setLabel(sprintf(_("Use %s Authentication:"), PRODUCT_NAME)) $cb_airtime_auth->setLabel(sprintf(_("Use %s Authentication:"), PRODUCT_NAME))
->setRequired(false) ->setRequired(false);
->setDecorators(array('ViewHelper'));
$this->addElement($cb_airtime_auth); $this->addElement($cb_airtime_auth);
$cb_custom_auth = new Zend_Form_Element_Checkbox("cb_custom_auth"); $cb_custom_auth = new Zend_Form_Element_Checkbox("cb_custom_auth");
$cb_custom_auth ->setLabel(_("Use Custom Authentication:")) $cb_custom_auth ->setLabel(_("Use Custom Authentication:"))
->setRequired(false) ->setRequired(false);
->setDecorators(array('ViewHelper'));
$this->addElement($cb_custom_auth); $this->addElement($cb_custom_auth);
//custom username //custom username
@ -26,8 +24,7 @@ class Application_Form_AddShowLiveStream extends Zend_Form_SubForm
->setLabel(_('Custom Username')) ->setLabel(_('Custom Username'))
->setFilters(array('StringTrim')) ->setFilters(array('StringTrim'))
->setValidators(array( ->setValidators(array(
new ConditionalNotEmpty(array("cb_custom_auth"=>"1")))) new ConditionalNotEmpty(array("cb_custom_auth"=>"1"))));
->setDecorators(array('ViewHelper'));
$this->addElement($custom_username); $this->addElement($custom_username);
//custom password //custom password
@ -39,18 +36,34 @@ class Application_Form_AddShowLiveStream extends Zend_Form_SubForm
->setLabel(_('Custom Password')) ->setLabel(_('Custom Password'))
->setFilters(array('StringTrim')) ->setFilters(array('StringTrim'))
->setValidators(array( ->setValidators(array(
new ConditionalNotEmpty(array("cb_custom_auth"=>"1")))) new ConditionalNotEmpty(array("cb_custom_auth"=>"1"))));
->setDecorators(array('ViewHelper'));
$this->addElement($custom_password); $this->addElement($custom_password);
$connection_url = Application_Model_Preference::GetLiveDJSourceConnectionURL(); $showSourceParams = parse_url(Application_Model_Preference::GetLiveDJSourceConnectionURL());
if (trim($connection_url) == "") {
$connection_url = "N/A";
}
$this->setDecorators(array( // Show source connection url parameters
array('ViewScript', array('viewScript' => 'form/add-show-live-stream.phtml', "connection_url"=>$connection_url)) $showSourceHost = new Zend_Form_Element_Text('show_source_host');
)); $showSourceHost->setAttrib('readonly', true)
->setLabel(_('Host:'))
->setValue(isset($showSourceParams["host"])?$showSourceParams["host"]:"");
$this->addElement($showSourceHost);
$showSourcePort = new Zend_Form_Element_Text('show_source_port');
$showSourcePort->setAttrib('readonly', true)
->setLabel(_('Port:'))
->setValue(isset($showSourceParams["port"])?$showSourceParams["port"]:"");
$this->addElement($showSourcePort);
$showSourceMount = new Zend_Form_Element_Text('show_source_mount');
$showSourceMount->setAttrib('readonly', true)
->setLabel(_('Mount:'))
->setValue(isset($showSourceParams["mount"])?$showSourceParams["mount"]:"");
$this->addElement($showSourceMount);
$this->setDecorators(
array(
array('ViewScript', array('viewScript' => 'form/add-show-live-stream.phtml'))
));
} }
public function isValid($data) public function isValid($data)

View file

@ -11,38 +11,38 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
$defaultFade = Application_Model_Preference::GetDefaultTransitionFade(); $defaultFade = Application_Model_Preference::GetDefaultTransitionFade();
$this->setDecorators(array(
array('ViewScript', array('viewScript' => 'form/preferences_livestream.phtml')),
));
// automatic trasition on source disconnection // automatic trasition on source disconnection
$auto_transition = new Zend_Form_Element_Checkbox("auto_transition"); $auto_transition = new Zend_Form_Element_Checkbox("auto_transition");
$auto_transition->setLabel(_("Auto Switch Off")) $auto_transition->setLabel(_("Auto Switch Off:"))
->setValue(Application_Model_Preference::GetAutoTransition()) ->setValue(Application_Model_Preference::GetAutoTransition());
->setDecorators(array('ViewHelper'));
$this->addElement($auto_transition); $this->addElement($auto_transition);
// automatic switch on upon source connection // automatic switch on upon source connection
$auto_switch = new Zend_Form_Element_Checkbox("auto_switch"); $auto_switch = new Zend_Form_Element_Checkbox("auto_switch");
$auto_switch->setLabel(_("Auto Switch On")) $auto_switch->setLabel(_("Auto Switch On:"))
->setValue(Application_Model_Preference::GetAutoSwitch()) ->setValue(Application_Model_Preference::GetAutoSwitch());
->setDecorators(array('ViewHelper'));
$this->addElement($auto_switch); $this->addElement($auto_switch);
// Default transition fade // Default transition fade
$transition_fade = new Zend_Form_Element_Text("transition_fade"); $transition_fade = new Zend_Form_Element_Text("transition_fade");
$transition_fade->setLabel(_("Switch Transition Fade (s)")) $transition_fade->setLabel(_("Switch Transition Fade (s):"))
->setFilters(array('StringTrim')) ->setFilters(array('StringTrim'))
->addValidator('regex', false, array('/^\d*(\.\d+)?$/', ->addValidator('regex', false, array('/^\d*(\.\d+)?$/',
'messages' => _('Please enter a time in seconds (eg. 0.5)'))) 'messages' => _('Please enter a time in seconds (eg. 0.5)')))
->setValue($defaultFade) ->setValue($defaultFade);
->setDecorators(array('ViewHelper'));
$this->addElement($transition_fade); $this->addElement($transition_fade);
//Master username //Master username
$master_username = new Zend_Form_Element_Text('master_username'); $master_username = new Zend_Form_Element_Text('master_username');
$master_username->setAttrib('autocomplete', 'off') $master_username->setAttrib('autocomplete', 'off')
->setAllowEmpty(true) ->setAllowEmpty(true)
->setLabel(_('Master Username')) ->setLabel(_('Username:'))
->setFilters(array('StringTrim')) ->setFilters(array('StringTrim'))
->setValue(Application_Model_Preference::GetLiveStreamMasterUsername()) ->setValue(Application_Model_Preference::GetLiveStreamMasterUsername());
->setDecorators(array('ViewHelper'));
$this->addElement($master_username); $this->addElement($master_username);
//Master password //Master password
@ -56,26 +56,51 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
->setAttrib('renderPassword','true') ->setAttrib('renderPassword','true')
->setAllowEmpty(true) ->setAllowEmpty(true)
->setValue(Application_Model_Preference::GetLiveStreamMasterPassword()) ->setValue(Application_Model_Preference::GetLiveStreamMasterPassword())
->setLabel(_('Master Password')) ->setLabel(_('Password:'))
->setFilters(array('StringTrim')) ->setFilters(array('StringTrim'));
->setDecorators(array('ViewHelper'));
$this->addElement($master_password); $this->addElement($master_password);
//Master source connection url $masterSourceParams = parse_url(Application_Model_Preference::GetMasterDJSourceConnectionURL());
$master_dj_connection_url = new Zend_Form_Element_Text('master_dj_connection_url');
$master_dj_connection_url->setAttrib('readonly', true)
->setLabel(_('Master Source Connection URL'))
->setValue(Application_Model_Preference::GetMasterDJSourceConnectionURL())
->setDecorators(array('ViewHelper'));
$this->addElement($master_dj_connection_url);
//Show source connection url // Master source connection url parameters
$live_dj_connection_url = new Zend_Form_Element_Text('live_dj_connection_url'); $masterSourceHost = new Zend_Form_Element_Text('master_source_host');
$live_dj_connection_url->setAttrib('readonly', true) $masterSourceHost->setAttrib('readonly', true)
->setLabel(_('Show Source Connection URL')) ->setLabel(_('Host:'))
->setValue(Application_Model_Preference::GetLiveDJSourceConnectionURL()) ->setValue(isset($masterSourceParams["host"])?$masterSourceParams["host"]:"");
->setDecorators(array('ViewHelper')); $this->addElement($masterSourceHost);
$this->addElement($live_dj_connection_url);
$masterSourcePort = new Zend_Form_Element_Text('master_source_port');
$masterSourcePort->setAttrib('readonly', true)
->setLabel(_('Port:'))
->setValue(isset($masterSourceParams["port"])?$masterSourceParams["port"]:"");
$this->addElement($masterSourcePort);
$masterSourceMount = new Zend_Form_Element_Text('master_source_mount');
$masterSourceMount->setAttrib('readonly', true)
->setLabel(_('Mount:'))
->setValue(isset($masterSourceParams["path"])?$masterSourceParams["path"]:"");
$this->addElement($masterSourceMount);
$showSourceParams = parse_url(Application_Model_Preference::GetLiveDJSourceConnectionURL());
// Show source connection url parameters
$showSourceHost = new Zend_Form_Element_Text('show_source_host');
$showSourceHost->setAttrib('readonly', true)
->setLabel(_('Host:'))
->setValue(isset($showSourceParams["host"])?$showSourceParams["host"]:"");
$this->addElement($showSourceHost);
$showSourcePort = new Zend_Form_Element_Text('show_source_port');
$showSourcePort->setAttrib('readonly', true)
->setLabel(_('Port:'))
->setValue(isset($showSourceParams["port"])?$showSourceParams["port"]:"");
$this->addElement($showSourcePort);
$showSourceMount = new Zend_Form_Element_Text('show_source_mount');
$showSourceMount->setAttrib('readonly', true)
->setLabel(_('Mount:'))
->setValue(isset($showSourceParams["mount"])?$showSourceParams["mount"]:"");
$this->addElement($showSourceMount);
// demo only code // demo only code
if (!$isStreamConfigable) { if (!$isStreamConfigable) {
@ -93,19 +118,30 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
$CC_CONFIG = Config::getConfig(); $CC_CONFIG = Config::getConfig();
$isDemo = isset($CC_CONFIG['demo']) && $CC_CONFIG['demo'] == 1; $isDemo = isset($CC_CONFIG['demo']) && $CC_CONFIG['demo'] == 1;
$master_dj_connection_url = Application_Model_Preference::GetMasterDJSourceConnectionURL(); $masterSourceParams = parse_url(Application_Model_Preference::GetMasterDJSourceConnectionURL());
$live_dj_connection_url = Application_Model_Preference::GetLiveDJSourceConnectionURL(); $showSourceParams = parse_url(Application_Model_Preference::GetLiveDJSourceConnectionURL());
$this->setDecorators(array( $this->setDecorators(
array('ViewScript', array('viewScript' => 'form/preferences_livestream.phtml', 'master_dj_connection_url'=>$master_dj_connection_url, 'live_dj_connection_url'=>$live_dj_connection_url, 'isDemo' => $isDemo)) array (
)); array ('ViewScript',
array (
'viewScript' => 'form/preferences_livestream.phtml',
'master_source_host' => isset($masterSourceParams["host"])?$masterSourceParams["host"]:"",
'master_source_port' => isset($masterSourceParams["port"])?$masterSourceParams["port"]:"",
'master_source_mount' => isset($masterSourceParams["mount"])?$masterSourceParams["mount"]:"",
'show_source_host' => isset($showSourceParams["host"])?$showSourceParams["host"]:"",
'show_source_port' => isset($showSourceParams["port"])?$showSourceParams["port"]:"",
'show_source_mount' => isset($showSourceParams["mount"])?$showSourceParams["mount"]:"",
'isDemo' => $isDemo,
)
)
)
);
} }
public function isValid($data) public function isValid($data)
{ {
$isValid = parent::isValid($data); return parent::isValid($data);
return $isValid;
} }
} }

View file

@ -1,60 +1,20 @@
<fieldset> <fieldset>
<dl> <dl>
<dt id="cb_airtime_auth_override-label"> <?php echo $this->element->getElement('cb_airtime_auth')->render(); ?>
<label class="optional" for="cb_airtime_auth"> <?php echo $this->element->getElement('cb_custom_auth')->render(); ?>
<?php echo $this->element->getElement('cb_airtime_auth')->getLabel() ?>
<span class='airtime_auth_help_icon'></span>
</label>
</dt>
<dd id="cb_airtime_auth_override-element">
<?php echo $this->element->getElement('cb_airtime_auth') ?>
</dd>
<dt id="cb_custom_auth_override-label">
<label class="optional" for="cb_custom_auth">
<?php echo $this->element->getElement('cb_custom_auth')->getLabel() ?>
<span class='custom_auth_help_icon'></span>
</label>
</dt>
<dd id="cb_custom_auth_override-element">
<?php echo $this->element->getElement('cb_custom_auth') ?>
</dd>
<div id="custom_auth_div"> <div id="custom_auth_div">
<dt id="custom_username-label" class="block-display"> <?php echo $this->element->getElement('custom_username')->render(); ?>
<label class="optional" for="custom_username"><?php echo $this->element->getElement('custom_username')->getLabel() ?> : <?php echo $this->element->getElement('custom_password')->render(); ?>
<span class='stream_username_help_icon'></span>
</label>
</dt>
<dd id="custom_username-element" class="block-display">
<?php echo $this->element->getElement('custom_username') ?>
<?php if($this->element->getElement('custom_username')->hasErrors()) : ?>
<ul class='errors'>
<?php foreach($this->element->getElement('custom_username')->getMessages() as $error): ?>
<li><?php echo $error; ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</dd>
<dt id="custom_password-label" class="block-display">
<label class="optional" for="custom_password"><?php echo $this->element->getElement('custom_password')->getLabel() ?> :
</label>
</dt>
<dd id="custom_password-element" class="block-display">
<?php echo $this->element->getElement('custom_password') ?>
<?php if($this->element->getElement('custom_password')->hasErrors()) : ?>
<ul class='errors'>
<?php foreach($this->element->getElement('custom_password')->getMessages() as $error): ?>
<li><?php echo $error; ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</dd>
</div> </div>
<dt id="Connection_URL-label"> <fieldset>
<label for="outputStreamURL"><?php echo _("Connection URL: "); ?></label> <legend><?php echo _("Show Source") ?></legend>
</dt> <p class="input-settings-inline-p">
<dd id="Connection_URL-element"> <?php echo _("DJs can use these settings to connect and broadcast live during this show (with compatible software)") ?>
<span id="stream_url" class="static_text"><?php echo $this->connection_url; ?></span> </p>
</dd> <?php echo $this->element->getElement("show_source_host")->render() ?>
<?php echo $this->element->getElement("show_source_port")->render() ?>
<?php echo $this->element->getElement("show_source_mount")->render() ?>
</fieldset>
</dl> </dl>
</fieldset> </fieldset>

View file

@ -1,102 +1,34 @@
<fieldset class="padded stream-setting-global" style="margin-top: 15px"> <fieldset class="padded stream-setting-global" style="margin-top: 15px">
<legend><?php echo _("Input Stream Settings") ?></legend> <legend><?php echo _("Input Stream Settings") ?></legend>
<dl class="zend_form"> <dl class="zend_form">
<dt id="auto_transition-label"> <?php echo $this->element->getElement('auto_transition')->render() ?>
<label class="optional" for="auto_transition"><?php echo $this->element->getElement('auto_transition')->getLabel() ?> : <span class="icecast_metadata_help_icon" id="auto_transition_help"></span>
<span class="icecast_metadata_help_icon" id="auto_transition_help"> <?php echo $this->element->getElement('auto_switch')->render() ?>
</span> <span class="icecast_metadata_help_icon" id="auto_switch_help"></span>
</label> <?php echo $this->element->getElement('transition_fade')->render() ?>
</dt>
<dd id="auto_transition-element"> <fieldset class="padded stream-setting-global" style="margin-top: 15px">
<?php echo $this->element->getElement('auto_transition') ?> <legend><?php echo _("Master Source") ?></legend>
<?php if($this->element->getElement('auto_transition')->hasErrors()) : ?> <p class="input-settings-inline-p">
<ul class='errors'> <?php echo _("Use these settings in your broadcasting software to connect to Master Source") ?>
<?php foreach($this->element->getElement('auto_transition')->getMessages() as $error): ?> </p>
<li><?php echo $error; ?></li> <?php echo $this->element->getElement('master_username')->render() ?>
<?php endforeach; ?> <span class="master_username_help_icon"></span>
</ul> <?php echo $this->element->getElement('master_password')->render() ?>
<?php endif; ?>
</dd> <?php echo $this->element->getElement("master_source_host")->render() ?>
<dt id="auto_switch-label"> <?php echo $this->element->getElement("master_source_port")->render() ?>
<label class="optional" for="auto_transition"><?php echo $this->element->getElement('auto_switch')->getLabel() ?> : <?php echo $this->element->getElement("master_source_mount")->render() ?>
<span class="icecast_metadata_help_icon" id="auto_switch_help"> </fieldset>
</span>
</label> <fieldset class="padded stream-setting-global" style="margin-top: 15px">
</dt> <legend><?php echo _("Show Source") ?></legend>
<dd id="auto_switch-element"> <p class="input-settings-inline-p">
<?php echo $this->element->getElement('auto_switch') ?> <?php echo _("These settings allow DJs to connect to individual shows through Show Source") ?>
<?php if($this->element->getElement('auto_switch')->hasErrors()) : ?> </p>
<ul class='errors'> <?php echo $this->element->getElement("show_source_host")->render() ?>
<?php foreach($this->element->getElement('auto_switch')->getMessages() as $error): ?> <?php echo $this->element->getElement("show_source_port")->render() ?>
<li><?php echo $error; ?></li> <?php echo $this->element->getElement("show_source_mount")->render() ?>
<?php endforeach; ?> </fieldset>
</ul>
<?php endif; ?>
</dd>
<dt id="transition_fade-label">
<label class="optional" for="transition_fade"><?php echo $this->element->getElement('transition_fade')->getLabel() ?> :
</label>
</dt>
<dd id="transition_fade-element">
<?php echo $this->element->getElement('transition_fade') ?>
<?php if($this->element->getElement('transition_fade')->hasErrors()) : ?>
<ul class='errors'>
<?php foreach($this->element->getElement('transition_fade')->getMessages() as $error): ?>
<li><?php echo $error; ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</dd>
<dt id="master_username-label">
<label class="optional" for="master_username"><?php echo $this->element->getElement('master_username')->getLabel() ?> :
<span class='master_username_help_icon'></span>
</label>
</dt>
<dd id="master_username-element">
<?php echo $this->element->getElement('master_username') ?>
<?php if($this->element->getElement('master_username')->hasErrors()) : ?>
<ul class='errors'>
<?php foreach($this->element->getElement('master_username')->getMessages() as $error): ?>
<li><?php echo $error; ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</dd>
<dt id="master_password-label">
<label class="optional" for="master_password"><?php echo $this->element->getElement('master_password')->getLabel() ?> :
</label>
</dt>
<dd id="master_password-element">
<?php echo $this->element->getElement('master_password') ?>
<?php if($this->element->getElement('master_password')->hasErrors()) : ?>
<ul class='errors'>
<?php foreach($this->element->getElement('master_password')->getMessages() as $error): ?>
<li><?php echo $error; ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</dd>
<dt id="master_dj_connection_url-label">
<label class="optional" for="master_dj_connection_url" style="white-space: nowrap">
<?php echo _("Master Source Connection URL:")?>
</label>
</dt>
<dd id="master_dj_connection_url-element">
<span id="stream_url"><?php echo $this->element->getElement('master_dj_connection_url')->setValue($this->master_dj_connection_url) ?></span>
<div id="master_dj_connection_url_actions" style="display:none">
<a href=# id="ok" style="font-size: 12px;"><?php echo _("OK") ?></a> <a href=# id="reset" style="font-size: 12px;"><?php echo _("RESET"); ?></a>
</div>
</dd>
<dt id="live_dj_connection_url-label">
<label class="optional" for="live_dj_connection_url" style="white-space: nowrap">
<?php echo _("Show Source Connection URL:")?>
</label>
</dt>
<dd id="live_dj_connection_url-element">
<span id="stream_url"><?php echo $this->element->getElement('live_dj_connection_url')->setValue($this->live_dj_connection_url) ?></span>
<div id="live_dj_connection_url_actions" style="display:none">
<a href=# id="ok" style="font-size: 12px;"><?php echo _("OK") ?></a> <a href=# id="reset" style="font-size: 12px;"><?php echo _("RESET"); ?></a>
</div>
</dd>
</dl> </dl>
</fieldset> </fieldset>