'Multivalue CSV parser', 'description' => 'Parse data in Comma Separated Value format, with the option for multiple values per cell.', 'handler' => array( 'parent' => 'FeedsCSVParser', 'class' => 'FeedsMultiValueCSVParser', 'file' => 'FeedsMultiValueCSVParser.inc', 'path' => drupal_get_path('module', 'gefos') . '/feeds', ), ); return $info; } /** * Implements hook_block_info(). * * This hook declares what blocks are provided by the module. */ function gefos_block_info() { $blocks = array(); $blocks['related-content'] = array( 'info' => t('Related information (Gefos)'), 'status' => TRUE, 'region' => 'sidebar_first', 'visibility' => BLOCK_VISIBILITY_LISTED, 'pages' => 'node/*', ); return $blocks; } /** * Implements hook_block_view(). * * This hook generates the contents of the blocks themselves. */ function gefos_block_view($delta = '') { //The $delta parameter tells us which block is being requested. switch ($delta) { case 'related-content': return _gefos_related_content_block_content(); default: return; } } /** * Related content block content. */ function _gefos_related_content_block_content() { if (strpos($_GET['q'], 'node/') === 0) { $node_path = explode('/', $_GET['q']); if (array_key_exists(1, $node_path) && is_numeric($node_path[1])) { $node = node_load($node_path[1]); $related_content = array(); // look for nodes refering the current node $query = db_select('field_config', 'f'); $query->fields('f', array('field_name')) ->condition('f.type', 'node_reference', '=') ->condition('f.deleted', FALSE, '='); $result = $query->execute(); while ($record = $result->fetchAssoc()) { //debug($record); $field_name = $record['field_name']; $q = db_select('field_data_' . $field_name, 'f'); $q->fields('f', array('entity_id')) ->condition('f.deleted', FALSE, '=') ->condition('f.' . $field_name . '_nid', $node->nid, '='); $res = $q->execute(); while ($rec = $res->fetchAssoc()) { $related_node = node_load($rec['entity_id']); if (node_access('view', $related_node)) { $node_type = node_type_load($related_node->type); if (!array_key_exists($node_type->name, $related_content)) { $related_content[$node_type->name] = array(); } $related_content[$node_type->name][$related_node->title] = $related_node->nid; } } } // look for nodes referred by the current node $query = db_select('field_config', 'f'); $query->join('field_config_instance', 'fi', 'f.id = fi.field_id'); $query->fields('f', array('field_name')) ->condition('f.type', 'node_reference', '=') ->condition('f.deleted', FALSE, '=') ->condition('fi.bundle', $node->type, '='); $result = $query->execute(); while ($record = $result->fetchAssoc()) { $field_name = $record['field_name']; $field = $node->$field_name; $field_info = field_info_instance('node', $field_name, $node->type); $related_content[$field_info['label']] = array(); if (array_key_exists($node->language, $field)) { $values = $field[$node->language]; if ($values) { foreach ($values as $val) { $related_node = node_load($val['nid']); if (node_access('view', $related_node)) { $related_content[$field_info['label']][$related_node->title] = $related_node->nid; } } } } } if (empty($related_content)) { return; } $content = ''; $block = array(); $block['subject'] = t('Related information'); $block['content'] = $content; return $block; } } return; } function gefos_menu() { $items = array(); $items['admin/config/development/gefos'] = array( 'title' => 'Gefos', 'description' => 'development tools for Gefos', 'page callback' => 'drupal_get_form', 'page arguments' => array('_gefos_devel_form'), 'access arguments' => array('administer site configuration'), ); return $items; } function _gefos_devel_form() { $form = array(); $form['field_description'] = array( '#type' => 'fieldset', '#title' => t('Field descriptions'), ); $form['field_description']['run'] = array( '#type' => 'submit', '#value' => t('Configure field descriptions for Gefos content types'), '#submit' => array('_gefos_enable_field_description_batch'), ); $form['field_description']['debug'] = array( '#type' => 'submit', '#value' => t('Debug'), '#submit' => array('_gefos_devel_form_debug'), ); return $form; } function _gefos_devel_form_debug() { $index = search_api_index_load('studies_index', TRUE); dpm($index, 'index'); dpm($index->getFields(FALSE, TRUE), 'getFields'); }