err_no === 0 ) { $locomill->start(); $locomill->loadModel('prefect'); $locomill->loadModel('grapevine'); $locomill->loadModel('shop'); $locomill->loadModel('shop_tag'); $locomill->loadModel('plus_group'); $locomill->loadModel('campaign_tag'); $locomill->call('shops'); $locomill->call('grapevines'); } else { redirect(null, 500); } $area2_array = $locomill->Area2->area2_array; $generation_list = $locomill->Member->generation_list; $gender_list = $locomill->Member->gender_list; unset($gender_list[0], $generation_list[0]); $shop_tag_list = $locomill->ShopTag->find('list',array('conditions' => array('available' => true))); $shop_tag_array = $locomill->ShopTag->find('all',array('conditions' => array('available' => true))); $locomill->assign("LCM_TAG_SHOP_TAG_ARRAY", $shop_tag_array); $campaign_tag_array = $locomill->CampaignTag->find('list', array('conditions' => array('enable' => 'Y'), 'fields' => 'id,name', 'order' => 'position,id')); $locomill->assign("LCM_TAG_KUCHIKOMI_CAMPAIGN_TAG", $campaign_tag_array, true); $prefect_list = $locomill->Prefect->find('list'); $city_list = $locomill->City->find('list', array('conditions' => array('prefect_id' => LOCOMILL_FC_PREFECT_INDEX))); $locomill->assign("LCM_TAG_SHOP_TAG_LIST", $shop_tag_list); $locomill->assign("LCM_TAG_GENERATION_ARRAY", $generation_list ); $locomill->assign("LCM_TAG_GENDER_ARRAY", $gender_list ); $locomill->assign("PrefectList", $prefect_list ); $locomill->assign("CityList", $city_list); $pVal = $_GET; $page = $locomill->param['page']; //クチコミリスト表示件数 $pagerCond = array('count' => 10); if ($locomill->UserAgent['isMobile']){ $pagerCond['count'] = 5; } $cond = array('available' => true); $search_list = array('q' => '', 'prefect' => 0, 'city_id' => 0, 'generation' => '', 'gender' => '','s' => '', 'search_c_tag' => array()); $imakoko = array(); $title = array(); //追加タイトルタグ if (!empty($pVal['q'])) { $order = array(' ','・', "\n", "\r", '&','「','」'); $pVal['q'] = str_replace($order, ' ', $pVal['q']); $pVal['q'] = preg_replace('/\s\s+/', ' ', trim($pVal['q'])); $words = array_unique(explode(' ', $pVal['q'])); $cond['comment LIKE'] = $words; $search_list['q'] = implode(' ', $words); $title[] = implode(' ', $words); unset($order, $words); } if (isset($pVal['gender']) && 0 < $pVal['gender']){ $cond['sex'] = $pVal['gender']; $search_list['gender'] = $pVal['gender']; $title[] = $gender_list[$pVal['gender']]; } if (isset($pVal['generation']) && 0 < $pVal['generation']){ $cond['generation'] = $pVal['generation']; $search_list['generation'] = $pVal['generation']; $title[] = $generation_list[$pVal['generation']]; } if (isset($pVal['prefect']) && 0 < $pVal['prefect']){ $cond['prefect'] = $pVal['prefect']; $search_list['prefect'] = $pVal['prefect']; } if (isset($pVal['city_id']) && 0 < $pVal['city_id']){ $cond['city_id'] = $pVal['city_id']; $search_list['city_id'] = $pVal['city_id']; $search_list['prefect'] = $locomill->City->find('one', array('conditions' => array('id' => $pVal['city_id']), 'fields' => 'prefect_id')); $city_list = $locomill->City->find('list', array('conditions' => array('prefect_id' => $search_list['prefect']))); } $locomill->assign("CityList", $city_list); if (0 < $search_list['city_id']) { if (0 < $search_list['prefect']) { $title['location'] = $prefect_list[$search_list['prefect']]; } $title['location'] .= $city_list[$search_list['city_id']]; } $locomill->assign("SEARCH_TITLE", implode('/', $title)); $shop_id = 0; $shop_data = array(); if (isset($pVal['s']) && 0 < $pVal['s']){ $cond['shop_id'] = $shop_id = $pVal['s']; $search_list['s'] = $pVal['s']; $shop_data = $locomill->Shop->getById($shop_id); if (!empty($shop_data['shop_enable']) && $shop_data['shop_enable'] != 1){ if ($locomill->param['preview'] !== "on" ) { $shop_data = array(); unset($cond['shop_id']); } } } $locomill->assign("LCM_TAG_SHOP_DATA", $shop_data, true); if (empty($cond['shop_id'])){ $cond[] = 'shop_id in(SELECT id FROM `shop` WHERE `shop_enable` = 1)'; } /** * プラスグループ検索 * * */ $shop_tag_id = 0; $shop_tag_data = array(); if (!empty($pVal['t']) && 0 < $pVal['t'] && isset($shop_tag_array[$pVal['t']])) { $shop_tag_id = $pVal['t']; $cond['shop_id in'] = 'SELECT id FROM shop_tag_relations WHERE shop_tag_id =' .db_escape($pVal['t'], $locomill->connect). ' AND belong= "shop"'; } $locomill->assign("LCM_TAG_SHOP_TAG_ID", $shop_tag_id); if ($shop_tag_id) { $shop_tag_data = $shop_tag_array[$shop_tag_id]; $plus_group_array = $locomill->PlusGroup->find('all', array('conditions' => array('shop_tag_id ' => $shop_tag_id))); $locomill->assign("LCM_TAG_SHOP_TAG_DATA", $shop_tag_array[$shop_tag_id], true); $locomill->assign("LCM_TAG_PLUS_GROUP_ARRAY", $plus_group_array, true); } // キャンペーンタグ $imakoko['c_tag'] = ''; if (isset($pVal['search_c_tag']) && !empty($pVal['search_c_tag']) && is_array($pVal['search_c_tag'])){ $temp = array(); foreach ($pVal['search_c_tag'] AS $v) { if (isset($campaign_tag_array[$v])) { $temp[] = sprintf('FIND_IN_SET(%d, campaign_tag)', $v); $imakoko['c_tag'] .= $campaign_tag_array[$v] . ' '; } } if (!empty($temp)) { $cond['OR'] = $temp; $search_list['search_c_tag'] = $pVal['search_c_tag']; } } /** * 検索処理 * */ $grapevine_array = array(); $_grapevine_array = $locomill->Grapevine->find('list', array('conditions' => $cond, 'fields' => 'id,display_date', 'limit' => $pagerCond['count'], 'page' => $page, 'order' => 'display_date DESC')); $grapevine_count = $locomill->Grapevine->numrows(); $locomill->assign("LCM_TAG_SEARCH_LIST", $search_list); $locomill->assign("LCM_TAG_IMAKOKO", $imakoko, true); $search_str = (1 < $page) ? '&page='.$page:''; foreach ($search_list AS $k => $v) { if (!empty($v)) { if (is_array($v)) { foreach ($v AS $v2) { if (!empty($v2)) { $search_str .= '&'.$k.'[]='.$v2; } } } else { $search_str .= '&'.$k.'='.$v; } } } $locomill->assign("LCM_TAG_SEARCH_STR", $search_str); foreach ($_grapevine_array AS $k => $v) { $v = $locomill->Grapevine->getById($k); $v = $locomill->Grapevines->adjust($v, 'all'); $grapevine_array[] = $v; unset($v); } unset($_grapevine_array); $locomill->assign("LCM_TAG_GRAPEVINE_ARRAY", $grapevine_array, true); $locomill->assign("LCM_TAG_GRAPEVINE_COUNT", $grapevine_count); $params = array( 'clearIfVoid'=>true, 'extraVars' => $search_list, 'isMobile' => $locomill->UserAgent['isMobile'], ); $pager = Pagination::build($grapevine_count, $params); $locomill->assign('LCM_TAG_PAGER', $pager); // タグ変数定義 $locomill->assign( "LCM_TAG_VALUES", $pVal, true); // canonical $temp = array(); foreach ($search_list AS $k => $v) { if (!empty($pVal[$k])) { if ($k == 'q') { $temp[] = sprintf('%s=%s', $k, urlencode($pVal[$k])); } else { if (is_array($pVal[$k])) { foreach ($pVal[$k] AS $v2) { if (!empty($v2)) { $temp[] = sprintf('%s[]=%s', $k, $v2); } } } else { $temp[] = sprintf('%s=%s', $k, $pVal[$k]); } } } } $canonical_url = sprintf('shop/kuchikomi_list.shtml%s', (!empty($temp)? '?' . implode('&', $temp): '')); $locomill->assign('CANONICAL_URL', escapeHTML($canonical_url)); //テンプレート設定 $theme_name = ''; $theme_layout = ''; $css_path = array(); if ($shop_tag_data) { $theme = $shop_tag_data['theme_name']; $theme_dir = THEME_DIR .'extra_list' . DS . $theme . DS ; $theme_layout = DOC_ROOT . $theme_dir . 'layout.tpl'; if ($locomill->View->templateExists($theme_layout)) { $locomill->viewFilename = array($theme_layout.'|shop/kuchikomi_list.tpl', 'shop/mobile_grapevine.tpl'); } if (is_file(DOC_ROOT . $theme_dir . 'css' . DS . 'style.css')) { $filetime = @filemtime(DOC_ROOT . $theme_dir . 'css' . DS . 'style.css'); $css_path[] = $theme_dir . 'css' . DS . 'style.css?' . date('YmdHi', $filetime); } } else { $locomill->viewFilename = array("shop/kuchikomi_list.tpl", "shop/mobile_kuchikomi_list.tpl"); if ($shop_id){ $locomill->viewFilename[1] = "shop/mobile_grapevine.tpl"; } } $locomill->assign('isThemeLayout', (bool) $theme_layout); $locomill->assign('THEME_NAME', $theme_name); $locomill->assign('CSS_PATH', $css_path); $locomill->display( );