本文整理匯總了PHP中Core\Helper\Utility\Route::makeShopSystemUrl方法的典型用法代碼示例。如果您正苦於以下問題:PHP Route::makeShopSystemUrl方法的具體用法?PHP Route::makeShopSystemUrl怎麽用?PHP Route::makeShopSystemUrl使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Core\Helper\Utility\Route
的用法示例。
在下文中一共展示了Route::makeShopSystemUrl方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: smarty_helper_function_make_system_url
/**
* 用於生成係統的操作鏈接,符合係統 URL 調用規範
*
* 在模板中的使用方法 {{makeUrl controller='/User/Login' username='xxx' password='xxx' }}
*
* 必須要有 controller 用於指定控製器,其它參數可以沒有
*
* */
function smarty_helper_function_make_system_url(array $paramArray, $smarty)
{
$system = isset($paramArray['system']) ? $paramArray['system'] : '';
$controller = isset($paramArray['controller']) ? $paramArray['controller'] : '/Error/E404';
$static = isset($paramArray['static']) ? $paramArray['static'] : null;
if (empty($system)) {
return '';
}
// 去除 system,controller, static ,其它都是控製器的參數
unset($paramArray['system']);
unset($paramArray['controller']);
unset($paramArray['static']);
return RouteHelper::makeShopSystemUrl($system, $controller, $paramArray, $static);
}
示例2: get
public function get($f3)
{
global $smarty;
// 生成 smarty 的緩存 id
$smartyCacheId = 'Shop|Index';
// 開啟並設置 smarty 緩存時間
enableSmartyCache(true, bzf_get_option_value('smarty_cache_time_shop_index'));
if ($smarty->isCached('shop_index.tpl', $smartyCacheId)) {
goto out_display;
}
// 滑動圖片廣告
$shop_index_adv_slider = json_decode(bzf_get_option_value('shop_index_adv_slider'), true);
if (!empty($shop_index_adv_slider)) {
$smarty->assign('shop_index_adv_slider', $shop_index_adv_slider);
}
// 今日新品
$recommandGoodsArray = SearchHelper::search(SearchHelper::Module_Goods, $this->searchFieldSelector, $this->searchExtraCondArray, array(array('goods_id', 'desc')), 0, 40);
if (!empty($recommandGoodsArray)) {
$smarty->assign('recommandGoodsArray', $recommandGoodsArray);
}
// 廣告 advBlock
$shop_index_advblock_json_data = json_decode(bzf_get_option_value('shop_index_advblock_json_data'), true);
if (!empty($shop_index_advblock_json_data)) {
// 生成隨機的 id 號給 html 使用
foreach ($shop_index_advblock_json_data as &$advBlockObject) {
$advBlockObject['id'] = Utils::generateRandomHtmlId();
foreach ($advBlockObject['advBlockImageArray'] as &$advBlockImage) {
$advBlockImage['id'] = Utils::generateRandomHtmlId();
}
}
$smarty->assign('shop_index_advblock_json_data', $shop_index_advblock_json_data);
}
// 移動端對應的 URL,用於百度頁麵適配
$smarty->assign('currentPageMobileUrl', RouteHelper::makeShopSystemUrl(PluginHelper::SYSTEM_MOBILE, '/'));
out_display:
$smarty->assign('seo_title', $smarty->getTemplateVars('seo_title') . ',' . $f3->get('HOST'));
$smarty->display('shop_index.tpl', $smartyCacheId);
}
示例3: smarty_helper_function_goods_view_toolbar
/**
* 生成商品查看的 toolbar,用戶可以查看 團購、商城、移動
*
* @param array $paramArray
* @param $smarty
*
* @return string
*/
function smarty_helper_function_goods_view_toolbar(array $paramArray, $smarty)
{
$goods_id = isset($paramArray['goods_id']) ? intval($paramArray['goods_id']) : 0;
$system_tag_list = isset($paramArray['system_tag_list']) ? $paramArray['system_tag_list'] : '';
// 參數不對,沒有東西可以輸出
if ($goods_id <= 0) {
return 'goods_id [' . $goods_id . '] 非法';
}
// 如果不提供 system_tag_list 參數,我們從數據庫查詢
if (!array_key_exists('system_tag_list', $paramArray)) {
static $goodsBasicService = null;
if (!$goodsBasicService) {
$goodsBasicService = new GoodsBasicService();
}
// 緩存 5 秒鍾
$goods = $goodsBasicService->loadGoodsById($goods_id, 5);
if (!$goods->isEmpty()) {
$system_tag_list = $goods['system_tag_list'];
} else {
return 'goods_id [' . $goods_id . '] 非法';
}
}
// 解析成 System Array
$systemArray = \Core\Helper\Utility\Utils::parseTagString($system_tag_list);
$htmlContent = '<div class="btn-group">';
$system_url_base_array = json_decode(\Theme\Manage\ManageThemePlugin::getOptionValue('system_url_base_array'), true);
if (!empty($system_url_base_array)) {
foreach ($systemArray as $system) {
if (!array_key_exists($system, $system_url_base_array)) {
// 不存在的係統,跳過
continue;
}
$themeSystem = $system_url_base_array[$system];
$htmlContent .= '<a title="查看' . $themeSystem['name'] . '商品詳情" target="_blank" href="' . RouteHelper::makeShopSystemUrl($system, '/Goods/View', array('goods_id' => $goods_id)) . '" class="btn btn-mini btn-info">' . $themeSystem['name'] . '</a>';
}
}
$htmlContent .= '</div>';
return htmlspecialchars($htmlContent);
}
示例4: get
//.........這裏部分代碼省略.........
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)) {
$smarty->assign('linkGoodsArray', $linkGoodsArray);
}
if (!Utils::isEmpty($supplierGoodsArray)) {
$smarty->assign('supplierGoodsArray', $supplierGoodsArray);
}
// 滑動圖片廣告
$goods_view_adv_slider = json_decode(bzf_get_option_value('goods_view_adv_slider'), true);
if (!empty($goods_view_adv_slider)) {
$smarty->assign('goods_view_adv_slider', $goods_view_adv_slider);
}
// 移動端對應的 URL,用於百度頁麵適配
$smarty->assign('currentPageMobileUrl', RouteHelper::makeShopSystemUrl(PluginHelper::SYSTEM_MOBILE, '/Goods/View', array('goods_id' => $goods_id)));
out_display:
$smarty->display('goods_view.tpl', $smartyCacheId);
return;
out_fail:
// 失敗從這裏返回
RouteHelper::reRoute($this, '/');
// 返回首頁
}