| 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'); |
| 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 |
|
|
| 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 |
|
|
| 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 |
|
|
| 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 |
|
|
| 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. |
| 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) { |
| 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; |