You are here

function seochecklist_admin_settings in SEO Checklist 6.3

Same name and namespace in other branches
  1. 5.2 seochecklist.module \seochecklist_admin_settings()
  2. 5 SEOChecklist.module \SEOChecklist_admin_settings()
  3. 6.2 seochecklist.module \seochecklist_admin_settings()
  4. 7.3 seochecklist.admin.inc \seochecklist_admin_settings()

Define the settings form.

1 string reference to 'seochecklist_admin_settings'
seochecklist_menu in ./seochecklist.module
Implementation of hook_menu().

File

./seochecklist.admin.inc, line 14
Administrative page callbacks for the seochecklist module.

Code

function seochecklist_admin_settings() {
  global $user;
  global $seochecklist_items;
  global $seochecklist_groups;
  $seochecklist_items = $seochecklist_groups = array();
  _seochecklist_fill();
  $form['save_above'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
    '#weight' => '-100',
  );

  // Fetch modules and groups from database.
  $group_id = 0;

  // Every group is a fieldset.
  foreach ($seochecklist_groups as $group_id => $data) {
    $form['group_' . $group_id] = array(
      '#type' => 'fieldset',
      '#title' => $data->name,
      '#collapsible' => TRUE,
      '#description' => $data->description,
      '#group' => 'seochecklist',
    );
  }
  $res = db_query('SELECT * FROM seo_checklist');
  while ($row = db_fetch_object($res)) {
    $seochecklist_items[$row->id]->completed = $row->completed;
    $seochecklist_items[$row->id]->uid = $row->uid;
  }
  foreach ($seochecklist_items as $row) {
    $row->links = array();
    if (@$row->description) {
      $row->links[] = $row->description;
    }
    if (@$row->completed) {

      // Show when and who completed this task.
      $row->links[] = t('Completed on %date by !username', array(
        '%date' => format_date($row->completed, 'small'),
        '!username' => theme('username', user_load($row->uid)),
      ));
    }
    else {
      $row->completed = 0;

      // Show non-completed sub-tasks.
      if ($row->download) {
        $row->links[] = l(t('Download'), $row->download, array(
          'attributes' => array(
            'target' => '_blank',
          ),
        ));
      }
      if ($row->enable) {
        $row->links[] = l(t('Enable'), $row->enable);
      }
    }
    if ($row->configure && (!$row->module || module_exists($row->module))) {

      // Show the link to configure if this isn't a module or module is enabled.
      $row->links[] = l(t('Configure'), $row->configure);
    }
    if (variable_get('seo_checklist_book_references', 1) && ($page = seochecklist_get_book_references($row->id))) {
      $row->links[] = t('See <a href="@book-purchase">Drupal 6 SEO</a> p. @page', array(
        '@page' => $page,
        '@book-purchase' => SEOCHECKLIST_BOOK_PURCHASE,
      ));
    }
    $form['group_' . $row->group_id]['seochecklist_task_' . $row->id] = array(
      '#type' => 'checkbox',
      '#title' => t($row->name),
      '#default_value' => $row->completed || $row->module && module_exists($row->module),
      '#description' => join(' | ', $row->links),
    );
    if (strpos($row->name, 'Clean URLs') === 0) {
      $form['group_' . $row->group_id]['seochecklist_task_' . $row->id]['#disabled'] = !variable_get('clean_url', 0);
      $form['group_' . $row->group_id]['seochecklist_task_' . $row->id]['#default_value'] |= variable_get('clean_url', 0);
    }
  }
  $form['save'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
    '#weight' => 100,
  );
  if (module_exists('vertical_tabs')) {
    $form['#pre_render'][] = 'vertical_tabs_form_pre_render';
    $form['save_above']['#attributes']['class'] = 'js-hide';
  }
  else {
    drupal_set_message(t('Your SEO Checklist interface (in addition to your content and content type edit pages) will be greatly enhanced by installing the <a href="@vertical-tabs">Vertical Tabs module</a>.', array(
      '@vertical-tabs' => 'http://drupal.org/project/vertical_tabs',
    )), 'status', FALSE);
  }
  return $form;
}