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;
|
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(
|
|
|
|
array('ViewScript', array('viewScript' => 'form/preferences_livestream.phtml')),
|
|
|
|
));
|
|
|
|
|
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:"))
|
|
|
|
->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:"))
|
|
|
|
->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):"))
|
2012-03-21 03:16:17 +01:00
|
|
|
->setFilters(array('StringTrim'))
|
2015-01-26 23:49:58 +01:00
|
|
|
->addValidator('regex', false, array('/^\d*(\.\d+)?$/',
|
2015-01-26 23:41:10 +01:00
|
|
|
'messages' => _('Please enter a time in seconds (eg. 0.5)')))
|
2015-06-30 18:14:33 +02:00
|
|
|
->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')
|
2012-02-08 06:04:19 +01:00
|
|
|
->setAllowEmpty(true)
|
2015-06-30 18:14:33 +02:00
|
|
|
->setLabel(_('Username:'))
|
2012-02-06 23:51:02 +01:00
|
|
|
->setFilters(array('StringTrim'))
|
2015-06-30 18:14:33 +02: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
|
|
|
|
2012-02-06 23:51:02 +01:00
|
|
|
//Master password
|
2012-08-29 05:04:55 +02:00
|
|
|
if ($isDemo) {
|
2012-06-05 18:18:59 +02:00
|
|
|
$master_password = new Zend_Form_Element_Text('master_password');
|
2012-08-29 05:04:55 +02:00
|
|
|
} else {
|
2012-06-05 18:18:59 +02:00
|
|
|
$master_password = new Zend_Form_Element_Password('master_password');
|
|
|
|
$master_password->setAttrib('renderPassword','true');
|
|
|
|
}
|
2012-02-21 23:58:05 +01:00
|
|
|
$master_password->setAttrib('autocomplete', 'off')
|
2012-02-08 06:04:19 +01:00
|
|
|
->setAttrib('renderPassword','true')
|
|
|
|
->setAllowEmpty(true)
|
2012-10-17 21:16:03 +02:00
|
|
|
->setValue(Application_Model_Preference::GetLiveStreamMasterPassword())
|
2015-06-30 18:14:33 +02:00
|
|
|
->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');
|
|
|
|
$masterSourceHost->setAttrib('readonly', true)
|
|
|
|
->setLabel(_('Host:'))
|
|
|
|
->setValue(isset($masterSourceParams["host"])?$masterSourceParams["host"]:"");
|
|
|
|
$this->addElement($masterSourceHost);
|
|
|
|
|
|
|
|
$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:'))
|
2015-07-07 21:55:35 +02:00
|
|
|
->setValue(isset($showSourceParams["path"])?$showSourceParams["path"]:"");
|
2015-06-30 18:14:33 +02:00
|
|
|
$this->addElement($showSourceMount);
|
2012-07-11 00:55:44 +02:00
|
|
|
|
2012-06-05 18:18:59 +02:00
|
|
|
// demo only code
|
2015-07-03 19:32:41 +02:00
|
|
|
if ($isDemo) {
|
2012-06-05 18:18:59 +02:00
|
|
|
$elements = $this->getElements();
|
2012-08-29 05:04:55 +02:00
|
|
|
foreach ($elements as $element) {
|
|
|
|
if ($element->getType() != 'Zend_Form_Element_Hidden') {
|
2012-06-05 18:18:59 +02:00
|
|
|
$element->setAttrib("disabled", "disabled");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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(
|
|
|
|
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"]:"",
|
2015-07-07 21:55:35 +02:00
|
|
|
'master_source_mount' => isset($masterSourceParams["path"])?$masterSourceParams["path"]:"",
|
2015-06-30 18:14:33 +02:00
|
|
|
'show_source_host' => isset($showSourceParams["host"])?$showSourceParams["host"]:"",
|
|
|
|
'show_source_port' => isset($showSourceParams["port"])?$showSourceParams["port"]:"",
|
2015-07-07 21:55:35 +02:00
|
|
|
'show_source_mount' => isset($showSourceParams["path"])?$showSourceParams["path"]:"",
|
2015-06-30 18:14:33 +02:00
|
|
|
'isDemo' => $isDemo,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
2012-03-19 21:08:23 +01:00
|
|
|
}
|
2012-07-11 00:55:44 +02:00
|
|
|
|
2012-08-29 05:04:55 +02:00
|
|
|
public function isValid($data)
|
|
|
|
{
|
2015-06-30 18:14:33 +02:00
|
|
|
return parent::isValid($data);
|
2012-03-22 21:21:23 +01:00
|
|
|
}
|
2012-07-11 00:55:44 +02:00
|
|
|
|
2012-05-19 01:08:50 +02:00
|
|
|
}
|