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

[eluser]Avatar[/eluser]
This is my current eviron.php file located inside app/libraries/ I will place it on the wiki once it deserves to be up there and is nicely working.
Code:
<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');
/*

ENVIRON VARIABLES LIBRARY for ME & Smarty Template System
by
Aleksandr Ilyich Goretoy aka RussianPimp YingYes

This class is very early beta and will be rigourously tested and modified
You are allowed to use this code as you wish as long as this sig stays here. Please don't delete it.
Currently works for loading templates from file system and db(kinda buggy) Send me bugfixes in ci forum.
*/
class Environ {
    var $template_name;
    var $templates_folder;
    var $template;
    var $template_root;
    var $template_dir;
    var $_environ=array();
    var $theme=array();
    var $data=array();
    function __construct()
    {
        $this->ci =& get_instance();
        $this->ci->load->helper('url');
        define('ENVIRONMENT_VERSION', '1.0.4');
        log_message('debug', "Environment Class Initialized : Environ " . ENVIRONMENT_VERSION);
        $this->init();

        

    }
    function init($environ=array())
    {    
        // Load the required files for this lib to
        // work correctly.
        $this->ci->load->model('environ_model');
        $this->ci->load->model('template_model');
        $this->ci->config->load('environ');
        
        //get environment variables from config file
        $this->document_path = $_SERVER['DOCUMENT_ROOT'].$this->ci->config->item('base_dir').APPPATH.'views/';
        $this->template_name = $this->ci->config->item('template_name');
        $this->templates_folder=$this->ci->config->item('templates_folder');
        $this->theme_config_file=$this->ci->config->item('theme_config_file');
        $this->template_location = $this->ci->config->item('template_location');
        $this->_set_template();
        if(strtolower($this->template_location)=='file')
        {
            /*this line loads the config file located inside the template directory
            app/views/smarty/templates/$template_name/config/$theme_config_file
            */
            $this->ci->load->config('../views/'.$this->template.'config/'.$this->theme_config_file,true,true);
            $this->_theme_config($this->ci->config->item('../views/'.$this->template.'config/'.$this->theme_config_file));
            
        }
        else
        {
            $this->template_id = $this->ci->template_model->get_config_item_value('template_id');
            $this->template_name = $this->ci->template_model->get_config_item_value('template_name');
        }
        $this->_template_asset_dirs($this->template_location);
        
        $this->_template_theme('css',$this->template_location);
        $this->_template_theme('js',$this->template_location);
    
        $this->_template($this->template_location,'layout');
        $this->_templify_array($this->data['template_layout'],'layout');
        
        $this->_template($this->template_location,'admin');
        $this->_templify_array($this->data['template_admin'],'admin');    
                
        $this->_template($this->template_location,'pages');                  
        $this->_templify_array($this->data['template_pages'],'pages');
    }
    function _templify_array($array,$string='layout')
    {
        if(is_array($array))
        {
            foreach($array as $key=>$val)
            {
                $path=preg_split('/\//',$val);
                if($val!='index')
                {
                    if(isset($path[1]))
                    {
                        if(file_exists($this->template_root.$path[0].'/tpl_'.$path[1].EXT))
                        if($this->ci->smarty_parser->template_exists('ci:'.$this->template.$path[0].'/tpl_'.$path[1].EXT))
                        {
                        $this->data['template_'.$string][$path[0].'_'.$path[1].'_tpl']='ci:'.$this->template.$path[0].'/tpl_'.$path[1].EXT;
                        }
                    
                        if(file_exists($this->template_root.$string.'/tpl_'.$val.EXT))
                        if($this->ci->smarty_parser->template_exists('ci:'.$this->template.$string.'/tpl_'.$val.EXT))
                        {
                            $this->data['template_'.$string][$val.'_tpl']='ci:'.$this->template.$string.'/tpl_'.$val.EXT;
                        }
                        
                    }
                    else
                    {
                        if(file_exists($this->template_root.'tpl_'.$val.EXT))
                        if($this->ci->smarty_parser->template_exists('ci:'.$this->template.'tpl_'.$val.EXT))
                        {
                            $this->data['template_'.$string][$val.'_tpl']='ci:'.$this->template.'tpl_'.$val.EXT;
                        }
                        
                        if(file_exists($this->template_root.$string.'/tpl_'.$val.EXT))
                        if($this->ci->smarty_parser->template_exists('ci:'.$this->template.$string.'/tpl_'.$val.EXT))
                        {
                            $this->data['template_'.$string][$val.'_tpl']='ci:'.$this->template.$string.'/tpl_'.$val.EXT;
                        }
                        
                    }
                    
                }
            }
            
        }
    }
cut and paste these 3 sections.


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