本文整理匯總了PHP中Core\Helper\Utility\Route類的典型用法代碼示例。如果您正苦於以下問題:PHP Route類的具體用法?PHP Route怎麽用?PHP Route使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Route類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: 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);
}
示例2: preparePage
private function preparePage($goods_id, $pageNo)
{
global $smarty;
// 設置缺省值
$pageNo = isset($pageNo) && $pageNo > 0 ? $pageNo : 0;
$pageSize = 10;
// 每頁顯示 10 個
// 查詢條件
$condArray = array();
$condArray[] = array('goods_id = ?', $goods_id);
$condArray[] = array('is_show = 1');
$baseService = new BaseService();
$totalCount = $baseService->_countArray('goods_comment', $condArray);
if ($totalCount <= 0) {
// 沒數據,可以直接退出了
return;
}
// 頁數超過最大值
if ($pageNo * $pageSize >= $totalCount) {
return;
}
// 查詢數據
$goodsCommentArray = $baseService->_fetchArray('goods_comment', '*', $condArray, array('order' => 'comment_id desc'), $pageNo * $pageSize, $pageSize);
// 給 smarty 賦值
$smarty->assign('currentUrl', RouteHelper::makeUrl('/Ajax/GoodsComment', array('goods_id' => $goods_id)));
$smarty->assign('totalCount', $totalCount);
$smarty->assign('pageNo', $pageNo);
$smarty->assign('pageSize', $pageSize);
$smarty->assign('goodsCommentArray', $goodsCommentArray);
}
示例3: get
public function get($f3)
{
// 設置 order_refer 記錄,記錄在客戶端
$orderRefer = array();
// 檢查彩貝的記錄
$caibeiRefer = $f3->get('SESSION[yiqifa_caibei_order_refer]');
if (!empty($caibeiRefer)) {
$orderRefer = $caibeiRefer;
unset($orderRefer['refer_host']);
// 去掉彩貝的 refer_host
}
// 清除彩貝記錄
$f3->set('SESSION[yiqifa_caibei_order_refer]', null);
$orderRefer['utm_source'] = 'YIQIFACPS';
// 保存額外的 億起發 參數
$validator = new Validator($_REQUEST);
$referParamArray = array();
$referParamArray['src'] = $validator->validate('src');
$referParamArray['cid'] = $validator->validate('cid');
$referParamArray['wi'] = $validator->validate('wi');
$referParamArray['channel'] = $validator->validate('channel');
$orderRefer['refer_param'] = json_encode($referParamArray);
//設置 cookie
ReferHelper::setOrderReferSpecific($f3, $orderRefer, YiqifaCpsPlugin::getOptionValue('yiqifacps_duration'));
// 頁麵跳轉到商品
$url = $validator->validate('url');
$redirectUrl = empty($url) ? '/' : $url;
RouteHelper::reRoute($this, $redirectUrl);
return;
}
示例4: get
/**
* 360 一站通登陸
*/
public function get($f3)
{
// 標準動態鏈接,不能偽靜態地址
$callback = RouteHelper::makeUrl('/Thirdpart/Dev360Auth/Callback', null, false, true, false);
$params = array('client_id' => Dev360AuthPlugin::getOptionValue(self::$optionKeyPrefix . 'dev360auth_app_key'), 'redirect_uri' => $callback, 'response_type' => 'code');
$url = 'https://openapi.360.cn/oauth2/authorize?' . http_build_query($params);
header("Location: {$url}");
}
示例5: get
public function get($f3)
{
AuthHelper::removeAuthUser();
$f3->clear('SESSION');
$this->addFlashMessage('成功退出登陸');
// 返回首頁
RouteHelper::reRoute($this, '/', false);
}
示例6: 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, '/');
// 返回首頁
}
示例7: smarty_helper_function_make_url
/**
* 用於生成係統的操作鏈接,符合係統 URL 調用規範
*
* 在模板中的使用方法 {{makeUrl controller='/User/Login' username='xxx' password='xxx' }}
*
* 必須要有 controller 用於指定控製器,其它參數可以沒有
*
* */
function smarty_helper_function_make_url(array $paramArray, $smarty)
{
$controller = isset($paramArray['controller']) ? $paramArray['controller'] : '/Error/E404';
$static = isset($paramArray['static']) ? $paramArray['static'] : null;
// 去除 controller, static ,其它都是控製器的參數
unset($paramArray['controller']);
unset($paramArray['static']);
return RouteHelper::makeUrl($controller, $paramArray, false, false, $static);
}
示例8: post
public function post($f3)
{
global $smarty;
// 首先做參數合法性驗證
$validator = new Validator($f3->get('POST'));
$input = array();
$input['user_name'] = $validator->required('用戶名不能為空')->minLength(2, '用戶名最短為2個字符')->validate('user_name');
$input['password'] = $validator->required('密碼不能為空')->minLength(6, '密碼最短為6個非空字符')->validate('password');
$input['email'] = $validator->validate('email');
$input['mobile_phone'] = $validator->digits('手機號格式不對')->validate('mobile_phone');
$p_captcha = $validator->required('驗證碼不能為空')->validate('captcha');
// 手機輸入,輸入法經常無故添加空格,我們需要去除所有的空額,防止出錯
$p_captcha = Utils::filterAlnumStr($p_captcha);
// 需要跳轉回去的地址
$returnUrl = $validator->validate('returnUrl');
if (!$this->validate($validator)) {
goto out_fail;
}
// 檢查驗證碼是否有效
$captchaController = new \Controller\Image\Captcha();
if (!$captchaController->validateCaptcha($p_captcha)) {
$this->addFlashMessage('驗證碼錯誤[' . $p_captcha . '][' . $captchaController->getCaptcha() . ']');
goto out_fail;
}
$userService = new UserService();
// 檢查用戶是否已經注冊
$isUserExist = $userService->isUserExist($input['user_name'], $input['email']);
if ($isUserExist) {
$this->addFlashMessage($isUserExist . '已經存在');
goto out_fail;
}
// 注冊用戶
$user = $userService->registerUser($input);
if (!$user) {
$this->addFlashMessage('用戶注冊失敗,請稍後刷新頁麵重試');
goto out_fail;
}
// 記錄用戶的登陸信息
$userInfo = $user->toArray();
unset($userInfo['password']);
// 不要記錄密碼
AuthHelper::saveAuthUser($userInfo, 'normal');
$this->addFlashMessage("注冊成功");
if ($returnUrl) {
header('Location:' . $returnUrl);
return;
} else {
// 跳轉到用戶之前看的頁麵,如果之前沒有看過的頁麵那就回到首頁
RouteHelper::jumpBack($this, '/', true);
}
return;
// 這裏正常返回
out_fail:
// 失敗,從這裏出口
$smarty->assign('captchaUrl', RouteHelper::makeUrl('/Image/Captcha', array('hash' => time())));
$smarty->display('user_register.tpl', 'User|Register|post');
}
示例9: pluginGetConfigureUrl
public function pluginGetConfigureUrl($system)
{
// manage 係統可以配置這個插件
if (PluginHelper::SYSTEM_MANAGE === $system) {
return RouteHelper::makeUrl('/Theme/Shop/Index');
}
// 其它係統不需要配置
return null;
}
示例10: beforeRoute
public function beforeRoute($f3)
{
parent::beforeRoute($f3);
// 用戶沒有登陸,讓用戶去登陸
if (!AuthHelper::isAuthUser()) {
// 如果已經記錄了一個回跳 URL ,則不要再覆蓋這個記錄了
RouteHelper::reRoute($this, '/User/Login', !RouteHelper::hasRememberUrl());
}
}
示例11: get
/**
* QQ 登陸
*/
public function get($f3)
{
$callback = RouteHelper::makeUrl('/Thirdpart/QQAuth/Callback', null, false, true);
$qqLoginState = md5(uniqid(rand(), true));
// 防止 csrf 攻擊
$f3->set('SESSION[qq_login_state]', $qqLoginState);
$loginUrl = "https://graph.qq.com/oauth2.0/authorize?response_type=code&client_id=" . QQAuthPlugin::getOptionValue('qqauth_appid') . "&redirect_uri=" . urlencode($callback) . "&state=" . $qqLoginState . "&scope=get_user_info";
header("Location:{$loginUrl}");
}
示例12: get
public function get($f3)
{
AdminLog::logAdminOperate('user.logout', '用戶退出', 'IP:' . $f3->get('IP'));
AuthHelper::removeAuthUser();
$f3->clear('SESSION');
$this->addFlashMessage('成功退出登陸');
// 刷新當前頁麵
RouteHelper::reRoute($this, '/', false);
}
示例13: get
public function get($f3)
{
global $smarty;
$smartyCacheId = 'EtaoFeed|' . md5(__NAMESPACE__ . '\\' . __CLASS__ . '_\\' . __METHOD__);
// 判斷是否有緩存
enableSmartyCache(true, 1200);
// 緩存 20 分鍾
if ($smarty->isCached('empty.tpl', $smartyCacheId)) {
goto out_display;
}
$currentStamp = Time::localTimeStr();
$sellerId = EtaoFeedPlugin::getOptionValue('etaofeed_seller_id');
$categoryUrl = RouteHelper::makeUrl('/Thirdpart/EtaoFeed/Category', null, false, true);
$itemDir = RouteHelper::makeUrl('/Thirdpart/EtaoFeed/Item', null, false, true);
$itemIdXmlList = '';
// 處理 delete 的商品
$currentThemeInstance = ThemeHelper::getCurrentSystemThemeInstance();
$totalGoodsCount = SearchHelper::count(SearchHelper::Module_Goods, array(array('is_on_sale = 0'), array('update_time', '>=', EtaoFeedPlugin::getOptionValue('etaofeed_query_timestamp')), array(QueryBuilder::buildGoodsFilterForSystem($currentThemeInstance->getGoodsFilterSystemArray()))));
if ($totalGoodsCount <= 0) {
goto query_update_goods;
}
$totalPageCount = ceil($totalGoodsCount / Item::$pageSize);
for ($index = 0; $index < $totalPageCount; $index++) {
$itemIdXmlList .= '<outer_id action="delete">1' . $index . '</outer_id>';
}
query_update_goods:
// 處理修改過的商品
$totalGoodsCount = SearchHelper::count(SearchHelper::Module_Goods, array(array('is_on_sale = 1'), array('update_time', '>=', EtaoFeedPlugin::getOptionValue('etaofeed_query_timestamp')), array(QueryBuilder::buildGoodsFilterForSystem($currentThemeInstance->getGoodsFilterSystemArray()))));
if ($totalGoodsCount <= 0) {
goto out_output;
}
$totalPageCount = ceil($totalGoodsCount / Item::$pageSize);
for ($index = 0; $index < $totalPageCount; $index++) {
$itemIdXmlList .= '<outer_id action="upload">2' . $index . '</outer_id>';
}
out_output:
$apiXml = <<<XML
<?xml version="1.0" encoding="utf-8" ?>
<root>
<version>1.0</version>
<modified>{$currentStamp}</modified>
<seller_id>{$sellerId}</seller_id>
<cat_url>{$categoryUrl}</cat_url>
<dir>{$itemDir}/</dir>
<item_ids>{$itemIdXmlList}</item_ids>
</root>
XML;
$smarty->assign('outputContent', $apiXml);
// 更新查詢時間
//EtaoFeedPlugin::saveOptionValue('etaofeed_query_timestamp', Time::gmTime());
out_display:
header('Content-Type:text/xml;charset=utf-8');
header("Cache-Control: no-cache, must-revalidate");
// HTTP/1.1 //查詢信息
$smarty->display('empty.tpl', $smartyCacheId);
}
示例14: post
public function post($f3)
{
global $smarty;
// 首先做參數合法性驗證
$validator = new Validator($f3->get('POST'));
$input = array();
$input['user_name'] = $validator->required('用戶名不能為空')->validate('user_name');
$input['password'] = $validator->required('密碼不能為空')->validate('password');
$p_captcha = $validator->required('驗證碼不能為空')->validate('captcha');
if (!$this->validate($validator)) {
goto out_fail;
}
// 檢查驗證碼是否有效
$captchaController = new \Controller\Image\Captcha();
if (!$captchaController->validateCaptcha($p_captcha)) {
$this->addFlashMessage("驗證碼錯誤");
goto out_fail;
}
$adminService = new AdminUserService();
// 驗證用戶登陸
$admin = $adminService->doAuthAdmin($input['user_name'], $input['user_name'], $input['password']);
if (!$admin) {
$this->addFlashMessage("登陸失敗,用戶名、密碼錯誤");
goto out_fail;
}
// 記錄用戶的登陸信息
$adminUserInfo = $admin->toArray();
unset($adminUserInfo['password']);
// 不要記錄密碼
// 取得用戶的角色權限
$adminUserInfo['role_action_list'] = '';
if ($adminUserInfo['role_id'] > 0) {
$metaRoleService = new MetaRoleService();
$role = $metaRoleService->loadRoleById($adminUserInfo['role_id']);
if (!$role->isEmpty()) {
// 賦值角色權限
$adminUserInfo['role_action_list'] = $role['meta_data'];
}
}
AuthHelper::saveAuthUser($adminUserInfo);
try {
// 記錄用戶登錄日誌
AdminLog::logAdminOperate('user.login', '用戶登錄', 'IP:' . $f3->get('IP'));
} catch (\Exception $e) {
// do nothing
}
$this->addFlashMessage("登陸成功");
// 跳轉到用戶之前看的頁麵,如果之前沒有看過的頁麵那就回到首頁
RouteHelper::jumpBack($this, '/', true);
return;
// 這裏正常返回
out_fail:
// 失敗從這裏入口
$smarty->display('user_login.tpl', 'User|Login|post');
}
示例15: post
public function post($f3)
{
// 權限檢查
$this->requirePrivilege('manage_plugin_theme_configure');
// 保存數據
ShopThemePlugin::saveOptionValue('head_nav_json_data', json_encode($f3->get('POST[headNav]')));
// 清除 所有頁麵
$shopClear = new ShopClear();
$shopClear->clearAllCache();
$this->addFlashMessage('保存設置成功');
RouteHelper::reRoute($this, '/Theme/Shop/HeadNav');
}