diff -urp /Users/mark/Desktop/lineage/lineage.views.inc lineage/lineage.views.inc
--- /Users/mark/Desktop/lineage/lineage.views.inc 2009-11-15 06:20:39.000000000 +0100
+++ lineage/lineage.views.inc 2010-01-09 22:12:49.000000000 +0100
@@ -6,7 +6,7 @@
function lineage_views_data() {
$tables['term_lineage'] = array(
'table' => array(
- 'group' => 'Taxonomy',
+ 'group' => t('Taxonomy'),
'join' => array(
'node' => array(
'left_table' => 'term_node',
diff -urp /Users/mark/Desktop/lineage/lineage_handler_field.inc lineage/lineage_handler_field.inc
--- /Users/mark/Desktop/lineage/lineage_handler_field.inc 2009-11-15 06:20:39.000000000 +0100
+++ lineage/lineage_handler_field.inc 2010-01-09 22:14:34.000000000 +0100
@@ -4,25 +4,61 @@
* Field handler for Taxonomy: Hierarchy
*/
class lineage_handler_field extends views_handler_field {
+ /**
+ * Provide formatter option.
+ */
+ function options_form(&$form, &$form_state) {
+ parent::options_form($form, $form_state);
+
+ $field = $this->content_field;
+ $options = $this->options;
+
+ $formatters = array('raw' => t("Raw lineage entry"),
+ 'path' => t("Path"),
+ 'hover_link' => t("'Pseudo-link' with indentation and rollover"));
+ $format = $options['format'] ? $options['format'] : "hover_link";
+ $form['format'] = array(
+ '#title' => t('Format'),
+ '#type' => 'select',
+ '#options' => $formatters,
+ '#required' => TRUE,
+ '#default_value' => $format,
+ '#weight' => 1,
+ );
+ }
+
function render($values) {
$content = $values->{$this->field_alias};
- if ($content == '') {
- return '';
- }
+ if ($content == '') return '';
+
+ $options = $this->options ? $this->options : array();
+ $format = $options['format'] ? $options['format'] : "";
+ switch ($options['format']) {
+ case 'raw':
+ return $content;
+ break;
- // split lineage string into pieces, i.e. hierarchial path (getting rid of weight numbers, too)
- $path = preg_split("(\n[0-9]+-)", "\n" . $content);
- $s = '';
- // compose the path in readable form
- foreach ($path as $a) {
- if ($s != '') {
- $s .= ' / ';
+ case 'hover_link':
+ case 'path':
+ default:
+ // split lineage string into pieces, i.e. hierarchial path (getting rid of weight numbers, too)
+ $path = preg_split("(\n[0-9]+)", "\n".$content);
+ $s = '';
+ // compose the path in readable form
+ foreach ($path as $a) {
+ if ($s != '')
+ $s .= ' / ';
+ $s .= str_replace("\n", '', $a);
}
- $s .= str_replace("\n", '', $a);
+ // output pseudo-link (without href) with hierarchically indented term and full path via title/alt-rollover
+ if ($options['format'] == 'hover_link')
+ return str_repeat(' ', substr_count($content, "\n")-1)
+ . '' . $a . '';
+ else
+ return $s;
+ break;
}
- // output pseudo-link (without href) with hierarchically indented term and full path via title/alt-rollover
- return str_repeat(' ', substr_count($content, "\n") - 1) . '' . $a . '';
}
}