updated webform, uuid, synonyms modules
This commit is contained in:
parent
ed483507e5
commit
b9c809d2c7
@ -7,9 +7,9 @@ files[] = uuid.test
|
||||
dependencies[] = node
|
||||
dependencies[] = user
|
||||
|
||||
; Information added by Drupal.org packaging script on 2016-08-02
|
||||
version = "7.x-1.0-beta2"
|
||||
; Information added by Drupal.org packaging script on 2017-04-27
|
||||
version = "7.x-1.0"
|
||||
core = "7.x"
|
||||
project = "uuid"
|
||||
datestamp = "1470153540"
|
||||
datestamp = "1493291958"
|
||||
|
||||
|
@ -5,9 +5,9 @@ package = UUID
|
||||
dependencies[] = uuid
|
||||
|
||||
|
||||
; Information added by Drupal.org packaging script on 2016-08-02
|
||||
version = "7.x-1.0-beta2"
|
||||
; Information added by Drupal.org packaging script on 2017-04-27
|
||||
version = "7.x-1.0"
|
||||
core = "7.x"
|
||||
project = "uuid"
|
||||
datestamp = "1470153540"
|
||||
datestamp = "1493291958"
|
||||
|
||||
|
@ -7,9 +7,9 @@ dependencies[] = services
|
||||
dependencies[] = uuid
|
||||
dependencies[] = entity
|
||||
|
||||
; Information added by Drupal.org packaging script on 2016-08-02
|
||||
version = "7.x-1.0-beta2"
|
||||
; Information added by Drupal.org packaging script on 2017-04-27
|
||||
version = "7.x-1.0"
|
||||
core = "7.x"
|
||||
project = "uuid"
|
||||
datestamp = "1470153540"
|
||||
datestamp = "1493291958"
|
||||
|
||||
|
@ -11,9 +11,9 @@ features[ctools][] = services:services:3
|
||||
features[features_api][] = api:2
|
||||
features[services_endpoint][] = uuid_services_example
|
||||
|
||||
; Information added by Drupal.org packaging script on 2016-08-02
|
||||
version = "7.x-1.0-beta2"
|
||||
; Information added by Drupal.org packaging script on 2017-04-27
|
||||
version = "7.x-1.0"
|
||||
core = "7.x"
|
||||
project = "uuid"
|
||||
datestamp = "1470153540"
|
||||
datestamp = "1493291958"
|
||||
|
||||
|
@ -611,7 +611,7 @@ function webform_get_submissions($filters = array(), $header = NULL, $pager_coun
|
||||
|
||||
// No need to find SIDs if it was given to us.
|
||||
if (isset($filters['sid'])) {
|
||||
$sids = array($filters['sid']);
|
||||
$sids = (array) $filters['sid'];
|
||||
}
|
||||
// Build the list of SIDs that need to be retrieved.
|
||||
else {
|
||||
@ -705,7 +705,12 @@ function webform_get_submissions($filters = array(), $header = NULL, $pager_coun
|
||||
$function($submissions);
|
||||
}
|
||||
|
||||
return $submissions;
|
||||
// Reorder submissions to reflect table header sorting.
|
||||
$ordered_submissions = array();
|
||||
foreach($sids as $sid) {
|
||||
$ordered_submissions[$sid] = $submissions[$sid];
|
||||
}
|
||||
return $ordered_submissions;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -24,9 +24,9 @@ files[] = tests/permissions.test
|
||||
files[] = tests/submission.test
|
||||
files[] = tests/webform.test
|
||||
|
||||
; Information added by Drupal.org packaging script on 2016-10-19
|
||||
version = "7.x-3.25"
|
||||
; Information added by Drupal.org packaging script on 2017-02-09
|
||||
version = "7.x-3.27"
|
||||
core = "7.x"
|
||||
project = "webform"
|
||||
datestamp = "1476870845"
|
||||
datestamp = "1486665496"
|
||||
|
||||
|
@ -48,6 +48,7 @@ Module ships with ability to provide synonyms from the following locations:
|
||||
* "Taxonomy Term Reference" field type
|
||||
* "Entity Reference" field type
|
||||
* "Commerce Product Reference" field type
|
||||
* "Commerce price" field type
|
||||
* "Number" field type
|
||||
* "Float" field type
|
||||
* "Decimal" field type
|
||||
|
@ -41,6 +41,7 @@ As stated above, your synonyms can be stored in about any kind of storage. On th
|
||||
<li>Decimal</li>
|
||||
<li>Float</li>
|
||||
<li>Commerce product reference (you'll have to additionally enable "Synonyms Commerce" submodule for this one)</li>
|
||||
<li>Commerce price (you'll have to additionally enable "Synonyms Commerce" submodule for this one)</li>
|
||||
</ul>
|
||||
|
||||
<p>Other modules may extend this list by implementing behaviors for other field types. Refer to <a href="&topic:synonyms/synonyms_behavior_implementation_field_based&">writing custom field-based behavior implementation</a> for more details.</p>
|
||||
|
@ -17,11 +17,14 @@ interface SynonymsBehavior {
|
||||
*
|
||||
* @param object $entity
|
||||
* Entity from which to extract synonyms
|
||||
* @param string $langcode
|
||||
* Language code for which to extract synonyms from the entity, if one is
|
||||
* known
|
||||
*
|
||||
* @return array
|
||||
* Array of synonyms extracted from $entity
|
||||
* @return array Array of synonyms extracted from $entity
|
||||
* Array of synonyms extracted from $entity
|
||||
*/
|
||||
public function extractSynonyms($entity);
|
||||
public function extractSynonyms($entity, $langcode = NULL);
|
||||
|
||||
/**
|
||||
* Add an entity as a synonym into another entity.
|
||||
@ -65,7 +68,11 @@ interface SynonymsBehavior {
|
||||
* For ease of work with these placeholders, you may extend the
|
||||
* AbstractSynonymsBehavior class and then just invoke the
|
||||
* AbstractSynonymsBehavior->synonymsFindProcessCondition() method, so you
|
||||
* won't have to worry much about it
|
||||
* won't have to worry much about it. Important note: if you plan on
|
||||
* re-using the same $condition object for multiple invocations of this
|
||||
* method you must pass in here a clone of your condition object, since the
|
||||
* internal implementation of this method will change the condition (will
|
||||
* swap the aforementioned placeholders with actual column names)
|
||||
*
|
||||
* @return Traversable
|
||||
* Traversable result set of found synonyms and entity IDs to which those
|
||||
|
@ -24,7 +24,7 @@ function synonyms_behavior_autocomplete_settings_form($form, &$form_state, $sett
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Autocomplete wording'),
|
||||
'#default_value' => isset($settings['wording']) ? $settings['wording'] : '@synonym is a synonym of @entity',
|
||||
'#description' => t('Specify with what wording the synonyms should be suggested in the autocomplete feature. You may use: <ul><li><em>@synonym</em> to denote value of the synonym</li><li><em>@entity</em> to denote entity name</li><li><em>@field_name</em> to denote lowercase label of the field from where the synonym originates</li></ul>'),
|
||||
'#description' => t('Specify with what wording the synonyms should be suggested in the autocomplete feature. You may use: <ul><li><em>@synonym</em> to denote value of the synonym</li><li><em>@entity</em> to denote entity name</li><li><em>@field_name</em> to denote lowercase label of the field from where the synonym originates</li><li><em>@bundle</em> to denote bundle name of the suggested entity</li></ul>'),
|
||||
'#required' => TRUE,
|
||||
);
|
||||
|
||||
|
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Synonyms-friendly entity look up feeds taper plugin.
|
||||
*/
|
||||
|
||||
$plugin = array(
|
||||
'form' => 'synonyms_entity_find_feeds_tamper_form',
|
||||
'callback' => 'synonyms_entity_find_feeds_tamper_callback',
|
||||
'name' => 'Synonyms-friendly entity look up',
|
||||
'multi' => 'loop',
|
||||
'category' => 'Other',
|
||||
);
|
||||
|
||||
/**
|
||||
* Feeds tamper settings form builder.
|
||||
*/
|
||||
function synonyms_entity_find_feeds_tamper_form($importer, $element_key, $settings, array &$form_state) {
|
||||
$html_id = 'synonysm-entity-find-feeds-tamper-settings';
|
||||
$form = array(
|
||||
'#prefix' => '<div id="' . $html_id . '">',
|
||||
'#suffix' => '</div>',
|
||||
);
|
||||
|
||||
$entity_info = entity_get_info();
|
||||
|
||||
$entity_type_options = array();
|
||||
foreach ($entity_info as $entity_type => $entity_type_info) {
|
||||
$entity_type_options[$entity_type] = $entity_type_info['label'];
|
||||
}
|
||||
|
||||
$default_entity_type = isset($form_state['values']['settings']['entity_type']) ? $form_state['values']['settings']['entity_type'] : (isset($settings['entity_type']) ? $settings['entity_type'] : NULL);
|
||||
|
||||
$form['entity_type'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Entity type'),
|
||||
'#required' => TRUE,
|
||||
'#options' => $entity_type_options,
|
||||
'#default_value' => $default_entity_type,
|
||||
'#ajax' => array(
|
||||
'callback' => 'synonyms_entity_find_feeds_tamper_form_ajax',
|
||||
'wrapper' => $html_id,
|
||||
),
|
||||
);
|
||||
|
||||
$bundle_options = array();
|
||||
if ($default_entity_type) {
|
||||
foreach ($entity_info[$default_entity_type]['bundles'] as $bundle => $bundle_info) {
|
||||
$bundle_options[$bundle] = $bundle_info['label'];
|
||||
}
|
||||
}
|
||||
|
||||
$form['bundle'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Bundle'),
|
||||
'#options' => $bundle_options,
|
||||
'#default_value' => isset($settings['bundle']) ? $settings['bundle'] : NULL,
|
||||
'#access' => isset($entity_type['entity keys']['bundle']) && $entity_type['entity keys']['bundle'],
|
||||
);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Feeds tamper callback to execute entity look up by its synonyms.
|
||||
*/
|
||||
function synonyms_entity_find_feeds_tamper_callback($result, $item_key, $element_key, &$field, array $settings) {
|
||||
$found = synonyms_get_entity_by_synonym($settings['entity_type'], $field, $settings['bundle']);
|
||||
if ($found) {
|
||||
$field = $found;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax callback for form changes.
|
||||
*/
|
||||
function synonyms_entity_find_feeds_tamper_form_ajax(array $form, array &$form_state) {
|
||||
return isset($form['plugin']['settings']) ? $form['plugin']['settings'] : $form['settings'];
|
||||
}
|
@ -75,11 +75,14 @@ class MySynonymsSynonymsBehavior extends AbstractSynonymsBehavior implements Aut
|
||||
*
|
||||
* @param object $entity
|
||||
* Entity from which to extract synonyms
|
||||
* @param string $langcode
|
||||
* Language code for which to extract synonyms from the entity, if one is
|
||||
* known
|
||||
*
|
||||
* @return array
|
||||
* Array of synonyms extracted from $entity
|
||||
*/
|
||||
public function extractSynonyms($entity) {
|
||||
public function extractSynonyms($entity, $langcode = NULL) {
|
||||
$synonyms = array();
|
||||
|
||||
// Do something with $entity in order to extract synonyms from it. Add all
|
||||
@ -129,12 +132,16 @@ class MySynonymsSynonymsBehavior extends AbstractSynonymsBehavior implements Aut
|
||||
* synonyms column which you should replace with the actual column name
|
||||
* where the synonyms data for your provider is stored in plain text.
|
||||
* - AbstractSynonymsBehavior::COLUMN_ENTITY_ID_PLACEHOLDER: to denote
|
||||
* column that holds entity ID. You are supposed to replace this placeholder
|
||||
* with actual column name that holds entity ID in your case.
|
||||
* column that holds entity ID. You are supposed to replace this
|
||||
* placeholder with actual column name that holds entity ID in your case.
|
||||
* For ease of work with these placeholders, you may extend the
|
||||
* AbstractSynonymsBehavior class and then just invoke the
|
||||
* AbstractSynonymsBehavior->synonymsFindProcessCondition() method, so you
|
||||
* won't have to worry much about it
|
||||
* won't have to worry much about it. Important note: if you plan on
|
||||
* re-using the same $condition object for multiple invocations of this
|
||||
* method you must pass in here a clone of your condition object, since the
|
||||
* internal implementation of this method will change the condition (will
|
||||
* swap the aforementioned placeholders with actual column names)
|
||||
*
|
||||
* @return Traversable
|
||||
* Traversable result set of found synonyms and entity IDs to which those
|
||||
|
@ -21,9 +21,9 @@ files[] = views/synonyms_views_handler_filter_term_tid.inc
|
||||
files[] = views/synonyms_views_handler_field_synonyms.inc
|
||||
files[] = views/synonyms_views_handler_filter_entityreference_synonyms.inc
|
||||
|
||||
; Information added by Drupal.org packaging script on 2016-05-07
|
||||
version = "7.x-1.5"
|
||||
; Information added by Drupal.org packaging script on 2017-06-30
|
||||
version = "7.x-1.6"
|
||||
core = "7.x"
|
||||
project = "synonyms"
|
||||
datestamp = "1462586641"
|
||||
datestamp = "1498833845"
|
||||
|
||||
|
@ -17,13 +17,13 @@ function synonyms_schema() {
|
||||
'entity_type' => array(
|
||||
'description' => 'Entity type whose behavior implementation is stored in this row.',
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'length' => 128,
|
||||
'not null' => TRUE,
|
||||
),
|
||||
'bundle' => array(
|
||||
'description' => 'Bundle name whose behavior implementation is stored in this row.',
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'length' => 128,
|
||||
'not null' => TRUE,
|
||||
),
|
||||
'provider' => array(
|
||||
@ -311,3 +311,63 @@ function synonyms_update_7103() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Truncating 'entity_type' and 'bundle' columns to 128 length.
|
||||
*/
|
||||
function synonyms_update_7104() {
|
||||
$table = 'synonyms_settings';
|
||||
|
||||
$indexes = array(
|
||||
'unique keys' => array(
|
||||
// We build 2 different indexes on the same column set because there are
|
||||
// 2 different functions that may query this table and the columns they
|
||||
// filter on may vary.
|
||||
'behavior_implementation' => array('behavior', 'entity_type', 'bundle', 'provider'),
|
||||
'all_enabled' => array('entity_type', 'bundle', 'provider', 'behavior'),
|
||||
),
|
||||
);
|
||||
|
||||
$fields = array(
|
||||
'entity_type' => array(
|
||||
'description' => 'Entity type whose behavior implementation is stored in this row.',
|
||||
'type' => 'varchar',
|
||||
'length' => 128,
|
||||
'not null' => TRUE,
|
||||
),
|
||||
'bundle' => array(
|
||||
'description' => 'Bundle name whose behavior implementation is stored in this row.',
|
||||
'type' => 'varchar',
|
||||
'length' => 128,
|
||||
'not null' => TRUE,
|
||||
),
|
||||
);
|
||||
|
||||
foreach ($fields as $field => $schema) {
|
||||
foreach ($indexes['unique keys'] as $index_name => $index_specification) {
|
||||
db_drop_unique_key($table, $index_name);
|
||||
}
|
||||
|
||||
db_change_field($table, $field, $field, $schema, $indexes);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Making actual module tables follow the declared schema.
|
||||
*/
|
||||
function synonyms_update_7105() {
|
||||
db_drop_unique_key('synonyms_settings', 'behavior_implementation');
|
||||
db_drop_unique_key('synonyms_settings', 'all_enabled');
|
||||
|
||||
db_change_field('synonyms_settings', 'provider', 'provider', array(
|
||||
'description' => 'Provider name whose behavior implementation is stored in this row.',
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
), array(
|
||||
'unique keys' => array(
|
||||
'behavior_implementation' => array('behavior', 'entity_type', 'bundle', 'provider'),
|
||||
'all_enabled' => array('entity_type', 'bundle', 'provider', 'behavior'),
|
||||
),
|
||||
));
|
||||
}
|
||||
|
@ -105,6 +105,13 @@ function synonyms_ctools_plugin_directory($owner, $plugin_type) {
|
||||
return 'plugins/' . $plugin_type;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'feeds_tamper':
|
||||
switch ($plugin_type) {
|
||||
case 'plugins':
|
||||
return 'plugins/feeds_tamper';
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -137,6 +144,7 @@ function synonyms_entity_property_info() {
|
||||
'computed' => TRUE,
|
||||
'sanitized' => TRUE,
|
||||
'raw getter callback' => 'synonyms_get_raw',
|
||||
'translatable' => TRUE,
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -477,12 +485,16 @@ function synonyms_autocomplete_entity_validate($element, &$form_state) {
|
||||
$field = field_info_field($element['#field_name']);
|
||||
$instance = field_info_instance($element['#entity_type'], $field['field_name'], $element['#bundle']);
|
||||
$handler = entityreference_get_selection_handler($field, $instance);
|
||||
$matches = $handler->getReferencableEntities($input, 'IN');
|
||||
|
||||
foreach ($matches as $bundle => $entity_ids) {
|
||||
foreach ($entity_ids as $entity_id => $label) {
|
||||
$value[] = $entity_id;
|
||||
unset($input[drupal_strtolower($label)]);
|
||||
foreach ($input as $k => $v) {
|
||||
$matches = $handler->getReferencableEntities($v, '=');
|
||||
|
||||
foreach ($matches as $bundle => $entity_ids) {
|
||||
$entities = entity_load($field['settings']['target_type'], array_keys($entity_ids));
|
||||
foreach ($entity_ids as $entity_id => $label) {
|
||||
$value[] = $entity_id;
|
||||
unset($input[drupal_strtolower(entity_label($field['settings']['target_type'], $entities[$entity_id]))]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -491,7 +503,7 @@ function synonyms_autocomplete_entity_validate($element, &$form_state) {
|
||||
foreach ($behavior_implementations as $implementation) {
|
||||
$condition = db_and();
|
||||
$condition->condition(AbstractSynonymsBehavior::COLUMN_SYNONYM_PLACEHOLDER, $input, 'IN');
|
||||
foreach ($implementation['object']->synonymsFind($condition) as $synonym) {
|
||||
foreach ($implementation['object']->synonymsFind(clone $condition) as $synonym) {
|
||||
$value[] = $synonym->entity_id;
|
||||
unset($input[drupal_strtolower($synonym->synonym)]);
|
||||
if (empty($input)) {
|
||||
@ -687,11 +699,16 @@ function synonyms_get_raw($entity, array $options, $name, $entity_type, &$contex
|
||||
$bundle = entity_extract_ids($entity_type, $entity);
|
||||
$bundle = $bundle[2];
|
||||
|
||||
$langcode = NULL;
|
||||
if (isset($options['language']) && $options['language']) {
|
||||
$langcode = $options['language']->language;
|
||||
}
|
||||
|
||||
$behavior_implementations = synonyms_behavior_get_all_enabled($entity_type, $bundle);
|
||||
$providers = array();
|
||||
foreach ($behavior_implementations as $implementation) {
|
||||
if (!in_array($implementation['provider'], $providers)) {
|
||||
$synonyms = array_merge($synonyms, $implementation['object']->extractSynonyms($entity));
|
||||
$synonyms = array_merge($synonyms, $implementation['object']->extractSynonyms($entity, $langcode));
|
||||
$providers[] = $implementation['provider'];
|
||||
}
|
||||
}
|
||||
@ -742,12 +759,16 @@ function synonyms_get_term_synonyms($term) {
|
||||
*
|
||||
* @param QueryConditionInterface $condition
|
||||
* Object of QueryConditionInterface that specifies conditions by which you
|
||||
* want to find synonyms. When building this condition object, use
|
||||
* AbstractSynonymsBehavior::COLUMN_PLACEHOLDER as a placeholder for real
|
||||
* column name that contains synonym as text. For example, if you were to find
|
||||
* all entities with synonyms that begin with "synonym-come-here" substring,
|
||||
* case insensitive and replacing all spaces in original synonym string by a
|
||||
* dash sign, then you would have to create the following condition object:
|
||||
* want to find synonyms. When building this condition object, you can use
|
||||
* the following column placeholders:
|
||||
* - AbstractSynonymsBehavior::COLUMN_PLACEHOLDER: as a placeholder for real
|
||||
* column name that contains synonym as text
|
||||
* - AbstractSynonymsBehavior::COLUMN_ENTITY_ID_PLACEHOLDER: as a placeholder
|
||||
* for real column name that holds entity ID
|
||||
* For example, if you were to find all entities with synonyms that begin with
|
||||
* "synonym-come-here" substring, case insensitive and replacing all spaces
|
||||
* in original synonym string by a dash sign, then you would have to create
|
||||
* the following condition object:
|
||||
* db_and()
|
||||
* ->where("LOWER(REPLACE(" . AbstractSynonymsBehavior::COLUMN_PLACEHOLDER . ", ' ', '-')) LIKE :synonym", array(
|
||||
* ':synonym' => '%' . db_like($some-var) . '%'
|
||||
@ -772,7 +793,7 @@ function synonyms_synonyms_find(QueryConditionInterface $condition, $entity_type
|
||||
|
||||
$behavior_implementations = synonyms_behavior_get_all_enabled($entity_type, $bundle);
|
||||
foreach ($behavior_implementations as $behavior_implementation) {
|
||||
foreach ($behavior_implementation['object']->synonymsFind($condition) as $row) {
|
||||
foreach ($behavior_implementation['object']->synonymsFind(clone $condition) as $row) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
}
|
||||
|
@ -165,7 +165,9 @@ function synonyms_autocomplete_taxonomy_term($field_name, $entity_type, $bundle,
|
||||
$synonym_terms = taxonomy_term_load_multiple($synonym_terms);
|
||||
foreach ($tags_return as &$v) {
|
||||
if (isset($v['synonym'])) {
|
||||
$entity_ids = entity_extract_ids('taxonomy_term', $synonym_terms[$v['tid']]);
|
||||
$v['name'] = $synonym_terms[$v['tid']]->name;
|
||||
$v['bundle'] = $entity_ids[2];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -242,8 +244,10 @@ function synonyms_autocomplete_entity($field_name, $entity_type, $bundle, $tags_
|
||||
|
||||
$tags_typed_entity_ids = array();
|
||||
if (!empty($tags_typed)) {
|
||||
foreach ($handler->getReferencableEntities($tags_typed, 'IN') as $target_entity_ids) {
|
||||
$tags_typed_entity_ids = array_merge($tags_typed_entity_ids, array_keys($target_entity_ids));
|
||||
foreach ($tags_typed as $v) {
|
||||
foreach ($handler->getReferencableEntities($v, '=') as $target_entity_ids) {
|
||||
$tags_typed_entity_ids = array_merge($tags_typed_entity_ids, array_keys($target_entity_ids));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -251,9 +255,18 @@ function synonyms_autocomplete_entity($field_name, $entity_type, $bundle, $tags_
|
||||
if ($tag_last) {
|
||||
foreach ($handler->getReferencableEntities($tag_last) as $target_entity_ids) {
|
||||
foreach (array_diff_key($target_entity_ids, drupal_map_assoc($tags_typed_entity_ids)) as $target_id => $label) {
|
||||
// We do not use the label such as given us by
|
||||
// $handler->getReferencableEntities() because some handlers may include
|
||||
// more than just plain entity label. However, our validate handler
|
||||
// expects the exact labels in the text field. So we assure we put a
|
||||
// label there.
|
||||
// These entities have already been loaded by $handler, so we shouldn't
|
||||
// care that much performance-wise about loading them in batch.
|
||||
$entity = entity_load($field['settings']['target_type'], array($target_id));
|
||||
$entity = reset($entity);
|
||||
$matches[] = array(
|
||||
'target_id' => $target_id,
|
||||
'name' => $label,
|
||||
'name' => entity_label($field['settings']['target_type'], $entity),
|
||||
);
|
||||
if (count($matches) == $max_suggestions) {
|
||||
break (2);
|
||||
@ -306,7 +319,9 @@ function synonyms_autocomplete_entity($field_name, $entity_type, $bundle, $tags_
|
||||
foreach ($matches as $k => $match) {
|
||||
if (!isset($match['name']) && isset($match['synonym'])) {
|
||||
if (entity_access('view', $field['settings']['target_type'], $synonym_entities[$match['target_id']])) {
|
||||
$entity_ids = entity_extract_ids($field['settings']['target_type'], $synonym_entities[$match['target_id']]);
|
||||
$matches[$k]['name'] = entity_label($field['settings']['target_type'], $synonym_entities[$match['target_id']]);
|
||||
$matches[$k]['bundle'] = $entity_ids[2];
|
||||
}
|
||||
else {
|
||||
unset($matches[$k]);
|
||||
@ -332,6 +347,7 @@ function synonyms_autocomplete_entity($field_name, $entity_type, $bundle, $tags_
|
||||
* - behavior_implementation: (array) If this entry is matched through a
|
||||
* synonym, put here the behavior implementation array that provided this
|
||||
* match
|
||||
* - bundle: (string) Bundle of the entity that is suggested in this entry
|
||||
* @param string $prefix
|
||||
* Any prefix to be appended to 'name' property of $matches array when
|
||||
* inserting into the autocomplete textfield. Normally it is the already
|
||||
@ -344,6 +360,8 @@ function synonyms_autocomplete_entity($field_name, $entity_type, $bundle, $tags_
|
||||
function synonyms_autocomplete_format($matches, $prefix) {
|
||||
$output = array();
|
||||
|
||||
$entity_info = array();
|
||||
|
||||
foreach ($matches as $match) {
|
||||
$n = synonyms_autocomplete_escape($match['name']);
|
||||
while (isset($output[$prefix . $n])) {
|
||||
@ -351,10 +369,15 @@ function synonyms_autocomplete_format($matches, $prefix) {
|
||||
}
|
||||
$wording = check_plain($match['name']);
|
||||
if (isset($match['synonym'])) {
|
||||
$wording = format_string(filter_xss($match['behavior_implementation']['settings']['wording']), array(
|
||||
if (!isset($entity_info[$match['behavior_implementation']['entity_type']])) {
|
||||
$entity_info[$match['behavior_implementation']['entity_type']] = entity_get_info($match['behavior_implementation']['entity_type']);
|
||||
}
|
||||
|
||||
$wording = format_string(filter_xss_admin($match['behavior_implementation']['settings']['wording']), array(
|
||||
'@entity' => $match['name'],
|
||||
'@synonym' => $match['synonym'],
|
||||
'@field_name' => drupal_strtolower($match['behavior_implementation']['label']),
|
||||
'@bundle' => $entity_info[$match['behavior_implementation']['entity_type']]['bundles'][$match['bundle']]['label'],
|
||||
));
|
||||
}
|
||||
$output[$prefix . $n] = $wording;
|
||||
|
@ -323,6 +323,23 @@ class SynonymsSynonymsWebTestCase extends SynonymsWebTestCase {
|
||||
|
||||
$entity_id = synonyms_get_entity_by_synonym('taxonomy_term', $term_parent->{$this->fields['disabled']['field']['field_name']}[LANGUAGE_NONE][0]['value']);
|
||||
$this->assertEqual($entity_id, 0, 'synonyms_get_entity_by_synonym() returns 0 if a non-synonym field value is supplied.');
|
||||
|
||||
// Testing the function synonyms_synonyms_find().
|
||||
// Adding one more behavior implementation and making sure 2 of them work
|
||||
// as expected.
|
||||
$behavior_implementation = array(
|
||||
'entity_type' => $this->behavior_implementation['entity_type'],
|
||||
'bundle' => $this->behavior_implementation['bundle'],
|
||||
'provider' => synonyms_provider_field_provider_name($this->fields['disabled']['field']),
|
||||
'behavior' => $this->behavior_implementation['behavior'],
|
||||
'settings' => $this->behavior_implementation['settings'],
|
||||
);
|
||||
synonyms_behavior_implementation_save($behavior_implementation);
|
||||
$condition = db_and();
|
||||
$condition->condition(AbstractSynonymsBehavior::COLUMN_SYNONYM_PLACEHOLDER, $parent_synonym);
|
||||
$found_synonyms = synonyms_synonyms_find($condition, $this->behavior_implementation['entity_type'], $this->behavior_implementation['bundle']);
|
||||
$this->assertEqual(count($found_synonyms), 1, 'Function synonyms_synonyms_find() returns only 1 found synonym for the case when 2 synonym behaviors are enabled.');
|
||||
$this->assertTrue($found_synonyms[0]->synonym == $parent_synonym && $found_synonyms[0]->entity_id = $term_parent->tid, 'Function synonyms_synonyms_find() returns corret synonym information when 2 synonym behaviors are enabled.');
|
||||
}
|
||||
}
|
||||
|
||||
@ -374,7 +391,7 @@ abstract class AbstractAutocompleteSynonymsWebTestCase extends SynonymsWebTestCa
|
||||
public function setUp($modules = array()) {
|
||||
$this->behavior_implementation['behavior'] = 'autocomplete';
|
||||
$this->behavior_implementation['settings'] = array(
|
||||
'wording' => '@synonym @field_name @entity',
|
||||
'wording' => '@synonym @field_name @entity @bundle',
|
||||
);
|
||||
$modules[] = 'synonyms_provider_property';
|
||||
parent::setUp($modules);
|
||||
@ -634,10 +651,14 @@ abstract class AbstractAutocompleteSynonymsWebTestCase extends SynonymsWebTestCa
|
||||
}
|
||||
$provider = synonyms_behavior_implementation_info($behavior_implementation['entity_type'], $behavior_implementation['bundle'], $behavior_implementation['behavior']);
|
||||
$provider = $provider[$behavior_implementation['provider']];
|
||||
$entity_ids = entity_extract_ids($behavior_implementation['entity_type'], $entity);
|
||||
$entity_info = entity_get_info($behavior_implementation['entity_type']);
|
||||
|
||||
return format_string($behavior_implementation['settings']['wording'], array(
|
||||
'@synonym' => $synonym,
|
||||
'@entity' => entity_label($behavior_implementation['entity_type'], $entity),
|
||||
'@field_name' => drupal_strtolower($provider['label']),
|
||||
'@bundle' => $entity_info['bundles'][$entity_ids[2]]['label'],
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Enables Commerce Price field type for synonyms integration.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Definition of CommercePriceSynonymsBehavior class.
|
||||
*/
|
||||
class CommercePriceSynonymsBehavior extends AbstractFieldSynonymsBehavior {
|
||||
|
||||
public function extractSynonyms($entity, $langcode = NULL) {
|
||||
$synonyms = array();
|
||||
|
||||
foreach ($this->entityItems($entity, $langcode) as $item) {
|
||||
$synonyms[] = commerce_currency_format($item['amount'], $item['currency_code'], $entity);
|
||||
}
|
||||
|
||||
return $synonyms;
|
||||
}
|
||||
|
||||
public function mergeEntityAsSynonym($trunk_entity, $synonym_entity, $synonym_entity_type) {
|
||||
// TODO: remove this thing.
|
||||
}
|
||||
|
||||
public function synonymsFind(QueryConditionInterface $condition) {
|
||||
if ($this->field['storage']['type'] != 'field_sql_storage') {
|
||||
throw new SynonymsBehaviorException(t('Not supported storage engine %type in @method() method.', array(
|
||||
'%type' => $this->field['storage']['type'],
|
||||
'@method' => __METHOD__,
|
||||
)));
|
||||
}
|
||||
$table = array_keys($this->field['storage']['details']['sql'][FIELD_LOAD_CURRENT]);
|
||||
$table = reset($table);
|
||||
$columns = $this->field['storage']['details']['sql'][FIELD_LOAD_CURRENT][$table];
|
||||
|
||||
$query = db_select($table, 'field');
|
||||
|
||||
$query->fields('field', array('entity_id'));
|
||||
$query->addField('field', $columns['amount'], 'amount');
|
||||
$query->addField('field', $columns['currency_code'], 'currency_code');
|
||||
$query->condition('field.entity_type', $this->instance['entity_type']);
|
||||
$query->condition('field.bundle', $this->instance['bundle']);
|
||||
|
||||
$this->synonymsFindProcessCondition($condition, 'field.' . $columns['amount'], 'field.entity_id');
|
||||
$query->condition($condition);
|
||||
$result = $query->execute();
|
||||
|
||||
$matches = array();
|
||||
|
||||
foreach ($result as $row) {
|
||||
$matches[] = (object) array(
|
||||
'entity_id' => $row->entity_id,
|
||||
'synonym' => commerce_currency_format($row->amount, $row->currency_code),
|
||||
);
|
||||
}
|
||||
|
||||
return $matches;
|
||||
}
|
||||
}
|
@ -10,11 +10,11 @@
|
||||
*/
|
||||
class CommerceProductReferenceSynonymsBehavior extends AbstractFieldSynonymsBehavior {
|
||||
|
||||
public function extractSynonyms($entity) {
|
||||
public function extractSynonyms($entity, $langcode = NULL) {
|
||||
$synonyms = array();
|
||||
|
||||
$product_ids = array();
|
||||
foreach ($this->entityItems($entity) as $item) {
|
||||
foreach ($this->entityItems($entity, $langcode) as $item) {
|
||||
$product_ids[] = $item['product_id'];
|
||||
}
|
||||
$entities = commerce_product_load_multiple($product_ids);
|
||||
|
@ -4,16 +4,18 @@ package = Synonyms
|
||||
core = 7.x
|
||||
dependencies[] = synonyms_provider_field
|
||||
dependencies[] = commerce_product_reference
|
||||
dependencies[] = commerce_price
|
||||
|
||||
test_dependencies[] = commerce:commerce_product_ui
|
||||
|
||||
files[] = synonyms_commerce.test
|
||||
|
||||
files[] = includes/CommerceProductReferenceSynonymsBehavior.class.inc
|
||||
files[] = includes/CommercePriceSynonymsBehavior.class.inc
|
||||
|
||||
; Information added by Drupal.org packaging script on 2016-05-07
|
||||
version = "7.x-1.5"
|
||||
; Information added by Drupal.org packaging script on 2017-06-30
|
||||
version = "7.x-1.6"
|
||||
core = "7.x"
|
||||
project = "synonyms"
|
||||
datestamp = "1462586641"
|
||||
datestamp = "1498833845"
|
||||
|
||||
|
@ -154,6 +154,7 @@ function synonyms_commerce_synonyms_provider_field_behavior_implementation_info(
|
||||
case 'autocomplete':
|
||||
return array(
|
||||
'commerce_product_reference' => 'CommerceProductReferenceSynonymsBehavior',
|
||||
'commerce_price' => 'CommercePriceSynonymsBehavior',
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
@ -117,7 +117,9 @@ function synonyms_commerce_autocomplete($field_name, $entity_type, $bundle) {
|
||||
$synonym_entities = commerce_product_load_multiple($synonym_entities);
|
||||
foreach ($matches as $k => $match) {
|
||||
if (!isset($match['name']) && isset($match['synonym'])) {
|
||||
$entity_ids = entity_extract_ids('commerce_product', $synonym_entities[$match['target_id']]);
|
||||
$matches[$k]['name'] = entity_label('commerce_product', $synonym_entities[$match['target_id']]);
|
||||
$matches[$k]['bundle'] = $entity_ids[2];
|
||||
}
|
||||
}
|
||||
$matches = array_values($matches);
|
||||
|
@ -847,3 +847,248 @@ class CommerceProductReferenceSynonymsBehaviorWebTestCase extends AbstractSynony
|
||||
return $entity;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test CommercePriceSynonymsBehavior class.
|
||||
*/
|
||||
class CommercePriceSynonymsBehaviorWebTestCase extends AbstractSynonymsProviderFieldWebTestCase {
|
||||
|
||||
/**
|
||||
* GetInfo method.
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'CommercePriceSynonymsBehavior',
|
||||
'description' => 'Ensure that the synonyms module extracts synonyms from commerce price fields correctly.',
|
||||
'group' => 'Synonyms',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* SetUp method.
|
||||
*/
|
||||
public function setUp($modules = array()) {
|
||||
$modules[] = 'commerce_price';
|
||||
$modules[] = 'commerce_product_reference';
|
||||
$modules[] = 'commerce_product_ui';
|
||||
$modules[] = 'synonyms_commerce';
|
||||
|
||||
$this->fields['enabled']['field'] = array(
|
||||
'field_name' => 'synonyms_commerce_price',
|
||||
'cardinality' => FIELD_CARDINALITY_UNLIMITED,
|
||||
'type' => 'commerce_price',
|
||||
);
|
||||
|
||||
parent::setUp($modules);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test synonyms extraction for 'commerce_price' field type.
|
||||
*/
|
||||
public function testCommercePrice() {
|
||||
// Testing synonymsExtract().
|
||||
$this->assertSynonymsExtract(array(), array(), 'on empty field.');
|
||||
|
||||
$this->assertSynonymsExtract(array(
|
||||
LANGUAGE_NONE => array(
|
||||
0 => array(
|
||||
'amount' => 1000,
|
||||
'currency_code' => 'USD',
|
||||
),
|
||||
),
|
||||
), array(commerce_currency_format(1000, 'USD')), 'on a field that holds one value.');
|
||||
|
||||
// Testing synonymFind() method.
|
||||
$this->assertSynonymsFind(array(), db_and()->condition(AbstractSynonymsBehavior::COLUMN_SYNONYM_PLACEHOLDER, $this->randomName()), 'on empty field');
|
||||
|
||||
$meta_data = array();
|
||||
$meta_data[] = array(
|
||||
'items' => array(),
|
||||
'found_synonyms' => array(),
|
||||
);
|
||||
$this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsBehavior::COLUMN_SYNONYM_PLACEHOLDER, $this->randomName()), 'on a field without values');
|
||||
|
||||
$meta_data = array();
|
||||
$meta_data[] = array(
|
||||
'items' => array(
|
||||
LANGUAGE_NONE => array(
|
||||
array(
|
||||
'amount' => 1000,
|
||||
'currency_code' => 'USD',
|
||||
),
|
||||
),
|
||||
),
|
||||
'found_synonyms' => array(),
|
||||
);
|
||||
$this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsBehavior::COLUMN_SYNONYM_PLACEHOLDER, $this->randomName()), 'on a field with a value but searching for another string');
|
||||
|
||||
$meta_data = array();
|
||||
$meta_data[] = array(
|
||||
'items' => array(
|
||||
LANGUAGE_NONE => array(
|
||||
array(
|
||||
'amount' => 1000,
|
||||
'currency_code' => 'USD',
|
||||
),
|
||||
),
|
||||
),
|
||||
'found_synonyms' => array(commerce_currency_format(1000, 'USD')),
|
||||
);
|
||||
$this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsBehavior::COLUMN_SYNONYM_PLACEHOLDER, 1000), 'on a field with a single value searching for that string');
|
||||
|
||||
$meta_data = array();
|
||||
$meta_data[] = array(
|
||||
'items' => array(
|
||||
LANGUAGE_NONE => array(
|
||||
array(
|
||||
'amount' => 1000,
|
||||
'currency_code' => 'USD',
|
||||
),
|
||||
array(
|
||||
'amount' => 2000,
|
||||
'currency_code' => 'USD',
|
||||
),
|
||||
),
|
||||
),
|
||||
'found_synonyms' => array(commerce_currency_format(1000, 'USD')),
|
||||
);
|
||||
$this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsBehavior::COLUMN_SYNONYM_PLACEHOLDER, 1000), 'on a field with 2 values searching for one of those 2 values');
|
||||
|
||||
$meta_data = array();
|
||||
$meta_data[] = array(
|
||||
'items' => array(
|
||||
LANGUAGE_NONE => array(
|
||||
array(
|
||||
'amount' => 1000,
|
||||
'currency_code' => 'USD',
|
||||
),
|
||||
array(
|
||||
'amount' => 2000,
|
||||
'currency_code' => 'USD',
|
||||
),
|
||||
),
|
||||
),
|
||||
'found_synonyms' => array(commerce_currency_format(1000, 'USD')),
|
||||
);
|
||||
$meta_data[] = array(
|
||||
'items' => array(
|
||||
LANGUAGE_NONE => array(
|
||||
array(
|
||||
'amount' => 100,
|
||||
'currency_code' => 'USD',
|
||||
),
|
||||
array(
|
||||
'amount' => 200,
|
||||
'currency_code' => 'USD',
|
||||
),
|
||||
),
|
||||
),
|
||||
'found_synonyms' => array(),
|
||||
);
|
||||
$this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsBehavior::COLUMN_SYNONYM_PLACEHOLDER, 1000), 'on 2 fields with 2 values each searching for one of those values');
|
||||
|
||||
$meta_data = array();
|
||||
$meta_data[] = array(
|
||||
'items' => array(
|
||||
LANGUAGE_NONE => array(
|
||||
array(
|
||||
'amount' => 1000,
|
||||
'currency_code' => 'USD',
|
||||
),
|
||||
),
|
||||
),
|
||||
'found_synonyms' => array(commerce_currency_format(1000, 'USD')),
|
||||
);
|
||||
$this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsBehavior::COLUMN_SYNONYM_PLACEHOLDER, '%' . db_like(10) . '%', 'LIKE'), 'on a field with a value searching for a string LIKE the %value%');
|
||||
|
||||
$meta_data = array();
|
||||
$meta_data[] = array(
|
||||
'items' => array(
|
||||
LANGUAGE_NONE => array(
|
||||
array(
|
||||
'amount' => 1000,
|
||||
'currency_code' => 'USD',
|
||||
),
|
||||
array(
|
||||
'amount' => 100,
|
||||
'currency_code' => 'USD',
|
||||
),
|
||||
),
|
||||
),
|
||||
'found_synonyms' => array(
|
||||
commerce_currency_format(1000, 'USD'),
|
||||
commerce_currency_format(100, 'USD'),
|
||||
),
|
||||
);
|
||||
$this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsBehavior::COLUMN_SYNONYM_PLACEHOLDER, db_like(100) . '%', 'LIKE'), 'on a field with 2 similar values searching a string like %both values%');
|
||||
|
||||
$meta_data = array();
|
||||
$meta_data[] = array(
|
||||
'items' => array(
|
||||
LANGUAGE_NONE => array(
|
||||
array(
|
||||
'amount' => 1000,
|
||||
'currency_code' => 'USD',
|
||||
),
|
||||
array(
|
||||
'amount' => 2000,
|
||||
'currency_code' => 'USD',
|
||||
),
|
||||
),
|
||||
),
|
||||
'found_synonyms' => array(
|
||||
commerce_currency_format(1000, 'USD'),
|
||||
commerce_currency_format(2000, 'USD'),
|
||||
),
|
||||
);
|
||||
$condition = db_or()
|
||||
->condition(AbstractSynonymsBehavior::COLUMN_SYNONYM_PLACEHOLDER, 1000)
|
||||
->condition(AbstractSynonymsBehavior::COLUMN_SYNONYM_PLACEHOLDER, 2000);
|
||||
$this->assertSynonymsFind($meta_data, $condition, 'on a field with 2 values searching for value1 or value2');
|
||||
|
||||
$meta_data = array();
|
||||
$meta_data[] = array(
|
||||
'items' => array(
|
||||
LANGUAGE_NONE => array(
|
||||
array(
|
||||
'amount' => 1000,
|
||||
'currency_code' => 'USD',
|
||||
),
|
||||
array(
|
||||
'amount' => 2000,
|
||||
'currency_code' => 'USD',
|
||||
),
|
||||
),
|
||||
),
|
||||
'found_synonyms' => array(commerce_currency_format(1000, 'USD')),
|
||||
);
|
||||
$condition = db_and()
|
||||
->condition(AbstractSynonymsBehavior::COLUMN_SYNONYM_PLACEHOLDER, 1000)
|
||||
->condition(AbstractSynonymsBehavior::COLUMN_SYNONYM_PLACEHOLDER, '%' . db_like(10) . '%', 'LIKE');
|
||||
$this->assertSynonymsFind($meta_data, $condition, 'on a field with 2 values searching for value1 and LIKE value1%');
|
||||
|
||||
$meta_data = array();
|
||||
$meta_data[] = array(
|
||||
'items' => array(
|
||||
LANGUAGE_NONE => array(
|
||||
array(
|
||||
'amount' => 1000,
|
||||
'currency_code' => 'USD',
|
||||
),
|
||||
array(
|
||||
'amount' => 2000,
|
||||
'currency_code' => 'USD',
|
||||
),
|
||||
),
|
||||
),
|
||||
'found_synonyms' => array(
|
||||
commerce_currency_format(1000, 'USD'),
|
||||
commerce_currency_format(2000, 'USD'),
|
||||
),
|
||||
);
|
||||
$condition = db_or()
|
||||
->condition(AbstractSynonymsBehavior::COLUMN_SYNONYM_PLACEHOLDER, 1000)
|
||||
->condition(db_and()->condition(AbstractSynonymsBehavior::COLUMN_SYNONYM_PLACEHOLDER, 2000)->condition(AbstractSynonymsBehavior::COLUMN_SYNONYM_PLACEHOLDER, '%' . db_like(20) . '%', 'LIKE'));
|
||||
$this->assertSynonymsFind($meta_data, $condition, 'on a field with 2 values searching for (value1 or (value2 AND value2%))');
|
||||
}
|
||||
}
|
||||
|
@ -45,13 +45,16 @@ abstract class AbstractFieldSynonymsBehavior extends AbstractSynonymsBehavior {
|
||||
*
|
||||
* @param object $entity
|
||||
* Entity whose items should be retrieved
|
||||
* @param string $langcode
|
||||
* Language code for which to retrieve items from the entity, if one is
|
||||
* known
|
||||
*
|
||||
* @return array
|
||||
* Array of items that provided entity has in the field on which behavior
|
||||
* implementation is set up
|
||||
*/
|
||||
protected function entityItems($entity) {
|
||||
$items = field_get_items($this->instance['entity_type'], $entity, $this->field['field_name']);
|
||||
protected function entityItems($entity, $langcode = NULL) {
|
||||
$items = field_get_items($this->instance['entity_type'], $entity, $this->field['field_name'], $langcode);
|
||||
return is_array($items) ? $items : array();
|
||||
}
|
||||
|
||||
|
@ -10,11 +10,11 @@
|
||||
*/
|
||||
class EntityReferenceSynonymsBehavior extends AbstractFieldSynonymsBehavior implements AutocompleteSynonymsBehavior, SelectSynonymsBehavior {
|
||||
|
||||
public function extractSynonyms($entity) {
|
||||
public function extractSynonyms($entity, $langcode = NULL) {
|
||||
$synonyms = array();
|
||||
|
||||
$target_tids = array();
|
||||
foreach ($this->entityItems($entity) as $item) {
|
||||
foreach ($this->entityItems($entity, $langcode) as $item) {
|
||||
$target_tids[] = $item['target_id'];
|
||||
}
|
||||
$entities = entity_load($this->field['settings']['target_type'], $target_tids);
|
||||
|
@ -10,11 +10,11 @@
|
||||
*/
|
||||
class TaxonomySynonymsBehavior extends AbstractFieldSynonymsBehavior implements AutocompleteSynonymsBehavior, SelectSynonymsBehavior {
|
||||
|
||||
public function extractSynonyms($entity) {
|
||||
public function extractSynonyms($entity, $langcode = NULL) {
|
||||
$synonyms = array();
|
||||
|
||||
$terms = array();
|
||||
foreach ($this->entityItems($entity) as $item) {
|
||||
foreach ($this->entityItems($entity, $langcode) as $item) {
|
||||
$terms[] = $item['tid'];
|
||||
}
|
||||
$terms = taxonomy_term_load_multiple($terms);
|
||||
|
@ -10,10 +10,10 @@
|
||||
*/
|
||||
class TextSynonymsBehavior extends AbstractFieldSynonymsBehavior implements AutocompleteSynonymsBehavior, SelectSynonymsBehavior {
|
||||
|
||||
public function extractSynonyms($entity) {
|
||||
public function extractSynonyms($entity, $langcode = NULL) {
|
||||
$synonyms = array();
|
||||
|
||||
foreach ($this->entityItems($entity) as $item) {
|
||||
foreach ($this->entityItems($entity, $langcode) as $item) {
|
||||
$synonyms[] = $item['value'];
|
||||
}
|
||||
|
||||
|
@ -12,9 +12,9 @@ files[] = includes/TextSynonymsBehavior.class.inc
|
||||
|
||||
files[] = synonyms_provider_field.test
|
||||
|
||||
; Information added by Drupal.org packaging script on 2016-05-07
|
||||
version = "7.x-1.5"
|
||||
; Information added by Drupal.org packaging script on 2017-06-30
|
||||
version = "7.x-1.6"
|
||||
core = "7.x"
|
||||
project = "synonyms"
|
||||
datestamp = "1462586641"
|
||||
datestamp = "1498833845"
|
||||
|
||||
|
@ -31,7 +31,7 @@ class AbstractPropertySynonymsBehavior extends AbstractSynonymsBehavior implemen
|
||||
$this->entity_info = entity_get_info($this->behavior_implementation['entity_type']);
|
||||
}
|
||||
|
||||
public function extractSynonyms($entity) {
|
||||
public function extractSynonyms($entity, $langcode = NULL) {
|
||||
$synonyms = array();
|
||||
|
||||
if (isset($entity->{$this->property}) && $entity->{$this->property}) {
|
||||
|
@ -10,9 +10,9 @@ files[] = includes/SearchPropertySynonymsBehavior.class.inc
|
||||
|
||||
files[] = synonyms_provider_property.test
|
||||
|
||||
; Information added by Drupal.org packaging script on 2016-05-07
|
||||
version = "7.x-1.5"
|
||||
; Information added by Drupal.org packaging script on 2017-06-30
|
||||
version = "7.x-1.6"
|
||||
core = "7.x"
|
||||
project = "synonyms"
|
||||
datestamp = "1462586641"
|
||||
datestamp = "1498833845"
|
||||
|
||||
|
@ -17,9 +17,9 @@ files[] = includes/SearchTaxonomySynonymsBehavior.class.inc
|
||||
files[] = includes/SearchEntityReferenceSynonymsBehavior.class.inc
|
||||
files[] = includes/SearchCommerceProductReferenceSynonymsBehavior.class.inc
|
||||
|
||||
; Information added by Drupal.org packaging script on 2016-05-07
|
||||
version = "7.x-1.5"
|
||||
; Information added by Drupal.org packaging script on 2017-06-30
|
||||
version = "7.x-1.6"
|
||||
core = "7.x"
|
||||
project = "synonyms"
|
||||
datestamp = "1462586641"
|
||||
datestamp = "1498833845"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user