Esempio n. 1
0
 public function __call($name, $arguments)
 {
     $value = '';
     $aParams = explode('_', $name);
     $method = array_shift($aParams);
     if ('get' == $method) {
         $returnType = SJB_Array::get($arguments, 0);
         $fieldType = SJB_Array::get($arguments, 1);
         $listingFieldID = SJB_Array::get($arguments, 2);
         $value = null;
         switch ($returnType) {
             case 'array':
             case 'string':
             case 'int':
                 $type = '(' . $returnType . ')';
                 break;
             default:
                 $type = '(string)';
                 break;
         }
         $val = '$this->oProfile->' . implode('->', array_map('strtolower', $aParams));
         $exec = 'return (!empty(' . $val . ')) ? ' . $type . $val . ': \'\';';
         switch ($fieldType) {
             case 'tree':
                 $exec = 'return (!empty(' . $val . ')) ? ' . $type . $val . ': \'\';';
                 $value = eval($exec);
                 if (is_array($value)) {
                     if (isset($value[0])) {
                         $value = $value[0];
                     }
                 }
                 $value = $this->getTreeValues($value, $listingFieldID);
                 break;
             case 'array':
                 $listingFieldSID = SJB_ListingFieldManager::getListingFieldSIDByID($listingFieldID);
                 if (!empty($listingFieldSID)) {
                     $exec = 'return (!empty(' . $val . ')) ? ' . $val . ': \'\';';
                     $value = eval($exec);
                     $value = SJB_ListingFieldManager::getListItemSIDByValue($value, $listingFieldSID);
                     $value = eval('return ' . $type . ' $value;');
                 }
                 break;
             default:
                 $value = eval($exec);
                 break;
         }
     }
     return $value;
 }
Esempio n. 2
0
 public static function getPropertyByParentID($parentID, $fieldID, $listing_type_sid = 0)
 {
     $parentSID = SJB_ListingFieldManager::getListingFieldSIDByID($parentID);
     $fields = SJB_ListingFieldManager::getListingFieldsInfoByParentSID($parentSID);
     $fieldSID = null;
     foreach ($fields as $field) {
         if ($field['id'] == $fieldID) {
             $fieldSID = $field['sid'];
         }
     }
     if ($fieldSID) {
         $property_info = SJB_ListingFieldDBManager::getListingFieldInfoBySID($fieldSID);
         $property_info['id'] = $parentID . "_" . $property_info['id'];
         $fieldID = $property_info['id'];
         return new SJB_ObjectProperty($property_info);
     }
     return null;
 }
Esempio n. 3
0
 function _getWhereCommonStatement($criteria)
 {
     $where_common_block = 'AND (0 ';
     foreach ($criteria as $property_criteria) {
         $where_AND_block = '';
         foreach ($property_criteria as $criterion) {
             if ($criterion->isValid() && SJB_ListingFieldManager::getListingFieldSIDByID($criterion->property_name)) {
                 $sql = $criterion->getSQL();
                 if ($sql !== null) {
                     $where_AND_block .= 'AND ' . $sql . ' ';
                 }
             }
         }
         if (!empty($where_AND_block)) {
             $where_common_block .= sprintf('OR(1 %s) ', $where_AND_block);
             $this->valid_criterion_number++;
         }
     }
     if ($this->valid_criterion_number == 0) {
         $where_common_block = '';
     } else {
         $where_common_block .= ') ';
     }
     return $where_common_block;
 }
Esempio n. 4
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     if (isset($_REQUEST['listing_type_id'])) {
         $listing_type_id = $_REQUEST['listing_type_id'];
         SJB_Session::setValue('listing_type_id', $listing_type_id);
     } elseif (isset($_REQUEST['restore'])) {
         $listing_type_id = SJB_Session::getValue('listing_type_id');
     } else {
         SJB_Session::setValue('listing_type_id', null);
     }
     $listing_type_sid = 0;
     if (!empty($listing_type_id)) {
         $listing_type_sid = SJB_ListingTypeManager::getListingTypeSIDByID($listing_type_id);
     }
     if (!isset($_REQUEST['listing_type']['equal']) && isset($listing_type_id)) {
         $_REQUEST['listing_type']['equal'] = $listing_type_id;
     }
     if (isset($_REQUEST['searchId'])) {
         $criteria_saver = new SJB_ListingCriteriaSaver($_REQUEST['searchId']);
         $_REQUEST = array_merge($_REQUEST, $criteria_saver->getCriteria());
     }
     $empty_listing = new SJB_Listing(array(), $listing_type_sid);
     $empty_listing->addIDProperty();
     $empty_listing->addActivationDateProperty();
     $empty_listing->addUsernameProperty();
     $empty_listing->addKeywordsProperty();
     $empty_listing->addPicturesProperty();
     $empty_listing->addListingTypeIDProperty();
     $empty_listing->addPostedWithinProperty();
     $search_form_builder = new SJB_SearchFormBuilder($empty_listing);
     $criteria = SJB_SearchFormBuilder::extractCriteriaFromRequestData($_REQUEST);
     $properties = $empty_listing->getProperties();
     foreach ($properties as $propertyName => $property) {
         if ($property->getType() == 'location') {
             $propertyInfo = $property->type->property_info;
             if ($propertyInfo['enable_search_by_radius'] == 1) {
                 if (!isset($criteria['system'][$propertyName])) {
                     $value = array('value' => '', 'radius' => '10');
                     $criterion = SJB_SearchCriterion::getCriterionByType('location');
                     $criterion->setProperty($property);
                     $criterion->setPropertyName($propertyName);
                     $criterion->setValue($value);
                     $criteria['system'][$propertyName][] = $criterion;
                 }
             }
         }
     }
     $search_form_builder->setCriteria($criteria);
     $search_form_builder->registerTags($tp);
     $form_fields = $search_form_builder->getFormFieldsInfo();
     $metaDataProvider = SJB_ObjectMother::getMetaDataProvider();
     $template = SJB_Request::getVar('form_template', 'search_form.tpl');
     $formBuilder = SJB_FormBuilderManager::getFormBuilder(SJB_FormBuilderManager::FORM_BUILDER_TYPE_SEARCH, $listing_type_id);
     $formBuilder->setChargedTemplateProcessor($tp);
     if ($template == 'quick_search.tpl') {
         $fieldSID = SJB_ListingFieldManager::getListingFieldSIDByID('Location');
         if ($fieldSID) {
             $fields = SJB_ListingFieldManager::getFieldInfoBySID($fieldSID);
             if (!empty($fields['fields'])) {
                 foreach ($fields['fields'] as $field) {
                     $form_fields[$fields['id'] . '_' . $field['id']] = $field;
                 }
             }
             $tp->assign('locationFields', array($fields));
         }
     }
     $tp->assign('form_fields', $form_fields);
     $tp->assign('METADATA', array('form_fields' => $metaDataProvider->getFormFieldsMetadata($form_fields)));
     $tp->display($template);
 }
Esempio n. 5
0
 public static function getListingsFromSimplyHired($params)
 {
     $listingTypeID = SJB_ListingTypeManager::getListingTypeIDBySID($params->listing_type_sid);
     if ($listingTypeID == 'Job' && $GLOBALS['uri'] == '/search-results-jobs/' || $GLOBALS['uri'] == '/ajax/') {
         $publisherID = SJB_Settings::getSettingByName('simplyHiredPublisherID');
         $limit = SJB_Settings::getSettingByName('countSimplyHiredListings');
         $ip = $_SERVER['REMOTE_ADDR'];
         $userAgent = urlencode(SJB_Request::getUserAgent());
         $start = $limit * ($params->listing_search_structure['current_page'] - 1) + 1;
         $stateIndexes = array('AL' => 'Alabama', 'AK' => 'Alaska', 'AZ' => 'Arizona', 'AR' => 'Arkansas', 'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware', 'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho', 'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas', 'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine', 'MD' => 'Maryland', 'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi', 'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada', 'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York', 'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma', 'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina', 'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah', 'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia', 'WI' => 'Wisconsin', 'WY' => 'Wyoming', 'DC' => 'District of Columbia', 'AS' => 'American Samoa', 'GU' => 'Guam', 'MP' => 'Northern Mariana Islands', 'PR' => 'Puerto Rico', 'UM' => "United's Minor Outlying Islands", 'VI' => 'Virgin Islands');
         $countryCodes = array('United States' => 'us', 'Australia' => 'au', 'Austria' => 'at', 'Belgium' => 'be', 'Brazil' => 'br', 'Canada' => 'ca', 'France' => 'fr', 'Germany' => 'de', 'India' => 'in', 'Ireland' => 'ie', 'Italy' => 'it', 'Mexico' => 'mx', 'Netherlands' => 'nl', 'Spain' => 'es', 'Switzerland' => 'ch', 'United Kingdom' => 'gb');
         // SET PARAMS FOR REQUEST
         $keywords = '';
         $criteria = $params->criteria_saver->criteria;
         $fieldSID = SJB_ListingFieldManager::getListingFieldSIDByID('JobCategory');
         $fieldInfo = SJB_ListingFieldDBManager::getListValuesBySID($fieldSID);
         $fieldList = array();
         foreach ($fieldInfo as $val) {
             $fieldList[$val['id']] = $val['caption'];
         }
         $categoryCriteria = isset($criteria['JobCategory']['multi_like']) ? $criteria['JobCategory']['multi_like'] : '';
         if (!empty($categoryCriteria)) {
             foreach ($categoryCriteria as $category) {
                 if (!empty($fieldList[$category])) {
                     $keywords .= empty($keywords) ? $fieldList[$category] : ' OR ' . $fieldList[$category];
                 }
             }
             if (!empty($keywords)) {
                 $keywords = "({$keywords})";
             }
         }
         foreach ($criteria as $field) {
             if (is_array($field)) {
                 foreach ($field as $fieldType => $values) {
                     if ($fieldType == 'multi_like_and') {
                         foreach ($values as $val) {
                             $keywords .= empty($keywords) ? $val : ' ' . $val;
                         }
                     }
                 }
             }
         }
         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'))) {
                     $keywords .= $item;
                 }
             }
         }
         $systemKeywords = trim(SJB_Settings::getSettingByName('simplyHiredKeyword'));
         $keywords = $systemKeywords ? '(' . $systemKeywords . ')' . ($keywords ? ' OR (' . $keywords . ')' : '') : $keywords;
         $keywords = preg_replace('/\\s+/', ' ', $keywords);
         $keywords = str_replace(',', '', $keywords);
         $keywords = urlencode(trim($keywords));
         $location = self::getLocation($criteria, 'simplyHiredLocation');
         $radius = SJB_Settings::getSettingByName('simplyHiredMiles');
         if (isset($criteria['Location_ZipCode']['geo']['radius']) && !empty($criteria['Location_ZipCode']['geo']['radius'])) {
             $radius = $criteria['Location_ZipCode']['geo']['radius'];
             if ($radius == 'any') {
                 $radius = '';
             }
         }
         $sortBy = SJB_Settings::getSettingByName('simplyHiredSortBy');
         $siteUrl = SJB_Settings::getSettingByName('simplyHiredSiteUrl');
         $jobAMaticDomain = SJB_Settings::getSettingByName('jobAMaticDomain', false);
         if (!empty($jobAMaticDomain) && $siteUrl == 'simplyhired.com') {
             $jobAMaticDomain = str_replace('http://', '', $jobAMaticDomain);
             $jobAMaticDomain = str_replace('/', '', $jobAMaticDomain);
             $jobAMaticDomain = "&jbd={$jobAMaticDomain}";
         } else {
             $jobAMaticDomain = '';
         }
         if ($siteUrl == 'simplyhired.com') {
             $ssty = 2;
         } else {
             $ssty = 3;
         }
         $url = "http://api.{$siteUrl}/a/jobs-api/xml-v2/q-{$keywords}/l-{$location}/mi-{$radius}/ws-{$limit}/pn-{$params->listing_search_structure['current_page']}/sb-{$sortBy}?pshid={$publisherID}&ssty={$ssty}&cflg=r{$jobAMaticDomain}&clip={$ip}";
         $sxml = new simplexml();
         $xmlString = SJB_HelperFunctions::getUrlContentByCurl($url);
         $simplyhiredListings = array();
         if ($xmlString === false) {
             //				throw new Exception("simplyHiredPlugin: Failed to read XML from url - {$url}");
             SJB_Logger::error("simplyHiredPlugin: Failed to read XML from url - {$url}");
         } else {
             //$tree = $sxml->xml_load_file($url, 'array');
             $tree = $sxml->xml_load_file($xmlString, 'array');
             $totalResults = 0;
             if ($tree !== false) {
                 $results = isset($tree['rs']) ? $tree['rs'] : array();
                 $outputCountry = array_flip($countryCodes);
                 foreach ($results as $node) {
                     if ($tree['rq']['rpd'] == 1) {
                         $node = array($node);
                     }
                     foreach ($node as $key => $result) {
                         $state = (string) $result['loc']['@attributes']['st'];
                         $country = (string) $result['loc']['@attributes']['country'];
                         $simplyhiredListings[$key] = array('Title' => (string) $result['jt'], 'CompanyName' => (string) isset($result['cn']['@content']) ? $result['cn']['@content'] : '', 'JobDescription' => (string) $result['e'], 'Location' => array('Country' => empty($country) ? '' : (isset($outputCountry[strtolower($country)]) ? $outputCountry[strtolower($country)] : ''), 'State' => empty($location[1]) ? '' : (isset($stateIndexes[strtoupper($state)]) ? $stateIndexes[strtoupper($state)] : ''), 'State_Code' => empty($state) ? '' : strtoupper($state), 'City' => (string) $result['loc']['@attributes']['cty']), 'activation_date' => (string) $result['dp'], 'url' => (string) $result['src']['@attributes']['url'], 'api' => 'simplyHired', 'onmousedown' => ' onMouseDown="xml_sclk(this);" ', 'target' => ' target="_blank"', 'onclick' => 'onclick="addStatisticsForSimplyHired();" ', 'code' => '<span style="font-size:10px; position:relative; top:-5px; font-family:Arial,sans-serif;color: #333;"><a style="color: #333; text-decoration:none" href="' . SJB_Request::getProtocol() . '://www.simplyhired.com/">Jobs</a> by</span> <a STYLE="text-decoration:none" href="' . SJB_Request::getProtocol() . '://www.simplyhired.com/"><img src="' . SJB_Request::getProtocol() . '://www.jobamatic.com/c/jbb/images/simplyhired.png" alt="Simply Hired"></a>');
                     }
                 }
             }
         }
         self::$simplyhiredListings = $simplyhiredListings;
     }
     return $params;
 }
Esempio n. 6
0
 private static function getCategory($categories)
 {
     $industryList = (require_once 'industry_config.php');
     $result = array();
     $fieldSID = SJB_ListingFieldManager::getListingFieldSIDByID('JobCategory');
     $fieldInfo = SJB_ListingFieldDBManager::getListValuesBySID($fieldSID);
     $fieldList = array();
     foreach ($fieldInfo as $val) {
         $fieldList[$val['id']] = $val['caption'];
     }
     foreach ($categories as $category) {
         if (!empty($fieldList[$category]) && isset($industryList[$fieldList[$category]])) {
             $result[] = $industryList[$fieldList[$category]];
         }
     }
     return array_unique($result);
 }
Esempio n. 7
0
 public static function getListingsFromIndeed($params)
 {
     $listingTypeID = SJB_ListingTypeManager::getListingTypeIDBySID($params->listing_type_sid);
     if ($listingTypeID == 'Job' && $GLOBALS['uri'] == '/search-results-jobs/' || $GLOBALS['uri'] == '/ajax/') {
         $page = isset($_REQUEST['page']) ? $_REQUEST['page'] : $params->listing_search_structure['current_page'];
         $publisherID = SJB_Settings::getSettingByName('IndeedPublisherID');
         $limit = SJB_Settings::getSettingByName('countIndeedListings');
         $ip = $_SERVER['REMOTE_ADDR'];
         $userAgent = urlencode(SJB_Request::getUserAgent());
         $start = $limit * ($page - 1);
         $stateIndexes = array('AL' => 'Alabama', 'AK' => 'Alaska', 'AZ' => 'Arizona', 'AR' => 'Arkansas', 'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware', 'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho', 'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas', 'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine', 'MD' => 'Maryland', 'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi', 'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada', 'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York', 'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma', 'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina', 'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah', 'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia', 'WI' => 'Wisconsin', 'WY' => 'Wyoming', 'DC' => 'District of Columbia', 'AS' => 'American Samoa', 'GU' => 'Guam', 'MP' => 'Northern Mariana Islands', 'PR' => 'Puerto Rico', 'UM' => "United's Minor Outlying Islands", 'VI' => 'Virgin Islands');
         $countryCodes = array('United States' => 'us', 'Argentina' => 'ar', 'Australia' => 'au', 'Austria' => 'at', 'Bahrain' => 'bh', 'Belgium' => 'be', 'Brazil' => 'br', 'Canada' => 'ca', 'Chile' => 'cl', 'China' => 'cn', 'Colombia' => 'co', 'Czech Republic' => 'cz', 'Denmark' => 'dk', 'Finland' => 'fi', 'France' => 'fr', 'Germany' => 'de', 'Greece' => 'gr', 'Hong Kong' => 'hk', 'Hungary' => 'hu', 'India' => 'in', 'Indonesia' => 'id', 'Ireland' => 'ie', 'Israel' => 'il', 'Italy' => 'it', 'Japan' => 'jp', 'Korea' => 'kr', 'Kuwait' => 'kw', 'Luxembourg' => 'lu', 'Malaysia' => 'my', 'Mexico' => 'mx', 'Netherlands' => 'nl', 'New Zealand' => 'nz', 'Norway' => 'no', 'Oman' => 'om', 'Pakistan' => 'pk', 'Peru' => 'pe', 'Philippines' => 'ph', 'Poland' => 'pl', 'Portugal' => 'pt', 'Qatar' => 'qa', 'Romania' => 'ro', 'Russia' => 'ru', 'Russian Federation' => 'ru', 'Saudi Arabia' => 'sa', 'Singapore' => 'sg', 'South Africa' => 'za', 'Spain' => 'es', 'Sweden' => 'se', 'Switzerland' => 'ch', 'Taiwan' => 'tw', 'Turkey' => 'tr', 'United Arab Emirates' => 'ae', 'United Kingdom' => 'gb', 'Venezuela' => 've');
         $countryDomains = array('us' => 'indeed.com', 'ar' => 'ar.indeed.com', 'au' => 'au.indeed.com', 'at' => 'at.indeed.com', 'bh' => 'bh.indeed.com', 'be' => 'be.indeed.com', 'br' => 'indeed.com.br', 'ca' => 'ca.indeed.com', 'cl' => 'indeed.cl', 'cn' => 'cn.indeed.com', 'co' => 'co.indeed.com', 'cz' => 'cz.indeed.com', 'dk' => 'dk.indeed.com', 'fi' => 'indeed.fi', 'fr' => 'indeed.fr', 'de' => 'de.indeed.com', 'gr' => 'gr.indeed.com', 'hk' => 'indeed.hk', 'hu' => 'hu.indeed.com', 'in' => 'indeed.co.in', 'id' => 'id.indeed.com', 'ie' => 'ie.indeed.com', 'il' => 'il.indeed.com', 'it' => 'it.indeed.com', 'jp' => 'jp.indeed.com', 'kr' => 'kr.indeed.com', 'kw' => 'kw.indeed.com', 'lu' => 'indeed.lu', 'my' => 'indeed.com.my', 'mx' => 'indeed.com.mx', 'nl' => 'indeed.nl', 'nz' => 'nz.indeed.com', 'no' => 'no.indeed.com', 'om' => 'om.indeed.com', 'pk' => 'indeed.com.pk', 'pe' => 'indeed.com.pe', 'ph' => 'indeed.com.ph', 'pl' => 'pl.indeed.com', 'pt' => 'indeed.pt', 'qa' => 'qa.indeed.com', 'ro' => 'ro.indeed.com', 'ru' => 'ru.indeed.com', 'sa' => 'sa.indeed.com', 'sg' => 'indeed.com.sg', 'za' => 'indeed.co.za', 'es' => 'indeed.es', 'se' => 'se.indeed.com', 'ch' => 'indeed.ch', 'tw' => 'tw.indeed.com', 'tr' => 'tr.indeed.com', 'ae' => 'indeed.ae', 'gb' => 'indeed.co.uk', 've' => 've.indeed.com');
         // SET PARAMS FOR REQUEST
         $keywords = '';
         $criteria = $params->criteria_saver->criteria;
         $fieldSID = SJB_ListingFieldManager::getListingFieldSIDByID('JobCategory');
         $fieldInfo = SJB_ListingFieldDBManager::getListValuesBySID($fieldSID);
         $fieldList = array();
         foreach ($fieldInfo as $val) {
             $fieldList[$val['id']] = $val['caption'];
         }
         $categoryCriteria = isset($criteria['JobCategory']['multi_like']) ? $criteria['JobCategory']['multi_like'] : '';
         if (!empty($categoryCriteria)) {
             if (!empty($keywords)) {
                 $keywords .= ' or ';
             }
             foreach ($categoryCriteria as $category) {
                 if (!empty($category) && !empty($fieldList[$category])) {
                     $keywords .= $fieldList[$category] . ' or ';
                 }
             }
             $keywords = substr($keywords, 0, strlen($keywords) - 4);
         }
         foreach ($criteria as $fieldName => $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 (isset($criteria['keywords']) && !empty($criteria['keywords'])) {
             foreach ($criteria['keywords'] as $key => $item) {
                 if (in_array($key, array('exact_phrase', 'any_words', 'all_words'))) {
                     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);
         $location = self::getLocation($criteria);
         if (isset($criteria['Location']['location']['radius']) && !empty($criteria['Location']['location']['radius'])) {
             if ($criteria['Location']['location']['radius'] == 'any') {
                 $radius = '';
             } else {
                 $radius = $criteria['Location']['location']['radius'];
             }
         } else {
             $radius = 0;
         }
         $indeedCountry = SJB_Settings::getSettingByName('IndeedCountry');
         $country = !empty($criteria['Location_Country']['multi_like'][0]) ? $criteria['Location_Country']['multi_like'][0] : $indeedCountry;
         $codes = array_values($countryCodes);
         if (!in_array($country, $codes)) {
             // ok. Country value - not correct Indeed value. Lets try convert it.
             if (is_numeric($country)) {
                 $countryInfo = SJB_CountriesManager::getCountryInfoBySID($country);
                 $country = !empty($countryInfo['country_code']) ? $countryInfo['country_code'] : '';
             }
         }
         $jobType = SJB_Settings::getSettingByName('IndeedJobType');
         $siteType = SJB_Settings::getSettingByName('IndeedSiteType');
         $sort = SJB_Settings::getSettingByName('IndeedSort');
         $highlight = SJB_Settings::getSettingByName('IndeedHighlightKeywords');
         $url = "http://api.indeed.com/ads/apisearch?publisher={$publisherID}&q={$keywords}&l={$location}&sort={$sort}&radius={$radius}&st={$siteType}&jt={$jobType}&start={$start}&limit={$limit}&fromage=&filter=&latlong=1&co={$country}&highlight={$highlight}&chnl=&userip={$ip}&useragent={$userAgent}&v=2";
         $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);
         curl_close($ch);
         $indeedListings = array();
         if ($xml !== false) {
             $doc = new DOMDocument();
             try {
                 $doc->loadXML($xml, LIBXML_NOERROR);
                 $results = $doc->getElementsByTagName('results');
                 if ($results instanceof DOMNodeList) {
                     $outputCountry = array_flip($countryCodes);
                     $totalResults = $doc->getElementsByTagName('totalresults')->item(0)->nodeValue;
                     $totalPages = ceil((int) $totalResults / $limit);
                     $pageNumber = $doc->getElementsByTagName('pageNumber')->item(0)->nodeValue;
                     $indeedDomain = !empty($indeedCountry) && isset($countryDomains[$indeedCountry]) ? $countryDomains[$indeedCountry] : $countryDomains['us'];
                     if (strpos($indeedDomain, '.') !== 2) {
                         $indeedDomain = 'www.' . $indeedDomain;
                     }
                     foreach ($results as $node) {
                         foreach ($node->getElementsByTagName('result') as $result) {
                             $resultXML = simplexml_import_dom($result);
                             $jobKey = (string) $resultXML->jobkey;
                             $state = (string) $resultXML->state;
                             $country = (string) $resultXML->country;
                             $indeedListings[$jobKey] = array('Title' => (string) $resultXML->jobtitle, 'CompanyName' => (string) $resultXML->company, 'JobDescription' => (string) $resultXML->snippet, 'Location' => array('Country' => empty($country) ? '' : $outputCountry[strtolower($country)], 'State' => empty($state) ? '' : isset($stateIndexes[strtoupper($state)]) ? $stateIndexes[strtoupper($state)] : $state, 'State_Code' => empty($state) ? '' : strtoupper($state), 'City' => (string) $resultXML->city), 'url' => (string) $resultXML->url, 'onmousedown' => ' onMouseDown="' . (string) $resultXML->onmousedown . '" ', 'target' => ' target="_blank" ', 'jobkey' => $jobKey, 'activation_date' => (string) $resultXML->date, 'api' => 'indeed', 'code' => '<span id="indeed_at"><a href="' . SJB_Request::getProtocol() . '://' . $indeedDomain . '/">jobs</a> by <a href="' . SJB_Request::getProtocol() . '://' . $indeedDomain . '/" title="Job Search"><img src="' . SJB_Request::getProtocol() . '://www.indeed.com/p/jobsearch.gif" style="border: 0; vertical-align: middle;" alt="Indeed job search"></a></span>', 'pageNumber' => $pageNumber, 'totalPages' => $totalPages);
                         }
                     }
                 } else {
                     SJB_Logger::error('CANT GET INDEED XML RESULTS');
                 }
             } catch (ErrorException $e) {
                 SJB_Logger::error($e->getMessage());
             }
         } else {
             SJB_Logger::error('NOT VALID RESPONSE FROM INDEED');
         }
         self::$indeedListings = $indeedListings;
     }
     return $params;
 }
Esempio n. 8
0
 public function get_Country($returnType, $listingFieldID)
 {
     $value = SJB_Countries::getCountryNameByISO2((string) $this->oProfile->location->country->code);
     if (!empty($value)) {
         $listingFieldSID = SJB_ListingFieldManager::getListingFieldSIDByID($listingFieldID);
         if ($listingFieldSID) {
             $value = SJB_ListingFieldManager::getListItemSIDByValue($value, $listingFieldSID);
             return eval('return (' . $returnType . ') $value;');
         }
     }
 }
Esempio n. 9
0
 public static function isValid($type)
 {
     if (!SJB_ListingFieldManager::getListingFieldSIDByID($type->property_info['value'])) {
         if (SJB_DB::query('SHOW COLUMNS FROM `listings` WHERE `Field` = ?s', $type->property_info['value'])) {
             return 'NOT_UNIQUE_VALUE';
         }
     }
     return true;
 }