--- nodereferrer_view_handler_field_old.inc 2009-03-05 05:51:08.000000000 +0100
+++ nodereferrer_view_handler_field.inc 2009-03-28 02:24:39.000000000 +0100
@@ -1,127 +1,143 @@
- $v) {
- $options[$k] = $v['label'];
- }
- $form['formatter'] = array(
- '#type' => 'select',
- '#multiple' => FALSE,
- '#title' => t('Formatter'),
- '#options' => $options,
- '#description' => t('Select the formatter to use to display the fields'),
- '#default_value' => empty($this->options['formatter']) ? '' : $this->options['formatter'],
- );
-
- $form['list'] = array(
- '#type' => 'select',
- '#multiple' => FALSE,
- '#title' => t('Display as'),
- '#options' => array( 'list' => 'List items', 'comma' => 'Comma separated list'),
- '#description' => t('Select how multiple values should be displayed'),
- '#default_value' => empty($this->options['list']) ? 'list' : $this->options['list'],
- );
-
- $form['fields'] = array(
- '#type' => 'checkboxes',
- '#multiple' => TRUE,
- '#title' => $this->get_options_title(),
- '#options' => $this->get_options(),
- '#description' => t('This is optional ; if nothing is selected then all referrers will be returned'),
- '#default_value' => empty($this->options['fields']) ? array() : $this->options['fields'],
- );
-
- if (module_exists('translation')) {
- $form['multilingual'] = array(
- '#type' => 'fieldset',
- '#collapsible' => 'true',
- '#collapsed' => 'true',
- '#title' => t('Multilingual options'),
- );
-
- $default = 0;
- if (!empty($this->options['multilingual']['referrers_of_translations'])) {
- $default = $this->options['multilingual']['referrers_of_translations'];
- }
- $form['multilingual']['referrers_of_translations'] = array(
- '#type' => 'checkbox',
- '#title' => t('Include refererrers of translations'),
- '#description' => t('If this is checked, will also include nodes that refer to translations of the given node'),
- '#default_value' => $default,
- );
-
- $default = 0;
- if (!empty($this->options['multilingual']['translations_of_referrers'])) {
- $default = $this->options['multilingual']['translations_of_referrers'];
- }
- $form['multilingual']['translations_of_referrers'] = array(
- '#type' => 'checkbox',
- '#title' => t('Include translations of referrers'),
- '#description' => t('If this is checked, will also include translations of nodes that refer to the given node. You may not need this if you synchronise your CCK field.'),
- '#default_value' => $default,
- );
- }
- }
-
- /**
- * All we need to do is ensure our table is there
- */
- function query() {
- $this->ensure_my_table();
- }
-
- /**
- * Given a node id, field names and content names, returns the list of nodes
- * that refer to the given node. This takes translation settings into account
- */
- function referrers($nid, $fields, $types = null) {
- return nodereferrer_referrers_with_translations(
- $nid, $fields, $types,
- !empty($this->options['multilingual']['referrers_of_translations']),
- !empty($this->options['multilingual']['translations_of_referrers'])
- );
- }
-
- /**
- * Render the field.
- *
- */
- function render($values) {
- $list = $this->get_item_list($values->nid);
- foreach ($list as $k => $v) {
- $list[$k] = theme('nodereferrer_field_'.$this->options['formatter'], $v);
- }
- if ($this->options['list'] == 'list') {
- if (count($list)) {
- return '
- '.implode('
- ', array_filter($list)).'
';
- } else {
- return '';
- }
- } else {
- return implode(', ', $list);
- }
- }
-
- /**
- * This should be overriden by descendant classes
- */
- function get_node_list($nid) {
- return array();
- }
-
- function get_options() {
- return array();
- }
-}
-
+ 'select',
+ '#multiple' => FALSE,
+ '#title' => t('Display referrers count'),
+ '#options' => array( 'no' => 'No', 'yes' => 'Yes'),
+ '#description' => t('Choose Yes to only display the number of referrers node, it will overite the other formating options'),
+ '#default_value' => empty($this->options['count']) ? 'no' : $this->options['count'],
+ );
+ //End Edit #1/2
+
+ $options = nodereferrer_field_formatter_info();
+ foreach ($options as $k => $v) {
+ $options[$k] = $v['label'];
+ }
+ $form['formatter'] = array(
+ '#type' => 'select',
+ '#multiple' => FALSE,
+ '#title' => t('Formatter'),
+ '#options' => $options,
+ '#description' => t('Select the formatter to use to display the fields'),
+ '#default_value' => empty($this->options['formatter']) ? '' : $this->options['formatter'],
+ );
+
+ $form['list'] = array(
+ '#type' => 'select',
+ '#multiple' => FALSE,
+ '#title' => t('Display as'),
+ '#options' => array( 'list' => 'List items', 'comma' => 'Comma separated list'),
+ '#description' => t('Select how multiple values should be displayed'),
+ '#default_value' => empty($this->options['list']) ? 'list' : $this->options['list'],
+ );
+
+ $form['fields'] = array(
+ '#type' => 'checkboxes',
+ '#multiple' => TRUE,
+ '#title' => $this->get_options_title(),
+ '#options' => $this->get_options(),
+ '#description' => t('This is optional ; if nothing is selected then all referrers will be returned'),
+ '#default_value' => empty($this->options['fields']) ? array() : $this->options['fields'],
+ );
+
+ if (module_exists('translation')) {
+ $form['multilingual'] = array(
+ '#type' => 'fieldset',
+ '#collapsible' => 'true',
+ '#collapsed' => 'true',
+ '#title' => t('Multilingual options'),
+ );
+
+ $default = 0;
+ if (!empty($this->options['multilingual']['referrers_of_translations'])) {
+ $default = $this->options['multilingual']['referrers_of_translations'];
+ }
+ $form['multilingual']['referrers_of_translations'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Include refererrers of translations'),
+ '#description' => t('If this is checked, will also include nodes that refer to translations of the given node'),
+ '#default_value' => $default,
+ );
+
+ $default = 0;
+ if (!empty($this->options['multilingual']['translations_of_referrers'])) {
+ $default = $this->options['multilingual']['translations_of_referrers'];
+ }
+ $form['multilingual']['translations_of_referrers'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Include translations of referrers'),
+ '#description' => t('If this is checked, will also include translations of nodes that refer to the given node. You may not need this if you synchronise your CCK field.'),
+ '#default_value' => $default,
+ );
+ }
+ }
+
+ /**
+ * All we need to do is ensure our table is there
+ */
+ function query() {
+ $this->ensure_my_table();
+ }
+
+ /**
+ * Given a node id, field names and content names, returns the list of nodes
+ * that refer to the given node. This takes translation settings into account
+ */
+ function referrers($nid, $fields, $types = null) {
+ return nodereferrer_referrers_with_translations(
+ $nid, $fields, $types,
+ !empty($this->options['multilingual']['referrers_of_translations']),
+ !empty($this->options['multilingual']['translations_of_referrers'])
+ );
+ }
+
+ /**
+ * Render the field.
+ *
+ */
+ function render($values) {
+ $list = $this->get_item_list($values->nid);
+ foreach ($list as $k => $v) {
+ $list[$k] = theme('nodereferrer_field_'.$this->options['formatter'], $v);
+ }
+ //Edit #2/2 to only display the number of node
+ if($this->options['count'] == 'yes') {
+ return ''.count($list).'';
+ }
+ //End Edit #2/2
+ else if ($this->options['list'] == 'list') {
+ if (count($list)) {
+ return '- '.implode('
- ', array_filter($list)).'
';
+ } else {
+ return '';
+ }
+ } else {
+ return implode(', ', $list);
+ }
+ }
+
+ /**
+ * This should be overriden by descendant classes
+ */
+ function get_node_list($nid) {
+ return array();
+ }
+
+ function get_options() {
+ return array();
+ }
+}
+