You are here

protected function views_oai_pmh_plugin_style::eat_attributes in Views OAI-PMH 7.3

Check whether any of the available attributes applies to elements.

Check whether any of the available attributes applies to elements. in the given path. Attributes that apply get removed from $available_attributes.

1 call to views_oai_pmh_plugin_style::eat_attributes()
views_oai_pmh_plugin_style::append_record_metadata in plugins/views_oai_pmh_plugin_style.inc
Builds the core of a record's XML.

File

plugins/views_oai_pmh_plugin_style.inc, line 635
Contains the base OAI-PMH style plugin.

Class

views_oai_pmh_plugin_style
Views OAI-PMH_plugin style.

Code

protected function eat_attributes($path, &$available_attributes) {

  // Clean path to match format used by metadata_format->attributes keys.
  foreach (array_keys($path) as $index) {
    $this
      ->prepare_tag($path[$index]);
  }

  // Loop through all subpaths, starting with the full path.
  while (!empty($path)) {
    $subpath = implode('/', $path);

    // Check if the metadata format supports any attributes on the current
    // path.
    if (isset($this->request->metadata_format->attributes[$subpath]) && !empty($this->request->metadata_format->attributes[$subpath])) {

      // Check if any of our available attributes are among those supported by
      // the metadata format.
      foreach ($available_attributes as $attribute_name => $attribute_field_name) {
        if (in_array($attribute_name, $this->request->metadata_format->attributes[$subpath])) {

          // Attribute applies. Let's remove it from the available ones!
          unset($available_attributes[$attribute_name]);
        }
      }
    }
    array_pop($path);
  }
}