You are here

function flipping_book_reference_potential_references in Flipping Book 7

Retrieves an array of candidate referenceable flipping_books.

This info is used in various places (allowed values, autocomplete results, input validation...). Some of them only need the fbids, others fbid + titles, others yet fbid + titles + rendered row (for display in widgets).

The array we return contains all the potentially needed information, and lets consumers use the parts they actually need.

Parameters

array $field: The field definition.

array $options: An array of options to limit the scope of the returned list. The following key/value pairs are accepted:

  • string: string to filter titles on (used by autocomplete).
  • match: operator to match the above string against, can be any of: 'contains', 'equals', 'starts_with'. Defaults to 'contains'.
  • ids: array of specific flipping_book ids to lookup.
  • limit: maximum size of the the result set. Defaults to 0 (no limit).

Return value

array An array of valid flipping_books in the form: array( fbid => array( 'title' => The flipping_book title, 'rendered' => The text to display in widgets (can be HTML) ), ... )

4 calls to flipping_book_reference_potential_references()
flipping_book_reference_autocomplete in ./flipping_book_reference.module
Menu callback for the autocomplete results.
flipping_book_reference_autocomplete_validate in ./flipping_book_reference.module
Validation callback for a flipping_book_reference autocomplete element.
flipping_book_reference_field_validate in ./flipping_book_reference.module
Implements hook_field_validate().
_flipping_book_reference_options in ./flipping_book_reference.module
List referenceable flipping_books suitable for the '#option' FAPI prop.

File

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

Code

function flipping_book_reference_potential_references($field, $options = array()) {

  // Fill in default options.
  $options += array(
    'string' => '',
    'match' => 'contains',
    'ids' => array(),
    'limit' => 0,
  );
  $results =& drupal_static(__FUNCTION__, array());

  // Create unique id for static cache.
  $cid = $field['field_name'] . ':' . $options['match'] . ':' . ($options['string'] !== '' ? $options['string'] : implode('-', $options['ids'])) . ':' . $options['limit'];
  if (!isset($results[$cid])) {
    $references = _flipping_book_reference_potential_references_standard($field, $options);

    // Store the results.
    $results[$cid] = !empty($references) ? $references : array();
  }
  return $results[$cid];
}