5 * Select Drupal content to create a newsletter
9 * Theme the node selection form
11 function theme_scs_sortable_table($form) {
12 $form = $form['form'];
13 $headers = array(t('Node title'), t('Weight'));
15 foreach (element_children($form['nodes']) as
$nid) {
17 $row[] = db_query('SELECT title FROM {node} WHERE nid = :nid', array(':nid' => $nid))->fetchField();
18 $row[] = drupal_render($form['nodes'][$nid]['weight']);
21 'class' => array('draggable'),
24 $output = theme('table', array('header' => $headers, 'rows' => $rows, 'attributes' => array('id' => 'scs-sort-nodes')));
26 if (isset($form['scs_title']) && isset($form['scs_toc'])) {
27 $info = drupal_render($form['scs_title']) .
drupal_render($form['scs_toc']);
29 $output = $info .
$output .
drupal_render_children($form);
30 drupal_add_tabledrag('scs-sort-nodes', 'order', 'sibling', 'node-weight');
35 * Each selected node goes true this function to create a nice body
37 function theme_scs_node_output($node) {
38 //TODO Fix a teaser of this node
40 $output = '<div id="node_' .
$node['nid'] .
'">';
41 $output .
= '<h1>' .
$node['title'] .
'</h1>';
42 $output .
= '<p>' .
$node['body'][LANGUAGE_NONE
][0]['value'] .
'</p>';
43 $output .
= '<p>' .
l(t('Read more'), 'node/' .
$node['nid']) .
'</p>';
50 * Theme the node sort form into a table
52 function theme_scs_sort_nodes($form) {
53 $form = $form['form'];
54 $headers = array(t('Node title'), t('Weight'));
57 foreach ($form as
$name => $field) {
58 if (preg_match('/^weight_/', $name)) {
59 $nid = explode('_', $name);
61 $title = db_query('SELECT title FROM {node} WHERE nid = :nid', array(':nid' => $nid))->fetchField();
62 unset($form[$name]['#title']);
66 $row[] = drupal_render($form[$name]);
69 'class' => array('draggable'),
74 return drupal_render($form['newsletter_title']) .
drupal_render($form['newsletter_toc']) .
drupal_render($form['newsletter_content_type']) .
theme('table', array('header' => $headers, 'rows' => $rows, 'attributes' => array('id' => 'scs_node_sort_table'))) .
drupal_render_children($form);
78 * Theme function to add the titles of the selected nodes at top of the newsletter
80 function theme_scs_node_titles($variables) {
81 if (variable_get('scs_format', 'plain') == 'plain') {
82 return implode("\n", $variables['titles']);
85 return '<div id="toc">' .
theme('item_list', array('items' => $variables['titles'])) .
'</div>';
90 * Theme a complete newsletter.
92 function theme_scs_newsletter_output($variables) {
97 foreach ($variables['nodes'] as
$node) {
98 if ($variables['toc']) {
99 if (variable_get('scs_format', 'plain') == 'plain') {
100 $titles[] = $node->title
;
103 $titles[] = '<a href="#node_' .
$node->nid .
'">' .
$node->title .
'</a>';
107 $body .
= theme('scs_node_output', (array) $node);
111 if ($variables['toc']) {
112 $body = theme('scs_node_titles', array('titles' => $titles)) .
$body;
115 // Complete newsletter body