Пример #1
0
 private function onSearch()
 {
     $wildCardCompanyName = '';
     $wildCardKeyTechnologies = '';
     /* Bail out to prevent an error if the GET string doesn't even contain
      * a field named 'wildCardString' at all.
      */
     if (!isset($_GET['wildCardString'])) {
         $this->listByView('No wild card string specified.');
         return;
     }
     $query = trim($_GET['wildCardString']);
     /* Set up sorting. */
     if ($this->isRequiredIDValid('page', $_GET)) {
         $currentPage = $_GET['page'];
     } else {
         $currentPage = 1;
     }
     $searchPager = new SearchPager(CANDIDATES_PER_PAGE, $currentPage, $this->_siteID, $_GET);
     if ($searchPager->isSortByValid('sortBy', $_GET)) {
         $sortBy = $_GET['sortBy'];
     } else {
         $sortBy = 'name';
     }
     if ($searchPager->isSortDirectionValid('sortDirection', $_GET)) {
         $sortDirection = $_GET['sortDirection'];
     } else {
         $sortDirection = 'ASC';
     }
     $baseURL = CATSUtility::getFilteredGET(array('sortBy', 'sortDirection', 'page'), '&');
     $searchPager->setSortByParameters($baseURL, $sortBy, $sortDirection);
     if (!eval(Hooks::get('CLIENTS_ON_SEARCH_PRE'))) {
         return;
     }
     /* Get our current searching mode. */
     $mode = $this->getTrimmedInput('mode', $_GET);
     /* Execute the search. */
     $search = new SearchCompanies($this->_siteID);
     switch ($mode) {
         case 'searchByName':
             $wildCardCompanyName = $query;
             $rs = $search->byName($query, $sortBy, $sortDirection);
             break;
         case 'searchByKeyTechnologies':
             $wildCardKeyTechnologies = $query;
             $rs = $search->byKeyTechnologies($query, $sortBy, $sortDirection);
             break;
         default:
             $this->listByView('Invalid search mode.');
             return;
             break;
     }
     foreach ($rs as $rowIndex => $row) {
         if ($row['isHot'] == 1) {
             $rs[$rowIndex]['linkClass'] = 'jobLinkHot';
         } else {
             $rs[$rowIndex]['linkClass'] = 'jobLinkCold';
         }
         if (!empty($row['ownerFirstName'])) {
             $rs[$rowIndex]['ownerAbbrName'] = StringUtility::makeInitialName($row['ownerFirstName'], $row['ownerLastName'], false, LAST_NAME_MAXLEN);
         } else {
             $rs[$rowIndex]['ownerAbbrName'] = 'None';
         }
     }
     $companyIDs = implode(',', ResultSetUtility::getColumnValues($rs, 'companyID'));
     $exportForm = ExportUtility::getForm(DATA_ITEM_COMPANY, $companyIDs, 40, 15);
     /* Save the search. */
     $savedSearches = new SavedSearches($this->_siteID);
     $savedSearches->add(DATA_ITEM_COMPANY, $query, $_SERVER['REQUEST_URI'], false);
     $savedSearchRS = $savedSearches->get(DATA_ITEM_COMPANY);
     $query = urlencode(htmlspecialchars($query));
     if (!eval(Hooks::get('CLIENTS_ON_SEARCH_POST'))) {
         return;
     }
     $this->_template->assign('savedSearchRS', $savedSearchRS);
     $this->_template->assign('active', $this);
     $this->_template->assign('subActive', 'Search Companies');
     $this->_template->assign('exportForm', $exportForm);
     $this->_template->assign('pager', $searchPager);
     $this->_template->assign('rs', $rs);
     $this->_template->assign('isResultsMode', true);
     $this->_template->assign('wildCardCompanyName', $wildCardCompanyName);
     $this->_template->assign('wildCardString', $query);
     $this->_template->assign('wildCardKeyTechnologies', $wildCardKeyTechnologies);
     $this->_template->assign('mode', $mode);
     $this->_template->display('./modules/companies/Search.tpl');
 }
Пример #2
0
 */
include_once './lib/Companies.php';
include_once './lib/Search.php';
$interface = new SecureAJAXInterface();
if (!isset($_REQUEST['dataName'])) {
    $interface->outputXMLErrorPage(-1, 'Invalid data name.');
    die;
}
if (!$interface->isRequiredIDValid('maxResults')) {
    $interface->outputXMLErrorPage(-1, 'Invalid max results count.');
    die;
}
$siteID = $interface->getSiteID();
$dataName = trim($_REQUEST['dataName']);
$maxResults = $_REQUEST['maxResults'];
$search = new SearchCompanies($siteID);
$companiesArray = $search->byName($dataName, 'company.name', 'ASC');
if (empty($companiesArray)) {
    $interface->outputXMLErrorPage(-2, 'No companies data.');
    die;
}
$output = "<data>\n" . "    <errorcode>0</errorcode>\n" . "    <errormessage></errormessage>\n" . "    <totalelements>" . count($companiesArray) . "</totalelements>\n";
$arrayCounter = 0;
foreach ($companiesArray as $rowIndex => $row) {
    $arrayCounter++;
    if ($arrayCounter > $maxResults) {
        break;
    }
    $output .= "    <result>\n" . "        <id>" . $companiesArray[$rowIndex]['companyID'] . "</id>\n" . "        <name>" . rawurlencode($companiesArray[$rowIndex]['name']) . "</name>\n" . "    </result>\n";
}
$output .= "</data>\n";