/** * * 为 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; }
/** * * 为 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; }
* */ 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 函数 smarty_helper_register($smarty); // 注册资源应用函数 function smarty_helper_get_asset_url(array $paramArray, $smarty) { global $themeUniqueId; if (!isset($paramArray['asset'])) { return '';