require_once("common.php");
require_once("htmltemplate.inc");
$TemplateFile = TemplateFile;
$MobileFLG = 0;
$html = array();
$html['sitetitle'] = SITETITLE;
$html['mobilesitetitle'] = MOBILESITETITLE;
$html['siteurl'] = SITEURL;
$html['sitedesc'] = SITEDESC;
$html['metadesc'] = METADESC;
$html['metakeyw'] = METAKEYW;
$ContentsMode = $_REQUEST['m'];
$RakutenGenreId = $_REQUEST['g'];
if (!$RakutenGenreId) { $RakutenGenreId = 0; }
$RakutenShopCode = $_REQUEST['shopCode'];
$Page = $_REQUEST['p'];
if (!$Page) { $Page = 1; }
$Sort = $_REQUEST['sort'];
if (!$Sort) { $Sort = "-reviewCount"; }
/* ------------------------------------------------------------
トップメニュー
------------------------------------------------------------ */
$i = 0;
while (list($key,$val) = each($TopMenuNavi)) {
if ($key == "0") {
$html['topmenu'][$i]['url'] = SITEURL;
$html['topmenu'][$i]['title'] = $val;
} else {
if ($HTURL) {
$html['topmenu'][$i]['url'] = SITEURL."list/".$key."/";
} else {
$html['topmenu'][$i]['url'] = SITEURL."?m=list&g=".$key;
}
$html['topmenu'][$i]['title'] = $val;
}
$i++;
}
/* ------------------------------------------------------------
メニュー
------------------------------------------------------------ */
//echo "IN-Genre:".$RakutenGenreId."
";
$ret = Rakuten_MenuList($RakutenGenreId);
//echo_pre(array_to_string('ret',$ret));
//echo "IN-Genre-END
";
$m1 = 0; $m2 = 0; $m3 = 0; $m4 = 0; $m5 = 0;
for ($i=0;$i".$ret[$i]['genreName']."\n";
} else {
$html['search'][$i]['option'] = "\n";
}
}
/* ------------------------------------------------------------
ページ
------------------------------------------------------------ */
function ViewPage($Mode="list", $Genre="", $Keyword="", $ShopCode="") {
global $html, $Page, $Sort, $HTURL, $MobileFLG;
$Keyword = mb_eregi_replace('/','%2F',$Keyword);
switch ($Mode) {
case "list":
if ($Keyword) {
if ($HTURL) {
$filename = "search/".$Genre."/%d/".$Sort."/".urlencode($Keyword)."/";
} else {
$filename = "?m=search&g=".$Genre."&p=%d&sort=".$Sort."&SearchKeyword=".urlencode($Keyword);
}
} else {
if ($HTURL) {
$filename = "list/".$Genre."/%d/".$Sort."/";
} else {
$filename = "?m=list&g=".$Genre."&p=%d&sort=".$Sort;
}
}
break;
case "shop":
if ($HTURL) {
$filename = "shop/".$Genre."/".$ShopCode."/%d/".$Sort."/";
} else {
$filename = "?m=shop&g=".$Genre."&shopCode=".$ShopCode."&p=%d&sort=".$Sort;
}
break;
case "search":
if ($HTURL) {
$filename = "search/".$Genre."/%d/".$Sort."/".urlencode($Keyword)."/";
} else {
$filename = "?m=search&g=".$Genre."&p=%d&sort=".$Sort."&SearchKeyword=".urlencode($Keyword);
}
break;
}
if ($MobileFLG) {
// 携帯
$params = array("perPage"=>10, "totalItems"=>$html['ItemTotalResults'], "currentPage"=>$Page, "fileName"=>$filename, "append"=>FALSE, "prevImg"=>"<", "nextImg"=>">", delta=>5);
} else {
// PC
$params = array("perPage"=>10, "totalItems"=>$html['ItemTotalResults'], "currentPage"=>$Page, "fileName"=>$filename, "append"=>FALSE, "prevImg"=>"前<", "nextImg"=>">次");
}
$o_page = Pager::factory($params);
$ItemPageNavi = $o_page->getLinks();
$html['ItemPageNavi'] = $ItemPageNavi['all'];
// SORT
$SortValue = array(
"reviewCount" => "レビューの少ない順",
"-reviewCount" => "レビューの多い順",
"itemPrice" => "価格(安い順)",
"-itemPrice" => "価格(高い順)",
// "+updateTimestamp" => "商品更新日時順(昇順)",
// "-updateTimestamp" => "商品更新日時順(降順)",
"random" => "ランダム順",
);
$i = 0;
$html['ItemSortNaviM'] = $Mode;
$html['ItemSortNaviG'] = $Genre;
$html['ItemSortNaviS'] = $ShopCode;
$html['ItemSortNaviPage'] = $Page;
$html['ItemSortNaviKeyword'] = $Keyword;
while (list($key,$val) = each($SortValue)) {
if ($Sort == $key) {
$html['ItemSortNaviOpt'][$i]['option'] = "\n";
} else {
$html['ItemSortNaviOpt'][$i]['option'] = "\n";
}
$i++;
}
}
/*----------------------------------------------------------
コンテンツ表示
----------------------------------------------------------*/
// SortのリクエストがreviewCountかitemPriceなら先頭に+をつける
if ($Sort == "reviewCount" || $Sort == "itemPrice") {
$RakutenSort = "+".$Sort;
} else {
$RakutenSort = $Sort;
}
switch ($ContentsMode) {
case "item": // 個別商品
$RakutenItemCode = $_REQUEST['itemCode'];
// 表示中のページURL
if ($HTURL) {
$html['ThisPageUrl'] = SITEURL."item/".$RakutenGenreId."/".$RakutenItemCode."/";
} else {
$html['ThisPageUrl'] = SITEURL."?m=item&g=".$RakutenGenreId."&itemCode=".$RakutenItemCode;
}
// リクエスト
$html = array_merge_recursive($html, Rakuten_ItemCodeSearch($RakutenItemCode, $MobileFLG));
$html['pagetitle'] = $html['Item']['itemName']." - ".Rakuten_GenreName($RakutenGenreId)." - ".SITETITLE;
break;
case "shop": // ショップ検索
// 表示中のページURL
if ($HTURL) {
$html['ThisPageUrl'] = SITEURL."shop/".$RakutenGenreId."/".$RakutenShopCode."/".$Page."/".$Sort."/";
} else {
$html['ThisPageUrl'] = SITEURL."?m=shop&g=".$RakutenGenreId."&shopCode=".$RakutenShopCode."&p=".$Page."&sort=".$Sort;
}
// リクエスト
$html = array_merge_recursive($html, Rakuten_ItemSearch('', $RakutenShopCode, $RakutenGenreId, $Page, $RakutenSort, $MobileFLG));
ViewPage("shop", $RakutenGenreId, "", $RakutenShopCode);
$html['ItemKeyword'] = $html['List'][0]['shopName'];
$html['pagetitle'] = $html['ItemKeyword']." - ".SITETITLE;
// $html['ItemKeyword'] = $RakutenShopCode;
// $html['pagetitle'] = $html['ItemKeyword']." - ".SITETITLE;
break;
case "search": // 検索
if ($_GET['SearchKeyword']) { $SearchKeyword = urldecode($_GET['SearchKeyword']);
} elseif ($_POST['SearchKeyword']) { $SearchKeyword = $_POST['SearchKeyword'];
} else { $SearchKeyword = ""; }
if ($SearchKeyword && get_magic_quotes_gpc()) {
$SearchKeyword = stripslashes($SearchKeyword);
}
// 表示中のページURL
if ($HTURL) {
$html['ThisPageUrl'] = SITEURL."search/".$RakutenGenreId."/".$Page."/".$Sort."/".urlencode($SearchKeyword)."/";
} else {
$html['ThisPageUrl'] = SITEURL."?m=search&g=".$RakutenGenreId."&p=".$Page."&sort=".$Sort."&SearchKeyword=".urlencode($SearchKeyword);
}
// リクエスト
$html = array_merge_recursive($html, Rakuten_ItemSearch($SearchKeyword, $RakutenShopCode, $RakutenGenreId, $Page, $RakutenSort, $MobileFLG));
ViewPage("search", $RakutenGenreId, $SearchKeyword);
$html['ItemKeyword'] = $SearchKeyword." - ".Rakuten_GenreName($RakutenGenreId);
$html['SearchKeyword'] = $SearchKeyword;
$html['pagetitle'] = $html['ItemKeyword']." - ".SITETITLE;
break;
case "list": // 一覧
// 表示中のページURL
if ($HTURL) {
$html['ThisPageUrl'] = SITEURL."list/".$RakutenGenreId."/".$Page."/".$Sort."/";
} else {
$html['ThisPageUrl'] = SITEURL."?m=list&g=".$RakutenGenreId."&p=".$Page."&sort=".$Sort;
}
// リクエスト
$html = array_merge_recursive($html, Rakuten_ItemSearch('', $RakutenShopCode, $RakutenGenreId, $Page, $RakutenSort, $MobileFLG));
ViewPage("list", $RakutenGenreId, "");
$html['ItemKeyword'] = Rakuten_GenreName($RakutenGenreId);
$html['pagetitle'] = $html['ItemKeyword']." - ".SITETITLE;
break;
default:
// TOPのノード
if (count($TopItemIndex) > 0) {
list($key,$val) = each($TopItemIndex);
$html = array_merge_recursive($html, Rakuten_ItemSearch($val,'',$key, $Page, $RakutenSort, $MobileFLG));
ViewPage("list", $key, $val);
if ($val) { $html['ItemKeyword'] = $val;
} elseif ($key) { $html['ItemKeyword'] = Rakuten_GenreName($key);
} else { $html['ItemKeyword'] = ""; }
}
$html['pagetitle'] = SITETITLE;
}
if ($MobileFLG) {
$html = array_to_kana($html);
}
HtmlTemplate::t_include($TemplateFile, $html);
?>