|
diff --git a/nopremium.admin.inc b/nopremium.admin.inc |
|
index 99918eb..6f601bb 100644 |
|
--- a/nopremium.admin.inc |
|
+++ b/nopremium.admin.inc |
|
@@ -5,6 +5,12 @@ |
|
* http://www.absyx.fr |
|
*/ |
|
|
|
+/** |
|
+ * Node Option Premium module settings form. |
|
+ * |
|
+ * @see nopremium_settings_form_submit() |
|
+ * @ingroup forms |
|
+ */ |
|
function nopremium_settings_form() { |
|
$form['message'] = array( |
|
'#type' => 'fieldset', |
|
@@ -12,21 +18,44 @@ function nopremium_settings_form() { |
|
'#description' => t('You may customize the messages displayed to unprivileged users trying to view full premium contents.'), |
|
); |
|
$form['message']['nopremium_message'] = array( |
|
- '#type' => 'textarea', |
|
+ '#type' => 'text_format', |
|
'#title' => t('Default message'), |
|
'#description' => t('This message will apply to all content types with blank messages below.'), |
|
'#default_value' => nopremium_get_message(), |
|
'#rows' => 3, |
|
'#required' => TRUE, |
|
+ '#format' => nopremium_get_text_format(), |
|
); |
|
foreach (node_type_get_names() as $type => $name) { |
|
$form['message']['nopremium_message_'. $type] = array( |
|
- '#type' => 'textarea', |
|
+ '#type' => 'text_format', |
|
'#title' => t('Message for %type content type', array('%type' => $name)), |
|
'#default_value' => variable_get('nopremium_message_'. $type, ''), |
|
+ '#format' => variable_get('nopremium_text_format_' . $type, filter_fallback_format()), |
|
'#rows' => 3, |
|
); |
|
} |
|
|
|
- return system_settings_form($form); |
|
+ $form['buttons']['submit'] = array( |
|
+ '#type' => 'submit', |
|
+ '#value' => t('Save configuration'), |
|
+ ); |
|
+ return $form; |
|
} |
|
+ |
|
+/** |
|
+ * Submit handler for Node Option module settings form. |
|
+ * |
|
+ * @see nopremium_settings_form() |
|
+ */ |
|
+function nopremium_settings_form_submit($form, $form_state) { |
|
+ $values = $form_state['values']; |
|
+ variable_set('nopremium_message', $values['nopremium_message']['value']); |
|
+ variable_set('nopremium_text_format', $values['nopremium_message']['format']); |
|
+ foreach (node_type_get_names() as $type => $name) { |
|
+ variable_set('nopremium_message_' . $type, $values['nopremium_message_' . $type]['value']); |
|
+ variable_set('nopremium_text_format_' . $type, $values['nopremium_message_' . $type]['format']); |
|
+ } |
|
+ |
|
+ drupal_set_message(t('The configuration options have been saved.')); |
|
+} |
|
\ No newline at end of file |
|
diff --git a/nopremium.info b/nopremium.info |
|
index a4d8de7..ee73e41 100644 |
|
--- a/nopremium.info |
|
+++ b/nopremium.info |
|
@@ -2,4 +2,10 @@ name = Node Option Premium |
|
description = Shows only the teasers of premium contents to unprivileged users. |
|
configure = admin/config/workflow/nopremium |
|
; package = |
|
-core = 7.x |
|
\ No newline at end of file |
|
+core = 7.x |
|
+; Information added by drupal.org packaging script on 2011-04-02 |
|
+version = "7.x-1.1" |
|
+core = "7.x" |
|
+project = "nopremium" |
|
+datestamp = "1301749569" |
|
+ |
|
diff --git a/nopremium.module b/nopremium.module |
|
index 89da9bc..5e0cba7 100644 |
|
--- a/nopremium.module |
|
+++ b/nopremium.module |
|
@@ -211,7 +211,7 @@ function nopremium_menu() { |
|
* @ingroup themeable |
|
*/ |
|
function theme_nopremium_message($variables) { |
|
- return '<div class="nopremium-message">'. check_markup(t(nopremium_get_message($variables['node']->type))) .'</div>'; |
|
+ return '<div class="nopremium-message">'. check_markup(t(nopremium_get_message($variables['node']->type)), nopremium_get_text_format($variables['node']->type)) .'</div>'; |
|
} |
|
|
|
|
|
@@ -288,3 +288,16 @@ function nopremium_get_message($type = '') { |
|
|
|
return variable_get('nopremium_message', 'The full content of this page is available to premium users only.'); |
|
} |
|
+ |
|
+/** |
|
+ * Get the input format for the given node type. |
|
+ */ |
|
+function nopremium_get_text_format($type = '') { |
|
+ if ($type) { |
|
+ $message = variable_get('nopremium_message_'. $type, ''); |
|
+ if ($message) { |
|
+ return variable_get('nopremium_text_format_' . $type, filter_fallback_format()); |
|
+ } |
|
+ } |
|
+ return variable_get('nopremium_text_format', filter_fallback_format()); |
|
+} |