-added simple configuration page
-implemented CC-1830 -issue CC-1850 closed
This commit is contained in:
parent
1e23907df1
commit
df675bd8c6
15 changed files with 179 additions and 9 deletions
|
@ -84,6 +84,10 @@
|
|||
<actionMethod actionName="getDataGridData"/>
|
||||
<actionMethod actionName="livestream"/>
|
||||
</controllerFile>
|
||||
<controllerFile controllerName="Preference">
|
||||
<actionMethod actionName="index"/>
|
||||
<actionMethod actionName="update"/>
|
||||
</controllerFile>
|
||||
</controllersDirectory>
|
||||
<formsDirectory>
|
||||
<formFile formName="Login"/>
|
||||
|
@ -100,10 +104,12 @@
|
|||
<formFile formName="AddShowStyle"/>
|
||||
<formFile formName="AddShowWhat"/>
|
||||
<formFile formName="AddShowRepeats"/>
|
||||
<formFile formName="Preferences"/>
|
||||
</formsDirectory>
|
||||
<layoutsDirectory enabled="false"/>
|
||||
<modelsDirectory>
|
||||
<modelFile modelName="Nowplaying"/>
|
||||
<modelFile modelName="Preference"/>
|
||||
</modelsDirectory>
|
||||
<modulesDirectory enabled="false"/>
|
||||
<viewsDirectory>
|
||||
|
@ -270,6 +276,12 @@
|
|||
<viewControllerScriptsDirectory forControllerName="Schedule">
|
||||
<viewScriptFile forActionName="showContentDialog"/>
|
||||
</viewControllerScriptsDirectory>
|
||||
<viewControllerScriptsDirectory forControllerName="Preference">
|
||||
<viewScriptFile forActionName="index"/>
|
||||
</viewControllerScriptsDirectory>
|
||||
<viewControllerScriptsDirectory forControllerName="Preference">
|
||||
<viewScriptFile forActionName="update"/>
|
||||
</viewControllerScriptsDirectory>
|
||||
</viewScriptsDirectory>
|
||||
<viewHelpersDirectory/>
|
||||
<viewFiltersDirectory enabled="false"/>
|
||||
|
@ -313,6 +325,7 @@
|
|||
<testApplicationControllerFile filesystemName="ApiControllerTest.php"/>
|
||||
<testApplicationControllerFile filesystemName="UserControllerTest.php"/>
|
||||
<testApplicationControllerFile filesystemName="NowplayingControllerTest.php"/>
|
||||
<testApplicationControllerFile filesystemName="PreferenceControllerTest.php"/>
|
||||
</testApplicationControllerDirectory>
|
||||
</testApplicationDirectory>
|
||||
<testLibraryDirectory>
|
||||
|
|
|
@ -64,9 +64,16 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
|
|||
$this->view->headScript()->appendFile('/js/playlist/playlist.js','text/javascript');
|
||||
|
||||
$view->headScript()->appendFile('/js/airtime/common/common.js','text/javascript');
|
||||
}
|
||||
|
||||
//TODO: Find better place to put this in.
|
||||
protected function _initViewHelpers(){
|
||||
$view = $this->getResource('view');
|
||||
$view->addHelperPath('../application/views/helpers', 'Airtime_View_Helper');
|
||||
}
|
||||
|
||||
protected function _initTitle(){
|
||||
$view = $this->getResource('view');
|
||||
$view->headTitle(Application_Model_Preference::GetStationName());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,8 @@ $ccAcl->add(new Zend_Acl_Resource('library'))
|
|||
->add(new Zend_Acl_Resource('schedule'))
|
||||
->add(new Zend_Acl_Resource('api'))
|
||||
->add(new Zend_Acl_Resource('nowplaying'))
|
||||
->add(new Zend_Acl_Resource('search'));
|
||||
->add(new Zend_Acl_Resource('search'))
|
||||
->add(new Zend_Acl_Resource('preference'));
|
||||
|
||||
/** Creating permissions */
|
||||
$ccAcl->allow('guest', 'index')
|
||||
|
@ -33,7 +34,8 @@ $ccAcl->allow('guest', 'index')
|
|||
->allow('host', 'playlist')
|
||||
->allow('host', 'sideplaylist')
|
||||
->allow('host', 'schedule')
|
||||
->allow('admin', 'user');
|
||||
->allow('admin', 'user')
|
||||
->allow('admin', 'preference');
|
||||
|
||||
$aclPlugin = new Zend_Controller_Plugin_Acl($ccAcl);
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ $pages = array(
|
|||
array(
|
||||
'label' => 'Preferences',
|
||||
'module' => 'default',
|
||||
'controller' => 'Nowplaying'
|
||||
'controller' => 'Preference'
|
||||
),
|
||||
array(
|
||||
'label' => 'Manage Users',
|
||||
|
|
43
application/controllers/PreferenceController.php
Normal file
43
application/controllers/PreferenceController.php
Normal file
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
class PreferenceController extends Zend_Controller_Action
|
||||
{
|
||||
|
||||
public function init()
|
||||
{
|
||||
/* Initialize action controller here */
|
||||
}
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$form = new Application_Form_Preferences();
|
||||
$this->view->form = $form;
|
||||
}
|
||||
|
||||
public function updateAction()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
if (!$this->getRequest()->isPost()) {
|
||||
return $this->_forward('Preference/index');
|
||||
}
|
||||
|
||||
$form = new Application_Form_Preferences();
|
||||
if (!$form->isValid($request->getPost())) {
|
||||
// Failed validation; redisplay form
|
||||
$this->view->form = $form;
|
||||
return $this->render('index'); //render the phtml file
|
||||
}
|
||||
|
||||
$auth = Zend_Auth::getInstance();
|
||||
$id = $auth->getIdentity()->id;
|
||||
|
||||
$values = $form->getValues();
|
||||
Application_Model_Preference::UpdateStationName($values["stationName"], $id);
|
||||
$this->view->form = $form;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
34
application/forms/Preferences.php
Normal file
34
application/forms/Preferences.php
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
class Application_Form_Preferences extends Zend_Form
|
||||
{
|
||||
|
||||
public function init()
|
||||
{
|
||||
$this->setAction('/Preference/update')->setMethod('post');
|
||||
|
||||
// Add login element
|
||||
$this->addElement('text', 'stationName', array(
|
||||
'label' => 'Station Name:',
|
||||
'required' => true,
|
||||
'filters' => array('StringTrim'),
|
||||
'validators' => array('NotEmpty')
|
||||
));
|
||||
|
||||
/*
|
||||
$this->addElement('select', 'test', array(
|
||||
'label' => 'Live Stream Button: ',
|
||||
'multiOptions' => array(
|
||||
"e" => "enabled",
|
||||
"d" => "disabled"
|
||||
))
|
||||
);
|
||||
*/
|
||||
|
||||
$this->addElement('submit', 'submit', array(
|
||||
'ignore' => true,
|
||||
'label' => 'Submit',
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>Airtime</title>
|
||||
<?php echo $this->headTitle() ?>
|
||||
<?php echo $this->headScript() ?>
|
||||
<?php echo $this->headLink() ?>
|
||||
</head>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>Airtime</title>
|
||||
<?php echo $this->headTitle() ?>
|
||||
<?php echo $this->headScript() ?>
|
||||
<?php echo $this->headLink() ?>
|
||||
</head>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>Airtime</title>
|
||||
<?php echo $this->headTitle() ?>
|
||||
<?php echo $this->headScript() ?>
|
||||
<?php echo $this->headLink() ?>
|
||||
</head>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>Airtime</title>
|
||||
<?php echo $this->headTitle() ?>
|
||||
<?php echo $this->headScript() ?>
|
||||
<?php echo $this->headLink() ?>
|
||||
</head>
|
||||
|
|
44
application/models/Preference.php
Normal file
44
application/models/Preference.php
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
class Application_Model_Preference
|
||||
{
|
||||
|
||||
public static function UpdateStationName($name, $id){
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
|
||||
//Check if key already exists
|
||||
$sql = "SELECT COUNT(*) FROM cc_pref"
|
||||
." WHERE keystr = 'station_name'";
|
||||
$result = $CC_DBC->GetOne($sql);
|
||||
|
||||
if ($result == 1){
|
||||
$sql = "UPDATE cc_pref"
|
||||
." SET subjid = $id, valstr = '$name'"
|
||||
." WHERE keystr = 'station_name'";
|
||||
} else {
|
||||
$sql = "INSERT INTO cc_pref (subjid, keystr, valstr)"
|
||||
." VALUES ($id, 'station_name', '$name')";
|
||||
}
|
||||
return $CC_DBC->query($sql);
|
||||
}
|
||||
|
||||
public static function GetStationName(){
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
//Check if key already exists
|
||||
$sql = "SELECT COUNT(*) FROM cc_pref"
|
||||
." WHERE keystr = 'station_name'";
|
||||
$result = $CC_DBC->GetOne($sql);
|
||||
|
||||
if ($result == 0)
|
||||
return "Airtime";
|
||||
else {
|
||||
$sql = "SELECT valstr FROM cc_pref"
|
||||
." WHERE keystr = 'station_name'";
|
||||
$result = $CC_DBC->GetOne($sql);
|
||||
return $result." - Airtime";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
3
application/views/scripts/preference/index.phtml
Normal file
3
application/views/scripts/preference/index.phtml
Normal file
|
@ -0,0 +1,3 @@
|
|||
<?php
|
||||
echo $this->form;
|
||||
?>
|
4
application/views/scripts/preference/update.phtml
Normal file
4
application/views/scripts/preference/update.phtml
Normal file
|
@ -0,0 +1,4 @@
|
|||
Preferences Updated.
|
||||
<?php
|
||||
echo $this->form;
|
||||
?>
|
BIN
public/css/images/schedule-show_progressbar_bg.png
Normal file
BIN
public/css/images/schedule-show_progressbar_bg.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 949 B |
20
tests/application/controllers/PreferenceControllerTest.php
Normal file
20
tests/application/controllers/PreferenceControllerTest.php
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
require_once 'PHPUnit/Framework/TestCase.php';
|
||||
|
||||
class PreferenceControllerTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
/* Setup Routine */
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
/* Tear Down Routine */
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue