You are here

function seochecklist_admin_settings in SEO Checklist 7.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.3 seochecklist.admin.inc \seochecklist_admin_settings()
  4. 6.2 seochecklist.module \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 15
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;

  // Vertical tab element.
  $form['seochecklist'] = array(
    '#type' => 'vertical_tabs',
  );

  // 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_select('seo_checklist', 'c')
    ->fields('c', array(
    'completed',
    'id',
    'uid',
  ))
    ->execute();
  foreach ($res as $row) {
    $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', array(
          'account' => 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,
  );
  $form['save_above']['#attributes']['class'][] = 'js-hide';
  return $form;
}