Language ID rework

This commit is contained in:
Deon George
2012-07-30 15:10:58 +10:00
parent 5697e7985b
commit 7b0e87d28c
12 changed files with 51 additions and 13 deletions

View File

@@ -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

View File

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

View File

@@ -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
*/

View File

@@ -0,0 +1,16 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* OSB Language Model
*
* @package OSB
* @subpackage Modules
* @category Models
* @author Deon George
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Model_Language extends ORMOSB {
protected $_form = array('id'=>'id','value'=>'name');
}
?>

View File

@@ -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() {

View File

@@ -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;