Index: trunk/kernel/units/languages/languages_item.php =================================================================== diff -u -N -r4758 -r6093 --- trunk/kernel/units/languages/languages_item.php (.../languages_item.php) (revision 4758) +++ trunk/kernel/units/languages/languages_item.php (.../languages_item.php) (revision 6093) @@ -1,27 +1,27 @@ IDField.') FROM '.$this->Application->GetLiveName($this->TableName); return $this->Conn->GetOne($sql) + 1; } - + function setPrimary($reset_primary = true) { if ($reset_primary) { $sql = 'UPDATE '.$this->TableName.' SET PrimaryLang = 0'; $this->Conn->Query($sql); } - + $sql = 'UPDATE '.$this->TableName.' SET PrimaryLang = 1, Enabled = 1 WHERE '.$this->IDField.' = '.$this->GetID(); - $this->Conn->Query($sql); + $this->Conn->Query($sql); } - + /** * Allows to format number according to regional settings * @@ -33,6 +33,32 @@ { return number_format($number, $precision, $this->GetDBField('DecimalPoint'), $this->GetDBField('ThousandSep')); } + + function Load($id, $id_field_name=null) + { + $default = false; + if ($id == 'default') { + $id = 1; + $id_field_name = 'PrimaryLang'; + $default = true; + } + + $res = parent::Load($id, $id_field_name); + + if ($default) { + if (!$res) { + if ($this->Application->IsAdmin()) { + $res = parent::Load(1); + } + else { + $this->Application->ApplicationDie('No Primary Language Selected'); + } + } + $this->Application->SetVar('lang.current_id', $this->GetID() ); + $this->Application->SetVar('m_lang', $this->GetID() ); + } + return $res; + } } ?> \ No newline at end of file