/** * 为系统设置运行环境 * * @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; }
/** * * 为 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; }
/** * * 为 shop 系统设置运行环境 * * @return bool */ private function doShopAction() { global $f3; global $smarty; // 获取当前插件的根地址 $currentThemeBasePath = dirname(__FILE__); // 通用的加载 $this->doOtherAction(); // shop Code 目录加入到 auto load 的路径中,这样系统就能自动做 class 加载 SystemHelper::addAutoloadPath($currentThemeBasePath . '/shop/Code', true); // 设置路由,这样用户就能访问到我们的程序了 $f3->config($currentThemeBasePath . '/shop/route.cfg'); $f3->config($currentThemeBasePath . '/shop/route-rewrite.cfg'); ReferHelper::addReferItem('HostRefer', new HostRefer()); // 记录来源的 refer_host 和 refer_url // 注册 Asset 模块 \Core\Asset\ManagerHelper::registerModule(ShopThemePlugin::pluginGetUniqueId(), $this->pluginGetVersion(), $currentThemeBasePath . '/shop/Asset'); // 发布必要的资源文件 \Core\Asset\ManagerHelper::publishAsset(ShopThemePlugin::pluginGetUniqueId(), 'bootstrap-custom'); \Core\Asset\ManagerHelper::publishAsset(ShopThemePlugin::pluginGetUniqueId(), 'css'); \Core\Asset\ManagerHelper::publishAsset(ShopThemePlugin::pluginGetUniqueId(), 'js'); \Core\Asset\ManagerHelper::publishAsset(ShopThemePlugin::pluginGetUniqueId(), 'img'); // 增加 smarty 模板搜索路径 $smarty->addTemplateDir($currentThemeBasePath . '/shop/Tpl/'); // 加载 smarty 的扩展,里面有一些我们需要用到的函数 require_once $currentThemeBasePath . '/shop/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; }