You are here

scs_sort.tpl.php in Simplenews Content Selection 6.2

File

templates/scs_sort.tpl.php
View source
<?php

$rows = array();
foreach ($form as $name => $field) {
  if (ereg('weight_', $name)) {
    $nid = explode('_', $name);
    $nid = $nid[1];
    if (is_numeric($nid)) {
      $title = db_result(db_query('SELECT title FROM {node} WHERE nid = %d', $nid));
      unset($form[$name]['#title']);
      $row = array();
      $row[] = $title;
      $row[] = drupal_render($form['region_' . $nid]);
      $row[] = drupal_render($form[$name]);
      $rows[] = array(
        'data' => $row,
      );
    }
  }
}
?>

<?php


// Add CSS
// Add table javascript.
drupal_add_js('misc/tableheader.js');
drupal_add_js(drupal_get_path('module', 'scs') . '/scs.js');
for ($i = 0; $i < 11; $i++) {
  drupal_add_tabledrag('scs_node_sort_table', 'match', 'sibling', 'scs_region', 'scs_region_' . $i, NULL, FALSE);
  drupal_add_tabledrag('scs_node_sort_table', 'order', 'sibling', 'scs_weight', 'scs_weight_' . $i);
}
?>
<style type="text/css">
#scs_node_sort_table tr.region-populated {
    display: none;
}

#scs_node_sort_table tr.region-message {
    color: #999999;
    font-weight: normal;
}
</style>
<?php

if (isset($form['newsletter_title'])) {
  print drupal_render($form['newsletter_title']);
  print drupal_render($form['newsletter_toc']);
  if (isset($form['newsletter_type'])) {
    print drupal_render($form['newsletter_type']);
  }
}
?>
<table id="scs_node_sort_table" class="sticky-enabled">
  <thead>
    <tr>
      <th><?php

print t('Node title');
?></th>
      <th><?php

print t('Region');
?>
      <th><?php

print t('Weight');
?></th>
    </tr>
  </thead>
  <tbody>
    <?php

$row = 0;
?>
    <tr class="region region-0">
    	<td colspan="3" class="region"><?php

print t('No region');
?></td>
    </tr>
    <?php

foreach ($rows as $key => $data) {
  ?>
    <tr class="draggable <?php

  print $row % 2 == 0 ? 'odd' : 'even';
  print $data->row_class ? ' ' . $data->row_class : '';
  ?>">
      <td class="block"><?php

  print $data['data'][0];
  ?></td>
      <td><?php

  print $data['data'][1];
  ?></td>
      <td><?php

  print $data['data'][2];
  ?></td>
    </tr>
    <?php

  $row++;
  ?>
    <?php

}
?>
    <?php

for ($i = 0; $i < 10; $i++) {
  ?>
      <tr class="region region-<?php

  print $i + 1;
  ?>">
        <td colspan="3" class="region"><?php

  print t('Region' . ' ' . ($i + 1));
  ?></td>
      </tr>
      <tr class="region-message region-<?php

  print $i + 1;
  ?>-message region-empty">
        <td colspan="3"><em><?php

  print t('No nodes in this region');
  ?></em></td>
      </tr>
    <?php

}
?>
  </tbody>
</table>

<?php

print drupal_render($form);