Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TL : mise a jour tl_hacks pour gerer icons univers sur views
- Loading branch information
Showing
3 changed files
with
84 additions
and
1 deletion.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
sites/terraludis.org/modules/tl_hacks/og_handler_filter_group_audience_gid_tl.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
/** | ||
* Filter handler for group audience:gid | ||
*/ | ||
class og_handler_filter_group_audience_gid_tl extends views_handler_filter_many_to_one { | ||
|
||
function get_value_options() { | ||
|
||
// @TODO add extra settings to allow filtering by OG_STATE in og_get_all_group() | ||
$groups = og_load_multiple(og_get_all_group()); | ||
|
||
foreach($groups as $group) { | ||
if ($group->access()) { | ||
$entity = reset(entity_load('node', array($group->etid))); | ||
if ($this->value_form_type == 'checkboxes') { | ||
$flang = field_language('node', $entity, 'field_icon'); | ||
$imageData = array( | ||
'style_name' => 'universe_icon', | ||
'path' => !empty($entity->field_icon) ? $entity->field_icon[$flang][0]['filename'] : _tl_hacks_get_default_icon_uri(), | ||
'alt' => check_plain($entity->title), | ||
'title' => check_plain($entity->title), | ||
); | ||
$this->value_options[$group->gid] = theme('image_style', $imageData); | ||
} else { | ||
$this->value_options[$group->gid] = $entity->title; | ||
} | ||
} | ||
} | ||
} | ||
|
||
function value_form(&$form, &$form_state) { | ||
if (empty($form_state['form_id']) || $form_state['form_id'] != 'views_ui_config_item_form') { | ||
$this->value_form_type = 'checkboxes'; | ||
} | ||
|
||
parent::value_form($form, $form_state); | ||
|
||
if (empty($form_state['form_id']) || $form_state['form_id'] != 'views_ui_config_item_form') { | ||
$form['value']['#theme'] = 'select_as_checkboxes'; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ package = Terraludis | |
core = 7.x | ||
|
||
files[] = tl_hacks.module | ||
files[] = og_handler_filter_group_audience_gid_tl.inc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters