You are here

function cmf_admin_both_form in Content Management Filter 6

Same name and namespace in other branches
  1. 5 both.inc \cmf_admin_both_form()
  2. 6.2 both.inc \cmf_admin_both_form()
  3. 7 both.inc \cmf_admin_both_form()

Defines the form for mixed content administration filter results.

Return value

array with forms properties

See also

cmf_admin_both_form_validate().

cmf_admin_both_form_submit().

1 string reference to 'cmf_admin_both_form'
cmf_admin_content_page in ./cmf.module
Called when user goes to example.com/admin/content/filter

File

./both.inc, line 20
@brief Content management filter "both" operations file

Code

function cmf_admin_both_form() {
  $destination = drupal_get_destination();
  $lang_codes = array(
    '' => t('Neutral'),
  );
  if (module_exists('locale')) {
    $locale_available = TRUE;
    $lang_codes += locale_language_list('name');
  }
  else {
    $locale_available = FALSE;
  }

  // Build an 'Update options' form.
  if (user_access('filter and manage site content')) {
    $form['options'] = array(
      '#type' => 'fieldset',
      '#title' => t('Update options'),
      '#prefix' => '<div class="container-inline">',
      '#suffix' => '</div>',
    );
    $form['options']['operation'] = array(
      '#type' => 'select',
      '#options' => array(
        'publish' => t('Publish'),
        'unpublish' => t('Unpublish'),
        'delete' => t('Delete'),
      ),
      '#default_value' => 'publish',
    );
    $form['options']['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Update'),
    );
  }

  // Load the objects that we want to display.
  $form['header'] = array(
    '#type' => 'value',
    '#value' => cmf_build_header(),
  );
  $result = cmf_perform_query($form['header']['#value']);

  // Build a table listing the appropriate objects.
  while ($object = db_fetch_object($result)) {
    if ($object->cid == 0) {
      $objects['n-' . $object->nid] = '';
      if ($_SESSION['cmf_show_nid']) {
        $form['cmf_id']['n-' . $object->nid] = array(
          '#value' => l($object->nid, 'node/' . $object->nid, array(
            'attributes' => array(
              'title' => t('Node !nid', array(
                '!nid' => $object->nid,
              )),
            ),
          )),
        );
      }
      $form['title']['n-' . $object->nid] = array(
        '#value' => l($object->title, 'node/' . $object->nid, array(
          'attributes' => array(
            'title' => check_plain($object->body),
          ),
          'fragment' => 'node-' . $object->nid,
        )) . ' ' . theme('mark', node_mark($object->nid, $object->changed)),
      );
      $form['kind']['n-' . $object->nid] = array(
        '#value' => _cmf_get_img('node', t('node')),
      );
      $form['type']['n-' . $object->nid] = $object->type == 'forum' ? array(
        '#value' => '<p title="' . _cmf_get_forum($object->nid) . '">' . check_plain(node_get_types('name', $object)) . '</p>',
      ) : array(
        '#value' => check_plain(node_get_types('name', $object)),
      );
      if (!(arg(0) == 'user' && is_numeric(arg(1)) && arg(1) > 0)) {
        $form['username']['n-' . $object->nid] = array(
          '#value' => theme('cmf_user', $object->uid),
        );
      }
      $status = array();
      $status[] = $object->status ? t('published') : t('not published');
      if ($object->promote) {
        $status[] = t('promoted');
      }
      if ($object->sticky > 0) {

        // >0 allows for sticky-encoded weighting.
        $status[] = t('sticky');
      }
      if ($object->moderate) {
        $status[] = t('moderated');
      }
      $form['status']['n-' . $object->nid] = array(
        '#value' => implode(', ', $status),
      );
      $form['created']['n-' . $object->nid] = array(
        '#value' => format_date($object->created, 'small'),
      );
      if ($locale_available) {
        $form['language']['n-' . $object->nid] = array(
          '#value' => $lang_codes[$object->language],
        );
      }
      if (user_access('filter and manage site content')) {
        $form['operations']['n-' . $object->nid] = array(
          '#value' => l(_cmf_get_img('edit', t('edit')) . ' ' . t('edit'), 'node/' . $object->nid . '/edit', array(
            'query' => $destination,
            'html' => TRUE,
          )),
        );
      }
    }
    else {
      $objects['c-' . $object->cid] = '';
      if ($_SESSION['cmf_show_nid']) {
        $form['cmf_id']['c-' . $object->cid] = array(
          '#value' => l($object->nid, 'node/' . $object->nid, array(
            'attributes' => array(
              'title' => t('Node !nid, Comment !cid', array(
                '!nid' => $object->nid,
                '!cid' => $object->cid,
              )),
            ),
            'fragment' => 'comment-' . $object->cid,
          )),
        );
      }
      $form['title']['c-' . $object->cid] = array(
        '#value' => l($object->title, 'node/' . $object->nid, array(
          'attributes' => array(
            'title' => check_plain($object->comment),
          ),
          'fragment' => 'comment-' . $object->cid,
        )),
      );
      $form['kind']['c-' . $object->cid] = array(
        '#value' => _cmf_get_img('comment', t('comment')),
      );
      $form['type']['c-' . $object->cid] = $object->type == 'forum' ? array(
        '#value' => '<p title="' . _cmf_get_forum($object->nid) . '">' . theme('cmf_type', $object->type) . '</p>',
      ) : array(
        '#value' => theme('cmf_type', $object->type),
      );
      if (!(arg(0) == 'user' && is_numeric(arg(1)) && arg(1) > 0)) {
        $form['username']['c-' . $object->cid] = array(
          '#value' => theme('cmf_user', $object->uid),
        );
      }
      $form['status']['c-' . $object->cid] = array(
        '#value' => $object->status ? t('not published') : t('published'),
      );
      $form['created']['c-' . $object->cid] = array(
        '#value' => format_date($object->created, 'small'),
      );
      if (user_access('filter and manage site content')) {
        $form['operations']['c-' . $object->cid] = array(
          '#value' => l(_cmf_get_img('edit', t('edit')) . ' ' . t('edit'), 'comment/edit/' . $object->cid, array(
            'query' => $destination,
            'html' => TRUE,
          )),
        );
      }
    }
  }
  if (user_access('filter and manage site content')) {
    $form['objects'] = array(
      '#type' => 'checkboxes',
      '#options' => $objects,
    );
  }
  $form['pager'] = array(
    '#value' => theme('pager', NULL, $_SESSION['cmf_max_rows'], 0),
  );
  return $form;
}