Skip to content
Snippets Groups Projects
Commit eda8bc96 authored by Eric Bremner's avatar Eric Bremner Committed by Martin Leblanc
Browse files

ISTWCMS-5214: adding theming for opportunity nodes and fixing dates

parent 69921537
No related branches found
No related tags found
1 merge request!188ISTWCMS-5214: adding theming for opportunity nodes and fixing dates
......@@ -190,6 +190,7 @@ class UWService implements UWServiceInterface {
'uw_ct_contact',
'uw_ct_event',
'uw_ct_news_item',
'uw_ct_opportunity',
'uw_ct_profile',
'uw_ct_web_page',
'uw_ct_service',
......@@ -202,6 +203,7 @@ class UWService implements UWServiceInterface {
'uw_ct_contact',
'uw_ct_event',
'uw_ct_news_item',
'uw_ct_opportunity',
'uw_ct_profile',
'uw_ct_catalog_item',
'uw_ct_service',
......
......@@ -84,6 +84,10 @@ class UwNodeContent {
case 'uw_ct_service':
$content_data = $this->getServiceContent($node_flags);
break;
case 'uw_ct_opportunity':
$content_data = $this->getOpportunityContent($node_flags);
break;
}
return $this->uwNodeData->getNodeData($node, $view_mode, $content_data);
......@@ -622,6 +626,55 @@ class UwNodeContent {
return $content_data;
}
/**
* Get the node content for opportunity content type.
*
* @param array $node_flags
* The flags for the node.
*
* @return array
* Array of content to get from the node.
*/
public function getOpportunityContent(array $node_flags): array {
// Get the content data.
$content_data = $this->setupContentData($node_flags);
// Setup the header content.
if ($node_flags['get_header']) {
$content_data['header']['opportunity_type'] = $this->addToContentData('terms', ['field_uw_opportunity_type']);
$content_data['header']['employment_type'] = $this->addToContentData('terms', ['field_uw_opportunity_employment']);
$content_data['header']['rate_of_pay'] = $this->addToContentData('plain_text', 'field_uw_opportunity_pay_rate');
$content_data['header']['rate_of_pay_type'] = $this->addToContentData('terms', ['field_uw_opportunity_pay_type']);
$content_data['header']['job_id'] = $this->addToContentData('plain_text', 'field_uw_opportunity_job_id');
}
if ($node_flags['get_footer']) {
$content_data['footer']['links']['has_children'] = TRUE;
$content_data['footer']['links']['application'] = $this->addToContentData('link', 'field_uw_opportunity_link');
$content_data['footer']['links']['additional_info'] = $this->addToContentData('link', 'field_uw_opportunity_additional');
$content_data['footer']['links']['contact'] = $this->addToContentData('link', 'field_uw_opportunity_contact');
$content_data['footer']['opportunity_details']['has_children'] = TRUE;
$content_data['footer']['opportunity_details']['posted_by'] = $this->addToContentData('plain_text', 'field_uw_opportunity_post_by');
$content_data['footer']['opportunity_details']['number_of_positions'] = $this->addToContentData('select', 'field_uw_opportunity_pos_number');
$content_data['footer']['opportunity_details']['reports_to'] = $this->addToContentData('plain_text', 'field_uw_opportunity_report');
$content_data['footer']['opportunity_dates']['has_children'] = TRUE;
$content_data['footer']['opportunity_dates']['posted'] = $this->addToContentData('date', 'field_uw_opportunity_date');
$content_data['footer']['opportunity_dates']['deadline'] = $this->addToContentData('date', 'field_uw_opportunity_deadline');
$content_data['footer']['opportunity_dates']['start_date'] = $this->addToContentData('date', 'field_uw_opportunity_start_date');
$content_data['footer']['opportunity_dates']['end_date'] = $this->addToContentData('date', 'field_uw_opportunity_end_date');
}
// Setup the actual content.
if ($node_flags['get_content']) {
$content_data['content'] = $this->addToContentData('content', 'field_uw_blog_summary');
}
return $content_data;
}
/**
* Gets the most recent date.
*
......
......@@ -677,17 +677,14 @@ class UwNodeFieldValue {
* The field name that has the date(s).
* @param string $view_mode
* The view mode of the node.
*
* @return array
* Array of dates.
*/
public function getDates(Node $node, string $field_name, string $view_mode): array {
public function getDates(Node $node, string $field_name, string $view_mode) {
$return_dates = [];
// If this is not and event, just get the date.
if ($node->getType() !== 'uw_ct_event') {
$return_dates[] = date('l, F j, Y', strtotime($node->$field_name->value));
$return_dates[] = $this->getDate([$node->$field_name->value], 'blog');
}
else {
......@@ -851,33 +848,37 @@ class UwNodeFieldValue {
* @param string $type
* The type of date.
*
* @return string
* A converted date to a string.
* @return array
* An array about a date.
*/
public function getDate(array $date, string $type): string {
public function getDate(array $date, string $type): array {
$return_date = '';
$return_date = [];
if ($type == 'event') {
// If this is the same day, get the date and the start and end times.
if ($date['duration'] < '1439') {
$start_date = date(self::DATE_FORMAT_DATE_TIME, $date['value']);
$end_date = date(self::DATE_FORMAT_TIME_ONLY, $date['end_value']);
$return_date = $start_date . ' - ' . $end_date . ' ' . date('T', $date['end_value']);
$return_date['date_range'] = TRUE;
$return_date['same_day'] = TRUE;
$return_date['start_date'] = $date['value'];
$return_date['end_date'] = $date['end_value'];
}
// This is not the day, get the start and end date with time.
elseif ($date['duration'] > '1439') {
$start_date = date(self::DATE_FORMAT_DATE_TIME, $date['value']);
$end_date = date(self::DATE_FORMAT_DATE_TIME, $date['end_value']);
$return_date = $start_date . ' - ' . $end_date . ' ' . date('T', $date['end_value']);
$return_date['date_range'] = TRUE;
$return_date['same_day'] = FALSE;
$return_date['start_date'] = $date['value'];
$return_date['end_date'] = $date['end_value'];
}
// The all date case, duration is always 1439.
else {
$return_date = date(self::DATE_FORMAT_DATE_ONLY, $date['value']) . ' (all day)';
$return_date['all_day'] = TRUE;
$return_date['date'] = $date['value'];
}
}
else {
$return_date['date'] = $date[0];
}
return $return_date;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment