summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.txt8
-rw-r--r--data.views.inc17
-rw-r--r--views/views_handler_field_data_markup.inc38
3 files changed, 62 insertions, 1 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index ffb9461..6f3ec4c 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -1,5 +1,11 @@
// $Id$
+Data 6.x 1.0 xxxxxxxxxxxxxxxxxxxx
+---------------------------------
+
+- #731530 jmiccolis: Add markup field handler.
+
+
Data 6.x 1.0 Alpha 10, 2010-01-25
---------------------------------
@@ -21,4 +27,4 @@ Data 6.x 1.0 Alpha 9, 2009-11-18
Data 6.x 1.0 Alpha 8, 2009-10-20
---------------------------------
-- Initial release. \ No newline at end of file
+- Initial release.
diff --git a/data.views.inc b/data.views.inc
index c938bd9..bc6cd6e 100644
--- a/data.views.inc
+++ b/data.views.inc
@@ -93,6 +93,22 @@ function data_views_data() {
}
/**
+ * Implementation of hook_views_handlers().
+ */
+function data_views_handlers() {
+ return array(
+ 'info' => array(
+ 'path' => drupal_get_path('module', 'data') . '/views',
+ ),
+ 'handlers' => array(
+ 'views_handler_field_data_markup' => array(
+ 'parent' => 'views_handler_field',
+ ),
+ ),
+ );
+}
+
+/**
* Return all available field handlers.
*
* @param $type
@@ -114,6 +130,7 @@ function data_get_views_handler_options($type = NULL, $reset = FALSE) {
'views_handler_field_numeric' => 'views_handler_field_numeric',
'views_handler_field_date' => 'views_handler_field_date',
'views_handler_field_url' => 'views_handler_field_url',
+ 'views_handler_field_data_markup' => 'views_handler_field_data_markup',
);
$handlers['filter'] = array(
'views_handler_filter_date' => 'views_handler_filter_date',
diff --git a/views/views_handler_field_data_markup.inc b/views/views_handler_field_data_markup.inc
new file mode 100644
index 0000000..8bf7b79
--- /dev/null
+++ b/views/views_handler_field_data_markup.inc
@@ -0,0 +1,38 @@
+<?php
+// $Id$
+
+/**
+ * A handler to run a field through check_markup.
+ */
+class views_handler_field_data_markup extends views_handler_field {
+
+ function construct() {
+ parent::construct();
+ $this->format = $this->definition['format'];
+ }
+
+ function options_form(&$form, &$form_state) {
+ parent::options_form($form, $form_state);
+
+ $options = array('default' => t('<Default>'));
+ $result = db_query("SELECT format, name FROM {filter_formats}");
+ while ($row = db_fetch_object($result)) {
+ $options[$row->format] = $row->name;
+ }
+ $form['format'] = array(
+ '#type' => 'select',
+ '#options' => $options,
+ '#title' => t('Format'),
+ '#default_value' => isset($this->options['format']) ? $this->options['format'] : '',
+ '#description' => t('Choose the filter format to use for this field.'),
+ );
+ }
+
+ function render($values) {
+ $value = $values->{$this->field_alias};
+ if ($value) {
+ $format = is_numeric($this->options['format']) ? $this->options['format'] : variable_get('filter_default_format', 1);
+ return check_markup($value, $format, FALSE);
+ }
+ }
+}