-title now stored in session variable.

This commit is contained in:
mkonecny 2011-02-03 19:17:52 -05:00
parent df675bd8c6
commit 4698e963c1
6 changed files with 63 additions and 60 deletions

View file

@ -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());
}
}