/** * 模板渲染 * * @param string $template 模板文件 * @return htmlcode */ public function fetch($template = '') { $hashkey = core_debug::info('compile template: ' . $template); $html = $this->getRender()->fetch($template); core_debug::upTime($hashkey); return $html; }
public function display($params = array()) { $loadWidgetHashkey = core_debug::info('load widget: ' . get_class($this)); $params = $this->params($params); $compileWidgetHashkey = core_debug::info('compile widget: ' . $this->tpl()); $this->render->display($this->tpl()); core_debug::upTime($loadWidgetHashkey); core_debug::upTime($compileWidgetHashkey); }
public function __construct($params = array()) { if (!isset($params['cache_dir']) || !$this->getInstance()->isDir($params['cache_dir'])) { $this->savepath = core::getConfig('cache_filesystem_dir'); } else { $this->savepath = $params['cache_dir']; } core_debug::info('set filesystem dir: ' . $this->getSavePath()); }
public function __construct($params = array()) { $host = $params['host']; $port = !empty($params['port']) ? $params['port'] : 6379; if ($host != '') { core_debug::info('add redis server: ' . $host . ":" . $port); $this->getInstance()->connect($host, $port); } else { throw new Exception('can\'t load cache_redis_host, please check it.'); } }
public function __construct($params = array()) { $hosts = array(); if ($params['host'] != '') { $config = explode(',', $params['host']); foreach ($config as $v) { $v = trim($v); $tmp = explode(':', $v); $hosts[] = array($tmp[0], $tmp[1]); core_debug::info('add memcached server: ' . $v); } $this->getInstance()->addServers($hosts); } else { throw new Exception('can\'t load cache_memcache_host, please check it.'); } }
/** * 发起请求 * * @param string $url 请求地址 * @param array $method 请求方式 * @param array $params 请求参数 * @return void */ private function _request($url = '', $method = 'POST', $params = array()) { $hashkey = core_debug::info("curl {$method} request: {$url} , requesting ..."); curl_setopt($this->client, CURLOPT_CONNECTTIMEOUT, 20); curl_setopt($this->client, CURLOPT_URL, $url); curl_setopt($this->client, CURLOPT_RETURNTRANSFER, 1); curl_setopt($this->client, CURLOPT_CONNECTTIMEOUT, $this->getTimeout()); curl_setopt($this->client, CURLOPT_TIMEOUT, $this->getTimeout()); if ($method == 'POST') { curl_setopt($this->client, CURLOPT_POST, count($params)); curl_setopt($this->client, CURLOPT_POSTFIELDS, $params); } $this->response = curl_exec($this->client); curl_close($this->client); if ($this->response === false) { $debugInfo = "curl {$method} request: {$url} , timeout(" . $this->getTimeout() . " Seconds)."; } else { $debugInfo = "curl {$method} request: {$url} , ok."; } core_debug::info($debugInfo, $hashkey); return $this->response; }
/** * 设置参数信息 * * @return void */ private static function setBoot() { $pathinfo = self::instance('core_url')->getPathInfo(); $queryString = self::instance('core_router')->parse($pathinfo); $get = self::instance('core_url')->getQueryParams($queryString); $controller = $get[self::$config['mvc_controller']]; $action = $get[self::$config['mvc_action']]; if ($controller == '') { $controller = self::$config['default_controller']; } if ($action == '') { $action = self::$config['default_action']; } self::$boot[self::$config['mvc_controller']] = $controller; self::$boot[self::$config['mvc_action']] = $action; self::$boot['pathinfo'] = $pathinfo; core_debug::info('path info: ' . $pathinfo); core_debug::info('query string: ' . $queryString); }