replace('C_', 'matchCriteria_', $vacancyLabel);
$criteriaName = array_key_exists($vacancyNameKey, $vacancy['matchCriteriaNames']) ? $vacancy['matchCriteriaNames'][$vacancyNameKey] : $vacancyLabel;
$vacancy['labels'][$vacancyLabel] = [
'name' => $criteriaName,
'values' => $vacancy[$vacancyNameKey]
];
}
// Add categorie
if ($vacancyLabel === 'category' && isset($vacancy['category']) && $vacancy['category'] !== NULL) {
$vacancy['labels'][$vacancyLabel] = [
'name' => __('Category', 'otys-jobs-apply'),
'values' => [$vacancy['category']]
];
}
}
}
/**
* Add consultant info
*/
$vacancy['consultantInfo'] = null;
if (isset($vacancy['userId']) && is_int($vacancy['userId']) && $vacancy['userId'] !== 0) {
$userInfo = ConsultantModel::get($vacancy['userId']);
if (!is_wp_error($userInfo)) {
$vacancy['consultantInfo'] = $userInfo;
}
}
/**
* Add vacancy url
*/
$vacancy['applyUrl'] = Routes::get('vacancy-apply', [
'slug' => $customSlugIsActive ? $vacancy['slug'][$website] : sanitize_title($vacancy['title']) . '-' . $vacancy['uid']
]);
/**
* Add vacancy fallback image
*/
$fallbackIamgeId = get_option('otys_option_vacancies_header_falllback', '');
$vacancy['vacancyFallbackImage'] = ($fallbackIamgeId !== '') ? wp_get_attachment_url($fallbackIamgeId) : esc_url(OTYS_PLUGIN_ASSETS_URL) . '/images/vacancies/vacancy-header.jpg';
/**
* Add image url's
*/
// Set gallery url's
if (is_array($vacancy['PhotoGallery'])) {
foreach ($vacancy['PhotoGallery'] as $galleryKey => $galleryItem) {
$vacancy['PhotoGallery'][$galleryKey]['photoUrl'] = $uploadUrl. $galleryItem['photo'];
$vacancy['PhotoGallery'][$galleryKey]['thumbnailUrl'] = $uploadUrl. $galleryItem['thumbnail'];
}
}
// Check if there is a relation logo is present and add a new variable including the entire url
$vacancy['relationLogoUrl'] = (isset($vacancy['relationLogoFileName']) && $vacancy['relationLogoFileName']) ?
$uploadUrl . $vacancy['relationLogoFileName'] : null;
// Check if there is a photo present and add a new variable including the entire url
$vacancy['photoUrl'] = (isset($vacancy['photoFileName']) && $vacancy['photoFileName']) ?
$uploadUrl . $vacancy['photoFileName'] : null;
// Check if there is a photo thumbnail present and add a new variable including the entire url
$vacancy['photoThumbUrl'] = (isset($vacancy['photoThumbFileName']) && $vacancy['photoThumbFileName']) ?
$uploadUrl . $vacancy['photoThumbFileName'] : null;
}
return $vacancy;
}
/**
* Get labels which should be shown
*
* @return array
*/
private static function getLabelsToShow(): array
{
$settingName = 'otys_option_vacancies_detail_match_criteria_labels';
if (($matchCriteriaToShow = get_option($settingName, false)) === false || !is_array($matchCriteriaToShow)) {
return [];
}
$filteredValues = array_filter($matchCriteriaToShow, function ($val) {
return $val === 'true';
});
return is_array($filteredValues) ? array_keys($filteredValues) : [];
}
/**
* Get extra fields for vacancies
*
* @return array | \WP_error
*/
public static function getExtraFields()
{
// Get current WordPress language
$language = OtysApi::getLanguage();
$extraFields = OtysApi::post([
'method' => 'Otys.Services.VacancyService.getExtraFieldsList',
'params' => [$language]
], true);
return $extraFields;
}
/**
* getFields returns a list of the textfields in OTYS and wheter the textFields are published or not
* Textfields are based on setting GE127
*
* @return array | \WP_Error
* @since 1.0.0
*/
public static function getTextFields()
{
$textFields = OtysApi::post([
'method' => 'Otys.Services.VacancyTextFieldService.getList',
'params' => []
], true);
if (is_wp_error($textFields) || !is_array($textFields)) {
return $textFields;
}
// Assign the OWS Fieldname to every textField
foreach ($textFields as $keyTexTfield => $textField) {
$textFields[$keyTexTfield]['owsName'] = static::getTextFieldsOwsName($textField['field']);
}
return $textFields;
}
/**
* getTextFieldsOwsName
*
* @param mixed $fieldName
* @return string
* @since 1.0.0
*/
public static function getTextFieldsOwsName(string $fieldName): string
{
$fieldNames = [
'bedrprofiel' => 'textField_companyProfile',
'functieo' => 'textField_description',
'functiee' => 'textField_requirements',
'sal_o' => 'textField_salary',
'chapo' => 'textField_summary',
'bedrcultuur' => 'textField_companyCulture',
'extra_fld_01' => 'textField_extra1',
'extra_fld_02' => 'textField_extra2',
'extra_fld_03' => 'textField_extra3',
'extra_fld_04' => 'textField_extra4',
'extra_fld_05' => 'textField_extra5',
'extra_fld_06' => 'textField_extra6',
'extra_fld_07' => 'textField_extra7',
'extra_fld_08' => 'textField_extra8',
'extra_fld_09' => 'textField_extra9',
'extra_fld_10' => 'textField_extra10'
];
return array_key_exists($fieldName, $fieldNames) ? $fieldNames[$fieldName] : '';
}
}