diff --git a/application/classes/config.php b/application/classes/config.php index 0ed1fe2e..a306333b 100644 --- a/application/classes/config.php +++ b/application/classes/config.php @@ -13,7 +13,7 @@ class Config extends lnApp_Config { // Our setup object public $so; - public static $no_site_id_tables = array('setup','country','currency','tax'); + public static $no_site_id_tables = array('setup','country','currency','language','tax'); /** * Load our site configuration from the DB diff --git a/application/classes/lnapp/controller/templatedefault.php b/application/classes/lnapp/controller/templatedefault.php index 1c6f419d..c4a9afa8 100644 --- a/application/classes/lnapp/controller/templatedefault.php +++ b/application/classes/lnapp/controller/templatedefault.php @@ -162,7 +162,7 @@ abstract class lnApp_Controller_TemplateDefault extends Controller_Template { $this->template->title = ''; // Language - $this->meta->language = Config::instance()->so->language_id; + $this->meta->language = Config::instance()->so->language->iso; // Description $this->meta->description = sprintf('%s::%s',$this->request->controller(),$this->request->action()); diff --git a/application/classes/model/account.php b/application/classes/model/account.php index be59abe0..3ebea21b 100644 --- a/application/classes/model/account.php +++ b/application/classes/model/account.php @@ -20,6 +20,7 @@ class Model_Account extends Model_Auth_UserDefault { ); protected $_has_one = array( 'affiliate' => array('far_key'=>'id'), + 'language'=>array('foreign_key'=>'id','far_key'=>'language_id'), ); protected $_display_filters = array( @@ -60,11 +61,6 @@ class Model_Account extends Model_Auth_UserDefault { return StaticList_Module::form($name,'country',$this->country_id,'id','name',array('active'=>'=:1'),FALSE,array('class'=>'form_button')); } - public function language($name) { - // @todo To setup - return 'en'; - } - /** * Get the groups that an account belongs to */ diff --git a/application/classes/model/language.php b/application/classes/model/language.php new file mode 100644 index 00000000..ae88714f --- /dev/null +++ b/application/classes/model/language.php @@ -0,0 +1,16 @@ +'id','value'=>'name'); +} +?> diff --git a/application/classes/model/setup.php b/application/classes/model/setup.php index 9f4830dd..a20cc812 100644 --- a/application/classes/model/setup.php +++ b/application/classes/model/setup.php @@ -19,6 +19,7 @@ class Model_Setup extends ORMOSB { protected $_has_one = array( 'country'=>array('foreign_key'=>'id','far_key'=>'country_id'), + 'language'=>array('foreign_key'=>'id','far_key'=>'language_id'), ); public function rules() { diff --git a/application/classes/ormosb.php b/application/classes/ormosb.php index 223ba7eb..d9adf721 100644 --- a/application/classes/ormosb.php +++ b/application/classes/ormosb.php @@ -22,6 +22,9 @@ abstract class ORMOSB extends ORM { // Our attribute values that need to be stored as serialized protected $_serialize_column = array(); + // Our attributes used in forms. + protected $_form = array(); + public function rules() { return array( 'id'=>array( @@ -60,6 +63,10 @@ abstract class ORMOSB extends ORM { } } + final public static function form($table,$blank=FALSE) { + return ORM::factory($table)->formselect($blank); + } + /** * Get Next record id * @@ -146,6 +153,18 @@ abstract class ORMOSB extends ORM { return parent::__get($column); } + public function formselect($blank) { + $result = array(); + + if ($blank) + $result[] = ''; + + foreach ($this->find_all() as $o) + $result[$o->{$this->_form['id']}] = $o->{$this->_form['value']}; + + return $result; + } + public function keyget($column,$key=NULL) { if (is_null($key) OR ! is_array($this->$column)) return $this->$column; diff --git a/application/views/account/user/edit.php b/application/views/account/user/edit.php index 16a09632..e24c6f9b 100644 --- a/application/views/account/user/edit.php +++ b/application/views/account/user/edit.php @@ -65,7 +65,7 @@