-title now stored in session variable.
This commit is contained in:
parent
df675bd8c6
commit
4698e963c1
6 changed files with 63 additions and 60 deletions
|
@ -73,7 +73,7 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
|
||||||
|
|
||||||
protected function _initTitle(){
|
protected function _initTitle(){
|
||||||
$view = $this->getResource('view');
|
$view = $this->getResource('view');
|
||||||
$view->headTitle(Application_Model_Preference::GetStationName());
|
$view->headTitle(Application_Model_Preference::GetHeadTitle());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ $ccAcl->allow('guest', 'index')
|
||||||
->allow('guest', 'api')
|
->allow('guest', 'api')
|
||||||
->allow('host', 'plupload')
|
->allow('host', 'plupload')
|
||||||
->allow('host', 'playlist')
|
->allow('host', 'playlist')
|
||||||
->allow('host', 'sideplaylist')
|
->allow('host', 'sideplaylist')
|
||||||
->allow('host', 'schedule')
|
->allow('host', 'schedule')
|
||||||
->allow('admin', 'user')
|
->allow('admin', 'user')
|
||||||
->allow('admin', 'preference');
|
->allow('admin', 'preference');
|
||||||
|
|
|
@ -49,50 +49,27 @@ $pages = array(
|
||||||
'action' => 'plupload',
|
'action' => 'plupload',
|
||||||
'resource' => 'plupload'
|
'resource' => 'plupload'
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'label' => 'Configure',
|
'label' => 'Configure',
|
||||||
'uri' => 'javascript:void(null)',
|
'uri' => 'javascript:void(null)',
|
||||||
'pages' => array(
|
'resource' => 'preference',
|
||||||
array(
|
'pages' => array(
|
||||||
'label' => 'Preferences',
|
array(
|
||||||
'module' => 'default',
|
'label' => 'Preferences',
|
||||||
'controller' => 'Preference'
|
'module' => 'default',
|
||||||
),
|
'controller' => 'Preference'
|
||||||
array(
|
),
|
||||||
'label' => 'Manage Users',
|
array(
|
||||||
'module' => 'default',
|
'label' => 'Manage Users',
|
||||||
'controller' => 'user',
|
'module' => 'default',
|
||||||
'action' => 'add-user',
|
'controller' => 'user',
|
||||||
'resource' => 'user'
|
'action' => 'add-user',
|
||||||
)
|
'resource' => 'user'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
/*
|
)
|
||||||
array(
|
|
||||||
'label' => 'Media Library',
|
|
||||||
'module' => 'default',
|
|
||||||
'controller' => 'Library',
|
|
||||||
'action' => 'index',
|
|
||||||
'resource' => 'library',
|
|
||||||
'pages' => array(
|
|
||||||
array(
|
|
||||||
'label' => 'Add Audio',
|
|
||||||
'module' => 'default',
|
|
||||||
'controller' => 'Plupload',
|
|
||||||
'action' => 'plupload',
|
|
||||||
'resource' => 'plupload'
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'label' => 'Search (not working right now)',
|
|
||||||
'module' => 'default',
|
|
||||||
'controller' => 'Search',
|
|
||||||
'action' => 'index',
|
|
||||||
'resource' => 'search'
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
*/
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
// Create container from array
|
// Create container from array
|
||||||
$container = new Zend_Navigation($pages);
|
$container = new Zend_Navigation($pages);
|
||||||
|
|
|
@ -27,12 +27,10 @@ class PreferenceController extends Zend_Controller_Action
|
||||||
$this->view->form = $form;
|
$this->view->form = $form;
|
||||||
return $this->render('index'); //render the phtml file
|
return $this->render('index'); //render the phtml file
|
||||||
}
|
}
|
||||||
|
|
||||||
$auth = Zend_Auth::getInstance();
|
|
||||||
$id = $auth->getIdentity()->id;
|
|
||||||
|
|
||||||
$values = $form->getValues();
|
$values = $form->getValues();
|
||||||
Application_Model_Preference::UpdateStationName($values["stationName"], $id);
|
Application_Model_Preference::SetHeadTitle($values["stationName"], $this->view);
|
||||||
|
|
||||||
$this->view->form = $form;
|
$this->view->form = $form;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,8 @@ class Application_Form_Preferences extends Zend_Form
|
||||||
'label' => 'Station Name:',
|
'label' => 'Station Name:',
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'filters' => array('StringTrim'),
|
'filters' => array('StringTrim'),
|
||||||
'validators' => array('NotEmpty')
|
'validators' => array('NotEmpty'),
|
||||||
|
'value' => Application_Model_Preference::GetValue("station_name")
|
||||||
));
|
));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -3,42 +3,69 @@
|
||||||
class Application_Model_Preference
|
class Application_Model_Preference
|
||||||
{
|
{
|
||||||
|
|
||||||
public static function UpdateStationName($name, $id){
|
public static function SetValue($key, $value, $id){
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG, $CC_DBC;
|
||||||
|
|
||||||
//Check if key already exists
|
//Check if key already exists
|
||||||
$sql = "SELECT COUNT(*) FROM cc_pref"
|
$sql = "SELECT COUNT(*) FROM cc_pref"
|
||||||
." WHERE keystr = 'station_name'";
|
." WHERE keystr = '$key'";
|
||||||
$result = $CC_DBC->GetOne($sql);
|
$result = $CC_DBC->GetOne($sql);
|
||||||
|
|
||||||
if ($result == 1){
|
if ($result == 1){
|
||||||
$sql = "UPDATE cc_pref"
|
$sql = "UPDATE cc_pref"
|
||||||
." SET subjid = $id, valstr = '$name'"
|
." SET subjid = $id, valstr = '$value'"
|
||||||
." WHERE keystr = 'station_name'";
|
." WHERE keystr = '$key'";
|
||||||
} else {
|
} else {
|
||||||
$sql = "INSERT INTO cc_pref (subjid, keystr, valstr)"
|
$sql = "INSERT INTO cc_pref (subjid, keystr, valstr)"
|
||||||
." VALUES ($id, 'station_name', '$name')";
|
." VALUES ($id, '$key', '$value')";
|
||||||
}
|
}
|
||||||
return $CC_DBC->query($sql);
|
return $CC_DBC->query($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function GetStationName(){
|
public static function GetValue($key){
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG, $CC_DBC;
|
||||||
//Check if key already exists
|
//Check if key already exists
|
||||||
$sql = "SELECT COUNT(*) FROM cc_pref"
|
$sql = "SELECT COUNT(*) FROM cc_pref"
|
||||||
." WHERE keystr = 'station_name'";
|
." WHERE keystr = '$key'";
|
||||||
$result = $CC_DBC->GetOne($sql);
|
$result = $CC_DBC->GetOne($sql);
|
||||||
|
|
||||||
if ($result == 0)
|
if ($result == 0)
|
||||||
return "Airtime";
|
return "Airtime";
|
||||||
else {
|
else {
|
||||||
$sql = "SELECT valstr FROM cc_pref"
|
$sql = "SELECT valstr FROM cc_pref"
|
||||||
." WHERE keystr = 'station_name'";
|
." WHERE keystr = '$key'";
|
||||||
$result = $CC_DBC->GetOne($sql);
|
$result = $CC_DBC->GetOne($sql);
|
||||||
return $result." - Airtime";
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function GetHeadTitle(){
|
||||||
|
/* Caches the title name as a session variable so we dont access
|
||||||
|
* the database on every page load. */
|
||||||
|
$defaultNamespace = new Zend_Session_Namespace('title_name');
|
||||||
|
if (isset($defaultNamespace->title)) {
|
||||||
|
$title = $defaultNamespace->title;
|
||||||
|
} else {
|
||||||
|
$title = Application_Model_Preference::GetValue("station_name");
|
||||||
|
$defaultNamespace->title = $title;
|
||||||
|
}
|
||||||
|
return $title." - Airtime";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function SetHeadTitle($title, $view){
|
||||||
|
$auth = Zend_Auth::getInstance();
|
||||||
|
$id = $auth->getIdentity()->id;
|
||||||
|
|
||||||
|
Application_Model_Preference::SetValue("station_name", $title, $id);
|
||||||
|
$defaultNamespace = new Zend_Session_Namespace('title_name');
|
||||||
|
$defaultNamespace->title = $title;
|
||||||
|
|
||||||
|
//set session variable to new station name so that html title is updated.
|
||||||
|
//should probably do this in a view helper to keep this controller as minimal as possible.
|
||||||
|
$view->headTitle()->exchangeArray(array()); //clear headTitle ArrayObject
|
||||||
|
$view->headTitle(Application_Model_Preference::GetHeadTitle());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue