%once> # # # # THIS QUERY COMPONENT IS ONLY FOR JOBS (Eventually into a category). NOT COMPANY # use Date::Calc ; use Careerjet::DateTime ; use Careerjet::UserQueryBuilder ; use Careerjet::Searcher::JobSearchBalancer; my $pagesize = $r->dir_config('CareerjetJobPageSize') || 10 ; my $maxoffset = 2000; my %jobComps = () ; %once> <%shared> my $forumLinkDisp = $r->dir_config('CareerjetForumActive') || 0 ; unless( $jobComps{'normal'} ){ $jobComps{'normal'} = $m->fetch_comp('/search/job_normal.mas' ) ; $jobComps{'compact2'} = $m->fetch_comp('/search/job_compact2.mas' ) ; } my $JOBSEARCHSOURCE = $m->shared()->{'JOBSEARCHSOURCE'} ; my $default_location = $r->dir_config('CareerjetDefaultLocation') || 54 ; my $defaultLanguage = $r->dir_config('CareerjetSearchDefaultLanguage') || '' ; my $fragmentSize = $r->dir_config('CareerjetSearchFragmentSize') || 100 ; my $noindex_zerojobs = $r->dir_config('CareerjetNoIndexZeroJobs') || 0; my $zerocompanyjobs404 = $r->dir_config('Careerjet404ZeroCommpanyJobs') || 0; my $google_afs_weight = $r->dir_config('CareerjetGoogleAFSWeight') || 0.5; my $cgi = $m->cgi_object() ; $cgi->charset('UTF-8'); ## CONTEXTUAL PARAMETERS my $sortmode = $m->cgi_object()->param('sort') || 'relevance' ; my $datefilter = $m->cgi_object()->param('df') || '' ; my $style = $m->cgi_object()->param('style') || '' ; # DIAGNOSTIC MODE my $diag = $m->cgi_object()->param('diag'); # Read the style from cookie and pass it in the shared # Read style from cookie my $jar = Apache2::Cookie::Jar->new($r) ; my $nowstyle = undef ; my $c_style = $jar->cookies('style'); if ( $c_style ){ $nowstyle = $c_style->value() ; } $m->shared()->{'style'} = $nowstyle ; # End of style grabbing part # replace style by $nowstyle priority to cookie # Trigger the bookmark_page $m->shared()->{'bookmark_page'} = 1 ; ## ## Query part # # GRABING OFFSET # SEO parameter p (page) my $page_num = $m->cgi_object()->param('p') ; my $offset = $m->cgi_object()->param('b') || 1 ; # MOST PROBABLY THE PAGE NUMBER IS GIVEN if (defined $m->cgi_object()->param('p')) { $offset = 1 + (($m->cgi_object()->param('p') - 1) * $pagesize); } $offset-- ; if ( $offset < 0 ) { $offset = 0 ; } #Maximizing offset if ( $offset > $maxoffset - $pagesize + 1) { $offset = $maxoffset - $pagesize + 1; } ## SEARCH BUILDING my $qBuilder = Careerjet::UserQueryBuilder->new( { 'charset' => 'UTF-8' } ) ; my $query = $qBuilder->queryFromCGI($cgi) ; my $searchOptions = { 'offset' => $offset , 'limit' => $pagesize , 'sort' => $sortmode , 'countrylang' => $ENV{'country'} || 'uk', 'dlid' => $default_location , 'fragsize' => $fragmentSize , } ; if ( $defaultLanguage ){ $searchOptions->{'langboost'} = $defaultLanguage ; } if ( $datefilter ){ $searchOptions->{'datefilter'} = $datefilter ; } ## OK REDIRECT TO CANONIC URL IF NEEDED if ( $r->dir_config('CareerjetVarRedirect') ){ $m->comp('/utils/canonical_search.mas' , 'q' => $query , 'options' => $searchOptions ) ; } # Share query variables with other .mas modules $m->shared()->{'query'} = $query ; $m->shared()->{'searchOptions'} = $searchOptions ; $m->shared()->{'seo_url'} = $m->cgi_object()->param('seo_url') || 0 ; # Memorize for future pages and mostly for saving this query # lQ : lastQuery $m->session()->{'lQ'} = $query ; # sO : searchOptions $m->session()->{'sO'} = $searchOptions ; my $diagnostic_mode; if ($diag eq "goose") { $diagnostic_mode = 1; } # # ACTUAL SEARCH # # my $t1 = Time::HiRes::time() ; $QUERYRESULT = {}; eval { $QUERYRESULT = Careerjet::Searcher::JobSearchBalancer->search($query, $searchOptions); }; if ($@) { warn $@; } my $t2 = Time::HiRes::time() ; ## adsense for search channel my $google_afc_keywords = $r->dir_config('CareerjetGoogleAFCKeywords') || 0 ; my $googleAFSChannel = $r->dir_config('CareerjetGoogleAFSChannel') || 0 ; if ($query->s() =~ m/company:/s) { $googleAFSChannel = 0; } $m->shared()->{google_afs_channel} = $googleAFSChannel; ## new google ads my $new_google_ads = $r->dir_config('CareerjetNewGoogleAds') || 0 ; my $num_ads_top = $r->dir_config('CareerjetGoogleNumAdsTop') || 0; my $num_ads_bottom = $r->dir_config('CareerjetGoogleNumAdsBottom') || 0; ## AFS top and bottom my $afsTopBottom = $r->dir_config('CareerjetGoogleAFSTopBottom') ; my ( $afsTop , $afsBottom ) = ( 0 , 0 ) ; if ( $afsTopBottom ){ ( $afsTop , $afsBottom ) = split('-' , $afsTopBottom ); } # # Gives info for custom ads display if rtype is NEUTRAL (MEANING ACTUAL JOBS HAS BEEN FOUND) my $nJobsFound = 0 ; if ( defined $QUERYRESULT && $QUERYRESULT->{'rtype'} eq "N" ){ $m->shared()->{'ads_numjobs'} = $QUERYRESULT->{'result'}->{'nresults'} ; $nJobsFound = $QUERYRESULT->{'result'}->{'nresults'} ; $m->shared()->{'ads_pagesize'} = $QUERYRESULT->{'result'}->{'pagesize'} ; } # Eventually log loglid my $loglid = $m->cgi_object()->param('loglid') ; if ( $loglid ){ my $logl = Encode::decode_utf8( $m->cgi_object()->param('logl') ) ; my $fname = '/home/apache/logs/monitoring/locations.log' ; if ( open LOGF , '>>'.$fname ){ binmode LOGF , ":utf8" ; my $parentsarray = $QUERYRESULT->{'location'}->{'ancestors'} ; my $path = '' ; foreach my $parent ( @$parentsarray ){ $path .= $parent->{'l'}.' > ' ; } $path .= $QUERYRESULT->{'location'}->{'thisl'}->{'l'} ; print LOGF $loglid."\cA".$path."\cA".$logl."\cA".$ENV{'country'}."\n" ; close LOGF ; } else { warn "Cannot open $fname" ; } } ## COMPLETE QUERY INFORMATIONS unless( $query->l()){ $query->l($QUERYRESULT->{'location'}->{'thisl'}->{'l'}); } $query->lid($QUERYRESULT->{'location'}->{'thisl'}->{'lid'}) ; $query->cid($QUERYRESULT->{'result'}->{'catid'}); %shared> <%method title> %method> <%method specialhead> <%perl> use Careerjet::Local::Translations2 ; my $argline = $m->scomp('/utils/search_args.mas' , h => $query ); my $ds = $m->shared()->{'query'}->s() ; my $dl = $m->shared()->{'query'}->l() ; my $domain = get_trans("DOMAIN"); $domain =~ s/^www\.//; my $title; my $description; my $meta_keywords; my $meta_robots = ''; if ( ( defined $QUERYRESULT->{'result'}->{'catid'} ) && ( $QUERYRESULT->{'result'}->{'catid'} > 0 ) ) { # THERE WAS A SECTOR IN THE QUERY, LEADING TO SECTOR ID IN THE RESULT. IMPLIES THE RESULT IS OF TYPE J (JOBS) # # Location: # $QUERYRESULT->[5] $title = get_trans("CATEGORY_GOOGLE_TITLE"); $description = get_trans("CATEGORY_GOOGLE_DESCRIPTION"); $meta_keywords = get_trans("CATEGORY_GOOGLE_META"); my $category = Careerjet::CDB::Categories->get_name($QUERYRESULT->{'result'}->{'catid'}, $ENV{'country'}); # STORE cid ( CID is QUERYRESULT->[3] ) #$m->session()->{'cid'} = $QUERYRESULT->[3] ; # REPLACING category in descriptions ( $w ). $title =~ s/\$w/$category/g; $description =~ s/\$w/$category/g; $meta_keywords =~ s/\$w/$category/g; # REPLACING location in descriptions ( $w ) my $location = $QUERYRESULT->{'location'}->{'thisl'}->{'l'} ; $title =~ s/\$l/$location/g; $description =~ s/\$l/$location/g; $meta_keywords =~ s/\$l/$location/g; ## makes it look better $title =~ s/in United/in the United/; $description =~ s/in United/in the United/; $title =~ s/in USA/in the USA/; $description =~ s/in USA/in the USA/; $title =~ s/in Philippines/in the Philippines/; $description =~ s/in Philippines/in the Philippines/; # if ( ( defined $page_num ) && ( $page_num > 1 ) ){ # my $pageTranslation = get_trans('TITLE_PAGE_NUM') ; # $pageTranslation =~ s/\$p/$page_num/ ; # $title .= ' | '.$pageTranslation ; # } } elsif ($QUERYRESULT->{'rtype'} eq "N" && $query->s() eq "") { # OK THERE IS NO CATEGORY AND NOTHING IN S $title = get_trans("LOCATION_GOOGLE_TITLE"); $description = get_trans("LOCATION_GOOGLE_DESCRIPTION"); $meta_keywords = get_trans("LOCATION_GOOGLE_META"); my $location = $QUERYRESULT->{'location'}->{'thisl'}->{'l'} ; $title =~ s/\$l/$location/g; $description =~ s/\$l/$location/g; $meta_keywords =~ s/\$l/$location/g; } elsif ($QUERYRESULT->{'rtype'} eq "N" && $query->s() =~ m/^company:\s*\"(.*?)\"$/) { # JOBS RESULTS WITH ONLY A COMPANY IN THE QUERY my $company = $1; $company =~ s/\s/_/g ; $m->shared()->{'company_norm'} = $company ; # # Get the real company name from the service my $COMPANYSOURCE = $m->shared()->{'COMPANYSOURCE'} ; my $compSearcher = $COMPANYSOURCE->get(); my $companyObject = {} ; eval{ $companyObject = $compSearcher->getOneCompany($company,$default_location) ; $COMPANYSOURCE->free($compSearcher) ; }; if ( $@ ){ warn $@ ; $COMPANYSOURCE->fail($compSearcher); } my $realCompanyName = $companyObject->{'company'} ; my $companySite = $companyObject->{'site'} ; # || 'www.dummy.dum' ; print "\n" ; $company =~ s/_/ /g ; $m->shared()->{'company'} = $realCompanyName || $company ; $m->shared()->{'company_site'} = $companySite ; $m->shared()->{'company_letter'} = $companyObject->{'companyletter'} ; $company = $m->shared()->{'company'} ; $title = get_trans("COMPANY_GOOGLE_TITLE"); $description = get_trans("COMPANY_GOOGLE_DESCRIPTION"); $meta_keywords = get_trans("COMPANY_GOOGLE_META"); $title =~ s/\$w/$company/g; $description =~ s/\$w/$company/g; $meta_keywords =~ s/\$w/$company/g; if (!$realCompanyName && $zerocompanyjobs404) { $r->status(404) ; $title .= ' | 404 ' ; } } else { ## ALL OTHER CASES (GENERAL CASE) $title = get_trans("SEARCH_GOOGLE_TITLE"); $description = get_trans("SEARCH_GOOGLE_DESCRIPTION"); $meta_keywords = get_trans("SEARCH_GOOGLE_META"); my $words = $query->s() ; my $location = $QUERYRESULT->{'location'}->{'thisl'}->{'l'} ; $title =~ s/\$w/$words/g; $title =~ s/\$l/$location/g; $description =~ s/\$w/$words/g; $description =~ s/\$l/$location/g; $meta_keywords =~ s/\$w/$words/g; $meta_keywords =~ s/\$l/$location/g; } # NO INDEX IN CASE OF ZERO RESULTS if ($noindex_zerojobs && ( ! $QUERYRESULT->{'result'}->{'nresults'} )) { $meta_robots = "\n "; } $m->shared()->{'pagetitle'} = $title.' | '.$domain ; %perl>
| <% $worddate %> | <% $job->{'company'} || ucfirst(get_trans('NOT_SPECIFIED')) %> | <% $jobtitle %> | <&| /jscrypt.mas &><% $job->{'site'} %>&> |
% # AND NOW THE ALLMIGHTY BREADCRUMBS % if ( $m->shared()->{'company'} ){ # PURE COMPANY CASE. <& /search/breadcrumb_company.mas , company => $m->shared()->{'company'} , company_norm => $m->shared()->{'company_norm'} , company_letter => $m->shared()->{'company_letter'} &> % } else { <& /search/breadcrumb.mas , q => $query &> % } ## END OF BREADCRUMB CASES.
% ## THE GREAT ACTION BOX <& /search/actionbox.mas &>% unless( $m->shared()->{'company_site'} ){ !!COMPANY_NO_JOBS!! % } else { % my $link = ''.$m->shared()->{'company_site'}.'' ; <% get_trans('COMPANY_NO_JOBS_SITE', undef , { 'company' => $m->shared()->{'company'} , 'sitehref' => $link } ) %> % }
% } else {