PHP Classes

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: Initial commit for update 4.2.8

This commit focuses on functioning the market addons. Current progress was finished for:
1. Theme and module import;
2. Theme and module uninstall;
3. Theme preview (pre-install);
4. Theme changer;
5. Theme customizer;

Updating the theme and url helper that previously not working with imported theme and modules. Add the function to call the asset under theme and module. The route module (core) was added for getting the theme and module assets.

Changes on Assets controller to working with theme preview (related to base_url and asset_url configuration value).

Add the extension (intl) check (pre-install) and phpspreadsheet dependencies to scale up the app to produce the excel import and export.

Correct the installation migration that previously fail to execute (caused by invalid json format while insert the data on group privileges table "by typo"). Change the structure of app__users table and change the country field to country_id (also rewrite users and account module).

CORE
Adds the capability to using custom title and icon for each request method (create, read, update, delete etc.) that previously applied to set_desrcription() with array pair: [$method => $title] | [$method => $icon]. Correcting the missing variable called from CRUD search feature.

This commit already tested both MySQLi, PostgreSQL and SQLite3. You may help me to test to install it under SQL Server database to check if it's has no error.
Date: 9 hours ago
Size: 2,267 bytes
 

Contents

Class file image Download
<?php

if(!function_exists('asset_loader'))
{
   
/**
     * load additional css or js file
     */
   
function asset_loader($assets = array())
    {
       
$theme = null;
       
$backtrace = debug_backtrace();
       
        foreach(
$backtrace as $key => $val)
        {
            if(isset(
$val['file']) && $val['file'] == ROOTPATH . 'aksara' . DIRECTORY_SEPARATOR . 'Laboratory' . DIRECTORY_SEPARATOR . 'Core.php' && isset($val['object']->_theme))
            {
               
$theme = $val['object']->_theme;
            }
        }
       
        if(!
$theme) return false;
       
        if(!
is_array($assets))
        {
           
$assets = array_map('trim', explode(',', $assets));
        }
       
       
$output = null;
       
        foreach(
$assets as $key => $val)
        {
            if(
file_exists(ROOTPATH . 'themes' . DIRECTORY_SEPARATOR . $theme . DIRECTORY_SEPARATOR . $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;
    }
   
   
/**
     * load theme asset
     */
   
function get_theme_asset($data = null)
    {
       
$theme = false;
       
$backtrace = debug_backtrace();
       
        foreach(
$backtrace as $key => $val)
        {
            if(isset(
$val['file']) && $val['file'] == ROOTPATH . 'aksara' . DIRECTORY_SEPARATOR . 'Laboratory' . DIRECTORY_SEPARATOR . 'Core.php' && isset($val['object']->_theme) && file_exists(ROOTPATH . 'themes' . DIRECTORY_SEPARATOR . $val['object']->_theme . DIRECTORY_SEPARATOR . $data))
            {
                return
base_url('themes/' . $val['object']->_theme . '/' . $data);
            }
        }
       
        return
'#';
    }
   
   
/**
     * load module asset
     */
   
function get_module_asset($data = null, $x = false)
    {
       
$controller = service('router')->controllerName();
       
       
preg_match('/\\\Modules\\\(.*?)\\\Controllers\\\/', $controller, $matches);
       
       
$module = $matches[1];
       
        if(
$module && file_exists(ROOTPATH . 'modules' . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . $data))
        {
            return
base_url('modules/' . $module . '/assets/' . $data);
        }
       
        return
'#';
    }
}

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