- <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
- /**
- * CodeIgniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author ExpressionEngine Dev Team
- * @copyright Copyright (c) 2006, EllisLab, Inc.
- * @license http://codeigniter.com/user_guide/license.html
- * @link http://codeigniter.com
- * @since Version 1.0
- * @filesource
- */
- // ------------------------------------------------------------------------
- /**
- * CodeIgniter User Authentication Model
- *
- * This Model provides CodeIgniter with a simple
- * and flexible user authnetication
- *
- * @package CodeIgniter
- * @subpackage Model
- * @category Model
- * @author Mathew Davies
- * @link
- */
- class Template_Model extends Model
- {
- var $query_count=0;
- function __construct()
- {
- parent::Model();
- }
- function clear_count()
- {
- $this->query_count=0;
- }
- function get_count()
- {
- return $this->query_count;
- }
- function get($table)
- {
- return $this->db->get($table);
- }
- function get_where($table,$array)
- {
- return $this->db->get_where($table,$array);
- }
- function select($array='*')
- {
- if(is_array($array))
- {
- $string=implode(',',$array);
- }
- else
- {
- $string=$array;
- }
- $this->db->select($string);
- }
- function set($data, $name = '' )
- {
- if ( empty($name) && is_array($data) )
- {
- $this->db->set($data);
- }
- else
- {
- $this->db->set($name, $data);
- }
- }
- function insert ($table)
- {
- $this->db->insert($table);
- if ( $this->db->affected_rows() > 0 )
- {
- return true;
- }
- return false;
- }
- function get_page_by_template_id_and_url($template_id,$url)
- {
- if(!empty($template_id))
- {
- $this->query_count++;
- return $this->db->query("select * from `pages` where `template`='".$template_id."' and `url`='".$url."' order by `orderby` ASC");
- }
- return false;
- }
- function get_pages_by_template_id($template_id)
- {
- if(!empty($template_id))
- {
- $this->query_count++;
- return $this->db->query("select * from `pages` where `template`='".$template_id."' order by `orderby` ASC");
- }
- return false;
- }
- function get_admin_layout_by_template_id($template_id)
- {
- if(!empty($template_id))
- {
- $this->query_count++;
- return $this->db->query("select * from `admin_layout` where `template`='".$template_id."'");
- }
- return false;
- }
- function get_admin_pages_by_template_id($template_id)
- {
- if(!empty($template_id))
- {
- $this->query_count++;
- return $this->db->query("select * from `admin_pages` where `template`='".$template_id."'");
- }
- return false;
- }
- function get_layout_by_template_id($template_id)
- {
- if(!empty($template_id))
- {
- $this->query_count++;
- return $this->db->query("select * from `layout` where `template`='".$template_id."'");
- }
- return false;
- }
- function get_sections_by_template_id($template_id)
- {
- if(!empty($template_id))
- {
- $this->query_count++;
- return $this->db->query("select * from `sections` where `template`='".$template_id."'");
- }
- return false;
- }
- function get_theme_css($template_id)
- {
- if(!empty($template_id))
- {
- $this->query_count++;
- return $this->db->query("select * from `css` where `template`='".$template_id."'");
- }
- return false;
- }
- function get_theme_js($template_id)
- {
- if(!empty($template_id))
- {
- $this->query_count++;
- return $this->db->query("select * from `js` where `template`='".$template_id."'");
- }
- return false;
- }
- function get_asset_dirs_by_template_id($template_id)
- {
- if(!empty($template_id))
- {
- $this->query_count++;
- return $this->db->query("select * from `templates` where `id`='".$template_id."'");
- }
- return false;
- }
- function left_join_by_template_id($t_id)
- {
- if(!empty($name))
- {
- $this->query_count++;
- $q=$this->db->query("SELECT templates.name, templates.images_dir, templates.swf_dir, templates.pdf_dir,
- layout.name,layout.url
- FROM templates
- LEFT JOIN layout
- ON templates.id=layout.template_id
- WHERE templates.id='".$t_id."'");
- return $q->row()->id;
- }
- return false;
- }
- function get_config_item_value($item_name)
- {
- if(!empty($item_name))
- {
- $this->query_count++;
- $this->db->select('value');
- $q=$this->db->get_where('site_config',array('name'=>$item_name));
- //$q=$this->db->query("select `value` from `site_config` where `name`='".$item_name."'");
- return $q->row()->value;
- }
- return false;
- }
- function get_template_id_by_name($name)
- {
- if(!empty($name))
- {
- $this->query_count++;
- $q=$this->db->query("select `id` from `templates` where `name`='".$name."'");
- return ($q->num_rows()!=0)?$q->row()->id:false;
- }
- return false;
- }
- }
- ?>
