You are here

function page_title_requirements in Page Title 7.2

Same name and namespace in other branches
  1. 8.2 page_title.module \page_title_requirements()
  2. 6.2 page_title.module \page_title_requirements()

Implements hook_requirements().

File

./page_title.module, line 43
Enhanced control over the page title (in the head tag).

Code

function page_title_requirements($phase) {
  $requirements = array();
  if ($phase == 'runtime') {

    // Are we on an old version?
    if (!page_title_is_up_to_date()) {
      $requirements['page_title_version'] = array(
        'title' => t('Page title version'),
        'value' => t('Out of date'),
        'description' => t('The Page Title module must be updated. You should run the !link immediately.', array(
          '!link' => l(t('database update script'), 'update.php'),
        )),
        'severity' => REQUIREMENT_ERROR,
      );
    }
    else {

      // Does the old table exist (it is left after the upgrade in case an admin wants to check the upgrade went ok)
      if (db_table_exists('page_title_old')) {
        $requirements['upgrade_table'] = array(
          'title' => t('Page Title upgrade table present'),
          'value' => '',
          'description' => t('The Page Title upgrade table (<code>page_title_old</code>) is present. You can remove it !link', array(
            '!link' => l(t('using this script'), 'admin/settings/page-title/drop-old-table'),
          )),
          'severity' => REQUIREMENT_WARNING,
        );
      }

      // If the page title module exists, check it has the right columns - there are reports of upgrade issues.
      // If the table doesn't exists, reinstall the module!
      if (!db_table_exists('page_title') || db_field_exists('page_title', 'nid')) {
        $requirements['page_title_version'] = array(
          'title' => t('Page title version'),
          'value' => t('Incorrect Schema'),
          'description' => t('It appears Drupal thinks the module is up to date, however the database schema is incorrect. Please uninstall and reinstall the module.'),
          'severity' => REQUIREMENT_ERROR,
        );
      }
      else {

        // Everything seems ok...
        $rows = db_query('SELECT COUNT(*) FROM {page_title}')
          ->fetchField();
        $requirements['page_title_version'] = array(
          'title' => t('Page title version'),
          'value' => t('Enabled (<code>page_title</code> table contains !rows)', array(
            '!rows' => format_plural($rows, '1 row', '@count rows'),
          )),
          'severity' => REQUIREMENT_OK,
        );
      }
    }
  }
  return $requirements;
}