Example #1
0
 /**
  * 根据 parseStaticUrl 的结果重新拼接 URL
  *
  * @param array $urlInfo
  *
  * @return string
  */
 public static function makeStaticUrl($urlInfo)
 {
     if (empty($urlInfo) || !is_array($urlInfo)) {
         return '';
     }
     // 非静态化 URL
     if (!self::$isMakeStaticUrl) {
         return (isset($urlInfo['shceme']) ? $urlInfo['shceme'] . '://' . @$urlInfo['host'] . ('80' == @$urlInfo['port'] ? '' : @$urlInfo['port']) : '') . @$urlInfo['path'] . (isset($urlInfo['query']) ? '?' . $urlInfo['query'] : '') . (isset($urlInfo['fragment']) ? '#' . $urlInfo['fragment'] : '');
     }
     // URL 静态化,需要特殊处理
     // Trick,由于 makeUrl 会自动添加 session_id,我们这里需要临时禁止它
     $old = Route::$enableSessionIdUrl;
     Route::$enableSessionIdUrl = false;
     $staticUrl = (isset($urlInfo['shceme']) ? $urlInfo['shceme'] . '://' . @$urlInfo['host'] . ('80' == @$urlInfo['port'] ? '' : @$urlInfo['port']) : '') . @$urlInfo['path_base'] . self::makeUrl(@$urlInfo['path_controller'], @$urlInfo['path_param_array'], true) . (isset($urlInfo['query']) ? '?' . $urlInfo['query'] : '') . (isset($urlInfo['fragment']) ? '#' . $urlInfo['fragment'] : '');
     Route::$enableSessionIdUrl = $old;
     return $staticUrl;
 }
Example #2
0
 public function get($f3)
 {
     // 关闭 session_id 的输出
     RouteHelper::$enableSessionIdUrl = false;
     // 解析传入的 fileName, 文件名的格式应该是 bangzhufu_2012100112_1.xml,最后的数字为页号
     $fileName = $f3->get('PARAMS.fileName');
     //去掉文件扩展名
     $fileName = substr($fileName, 0, strrpos($fileName, '.'));
     $fileNamePart = explode('_', $fileName);
     $fileNamePartSize = count($fileNamePart);
     // 这里定义文件名对应的输出函数
     $fileNameToMethodArray = array('GoodsSearch' => 'outputGoodsSearchListXml', 'GoodsView' => 'outputGoodsViewListXml');
     // 如果不符合文件结构,则输出 sitemap.xml
     if ($fileNamePartSize <= 0 || !is_numeric($fileNamePart[$fileNamePartSize - 1]) || !in_array($fileNamePart[0], array_keys($fileNameToMethodArray))) {
         $this->outputSiteMapXml($f3, $fileName);
         return;
     }
     // 输出每页的API数据
     $pageNo = abs(intval($fileNamePart[$fileNamePartSize - 1]));
     $pageNo = $pageNo > 0 ? $pageNo : 0;
     $methodName = $fileNameToMethodArray[$fileNamePart[0]];
     // 调用对应的输出函数
     call_user_func_array(array($this, $methodName), array($f3, $pageNo));
 }