| 1 |
<?php |
<?php |
| 2 |
// $Id$ |
// $Id: index.view.inc,v 1.1.2.2 2009/04/24 19:31:10 xano Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 6 |
* All functions for viewing indexes. |
* All functions for viewing indexes. |
| 7 |
*/ |
*/ |
| 8 |
|
|
| 9 |
/** |
/** |
| 19 |
function theme_index_preview_title($title) { |
function theme_index_preview_title($title) { |
| 20 |
return '<h3>' . $title . '</h3>'; |
return '<h3>' . $title . '</h3>'; |
| 21 |
} |
} |
| 22 |
|
|
| 23 |
|
/** |
| 24 |
|
* Render a single entity. |
| 25 |
|
* |
| 26 |
|
* @param $entity object |
| 27 |
|
* The entity object to render. |
| 28 |
|
*/ |
| 29 |
|
function index_render_entity($entity) { |
| 30 |
|
$entity_types_info = index_entity_types_get(); |
| 31 |
|
$theme_info = $entity_types_info[$entity->index_entity_type]['#theme_info']; |
| 32 |
|
require_once('./'. drupal_get_path('module', $theme_info['#module']) . '/' . $theme_info['#file']); |
| 33 |
|
|
| 34 |
|
return theme($theme_info['#theme'], $entity); |
| 35 |
|
} |
| 36 |
|
|
| 37 |
|
/** |
| 38 |
|
* Render an index as a tree. |
| 39 |
|
* |
| 40 |
|
* @param $index index |
| 41 |
|
* The index object of the index to render. |
| 42 |
|
* @param $depth integer |
| 43 |
|
* The layer to render. Internal use only. |
| 44 |
|
* @param $i integer |
| 45 |
|
* Incrementor used for calculating the zebra value. Internal use only. |
| 46 |
|
* |
| 47 |
|
* @return string |
| 48 |
|
* The fully rendered index. |
| 49 |
|
*/ |
| 50 |
|
function index_render_tree(index $index) { |
| 51 |
|
return theme('item_list', _index_render_tree($index)); |
| 52 |
|
} |
| 53 |
|
|
| 54 |
|
/** |
| 55 |
|
* Helper function for index_render_tree(). |
| 56 |
|
*/ |
| 57 |
|
function _index_render_tree(index $index, $depth = 0, &$i = 0, $parent = NULL) { |
| 58 |
|
$items = array(); |
| 59 |
|
$next_layer_entity_type = $index->layers[$depth + 1]['type']; |
| 60 |
|
$entity_types_info = index_entity_types_get(); |
| 61 |
|
$next_layer_entity_type_info = $entity_types_info[$next_layer_entity_type]; |
| 62 |
|
$key = $next_layer_entity_type_info['#relations'][$index->layers[$depth]['type']]; |
| 63 |
|
foreach ($index->data[$depth] as $entity) { |
| 64 |
|
if (isset($index->data[$depth + 1][$entity->$key])) { |
| 65 |
|
$children = index_render_tree($index, $depth + 1, $i, $entity); |
| 66 |
|
} |
| 67 |
|
} |
| 68 |
|
|
| 69 |
|
|
| 70 |
|
|
| 71 |
|
|
| 72 |
|
|
| 73 |
|
|
| 74 |
|
for ($i = 0, $len_i = count($children[$pid]); $i < $len_i; $i++) { |
| 75 |
|
$i++; |
| 76 |
|
$zebra = ($i % 2 == 0 ? 'even' : 'odd'); |
| 77 |
|
$term = $tree[$children[$pid][$i]]; |
| 78 |
|
|
| 79 |
|
$term_children = NULL; |
| 80 |
|
$parent = NULL; |
| 81 |
|
if (array_key_exists($term->tid, $children)) { |
| 82 |
|
$term_children = _vocabindex_list_render_tree($tree, $children, $vi, $term->tid, $i); |
| 83 |
|
} |
| 84 |
|
|
| 85 |
|
// Render the current term. |
| 86 |
|
$items[] = array( |
| 87 |
|
'data' => vocabindex_term_link($term, $vi), |
| 88 |
|
'children' => $term_children, |
| 89 |
|
'class' => $zebra . (!is_null($term_children) ? ' parent expanded' : NULL), |
| 90 |
|
); |
| 91 |
|
} |
| 92 |
|
|
| 93 |
|
return 'yaman'; |
| 94 |
|
} |