function aggregator_categorize_items

Form constructor to build the page list form.

Parameters

array $items: An array of the feed items.

string $feed_source: (optional) The feed source URL. Defaults to an empty string.

Return value

array An array of FAPI elements.

See also

aggregator_categorize_items_submit()

theme_aggregator_categorize_items()

Related topics

1 call to aggregator_categorize_items()
_aggregator_page_list in drupal/core/modules/aggregator/aggregator.pages.inc
Prints an aggregator page listing a number of feed items.

File

drupal/core/modules/aggregator/aggregator.pages.inc, line 196
User page callbacks for the Aggregator module.

Code

function aggregator_categorize_items($items, $feed_source = '') {
  $form['#submit'][] = 'aggregator_categorize_items_submit';
  $form['feed_source'] = array(
    '#value' => $feed_source,
  );
  $categories = array();
  $done = FALSE;
  $form['items'] = array(
    '#type' => 'table',
    '#header' => array(
      '',
      t('Categorize'),
    ),
  );
  if ($items && ($form_items = entity_view_multiple($items, 'default'))) {
    foreach (element_children($form_items) as $iid) {
      $categories_result = db_query('SELECT c.cid, c.title, ci.iid FROM {aggregator_category} c LEFT JOIN {aggregator_category_item} ci ON c.cid = ci.cid AND ci.iid = :iid', array(
        ':iid' => $iid,
      ));
      $selected = array();
      foreach ($categories_result as $category) {
        if (!$done) {
          $categories[$category->cid] = check_plain($category->title);
        }
        if ($category->iid) {
          $selected[] = $category->cid;
        }
      }
      $done = TRUE;
      $form['items'][$iid]['item'] = $form_items[$iid];
      $form['items'][$iid]['categories'] = array(
        '#type' => config('aggregator.settings')
          ->get('source.category_selector'),
        '#default_value' => $selected,
        '#options' => $categories,
        '#size' => 10,
        '#multiple' => TRUE,
        '#parents' => array(
          'categories',
          $iid,
        ),
      );
    }
  }
  $form['actions'] = array(
    '#type' => 'actions',
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save categories'),
  );
  $form['pager'] = array(
    '#theme' => 'pager',
  );
  return $form;
}