Exemple #1
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $action = SJB_Request::getVar('action');
     $api = SJB_Request::getVar('api', false);
     $request = $_REQUEST;
     unset($request['action']);
     switch ($action) {
         case 'header':
             $test = $tp->fetch("header.tpl");
             echo $test;
             exit;
             break;
         case 'simplyHired':
             SJB_Statistics::addStatistics('partneringSites');
             break;
         default:
             $isIPhone = false;
             if (class_exists('MobilePlugin')) {
                 $isIPhone = MobilePlugin::isPhone();
             }
             $url = SJB_Request::getVar('url');
             $url = $url ? base64_decode($url) : '';
             if (str_replace('www.', '', $_SERVER['HTTP_HOST']) === SJB_Settings::getValue('mobile_url') || SJB_Settings::getValue('detect_iphone') && $isIPhone) {
                 $url = str_replace('viewjob', 'm/viewjob', $url);
             }
             SJB_Statistics::addStatistics('partneringSites');
             if ($api && $api == 'indeed') {
                 SJB_HelperFunctions::redirect($url);
             }
             $tp->assign('url', $url);
             $tp->display("partnersite.tpl");
             break;
     }
 }
Exemple #2
0
 public static function getListingsFromBeyond($params)
 {
     $listingTypeID = SJB_ListingTypeManager::getListingTypeIDBySID($params->listing_type_sid);
     if ($listingTypeID == 'Job' && $GLOBALS['uri'] == '/search-results-jobs/' || $GLOBALS['uri'] == '/ajax/') {
         $limit = SJB_Settings::getSettingByName('countBeyondListings');
         $start = $limit * ($params->listing_search_structure['current_page'] - 1) + 1;
         if ($limit) {
             // SET PARAMS FOR REQUEST
             $criteria = $params->criteria_saver->criteria;
             $categoryCriteria = isset($criteria['JobCategory']['multi_like']) ? $criteria['JobCategory']['multi_like'] : '';
             $category = SJB_Settings::getSettingByName('BeyondIndustryList');
             if (!empty($categoryCriteria)) {
                 $categoryFromCriteria = self::getCategory($categoryCriteria);
                 if ($category) {
                     $category = explode('|', $category);
                     $category = array_unique(array_merge($category, $categoryFromCriteria));
                 } else {
                     $category = $categoryFromCriteria;
                 }
                 $category = implode('|', $category);
             }
             $keywords = SJB_Settings::getSettingByName('BeyondKeywords');
             foreach ($criteria as $field) {
                 if (is_array($field)) {
                     foreach ($field as $fieldType => $values) {
                         if ($fieldType === 'multi_like_and') {
                             foreach ($values as $val) {
                                 if ($keywords != '') {
                                     $keywords .= ' AND ';
                                 }
                                 $keywords .= $val;
                             }
                         }
                         if ($fieldType === 'location') {
                             if (isset($values['value']) && !empty($values['value'])) {
                                 if ($keywords != '') {
                                     $keywords .= ' AND ';
                                 }
                                 $keywords .= $values['value'];
                             }
                         }
                         if ($fieldType === 'like') {
                             if ($keywords != '') {
                                 $keywords .= ' AND ';
                             }
                             $keywords .= $values;
                         }
                     }
                 }
             }
             if (isset($criteria['keywords']) && !empty($criteria['keywords'])) {
                 foreach ($criteria['keywords'] as $key => $item) {
                     if (in_array($key, array('exact_phrase', 'any_words', 'all_words', 'like'))) {
                         if (!empty($keywords)) {
                             $keywords .= ' OR ';
                         }
                         $keywords .= $item;
                     }
                 }
             }
             if (substr($keywords, -4) == ' OR ') {
                 $keywords = substr($keywords, 0, strlen($keywords) - 4);
             }
             $keywords = trim($keywords);
             $keywords = urlencode($keywords);
             $keywords = !empty($keywords) ? "({$keywords})" : '';
             $city = '';
             if (!empty($criteria['Location_City']['like'])) {
                 $city = urlencode($criteria['Location_City']['like']);
             } else {
                 if (!empty($criteria['Location_City']['multi_like_and'][0])) {
                     $city = urlencode($criteria['Location_City']['multi_like_and'][0]);
                 } else {
                     if (!empty($criteria['Location']['location']['value'])) {
                         $city = urlencode($criteria['Location']['location']['value']);
                     }
                 }
             }
             $state = SJB_Settings::getSettingByName('BeyondState');
             if (isset($criteria['Location_State']['multi_like'])) {
                 foreach ($criteria['Location_State']['multi_like'] as $stateSID) {
                     if (!empty($stateSID)) {
                         $stateInfo = SJB_StatesManager::getStateInfoBySID($stateSID);
                         $state = !empty($stateInfo['state_code']) ? $stateInfo['state_code'] : '';
                     }
                 }
             }
             $countryCriteria = isset($criteria['Location_Country']['multi_like'][0]) ? $criteria['Location_Country']['multi_like'][0] : SJB_Settings::getSettingByName('BeyondCountry');
             $country = SJB_Settings::getSettingByName('BeyondCountry');
             if ($countryCriteria && is_numeric($countryCriteria)) {
                 $countryInfo = SJB_CountriesManager::getCountryInfoBySID($countryCriteria);
                 $country = !empty($countryInfo['country_code']) ? $countryInfo['country_code'] : '';
             }
             $employmentTypeCriteria = isset($criteria['EmploymentType']['multi_like']) ? $criteria['EmploymentType']['multi_like'] : '';
             $employmentType = SJB_Settings::getSettingByName('BeyonEmploymentType');
             if ($employmentTypeCriteria) {
                 $employmentType = self::getEmploymentType($employmentTypeCriteria);
             }
             $zipCode = SJB_Settings::getSettingByName('BeyondZipcode');
             if (isset($criteria['Location_ZipCode']['geo']['location']) && !empty($criteria['Location_ZipCode']['geo']['location'])) {
                 $zipCode = $criteria['Location_ZipCode']['geo']['location'];
             }
             $educationLevel = SJB_Settings::getSettingByName('BeyonEducationLevel');
             $experienceLevel = SJB_Settings::getSettingByName('BeyonExperienceLevel');
             $affID = SJB_Settings::getSettingByName('BeyondAffiliateID');
             $isIPhone = false;
             if (class_exists('MobilePlugin')) {
                 $isIPhone = MobilePlugin::isPhone();
             }
             if (str_replace('www.', '', $_SERVER['HTTP_HOST']) === SJB_Settings::getValue('mobile_url') || SJB_Settings::getValue('detect_iphone') && $isIPhone) {
                 $mobileAffID = SJB_Settings::getSettingByName('MobileBeyondAffiliateID');
                 $affID = $mobileAffID ? $mobileAffID : $affID;
             }
             $url = "http://www.beyond.com/common/services/job/search/default.asp?aff={$affID}&kw={$keywords}&kt=3&il={$category}&ct={$country}&st={$state}&zc={$zipCode}&el={$educationLevel}&et={$employmentType}&ex={$experienceLevel}&nw=e&pn={$start}&mx={$limit}&fwhere={$city}";
             $ch = curl_init();
             // set URL and other appropriate options
             curl_setopt($ch, CURLOPT_URL, $url);
             curl_setopt($ch, CURLOPT_HEADER, 0);
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
             // grab URL and pass it to the browser
             $xml = curl_exec($ch);
             // close cURL resource, and free up system resources
             curl_close($ch);
             $beyondListings = array();
             if ($xml !== false) {
                 $doc = new DOMDocument();
                 $doc->loadXML($xml, LIBXML_NOERROR | LIBXML_NOWARNING);
                 $results = $doc->getElementsByTagName('Item');
                 if ($results instanceof DOMNodeList) {
                     // if we need just total results number
                     foreach ($results as $node) {
                         $resultXML = simplexml_import_dom($node);
                         $jobKey = (string) $resultXML->SourceInformationID;
                         $location = explode(',', (string) $resultXML->Location);
                         $state = '';
                         $stateCode = '';
                         $country = '';
                         $city = !empty($location[0]) ? $location[0] : '';
                         if (isset($location[1])) {
                             $location = explode(' ', trim($location[1]));
                             if (!empty($location[0])) {
                                 $stateCode = trim($location[0]);
                                 $state = self::getState($stateCode);
                             }
                             if (!empty($location[1])) {
                                 $country = self::getCountry(trim($location[1]));
                             }
                         }
                         $beyondListings[$jobKey] = array('Title' => (string) $resultXML->Title, 'CompanyName' => (string) $resultXML->CompanyName, 'JobDescription' => (string) $resultXML->ShortDescription, 'JobCategory' => (string) $resultXML->CareerFocus, 'State' => $state, 'Country' => $country, 'City' => $city, 'Location' => array('Country' => $country, 'State' => $state, 'State_Code' => $stateCode, 'City' => $city), 'url' => SJB_System::getSystemSettings('SITE_URL') . '/partnersite/?url=' . base64_encode((string) $resultXML->ApplyURL), 'jobkey' => $jobKey, 'activation_date' => (string) $resultXML->Modified, 'api' => 'beyond', 'code' => '<span id=beyond_at><a href="http://www.beyond.com/">jobs</a> by <a href="http://www.beyond.com/" title="Job Search"><img src="' . SJB_System::getSystemSettings('SITE_URL') . '/system/plugins/beyond_integration_plugin/logo.png" style="border: 0; vertical-align: middle;" alt="Beyond job search"></a></span>');
                     }
                 } else {
                     SJB_Logger::error('CANT GET BEYOND XML RESULTS');
                 }
             } else {
                 SJB_Logger::error('NOT VALID RESPONSE FROM BEYOND');
             }
             self::$beyondListings = $beyondListings;
         }
     }
     return $params;
 }