You are here

function adci_contact_info_block_view in Multipurpose Corporate Profile 7

Implements hook_block_view().

File

modules/adci_contact_info/adci_contact_info.module, line 21
Info, view, save functions for ADCI Solutions contact info block.

Code

function adci_contact_info_block_view($delta = '') {
  if ($delta !== 'adci_contact_info_block' || !user_access('administer site configuration')) {
    return;
  }
  $block['content']['info'] = [
    '#type' => 'html_tag',
    '#tag' => 'p',
    '#value' => str_replace('@version', VERSION, variable_get('adci_contact_info_info', 'The website is using Drupal @version')),
  ];
  $block['content']['site'] = [
    '#type' => 'container',
  ];
  $block['content']['site']['title'] = [
    '#type' => 'html_tag',
    '#tag' => 'label',
    '#value' => variable_get('adci_contact_info_site_title', 'Supported by'),
  ];
  $block['content']['site']['link'] = [
    '#theme' => 'link',
    '#text' => variable_get('adci_contact_info_site_text', 'ADCI Solutions'),
    '#path' => variable_get('adci_contact_info_site_link', 'https://www.adcisolutions.com/'),
    '#options' => array(
      'attributes' => array(
        'target' => '_blank',
        'rel' => 'noopener noreferrer',
      ),
      'html' => FALSE,
    ),
  ];
  $block['content']['email'] = [
    '#type' => 'container',
  ];
  $block['content']['email']['title'] = [
    '#type' => 'html_tag',
    '#tag' => 'label',
    '#value' => variable_get('adci_contact_info_email_title', 'Email'),
  ];
  $block['content']['email']['email'] = [
    '#type' => 'html_tag',
    '#tag' => 'a',
    '#value' => variable_get('adci_contact_info_email', 'hello@adcillc.com'),
    '#attributes' => [
      'href' => 'mailto:' . variable_get('adci_contact_info_email', 'hello@adcillc.com'),
    ],
  ];
  $requirements = module_invoke_all('requirements', 'runtime');
  $severities = [];
  foreach ($requirements as $requirement) {
    if (isset($requirement['severity'])) {
      if (isset($severities[$requirement['severity']])) {
        $severities[(int) $requirement['severity']]++;
        continue;
      }
      $severities += [
        (int) $requirement['severity'] => 1,
      ];
    }
  }
  $listItems = [];
  $link = '<a href="/admin/reports/status">@text</a>';
  if (isset($severities['2'])) {
    $text = format_plural($severities['2'], '1 error', '@count errors');
    $listItems[] = str_replace('@text', $text, $link);
  }
  if (isset($severities['1'])) {
    $text = format_plural($severities['1'], '1 warning', '@count warnings');
    $listItems[] = str_replace('@text', $text, $link);
  }
  if (count($listItems) > 0) {
    $block['content']['errors'] = [
      '#theme' => 'item_list',
      '#list_type' => 'ul',
      '#title' => t('Your website requires your attention:'),
      '#items' => $listItems,
    ];
  }
  $block['content']['#attached'] = [
    'css' => array(
      drupal_get_path('module', 'adci_contact_info') . '/adci_contact_info.css',
    ),
  ];
  return $block;
}