Welcome Guest, Not a member yet? Register   Sign In
Modulated Templated CMS system
#16

[eluser]Avatar[/eluser]
this is my templates_model.php located inside app/models/
Code:
<?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://ellislab.com/codeigniter/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_pages_by_id($template_id)
    {
        if(!empty($template_id))
        {    
            $this->query_count++;
            return $this->db->query("select * from `pages` where `template`='".$template_id."'");
        }
        return false;
    }
    function get_pages_by_name($template_name)
    {
        if(!empty($template_name))
        {    
            $template_id= $this->get_template_id_by_name($template_name);
            if($template_id!=false)
            {
                $this->query_count++;
                return $this->db->query("select * from `pages` where `template`='".$template_id."'");
            }
            else
            {
                return false;
            }
        }
        return false;
    }
    function get_layout_by_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_layout_by_name($template_name)
    {
        if(!empty($template_name))
        {    
            $template_id= $this->get_template_id_by_name($template_name);
            if($template_id!=false)
            {
                $this->query_count++;
                return $this->db->query("select * from `layout` where `template`='".$template_id."'");
            }
            else
            {
                return false;
            }
        }
        return false;
    }
    function get_sections_by_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_id($template_id)
    {
        if(!empty($template_id))
        {    
            $this->query_count++;
            return $this->db->query("select * from `templates` where `id`='".$template_id."'");
        }
        return false;
    }
    function get_asset_dirs_by_name($template_name)
    {
        if(!empty($template_name))
        {    
            $this->query_count++;
            return $this->db->query("select * from `templates` where `name`='".$template_name."'");
        }
        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++;
            $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;
    }
    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;
    }
    
}


Messages In This Thread
Modulated Templated CMS system - by El Forum - 03-05-2008, 12:02 PM
Modulated Templated CMS system - by El Forum - 03-05-2008, 12:08 PM
Modulated Templated CMS system - by El Forum - 03-05-2008, 12:15 PM
Modulated Templated CMS system - by El Forum - 03-05-2008, 12:18 PM
Modulated Templated CMS system - by El Forum - 03-05-2008, 01:03 PM
Modulated Templated CMS system - by El Forum - 03-06-2008, 11:46 PM
Modulated Templated CMS system - by El Forum - 03-07-2008, 01:41 AM
Modulated Templated CMS system - by El Forum - 03-07-2008, 03:59 AM
Modulated Templated CMS system - by El Forum - 03-16-2008, 10:07 AM
Modulated Templated CMS system - by El Forum - 03-16-2008, 05:51 PM
Modulated Templated CMS system - by El Forum - 03-16-2008, 07:05 PM
Modulated Templated CMS system - by El Forum - 03-16-2008, 08:02 PM
Modulated Templated CMS system - by El Forum - 03-17-2008, 03:36 AM
Modulated Templated CMS system - by El Forum - 03-17-2008, 03:38 AM
Modulated Templated CMS system - by El Forum - 03-17-2008, 03:39 AM
Modulated Templated CMS system - by El Forum - 03-17-2008, 03:52 AM
Modulated Templated CMS system - by El Forum - 03-17-2008, 04:26 AM
Modulated Templated CMS system - by El Forum - 03-17-2008, 04:29 AM
Modulated Templated CMS system - by El Forum - 03-17-2008, 04:35 AM
Modulated Templated CMS system - by El Forum - 03-17-2008, 04:41 AM
Modulated Templated CMS system - by El Forum - 03-17-2008, 04:46 AM
Modulated Templated CMS system - by El Forum - 03-17-2008, 04:53 AM
Modulated Templated CMS system - by El Forum - 03-17-2008, 10:38 AM
Modulated Templated CMS system - by El Forum - 03-17-2008, 10:45 AM
Modulated Templated CMS system - by El Forum - 03-17-2008, 10:52 AM
Modulated Templated CMS system - by El Forum - 03-17-2008, 07:01 PM
Modulated Templated CMS system - by El Forum - 05-11-2008, 12:06 PM
Modulated Templated CMS system - by El Forum - 06-12-2008, 08:41 PM
Modulated Templated CMS system - by El Forum - 07-24-2009, 03:32 PM



Theme © iAndrew 2016 - Forum software by © MyBB