当前位置: 首页>>代码示例>>PHP>>正文


PHP Route::makeImageUrl方法代码示例

本文整理汇总了PHP中Core\Helper\Utility\Route::makeImageUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP Route::makeImageUrl方法的具体用法?PHP Route::makeImageUrl怎么用?PHP Route::makeImageUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Core\Helper\Utility\Route的用法示例。


在下文中一共展示了Route::makeImageUrl方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get

 public function get($f3)
 {
     // 权限检查
     $this->requirePrivilege('manage_goods_edit_edit_get');
     global $smarty;
     // 参数验证
     $validator = new Validator($f3->get('GET'));
     $goods_id = $validator->required('商品ID不能为空')->digits()->min(1)->validate('goods_id');
     if (!$this->validate($validator)) {
         goto out_fail;
     }
     // 取得商品图片集信息
     $goodsGalleryService = new GoodsGalleryService();
     $goodsGalleryArray = $goodsGalleryService->fetchGoodsGalleryArrayByGoodsId($goods_id);
     // 处理图片路径,全部需要生成为绝对路径
     foreach ($goodsGalleryArray as &$goodsGalleryItem) {
         $goodsGalleryItem['img_url'] = RouteHelper::makeImageUrl($goodsGalleryItem['img_url']);
         $goodsGalleryItem['thumb_url'] = RouteHelper::makeImageUrl($goodsGalleryItem['thumb_url']);
         $goodsGalleryItem['img_original'] = RouteHelper::makeImageUrl($goodsGalleryItem['img_original']);
     }
     // 显示商品图片集
     $smarty->assign('goodsGalleryArray', $goodsGalleryArray);
     out_display:
     $smarty->display('goods_edit_gallery.tpl');
     return;
     out_fail:
     RouteHelper::reRoute($this, '/Goods/Search');
 }
开发者ID:jackycgq,项目名称:bzfshop,代码行数:28,代码来源:Gallery.php

示例2: GalleryThumb

 /**
  * 根据 goods_id 得到一个商品的图片集
  *
  * @param $f3
  */
 public function GalleryThumb($f3)
 {
     // 参数验证
     $validator = new Validator($f3->get('GET'));
     $errorMessage = '';
     $goods_id = $validator->required()->digits()->min(1)->filter('ValidatorIntValue')->validate('goods_id');
     if (!$this->validate($validator)) {
         $errorMessage = implode('|', $this->flashMessageArray);
         goto out_fail;
     }
     $goodsGalleryService = new GoodsGalleryService();
     $galleryArray = $goodsGalleryService->fetchGoodsGalleryArrayByGoodsId($goods_id);
     $thumImageList = array();
     foreach ($galleryArray as $galleryItem) {
         $thumImageList[] = array('img_id' => $galleryItem['img_id'], 'thumb_url' => RouteHelper::makeImageUrl($galleryItem['thumb_url']));
     }
     out:
     Ajax::header();
     echo Ajax::buildResult(null, null, $thumImageList);
     return;
     out_fail:
     // 失败,返回出错信息
     Ajax::header();
     echo Ajax::buildResult(-1, $errorMessage, null);
 }
开发者ID:jackycgq,项目名称:bzfshop,代码行数:30,代码来源:Goods.php

示例3: get

 public function get($f3)
 {
     global $smarty;
     // 首先做参数合法性验证
     $validator = new Validator($f3->get('GET'));
     $goods_id = $validator->required('商品id不能为空')->digits('商品id非法')->min(1, true, '商品id非法')->validate('goods_id');
     if (!$this->validate($validator)) {
         goto out_fail;
     }
     // 生成 smarty 的缓存 id
     $smartyCacheId = 'Goods|' . $goods_id . '|View';
     // 开启并设置 smarty 缓存时间
     enableSmartyCache(true, MobileThemePlugin::getOptionValue('smarty_cache_time_goods_view'));
     // 缓存页面
     if ($smarty->isCached('goods_view.tpl', $smartyCacheId)) {
         goto out_display;
     }
     // 查询商品信息
     $goodsBasicService = new GoodsBasicService();
     $goodsInfo = $goodsBasicService->loadGoodsById($goods_id);
     // 商品不存在,退出
     if ($goodsInfo->isEmpty() || !Utils::isTagExist(PluginHelper::SYSTEM_MOBILE, $goodsInfo['system_tag_list'])) {
         $this->addFlashMessage('商品 [' . $goods_id . '] 不存在');
         goto out_fail;
     }
     // 取商品推广信息设置
     $goodsPromote = $goodsBasicService->loadGoodsPromoteByGoodsId($goods_id);
     // 取商品图片集
     $goodsGalleryArray = GoodsGalleryCache::getGoodsGallery($goods_id);
     foreach ($goodsGalleryArray as &$galleryItem) {
         $galleryItem['img_url'] = RouteHelper::makeImageUrl($galleryItem['img_url']);
         $galleryItem['thumb_url'] = RouteHelper::makeImageUrl($galleryItem['thumb_url']);
     }
     unset($galleryItem);
     // 设置商品页面的 SEO 信息
     $smarty->assign('seo_title', $goodsInfo['seo_title'] . ',' . $f3->get('sysConfig[site_name]'));
     $smarty->assign('seo_description', $goodsInfo['seo_description']);
     $smarty->assign('seo_keywords', $goodsInfo['seo_keyword']);
     // 给模板赋值
     $smarty->assign('goodsInfo', $goodsInfo);
     $smarty->assign('goodsPromote', $goodsPromote);
     if (!Utils::isEmpty($goodsGalleryArray)) {
         $smarty->assign('goodsGalleryArray', $goodsGalleryArray);
     }
     // 设置商品规格
     if (!empty($goodsInfo['goods_spec'])) {
         $goodsSpecService = new GoodsSpecService();
         $goodsSpecService->initWithJson($goodsInfo['goods_spec']);
         $smarty->assign('goodsSpec', $goodsSpecService->getGoodsSpecDataArray());
     }
     out_display:
     $smarty->display('goods_view.tpl', $smartyCacheId);
     return;
     out_fail:
     // 失败从这里返回
     RouteHelper::reRoute($this, '/');
     // 返回首页
 }
开发者ID:jackycgq,项目名称:bzfshop,代码行数:58,代码来源:View.php

示例4: getGoodsItemXml

    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;
    }
开发者ID:jackycgq,项目名称:bzfshop,代码行数:41,代码来源:Baidu.php

示例5: get

 public function get($f3)
 {
     global $smarty;
     // 首先做参数合法性验证
     $validator = new Validator($f3->get('GET'));
     $pageNo = $validator->digits('pageNo 参数非法')->min(0, true, 'pageNo 参数非法')->validate('pageNo');
     // 搜索参数数组
     $searchFormQuery = array();
     $searchFormQuery['category_id'] = $validator->digits('分类id非法')->min(1, true, '分类id非法')->filter('ValidatorIntValue')->validate('category_id');
     $searchFormQuery['suppliers_id'] = $validator->digits('供货商id非法')->min(1, true, '供货商id非法')->filter('ValidatorIntValue')->validate('suppliers_id');
     $searchFormQuery['goods_name'] = $validator->validate('goods_name');
     // 价格区间查询
     $shopPriceMin = $validator->filter('ValidatorFloatValue')->validate('shop_price_min');
     $shopPriceMax = $validator->filter('ValidatorFloatValue')->validate('shop_price_max');
     $searchFormQuery['shop_price'] = array($shopPriceMin, $shopPriceMax);
     // 排序
     $orderBy = $validator->oneOf(array('', 'total_buy_number', 'shop_price', 'add_time'))->validate('orderBy');
     $orderDir = $validator->oneOf(array('', 'asc', 'desc'))->validate('orderDir');
     $orderByParam = array();
     if (!empty($orderBy)) {
         $orderByParam = array(array($orderBy, $orderDir));
     }
     //增加一些我们的缺省排序
     $orderByParam[] = array('sort_order', 'desc');
     $orderByParam[] = array('goods_id', 'desc');
     // 参数验证
     if (!$this->validate($validator) || empty($searchFormQuery)) {
         goto out_fail;
     }
     $pageNo = isset($pageNo) && $pageNo > 0 ? $pageNo : 0;
     $pageSize = 10;
     // 每页固定显示 10 个商品
     // 生成 smarty 的缓存 id
     $smartyCacheId = 'Goods|Search|' . md5(json_encode($searchFormQuery) . json_encode($orderByParam) . '_' . $pageNo . '_' . $pageSize);
     // 开启并设置 smarty 缓存时间
     enableSmartyCache(true, MobileThemePlugin::getOptionValue('smarty_cache_time_goods_search'));
     if ($smarty->isCached('goods_search.tpl', $smartyCacheId)) {
         goto out_display;
     }
     // 合并查询参数
     $searchParamArray = array_merge(QueryBuilder::buildSearchParamArray($searchFormQuery), $this->searchExtraCondArray);
     $totalCount = SearchHelper::count(SearchHelper::Module_Goods, $searchParamArray);
     if ($totalCount <= 0) {
         goto out_display;
         // 没有商品,直接显示
     }
     // 页号可能是用户乱输入的,我们需要检查
     if ($pageNo * $pageSize >= $totalCount) {
         goto out_fail;
         // 返回首页
     }
     $goodsArray = SearchHelper::search(SearchHelper::Module_Goods, $this->searchFieldSelector, $searchParamArray, $orderByParam, $pageNo * $pageSize, $pageSize);
     if (empty($goodsArray)) {
         goto out_display;
     }
     // 取得 商品ID 列表
     $goodsIdArray = array();
     foreach ($goodsArray as $goodsItem) {
         $goodsIdArray[] = $goodsItem['goods_id'];
     }
     // 取得商品的图片
     $goodsGalleryService = new GoodsGalleryService();
     $goodsGalleryArray = $goodsGalleryService->fetchGoodsGalleryArrayByGoodsIdArray($goodsIdArray);
     $currentGoodsId = -1;
     $goodsThumbImageArray = array();
     $goodsImageArray = array();
     foreach ($goodsGalleryArray as $goodsGalleryItem) {
         if ($currentGoodsId == $goodsGalleryItem['goods_id']) {
             continue;
             //每个商品我们只需要一张图片,跳过其它的图片
         }
         $currentGoodsId = $goodsGalleryItem['goods_id'];
         // 新的商品 id
         $goodsThumbImageArray[$currentGoodsId] = RouteHelper::makeImageUrl($goodsGalleryItem['thumb_url']);
         $goodsImageArray[$currentGoodsId] = RouteHelper::makeImageUrl($goodsGalleryItem['img_url']);
     }
     // 赋值给模板
     $smarty->assign('totalCount', $totalCount);
     $smarty->assign('pageNo', $pageNo);
     $smarty->assign('pageSize', $pageSize);
     $smarty->assign('goodsArray', $goodsArray);
     $smarty->assign('goodsThumbImageArray', $goodsThumbImageArray);
     $smarty->assign('goodsImageArray', $goodsImageArray);
     out_display:
     $smarty->display('goods_search.tpl', $smartyCacheId);
     return;
     out_fail:
     // 失败从这里返回
     RouteHelper::reRoute($this, '/');
     // 返回首页
 }
开发者ID:jackycgq,项目名称:bzfshop,代码行数:91,代码来源:Search.php

示例6: getGoodsHeadImageUrl

 /**
  * 取得商品的头图 url
  *
  * @param int $goods_id
  *
  * @return string
  */
 public static function getGoodsHeadImageUrl($goods_id)
 {
     // 参数不对,没有东西可以输出
     if ($goods_id <= 0) {
         return '';
     }
     $goodsGallery = self::getGoodsGallery($goods_id);
     if (empty($goodsGallery)) {
         return '';
     }
     return RouteHelper::makeImageUrl($goodsGallery[0]['img_url']);
 }
开发者ID:swcug,项目名称:bzfshop,代码行数:19,代码来源:GoodsGalleryCache.php

示例7: get

 public function get($f3)
 {
     global $smarty;
     // 生成 smarty 的缓存 id
     $smartyCacheId = 'Mobile|Index';
     // 开启并设置 smarty 缓存时间
     enableSmartyCache(true, MobileThemePlugin::getOptionValue('smarty_cache_time_goods_index'));
     // 缓存页面
     if ($smarty->isCached('mobile_index.tpl', $smartyCacheId)) {
         goto out_display;
     }
     $categoryLevel = 3;
     // 取得分类下面 3 层的商品
     $categoryGoodsSzie = 4;
     // 每个分类下面取 4 个商品
     // 取得分类列表
     $categoryService = new CategoryService();
     $categoryArray = $categoryService->fetchCategoryArray(0);
     //取得分类
     // 取得商品列表
     $categoryGoodsArray = array();
     $goodsIdArray = array();
     foreach ($categoryArray as $category) {
         // 分类下面 3 层子分类, 取 4 个商品
         $goodsArray = $categoryService->fetchGoodsArray($category['meta_id'], $categoryLevel, PluginHelper::SYSTEM_MOBILE, 0, $categoryGoodsSzie);
         if (!empty($goodsArray)) {
             $categoryGoodsArray[$category['meta_id']] = $goodsArray;
             foreach ($goodsArray as $goodsItem) {
                 $goodsIdArray[] = $goodsItem['goods_id'];
             }
         }
     }
     // 网站完全没有商品? 不缓存
     if (empty($goodsIdArray)) {
         goto out_display;
     }
     // 取得商品的图片
     $goodsGalleryService = new GoodsGalleryService();
     $goodsGalleryArray = $goodsGalleryService->fetchGoodsGalleryArrayByGoodsIdArray($goodsIdArray);
     $currentGoodsId = -1;
     $goodsThumbImageArray = array();
     $goodsImageArray = array();
     foreach ($goodsGalleryArray as $goodsGalleryItem) {
         if ($currentGoodsId == $goodsGalleryItem['goods_id']) {
             continue;
             //每个商品我们只需要一张图片,跳过其它的图片
         }
         $currentGoodsId = $goodsGalleryItem['goods_id'];
         // 新的商品 id
         $goodsThumbImageArray[$currentGoodsId] = RouteHelper::makeImageUrl($goodsGalleryItem['thumb_url']);
         $goodsImageArray[$currentGoodsId] = RouteHelper::makeImageUrl($goodsGalleryItem['img_url']);
     }
     // 赋值给模板
     $smarty->assign('categoryArray', $categoryArray);
     $smarty->assign('categoryGoodsArray', $categoryGoodsArray);
     $smarty->assign('goodsThumbImageArray', $goodsThumbImageArray);
     $smarty->assign('goodsImageArray', $goodsImageArray);
     out_display:
     $smarty->assign('seo_title', $smarty->getTemplateVars('seo_title') . ',' . $f3->get('HOST'));
     $smarty->display('mobile_index.tpl', $smartyCacheId);
 }
开发者ID:jackycgq,项目名称:bzfshop,代码行数:61,代码来源:Index.php

示例8: getGoodsItemXml

    private function getGoodsItemXml($goodsItem, $goodsIdToGalleryArray)
    {
        // 截取描述,不能太长
        $goodsItem['goods_desc'] = mb_substr($goodsItem['goods_name'] . ' ' . strip_tags($goodsItem['goods_desc']), 0, 1000);
        // 截取商品标题,标题不能太长了
        $goodsItem['goods_name'] = mb_substr($goodsItem['goods_name'], 0, 60);
        $goodsViewUrl = RouteHelper::makeUrl('/Goods/View', array('goods_id' => $goodsItem['goods_id']), false, true);
        // 增加额外的链接参数
        $goodsViewUrl .= EtaoFeedPlugin::getOptionValue('etaofeed_goods_url_extra_param');
        // 处理图片列表
        $goodsGalleryArray = array();
        if (array_key_exists($goodsItem['goods_id'], $goodsIdToGalleryArray)) {
            $goodsGalleryArray = $goodsIdToGalleryArray[$goodsItem['goods_id']];
        }
        $goodsItemImageXml = '';
        if (!empty($goodsGalleryArray)) {
            $goodsItemImageXml = '<image is_default="true">' . RouteHelper::makeImageUrl($goodsGalleryArray[0]['img_original']) . '</image>';
            array_shift($goodsGalleryArray);
            // 去掉第一个图片
            $goodsItemImageXml .= '<more_images>';
            // 图片集中的图片
            foreach ($goodsGalleryArray as $goodsGalleryItem) {
                $goodsItemImageXml .= '<img>' . RouteHelper::makeImageUrl($goodsGalleryItem['img_original']) . '</img>';
            }
            $goodsItemImageXml .= '</more_images>';
        }
        // 转换数据显示
        $goodsItem['shop_price'] = Money::toSmartyDisplay($goodsItem['shop_price']);
        $goodsItem['shipping_fee'] = Money::toSmartyDisplay($goodsItem['shipping_fee']);
        $goodsItemXml = <<<XML
<item>
\t<seller_id><![CDATA[{$this->sellerId}]]></seller_id>
\t<outer_id>{$goodsItem['goods_id']}</outer_id>
\t<title><![CDATA[{$goodsItem['goods_name']}]]></title>
\t<product_id>{$goodsItem['goods_sn']}</product_id>
\t<type>fixed</type>
\t<available>1</available>
\t<price>{$goodsItem['shop_price']}</price>
\t<desc><![CDATA[{$goodsItem['goods_desc']}]]></desc>
\t{$goodsItemImageXml}
\t<scids>{$goodsItem['cat_id']}</scids>
\t<post_fee>{$goodsItem['shipping_fee']}</post_fee>
\t<href><![CDATA[{$goodsViewUrl}]]></href>
</item>
XML;
        return $goodsItemXml;
    }
开发者ID:jackycgq,项目名称:bzfshop,代码行数:47,代码来源:Item.php

示例9: getGoodsItemXml

    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;
    }
开发者ID:jackycgq,项目名称:bzfshop,代码行数:64,代码来源:Goods.php

示例10: smarty_helper_function_thumb_image

/**
 * 根据 img_id 取得缩略图
 *
 * @param array $paramArray
 * @param       $smarty
 *
 * @return string
 */
function smarty_helper_function_thumb_image(array $paramArray, $smarty)
{
    $img_id = isset($paramArray['img_id']) ? intval($paramArray['img_id']) : 0;
    // 参数不对,没有东西可以输出
    if ($img_id <= 0) {
        return '';
    }
    static $goodsGalleryService = null;
    if (!$goodsGalleryService) {
        $goodsGalleryService = new GoodsGalleryService();
    }
    $galleryItem = $goodsGalleryService->loadGoodsGalleryById($img_id, 1800);
    if ($galleryItem->isEmpty()) {
        return '';
    }
    return RouteHelper::makeImageUrl($galleryItem['thumb_url']);
}
开发者ID:jackycgq,项目名称:bzfshop,代码行数:25,代码来源:smarty_helper.php

示例11: get

 public function get($f3)
 {
     global $smarty;
     // 首先做参数合法性验证
     $validator = new Validator($f3->get('GET'));
     $goods_id = $validator->required('商品id不能为空')->digits('商品id非法')->min(1, true, '商品id非法')->validate('goods_id');
     if (!$this->validate($validator)) {
         goto out_fail;
     }
     // 生成 smarty 的缓存 id
     $smartyCacheId = 'Goods|' . $goods_id . '|View';
     // 开启并设置 smarty 缓存时间
     enableSmartyCache(true, bzf_get_option_value('smarty_cache_time_goods_view'));
     if ($smarty->isCached('goods_view.tpl', $smartyCacheId)) {
         goto out_display;
     }
     // 查询商品信息
     $goodsBasicService = new GoodsBasicService();
     $goodsInfo = $goodsBasicService->loadGoodsById($goods_id);
     // 商品不存在,退出
     if ($goodsInfo->isEmpty() || !Utils::isTagExist(PluginHelper::SYSTEM_SHOP, $goodsInfo['system_tag_list'])) {
         $this->addFlashMessage('商品 [' . $goods_id . '] 不存在');
         goto out_fail;
     }
     // 取得商品的分类层级
     $goodsCategoryLevelArray = array();
     $goodsCategoryService = new GoodsCategoryService();
     $categoryLevel = 5;
     // 最多取 5 层分类
     $currentCategoryId = $goodsInfo['cat_id'];
     for (; $categoryLevel > 0; $categoryLevel--) {
         $category = $goodsCategoryService->loadCategoryById($currentCategoryId, 1800);
         if ($category->isEmpty()) {
             break;
         }
         array_unshift($goodsCategoryLevelArray, $category);
         if ($category['parent_meta_id'] <= 0) {
             break;
         }
         $currentCategoryId = $category['parent_meta_id'];
     }
     // 取商品推广信息设置
     $goodsPromote = $goodsBasicService->loadGoodsPromoteByGoodsId($goods_id);
     // 取商品图片集
     $goodsGalleryArray = GoodsGalleryCache::getGoodsGallery($goods_id);
     foreach ($goodsGalleryArray as &$galleryItem) {
         $galleryItem['img_original'] = RouteHelper::makeImageUrl($galleryItem['img_original']);
         $galleryItem['img_url'] = RouteHelper::makeImageUrl($galleryItem['img_url']);
         $galleryItem['thumb_url'] = RouteHelper::makeImageUrl($galleryItem['thumb_url']);
     }
     unset($galleryItem);
     // 取相互关联的商品
     $linkGoodsArray = $goodsBasicService->fetchLinkGoodsArray($goods_id);
     // 相同供货商的商品,一起购买只收一份邮费
     $goodsSupplierService = new GoodsSupplierService();
     // 取得供货商下面的商品总数,总数只缓存 10 分钟
     $supplierTotalGoodsCount = $goodsSupplierService->countSupplierGoodsArray($goodsInfo['suppliers_id'], 600);
     // 随机挑选 10 个商品
     $supplierGoodsSize = 10;
     $supplierGoodsOffset = $supplierTotalGoodsCount <= $supplierGoodsSize ? 0 : mt_rand(0, $supplierTotalGoodsCount - $supplierGoodsSize);
     $supplierGoodsArray = $goodsSupplierService->fetchSupplierGoodsArray($goodsInfo['suppliers_id'], $supplierGoodsOffset, $supplierGoodsSize);
     // 把自己去除掉
     $supplierGoodsKeyExcludeArray = array();
     foreach ($supplierGoodsArray as $supplierGoodsKey => $supplierGoodsItem) {
         if ($supplierGoodsItem['goods_id'] == $goods_id) {
             $supplierGoodsKeyExcludeArray[] = $supplierGoodsKey;
         }
     }
     foreach ($supplierGoodsKeyExcludeArray as $supplierGoodsKey) {
         unset($supplierGoodsArray[$supplierGoodsKey]);
     }
     // 设置商品页面的 SEO 信息
     $smarty->assign('seo_title', $goodsInfo['seo_title'] . ',' . $f3->get('sysConfig[site_name]'));
     $smarty->assign('seo_description', $goodsInfo['seo_description']);
     $smarty->assign('seo_keywords', $goodsInfo['seo_keyword']);
     // 给模板赋值
     $smarty->assign('goodsInfo', $goodsInfo);
     $smarty->assign('goodsPromote', $goodsPromote);
     // 商品购买选择的规格
     if (!empty($goodsInfo['goods_spec'])) {
         $goodsSpecService = new GoodsSpecService();
         $goodsSpecService->initWithJson($goodsInfo['goods_spec']);
         // 只显示有库存的商品规格
         $goodsSpecData = $goodsSpecService->getBuyableData();
         $smarty->assign($goodsSpecData);
         $smarty->assign('goodsSpecJson', json_encode($goodsSpecData));
     }
     // 商品的类型属性
     if ($goodsInfo['type_id'] > 0) {
         $goodsTypeService = new GoodsTypeService();
         $goodsAttrTreeTable = $goodsTypeService->fetchGoodsAttrItemValueTreeTable($goodsInfo['goods_id'], $goodsInfo['type_id']);
         $smarty->assign('goodsAttrTreeTable', $goodsAttrTreeTable);
     }
     if (!empty($goodsCategoryLevelArray)) {
         $smarty->assign('goodsCategoryLevelArray', $goodsCategoryLevelArray);
     }
     if (!Utils::isEmpty($goodsGalleryArray)) {
         $smarty->assign('goodsGalleryArray', $goodsGalleryArray);
     }
     if (!Utils::isEmpty($linkGoodsArray)) {
//.........这里部分代码省略.........
开发者ID:jackycgq,项目名称:bzfshop,代码行数:101,代码来源:View.php


注:本文中的Core\Helper\Utility\Route::makeImageUrl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。