Ejemplo n.º 1
0
 /**
  * Get loader
  * 
  * @return Core_Loader
  */
 public static function getInstance()
 {
     if (null === self::$_singleton) {
         self::$_singleton = new self();
     }
     return self::$_singleton;
 }
Ejemplo n.º 2
0
 /**
  * 渲染视图
  * @param  [type] $tpl    视图路径(相对views)
  * @param  [type] $data   视图数据
  * @param  [type] $retstr 是否返回字符串
  * @return [type]         [description]
  */
 private function _render($tpl, $data, $retstr)
 {
     // 获取模板文件
     $tplFile = Core_Loader::getInstance()->getFile($tpl, VIEW_DIR);
     if (!$tplFile) {
         throw new Exception_Base("view not found - {$tpl}");
     }
     // 加载视图数据
     if (is_array($this->tplData) && count($this->tplData)) {
         extract($this->tplData);
     }
     // 如果$data中有$tplData的同名数据,覆盖之
     if (is_array($data) && count($data)) {
         extract($data, EXTR_OVERWRITE);
     }
     // 渲染开始,打开output buffer
     ob_start();
     // 使用include可以多次渲染同一视图
     include $tplFile;
     if ($retstr) {
         // 返回视图内容,关闭output buffer
         $buffer = ob_get_contents();
         @ob_end_clean();
         return $buffer;
     }
     // 输出视图,关闭output buffer
     ob_end_flush();
 }
Ejemplo n.º 3
0
 public static function registerPrefix($prefixKey, $basePath)
 {
     if (!self::$_isRegistered) {
         spl_autoload_register(array(__CLASS__, 'autoload'));
         self::$_isRegistered = true;
     }
     self::$_prefixData[$prefixKey] = $basePath;
 }
Ejemplo n.º 4
0
 /**
  * Initialize autoloader
  * 
  * @return Core_Loader
  */
 protected function _initAutoloader()
 {
     // Load and start loader
     require_once CORE_PATH . '/loader.php';
     Core_Loader::registerAsAutoloader();
     $autoloader = Core_Loader::getInstance();
     // Add APP_NAMESPACE to namespaces and attach the base path
     $autoloader->setNamespacePath(APP_NAMESPACE, APP_PATH);
     return $autoloader;
 }
Ejemplo n.º 5
0
 private static function _load($file)
 {
     $fileList = Core_Loader::getInstance()->getFile($file . PHP_EXT, CONFIG_DIR, true);
     if (empty($fileList)) {
         throw new Exception_Base("config file not found - {$file}");
     }
     $fileList = array_reverse($fileList);
     $config = array();
     foreach ($fileList as $f) {
         $c = (include $f);
         // 让后面覆盖前面的同名配置
         $config = Tool_Array::merge($config, $c);
     }
     self::$_config[$file] = $config;
 }
Ejemplo n.º 6
0
<?php

/*
 * This is an example of Sijax usage showing how easy it is
 * to make a tagging system with suggestions support.
 */
/**
 * We need to load Sijax classes, either manually or using Core_Loader.
 * The code below simply loads the Core_Loader class
 * and registers autoloading for classes prefixed with `Core_`.
 */
$corePath = dirname(dirname(dirname(__FILE__))) . '/';
require $corePath . 'Loader/Core_Loader.php';
Core_Loader::registerPrefix('Core', $corePath);
class SuggestHandler
{
    private function _getSuggestions($keyword)
    {
        $suggestionsArray = array();
        for ($i = 0; $i < 10; ++$i) {
            $suggestion = array();
            $name = $keyword . ' ' . $i;
            $suggestion['display'] = $name;
            $suggestion['selectResponse'] = "selectTag(" . json_encode($name) . ");";
            $suggestionsArray[] = $suggestion;
        }
        return $suggestionsArray;
    }
    public function suggestTags(Core_Sijax_Plugin_Suggest_Response $objResponse, array $params)
    {
        //Clear debug information container
Ejemplo n.º 7
0
<?php

/**
 * 框架入口文件
 * @author  hitzheng
 */
// 常量定义
define('SYSTEM_VERSION', '1.0.0');
define('SYSTEM_START_TIME', microtime(true));
define('CODE_SUCCESS', 1000);
define('CODE_FAILED', 1001);
define('CODE_PARAM_ERROR', 1002);
define('CODE_NEED_LOGIN', 1003);
// 自动加载
require SYS_PATH . '/library/core/loader.php';
spl_autoload_register(array(Core_Loader::getInstance(), 'loadClass'));
// 异常处理
Core_Exception::getInstance()->init();
Ejemplo n.º 8
0
/**
 * 单例加载
 *
 * @param string $className
 * @return object
 */
function S($className)
{
    return Core_Loader::getSingleton($className);
}
Ejemplo n.º 9
0
 /**
  * Setup URL parser
  * 
  * @return Core_HTTP_Url
  */
 protected function _initUrlParser()
 {
     Core_Loader::load('Core_HTTP_Url');
     $urlParser = Core_HTTP_Url::load();
     return $urlParser;
 }
 public function __construct()
 {
     parent::__construct();
 }
Ejemplo n.º 11
0
Archivo: CMS.php Proyecto: techart/tao
 protected static function configure_loader()
 {
     Core::load('Core.Loader');
     $base_path = self::$app_path;
     if (self::$enable_dev_components) {
         $base_path = str_replace('app', '(dev|app)', $base_path);
     }
     Core::loader(Core_Loader::extended())->paths(array('---Component.{name}.App' => $base_path . '/components/{name}/app(/lib)?', '-Component.{name}' => array($base_path . '/components(/{name}/lib)?', $base_path . '/components/{name}(/lib)?'), '--Component.{name}' => $base_path . '/components/{name}/lib'));
 }