/
category_lang.php
60 lines (50 loc) · 1.7 KB
/
category_lang.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php defined('SYSPATH') or die('No direct script access.');
/**
* Model for Localization of Categories
*
* PHP version 5
* LICENSE: This source file is subject to LGPL license
* that is available through the world-wide-web at the following URI:
* http://www.gnu.org/copyleft/lesser.html
* @author Ushahidi Team <team@ushahidi.com>
* @package Ushahidi - http://source.ushahididev.com
* @module Category Localization Model
* @copyright Ushahidi - http://www.ushahidi.com
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License (LGPL)
*/
class Category_Lang_Model extends ORM
{
protected $belongs_to = array('category');
protected $primary_key = 'id';
// Database table name
protected $table_name = 'category_lang';
static function category_langs($category_id=FALSE)
{
if($category_id != FALSE)
{
$category_langs = ORM::factory('category_lang')->where(array('category_id'=>$category_id))->find_all();
}else{
$category_langs = ORM::factory('category_lang')->find_all();
}
$cat_langs = array();
foreach($category_langs as $category_lang) {
$cat_langs[$category_lang->category_id][$category_lang->locale]['id'] = $category_lang->id;
$cat_langs[$category_lang->category_id][$category_lang->locale]['category_title'] = $category_lang->category_title;
}
return $cat_langs;
}
static function category_title($category_id,$locale)
{
$category_lang = ORM::factory('category_lang')
->where(array('category_id'=>$category_id,'locale'=>$locale))
->find_all();
foreach($category_lang as $cat){
if(isset($cat->category_title) AND $cat->category_title != '')
{
return $cat->category_title;
}else{
return FALSE;
}
}
}
}