err_no == 0) {
$locomill->start();
$ShopSch = new Shop_Search($locomill->connect);
$attr = new Shop_Attribute($locomill->connect);
$locomill->loadModel('area1');
$locomill->loadModel('area2');
$locomill->loadModel('shop_category');
$locomill->loadModel('shop_tag');
$locomill->loadModel('gift');
$locomill->loadModel('shop');
$locomill->loadModel("shop_timer");
$locomill->loadModel("shop_page");
$locomill->loadModel('shop_coupon');
$locomill->call('shops');
$locomill->loadModel("plus_group");
} else {
redirect(null, 500);
}
header("Expires: -1");
$area1_list = $locomill->Area1->area_list;
$area2_list = $locomill->Area2->area_list;
$locomill->ShopCategory->setSuffix(1);
$category1_array = $locomill->ShopCategory->find('list',
array('conditions' => array('cat1_enable' => 1),
'order' => 'position,cat1_id'));
$sort_array = array();
$sort_array['update'] = "情報更新順";
$sort_array['newest'] = "掲載開始順";
$sort_array['grapevine'] = "クチコミ数順";
$locomill->assign("LCM_TAG_SORT_ARRAY", $sort_array);
if (!empty($_GET['search_specific_time'])) {
if (strstr($_GET['search_specific_time'], ':')) {
$temp = explode(':', $_GET['search_specific_time']);
$_GET['search_specific_time_hour'] = (int)$temp[0];
$_GET['search_specific_time_minute'] = (int)$temp[1];
} else {
$_GET['search_specific_time_hour'] = $_GET['search_specific_time'];
}
}
$param_list = array('page' => 'int',
'sort' => 'alnum',
'offset' => 'int',
'format' => 'alnum',
'q' => 'string',
'search_active_time' => 'alnum',
'search_price' => 'int',
'search_pricemin' => 'int',
'search_pricemax' => 'int',
'search_parking_type' => 'alnum',
'search_service' => 'int',
'search_area' => 'alnum',
'search_area1' => 'int',
'search_area2' => 'int',
'search_category' => 'alnum',
'search_category1' => 'int',
'search_category2' => 'int',
'search_category3' => 'int',
'search_grapevine_num' => 'int',
'search_open_time' => 'int',
'search_close_time' => 'int',
'search_over_time' => 'int',
'search_specific_week' => 'int',
'search_specific_time_hour' => 'int',
'search_specific_time_minute' => 'int',
'search_time' => 'int',
'search_news' => 'alnum',
't' => 'int',
'tg' => 'int',
'sw_lat' => 'float',
'ne_lat' => 'float',
'sw_lng' => 'float',
'ne_lng' => 'float',
'lat' => 'float',
'lng' => 'float',
);
$pVal = Sanitize::normalize($_GET, $param_list);
$imakoko = $title = $search_array = array();
$shop_tag_array = $locomill->ShopTag->find('all',array('conditions' => array('available' => true)));
$locomill->assign("LCM_TAG_SHOP_TAG_ARRAY", $shop_tag_array);
// POST値の検証
$sort = "";
if (!empty($pVal['sort']) && isset($sort_array[$pVal['sort']])) {
$sort = $pVal['sort'];
}
$page = $locomill->param['page'];
//offset = 1 ~ offset(page * limit) 件数
$offset = 1;
if ($page == 1 && !empty($pVal['offset']) && 1 < $pVal['offset']){
$offset = (100 <= $pVal['offset'])? 100: $pVal['offset'];
}
//出力モード
$format = "";
if (!empty($pVal['format'])){
$format = $pVal['format'];
unset($pVal['format']);
unset($pVal['amp;format']);
}
$cond = array(
'search_enable' => 1,
'exclusion_state' => 1,
);
// ワード
$imakoko['word'] = "";
if (!empty($pVal['q'])) {
$cond['q'] = $imakoko['word'] = $pVal['q'];
}
// 駐車場
$imakoko['parking'] = "";
if (!empty($pVal['search_parking_type']) && is_array($pVal['search_parking_type'])) {
$imakoko['parking'] = "駐車場あり";
if (in_array('F',$pVal['search_parking_type'])){
$imakoko['parking'] = $imakoko['parking']. ' 無料';
}
if (in_array('P',$pVal['search_parking_type'])){
$imakoko['parking'] = $imakoko['parking']. ' 有料';
}
$cond['search_parking_type'] = $pVal['search_parking_type'];
}
// クチコミ**以上
$imakoko['grapevine'] = '';
if (!empty($pVal['search_grapevine_num']) && 0 < $pVal['search_grapevine_num']) {
$cond['search_grapevine_num'] = $pVal['search_grapevine_num'];
$cond['search_grapevine_disp'] = $pVal['search_grapevine_num'];
$imakoko['grapevine'] = $cond['search_grapevine_num'];
}
// エリア1、エリア2
$area1 = $area2 = 0;
//単一選択がある(true)場合、複数選択は無効
if (!empty($pVal['search_area'])){
unset($pVal['search_area1']);
unset($pVal['search_area2']);
list($area1, $area2) = explode('_', $pVal['search_area']);;
if ($area1 == 'a1') {
$cond['search_area1'] = array((int)$area2);
$cond['search_area2'] = array();
} else if ($area1 == "a2") {
$cond['search_area1'] = array();
$cond['search_area2'] = array((int)$area2);
}
}
if (!empty($pVal['search_area1'])) {
$cond['search_area1'] = (array)$pVal['search_area1'];
}
if (!empty($pVal['search_area2'])) {
$cond['search_area2'] = (array)$pVal['search_area2'];
}
$imakoko['area1'] = '';
if (!empty($cond['search_area1'])) {
foreach ( $cond['search_area1'] as $k => $v ) {
$cond['search_area1'][$k] = (int) $v;
if (isset($area1_list[$v])) {
$imakoko['area1'] .= $area1_list[$v] . ' ';
}
}
$title['area1_name'] = (count($cond['search_area1']) === 1)? trim($imakoko['area1']): false;
}
$imakoko['area2'] = '';
if (!empty($cond['search_area2'])) {
foreach ( $cond['search_area2'] as $k => $v ) {
if (isset($area2_list[$v])) {
$imakoko['area2'] .= $area2_list[$v] . ' ';
}
}
$title['area2_name'] = (count($cond['search_area2']) === 1)? trim($imakoko['area2']): false;
}
// カテゴリ2、カテゴリ3
$imakoko['search_category1'] = 0;
$imakoko['search_category2'] = 0;
$imakoko['search_category3'] = 0;
$title['category1_name'] = '';
//単一選択がある(true)場合、複数選択は無効
if (!empty($pVal['search_category'])){
unset($pVal['search_category1']);
unset($pVal['search_category2']);
unset($pVal['search_category3']);
list($category2, $category3) = explode('_', $pVal['search_category']);;
if ($category2 == 'c1') {
$cond['search_category1'] = array($category3);
} else if ($category2 == 'c2') {
$cond['search_category2'] = array($category3);
} else if ($category2 == "c3") {
$cond['search_category3'] = array($category3);
}
}
if (!empty($pVal['search_category1'])) {
$cond['search_category1'] = (array)$pVal['search_category1'];
}
if (!empty($pVal['search_category2'])) {
$cond['search_category2'] = (array)$pVal['search_category2'];
}
if (!empty($pVal['search_category3'])) {
$cond['search_category3'] = (array)$pVal['search_category3'];
}
$imakoko['category1'] = '';
if (!empty($cond['search_category1'])) {
foreach ( $cond['search_category1'] as $k => $v ) {
$cond['search_category1'][$k] = (int) $v;
$imakoko['category1'] .= $locomill->ShopCategory->name($v, 1). ' ';
}
$title['category1_name'] = (count($cond['search_category1']) === 1)? trim($imakoko['category1']): '';
}
$imakoko['category2'] = '';
if (!empty($cond['search_category2'])) {
foreach ( $cond['search_category2'] as $k => $v ) {
$cond['search_category2'][$k] = (int) $v;
$imakoko['category2'] .= $locomill->ShopCategory->name($v, 2) . ' ';
}
$title['category2_name'] = (count($cond['search_category2']) === 1)? trim($imakoko['category2']): '';
unset($category2_array);
}
$imakoko['category3'] = '';
if (!empty($cond['search_category3'])) {
foreach ( $cond['search_category3'] as $k => $v ) {
$cond['search_category3'][$k] = (int) $v;
$imakoko['category3'] .= $locomill->ShopCategory->name($v, 3) . ' ';
}
$title['category3_name'] = (count($cond['search_category3']) === 1)? trim($imakoko['category3']): '';
unset($category3_array);
}
// タイトル
$title['area_name'] = (!empty($title['area1_name']) && empty($title['area2_name']))? $title['area1_name']: ((!empty($title['area2_name']) && empty($title['area1_name']))? $title['area2_name']: '');
$title['category_name'] = (!empty($title['category3_name']))? $title['category3_name']: (!empty($title['category2_name'])? $title['category2_name']: $title['category1_name']);
$title['exists'] = (!empty($title['area_name']) || !empty($title['category_name']))? true: false;
$title['separator'] = (!empty($title['area_name']) && !empty($title['category_name']))? '/': '';
// サービス
$imakoko['service'] = '';
if (!empty($pVal['search_service'])) {
$locomill->loadModel('shop_service');
$service_array = $locomill->ShopService->find('all', array('conditions' => array('svc_enable' => 1)));
$cond['search_service'] = (array)$pVal['search_service'];
foreach ( $cond['search_service'] as $k => $v ) {
if (isset($service_array[$v])) {
$imakoko['service'] .= $service_array[$v]['svc_name'] . ' ';
}
}
}
// 価格
$imakoko['price'] = '';
if (!empty($pVal['search_price'])) {
$cond['search_price'] = $pVal['search_price'];
if (is_array($pVal['search_price'])) {
foreach ( $pVal['search_price'] as $k => $v ) {
if ($v == 1) $imakoko['price'] .= "1,000円以下 ";
if ($v == 2) $imakoko['price'] .= "1,001~2,000円 ";
if ($v == 3) $imakoko['price'] .= "2,001~3,000円 ";
if ($v == 4) $imakoko['price'] .= "3,001~4,000円 ";
if ($v == 5) $imakoko['price'] .= "4,001~5,000円 ";
if ($v == 6) $imakoko['price'] .= "5,001円以上 ";
}
}
}
if (!empty($pVal['search_pricemin'])) {
$cond['search_pricemin'] = $pVal['search_pricemin'];
}
if (!empty($pVal['search_pricemax'])) {
$cond['search_pricemax'] = $pVal['search_pricemax'];
}
if (!empty($pVal['search_pricemin']) && !empty($pVal['search_pricemax'])) {
$imakoko['price'] .= $pVal['search_pricemin'] .'~'.$pVal['search_pricemax'];
}else if (!empty($pVal['search_pricemin'])) {
$imakoko['price'] .= $pVal['search_pricemin'].'~';
}else if (!empty($pVal['search_pricemax'])) {
$imakoko['price'] .= '~'.$pVal['search_pricemax'];
}
// 営業時間
$imakoko['time'] = '';
if ( isset($pVal['search_open_time']) ) {
$cond['search_open_time'] = $pVal['search_open_time'];
}
if ( isset($pVal['search_close_time']) ) {
$cond['search_close_time'] = $pVal['search_close_time'];
}
if (isset($pVal['search_over_time']) && $pVal['search_over_time'] <= '48:00') {
$cond['search_over_time'] = $pVal['search_over_time'];
}
if (isset($pVal['search_specific_week']) && isset($pVal['search_specific_time_hour']) && 1 <= $pVal['search_specific_week'] && $pVal['search_specific_week'] <= 7) {
$cond['search_specific_week'] = $pVal['search_specific_week'];
$cond['search_specific_time'] = '';
if ( 0 < $pVal['search_specific_week'] ) {
$pVal['search_specific_time'] = sprintf('%d:%02d', $pVal['search_specific_time_hour'], $pVal['search_specific_time_minute']);
$cond['search_specific_time'] = $pVal['search_specific_time'];
}
}
if (!empty($cond['search_open_time']) && !empty($cond['search_open_time'])) {
$imakoko['time'] = $cond['search_open_time'] . '~' . $cond['search_close_time'];
} else if (!empty($pVal['search_open_time'])) {
$imakoko['time'] = $cond['search_open_time'] . '~';
} else if (!empty($pVal['search_close_time'])) {
$imakoko['time'] = '~' . $cond['search_close_time'];
}
if (!empty($cond['search_over_time'])) {
$time = explode(':',$cond['search_over_time']);
if (!empty($time[0]) && 24 < $time[0]) {
$time[0] = $time[0] - 24;
$time = '翌'.implode(':', $time);
}else{
$time = $cond['search_over_time'];
}
$imakoko['time'] = $time.':00以降も営業している';
}
if (!empty($pVal['search_specific_week']) && !empty($pVal['search_specific_time'])) {
switch ($pVal['search_specific_week']) {
case 1: $week_str = '月'; break;
case 2: $week_str = '火'; break;
case 3: $week_str = '水'; break;
case 4: $week_str = '木'; break;
case 5: $week_str = '金'; break;
case 6: $week_str = '土'; break;
case 7: $week_str = '日'; break;
default: $week_str = ''; break;
}
$imakoko['time'] .= (!empty($imakoko['time'])?' ':'') . $week_str.'曜日の'.$pVal['search_specific_time'].'に営業している';
}
if (!empty($pVal['search_time'])) {
$cond['search_time'] = (array)$pVal['search_time'];
if (in_array(1, $cond['search_time'])) {
$imakoko['time'] = '24時間営業 ';
}
}
//現在営業中
if (isset($pVal['search_active_time']) && $pVal['search_active_time'] == 'on'){
$cond['search_active_time'] = date('H:i:s', $locomill->timestamp);
$imakoko['time'] = '';
}
if ($pVal['sw_lat'] && $pVal['ne_lat'] && $pVal['sw_lng'] && $pVal['ne_lng']) {
$cond['bounds']['north'][0] = $pVal['sw_lat'];// $BoundsPoint['north'][0]; //
$cond['bounds']['south'][0] = $pVal['ne_lat'];// $BoundsPoint['south'][0]; //
$cond['bounds']['west'][1] = $pVal['sw_lng']; // $BoundsPoint['west'][1]; //
$cond['bounds']['east'][1] = $pVal['ne_lng']; // $BoundsPoint['east'][1]; //
$cond['point']['lat'] = $pVal['lat']; // center point latilude; //
$cond['point']['lng'] = $pVal['lng']; // center point lng; //
}
//page item news
if (!empty($pVal['search_news']) && $pVal['search_news'] === 'on'){
$cond['search_news'] = 'on';
}
/**
* プラスグループ検索
*
* */
$shop_tag_data = $plus_group_array = array();
$cond['t'] = 0;
$cond['tg'] = array();
if (isset($pVal['t']) && 0 < $pVal['t'] && isset($shop_tag_array[$pVal['t']])) {
$cond['t'] = $pVal['t'];
}
if (!empty($pVal['tg'])) {
$cond['tg'] = (array) $pVal['tg'];
}
$locomill->assign("LCM_TAG_PLUS_GROUP_ID", $cond['tg']);
$locomill->assign("LCM_TAG_SHOP_TAG_ID", $cond['t']);
if ($cond['t']) {
$plus_group_array = $locomill->PlusGroup->find('all', array('conditions' => array('shop_tag_id ' => $cond['t'])));
$shop_tag_data = $shop_tag_array[$cond['t']];
$imakoko['plus_group'] = '';
foreach ($cond['tg'] as $_) {
$imakoko['plus_group'] .= $plus_group_array[$_]['name'] . ' ';
}
}
$locomill->assign("LCM_TAG_SHOP_TAG_DATA", $shop_tag_data, true);
$locomill->assign("LCM_TAG_PLUS_GROUP_ARRAY", $plus_group_array, true);
/**
* 検索処理
* */
$search_array = $cond;
unset($search_array['search_enable']);
if (!empty($search_array['search_active_time'])){
$search_array['search_active_time'] = 'on';
}
$ShopSch->where($cond);
$ShopSch->order = '';
$select = 'id,shop_name,shop_enable,category1_1,category1_2,category1_3,category2_2,category2_3,image_name,thumbnail_name,area2_id,comment_short,grapevine_disp,sort,sort_start_date,sort_end_date,state,state_start_date,state_end_date,state_remark';
$shop_sql = $ShopSch->select('id');
$cond = array('available' => true);
$cond['shop_id in'] = str_replace(' SQL_CALC_FOUND_ROWS', '', $shop_sql);
if ($sort == 'update') {
$coupon_sort = '`updates` DESC,`shop_coupons`.`id`';
} elseif ($sort == 'newest') {
$coupon_sort = '`entry_date` DESC,`shop_coupons`.`id`';
} else {
$ShopSch->order($sort);
$coupon_sort = str_replace(' ORDER BY', '', $ShopSch->order);
}
$sql = $locomill->ShopCoupon->syntax('list', array('conditions' => $cond, 'order' => $coupon_sort));
$sql = str_replace('FROM `shop_coupons`', 'FROM `shop_coupons` LEFT JOIN (SELECT ' . $select . ' FROM `shop`) shop ON `shop_coupons`.`shop_id` = `shop`.`id`', $sql);
// 検索結果取得
$shop_count = 0;
if ($result = db_query($sql, $locomill->connect)) {
$shop_count = db_numrows($result);
}
$locomill->assign("LCM_TAG_SHOP_COUNT", $shop_count);
$params = array( 'extraVars' => trim_empty_array($pVal), 'isMobile' => $locomill->UserAgent['isMobile']);
if ($page == 1 && 1 < $offset){
$params['currentPage'] = $offset;
}
$pager = Pagination::build($shop_count, $params);
$locomill->assign('LCM_TAG_PAGER', $pager);
$shop_array = array();
if (0 < $shop_count) {
$startRow = (1 < $offset)? 0: $pager['startRow'] - 1;
$endRow = (int)$pager['endRow'];
if (!empty($cond['bounds']) && (!empty($shop_tag_data) || $format === 'json')) {
$endRow = $shop_count;
}
for($i = $startRow ; $i < $endRow; ++$i) {
db_data_seek($result, $i);
$aLine = db_result_assoc($result);
if (!$aLine){
break;
}
$aLine = $locomill->ShopCoupon->filter($aLine);
$aLine['coupon_term'] = ''; // 互換
$shop_data = $locomill->Shop->getById($aLine['shop_id'], array('fields' => $select));
$shop_data = $locomill->Shops->adjust($shop_data);
$aLine = array_merge($aLine, $shop_data); // ['id']は店舗IDになる
if ($format !== 'json') {
//プレゼント確認
$cond = array('shop_id' => $aLine['id']);
$cond[$locomill->curdate.' BETWEEN'] = array('start_date','end_date');
$aLine['gift_array'] = $locomill->Gift->find('one' ,array('conditions' => $cond,
'fields' => 'count(id)'));
//追加ページ
$cond = array('available' => true, 'shop_id' => $aLine['id'], 'belong' => 'shop');
$cond['shop_tag_id in'] = 'SELECT `id` FROM `shop_tags` WHERE "'.$locomill->curdate.'" BETWEEN start_date and end_date';
$aLine['pages'] = $locomill->ShopPage->find('all', array('conditions' => $cond,
'fields' => 'id,title,article'));
//有料・無料
$cond = array('available' => true, 'shop_id' => $aLine['id'], 'belong' => 'shop', 'level' => 10);
$cond['shop_tag_id in'] = 'SELECT `id` FROM `shop_tags` WHERE "'.$locomill->curdate.'" BETWEEN start_date and end_date';
$aLine['shop_page_count'] = $locomill->ShopPage->find('one', array('conditions' => $cond,
'fields' => 'count(id)'));
}
$shop_array[] = $aLine;
}
unset($aLine);
}
if ($format === 'json') {
$locomill->debug = false;
$locomill->loadModel('shop_geom');
$_shop_array = $shop_array;
$shop_array = array();
foreach ($_shop_array as $id => $shop) {
$points = $locomill->ShopGeom->getById($shop['id']);
$key = $points['wgs84_lat'].'-'.$points['wgs84_lng'];
if ($key != '0-0') {
$shop_array[$key][$id] = $shop;
}
}
ob_start("ob_gzhandler");
header("Content-Type: application/json; charset=utf-8");
echo json_encode($shop_array);
exit;
}
if ($locomill->UserAgent['isMobile']) {
$area_array = array();
foreach ($locomill->Area1->area_list as $key => $value) {
$area_array['a1_'.$key] = '●'.$value;
$_array = $locomill->Area2->find('list', array('conditions' =>array('area2_enable' => 1,'area1_id' => $key),
'fields' => 'area2_id,area2_name',
'order' => 'area1_id ASC, position ASC, area2_id ASC'));
foreach ($_array as $k => $val) {
$area_array['a2_'.$k] = ' '.$val;
}
}
$locomill->assign("LCM_TAG_AREA_MENU_ARRAY", $area_array);
$category_array = array();
$category1 = $locomill->ShopCategory->lists(1);
foreach ($category1 as $k1 => $v1) {
$category_array["c1_".$k1] = '●'.$v1['cat1_name'];
$locomill->ShopCategory->setSuffix(2);
$category2 = $locomill->ShopCategory->find('list', array('conditions' => array('cat2_enable' => 1,
'cat1_id' => $k1),
'fields' => 'cat2_id,cat2_name',
'order' => 'position asc,cat2_id'));
foreach ($category2 as $k2 => $v2) {
$category_array["c2_".$k2] = '○'.$v2;
$locomill->ShopCategory->setSuffix(3);
$category3 = $locomill->ShopCategory->find('list', array('conditions' => array('cat3_enable' => 1,
'cat2_id' => $k2),
'fields' => 'cat3_id,cat3_name',
'order' => 'position asc,cat3_id'
));
foreach ($category3 as $k3 => $v3) {
$category_array['c3_'.$k3] = ' '.$v3;
}
}
}
$locomill->assign("LCM_TAG_CAT_MENU_ARRAY", $category_array);
unset($_array,$k,$key,$val,$value);
}
// h1・title・keyword表示
$word = $area = $category = array();
if (!$locomill->UserAgent['isMobile']) {
if (!empty($search_array['q'])) {
$word = array_diff(array_unique(explode(' ', mb_convert_kana(trim($search_array['q']), 's'))), array(''));
}
if (!empty($search_array['search_area1'])) {
foreach ($search_array['search_area1'] AS $v) {
$area[] = $locomill->Area1->find('one', array('conditions' => array('area1_enable' => 1, 'area1_id' => $v), 'fields' => 'area1_name'));
}
}
if (!empty($search_array['search_area2'])) {
foreach ($search_array['search_area2'] AS $v) {
$area[] = $locomill->Area2->find('one', array('conditions' => array('area2_enable' => 1, 'area2_id' => $v), 'fields' => 'area2_name'));
}
}
if (empty($area)) {
$area_name = LOCOMILL_FC_PREFECT_NAME;
if (defined('LOCOMILL_FC_AREA_NAME') && LOCOMILL_FC_AREA_NAME) {
$area_name .= LOCOMILL_FC_AREA_NAME;
}
$area[] = $area_name;
unset($area_name);
}
if (!empty($search_array['search_category1'])) {
$locomill->ShopCategory->setSuffix(1);
foreach ($search_array['search_category1'] AS $v) {
$category[] = $locomill->ShopCategory->find('one', array('conditions' => array('cat1_enable' => 1, 'cat1_id' => $v), 'fields' => 'cat1_name'));
}
}
if (!empty($search_array['search_category2'])) {
$locomill->ShopCategory->setSuffix(2);
foreach ($search_array['search_category2'] AS $v) {
$category[] = $locomill->ShopCategory->find('one', array('conditions' => array('cat2_enable' => 1, 'cat2_id' => $v), 'fields' => 'cat2_name'));
}
}
if (!empty($search_array['search_category3'])) {
$locomill->ShopCategory->setSuffix(3);
foreach ($search_array['search_category3'] AS $v) {
$category[] = $locomill->ShopCategory->find('one', array('conditions' => array('cat3_enable' => 1, 'cat3_id' => $v), 'fields' => 'cat3_name'));
}
}
}
$locomill->assign("LCM_TAG_SEARCH_WORD", implode('と', $word));
$locomill->assign("LCM_TAG_SEARCH_AREA", implode('と', $area));
$locomill->assign("LCM_TAG_SEARCH_CATEGORY", implode('と', $category));
$temp = array();
if (!empty($word)) {
$temp[] = implode(',', $word);
}
if (!empty($area)) {
$temp[] = implode(',', $area);
}
if (!empty($category)) {
$temp[] = implode(',', $category);
}
$locomill->assign("LCM_TAG_SEARCH_KEYWORD", implode(',', $temp), true);
unset($word, $area, $category, $temp);
$time_list = array();
for ($i=6; $i<=24; ++$i){
$time_list['overtime'][$i] = $i;
}
for ($i=25; $i<=30; ++$i){
$time_list['overtime'][$i] = '翌'.($i-24);
}
$locomill->assign("LCM_TAG_SEARCH_ARRAY", $search_array, true);
$locomill->assign("LCM_TAG_VALUES", $pVal, true);
$locomill->assign("LCM_TAG_IMAKOKO", $imakoko, true);
$locomill->assign("LCM_TAG_TITLE", $title, true);
$locomill->assign("LCM_TAG_SHOP_ARRAY", $shop_array,true);
$locomill->assign("LCM_TAG_SORT_ID", $sort);
$locomill->assign("LCM_TAG_SORT_METHOD", $ShopSch->order_str);
$locomill->assign("LCM_TAG_TIME_LIST", $time_list);
$locomill->assign("LCM_TAG_CATEGORY1_ARRAY", $category1_array);
$google = Configure::load("google");
$locomill->assign('LCM_TAG_CONFIG_GOOGLE', $google->config);
unset($locomill->ShopTimer, $locomill->Gift, $locomill->Shops, $locomill->ShopCategory);
// canonical
$temp = array();
foreach ($param_list AS $k => $v) {
if (isset($pVal[$k]) && !empty($pVal[$k]) && $k != 'page' && $k != 'sort') {
if (is_array($pVal[$k])) {
if ((substr($k, 0, -1) == 'search_area' || substr($k, 0, -1) == 'search_category') && count($pVal[$k]) == 1) {
$key = (substr($k, 0, -1) == 'search_area')? 'a': 'c';
$temp[] = sprintf('%s=%s%d_%d', substr($k, 0, -1), $key, substr($k, -1), $pVal[$k][0]);
} else {
foreach ($pVal[$k] AS $v2) {
$temp[] = sprintf('%s[]=%s', $k, $v2);
}
}
} elseif ($k == 'q') {
$temp[] = sprintf('%s=%s', $k, urlencode(implode(' ', array_diff(array_unique(explode(' ', mb_convert_kana(trim($pVal[$k]), 's'))), array('')))));
} else {
$temp[] = sprintf('%s=%s', $k, $pVal[$k]);
}
}
}
$canonical_url = sprintf('shop/search_coupon.shtml%s', (!empty($temp)? '?' . implode('&', $temp): ''));
$locomill->assign('CANONICAL_URL', escapeHTML($canonical_url));
//カテゴリ広告用パラメータ
$search_category1 = (!empty($search_array['search_category1']))? $search_array['search_category1']: array();
$search_category2 = (!empty($search_array['search_category2']))? $search_array['search_category2']: array();
$search_category3 = (!empty($search_array['search_category3']))? $search_array['search_category3']: array();
$search_area1 = (!empty($search_array['search_area1']))? $search_array['search_area1']: array();
$search_area2 = (!empty($search_array['search_area2']))? $search_array['search_area2']: array();
$ad_category = array();
if (!empty($search_category3)) {
foreach ($search_category3 AS $v) {
$ad_category['category3'][] = $v;
if (isset($attr->category3_array[$v])) {
$search_category2[] = $attr->category3_array[$v]['cat2_id'];
$search_category1[] = $attr->category3_array[$v]['cat1_id'];
}
}
$search_category2 = array_unique($search_category2);
}
if (!empty($search_category2)) {
foreach ($search_category2 AS $v) {
$ad_category['category2'][] = $v;
if (isset($attr->category2_array[$v])) {
$search_category1[] = $attr->category2_array[$v]['cat1_id'];
}
}
$search_category1 = array_unique($search_category1);
}
if (!empty($search_category1)) {
foreach ($search_category1 AS $v) {
$ad_category['category1'][] = $v;
}
}
if (!empty($search_area2)) {
foreach ($search_area2 AS $v) {
$ad_category['area2'][] = $v;
}
}
if (!empty($search_area1)) {
foreach ($search_area1 AS $v) {
$ad_category['area1'][] = $v;
}
}
$locomill->assign("LCM_TAG_AD_CATEGORY", $ad_category, true);
$locomill->assign('isThemeLayout', false);
$locomill->assign('CONTENTS', "");
//テンプレート設定
$locomill->display(array('themes/shop_coupon/'.FC_ID.'/index.tpl',
'themes/shop_coupon/'.FC_ID.'/mobile.tpl'));