Exemplo n.º 1
0
 /**
  * Include One File
  *
  * @param string $path File Path
  * @return boolean
  */
 public static function import($path)
 {
     $path = realpath($path);
     Hook::listen(str_replace(Config::getSoul()->APP_FULL_PATH, '', $path));
     if (!isset(self::$_require[$path])) {
         if (self::isFile($path)) {
             require $path;
             self::$_require[$path] = true;
         } else {
             self::$_require[$path] = false;
         }
     }
     return self::$_require[$path];
 }
Exemplo n.º 2
0
 /**
  * Class constructor
  *
  * Setup Memcache(d)
  *
  * @return void
  */
 public function __construct()
 {
     Hook::listen(__CLASS__);
 }
Exemplo n.º 3
0
    /**
     * Show Page Trace in Output
     *
     * @return string
     */
    public function showTrace()
    {
        if (Config::getSoul()->APP_DEBUG == false) {
            return;
        }
        $trace = $this->getTrace();
        $tpl = '
<!-- Kotori Page Trace (If you want to hide this feature, please set APP_DEBUG to false.)-->
<div id="page_trace" style="position:fixed;bottom:0;right:0;font-size:14px;width:100%;z-index: 999999;color: #000;text-align:left;font-family:\'Hiragino Sans GB\',\'Microsoft YaHei\',\'WenQuanYi Micro Hei\';">
<div id="page_trace_tab" style="display:none;background:white;margin:0;height:250px;">
<div id="page_trace_tab_tit" style="height:30px;padding: 6px 12px 0;border-bottom:1px solid #ececec;border-top:1px solid #ececec;font-size:16px">';
        foreach ($trace as $key => $value) {
            $tpl .= '<span id="page_trace_tab_tit_' . strtolower($key) . '" style="color:#000;padding-right:12px;height:30px;line-height: 30px;display:inline-block;margin-right:3px;cursor: pointer;font-weight:700">' . $key . '</span>';
        }
        $tpl .= '</div>
<div id="page_trace_tab_cont" style="overflow:auto;height:212px;padding:0;line-height:24px">';
        foreach ($trace as $key => $info) {
            $tpl .= '<div id="page_trace_tab_cont_' . strtolower($key) . '" style="display:none;">
    <ol style="padding: 0; margin:0">';
            if (is_array($info)) {
                foreach ($info as $k => $val) {
                    $val = is_array($val) ? print_r($val, true) : (is_bool($val) ? json_encode($val) : $val);
                    $val = in_array($key, array('Support')) ? $val : htmlentities($val, ENT_COMPAT, 'utf-8');
                    $tpl .= '<li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px">' . (is_numeric($k) ? '' : $k . ' : ') . $val . '</li>';
                }
            }
            $tpl .= '</ol>
    </div>';
        }
        $tpl .= '</div>
</div>
<div id="page_trace_close" style="display:none;text-align:right;height:15px;position:absolute;top:10px;right:12px;cursor: pointer;"><img style="vertical-align:top;" src="data:image/gif;base64,R0lGODlhDwAPAJEAAAAAAAMDA////wAAACH/C1hNUCBEYXRhWE1QPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS4wLWMwNjAgNjEuMTM0Nzc3LCAyMDEwLzAyLzEyLTE3OjMyOjAwICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOnhtcE1NPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvbW0vIiB4bWxuczpzdFJlZj0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL3NUeXBlL1Jlc291cmNlUmVmIyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ1M1IFdpbmRvd3MiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6MUQxMjc1MUJCQUJDMTFFMTk0OUVGRjc3QzU4RURFNkEiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6MUQxMjc1MUNCQUJDMTFFMTk0OUVGRjc3QzU4RURFNkEiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDoxRDEyNzUxOUJBQkMxMUUxOTQ5RUZGNzdDNThFREU2QSIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDoxRDEyNzUxQUJBQkMxMUUxOTQ5RUZGNzdDNThFREU2QSIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PgH//v38+/r5+Pf29fTz8vHw7+7t7Ovq6ejn5uXk4+Lh4N/e3dzb2tnY19bV1NPS0dDPzs3My8rJyMfGxcTDwsHAv769vLu6ubi3trW0s7KxsK+urayrqqmop6alpKOioaCfnp2cm5qZmJeWlZSTkpGQj46NjIuKiYiHhoWEg4KBgH9+fXx7enl4d3Z1dHNycXBvbm1sa2ppaGdmZWRjYmFgX15dXFtaWVhXVlVUU1JRUE9OTUxLSklIR0ZFRENCQUA/Pj08Ozo5ODc2NTQzMjEwLy4tLCsqKSgnJiUkIyIhIB8eHRwbGhkYFxYVFBMSERAPDg0MCwoJCAcGBQQDAgEAACH5BAAAAAAALAAAAAAPAA8AAAIdjI6JZqotoJPR1fnsgRR3C2jZl3Ai9aWZZooV+RQAOw==" /></div>
</div>
<div id="page_trace_open" style="height:30px;float:right;text-align: right;overflow:hidden;position:fixed;bottom:0;right:0;color:#000;line-height:30px;cursor:pointer;"><div style="background:#232323;color:#FFF;padding:0 6px;float:right;line-height:30px;font-size:14px">';
        $errorCount = count(Handle::$errors);
        if ($errorCount == 0) {
            $tpl .= Hook::listen('\\Kotori\\App') . 'μs';
        } else {
            $tpl .= $errorCount . ' errors';
        }
        $tpl .= '</div><img width="30" style="border-left:2px solid black;border-top:2px solid black;border-bottom:2px solid black;" title="ShowPageTrace" src="' . Helper::logo() . '"></div>
<script type="text/javascript">
(function() {
\'use strict\';
var tab_tit = document.getElementById(\'page_trace_tab_tit\').getElementsByTagName(\'span\'),
    tab_cont = document.getElementById(\'page_trace_tab_cont\').getElementsByTagName(\'div\'),
    open = document.getElementById(\'page_trace_open\'),
    close = document.getElementById(\'page_trace_close\').children[0],
    trace = document.getElementById(\'page_trace_tab\'),
    storage = localStorage.getItem(\'kotori_show_page_trace\'),
    history = (storage !== null && storage.split(\'|\')) ||  [0,0],
    bindClick = function(dom, listener) {
        if (dom.addEventListener) {
            dom.addEventListener(\'click\', listener, false);
        } else {
            dom.attachEvent(\'onclick\', listener);
        }
    };
bindClick(open, function() {
    trace.style.display = \'block\';
    this.style.display = \'none\';
    close.parentNode.style.display = \'block\';
    history[0] = 1;
    localStorage.setItem(\'kotori_show_page_trace\', history.join(\'|\'));
});
bindClick(close, function() {
    trace.style.display = \'none\';
    this.parentNode.style.display = \'none\';
    open.style.display = \'block\';
    history[0] = 0;
    localStorage.setItem(\'kotori_show_page_trace\', history.join(\'|\'));
});
for (var i = 0; i < tab_tit.length; i++) {
    bindClick(tab_tit[i], (function(i) {
        return function() {
            for (var j = 0; j < tab_cont.length; j++) {
                tab_cont[j].style.display = \'none\';
                tab_tit[j].style.color = \'#999\';
            }
            tab_cont[i].style.display = \'block\';
            tab_tit[i].style.color = \'#000\';
            history[1] = i;
            localStorage.setItem(\'kotori_show_page_trace\', history.join(\'|\'));
        };
    })(i));
}
parseInt(history[0]) && open.click();
tab_tit[history[1]].click();
})();
</script>';
        return $tpl;
    }
Exemplo n.º 4
0
 /**
  * Class constructor
  *
  * Initialize Build Class.
  *
  * @return void
  */
 public function __construct($appPath)
 {
     $this->_appPath = $appPath;
     $this->startBuild();
     Hook::listen(__CLASS__);
 }
Exemplo n.º 5
0
 /**
  * Class constructor
  *
  * Initialize view and database classes.
  *
  * @return void
  */
 public function __construct()
 {
     $this->view = new View();
     $this->response = Response::getSoul();
     $this->request = Request::getSoul();
     $this->route = Route::getSoul();
     $this->db = $this->db();
     $this->model = ModelProvider::getSoul();
     $this->config = Config::getSoul();
     $this->cache = Cache::getSoul();
     Hook::listen(__CLASS__);
 }
Exemplo n.º 6
0
 /**
  * Class constructor
  *
  * Initialize Database.
  *
  * @return void
  */
 public function __construct($options = null)
 {
     parent::__construct($options);
     Hook::listen(__CLASS__);
 }
Exemplo n.º 7
0
 /**
  * Class constructor
  *
  * Setup Memcache(d)
  *
  * @return void
  */
 public function __construct()
 {
     // Try to load memcached server info from the config file.
     $defaults = $this->_memcacheConf['default'];
     $config = Config::getSoul()->CACHE;
     $memcacheConf = isset($config['MEMCACHED']) ? $config['MEMCACHED'] : null;
     if (is_array($memcacheConf)) {
         $this->_memcacheConf = array();
         foreach ($memcacheConf as $name => $conf) {
             $this->_memcacheConf[$name] = $conf;
         }
     }
     if (class_exists('Memcached', false)) {
         $this->_memcached = new \Memcached();
     } elseif (class_exists('Memcache', false)) {
         $this->_memcached = new \Memcache();
     } else {
         Log::normal('[Error] Failed to create Memcache(d) object; extension not loaded?');
     }
     foreach ($this->_memcacheConf as $cacheServer) {
         isset($cacheServer['HOST']) or $cacheServer['HOST'] = $defaults['HOST'];
         isset($cacheServer['PORT']) or $cacheServer['PORT'] = $defaults['PORT'];
         isset($cacheServer['WEIGHT']) or $cacheServer['WEIGHT'] = $defaults['WEIGHT'];
         if (get_class($this->_memcached) === 'Memcache') {
             // Third parameter is persistance and defaults to TRUE.
             $this->_memcached->addServer($cacheServer['HOST'], $cacheServer['PORT'], true, $cacheServer['WEIGHT']);
         } else {
             $this->_memcached->addServer($cacheServer['HOST'], $cacheServer['PORT'], $cacheServer['WEIGHT']);
         }
     }
     Hook::listen(__CLASS__);
 }
Exemplo n.º 8
0
 /**
  * Class constructor
  *
  * Initialize Response.
  *
  * @return void
  */
 public function __construct()
 {
     Hook::listen(__CLASS__);
     $this->setCharset('UTF-8');
 }
Exemplo n.º 9
0
 /**
  * Class constructor
  *
  * Initialize route class.
  *
  * @return void
  */
 public function __construct()
 {
     if (Request::getSoul()->isCli()) {
         $this->_uri = $this->parseArgv();
     } else {
         if (isset($_GET['_i'])) {
             $_SERVER['PATH_INFO'] = $_GET['_i'];
         }
         $_SERVER['PATH_INFO'] = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : (isset($_SERVER['ORIG_PATH_INFO']) ? $_SERVER['ORIG_PATH_INFO'] : (isset($_SERVER['REDIRECT_PATH_INFO']) ? $_SERVER['REDIRECT_PATH_INFO'] : ''));
         $this->_uri = $_SERVER['PATH_INFO'];
     }
     if (substr($this->_uri, 0, 1) == '/') {
         $this->_uri = ltrim($this->_uri, '/');
     }
     if (trim($this->_uri, '/') == '') {
         $this->_uri = '/';
     }
     Hook::listen(__CLASS__);
 }
Exemplo n.º 10
0
 /**
  * Class constructor
  * 
  * @param string $tplDir Template Directory
  * @return void
  */
 public function __construct($tplDir = null)
 {
     if (null == $tplDir) {
         $this->_tplDir = Config::getSoul()->APP_FULL_PATH . '/views/';
     } else {
         $this->_tplDir = $tplDir;
     }
     Hook::listen(__CLASS__);
 }
Exemplo n.º 11
0
 /**
  * Constructor
  *
  * Initialize class properties based on the configuration array.
  *
  * @return void
  */
 public function __construct()
 {
     $config = Config::getSoul()->CACHE;
     isset($config['ADAPTER']) && ($this->_adapter = $config['ADAPTER']);
     isset($config['PREFIX']) && ($this->keyPrefix = $config['PREFIX']);
     $className = '\\Kotori\\Core\\Cache\\' . ucfirst($this->_adapter);
     $this->{$this->_adapter} = new $className();
     if (!$this->isSupported($this->_adapter)) {
         Log::normal('[Error] Cache adapter "' . $this->_adapter . '" is unavailable. Cache is now using "Dummy" adapter.');
         $this->_adapter = 'dummy';
     }
     Hook::listen(__CLASS__);
 }