2012-02-06 23:51:02 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
|
|
|
|
{
|
2012-07-11 00:55:44 +02:00
|
|
|
|
2012-02-06 23:51:02 +01:00
|
|
|
public function init()
|
|
|
|
{
|
2013-01-14 22:16:14 +01:00
|
|
|
$CC_CONFIG = Config::getConfig();
|
2012-06-05 18:18:59 +02:00
|
|
|
$isDemo = isset($CC_CONFIG['demo']) && $CC_CONFIG['demo'] == 1;
|
2017-03-14 02:15:14 +01:00
|
|
|
$isStreamConfigable = Application_Model_Preference::GetEnableStreamConf() == "true";
|
2012-07-11 00:55:44 +02:00
|
|
|
|
2012-03-21 03:16:17 +01:00
|
|
|
$defaultFade = Application_Model_Preference::GetDefaultTransitionFade();
|
2012-07-11 00:55:44 +02:00
|
|
|
|
2015-06-30 18:14:33 +02:00
|
|
|
$this->setDecorators(array(
|
2017-03-17 03:30:08 +01:00
|
|
|
array('ViewScript', array('viewScript' => 'form/preferences_livestream.phtml')),
|
|
|
|
));
|
2015-06-30 18:14:33 +02:00
|
|
|
|
2012-06-12 21:38:03 +02:00
|
|
|
// automatic trasition on source disconnection
|
2012-06-05 22:41:41 +02:00
|
|
|
$auto_transition = new Zend_Form_Element_Checkbox("auto_transition");
|
2015-06-30 18:14:33 +02:00
|
|
|
$auto_transition->setLabel(_("Auto Switch Off:"))
|
2017-03-17 03:30:08 +01:00
|
|
|
->setValue(Application_Model_Preference::GetAutoTransition());
|
2012-06-05 22:41:41 +02:00
|
|
|
$this->addElement($auto_transition);
|
2012-07-11 00:55:44 +02:00
|
|
|
|
2012-06-12 21:38:03 +02:00
|
|
|
// automatic switch on upon source connection
|
|
|
|
$auto_switch = new Zend_Form_Element_Checkbox("auto_switch");
|
2015-06-30 18:14:33 +02:00
|
|
|
$auto_switch->setLabel(_("Auto Switch On:"))
|
2017-03-17 03:30:08 +01:00
|
|
|
->setValue(Application_Model_Preference::GetAutoSwitch());
|
2012-06-12 21:38:03 +02:00
|
|
|
$this->addElement($auto_switch);
|
2012-07-11 00:55:44 +02:00
|
|
|
|
2012-06-05 22:41:41 +02:00
|
|
|
// Default transition fade
|
2012-03-21 03:16:17 +01:00
|
|
|
$transition_fade = new Zend_Form_Element_Text("transition_fade");
|
2015-06-30 18:14:33 +02:00
|
|
|
$transition_fade->setLabel(_("Switch Transition Fade (s):"))
|
2017-03-17 03:30:08 +01:00
|
|
|
->setFilters(array('StringTrim'))
|
|
|
|
->addValidator('regex', false, array('/^\d*(\.\d+)?$/',
|
|
|
|
'messages' => _('Please enter a time in seconds (eg. 0.5)')))
|
|
|
|
->setValue($defaultFade);
|
2012-03-21 03:16:17 +01:00
|
|
|
$this->addElement($transition_fade);
|
2012-07-11 00:55:44 +02:00
|
|
|
|
2012-02-06 23:51:02 +01:00
|
|
|
//Master username
|
|
|
|
$master_username = new Zend_Form_Element_Text('master_username');
|
2012-02-21 23:58:05 +01:00
|
|
|
$master_username->setAttrib('autocomplete', 'off')
|
2017-03-17 03:30:08 +01:00
|
|
|
->setAllowEmpty(true)
|
|
|
|
->setLabel(_('Username:'))
|
|
|
|
->setFilters(array('StringTrim'))
|
|
|
|
->setValue(Application_Model_Preference::GetLiveStreamMasterUsername());
|
2012-02-06 23:51:02 +01:00
|
|
|
$this->addElement($master_username);
|
2012-07-11 00:55:44 +02:00
|
|
|
|
2012-02-06 23:51:02 +01:00
|
|
|
//Master password
|
2012-08-29 05:04:55 +02:00
|
|
|
if ($isDemo) {
|
2017-03-17 03:30:08 +01:00
|
|
|
$master_password = new Zend_Form_Element_Text('master_password');
|
2012-08-29 05:04:55 +02:00
|
|
|
} else {
|
2017-03-17 03:30:08 +01:00
|
|
|
$master_password = new Zend_Form_Element_Password('master_password');
|
|
|
|
$master_password->setAttrib('renderPassword', 'true');
|
2012-06-05 18:18:59 +02:00
|
|
|
}
|
2012-02-21 23:58:05 +01:00
|
|
|
$master_password->setAttrib('autocomplete', 'off')
|
2017-03-17 03:30:08 +01:00
|
|
|
->setAttrib('renderPassword', 'true')
|
|
|
|
->setAllowEmpty(true)
|
|
|
|
->setValue(Application_Model_Preference::GetLiveStreamMasterPassword())
|
|
|
|
->setLabel(_('Password:'))
|
|
|
|
->setFilters(array('StringTrim'));
|
2012-02-06 23:51:02 +01:00
|
|
|
$this->addElement($master_password);
|
2012-07-11 00:55:44 +02:00
|
|
|
|
2015-06-30 18:14:33 +02:00
|
|
|
$masterSourceParams = parse_url(Application_Model_Preference::GetMasterDJSourceConnectionURL());
|
|
|
|
|
|
|
|
// Master source connection url parameters
|
|
|
|
$masterSourceHost = new Zend_Form_Element_Text('master_source_host');
|
2017-03-14 02:15:14 +01:00
|
|
|
$masterSourceHost->setLabel(_('Host:'))
|
|
|
|
->setAttrib('readonly', true)
|
|
|
|
->setValue(Application_Model_Preference::GetMasterDJSourceConnectionURL());
|
2015-06-30 18:14:33 +02:00
|
|
|
$this->addElement($masterSourceHost);
|
|
|
|
|
2017-03-17 03:30:08 +01:00
|
|
|
|
2017-03-14 02:15:14 +01:00
|
|
|
//liquidsoap harbor.input port
|
|
|
|
$betweenValidator = Application_Form_Helper_ValidationTypes::overrideBetweenValidator(1024, 49151);
|
2017-03-17 03:30:08 +01:00
|
|
|
|
2017-03-14 02:15:14 +01:00
|
|
|
$m_port = Application_Model_StreamSetting::getMasterLiveStreamPort();
|
2017-03-17 03:30:08 +01:00
|
|
|
|
2015-06-30 18:14:33 +02:00
|
|
|
$masterSourcePort = new Zend_Form_Element_Text('master_source_port');
|
2017-03-14 02:15:14 +01:00
|
|
|
$masterSourcePort->setLabel(_('Master Source Port:'))
|
|
|
|
->setValue($m_port)
|
|
|
|
->addValidator('regex', false, array('pattern'=>'/^[0-9]+$/', 'messages'=>array('regexNotMatch'=>_('Only numbers are allowed.'))));
|
2017-03-16 15:18:43 +01:00
|
|
|
|
2017-03-17 03:30:08 +01:00
|
|
|
$this->addElement($masterSourcePort);
|
|
|
|
|
|
|
|
|
2015-06-30 18:14:33 +02:00
|
|
|
|
2017-03-14 02:15:14 +01:00
|
|
|
$m_mount = Application_Model_StreamSetting::getMasterLiveStreamMountPoint();
|
2015-06-30 18:14:33 +02:00
|
|
|
$masterSourceMount = new Zend_Form_Element_Text('master_source_mount');
|
2017-03-14 02:15:14 +01:00
|
|
|
$masterSourceMount->setLabel(_('Master Source Mount:'))
|
|
|
|
->setValue($m_mount)
|
|
|
|
->setValidators(array(
|
|
|
|
array('regex', false, array('/^[^ &<>]+$/', 'messages' => _('Invalid character entered')))));
|
2015-06-30 18:14:33 +02:00
|
|
|
$this->addElement($masterSourceMount);
|
|
|
|
|
|
|
|
$showSourceParams = parse_url(Application_Model_Preference::GetLiveDJSourceConnectionURL());
|
|
|
|
|
|
|
|
// Show source connection url parameters
|
|
|
|
$showSourceHost = new Zend_Form_Element_Text('show_source_host');
|
2017-03-14 02:15:14 +01:00
|
|
|
$showSourceHost->setLabel(_('Host:'))
|
|
|
|
->setAttrib('readonly', true)
|
|
|
|
->setValue(Application_Model_Preference::GetLiveDJSourceConnectionURL());
|
2015-06-30 18:14:33 +02:00
|
|
|
$this->addElement($showSourceHost);
|
|
|
|
|
2017-03-14 02:15:14 +01:00
|
|
|
//liquidsoap harbor.input port
|
|
|
|
$l_port = Application_Model_StreamSetting::getDjLiveStreamPort();
|
|
|
|
|
2015-06-30 18:14:33 +02:00
|
|
|
$showSourcePort = new Zend_Form_Element_Text('show_source_port');
|
2017-03-14 02:15:14 +01:00
|
|
|
$showSourcePort->setLabel(_('Show Source Port:'))
|
|
|
|
->setValue($l_port)
|
|
|
|
->setValidators(array($betweenValidator))
|
2017-03-17 03:30:08 +01:00
|
|
|
->addValidator('regex', false, array('pattern' => '/^[0-9]+$/', 'messages' => array('regexNotMatch' => _('Only numbers are allowed.'))));
|
2015-06-30 18:14:33 +02:00
|
|
|
$this->addElement($showSourcePort);
|
|
|
|
|
2017-03-14 02:15:14 +01:00
|
|
|
$l_mount = Application_Model_StreamSetting::getDjLiveStreamMountPoint();
|
2015-06-30 18:14:33 +02:00
|
|
|
$showSourceMount = new Zend_Form_Element_Text('show_source_mount');
|
2017-03-14 02:15:14 +01:00
|
|
|
$showSourceMount->setLabel(_('Show Source Mount:'))
|
|
|
|
->setValue($l_mount)
|
|
|
|
->setValidators(array(
|
|
|
|
array('regex', false, array('/^[^ &<>]+$/', 'messages' => _('Invalid character entered')))));
|
2015-06-30 18:14:33 +02:00
|
|
|
$this->addElement($showSourceMount);
|
2012-02-06 23:51:02 +01:00
|
|
|
}
|
2012-07-11 00:55:44 +02:00
|
|
|
|
2012-08-29 05:04:55 +02:00
|
|
|
public function updateVariables()
|
|
|
|
{
|
2013-01-14 22:16:14 +01:00
|
|
|
$CC_CONFIG = Config::getConfig();
|
2012-07-11 00:55:44 +02:00
|
|
|
|
2012-06-05 18:18:59 +02:00
|
|
|
$isDemo = isset($CC_CONFIG['demo']) && $CC_CONFIG['demo'] == 1;
|
2015-06-30 18:14:33 +02:00
|
|
|
$masterSourceParams = parse_url(Application_Model_Preference::GetMasterDJSourceConnectionURL());
|
|
|
|
$showSourceParams = parse_url(Application_Model_Preference::GetLiveDJSourceConnectionURL());
|
|
|
|
|
|
|
|
$this->setDecorators(
|
2017-03-17 03:30:08 +01:00
|
|
|
array(
|
|
|
|
array('ViewScript',
|
|
|
|
array(
|
|
|
|
'viewScript' => 'form/preferences_livestream.phtml',
|
|
|
|
'master_source_host' => isset($masterSourceHost) ? Application_Model_Preference::GetMasterDJSourceConnectionURL() : "",
|
|
|
|
'master_source_port' => isset($masterSourcePort) ? Application_Model_StreamSetting::getMasterLiveStreamPort() : "",
|
|
|
|
'master_source_mount' => isset($masterSourceMount) ? Application_Model_StreamSetting::getMasterLiveStreamMountPoint() : "",
|
|
|
|
'show_source_host' => isset($showSourceHost) ? Application_Model_Preference::GetLiveDJSourceConnectionURL() : "",
|
|
|
|
'show_source_port' => isset($showSourcePort) ? Application_Model_StreamSetting::getDjLiveStreamPort() : "",
|
|
|
|
'show_source_mount' => isset($showSourceMount) ? Application_Model_StreamSetting::getDjLiveStreamMountPoint() : "",
|
|
|
|
'isDemo' => $isDemo,
|
2015-06-30 18:14:33 +02:00
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
2012-03-19 21:08:23 +01:00
|
|
|
}
|
2012-07-11 00:55:44 +02:00
|
|
|
|
2017-03-17 03:30:08 +01:00
|
|
|
|
2012-08-29 05:04:55 +02:00
|
|
|
public function isValid($data)
|
|
|
|
{
|
2017-03-17 03:30:08 +01:00
|
|
|
$isValid = parent::isValid($data);
|
2012-07-11 00:55:44 +02:00
|
|
|
|
2017-03-17 03:30:08 +01:00
|
|
|
return $isValid;
|
|
|
|
}
|
|
|
|
}
|