Bontiv-Sourceer source code viewer
Root | Help
./bontiv-cms/core/core_functions.php
<?php

/**
 * Core function
 *
 * @version $Id$
 * @copyright 2010
 */

//Define common constant
define('COREDIR', ROOTDIR . 'core' . DIRECTORY_SEPARATOR);
define('LIBSDIR', ROOTDIR . 'libs' . DIRECTORY_SEPARATOR);
define('MODSDIR', ROOTDIR . 'modules' . DIRECTORY_SEPARATOR);
define('TMPDIR', ROOTDIR . 'tmp' . DIRECTORY_SEPARATOR);

include_once
COREDIR . 'core_exception.php';

function
__autoload($class)
{    
   
$parse = explode('_', strtolower($class));
   
$job = $parse[0];

    if (
$job == 'core')
    {
        if (
file_exists(COREDIR . $class . '.php'))
        {
            require
COREDIR . $class . '.php';
        }
        else
        {
            throw new
LibraryLoadingError('We can\'t load this core library : ' . $class);
        }
    }
    elseif (
$job == 'mod' && $class != $job)
    {
        if (
core_modules::IsLoaded($class))
        {
           
$mod = core_modules::GetDetail($class);
            require
MODSDIR . $mod['sysName'] . DIRECTORY_SEPARATOR . $class . '.php';
        }
        else
            throw new
LibraryLoadingError('Mod not found: ' . $class);
    }
    else
    {
       
core_libraries::LoadLibrary($job);
    }
}

function
LastClass()
{
   
$debug = debug_backtrace();
    return
$debug[2]['class'];
}

function
MyClass()
{
   
$debug = debug_backtrace();
    return
$debug[1]['class'];
}

function
sublib_include($class)
{
   
$lib = debug_backtrace();
   
$lib = dirname($lib[1]['args'][0]);
   
$dir = $lib . DIRECTORY_SEPARATOR . 'subinc' . DIRECTORY_SEPARATOR;
   
$class .= '.php';
    if (
file_exists($dir . $class) && is_file($dir . $class))
    {
        include
$dir . $class;
    }
    else
    {
       
trigger_error('Sub include not found ('.$dir.$class.')', E_USER_ERROR);
    }
}

function
ldate($date)
{
   
$conf = core_settings::Get('date-format');
    if (
$conf == false)
       
$conf = 'm/d/y H:i:s';

   
$time = strtotime($date);
    return
date($conf, $time);
}

function
DateToTimestamp ($date)
{
    if (
preg_match('`^([0-9]{4})-([0-9]{2})-([0-9]{2}) ([0-9]{2}):([0-9]{2}):([0-9]{2})$`', $date, $matched))
    {
        return
mktime($matched[4], $matched[5], $matched[6], $matched[2], $matched[3], $matched[1]);
    }
    else
        throw new
ArgError("This is not a date.");
   
}
?>
Presented with Bontiv-Sourceer