forked from bjohnson045/phpMyDirectory
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jobs_search.php
84 lines (70 loc) · 3.89 KB
/
jobs_search.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
define('PMD_SECTION', 'public');
include('./defaults.php' );
// Load the language variables required on this page
$PMDR->loadLanguage(array('public_jobs'));
// Set the page title
$PMDR->setAdd('page_title',$PMDR->getLanguage('public_jobs_search'));
$PMDR->set('meta_title',coalesce($PMDR->getConfig('jobs_search_meta_title'),$PMDR->getLanguage('public_jobs_search')));
$PMDR->set('meta_description',coalesce($PMDR->getConfig('jobs_search_meta_description'),$PMDR->getLanguage('public_jobs_search')));
// Set the breadcrumb links
$PMDR->setAddArray('breadcrumb',array('link'=>BASE_URL.'/jobs_search.php','text'=>$PMDR->getLanguage('public_jobs_search')));
// Initialize paging object and default settings
$paging = $PMDR->get('Paging');
$paging->linksNumber = 20;
$paging->setResultsNumber($PMDR->getConfig('count_directory'));
$paging->modRewrite = false;
// Load the template used for this page
$template_content = $PMDR->getNew('Template',PMDROOT.TEMPLATE_PATH.'jobs_search.tpl');
$where = '';
$where_parts = array();
$where_parts[] = "status='active'";
if(isset($_GET['keyword']) AND !empty($_GET['keyword'])) {
$where_parts[] = "MATCH(j.title,j.description_short,j.keywords) AGAINST (".$PMDR->get('Cleaner')->clean_db($_GET['keyword']).")";
}
$category_join = '';
if(isset($_GET['category_id']) AND !empty($_GET['category_id'])) {
$category_join = "INNER JOIN ".T_JOBS_CATEGORIES_LOOKUP." cl ON j.id=cl.job_id";
$where_parts[] = "cl.category_id=".$PMDR->get('Cleaner')->clean_db($_GET['category_id']);
}
if(count($where_parts)) {
$where = 'WHERE '.implode(' AND ',$where_parts);
}
$jobs = $db->GetAll("SELECT SQL_CALC_FOUND_ROWS j.* FROM ".T_JOBS." j $category_join $where ORDER BY j.date DESC LIMIT ?,?",array(intval($paging->limit1),intval($paging->limit2)));
$jobs_count = $db->FoundRows();
$paging->setTotalResults($jobs_count);
unset($_GET['submit_search']);
// Set up the paging template
$pageArray = $paging->getPageArray();
$template_page_navigation = $PMDR->get('Template',PMDROOT.TEMPLATE_PATH.'blocks/page_navigation.tpl');
$template_page_navigation->set('page',$pageArray);
// Get the listing results template
$template_results = $PMDR->getNew('Template',PMDROOT.TEMPLATE_PATH.'blocks/jobs_results.tpl');
$template_results->set('page',$pageArray);
if($jobs) {
$jobs_results = '';
foreach($jobs AS $job) {
$job['date'] = $PMDR->get('Dates_Local')->formatDateTime($job['date']);
$job['date_updated'] = $PMDR->get('Dates_Local')->formatDateTime($job['date_updated']);
$job['url'] = $PMDR->get('Jobs')->getURL($job['id'],$job['friendly_url']);
$jobs_results_template = $PMDR->getNew('Template',PMDROOT.TEMPLATE_PATH.'blocks/jobs_results_default.tpl');
$jobs_results_template->set('job',$job);
$jobs_results .= $jobs_results_template->render();
}
$template_results->set('jobs_results',$jobs_results);
$template_results->set('page_navigation',$template_page_navigation);
} else {
$template_content->set('error_message',$PMDR->getLanguage('public_search_users_no_results'));
}
$form = $PMDR->getNew('Form');
$form->method = 'GET';
$form->addField('keyword','text',array('label'=>'keyword','placeholder'=>$PMDR->getLanguage('public_jobs_keyword'),'value'=>$_GET['keyword']));
$categories = $db->GetAssoc("SELECT id, title FROM ".T_JOBS_CATEGORIES." ORDER BY title");
$form->addField('category_id','select',array('first_option'=>array(''=>$PMDR->getLanguage('public_jobs_category')),'options'=>$categories,'label'=>'category','placeholder'=>$PMDR->getLanguage('public_jobs_category'),'value'=>$_GET['category_id']));
$form->addField('submit','submit',array('label'=>$PMDR->getLanguage('search')));
$template_content->set('form',$form);
// Send remaining details to the template to control the data display
$template_content->set('jobs_results',$template_results);
$template_content->set('jobs_count', $jobs_count);
include(PMDROOT.'/includes/template_setup.php');
?>