コード例 #1
0
 /**
  * 构造函数
  */
 public function __construct($configName)
 {
     $configPath = CODE_PATH . '/configs/' . $configName . '.php';
     if (!file_exists($configPath)) {
         echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>[部署错误]主配置文件不存在!';
         exit;
     }
     $this->configName = $configName;
     $this->thisConfigData = CLoader::import($configName, $configPath);
 }
コード例 #2
0
 /**
  * 加载插件
  */
 public static function loadPlugin()
 {
     $loadPlugin = CConfig::getInstance()->load('LOAD_PLUGIN');
     $loadList = CConfig::getInstance()->load('LOAD_LIST');
     if (false === $loadPlugin) {
         return false;
     }
     $pluginPath = APP_PATH . '/plugins/';
     $confPath = CConfig::getInstance()->load('PLUGIN_PATH');
     if (null != $confPath) {
         $pluginPath = APP_PATH . '/' . trim($confPath) . '/';
     }
     //定义插件宏
     define('CPLUGIN_PATH', $pluginPath);
     $hooksFile = self::_getPathFile($pluginPath, $loadList);
     foreach ($hooksFile as $val) {
         $pluginRegisterFilePath = $pluginPath . $val . '/' . $val . '.php';
         if (!file_exists($pluginRegisterFilePath)) {
             self::$_failLoadPluginList[] = array('pluginName' => $val);
             continue;
         }
         CLoader::importFile($pluginRegisterFilePath);
         $thisPluginObject = new $val();
         $thisPluginReflection = new ReflectionClass($thisPluginObject);
         $isSubCPlugin = $thisPluginReflection->isSubclassOf('CPlugin');
         if (false == $isSubCPlugin) {
             self::$_failLoadPluginList[] = $val;
             continue;
         }
         $thisPluginObject->setHooks();
         $thisPluginData['pluginName'] = isset($thisPluginObject->pluginName) ? $thisPluginObject->pluginName : '';
         $thisPluginData['author'] = isset($thisPluginObject->author) ? $thisPluginObject->author : '';
         $thisPluginData['version'] = isset($thisPluginObject->version) ? $thisPluginObject->version : '';
         $thisPluginData['copyright'] = isset($thisPluginObject->copyright) ? $thisPluginObject->copyright : '';
         $thisPluginData['date'] = isset($thisPluginObject->date) ? $thisPluginObject->date : '';
         $thisPluginData['description'] = isset($thisPluginObject->description) ? $thisPluginObject->description : '';
         self::$_pluginList[] = $thisPluginData;
     }
 }
コード例 #3
0
 /**
  * 自动加载
  */
 private function classAutoLoad($className)
 {
     $loadStatus = CLoader::getInstance()->load($className);
 }
コード例 #4
0
 /**
  * 构造
  */
 public function __construct($viewName)
 {
     $this->_viewName = $viewName;
     $viewConfigs = CConfig::getInstance()->load('TEMPLATE');
     if (!isset($viewConfigs[$viewName])) {
         trigger_error('[视图错误]使用配置中不存在的模板引擎:' . $viewName, E_USER_ERROR);
     }
     $thisViewConfig = $viewConfigs[$viewName];
     $templatePath = isset($thisViewConfig['TEMPLATE_PATH']) ? $thisViewConfig['TEMPLATE_PATH'] : '';
     $viewConfItem = isset($thisViewConfig['CONF_INFO']) ? $thisViewConfig['CONF_INFO'] : array();
     if (!file_exists($templatePath)) {
         trigger_error('[视图错误]未能找到指定模板引擎[' . $viewName . ']的主文件:' . $templatePath, E_USER_ERROR);
     }
     CLoader::importFile($templatePath);
     $viewObject = new $viewName();
     if ('smarty' == $viewName) {
         $viewObject->template_dir = $viewConfItem['template_dir'];
         //编译目录
         $compile_dir = $viewConfItem['compile_dir'];
         if (!is_dir($compile_dir)) {
             if (false == mkdir($compile_dir, true, 0755)) {
                 echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>[部署错误]CMyFrame无法创建缓存目录,请确定服务器权限';
                 exit;
             }
             chmod($compile_dir, 0777);
         }
         $viewObject->compile_dir = $compile_dir;
         //缓存目录
         $cache_dir = $viewConfItem['cache_dir'];
         if (!is_dir($cache_dir)) {
             if (false == mkdir($cache_dir, true, 0755)) {
                 echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>[部署错误]CMyFrame无法创建缓存目录,请确定服务器权限';
                 exit;
             }
             chmod($cache_dir, 0777);
         }
         $viewObject->cache_dir = $cache_dir;
         //分隔符
         $viewObject->left_delimiter = $viewConfItem['left_delimiter'];
         $viewObject->right_delimiter = $viewConfItem['right_delimiter'];
         //使用PHP语法
         $viewObject->allow_php_tag = $viewConfItem['allow_php_tag'];
         //缓冲
         $viewObject->caching = $viewConfItem['caching'];
         $viewObject->cache_lifetime = $viewConfItem['cache_lifetime'];
         //注册函数
         $viewObject->register_function('url', array('CRequest', 'createUrl'));
         $viewObject->register_function('PageInfo', array('CSmarty', 'showPageData'));
         $viewObject->register_function('substr', array('CSmarty', 'cn_substr'));
         $viewObject->register_function('sayTime', array('CSmarty', 'sayTime'));
         //注册块函数
         $viewObject->register_block('checkRight', array('CSmarty', 'checkRight'));
         //设置默认数据
         CSmarty::setInitData($viewObject);
     } else {
         //设置所有配置项
         foreach ((array) $viewConfItem as $key => $val) {
             $viewObject->{$key} = $val;
         }
     }
     //第一次获取视图时
     CHooks::callHooks(HOOKS_VIEW_GET, $viewObject);
     $this->_viewObject = $viewObject;
 }
コード例 #5
0
ファイル: php-minify.php プロジェクト: kandy/HamsterCMF
<?php

if (!isset($_SERVER['argv'][1])) {
    echo 'Usage: php scripts/php-minify.php class.list', PHP_EOL;
    die;
}
$rootPath = dirname(__FILE__) . '/..';
set_include_path(implode(PATH_SEPARATOR, array(realpath($rootPath . '/library'), get_include_path())));
$loader = new CLoader();
$loader->process($_SERVER['argv'][1]);
class CLoader
{
    protected $classes = array();
    protected $outputFile = 'full.php';
    public function process($fileName)
    {
        if (!file_exists($fileName)) {
            die('Error: ' . $fileName . " do not exists" . PHP_EOL);
        }
        file_put_contents($this->outputFile, "<?php \n", LOCK_EX);
        foreach (file($fileName) as $name) {
            $loader->loadClass($name);
        }
    }
    public function loadClass($name)
    {
        $namePart = explode('_', trim($name));
        if (in_array($name, $this->classes)) {
            return;
        }
        if (in_array($namePart[0], array('Zend', 'System'))) {
コード例 #6
0
 /**
  * 类映射
  */
 private function _setDefaultMapp()
 {
     self::$_loadMapp = array('CConfig' => FRAME_PATH . '/boot/CConfig.php', 'CException' => FRAME_PATH . '/exception/CException.php', 'CRouteException' => FRAME_PATH . '/exception/CRouteException.php', 'CDbException' => FRAME_PATH . '/exception/CDbException.php', 'CClassNotFoundException' => FRAME_PATH . '/exception/CClassNotFoundException.php', 'CModelExcetpion' => FRAME_PATH . '/exception/CModelExcetpion.php', 'CPluginException' => FRAME_PATH . '/exception/CPluginException.php', 'CViewException' => FRAME_PATH . '/exception/CViewException.php', 'CacheException' => FRAME_PATH . '/exception/CacheException.php', 'CSessionCookieException' => FRAME_PATH . '/exception/CSessionCookieException.php', 'CRequest' => FRAME_PATH . '/request/CRequest.php', 'CUrl' => FRAME_PATH . '/request/CUrl.php', 'CRoute' => FRAME_PATH . '/request/CRoute.php', 'CRouteParse' => FRAME_PATH . '/components/CRouteParse.php', 'CController' => FRAME_PATH . '/components/CController.php', 'CTypeCheck' => FRAME_PATH . '/components/CTypeCheck.php', 'Cache' => FRAME_PATH . '/cache/Cache.php', 'CMemcache' => FRAME_PATH . '/cache/CMemcache.php', 'CFilecache' => FRAME_PATH . '/cache/CFilecache.php', 'CacheItem' => FRAME_PATH . '/cache/CacheItem.php', 'CDBError' => FRAME_PATH . '/database/CDbError.php', 'CSession' => FRAME_PATH . '/components/CSession.php', 'CCookie' => FRAME_PATH . '/components/CCookie.php', 'CEncrypt' => FRAME_PATH . '/components/CEncrypt.php', 'CHash' => FRAME_PATH . '/components/CHash.php', 'CRedis' => FRAME_PATH . '/components/CRedis.php', 'CHttp' => FRAME_PATH . '/components/CHttp.php', 'CDiContainer' => FRAME_PATH . '/components/CDiContainer.php', 'CDatabase' => FRAME_PATH . '/database/CDatabase.php', 'CBuilder' => FRAME_PATH . '/database/CBuilder.php', 'CResult' => FRAME_PATH . '/database/CResult.php', 'CExec' => FRAME_PATH . '/database/CExec.php', 'CActiveRecord' => FRAME_PATH . '/database/CActiveRecord.php', 'CModel' => FRAME_PATH . '/database/CModel.php', 'CEmptyModel' => FRAME_PATH . '/database/CEmptyModel.php', 'CHooks' => FRAME_PATH . '/plugin/CHooks.php', 'CPlugin' => FRAME_PATH . '/plugin/CPlugin.php', 'CArraySort' => FRAME_PATH . '/components/CArraySort.php', 'CView' => FRAME_PATH . '/view/CView.php', 'CResponse' => FRAME_PATH . '/response/CResponse.php', 'CLog' => FRAME_PATH . '/components/CLog.php');
 }