| 1 |
|
<?php |
| 2 |
|
// $Id: bio_panels.inc,v 1.1.2.3 2008/01/25 07:33:54 webchick Exp $ |
| 3 |
|
|
| 4 |
|
/** |
| 5 |
|
* @file |
| 6 |
|
* Panels integration for Bio module. |
| 7 |
|
*/ |
| 8 |
|
|
| 9 |
|
/** |
| 10 |
|
* Plugin to provide a relationship handler for node from user. |
| 11 |
|
*/ |
| 12 |
|
function bio_panels_relationships() { |
| 13 |
|
$bio_type = bio_get_type(); |
| 14 |
|
$args['node_from_user'] = array( |
| 15 |
|
'title' => t('User @type', array('@type' => $bio_type)), |
| 16 |
|
'keyword' => 'node', |
| 17 |
|
'description' => t("Adds a user's @type node.", array('@type' => $bio_type)), |
| 18 |
|
'required context' => new panels_required_context(t('User'), 'user'), |
| 19 |
|
'context' => 'bio_panels_context', |
| 20 |
|
); |
| 21 |
|
|
| 22 |
|
return $args; |
| 23 |
|
} |
| 24 |
|
|
| 25 |
|
/** |
| 26 |
|
* Return a new context based on an existing context. |
| 27 |
|
*/ |
| 28 |
|
function bio_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 NID for the user's bio node. |
| 36 |
|
$nid = bio_for_user($context->data->uid); |
| 37 |
|
|
| 38 |
|
// Load the node object itself. |
| 39 |
|
$bionode = node_load(array('nid' => $nid)); |
| 40 |
|
|
| 41 |
|
// Send it to Panels. |
| 42 |
|
return panels_context_create('node', $bionode); |
| 43 |
|
} |
| 44 |
|
else { |
| 45 |
|
return panels_context_create_empty('node', NULL); |
| 46 |
|
} |
| 47 |
|
} |
| 48 |
|
|