public static function getInstance() { if (!self::$_instance) { self::$_instance = new FM_Components_Search(); } return self::$_instance; }
function orgsAction() { $this->view->results = null; if ($_POST || $_GET && array_key_exists('all', $_GET)) { //print_r($_POST);exit; $search = FM_Components_Search::getInstance(); $search->setType(3); if ($_POST) { foreach ($_POST as $key => $value) { if (stristr($key, 'region')) { $regionId = explode('_', $key); $search->addRegion($regionId[2]); continue; } if (stristr($key, 'all')) { $regionId = explode('_', $key); $all[] = $regionId[2]; continue; } if (stristr($key, 'town')) { $townId = explode('_', $key); if ($townId[2] != 0) { $search->addTown($townId[2]); } continue; } if (stristr($key, 'category')) { $categoryId = explode('_', $key); if ($categoryId[2] != 0) { $search->addCategory($categoryId[2]); } continue; } if ($key == 'keyword') { $search->setKeywords(explode(',', $value)); continue; } if ($key == 'zip') { $search->setZipcode($value); } } } $results = $search->doNpSearch(); $objs = array(); if ($resultsTotal = count($results)) { //print_r($results); foreach ($results as $index => $values) { switch ($values['type']) { case 3: $obj = $values; $icon = new FM_Components_Util_Icon(array('orgId' => $values['id'])); $obj['icon'] = $icon->getFileName(); $objs[] = $obj; break; case 4: $obj = $values; $icon = new FM_Components_Util_Icon(array('orgId' => $values['id'])); $obj['icon'] = $icon->getFileName(); $obj['type'] = 4; $objs[] = $obj; break; } } $banners = FM_Components_Banner::getSortedRandomBanners(); $banners = $this->view->partial('banner/bannerleftindex.phtml', array('banners' => $banners)); $this->view->results = $this->view->partial('search/results.phtml', array('clients' => $objs, 'total' => $resultsTotal, 'banners' => $banners, 'type' => 'org')); } else { $this->view->noResults = true; } } $this->_helper->layout->setLayout('singlecolumn'); $this->view->layout()->cols = 1; $this->view->cats = $this->view->partial('search/categories.phtml', array('cats' => FM_Components_Util_Category::getSortedSearchCategories(true))); $this->view->towns = $this->view->partial('search/towns.phtml', array('towns' => FM_Components_Util_Town::getAll())); $this->view->orgsearch = true; }