Example #1
0
 /**
  *
  * 为 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;
 }
Example #2
0
    $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. 启动程序 --------------------------------------
// 启动控制器
$f3->run();
Example #3
0
 /**
  *
  * 为 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;
 }