Example #1
0
    private function getGoodsItemXml($index, $goodsItem, $goodsIdToGalleryArray)
    {
        global $f3;
        $siteName = $f3->get('sysConfig[site_name]');
        $goodsViewUrl = RouteHelper::makeUrl('/Goods/View', array('goods_id' => $goodsItem['goods_id']), false, true);
        $goodsViewUrl = RouteHelper::addParam($goodsViewUrl, array('utm_source' => 'baidutuan'));
        $goodsImageUrl = '';
        if (isset($goodsIdToGalleryArray[$goodsItem['goods_id']])) {
            $goodsImageUrl = RouteHelper::makeImageUrl($goodsIdToGalleryArray[$goodsItem['goods_id']][0]['img_url']);
        }
        // 购买数量
        $bought = $goodsItem['virtual_buy_number'] + $goodsItem['user_pay_number'];
        // 转换价格显示
        $goodsItem['market_price'] = Money::toSmartyDisplay($goodsItem['market_price']);
        $goodsItem['shop_price'] = Money::toSmartyDisplay($goodsItem['shop_price']);
        $rebate = 0;
        if ($goodsItem['market_price'] > 0) {
            $rebate = 10 * round($goodsItem['shop_price'] / $goodsItem['market_price'], 2);
        }
        $today = strtotime(date('Ymd'));
        $twoDaysLater = $today + 86400 * 2;
        $xmlitem = <<<XMLITEM
\t<url>
\t    <loc><![CDATA[{$goodsViewUrl}]]></loc>
\t    <data><display>
\t\t<website><![CDATA[{$siteName}]]></website>
\t\t<siteurl><![CDATA[{$this->siteUrl}]]></siteurl>
\t\t<city>全国</city>
\t\t<title><![CDATA[{$goodsItem['goods_name']}]]></title>
\t\t<image><![CDATA[{$goodsImageUrl}]]></image>
\t\t<startTime>{$today}</startTime>
\t\t<endTime>{$twoDaysLater}</endTime>
        <value>{$goodsItem['market_price']}</value>
        <price>{$goodsItem['shop_price']}</price>
        <rebate>{$rebate}</rebate>
        <bought>{$bought}</bought>
        </display></data>
        </url>
XMLITEM;
        return $xmlitem;
    }
Example #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;
 }
Example #3
0
/**
 * 生成分页栏,用法:{{bzf_paginator count=$totalCount pageNo=$pageNo pageSize=$pageSize }}
 */
function smarty_helper_function_paginator(array $paramArray, $smarty)
{
    $count = isset($paramArray['count']) ? $paramArray['count'] : 0;
    $pageNo = isset($paramArray['pageNo']) ? $paramArray['pageNo'] : 0;
    $pageSize = isset($paramArray['pageSize']) ? $paramArray['pageSize'] : 10;
    // 不需要分页
    if ($count <= 0 || $count < $pageSize) {
        return '';
    }
    // 修正 page 的值
    $pageNo = $pageNo * $pageSize < $count ? $pageNo : 0;
    $totalPage = ceil($count / $pageSize);
    // 只有一页,不需要分页
    if ($totalPage <= 1) {
        return '';
    }
    // 处理参数
    $currentUrl = RouteHelper::getRequestURL();
    // 首页
    $paginator = '<li><a href="' . RouteHelper::addParam($currentUrl, array('pageNo' => 0), true) . '">首页</a></li>';
    // 前后各输出 5 页
    $displayPageCount = 5;
    $pageStart = $pageNo - $displayPageCount > 0 ? $pageNo - $displayPageCount : 0;
    $pageEnd = $pageNo + $displayPageCount < $totalPage ? $pageNo + $displayPageCount : $totalPage - 1;
    for ($pageIndex = $pageStart; $pageIndex <= $pageEnd; $pageIndex++) {
        $link = '';
        if (0 == $pageIndex || $totalPage - 1 == $pageIndex) {
            $link = '<a href="' . RouteHelper::addParam($currentUrl, array('pageNo' => $pageIndex), true) . '">' . ($pageIndex + 1) . '</a>';
        } else {
            if ($pageStart == $pageIndex) {
                $link = '<a href="' . RouteHelper::addParam($currentUrl, array('pageNo' => $pageIndex), true) . '">&lt;&lt;</a>';
            } else {
                if ($pageEnd == $pageIndex) {
                    $link = '<a href="' . RouteHelper::addParam($currentUrl, array('pageNo' => $pageIndex), true) . '">&gt;&gt;</a>';
                } else {
                    $link = '<a href="' . RouteHelper::addParam($currentUrl, array('pageNo' => $pageIndex), true) . '">' . ($pageIndex + 1) . '</a>';
                }
            }
        }
        if ($pageNo == $pageIndex) {
            // 当前页,active
            $paginator .= '<li class="active">' . $link . '</li>';
        } else {
            $paginator .= '<li>' . $link . '</li>';
        }
    }
    // 末页
    $paginator .= '<li><a href="' . RouteHelper::addParam($currentUrl, array('pageNo' => $totalPage - 1), true) . '">末页</a></li>';
    return '<span>(总数:' . $count . '&nbsp;&nbsp;页数:' . ($pageNo + 1) . '/' . $totalPage . ')</span><ul>' . $paginator . '</ul>';
}
Example #4
0
    private function getGoodsItemXml($index, $goodsItem, $goodsIdToGalleryArray)
    {
        global $f3;
        static $buyNotice = "【下单说明】请在下单时留言注明尺码准确填写姓名、电话和收件地址!\n【发货说明】下单后48小时内发货,快递3-5天左右到达,节假日顺延。偏远地区需要补10元邮费。\n【关于尺寸】因测量手法问题,测量数据可能存在2-3CM误差,还请见谅!\n【关于色差】颜色因场景拍摄及电脑显示有差异均属于正常,不属于质量问题。图色显示与实物颜色我们保证以最接近实物的颜色上传。\n【关于签收】请务必本人签收。验货后,如商品有任何破损问题请当快递员面拒收!";
        $siteName = $f3->get('sysConfig[site_name]');
        $goodsViewUrl = RouteHelper::makeUrl('/Goods/View', array('goods_id' => $goodsItem['goods_id']), false, true);
        $goodsViewUrl = RouteHelper::addParam($goodsViewUrl, array('utm_source' => 'gouwuke'));
        $goodsImageUrlList = '<picurls>';
        $goodsGalleryArray = @$goodsIdToGalleryArray[$goodsItem['goods_id']];
        if (!empty($goodsGalleryArray)) {
            foreach ($goodsGalleryArray as $goodsGalleryItem) {
                $goodsImageUrlList .= '<picurllist>';
                $goodsImageUrlList .= '<picurl><![CDATA[' . RouteHelper::makeImageUrl($goodsGalleryItem['img_url']) . ']]></picurl>';
                $goodsImageUrlList .= '<bigpicurl><![CDATA[' . RouteHelper::makeImageUrl($goodsGalleryItem['img_original']) . ']]></bigpicurl>';
                $goodsImageUrlList .= '</picurllist>';
            }
        }
        $goodsImageUrlList .= '</picurls>';
        // 取得商品的分类层级
        $goodsCategoryLevelArray = array();
        $categoryLevel = 5;
        // 最多取 5 层分类
        $currentCategoryId = $goodsItem['cat_id'];
        for (; $categoryLevel > 0; $categoryLevel--) {
            $category = $this->goodsCategoryService->loadCategoryById($currentCategoryId, 1800);
            if ($category->isEmpty()) {
                break;
            }
            array_unshift($goodsCategoryLevelArray, $category);
            if ($category['parent_meta_id'] <= 0) {
                break;
            }
            $currentCategoryId = $category['parent_meta_id'];
        }
        $goodsCategoryLevelStr = '';
        foreach ($goodsCategoryLevelArray as $goodsCategoryItem) {
            $goodsCategoryLevelStr .= $goodsCategoryItem['meta_name'] . ' > ';
        }
        $goodsCategoryLevelStr .= '当前商品';
        // 转换价格显示
        $goodsItem['market_price'] = Money::toSmartyDisplay($goodsItem['market_price']);
        $goodsItem['shop_price'] = Money::toSmartyDisplay($goodsItem['shop_price']);
        $xmlitem = <<<XMLITEM
\t<urlset>
\t    <ident><![CDATA[{$this->siteIdentify}_{$goodsItem['goods_id']}]]></ident>
\t    <productname><![CDATA[{$goodsItem['goods_name']}]]></productname>
\t    <refprice>{$goodsItem['market_price']}</refprice>
        <price_1>{$goodsItem['shop_price']}</price_1>
        <zhekou_price><![CDATA[]]></zhekou_price>
        <zhekou><![CDATA[]]></zhekou>
        <ifcuxiao><![CDATA[false]]></ifcuxiao>
        <quehuo><![CDATA[false]]></quehuo>
        {$goodsImageUrlList}
\t    <url><![CDATA[{$goodsViewUrl}]]></url>
\t    <shortintro><![CDATA[{$goodsItem['goods_name']}]]></shortintro>
\t    <shortintrohtml><![CDATA[{$buyNotice}]]></shortintrohtml>
\t    <orifenlei><![CDATA[{$goodsCategoryLevelStr}]]></orifenlei>
\t    <pinpai><![CDATA[]]></pinpai>
\t    <color><![CDATA[]]></color>
        <chandi><![CDATA[]]></chandi>
    </urlset>
XMLITEM;
        return $xmlitem;
    }
Example #5
0
 /**
  * 路由到另外的页面
  *
  * @param object  $controller       当前跳转的控制器
  * @param string  $url              你想路由到的页面的 URL
  * @param boolean $rememberCurrent  是否记录当前页面的 URL,方便你之后用 jumpBack() 回到这个页面, 比如现在你需要让用户去登陆,登陆完之后你希望能返回当前页面
  *
  * */
 public static function reRoute($controller, $url, $rememberCurrent = false)
 {
     global $f3;
     if ($rememberCurrent) {
         self::setJumpBackUrl(Route::getFullURL());
     }
     // reroute 之前调用 afterRoute() 方法
     if (isset($controller) && is_object($controller) && method_exists($controller, 'afterRoute')) {
         $controller->afterRoute($f3);
     }
     // 如果 URL 不是绝对地址,我们生成绝对地址(静态化的时候保持地址格式一致)
     if (self::$isMakeStaticUrl && !Route::isUrlAbsolute($url) && false === strpos($url, '?')) {
         $url = Route::makeUrl($url, null, false, true);
     }
     if (Route::$enableSessionIdUrl) {
         $url = Route::addParam($url, array(session_name() => session_id()));
     }
     $f3->reroute($url);
 }
Example #6
0
/**
 * 生成分页栏,用法:{{bzf_paginator count=$totalCount pageNo=$pageNo pageSize=$pageSize }}
 */
function smarty_helper_function_paginator(array $paramArray, $smarty)
{
    $count = isset($paramArray['count']) ? $paramArray['count'] : 0;
    $pageNo = isset($paramArray['pageNo']) ? $paramArray['pageNo'] : 0;
    $pageSize = isset($paramArray['pageSize']) ? $paramArray['pageSize'] : 10;
    // 不需要分页
    if ($count <= 0 || $count < $pageSize) {
        return '';
    }
    // 修正 page 的值
    $pageNo = $pageNo * $pageSize < $count ? $pageNo : 0;
    $totalPage = ceil($count / $pageSize);
    // 只有一页,不需要分页
    if ($totalPage <= 1) {
        return '';
    }
    // 处理参数
    $currentUrl = RouteHelper::getRequestURL();
    // 去除已有的 page 和 size 参数
    $currentUrl = RouteHelper::removeParam($currentUrl, 'pageNo');
    $currentUrl = RouteHelper::removeParam($currentUrl, 'pageSize');
    // 上一页
    $pagePrevious = '<a data-role="button" class="ui-disabled" data-icon="arrow-l" data-iconpos="left" href="#" data-theme="b">上一页</a>';
    if ($pageNo > 0) {
        $pagePrevious = '<a data-role="button" data-icon="arrow-l" data-iconpos="left" href="' . RouteHelper::addParam($currentUrl, array('pageNo' => $pageNo - 1), true) . '"  data-theme="b" data-direction="reverse" data-transition="flow" >上一页</a>';
    }
    // 下一页
    $pageNext = '<a data-role="button" class="ui-disabled" data-icon="arrow-r" data-iconpos="right" href="#" data-theme="b">下一页</a>';
    if ($pageNo < $totalPage - 1) {
        $pageNext = '<a data-role="button" data-icon="arrow-r" data-iconpos="right" href="' . RouteHelper::addParam($currentUrl, array('pageNo' => $pageNo + 1), true) . '"  data-theme="b" data-transition="flow">下一页</a>';
    }
    return '<div class="ui-grid-a"><div class="ui-block-a">' . $pagePrevious . '</div><div class="ui-block-b">' . $pageNext . '</div></div>';
}