| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: book_parent.inc,v 1.2.2.3 2010/07/20 21:57:27 merlinofchaos Exp $ 3 4 /** 5 * @file 6 * Plugin to provide an relationship handler for book parent. 7 */ 8 9 /** 10 * Plugins are described by creating a $plugin array which will be used 11 * by the system that includes this file. 12 */ 13 $plugin = array( 14 'title' => t('Book parent'), 15 'keyword' => 'book_parent', 16 'description' => t('Adds a book parent from a node context.'), 17 'required context' => new ctools_context_required(t('Node'), 'node'), 18 'context' => 'ctools_book_parent_context', 19 'settings form' => 'ctools_book_parent_settings_form', 20 'settings form validate' => 'ctools_book_parent_settings_form_validate', 21 'defaults' => array('type' => 'top'), 22 ); 23 24 /** 25 * Return a new context based on an existing context. 26 */ 27 function ctools_book_parent_context($context, $conf) { 28 // If unset it wants a generic, unfilled context, which is just NULL. 29 if (empty($context->data)) { 30 return ctools_context_create_empty('node'); 31 } 32 33 if (isset($context->data->book)) { 34 if ($conf['type'] == 'top') { 35 $nid = $context->data->book['bid']; 36 } 37 else { 38 // Just load the parent book. 39 $item = book_link_load($context->data->book['plid']); 40 $nid = $item['nid']; 41 } 42 43 if (!empty($nid)) { 44 // Load the node. 45 $node = node_load($nid); 46 // Generate the context. 47 return ctools_context_create('node', $node); 48 } 49 } 50 } 51 52 /** 53 * Settings form for the relationship. 54 */ 55 function ctools_book_parent_settings_form($conf) { 56 $form['type'] = array( 57 '#type' => 'select', 58 '#title' => t('Relationship type'), 59 '#options' => array('parent' => t('Immediate parent'), 'top' => t('Top level book')), 60 '#default_value' => $conf['type'], 61 ); 62 63 return $form; 64 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Jul 9 18:01:44 2012 | Cross-referenced by PHPXref 0.7 |