updated to 7.x-1.11

This commit is contained in:
Bachir Soussi Chiadmi
2014-02-07 10:01:18 +01:00
parent a30917d1d2
commit cf03e9ca52
69 changed files with 4629 additions and 1557 deletions
+16 -48
View File
@@ -1,7 +1,12 @@
<?php
/**
* Search API data alteration callback that adds an URL field for all items.
* @file
* Contains SearchApiAlterAddHierarchy.
*/
/**
* Adds all ancestors for hierarchical fields.
*/
class SearchApiAlterAddHierarchy extends SearchApiAbstractAlterCallback {
@@ -15,24 +20,16 @@ class SearchApiAlterAddHierarchy extends SearchApiAbstractAlterCallback {
protected $field_options;
/**
* Enable this data alteration only if any hierarchical fields are available.
* Overrides SearchApiAbstractAlterCallback::supportsIndex().
*
* @param SearchApiIndex $index
* The index to check for.
*
* @return boolean
* TRUE if the callback can run on the given index; FALSE otherwise.
* Returns TRUE only if any hierarchical fields are available.
*/
public function supportsIndex(SearchApiIndex $index) {
return (bool) $this->getHierarchicalFields();
}
/**
* Display a form for configuring this callback.
*
* @return array
* A form array for configuring this callback, or FALSE if no configuration
* is possible.
* {@inheritdoc}
*/
public function configurationForm() {
$options = $this->getHierarchicalFields();
@@ -54,19 +51,7 @@ class SearchApiAlterAddHierarchy extends SearchApiAbstractAlterCallback {
}
/**
* Submit callback for the form returned by configurationForm().
*
* This method should both return the new options and set them internally.
*
* @param array $form
* The form returned by configurationForm().
* @param array $values
* The part of the $form_state['values'] array corresponding to this form.
* @param array $form_state
* The complete form state.
*
* @return array
* The new options array for this callback.
* {@inheritdoc}
*/
public function configurationFormSubmit(array $form, array &$values, array &$form_state) {
// Change the saved type of fields in the index, if necessary.
@@ -74,7 +59,7 @@ class SearchApiAlterAddHierarchy extends SearchApiAbstractAlterCallback {
$fields = &$this->index->options['fields'];
$previous = drupal_map_assoc($this->options['fields']);
foreach ($values['fields'] as $field) {
list($key, $prop) = explode(':', $field);
list($key) = explode(':', $field);
if (empty($previous[$field]) && isset($fields[$key]['type'])) {
$fields[$key]['type'] = 'list<' . search_api_extract_inner_type($fields[$key]['type']) . '>';
$change = TRUE;
@@ -82,7 +67,7 @@ class SearchApiAlterAddHierarchy extends SearchApiAbstractAlterCallback {
}
$new = drupal_map_assoc($values['fields']);
foreach ($previous as $field) {
list($key, $prop) = explode(':', $field);
list($key) = explode(':', $field);
if (empty($new[$field]) && isset($fields[$key]['type'])) {
$w = $this->index->entityWrapper(NULL, FALSE);
if (isset($w->$key)) {
@@ -102,19 +87,11 @@ class SearchApiAlterAddHierarchy extends SearchApiAbstractAlterCallback {
}
/**
* Alter items before indexing.
*
* Items which are removed from the array won't be indexed, but will be marked
* as clean for future indexing. This could for instance be used to implement
* some sort of access filter for security purposes (e.g., don't index
* unpublished nodes or comments).
*
* @param array $items
* An array of items to be altered, keyed by item IDs.
* {@inheritdoc}
*/
public function alterItems(array &$items) {
if (empty($this->options['fields'])) {
return array();
return;
}
foreach ($items as $item) {
$wrapper = $this->index->entityWrapper($item, FALSE);
@@ -137,16 +114,7 @@ class SearchApiAlterAddHierarchy extends SearchApiAbstractAlterCallback {
}
/**
* Declare the properties that are (or can be) added to items with this
* callback. If a property with this name already exists for an entity it
* will be overridden, so keep a clear namespace by prefixing the properties
* with the module name if this is not desired.
*
* @see hook_entity_property_info()
*
* @return array
* Information about all additional properties, as specified by
* hook_entity_property_info() (only the inner "properties" array).
* {@inheritdoc}
*/
public function propertyInfo() {
if (empty($this->options['fields'])) {
@@ -188,7 +156,7 @@ class SearchApiAlterAddHierarchy extends SearchApiAbstractAlterCallback {
}
/**
* Helper method for finding all hierarchical fields of an index's type.
* Finds all hierarchical fields for the current index.
*
* @return array
* An array containing all hierarchical fields of the index, structured as