/** * * 为 supplier 系统设置运行环境 * * @return bool */ private function doSupplierAction() { global $f3; global $smarty; // 获取当前插件的根地址 $currentThemeBasePath = dirname(__FILE__); // supplier 目录加入到 auto load 的路径中,这样系统就能自动做 class 加载 SystemHelper::addAutoloadPath($currentThemeBasePath . '/supplier/Code', true); // 设置路由,这样用户就能访问到我们的程序了 $f3->config($currentThemeBasePath . '/supplier/route.cfg'); // 注册 Asset 模块 \Core\Asset\ManagerHelper::registerModule(SupplierThemePlugin::pluginGetUniqueId(), $this->pluginGetVersion(), $currentThemeBasePath . '/supplier/Asset'); // 发布必要的资源文件 \Core\Asset\ManagerHelper::publishAsset(SupplierThemePlugin::pluginGetUniqueId(), 'bootstrap-custom'); \Core\Asset\ManagerHelper::publishAsset(SupplierThemePlugin::pluginGetUniqueId(), 'css'); \Core\Asset\ManagerHelper::publishAsset(SupplierThemePlugin::pluginGetUniqueId(), 'img'); \Core\Asset\ManagerHelper::publishAsset(SupplierThemePlugin::pluginGetUniqueId(), 'js'); // 增加 smarty 模板搜索路径 $smarty->addTemplateDir($currentThemeBasePath . '/supplier/Tpl/'); // 加载 smarty 的扩展,里面有一些我们需要用到的函数 require_once $currentThemeBasePath . '/supplier/Code/smarty_helper.php'; // 注册 smarty 函数 smarty_helper_register($smarty); // 设置网站的 Base 路径,给 JavaScript 使用 $smarty->assign("WEB_ROOT_HOST", $f3->get('sysConfig[webroot_schema_host]')); $smarty->assign("WEB_ROOT_BASE", $f3->get('BASE')); $smarty->assign("WEB_ROOT_BASE_RES", smarty_helper_function_get_asset_url(array('asset' => ''), null)); return true; }
public static function enableDebug() { // 设置 PHP 调试环境 ini_set('display_errors', 1); error_reporting(E_ALL | E_STRICT); // 开启 debug log BzfDebug::startDebugLogCollector(); // 当前目录 autoload \Core\Plugin\SystemHelper::addAutoloadPath(realpath(dirname(__FILE__))); $handler = new \Whoops\Handler\PrettyPageHandler(); // 增加额外的日志输出 $handler->addDataTableCallback('LOGS', function () { // 取得 logCollector $logCollector = BzfDebug::startDebugLogCollector(); $logArray = $logCollector->getLogArray(); // 由于 debug 只支持 key-->value 显示,我们只能简单一点了 $displayArray = array(); $index = 0; foreach ($logArray as $logItem) { $displayArray['' . sprintf('%02d', $index) . '|' . str_pad($logItem['level'], 10, ' ', STR_PAD_LEFT) . '|' . $logItem['source']] = $logItem['msg']; $index++; } return $displayArray; }); $run = new \Whoops\Run(); $run->pushHandler($handler); $run->register(); }
/** * 为 groupon 系统设置运行环境 * * @return bool */ private function doShopAction() { // 获取当前插件的根地址 $currentPluginBasePath = dirname(__FILE__); // shop 目录加入到 auto load 的路径中,这样系统就能自动做 class 加载 SystemHelper::addAutoloadPath($currentPluginBasePath . '/shop/Code'); // 注册一种支付方式 PaymentGatewayHelper::registerInstanceKeyClass('alipay', '\\Payment\\Alipay\\Gateway'); return true; }
/** * 为 groupon 系统设置运行环境 * * @return bool */ private function doGrouponAction() { // 获取当前插件的根地址 $currentPluginBasePath = dirname(__FILE__); // groupon 目录加入到 auto load 的路径中,这样系统就能自动做 class 加载 SystemHelper::addAutoloadPath($currentPluginBasePath . '/groupon/Code'); // 设置路由,这样用户就能访问到我们的程序了 SystemHelper::addRouteMap('/Thirdpart/QQAuth/Login', 'Controller\\Thirdpart\\QQAuth\\Login'); SystemHelper::addRouteMap('/Thirdpart/QQAuth/Callback', 'Controller\\Thirdpart\\QQAuth\\Callback'); return true; }
/** * 为系统设置运行环境 * * @return bool */ private function doEtaoFeedAction() { // 获取当前插件的根地址 $currentPluginBasePath = dirname(__FILE__); // yiqifacps code 目录加入到 auto load 的路径中,这样系统就能自动做 class 加载 SystemHelper::addAutoloadPath($currentPluginBasePath . '/shop/Code'); // 设置路由,这样用户就能访问到我们的程序了 SystemHelper::addRouteMap('/Thirdpart/EtaoFeed/Category', 'Controller\\Thirdpart\\EtaoFeed\\Category'); SystemHelper::addRouteMap('/Thirdpart/EtaoFeed/FullIndex', 'Controller\\Thirdpart\\EtaoFeed\\FullIndex'); SystemHelper::addRouteMap('/Thirdpart/EtaoFeed/IncIndex', 'Controller\\Thirdpart\\EtaoFeed\\IncIndex'); SystemHelper::addRouteMap('/Thirdpart/EtaoFeed/Item/@fileName', 'Controller\\Thirdpart\\EtaoFeed\\Item'); return true; }
/** * 为 manage 系统设置运行环境 * * @return bool */ private function doManageAction() { // 获取当前插件的根地址 $currentPluginBasePath = dirname(__FILE__); // manage 目录加入到 auto load 的路径中,这样系统就能自动做 class 加载 SystemHelper::addAutoloadPath($currentPluginBasePath . '/manage/Code'); // 设置路由,这样用户就能访问到我们的程序了 SystemHelper::addRouteMap('/Thirdpart/PageTextReplace/Configure', 'Controller\\Thirdpart\\PageTextReplace\\Configure'); // 增加 smarty 模板搜索路径 global $smarty; $smarty->addTemplateDir($currentPluginBasePath . '/manage/Tpl/'); return true; }
/** * 为系统设置运行环境 * * @return bool */ private function doGouwukeAction() { // 获取当前插件的根地址 $currentPluginBasePath = dirname(__FILE__); // code 目录加入到 auto load 的路径中,这样系统就能自动做 class 加载 SystemHelper::addAutoloadPath($currentPluginBasePath . '/gouwuke/Code'); // 设置路由,这样用户就能访问到我们的程序了 SystemHelper::addRouteMap('/Thirdpart/Gouwuke/Goods', 'Controller\\Thirdpart\\Gouwuke\\Goods'); // 增加 smarty 模板搜索路径 global $smarty; $smarty->addTemplateDir($currentPluginBasePath . '/gouwuke/Tpl/'); return true; }
// 调试模式,关闭缓存 $f3->set('CACHE', false); // 把 smarty 的一些错误警告关闭,不然会影响我们的调试 Smarty::muteExpectedErrors(); // 使用自定义的调试框架 if ($f3->get('USERDEBUG')) { require_once PROTECTED_PATH . '/Framework/Debug/BzfDebug.php'; // 开启 debug 功能 BzfDebug::enableDebug(); // 开启 Smarty Web Log BzfDebug::enableSmartyWebLog(); } } // ---------------------------------------- 4. 设置工程环境 -------------------------------------- // 设置代码路径 \Core\Plugin\SystemHelper::addAutoloadPath(INSTALL_PATH . '/Code', true); // 设置路由,这样用户就能访问到我们的程序了 $f3->config(INSTALL_PATH . '/route.cfg'); // 增加 smarty 模板搜索路径 $smarty->addTemplateDir(INSTALL_PATH . '/Tpl/'); // 加载 smarty 的扩展,里面有一些我们需要用到的函数 require_once INSTALL_PATH . '/Code/smarty_helper.php'; // 注册 smarty 函数 smarty_helper_register($smarty); // ---------------------------------------- 5. 为 JavaScript 设置变量 -------------------------------------- // 设置网站的 Base 路径,给 JavaScript 使用 $smarty->assign("WEB_ROOT_HOST", $f3->get('sysConfig[webroot_schema_host]')); $smarty->assign("WEB_ROOT_BASE", $f3->get('BASE')); $smarty->assign("WEB_ROOT_BASE_RES", $f3->get('BASE') . '/Asset/'); // ---------------------------------------- 6. 启动程序 -------------------------------------- // 启动控制器
/** * * 为 mobile 系统设置运行环境 * * @return bool */ private function doMobileAction() { global $f3; // 获取当前插件的根地址 $currentThemeBasePath = dirname(__FILE__); // 通用的加载 $this->doOtherAction(); // mobile 目录加入到 auto load 的路径中,这样系统就能自动做 class 加载 SystemHelper::addAutoloadPath($currentThemeBasePath . '/mobile/Code', true); // 设置路由,这样用户就能访问到我们的程序了 $f3->config($currentThemeBasePath . '/mobile/route.cfg'); $f3->config($currentThemeBasePath . '/mobile/route-rewrite.cfg'); // 记录用户从什么来源到达网站的 ReferHelper::addReferItem('HostRefer', new HostRefer()); // 记录来源的 refer_host 和 refer_url // 注册 Asset 模块 \Core\Asset\ManagerHelper::registerModule(MobileThemePlugin::pluginGetUniqueId(), $this->pluginGetVersion(), $currentThemeBasePath . '/mobile/Asset'); // 发布必要的资源文件 \Core\Asset\ManagerHelper::publishAsset(MobileThemePlugin::pluginGetUniqueId(), 'jquery-mobile'); \Core\Asset\ManagerHelper::publishAsset(MobileThemePlugin::pluginGetUniqueId(), 'css'); \Core\Asset\ManagerHelper::publishAsset(MobileThemePlugin::pluginGetUniqueId(), 'js'); \Core\Asset\ManagerHelper::publishAsset(MobileThemePlugin::pluginGetUniqueId(), 'img'); // 增加 smarty 模板搜索路径 global $smarty; $smarty->addTemplateDir($currentThemeBasePath . '/mobile/Tpl/'); // 加载 smarty 的扩展,里面有一些我们需要用到的函数 require_once $currentThemeBasePath . '/mobile/Code/smarty_helper.php'; // 注册 smarty 函数 smarty_helper_register($smarty); global $f3; // 设置网站的 Base 路径,给 JavaScript 使用 $smarty->assign("WEB_ROOT_HOST", $f3->get('sysConfig[webroot_schema_host]')); $smarty->assign("WEB_ROOT_BASE", $f3->get('BASE')); $smarty->assign("WEB_ROOT_BASE_RES", smarty_helper_function_get_asset_url(array('asset' => ''), null)); $smarty->assign("IS_USER_AUTH", \Core\Helper\Utility\Auth::isAuthUser()); // jQuery Mobile 根据当前页面的 URL 来决定是否缓存,我们对某些不希望缓存的页面在这里需要特殊处理, // 确保它的 url 是一直变化的 $currentPageUrl = \Core\Helper\Utility\Route::getRequestURL(); // 下面的操作页面不要缓存,因为每次可能都不一样,比如有验证码,或者有新订单 if (false !== strpos($currentPageUrl, '/User/') || false !== strpos($currentPageUrl, '/My/') || false !== strpos($currentPageUrl, '/Cart/')) { $currentPageUrl = \Core\Helper\Utility\Route::addParam($currentPageUrl, array('_no_cache_page' => time())); } $smarty->assign("CURRENT_PAGE_URL", $currentPageUrl); return true; }
/** * 为 aimeidaren 设置运行环境 * * @return bool */ private function doAimeidarenAction() { // 获取当前插件的根地址 $currentPluginBasePath = dirname(__FILE__); // Shop 目录加入到 auto load 的路径中,这样系统就能自动做 class 加载 SystemHelper::addAutoloadPath($currentPluginBasePath . '/shop/Code'); // 设置 Prefix Callback::$optionKeyPrefix = 'aimeidaren_'; Login::$optionKeyPrefix = 'aimeidaren_'; return $this->doDev360AuthAction(); }
/** * 为系统设置运行环境 * * @return bool */ private function doYiqifaCpsAction() { // 获取当前插件的根地址 $currentPluginBasePath = dirname(__FILE__); // yiqifacps code 目录加入到 auto load 的路径中,这样系统就能自动做 class 加载 SystemHelper::addAutoloadPath($currentPluginBasePath . '/yiqifacps/Code'); // 设置 CPS 日志,按照日期分目录存储 $todayDateStr = \Core\Helper\Utility\Time::localTimeStr('Y-m-d'); $todayDateArray = explode('-', $todayDateStr); $fileLogger = new \Core\Log\File('YIQIFACPS/' . $todayDateArray[0] . '/' . $todayDateArray[1] . '/' . implode('-', $todayDateArray) . '.yiqifacps.log'); $fileLogger->sourceAllow[] = 'YIQIFACPS'; // 只接收 YIQIFACPS 的日志 global $logger; $logger->addLogger($fileLogger); // 把 $fileLogger 放到全局日志列表中 // 设置路由,这样用户就能访问到我们的程序了 SystemHelper::addRouteMap('/Thirdpart/YiqifaCps/Redirect', 'Controller\\Thirdpart\\YiqifaCps\\Redirect'); SystemHelper::addRouteMap('/Thirdpart/YiqifaCps/QueryOrder', 'Controller\\Thirdpart\\YiqifaCps\\QueryOrder'); SystemHelper::addRouteMap('/Thirdpart/YiqifaCps/CaibeiLogin', 'Controller\\Thirdpart\\YiqifaCps\\CaibeiLogin'); // 设置一个 OrderRefer 用于记录订单来自于 亿起发CPS require_once $currentPluginBasePath . '/yiqifacps/Code/YiqifaCpsRefer.php'; // 设置订单 refer 用于记录订单来源于 亿起发CPS ReferHelper::addReferItem('YiqifaCpsRefer', new YiqifaCpsRefer()); // 增加 smarty 模板搜索路径 global $smarty; $smarty->addTemplateDir($currentPluginBasePath . '/yiqifacps/Tpl/'); return true; }
<?php /** * @author QiangYu * * 主题加载文件,用于主题自身的初始化 * * */ use Core\Plugin\SystemHelper; $themeUniqueId = 'theme_manage'; $themeVersion = $f3->get('sysConfig[version]') ?: '1.0'; $themeBasePath = dirname(__FILE__); // 增加当前主题的 autoload 路径 SystemHelper::addAutoloadPath($themeBasePath . '/Code', true); // 加载路由定义 $f3->config($themeBasePath . '/route.cfg'); $f3->config($themeBasePath . '/route-rewrite.cfg'); // 注册一个通用的缓存清除程序 \Core\Cache\ClearHelper::registerInstanceClass('\\Core\\Cache\\ShareClear'); // 设置模板文件路径 $smarty->addTemplateDir($themeBasePath . '/Tpl/'); // 注册模块 \Core\Asset\ManagerHelper::registerModule($themeUniqueId, $themeVersion, $themeBasePath . '/Asset'); // 发布主题的资源文件 \Core\Asset\ManagerHelper::publishAsset($themeUniqueId, 'bootstrap-custom'); \Core\Asset\ManagerHelper::publishAsset($themeUniqueId, 'css'); \Core\Asset\ManagerHelper::publishAsset($themeUniqueId, 'img'); \Core\Asset\ManagerHelper::publishAsset($themeUniqueId, 'js'); // 加载 smarty 的扩展,里面有一些我们需要用到的函数 require_once dirname(__FILE__) . '/Code/smarty_helper.php'; // 注册 smarty 函数