Language ID rework
This commit is contained in:
parent
5697e7985b
commit
7b0e87d28c
@ -13,7 +13,7 @@
|
|||||||
class Config extends lnApp_Config {
|
class Config extends lnApp_Config {
|
||||||
// Our setup object
|
// Our setup object
|
||||||
public $so;
|
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
|
* Load our site configuration from the DB
|
||||||
|
@ -162,7 +162,7 @@ abstract class lnApp_Controller_TemplateDefault extends Controller_Template {
|
|||||||
$this->template->title = '';
|
$this->template->title = '';
|
||||||
|
|
||||||
// Language
|
// Language
|
||||||
$this->meta->language = Config::instance()->so->language_id;
|
$this->meta->language = Config::instance()->so->language->iso;
|
||||||
|
|
||||||
// Description
|
// Description
|
||||||
$this->meta->description = sprintf('%s::%s',$this->request->controller(),$this->request->action());
|
$this->meta->description = sprintf('%s::%s',$this->request->controller(),$this->request->action());
|
||||||
|
@ -20,6 +20,7 @@ class Model_Account extends Model_Auth_UserDefault {
|
|||||||
);
|
);
|
||||||
protected $_has_one = array(
|
protected $_has_one = array(
|
||||||
'affiliate' => array('far_key'=>'id'),
|
'affiliate' => array('far_key'=>'id'),
|
||||||
|
'language'=>array('foreign_key'=>'id','far_key'=>'language_id'),
|
||||||
);
|
);
|
||||||
|
|
||||||
protected $_display_filters = array(
|
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'));
|
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
|
* Get the groups that an account belongs to
|
||||||
*/
|
*/
|
||||||
|
16
application/classes/model/language.php
Normal file
16
application/classes/model/language.php
Normal 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');
|
||||||
|
}
|
||||||
|
?>
|
@ -19,6 +19,7 @@ class Model_Setup extends ORMOSB {
|
|||||||
|
|
||||||
protected $_has_one = array(
|
protected $_has_one = array(
|
||||||
'country'=>array('foreign_key'=>'id','far_key'=>'country_id'),
|
'country'=>array('foreign_key'=>'id','far_key'=>'country_id'),
|
||||||
|
'language'=>array('foreign_key'=>'id','far_key'=>'language_id'),
|
||||||
);
|
);
|
||||||
|
|
||||||
public function rules() {
|
public function rules() {
|
||||||
|
@ -22,6 +22,9 @@ abstract class ORMOSB extends ORM {
|
|||||||
// Our attribute values that need to be stored as serialized
|
// Our attribute values that need to be stored as serialized
|
||||||
protected $_serialize_column = array();
|
protected $_serialize_column = array();
|
||||||
|
|
||||||
|
// Our attributes used in forms.
|
||||||
|
protected $_form = array();
|
||||||
|
|
||||||
public function rules() {
|
public function rules() {
|
||||||
return array(
|
return array(
|
||||||
'id'=>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
|
* Get Next record id
|
||||||
*
|
*
|
||||||
@ -146,6 +153,18 @@ abstract class ORMOSB extends ORM {
|
|||||||
return parent::__get($column);
|
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) {
|
public function keyget($column,$key=NULL) {
|
||||||
if (is_null($key) OR ! is_array($this->$column))
|
if (is_null($key) OR ! is_array($this->$column))
|
||||||
return $this->$column;
|
return $this->$column;
|
||||||
|
@ -65,7 +65,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="head">Language</td>
|
<td class="head">Language</td>
|
||||||
<td><?php echo $record->language('language_id'); ?></td>
|
<td><?php echo $record->language->display('name'); ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="head">Currency</td>
|
<td class="head">Currency</td>
|
||||||
|
@ -15,7 +15,8 @@ class Email_Template {
|
|||||||
private $template;
|
private $template;
|
||||||
private $etto;
|
private $etto;
|
||||||
private $email_data = array();
|
private $email_data = array();
|
||||||
private $default_lang = 'en';
|
// @todo Default lang should be the site setup
|
||||||
|
private $default_lang = 1;
|
||||||
private $components = array('subject','message_text','message_html');
|
private $components = array('subject','message_text','message_html');
|
||||||
|
|
||||||
public function __construct($template,$language_id=NULL) {
|
public function __construct($template,$language_id=NULL) {
|
||||||
|
@ -22,7 +22,12 @@ class Model_Product_Category extends ORMOSB {
|
|||||||
);
|
);
|
||||||
|
|
||||||
public function description() {
|
public function description() {
|
||||||
return ($a=$this->product_category_translate->where('language_id','=','en')->find()->description) ? $a : 'No Description';
|
// If the user is not logged in, show the site default language
|
||||||
|
// @todo This needs to change to the session language.
|
||||||
|
if (! $ao=Auth::instance()->get_user())
|
||||||
|
$ao=Config::instance()->so;
|
||||||
|
|
||||||
|
return ($a=$this->product_category_translate->where('language_id','=',$ao->language_id)->find()->description) ? $a : _('No Description');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function list_active() {
|
public function list_active() {
|
||||||
|
@ -48,7 +48,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Product Descriptions</td>
|
<td>Product Descriptions</td>
|
||||||
<td><?php echo Form::select('language_id',array('','EN'=>'EN')); ?></td>
|
<td><?php echo Form::select('language_id',ORMOSB::form('language',TRUE)); ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td> </td>
|
<td> </td>
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
// If there isnt a translated page, show the default language
|
// If there isnt a translated page, show the default language
|
||||||
// @todo - default language should come from configuration
|
// @todo - default language should come from configuration
|
||||||
if (! $translate->loaded())
|
if (! $translate->loaded())
|
||||||
$translate = $record->product_translate->where('product_id','=',$record->id)->and_where('language_id','=','en')->find();
|
$translate = $record->product_translate->where('product_id','=',$record->id)->and_where('language_id','=',1)->find();
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="table_background">
|
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="table_background">
|
||||||
|
@ -10,7 +10,7 @@ $translate = $record->product_translate->where('product_id','=',$record->id)->an
|
|||||||
// If there isnt a translated page, show the default language
|
// If there isnt a translated page, show the default language
|
||||||
// @todo - default language should come from configuration
|
// @todo - default language should come from configuration
|
||||||
if (! $translate->loaded())
|
if (! $translate->loaded())
|
||||||
$translate = $record->product_translate->where('product_id','=',$record->id)->and_where('language_id','=','en')->find();
|
$translate = $record->product_translate->where('product_id','=',$record->id)->and_where('language_id','=',1)->find();
|
||||||
|
|
||||||
// @todo Need to add in product attributes
|
// @todo Need to add in product attributes
|
||||||
// @todo Need to add in product plugins
|
// @todo Need to add in product plugins
|
||||||
|
Reference in New Issue
Block a user