Mercurial > hg > rr-repo
comparison sites/all/modules/semanticviews/semanticviews.module @ 4:ce11bbd8f642
added modules
author | danieleb <danielebarchiesi@me.com> |
---|---|
date | Thu, 19 Sep 2013 10:38:44 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
3:b28be78d8160 | 4:ce11bbd8f642 |
---|---|
1 <?php | |
2 /** | |
3 * @file semanticviews.module | |
4 * TODO: Enter file description here. | |
5 */ | |
6 | |
7 /** | |
8 * Implementation of hook_views_api(). | |
9 */ | |
10 function semanticviews_views_api() { | |
11 return array( | |
12 'api' => 2.0, | |
13 ); | |
14 } | |
15 | |
16 /** | |
17 * Helper function that returns an array with field aliases as key and the | |
18 * field tokens as values. | |
19 * | |
20 * @see views_handler_field::get_render_tokens() | |
21 */ | |
22 function semanticviews_get_alias_tokens($view) { | |
23 $tokens = array(); | |
24 // Now add replacements for our fields. | |
25 foreach ($view->display_handler->get_handlers('field') as $name => $handler) { | |
26 $tokens[$handler->field_alias] = "[$name]"; | |
27 } | |
28 return $tokens; | |
29 } | |
30 | |
31 /** | |
32 * Helper function that returns row replacements given a row and all tokens. | |
33 */ | |
34 function semanticviews_get_token_replacements($row, $tokens) { | |
35 $replacements = array(); | |
36 foreach ($row as $alias => $value) { | |
37 if (!empty($tokens[$alias])) { | |
38 $replacements[$tokens[$alias]] = $value; | |
39 } | |
40 } | |
41 return $replacements; | |
42 } |