You are here

function _flipping_book_reference_options in Flipping Book 7

List referenceable flipping_books suitable for the '#option' FAPI prop.

Warning: the function does NOT take care of encoding or escaping the flipping_book titles. Proper massaging needs to be performed by the caller, according to the destination FAPI '#type' (radios / checkboxes / select).

Parameters

array $field: The field definition.

bool $flat: Whether optgroups are allowed.

Return value

array An array of referenceable flipping_book titles, keyed by flipping_book id. If the $flat parameter is TRUE, the list might be nested by optgroup first.

2 calls to _flipping_book_reference_options()
flipping_book_reference_options_list in ./flipping_book_reference.module
Implements hook_options_list().
flipping_book_reference_views_filter_options in ./flipping_book_reference.module
Options callback for the views_handler_filter_in_operator filter.

File

./flipping_book_reference.module, line 535
Defines a field type for referencing one flipping_book from a node.

Code

function _flipping_book_reference_options($field, $flat = TRUE) {
  $references = flipping_book_reference_potential_references($field);
  $options = array();
  foreach ($references as $key => $value) {

    // The label, displayed in selects and checkboxes/radios, should have HTML
    // entities unencoded. The widgets (core's options.module) take care of
    // applying the relevant filters (strip_tags() or filter_xss()).
    $label = decode_entities($value['rendered']);
    if (empty($value['group']) || $flat) {
      $options[$key] = $label;
    }
    else {

      // The group name, displayed in selects, cannot contain tags, and should
      // have HTML entities unencoded.
      $group = decode_entities(strip_tags($value['group']));
      $options[$group][$key] = $label;
    }
  }
  return $options;
}