'; $left_html .= ''; $left_html .= ''; } } else { $right_html .= "
"; $conn_profile = new ConnectionProfile($prism_connection_profile_cms); $db = new DatabaseConnection($conn_profile); $conn_write_profile = new ConnectionProfile($cms_connection_profile_write ); $db_write = new DatabaseConnection($conn_write_profile); $sTmpCat = array(); $sSql = "SELECT category_id, category_name, category_parent FROM cms_category"; $sResult = $db->query($sSql); while ($sRow = mysql_fetch_array($sResult)) { $sTmpCat[$sRow["category_id"]] = array($sRow["category_name"], $sRow["category_parent"]); } $top_html = ""; if(isset($_GET["bc"]) && array_key_exists($_GET["bc"], $sTmpCat)) { $top_html = "Directory > Search Result > ".$sTmpCat[$_GET["bc"]][0]; } else { $top_html = "Directory > Search Result"; } $right_html = ""; if(isset($_GET["keyword"])) { $get_arr = $_GET; $current_page = 1; $rec_per_page = 10; if(isset($_GET["page"])) { $current_page = addslashes($_GET["page"]); } $get_arr["offset"] = ($current_page-1)*$rec_per_page; $get_arr["rpp"] = $rec_per_page; //print_r($get_arr); if(!isset($get_arr["orderby"])) { $get_arr["orderby"] = "name"; } $category_header = "Directory > Keyword Search "; $keyword_search = new KeywordSearch($db); $aCategory = $keyword_search->searchCategoryByQueryStr($get_arr);//get categories if (isset($aCategory)){ $c = $sTmpCat; $category_path_arr = array(); foreach ($aCategory as $key => $aCategoryInfo){ $tmp_cate = array(); $tmp_current_cate = $aCategoryInfo["category_id"]; $count = 0; while(true) { $tmp_link = ''; if(!array_key_exists($tmp_current_cate, $c) || count($c[$tmp_current_cate]) == 0) break; if($c[$tmp_current_cate][1] == 0) $tmp_link = "".$c[$tmp_current_cate][0].""; else $tmp_link = "".$c[$tmp_current_cate][0].""; array_push($tmp_cate, $tmp_link); if($c[$tmp_current_cate][1] == 0) break; else $tmp_current_cate = $c[$tmp_current_cate][1]; $count++; if($count > 5) //for safe break; } array_push($category_path_arr, "Directory > ".implode(" > ",array_reverse($tmp_cate)).""); } } $path_html = ''; $path_html .= implode("
", $category_path_arr); $r = $keyword_search->searchByQueryStr($get_arr);//get contents //echo "s"; $result = $keyword_search->getResultAry(); if(count($result) > 0) { $left_html .= ''; $left_html .= '

'; $bc_total = $keyword_search->getBCTotal(); $tmp = ''; foreach($bc_total as $k => $v) { if(array_key_exists($k, $sTmpCat)) { $left_html .= "".$sTmpCat[$k][0]." (".$v.")
"; //$tmp .= ""; } } //$left_html .= ''; $left_html .= '
'; $right_html .= "
".Content::getPagingStyle1($current_page,ceil($keyword_search->getTotal()/10))."
"; $rcnt = 0; foreach($result as $k => $v) { //get article(s) $param = ''; $param['biz_id'] = $v['business_id']; $param['orderby'] = ''; $param['approved'] = 'Yes'; //$param['RECORD_PER_PAGE'] = '6'; $artilce_coll_tmp = new ArticleCollection($db); $artilce_coll_tmp -> loadArticles($param); $result[$k]['article_ary'] = $artilce_coll_tmp -> getArticleArr(); //get article(e) if ($result[$k]['article_ary']){ foreach ($result[$k]['article_ary'] as $article_key => $article_info){ if (get_magic_quotes_gpc()) { $result[$k]['article_ary'][$article_key]['title_text'] = stripslashes($article_info['title_text']); $result[$k]['article_ary'][$article_key]['title_text_short'] = stripslashes($article_info['title_text_short']); $result[$k]['article_ary'][$article_key]['author_text'] = stripslashes($article_info['author_text']); } //echo '
';print_r($result[$k]);echo '
'; } } //get product(s) $aProductQuery['cid'] = $v['content_id']; $oProductCollection = new ProductCollection($db); $aResult = $oProductCollection->searchByQueryStr($aProductQuery); $iTotal = $oProductCollection->getTotal(); if ($iTotal > 0) $result[$k]['product'] = true; //get product(e) //echo '
';print_r($v);echo '
'; $rcnt++; $result[$k]["cnt"] = $rcnt; $right_html .= Content::getKeywordSearchContentHTML($result[$k], $sTmpCat, $_GET["keyword"]); } $right_html .= "
".Content::getPagingStyle1($current_page,ceil($keyword_search->getTotal()/10))."
"; $right_html .= "
"; } if((count($result) == 0) && (!$aCategory)) { $right_html .= "
"; } if ($current_page==1){//store the record in database if page 1 include_once("../class/RecentKeywordClass.php"); $oRecentKeyword = new RecentKeyword($db_write); $oRecentKeyword -> setKeyword(trim(strtolower($_GET["keyword"]))); $oRecentKeyword -> setKeywordType('directory'); $oRecentKeyword -> update(); //$oRecentKeyword -> emptyTable(); } }else if(isset($_GET["bid"])) { include("../class/ContentCollectionClass.php"); include("../class/Category.php"); include_once("../class/Content.php"); $page = 1; if(isset($_GET["page"]) && is_int($_GET["page"]+0) ) { $page = $_GET["page"]; } $category_header = "Directory > Related Links "; $content_collection = new ContentCollection($db); $cat = array(); $cat["RECORD_PER_PAGE"] = 10; $cat["offset"] = ($page-1)*10; $cat["bid"] = $_GET["bid"]; if(isset($_GET["district"])) { $cat["district_id"] = addslashes($_GET["district"]); } $cat["orderby"] = "content_name_eng"; if(isset($_GET["orderby"])) { if($_GET["orderby"] == "name" ) $cat["orderby"] = "content_name_eng"; else if( $_GET["orderby"] == "location" ) $cat["orderby"] = "content_district_eng"; } $content_collection->loadContents($cat); $r = $content_collection->getContentArr(); $imgs = $content_collection->getContentImage(); $right_html = ""; if($content_collection->getCollectionSize() > 0) { $right_html .= ""; if ($r){ // featured articles not shown if search by bid /*foreach ($r as $key => $content_info_ary){ //get article(s) $param = ''; $param['biz_id'] = $content_info_ary['business_id']; $param['orderby'] = ''; $param['approved'] = 'Yes'; //$param['RECORD_PER_PAGE'] = '6'; $artilce_coll_tmp = new ArticleCollection($db); $artilce_coll_tmp -> loadArticles($param); $r[$key]['article_ary'] = $artilce_coll_tmp -> getArticleArr(); //get article(e) if ($r[$key]['article_ary']){ foreach ($r[$key]['article_ary'] as $article_key => $article_info){ if (get_magic_quotes_gpc()) { $r[$key]['article_ary'][$article_key]['title_text'] = stripslashes($article_info['title_text']); $r[$key]['article_ary'][$article_key]['title_text_short'] = stripslashes($article_info['title_text_short']); $r[$key]['article_ary'][$article_key]['author_text'] = stripslashes($article_info['author_text']); } } } }*/ $right_html .= Content::getContentListHTML ($r, $imgs,'related_link'); } $right_html .= "
".Content::getPagingStyle1($page, ceil($content_collection->getCollectionSize()/10))."
"; } else { $right_html .= "
"; } $right_html .= ""; $cat = array(); $cat["RECORD_PER_PAGE"] = 1000; //$cat["offset"] = ($page-1)*10; $cat["bid"] = $_GET["bid"]; $cat["orderby"] = "content_district_eng"; $content_collection->loadContents($cat); $r = $content_collection->getContentArr(); $district_cnt = array(); $district_collection = array(); foreach($r as $k => $v) { if(!isset($district_cnt[$v["content_district_eng"]])) { $district_cnt[$v["content_district_eng"]] = 1; $district_collection[$v["content_district_eng"]] = $v["district_name"]; } else { $district_cnt[$v["content_district_eng"]]++; } } $district_html = ""; $unknown_text = ""; $total = 0; //print_r($_GET);die; foreach($district_collection as $k => $v) { if(isset($district_cnt[$k])) $total += $district_cnt[$k]; if (strlen($v)>23){ $v = substr($v, 0, 20); $v .= '...'; } //$tmp = "".(($v=="")?"Unknown district":stripslashes($v))." (".((isset($district_cnt[$k]) && $district_cnt[$k] > 0)?$district_cnt[$k]:"0").")"."
"; $tmp = ""; if($v == "") { $unknown_text .= $tmp; } else { $district_html .= $tmp; } } $district_html .=""; //if(0) if($total > 0) { $left_html = ''; $left_html .= '

'; //$left_html .= "All Districts (".$total.")"."
"; $left_html .= "
"; } //Finish Data process and generate HTML; ?>
 
Keyword Search: