Файл: system/classes/Core.php
Строк: 103
<?php
/**
 * Licensed under The MIT License
 * For full copyright and license information, please see the LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright (c) 2013, Taras Chornyi, Sergiy Mazurenko, Ivan Kotliar
 * @link          http://perf-engine.net
 * @package       PerfEngine
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
 */
class Core
{
    public static function moduleId()
    {
        $route = (isset($_GET['route']) ? input($_GET['route']) : null);
        $string = explode('/', $route);
        if(isset($string[0]) && $string[0] !== '/' && file_exists(ROOT.'/modules/'.$string[0]))
        {
            return $string[0];
        }
        else
        {
            return false;
        }
    }
    
    public static function pageId()
    {
        $route = (isset($_GET['route']) ? input($_GET['route']) : null);
        $string = explode('/', $route);
        if(isset($string[1]) && file_exists(ROOT.'/modules/'.$string[0].'/'.$string[1].'.php'))
        {
            return $string[1];
        }
        else
        {
            return false;
        }
    }
    
    public static function config($string = null)
    {
        $config = parse_ini_file(SYS.'/ini/core.ini');
        if($string === null)
        {
            return $config;
        }
        else
        {
            return $config[$string];
        }
    }
    
    public static function language()
    {
        if(User::logged())
        {
            return User::settings('lang');
        }
        else
        {
            $languages = scandir(SYS.'/lang');
            $acceptLanguage = (isset($_COOKIE['language']) ? input($_COOKIE['language']) : substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2));
            if(in_array($acceptLanguage, $languages))
            {
                return $acceptLanguage;
            }
            else
            {
                return self::config('lang');
            }
        }
    }
    
    public static function typeTheme()
    {
        if (isset($_COOKIE['TypeTheme'])) {
        return input($_COOKIE['TypeTheme']);
        } else {
        return browser_type();
        }
    }
    
    public static function themePath()
    {
        
        if(User::logged())
        {
            $path = TPL.'/themes/'.Core::TypeTheme().'/'.User::settings((Core::TypeTheme() == 'web' ? 'web_' : null).'theme');
        }
        else//if(!User::logged())
        {
            $path = TPL.'/themes/'.Core::TypeTheme().'/'.self::config((Core::TypeTheme() == 'web' ? 'web_' : null).'theme');
        }
        
        return $path;
    }
    
    public static function themeUrl()
    {
        
        if(User::logged())
        {
            $url = URL.'/template/themes/'.Core::TypeTheme().'/'.User::settings((Core::TypeTheme() == 'web' ? 'web_' : null).'theme');
        }
        else//if(!User::logged())
        {
            $url = URL.'/template/themes/'.Core::TypeTheme().'/'.self::config((Core::TypeTheme() == 'web' ? 'web_' : null).'theme');
        }
        return $url;
    }
}