Skip to content

Commit

Permalink
NBBIB-475 Adjust conference and report citation formats +url
Browse files Browse the repository at this point in the history
  • Loading branch information
camilocodes committed Feb 12, 2025
1 parent 21c4e67 commit 1ce0f1f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
9 changes: 8 additions & 1 deletion custom/modules/yabrm/yabrm_conference.page.inc
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ function template_preprocess_yabrm_conference(array &$variables) {
$title = $variables['content']['title']['0']['#context']['value'] ?? NULL;
$publisher = $variables['content']['publisher']['0']['#context']['value']
?? NULL;
$url = !empty($variables['content']['url']['0']['#url']) ? $variables['content']['url']['0']['#url']->getUri()
: NULL;

// Specific to Conference.
$conference_name = $variables['content']['conference_name']['0']['#context']['value'] ??
Expand Down Expand Up @@ -267,11 +269,16 @@ function template_preprocess_yabrm_conference(array &$variables) {
$pub_wad .= ', ' . trim($publication_year);
}

if ($url) {
$pub_wad .= ', ' . trim($url);
}

// Only add period if last character is not punctuation.
if (!preg_match("/[.!?,;:]$/", $pub_wad)) {
$pub_wad .= '.';
}

$pub_wad = substr($pub_wad, -1) == '.' ? $pub_wad : "$pub_wad.";
$pub_wad = $url ? substr($pub_wad, 0, -1) : $pub_wad;
$variables['content']['pub_wad'] = $pub_wad . ' <em class="cite-type">[ conference proceeding ]</em>';
}
19 changes: 10 additions & 9 deletions custom/modules/yabrm/yabrm_report.page.inc
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ function template_preprocess_yabrm_report(array &$variables) {
$title = $variables['content']['title']['0']['#context']['value'] ?? NULL;
$publisher = $variables['content']['publisher']['0']['#context']['value']
?? NULL;
$url = $variables['content']['url']['0']['#context']['value']
?? NULL;
$url = !empty($variables['content']['url']['0']['#url']) ? $variables['content']['url']['0']['#url']->getUri()
: NULL;

// Specific to Report.
$report_type = $variables['content']['report_type']['0']['#context']['value']
Expand Down Expand Up @@ -234,17 +234,17 @@ function template_preprocess_yabrm_report(array &$variables) {

$variables['content']['contribs_wad'] = $contribs_wad;

// Publication.
if ($publication_year) {
$pub_wad .= trim($publication_year);
}

// Publication.
if ($publisher) {
$pub_wad .= '. ' . trim($publisher);
$pub_wad .= ' ' . trim($publisher);
}

if ($publication_year) {
$pub_wad .= ', ' . trim($publication_year);
}

if ($url) {
$pub_wad .= trim($url);
$pub_wad .= ', ' . trim($url);
}

// Only add period if last character is not punctuation.
Expand All @@ -253,5 +253,6 @@ function template_preprocess_yabrm_report(array &$variables) {
}

$pub_wad = substr($pub_wad, -1) == '.' ? $pub_wad : "$pub_wad.";
$pub_wad = $url ? substr($pub_wad, 0, -1) : $pub_wad;
$variables['content']['pub_wad'] = $pub_wad . ' <em class="cite-type">[ report ]</em>';
}

0 comments on commit 1ce0f1f

Please sign in to comment.