2019-10-03 20:50:40 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Preprocess functions for GEO site.
|
|
|
|
*/
|
2019-10-04 10:41:25 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements hook_preprocess_page_title();
|
|
|
|
*
|
|
|
|
* @param $variables
|
|
|
|
*/
|
2019-10-03 20:50:40 -04:00
|
|
|
function geofresco_preprocess_page_title(&$variables) {
|
|
|
|
// WE SHALL BE SHAMELESS.
|
2019-10-04 09:31:20 -04:00
|
|
|
if (!isset($variables['title']) || !is_array($variables['title'])) {
|
|
|
|
// The pages we're interested in have title as markup, so bail if it's not.
|
|
|
|
return;
|
|
|
|
}
|
2019-10-03 20:50:40 -04:00
|
|
|
$string = isset($variables['title']['#markup']) ? $variables['title']['#markup'] : FALSE;
|
2024-02-16 13:03:13 -08:00
|
|
|
if ($string && strlen($string) > 7 && $pos = strpos($string, "'s blog", -7)) {
|
2019-10-03 20:50:40 -04:00
|
|
|
$uid = substr($string, 0, $pos);
|
|
|
|
if (is_numeric($uid) && $account = \Drupal\user\Entity\User::load($uid)) {
|
|
|
|
$variables['title'] = [
|
|
|
|
'#markup' => t("@username's blog",
|
|
|
|
['@username' => $account->getDisplayName()])
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-02-05 14:11:10 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements hook_preprocess_HOOK() for comment.
|
|
|
|
*
|
|
|
|
* Shortens and stacks username and submitted date.
|
|
|
|
*/
|
|
|
|
function geofresco_preprocess_comment(array &$variables) {
|
|
|
|
$comment = $variables['elements']['#comment'];
|
|
|
|
if (isset($comment->in_preview)) {
|
|
|
|
$variables['permalink_url'] = new Url('<front>');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$variables['permalink_url'] = $comment->permalink();
|
|
|
|
}
|
|
|
|
}
|