Revision 209feb13
Added by Andreas Kohlbecker about 4 years ago
modules/cdm_dataportal/includes/descriptions.inc | ||
---|---|---|
2266 | 2266 |
$header = ['Feature/Character', 'State']; |
2267 | 2267 |
|
2268 | 2268 |
$rows = []; |
2269 |
$rows = compose_description_element_rows($root_nodes, $rows);
|
|
2269 |
$rows = description_element_table_rows($root_nodes, $rows);
|
|
2270 | 2270 |
|
2271 | 2271 |
if (!empty($rows)) { |
2272 | 2272 |
$render_array['table'] = markup_to_render_array(theme('table', [ |
... | ... | |
2342 | 2342 |
} |
2343 | 2343 |
|
2344 | 2344 |
/** |
2345 |
* @param $root_nodes |
|
2346 |
* @param $rows |
|
2345 |
* Recursively creates an array of row items to be used in theme_table |
|
2346 |
* |
|
2347 |
* @param array $root_nodes |
|
2348 |
* @param array $row_items |
|
2349 |
* @param int $level |
|
2350 |
* the depth in the hierarchy |
|
2347 | 2351 |
* |
2348 | 2352 |
* @return array |
2353 |
* An array of row items to be used in theme_table |
|
2354 |
* |
|
2355 |
* |
|
2349 | 2356 |
*/ |
2350 |
function compose_description_element_rows($root_nodes, $rows) { |
|
2357 |
function description_element_table_rows($root_nodes, $row_items, $level = 0) { |
|
2358 |
$indent_string = ' '; |
|
2351 | 2359 |
foreach ($root_nodes as $root_node) { |
2352 | 2360 |
if(isset($root_node->descriptionElements)) { |
2353 | 2361 |
foreach ($root_node->descriptionElements as $element) { |
2362 |
$level_indent = str_pad('', $level * strlen($indent_string), $indent_string); |
|
2354 | 2363 |
switch ($element->class) { |
2355 | 2364 |
case 'CategoricalData': |
2356 | 2365 |
if (!empty($element->stateData)) { |
2357 |
$rows[] = [ |
|
2358 |
$element->feature->representation_L10n, |
|
2359 |
render_state_data($element), |
|
2366 |
$row_items[] = [ |
|
2367 |
'data' => [ |
|
2368 |
[ |
|
2369 |
'data' => markup_to_render_array($level_indent . $element->feature->representation_L10n), |
|
2370 |
'class' => 'level_' . $level |
|
2371 |
], |
|
2372 |
render_state_data($element), |
|
2373 |
], |
|
2374 |
'class' => 'level_' . $level |
|
2360 | 2375 |
]; |
2361 | 2376 |
} |
2362 | 2377 |
break; |
2363 | 2378 |
case 'QuantitativeData': |
2364 |
$rows[] = [ |
|
2365 |
$element->feature->representation_L10n, |
|
2366 |
render_quantitative_statistics($element), |
|
2379 |
$row_items[] = [ |
|
2380 |
'data' => [ |
|
2381 |
[ |
|
2382 |
'data' => markup_to_render_array($level_indent . $element->feature->representation_L10n), |
|
2383 |
'class' => 'level_' . $level |
|
2384 |
], |
|
2385 |
render_quantitative_statistics($element) |
|
2386 |
], |
|
2387 |
'class' => 'level_' . $level |
|
2367 | 2388 |
]; |
2368 | 2389 |
break; |
2369 | 2390 |
} |
2370 | 2391 |
} |
2371 | 2392 |
} |
2372 | 2393 |
// recurse child nodes |
2373 |
$rows = compose_description_element_rows($root_node->childNodes, $rows);
|
|
2394 |
$row_items = description_element_table_rows($root_node->childNodes, $row_items, $level + 1);
|
|
2374 | 2395 |
} |
2375 |
return $rows; |
|
2396 |
return $row_items;
|
|
2376 | 2397 |
} |
2377 | 2398 |
|
2378 | 2399 |
|
Also available in: Unified diff
ref #8739 indenting description table entries by chraracter hierarchy