File: aksara/Helpers/theme_helper.php

Recommend this page to a friend!
  Classes of Aby Dahana  >  Aksara  >  aksara/Helpers/theme_helper.php  >  Download  
File: aksara/Helpers/theme_helper.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Aksara
A CodeIgniter based API and CRUD generator
Author: By
Last change: Update theme_helper.php

Correct the regex pattern both windows and UNIX.
Date: 2 months ago
Size: 1,096 bytes
 

Contents

Class file image Download
<?php

if(!function_exists('asset_loader'))
{
   
/**
     * load additional css file
     */
   
function asset_loader($data = array())
    {
       
$backtrace = debug_backtrace();
       
$pattern = ('/' == DIRECTORY_SEPARATOR ? '/\/themes\/(.*?)\//' : '/\\\themes\\\(.*?)\\\/');
       
$theme = preg_match($pattern, (isset($backtrace[0]['file']) ? $backtrace[0]['file'] : null), $matched);
       
$theme = (isset($matched[1]) ? $matched[1] : null);
       
        if(!
$theme) return false;
       
        if(!
is_array($data))
        {
           
$data = array_map('trim', explode(',', $data));
        }
       
       
$output = null;
       
        foreach(
$data as $key => $val)
        {
            if(
file_exists('../themes/' . $theme . '/' . $val))
            {
                if(
'css' == strtolower(pathinfo($val, PATHINFO_EXTENSION)))
                {
                   
$output .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"" . base_url('themes/' . $theme . '/' . $val) . "\" />\n";
                }
                else
                {
                   
$output .= "<script type=\"text/javascript\" src=\"" . base_url('themes/' . $theme . '/' . $val) . "\"></script>\n";
                }
            }
        }
       
        return
$output;
    }
}


For more information send a message to info at phpclasses dot org.