hs_flatlist.module

Tracking 5.x-3.x branch
  1. drupal
    1. 5 contributions/hierarchical_select/modules/hs_flatlist.module
    2. 6 contributions/hierarchical_select/modules/hs_flatlist.module

Implementation of the Hierarchical Select API that allows one to use Hierarchical Select's dropbox for selecting multiple items of a flat list.

Functions & methods

NameDescription
hs_flatlist_hierarchical_select_childrenImplementation of hook_hierarchical_select_children().
hs_flatlist_hierarchical_select_implementation_infoImplementation of hook_hierarchical_select_implementation_info().
hs_flatlist_hierarchical_select_item_get_labelImplementation of hook_hierarchical_select_item_get_label().
hs_flatlist_hierarchical_select_lineageImplementation of hook_hierarchical_select_lineage().
hs_flatlist_hierarchical_select_paramsImplementation of hook_hierarchical_select_params().
hs_flatlist_hierarchical_select_root_levelImplementation of hook_hierarchical_select_root_level().
hs_flatlist_hierarchical_select_valid_itemImplementation of hook_hierarchical_select_valid_item().

File

View source
  1. <?php
  2. /**
  3. * @file
  4. * Implementation of the Hierarchical Select API that allows one to use
  5. * Hierarchical Select's dropbox for selecting multiple items of a flat list.
  6. */
  7. //----------------------------------------------------------------------------
  8. // Hierarchical Select hooks.
  9. /**
  10. * Implementation of hook_hierarchical_select_params().
  11. */
  12. function hs_flatlist_hierarchical_select_params() {
  13. $params = array(
  14. 'options',
  15. );
  16. return $params;
  17. }
  18. /**
  19. * Implementation of hook_hierarchical_select_root_level().
  20. */
  21. function hs_flatlist_hierarchical_select_root_level($params) {
  22. return $params['options'];
  23. }
  24. /**
  25. * Implementation of hook_hierarchical_select_children().
  26. */
  27. function hs_flatlist_hierarchical_select_children($parent, $params) {
  28. return array(); // A flat list doesn't have any children, ever.
  29. }
  30. /**
  31. * Implementation of hook_hierarchical_select_lineage().
  32. */
  33. function hs_flatlist_hierarchical_select_lineage($item, $params) {
  34. return array($item); // No hierarchies exist in flat lists.
  35. }
  36. /**
  37. * Implementation of hook_hierarchical_select_valid_item().
  38. */
  39. function hs_flatlist_hierarchical_select_valid_item($item, $params) {
  40. return (in_array($item, array_keys($params['options'])));
  41. }
  42. /**
  43. * Implementation of hook_hierarchical_select_item_get_label().
  44. */
  45. function hs_flatlist_hierarchical_select_item_get_label($item, $params) {
  46. return $params['options'][$item];
  47. }
  48. /**
  49. * Implementation of hook_hierarchical_select_implementation_info().
  50. */
  51. function hs_flatlist_hierarchical_select_implementation_info() {
  52. return array(
  53. 'hierarchy type' => t('None: flat list'),
  54. 'entity type' => t('N/A'),
  55. );
  56. }