| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: view.inc,v 1.1.2.3 2010/07/24 17:57:24 merlinofchaos Exp $ 3 4 /** 5 * @file 6 * 7 * Plugin to provide a node context. A node context is a node wrapped in a 8 * context object that can be utilized by anything that accepts contexts. 9 */ 10 11 /** 12 * Plugins are described by creating a $plugin array which will be used 13 * by the system that includes this file. 14 */ 15 $plugin = array( 16 'title' => t("View"), 17 'description' => t('Loads a view result into a context that can then be displayed across a panel or turned into other contexts.'), 18 'context' => 'views_content_context_view_create', 19 20 'settings form' => 'views_content_context_view_settings_form', 21 'settings form validate' => 'views_content_context_view_settings_form_validate', 22 'settings form submit' => 'views_content_context_view_settings_form_submit', 23 24 'defaults' => array('view' => ''), 25 26 'keyword' => 'view', 27 'context name' => 'view', 28 29 /* 30 'convert list' => 'views_content_context_view_convert_list', 31 'convert' => 'views_content_context_view_convert', 32 */ 33 34 /* 35 'placeholder form' => array( 36 '#type' => 'textfield', 37 '#description' => t('Enter the node ID of a node for this context.'), 38 ), 39 */ 40 ); 41 42 function views_content_context_view_create($empty, $data = NULL, $conf = FALSE) { 43 $context = new ctools_context('view'); 44 $context->plugin = 'view'; 45 46 if ($empty) { 47 return $context; 48 } 49 50 if ($conf) { 51 if (is_array($data) && !empty($data['view'])) { 52 list($name, $display_id) = explode(':', $data['view'], 2); 53 $data = views_get_view($name); 54 if ($data) { 55 $data->set_display($display_id); 56 } 57 } 58 } 59 60 if (is_object($data)) { 61 // We don't store the loaded view as we don't want the view object 62 // cached. 63 $context->data = array( 64 'name' => $data->name, 65 'display' => $data->current_display, 66 ); 67 68 // At runtime, this can get populated. Once it is populated this 69 // object should not be cached. 70 $context->view = NULL; 71 $context->title = $data->get_title(); 72 $context->argument = $data->name . ':' . $data->current_display; 73 74 $context->restrictions['base'] = array($data->base_table); 75 76 return $context; 77 } 78 } 79 80 function views_content_context_view_settings_form($conf) { 81 $views = views_get_applicable_views('returns context'); 82 foreach ($views as $data) { 83 list($view, $id) = $data; 84 $title = $view->display_handler->get_option('admin_title'); 85 if (!$title) { 86 $title = $view->name; 87 } 88 $options[$view->name . ':' . $id] = $title; 89 } 90 91 if (!empty($options)) { 92 natcasesort($options); 93 $form['view'] = array( 94 '#type' => 'select', 95 '#options' => $options, 96 '#title' => t('View'), 97 ); 98 } 99 else { 100 $form['view'] = array( 101 '#value' => '<p>' . t('There are currently no views with Context displays enabled. You should go to the view administration and add a Context display to use a view as a context.') . '</p>', 102 ); 103 } 104 105 return $form; 106 } 107 108 /** 109 * Validate a node. 110 */ 111 function views_content_context_view_settings_form_validate($form, &$form_values, &$form_state) { 112 if (empty($form_values['view'])) { 113 form_error($form['view'], t('You must select a view.')); 114 } 115 } 116 117 /** 118 * Provide a list of ways that this context can be converted to a string. 119 */ 120 function views_content_context_view_convert_list() { 121 $list = array( 122 ); 123 124 return $list; 125 } 126 127 /** 128 * Convert a context into a string. 129 */ 130 function views_content_context_view_convert($context, $type) { 131 switch ($type) { 132 } 133 } 134
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 |