You are here

function scs_sort_nodes in Simplenews Content Selection 6.2

Node sort page

1 call to scs_sort_nodes()
scs_node_selection in ./scs.pages.inc
1 string reference to 'scs_sort_nodes'
scs_menu in ./scs.module
Implements hook_menu()

File

./scs.pages.inc, line 212

Code

function scs_sort_nodes($nodes = array(), $post = array()) {
  $fields = false;
  $type = '';
  if (array_key_exists('storage', $nodes)) {
    if (count($_GET) != 0) {
      $fields = true;
      $nodes = array();
      foreach ($_GET as $key => $nid) {
        if ($key != 'q') {
          $nodes[] = $nid;
        }
      }
    }
    else {
      drupal_set_message(t('There was an error. No nodes found'));
      return array();
    }
  }
  $form = array();
  if ($fields == TRUE) {
    $form['newsletter_title'] = array(
      '#type' => 'textfield',
      '#title' => t('Title'),
      '#description' => t('Enter the title of this newsletter'),
      '#default_value' => variable_get('scs_default_title', t('Please edit the title of this newsletter.')),
      '#required' => true,
    );
    $form['newsletter_toc'] = array(
      '#type' => 'checkbox',
      '#title' => t('Create a table of contents'),
      '#description' => t('Create a table of contents at top of the newsletter with the titles of the selected nodes. If newsletter is HTML format, these table of contents will be bookmarks.'),
    );
    if (variable_get('scs_types', '') != '' && count(_scs_get_types()) != 1) {
      $form['newsletter_type'] = array(
        '#type' => 'select',
        '#title' => t('Newsletter type'),
        '#options' => _scs_get_types(),
        '#default_value' => $type,
      );
    }
    $content_types = variable_get('simplenews_content_types', array());
    if (count($content_types) != 1) {
      $form['newsletter_content_type'] = array(
        '#type' => 'select',
        '#title' => t('Content type'),
        '#description' => t('Select the content type of the newsletter you are creating. Only the content types selected ' . l('here', 'admin/settings/simplenews/general') . ' are displayed.'),
        '#options' => $content_types,
      );
    }
  }
  $counter = 0;
  $regions = array();
  $regions[0] = t('No region');
  for ($i = 0; $i < 10; $i++) {
    $regions[$i + 1] = t('Region' . ' ' . ($i + 1));
  }
  foreach ($nodes as $nid) {
    $form['weight_' . $nid] = array(
      '#type' => 'weight',
      '#default_value' => $counter,
      '#attributes' => array(
        'class' => 'scs_weight scs_weight_0',
      ),
      '#delta' => 100,
    );
    $form['region_' . $nid] = array(
      '#type' => 'select',
      '#default_value' => 0,
      '#options' => $regions,
      '#attributes' => array(
        'class' => 'scs_region scs_region_0',
      ),
    );
    $counter++;
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Create newsletter'),
  );
  return $form;
}