示例#1
0
/**
 * 把 html 中的图片替换成 lazyload 模式
 *
 * @param $htmlContent
 */
function smarty_helper_modifier_html_image_lazyload($htmlContent)
{
    $loadingImage = smarty_helper_function_get_asset_url(array('asset' => 'img/lazyload_placeholder_goods_desc.png'), null);
    $htmlContent = preg_replace('/<img(.*?)src="(.*?)"(.*?)\\/?>/', '<img \\1 class="lazyload" src="' . $loadingImage . '" data-original="\\2" \\3 />', $htmlContent);
    // 这里做 文本替换
    global $f3;
    if ($f3->get('sysConfig[goods_desc_text_replace]')) {
        $replaceArray = $f3->get('sysConfig[goods_desc_text_replace]');
        foreach ($replaceArray as $key => $value) {
            $htmlContent = str_replace($key, $value, $htmlContent);
        }
    }
    return $htmlContent;
}
示例#2
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;
 }
示例#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;
 }