2012-02-06 23:51:02 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
|
|
|
|
{
|
|
|
|
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;
|
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
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$this->setDecorators([
|
|
|
|
['ViewScript', ['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
|
2021-10-11 16:10:47 +02:00
|
|
|
$auto_transition = new Zend_Form_Element_Checkbox('auto_transition');
|
|
|
|
$auto_transition->setLabel(_('Auto Switch Off:'))
|
2022-01-23 19:15:55 +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
|
2021-10-11 16:10:47 +02:00
|
|
|
$auto_switch = new Zend_Form_Element_Checkbox('auto_switch');
|
|
|
|
$auto_switch->setLabel(_('Auto Switch On:'))
|
2022-01-23 19:15:55 +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
|
2021-10-11 16:10:47 +02:00
|
|
|
$transition_fade = new Zend_Form_Element_Text('transition_fade');
|
|
|
|
$transition_fade->setLabel(_('Switch Transition Fade (s):'))
|
|
|
|
->setFilters(['StringTrim'])
|
|
|
|
->addValidator('regex', false, ['/^\d*(\.\d+)?$/',
|
|
|
|
'messages' => _('Please enter a time in seconds (eg. 0.5)'), ])
|
2022-01-23 19:15:55 +01:00
|
|
|
->setValue($defaultFade);
|
2012-03-21 03:16:17 +01:00
|
|
|
$this->addElement($transition_fade);
|
2012-07-11 00:55:44 +02:00
|
|
|
|
2022-03-14 11:15:04 +01:00
|
|
|
// Master username
|
2012-02-06 23:51:02 +01:00
|
|
|
$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:'))
|
2021-10-11 16:10:47 +02:00
|
|
|
->setFilters(['StringTrim'])
|
2022-01-23 19:15:55 +01:00
|
|
|
->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
|
|
|
|
2022-03-14 11:15:04 +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:'))
|
2022-01-23 19:15:55 +01:00
|
|
|
->setFilters(['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-17 15:09:21 +01:00
|
|
|
$masterSourceHost->setLabel(_('Master Source Host:'))
|
2017-03-14 02:15:14 +01:00
|
|
|
->setAttrib('readonly', true)
|
2022-01-23 19:15:55 +01:00
|
|
|
->setValue(Application_Model_Preference::GetMasterDJSourceConnectionURL());
|
2015-06-30 18:14:33 +02:00
|
|
|
$this->addElement($masterSourceHost);
|
|
|
|
|
2022-03-14 11:15:04 +01:00
|
|
|
// liquidsoap harbor.input port
|
2017-03-14 02:15:14 +01:00
|
|
|
$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)
|
2021-10-11 16:10:47 +02:00
|
|
|
->setValidators([$betweenValidator])
|
2022-01-23 19:15:55 +01:00
|
|
|
->addValidator('regex', false, ['pattern' => '/^[0-9]+$/', 'messages' => ['regexNotMatch' => _('Only numbers are allowed.')]]);
|
2017-03-17 03:30:08 +01:00
|
|
|
|
2021-10-11 16:10:47 +02: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)
|
2021-10-11 16:10:47 +02:00
|
|
|
->setValidators([
|
2022-01-23 19:15:55 +01:00
|
|
|
['regex', false, ['/^[^ &<>]+$/', '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-17 15:09:21 +01:00
|
|
|
$showSourceHost->setLabel(_('Show Source Host:'))
|
2017-03-14 02:15:14 +01:00
|
|
|
->setAttrib('readonly', true)
|
2022-01-23 19:15:55 +01:00
|
|
|
->setValue(Application_Model_Preference::GetLiveDJSourceConnectionURL());
|
2015-06-30 18:14:33 +02:00
|
|
|
$this->addElement($showSourceHost);
|
|
|
|
|
2022-03-14 11:15:04 +01:00
|
|
|
// liquidsoap harbor.input port
|
2017-03-14 02:15:14 +01:00
|
|
|
$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)
|
2021-10-11 16:10:47 +02:00
|
|
|
->setValidators([$betweenValidator])
|
2022-01-23 19:15:55 +01:00
|
|
|
->addValidator('regex', false, ['pattern' => '/^[0-9]+$/', 'messages' => ['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)
|
2021-10-11 16:10:47 +02:00
|
|
|
->setValidators([
|
2022-01-23 19:15:55 +01:00
|
|
|
['regex', false, ['/^[^ &<>]+$/', '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(
|
2021-10-11 16:10:47 +02:00
|
|
|
[
|
|
|
|
['ViewScript',
|
|
|
|
[
|
2017-03-17 03:30:08 +01:00
|
|
|
'viewScript' => 'form/preferences_livestream.phtml',
|
2021-10-11 16:10:47 +02:00
|
|
|
'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() : '',
|
2017-03-17 03:30:08 +01:00
|
|
|
'isDemo' => $isDemo,
|
2021-10-11 16:10:47 +02:00
|
|
|
],
|
|
|
|
],
|
|
|
|
]
|
2015-06-30 18:14:33 +02:00
|
|
|
);
|
2012-03-19 21:08:23 +01:00
|
|
|
}
|
2017-03-17 15:09:21 +01:00
|
|
|
}
|