Blame view

modules/default/model/actions.class.php 1.26 KB
8d65d0ce   andryeyev   init
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
  <?php
  Class Actions{
   private $db;
   private $lang;
  
   function __construct($lang){
    $this->db = sdb::getInstance();
    $this->lang = $lang;
   }
   
  
   public function getActions($param = array()){
    $search = array();
    $sql = "select *,title_{$this->lang} as title,text_{$this->lang} as text from news where 1=1 and actio=1 ";
    if(count($search))$sql .= "AND " . implode(" AND ",$search)." ";
    $sql .= "order by date desc";
    $pagerOptions = Array(
      'mode' => 'Sliding',
      'delta' => 6,
      'perPage' => 10,
      'spacesBeforeSeparator' => 1,
      'spacesAfterSeparator' => 1
    );
    return Pager_Wrapper_DB($this->db, $sql, $pagerOptions, false, DB_FETCHMODE_ASSOC, array());
   }
   
   public function getLastNews($limit = 3){
    $sql = "select *,title_{$this->lang} as title,text_{$this->lang} as text from news order by date desc limit $limit";
    return $this->db->getAll($sql,array(),DB_FETCHMODE_ASSOC);
   }
   
   public function view($id){
    $sql = "select *,title_{$this->lang} as title,meta_title_{$this->lang} as meta_title,meta_description_{$this->lang} as meta_description,meta_keywords_{$this->lang} as meta_keywords,meta_about_{$this->lang} as meta_about,text_{$this->lang} as text from news where id=? limit 1";
    return $this->db->getRow($sql,array($id),DB_FETCHMODE_ASSOC);
   }
   
  }
  ?>