Repository URL to install this package:
|
Version:
2.1.1 ▾
|
novicell/dds
/
dds.module
|
|---|
<?php
use Drupal\Core\Routing\RouteMatchInterface;
/**
* Implements hook_help().
*/
function dds_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
// Main module help for the dds module.
case 'help.page.dds':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('Core module for the Drupal Design Suite.') . '</p>';
return $output;
default:
}
}
/**
* Implements hook_locale_translation_projects_alter().
*/
function dds_locale_translation_projects_alter(&$projects) {
$module_handler = \Drupal::service('module_handler');
$path = $module_handler->getModule('dds')->getPath();
$projects['dds']['info']['interface translation server pattern'] = $path.'/translations/%language.po';
}
/**
* Implements hook_theme().
*/
function dds_theme($existing, $type, $theme, $path) {
return [
'dds_spinner' => [
'variables' => [],
],
];
}
/**
* Implements hook_form_FORM_ID_alter().
*/
function dds_form_search_block_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
$form['actions']['submit']['#name'] = 'search';
}
/**
* Implements hook_page_attachments_alter().
*/
function dds_page_attachments_alter(array &$attachments) {
$request = \Drupal::request();
$path_info = strtolower($request->getPathInfo());
$config = \Drupal::config('dds.utilities.nofollow_settings');
$identical_paths = $config->get('identical_paths');
$noindex = preg_split("/\r\n|\n|\r/", $config->get('noindex'));
$nofollow = preg_split("/\r\n|\n|\r/", $config->get('nofollow'));
$nofollow_noindex = preg_split("/\r\n|\n|\r/", $config->get('nofollow_noindex'));
if ($identical_paths) {
if (!empty($nofollow_noindex)) {
if (in_array($path_info, $nofollow_noindex)) {
$attachments['#attached']['html_head'][] = [
[
'#tag' => 'meta',
'#attributes' => [
'name' => 'robots',
'content' => 'noindex',
],
],
'user_admin_no_index'
];
$attachments['#attached']['html_head'][] = [
[
'#tag' => 'meta',
'#attributes' => [
'name' => 'robots',
'content' => 'nofollow',
],
],
'user_admin_no_follow'
];
}
}
} else {
// Only add noindex if there are any paths defined.
if (!empty($noindex)) {
if (in_array($path_info, $noindex)) {
$attachments['#attached']['html_head'][] = [
[
'#tag' => 'meta',
'#attributes' => [
'name' => 'robots',
'content' => 'noindex',
],
],
'user_admin_no_index'
];
}
}
// Only add nofollow if there are any paths defined.
if (!empty($nofollow)) {
if (in_array($path_info, $nofollow)) {
$attachments['#attached']['html_head'][] = [
[
'#tag' => 'meta',
'#attributes' => [
'name' => 'robots',
'content' => 'nofollow',
],
],
'user_admin_no_follow'
];
}
}
}
}