protected function top_search($_page_title) { // get the employers $criteria = array('columns' => 'employers.id, employers.name, COUNT(jobs.id) AS job_count', 'joins' => 'employers ON employers.id = jobs.employer', 'group' => 'employers.id', 'order' => 'employers.name ASC'); $job = new Job(); $employers = $job->find($criteria); if ($employers === false) { $employers = array(); } // get the industries $industries = Industry::getIndustriesFromJobs(true); // get the countries $criteria = array('columns' => "countries.country_code, countries.country, COUNT(jobs.id) AS job_count", 'joins' => "countries ON countries.country_code = jobs.country", 'group' => "countries.country_code", 'order' => "countries.country ASC"); $job = new Job(); $countries = $job->find($criteria); $top = file_get_contents(dirname(__FILE__) . '/../../html/top_search.html'); $top = str_replace('%root%', $this->url_root, $top); $employers_options = ''; foreach ($employers as $emp) { $employers_options .= '<option value="' . $emp['id'] . '">' . desanitize($emp['name']); if ($emp['job_count'] > 0) { $employers_options .= ' (' . $emp['job_count'] . ')'; } $employers_options .= '</option>' . "\n"; } $top = str_replace('<!-- %employers_options% -->', $employers_options, $top); $industries_options = ''; foreach ($industries as $industry) { $industries_options .= '<option value="' . $industry['id'] . '">' . $industry['industry']; if ($industry['job_count'] > 0) { $industries_options .= ' (' . $industry['job_count'] . ')'; } $industries_options .= '</option>' . "\n"; } $top = str_replace('<!-- %industries_options% -->', $industries_options, $top); $countries_options = ''; foreach ($countries as $a_country) { $countries_options .= '<option value="' . $a_country['country_code'] . '">' . $a_country['country']; if ($a_country['job_count'] > 0) { $countries_options .= ' (' . $a_country['job_count'] . ')'; } $countries_options .= '</option>' . "\n"; } $top = str_replace('<!-- %countries_options% -->', $countries_options, $top); echo $top; }
private function get_industries() { $industries = Industry::getIndustriesFromJobs(true); return $industries; }