/** * 架构方法 设置参数 * * @access public * @param array $config * 配置参数 */ public function __construct($config = array()) { $this->config = array_merge($this->config, $config); $app = Application::getApp(); $appConfig = $app->getAppConfig(); $this->config['fontttf'] = $appConfig->get('mvc_static_path') . DIRECTORY_SEPARATOR . 'fonts' . DIRECTORY_SEPARATOR . 'rcode.ttf'; }
/** * 构造方法 * * @param string $tplName * 模板名,不需要后面的.tpl.php,子路径以/隔开 * @param string $mimeType * mime类型,默认值为text/html; charset=utf-8 */ public function __construct($tplName, $mimeType = 'text/html; charset=utf-8') { $app = Application::getApp(); $appConfig = $app->getAppConfig(); $this->tplBaspath = $appConfig->get('tpl_path'); $this->errHandler = $app->getErrHandler(); $this->setTplName($tplName); $this->mimeType = $mimeType; $this->openC = true; $tplData = array('public_context' => $appConfig->get('app_pub_context')); $this->tplData = new DataMap($tplData); }
public function __construct() { $app = Application::getApp(); $appConfig = $app->getAppConfig(); $tablePre = $appConfig->get('table_pre', 'pv2ex'); $dbType = $appConfig->get('db_type', 'mysql'); $this->app = $app; $this->appConfig = $appConfig; $this->tablePre = $tablePre; if ($dbType == 'redis') { $this->dbType = self::DB_REDIS; } else { $this->dbType = self::DB_MYSQL; } }
public function __construct(array $config) { $bucketName = $config['bucketName']; $app = Application::getApp(); $appConfig = $app->getAppConfig(); $this->fsContext = $appConfig->get('app_pub_context') . '/fs/' . $bucketName; $this->fsBasepath = $appConfig->get('app_pub_path') . DIRECTORY_SEPARATOR . 'fs' . DIRECTORY_SEPARATOR; if (DIRECTORY_SEPARATOR == '/') { $this->fsBasepath .= $bucketName; } else { $this->fsBasepath .= str_replace('/', DIRECTORY_SEPARATOR, $bucketName); } if (!is_dir($this->fsBasepath)) { mkdir($this->fsBasepath, 0777, true); } }
/** * 获取压缩类型 * * @return int 0表示不压缩,1表示gzip,2表示deflate */ public static function getCompressType() { if (!isset(self::$openCompress)) { $app = Application::getApp(); $appConfig = $app->getAppConfig(); self::$openCompress = $appConfig->get('tpl_compress'); } if (!self::$openCompress) { return 0; } if (!extension_loaded('zlib')) { return 0; } // if (!isset($_SERVER['HTTP_ACCEPT_ENCODING'])) { return 0; } if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false) { return 2; } elseif (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') !== false) { return 1; } else { return 0; } }
public function indexAction() { $app = Application::getApp(); $errHandler = $app->getErrHandler(); $errHandler->handle(404, '很抱歉,您要访问的页面不存在!'); }
<?php use liuguang\mvc\Application; define('APP_PATH', dirname(__FILE__)); define('APP_DEBUG', TRUE); include '../mvc/core.php'; Application::init();