/[drupal]/contributions/modules/cck/nodereference.module
ViewVC logotype

Diff of /contributions/modules/cck/nodereference.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.39.2.35, Mon Mar 24 01:58:34 2008 UTC revision 1.39.2.36, Mon Apr 28 23:50:29 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: nodereference.module,v 1.39.2.34 2008/03/24 01:51:14 yched Exp $  // $Id: nodereference.module,v 1.39.2.35 2008/03/24 01:58:34 yched Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 527  function _nodereference_filter_handler($ Line 527  function _nodereference_filter_handler($
527    $options = array(0 => t('<empty>'));    $options = array(0 => t('<empty>'));
528    $options = $options + _nodereference_potential_references($filterinfo['extra']['field']);    $options = $options + _nodereference_potential_references($filterinfo['extra']['field']);
529    return $options;    return $options;
530    }
531    
532    /**
533     * Implementation of hook_panels_relationships().
534     */
535    function nodereference_panels_relationships() {
536      $args = array();
537      $args['node_from_noderef'] = array(
538        'title' => t('Node from reference'),
539        'keyword' => 'nodereference',
540        'description' => t('Adds a node from a node reference in a node context; if multiple nodes are referenced, this will get the first referenced node only.'),
541        'required context' => new panels_required_context(t('Node'), 'node'),
542        'context' => 'nodereference_node_from_noderef_context',
543        'settings form' => 'nodereference_node_from_noderef_settings_form',
544        'settings form validate' => 'nodereference_node_from_noderef_settings_form_validate',
545        );
546      return $args;
547    }
548    
549    /**
550     * Return a new panels context based on an existing context
551     */
552    function nodereference_node_from_noderef_context($context = NULL, $conf) {
553      // If unset it wants a generic, unfilled context, which is just NULL
554      if (empty($context->data)) {
555        return panels_context_create_empty('node', NULL);
556      }
557      if (isset($context->data->{$conf['field_name']}[0]['nid']) && ($nid = $context->data->{$conf['field_name']}[0]['nid'])) {
558        if ($node = node_load($nid)) {
559          return panels_context_create('node', $node);
560        }
561      }
562    }
563    
564    /**
565     * Settings form for the panels relationship.
566     */
567    function nodereference_node_from_noderef_settings_form($conf) {
568      $options = array();
569      foreach (content_fields() as $field) {
570        if ($field['type'] == 'nodereference') {
571          $options[$field['field_name']] = t($field['widget']['label']);
572        }
573      }
574      $form['field_name'] = array(
575        '#title' => t('Node reference field'),
576        '#type' => 'select',
577        '#options' => $options,
578        '#default_value' => $conf['field_name'],
579        '#prefix' => '<div class="clear-block">',
580        '#suffix' => '</div>',
581      );
582    
583      return $form;
584  }  }

Legend:
Removed from v.1.39.2.35  
changed lines
  Added in v.1.39.2.36

  ViewVC Help
Powered by ViewVC 1.1.2