/[drupal]/contributions/modules/nodeprofile/nodeprofile_panels.inc
ViewVC logotype

Diff of /contributions/modules/nodeprofile/nodeprofile_panels.inc

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

revision 1.1, Mon Feb 4 11:29:32 2008 UTC revision 1.1.2.1, Mon Feb 4 11:29:32 2008 UTC
# Line 0  Line 1 
1    <?php
2    // $Id$
3    
4    /**
5     * @file
6     * Panels integration
7     */
8    
9    /**
10     * Plugin to provide an relationship handler for node from user
11     */
12    function nodeprofile_panels_relationships() {
13      $args['node_from_user'] = array(
14        'title' => t("Nodeprofile from user"),
15        'keyword' => 'nodeprofile',
16        'description' => t('Adds a nodeprofile from user context'),
17        'required context' => new panels_required_context(t('User'), 'user'),
18        'context' => 'nodeprofile_panels_context',
19        'settings form' => 'nodeprofile_panels_settings_form',
20        'settings form validate' => 'nodeprofile_panels_settings_form_validate',
21      );
22      return $args;
23    }
24    
25    /**
26     * Return a new context based on an existing context
27     */
28    function nodeprofile_panels_context($context = NULL, $conf) {
29      // If unset it wants a generic, unfilled context, which is just NULL
30      if (empty($context->data)) {
31        return panels_context_create_empty('node', NULL);
32      }
33    
34      if (isset($context->data->uid)) {
35        // Load the node for the requested type
36        $uid = $context->data->uid;
37        $nodeprofilenode = nodeprofile_load($conf['type'], $uid);
38    
39        // Send it to panels
40        return panels_context_create('node', $nodeprofilenode);
41      }
42      else {
43        return panels_context_create_empty('node', NULL);
44      }
45    }
46    
47    /**
48     * Settings form for the relationship
49     */
50    function nodeprofile_panels_settings_form($conf) {
51      $options = nodeprofile_get_types('names');
52      $form['type'] = array(
53        '#type' => 'select',
54        '#title' => t('Relationship type'),
55        '#options' => $options,
56        '#default_value' => $conf['type']
57      );
58    
59      return $form;
60    }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.1.2.1

  ViewVC Help
Powered by ViewVC 1.1.2