本文整理匯總了PHP中Core\Helper\Utility\Route::addParam方法的典型用法代碼示例。如果您正苦於以下問題:PHP Route::addParam方法的具體用法?PHP Route::addParam怎麽用?PHP Route::addParam使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Core\Helper\Utility\Route
的用法示例。
在下文中一共展示了Route::addParam方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: 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;
}
示例2: doMobileAction
/**
*
* 為 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: smarty_helper_function_paginator
/**
* 生成分頁欄,用法:{{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) . '"><<</a>';
} else {
if ($pageEnd == $pageIndex) {
$link = '<a href="' . RouteHelper::addParam($currentUrl, array('pageNo' => $pageIndex), true) . '">>></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 . ' 頁數:' . ($pageNo + 1) . '/' . $totalPage . ')</span><ul>' . $paginator . '</ul>';
}
示例4: 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;
}
示例5: reRoute
/**
* 路由到另外的頁麵
*
* @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);
}
示例6: smarty_helper_function_paginator
/**
* 生成分頁欄,用法:{{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>';
}