<?php
class Layout_model extends CI_Model {
public function getlayoutmodules($page) {
$this->db->select('l.*, m.*, lp.*');
$this->db->from('layouts l');
$this->db->join('modules m', 'm.modules_id = l.modules_id');
$this->db->join('layouts_positions lp', 'lp.layout_position_id = l.layout_position_id');
$this->db->where('l.page', $page);
$this->db->order_by('l.sort_order', 'asc');
$query = $this->db->get();
if ($query->num_rows() > 0) {
return $query->result_array();
}
return FALSE;
}
public function get_active_layouts_positions($page = NULL) {
$this->db->select('lp.layout_position_id');
$this->db->from('layouts l');
$this->db->join('layouts_positions lp', 'lp.layout_position_id = l.layout_position_id', 'LEFT');
$this->db->where('l.page', $page);
$query = $this->db->get();
if ($query->num_rows() > 0) {
return $query->result_array();
}
return FALSE;
}
public function get_non_active_layouts_positions($page = NULL) {
$data = array();
foreach ($this->get_active_layouts_positions($page) as $position) {
$this->db->where('layout_position_id !=', $position['layout_position_id']);
}
$query = $this->db->get('layouts_positions');
if ($query->num_rows() > 0) {
foreach ($query->result_array() as $result) {
$data[] = $result['position'];
}
}
return $data;
}
public function getlayoutpositions() {
$this->db->select('*');
$this->db->from('layouts_positions');
$query = $this->db->get();
if ($query->num_rows() > 0) {
return $query->result_array();
}
return FALSE;
}
}