/[drupal]/contributions/modules/sidecontent/sidecontent.module
ViewVC logotype

Diff of /contributions/modules/sidecontent/sidecontent.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.12, Sun Oct 22 20:29:08 2006 UTC revision 1.13, Tue Jul 3 22:39:39 2007 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: sidecontent.module,v 1.4.2.2 2006/06/10 15:09:21 MegaGrunt Exp $  // $Id: sidecontent.module,v 1.11.2.3 2006/10/22 19:43:50 MegaGrunt Exp $
3    
4  /**  /**
5   * Implementation of hook_help().   * Implementation of hook_perm().
6   */   */
 function sidecontent_help($section) {  
   
   switch ($section) {  
     case 'admin/modules#description':  
       return t('Displays page (node) content in a block.');  
   }  
 }  
   
7  function sidecontent_perm() {  function sidecontent_perm() {
8    
9   return array('access side content', 'create side content');   return array('access side content', 'create side content');
# Line 33  function sidecontent_block($op = 'list', Line 25  function sidecontent_block($op = 'list',
25    
26      case 'configure':      case 'configure':
27    
       $form['sidecontent_title'] = array(  
         '#type' => 'textfield',  
         '#title' => t('Block Title Default'),  
         '#default_value' => check_plain(variable_get('sidecontent_title', NULL)),  
         '#size' => 50,  
         '#maxlength' => 64,  
         '#description' => t('Leave blank to not display a title.'),  
       );  
28    
29        $form['sidecontent_print'] = array(        $form['sidecontent_print'] = array(
30          '#type' => 'checkbox',          '#type' => 'checkbox',
31          '#title' => t('Print view include'),          '#title' => t('Print view include'),
32          '#default_value' => check_plain(variable_get('sidecontent_print', false)),          '#default_value' => variable_get('sidecontent_print', false),
33          '#description' => t('Show content in print view (requires Print Friendly Pages module).'),          '#description' => t('Show content in print view (requires Print Friendly Pages module).'),
34        );        );
35    
# Line 58  function sidecontent_block($op = 'list', Line 42  function sidecontent_block($op = 'list',
42        $form['sidecontent_show_input_format'] = array(        $form['sidecontent_show_input_format'] = array(
43          '#type' => 'checkbox',          '#type' => 'checkbox',
44          '#title' => t('Show input format'),          '#title' => t('Show input format'),
45          '#default_value' => check_plain(variable_get('sidecontent_show_input_format', true)),          '#default_value' => variable_get('sidecontent_show_input_format', true),
46          '#description' => t('If this box is not checked, the default input format will be used when formatting the block content.'),          '#description' => t('If this box is not checked, the default input format will be used when formatting the block content.'),
47        );        );
48    
49        $form['sidecontent_show_in_group'] = array(        $form['sidecontent_show_in_group'] = array(
50          '#type' => 'checkbox',          '#type' => 'checkbox',
51          '#title' => t('Show in form group'),          '#title' => t('Show in form group'),
52          '#default_value' => check_plain(variable_get('sidecontent_show_in_group', true)),          '#default_value' => variable_get('sidecontent_show_in_group', true),
53          '#description' => t('Show textarea and form filters formatted as a form group.'),          '#description' => t('Show textarea and form filters formatted as a form group.'),
54        );        );
55    
# Line 83  function sidecontent_block($op = 'list', Line 67  function sidecontent_block($op = 'list',
67      case 'save':      case 'save':
68    
69          if (!user_access('create side content')) break;          if (!user_access('create side content')) break;
         variable_set('sidecontent_title', trim($edit['sidecontent_title']));  
70          variable_set('sidecontent_print', !empty($edit['sidecontent_print']));          variable_set('sidecontent_print', !empty($edit['sidecontent_print']));
71                  variable_set('sidecontent_show_input_format', !empty($edit['sidecontent_show_input_format']));                      variable_set('sidecontent_show_input_format', !empty($edit['sidecontent_show_input_format']));
72                  variable_set('sidecontent_show_in_group', !empty($edit['sidecontent_show_in_group']));                      variable_set('sidecontent_show_in_group', !empty($edit['sidecontent_show_in_group']));
73          variable_set('sidecontent_group_description', trim($edit['sidecontent_group_description']));          variable_set('sidecontent_group_description', trim($edit['sidecontent_group_description']));
74          return;          return;
75    
# Line 130  function sidecontent_block($op = 'list', Line 113  function sidecontent_block($op = 'list',
113    
114          if ($sidecontent->sidecontent) {          if ($sidecontent->sidecontent) {
115    
116            $block['subject'] = (empty($sidecontent->sidetitle)) ? check_plain(variable_get('sidecontent_title', NULL)) : check_plain($sidecontent->sidetitle);            if (!empty($sidecontent->sidetitle)) $block['subject'] = check_plain($sidecontent->sidetitle);
117            $block['content'] = check_markup($sidecontent->sidecontent, $sidecontent->format, FALSE);            $block['content'] = check_markup($sidecontent->sidecontent, $sidecontent->format, FALSE);
118          }          }
119    
# Line 141  function sidecontent_block($op = 'list', Line 124  function sidecontent_block($op = 'list',
124  }  }
125    
126    
127    /**
128    * Implementation of hook_form_alter.
129    */
130  function sidecontent_form_alter($form_id, &$form) {  function sidecontent_form_alter($form_id, &$form) {
131    
132    // Alter the settings form.    // Alter the settings form.
133    if (isset($form['type']) && $form['type']['#value'] . '_node_settings' == $form_id) {    if ($form_id == 'node_type_form') {
134            $node_type = $form['old_type']['#value'];
135     $form['submission']['sidecontent_'. $form['type']['#value']] = array (  
136       '#type' => 'radios',      $form['submission']['sidecontent'] = array(
137       '#title' => t('Enable side content'),        '#type' => 'radios',
138       '#default_value' => check_plain(variable_get('sidecontent_'. $form['type']['#value'], 1)),        '#title' => t('Enable side content'),
139       '#options' => array(t('Disabled'), t('Enabled'))        '#default_value' => variable_get('sidecontent_' . $node_type, 0),
140     );        '#options' => array(t('Disabled'), t('Enabled')),
141        );
142    }    }
143    
144    // Add stuff to the node submit form.    // Add stuff to the node submit form.
# Line 208  function sidecontent_form_alter($form_id Line 195  function sidecontent_form_alter($form_id
195    
196  }  }
197    
198    
199    /**
200    * Implementation of hook_nodeapi.
201    */
202  function sidecontent_nodeapi(&$node, $op, $teaser, $page) {  function sidecontent_nodeapi(&$node, $op, $teaser, $page) {
203    
204      switch ($op) {      switch ($op) {
# Line 269  function sidecontent_nodeapi(&$node, $op Line 260  function sidecontent_nodeapi(&$node, $op
260                  $sidecontent = check_markup($node->sidecontent, $node->format);                  $sidecontent = check_markup($node->sidecontent, $node->format);
261    
262                  // note: print module disregards theme, so we have to include our markup here - yuuk!                  // note: print module disregards theme, so we have to include our markup here - yuuk!
263                  $node->body = '<div class="sidecontent-print">' . $sidecontent . '</div>' . $node->body;                  $node->content['sidecontent'] = array(
264                                                          '#value' => '<div class="sidecontent-print">' . $sidecontent . '</div>',
265                                                                            '#weight' => -10,
266                    );
267              }              }
268    
269              break;              break;

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.13

  ViewVC Help
Powered by ViewVC 1.1.2