-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(){
|
||||
$view = $this->getResource('view');
|
||||
$view->headTitle(Application_Model_Preference::GetStationName());
|
||||
$view->headTitle(Application_Model_Preference::GetHeadTitle());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -52,6 +52,7 @@ $pages = array(
|
|||
array(
|
||||
'label' => 'Configure',
|
||||
'uri' => 'javascript:void(null)',
|
||||
'resource' => 'preference',
|
||||
'pages' => array(
|
||||
array(
|
||||
'label' => 'Preferences',
|
||||
|
@ -67,33 +68,9 @@ $pages = array(
|
|||
)
|
||||
)
|
||||
)
|
||||
/*
|
||||
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
|
||||
$container = new Zend_Navigation($pages);
|
||||
$container->id = "nav";
|
||||
|
|
|
@ -28,11 +28,9 @@ class PreferenceController extends Zend_Controller_Action
|
|||
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);
|
||||
Application_Model_Preference::SetHeadTitle($values["stationName"], $this->view);
|
||||
|
||||
$this->view->form = $form;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,8 @@ class Application_Form_Preferences extends Zend_Form
|
|||
'label' => 'Station Name:',
|
||||
'required' => true,
|
||||
'filters' => array('StringTrim'),
|
||||
'validators' => array('NotEmpty')
|
||||
'validators' => array('NotEmpty'),
|
||||
'value' => Application_Model_Preference::GetValue("station_name")
|
||||
));
|
||||
|
||||
/*
|
||||
|
|
|
@ -3,42 +3,69 @@
|
|||
class Application_Model_Preference
|
||||
{
|
||||
|
||||
public static function UpdateStationName($name, $id){
|
||||
public static function SetValue($key, $value, $id){
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
|
||||
//Check if key already exists
|
||||
$sql = "SELECT COUNT(*) FROM cc_pref"
|
||||
." WHERE keystr = 'station_name'";
|
||||
." WHERE keystr = '$key'";
|
||||
$result = $CC_DBC->GetOne($sql);
|
||||
|
||||
if ($result == 1){
|
||||
$sql = "UPDATE cc_pref"
|
||||
." SET subjid = $id, valstr = '$name'"
|
||||
." WHERE keystr = 'station_name'";
|
||||
." SET subjid = $id, valstr = '$value'"
|
||||
." WHERE keystr = '$key'";
|
||||
} else {
|
||||
$sql = "INSERT INTO cc_pref (subjid, keystr, valstr)"
|
||||
." VALUES ($id, 'station_name', '$name')";
|
||||
." VALUES ($id, '$key', '$value')";
|
||||
}
|
||||
return $CC_DBC->query($sql);
|
||||
}
|
||||
|
||||
public static function GetStationName(){
|
||||
public static function GetValue($key){
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
//Check if key already exists
|
||||
$sql = "SELECT COUNT(*) FROM cc_pref"
|
||||
." WHERE keystr = 'station_name'";
|
||||
." WHERE keystr = '$key'";
|
||||
$result = $CC_DBC->GetOne($sql);
|
||||
|
||||
if ($result == 0)
|
||||
return "Airtime";
|
||||
else {
|
||||
$sql = "SELECT valstr FROM cc_pref"
|
||||
." WHERE keystr = 'station_name'";
|
||||
." WHERE keystr = '$key'";
|
||||
$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