synonyms.pages.inc 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. <?php
  2. /**
  3. * @file
  4. * Menu page callbacks of Synonyms module.
  5. */
  6. /**
  7. * Page callback: Outputs JSON for taxonomy autocomplete suggestions.
  8. *
  9. * This callback outputs term name suggestions in response to Ajax requests
  10. * made by the synonyms autocomplete widget for taxonomy term reference
  11. * fields. The output is a JSON object of plain-text term suggestions,
  12. * keyed by the user-entered value with the completed term name appended.
  13. * Term names containing commas are wrapped in quotes. The search is made
  14. * with consideration of synonyms.
  15. *
  16. * @param string $field_name
  17. * The name of the term reference field.
  18. * @param string $entity_type
  19. * Entity type to which the supplied $field_name is attached to
  20. * @param string $bundle
  21. * Bundle name to which the supplied $field_name is attached to
  22. * @param string $tags_typed
  23. * (optional) A comma-separated list of term names entered in the
  24. * autocomplete form element. Only the last term is used for autocompletion.
  25. * Defaults to '' (an empty string).
  26. */
  27. function synonyms_autocomplete_taxonomy_term($field_name, $entity_type, $bundle, $tags_typed = '') {
  28. // If the request has a '/' in the search text, then the menu system will have
  29. // split it into multiple arguments, recover the intended $tags_typed.
  30. $args = func_get_args();
  31. // Shift off the $field_name argument.
  32. array_shift($args);
  33. // Shift off the $entity_type argument.
  34. array_shift($args);
  35. // Shift off the $bundle argument.
  36. array_shift($args);
  37. $tags_typed = implode('/', $args);
  38. // Make sure the field exists and is a taxonomy field.
  39. if (!($field = field_info_field($field_name)) || $field['type'] != 'taxonomy_term_reference') {
  40. // Error string. The JavaScript handler will realize this is not JSON and
  41. // will display it as debugging information.
  42. print t('Taxonomy field @field_name not found.', array('@field_name' => $field_name));
  43. exit;
  44. }
  45. if (!($instance = field_info_instance($entity_type, $field['field_name'], $bundle))) {
  46. // Error string. The JavaScript handler will realize this is not JSON and
  47. // will display it as debugging information.
  48. print t('There was not found an instance of @field_name in @entity_type.', array(
  49. '@field_name' => $field_name,
  50. '@entity_type' => $entity_type,
  51. ));
  52. exit;
  53. }
  54. $widget = $instance['widget']['type'] == 'synonyms_autocomplete_taxonomy_term' ? $instance['widget']['settings'] : field_info_widget_settings('synonyms_autocomplete_taxonomy_term');
  55. // How many suggestions maximum we are able to output.
  56. $max_suggestions = $widget['suggestion_size'];
  57. // Whether we are allowed to suggest more than one entry per term, shall that
  58. // entry be either term name itself or one of its synonyms.
  59. $suggest_only_unique = $widget['suggest_only_unique'];
  60. // The user enters a comma-separated list of tags. We only autocomplete the
  61. // last tag.
  62. $tags_typed = drupal_explode_tags($tags_typed);
  63. $tag_last = drupal_strtolower(array_pop($tags_typed));
  64. $tags_typed_tids = array();
  65. if (!empty($tags_typed)) {
  66. $efq = new EntityFieldQuery();
  67. $efq->entityCondition('entity_type', 'taxonomy_term');
  68. $efq->propertyCondition('name', $tags_typed);
  69. $tags_typed_tids = $efq->execute();
  70. if (isset($tags_typed_tids['taxonomy_term'])) {
  71. $tags_typed_tids = array_keys($tags_typed_tids['taxonomy_term']);
  72. }
  73. }
  74. // Array of found suggestions. Each subarray of this array will represent a
  75. // single suggestion entry.
  76. // - tid: (int) tid of the suggested term
  77. // - name: (string) name of the suggested term
  78. // - synonym: (string) optional synonym string that matched this entry
  79. // - behavior_implementation: (array) optional behavior implementation that
  80. // provided the synonym
  81. $tags_return = array();
  82. if ($tag_last != '') {
  83. // Part of the criteria for the query come from the field's own settings.
  84. $vocabularies = array();
  85. $tmp = taxonomy_vocabulary_get_names();
  86. foreach ($field['settings']['allowed_values'] as $tree) {
  87. $vocabularies[$tmp[$tree['vocabulary']]->vid] = $tree['vocabulary'];
  88. }
  89. $vocabularies = taxonomy_vocabulary_load_multiple(array_keys($vocabularies));
  90. // Firstly getting a list of tids that match by $term->name.
  91. $query = db_select('taxonomy_term_data', 't');
  92. $query->addTag('translatable');
  93. $query->addTag('term_access');
  94. // Do not select already entered terms.
  95. if (!empty($tags_typed_tids)) {
  96. $query->condition('t.tid', $tags_typed_tids, 'NOT IN');
  97. }
  98. // Select rows that match by term name.
  99. $result = $query
  100. ->fields('t', array('tid', 'name'))
  101. ->condition('t.vid', array_keys($vocabularies))
  102. ->condition('t.name', '%' . db_like($tag_last) . '%', 'LIKE')
  103. ->range(0, $max_suggestions)
  104. ->execute();
  105. foreach ($result as $v) {
  106. $tags_return[] = (array) $v;
  107. }
  108. // Now we go vocabulary by vocabulary looking through synonym fields.
  109. foreach ($vocabularies as $vocabulary) {
  110. // Now we go a synonym field by synonym field gathering suggestions.
  111. $bundle = field_extract_bundle('taxonomy_term', $vocabulary);
  112. $behavior_implementations = synonyms_behavior_get('autocomplete', 'taxonomy_term', $bundle, TRUE);
  113. foreach ($behavior_implementations as $implementation) {
  114. $condition = db_and();
  115. $condition->condition(AbstractSynonymsBehavior::COLUMN_SYNONYM_PLACEHOLDER, '%' . db_like($tag_last) . '%', 'LIKE');
  116. if (!empty($tags_typed_tids)) {
  117. $condition->condition(AbstractSynonymsBehavior::COLUMN_ENTITY_ID_PLACEHOLDER, $tags_typed_tids, 'NOT IN');
  118. }
  119. if ($suggest_only_unique && !empty($tags_return)) {
  120. $tmp = array();
  121. foreach ($tags_return as $tag_return) {
  122. $tmp[] = $tag_return['tid'];
  123. }
  124. $condition->condition(AbstractSynonymsBehavior::COLUMN_ENTITY_ID_PLACEHOLDER, $tmp, 'NOT IN');
  125. }
  126. $new_tids = array();
  127. foreach ($implementation['object']->synonymsFind($condition) as $synonym) {
  128. if (!$suggest_only_unique || !in_array($synonym->entity_id, $new_tids)) {
  129. $tags_return[] = array(
  130. 'tid' => $synonym->entity_id,
  131. 'name' => '',
  132. 'synonym' => $synonym->synonym,
  133. 'behavior_implementation' => $implementation,
  134. );
  135. $new_tids[] = $synonym->entity_id;
  136. }
  137. }
  138. }
  139. }
  140. $synonym_terms = array();
  141. foreach ($tags_return as $v) {
  142. if (isset($v['synonym'])) {
  143. $synonym_terms[] = $v['tid'];
  144. }
  145. }
  146. if (!empty($synonym_terms)) {
  147. $synonym_terms = taxonomy_term_load_multiple($synonym_terms);
  148. foreach ($tags_return as &$v) {
  149. if (isset($v['synonym'])) {
  150. $entity_ids = entity_extract_ids('taxonomy_term', $synonym_terms[$v['tid']]);
  151. $v['name'] = $synonym_terms[$v['tid']]->name;
  152. $v['bundle'] = $entity_ids[2];
  153. }
  154. }
  155. }
  156. if (count($tags_return) > $max_suggestions) {
  157. $tags_return = array_slice($tags_return, 0, $max_suggestions);
  158. }
  159. }
  160. $prefix = empty($tags_typed) ? '' : drupal_implode_tags($tags_typed) . ', ';
  161. drupal_json_output(synonyms_autocomplete_format($tags_return, $prefix));
  162. }
  163. /**
  164. * Page callback: Outputs JSON for entity autocomplete suggestions.
  165. *
  166. * This callback outputs entity name suggestions in response to Ajax requests
  167. * made by the synonyms autocomplete widget for entity reference fields. The
  168. * output is a JSON object of plain-text entity suggestions, keyed by the
  169. * user-entered value with the completed entity name appended. Entity names
  170. * containing commas are wrapped in quotes. The search is made with
  171. * consideration of synonyms.
  172. *
  173. * @param string $field_name
  174. * The name of the entity reference field.
  175. * @param string $entity_type
  176. * Entity type to which the supplied $field_name is attached to
  177. * @param string $bundle
  178. * Bundle name to which the supplied $field_name is attached to
  179. * @param string $tags_typed
  180. * (optional) A comma-separated list of entity names entered in the
  181. * autocomplete form element. Only the last term is used for autocompletion.
  182. * Defaults to '' (an empty string).
  183. */
  184. function synonyms_autocomplete_entity($field_name, $entity_type, $bundle, $tags_typed = '') {
  185. // If the request has a '/' in the search text, then the menu system will have
  186. // split it into multiple arguments, recover the intended $tags_typed.
  187. $args = func_get_args();
  188. // Shift off the $field_name argument.
  189. array_shift($args);
  190. // Shift off the $entity_type argument.
  191. array_shift($args);
  192. // Shift off the $bundle argument.
  193. array_shift($args);
  194. $tags_typed = implode('/', $args);
  195. if (!($field = field_info_field($field_name)) || $field['type'] != 'entityreference') {
  196. print t('Entity reference field @field_name not found.', array('@field_name' => $field_name));
  197. exit;
  198. }
  199. if (!($instance = field_info_instance($entity_type, $field['field_name'], $bundle))) {
  200. // Error string. The JavaScript handler will realize this is not JSON and
  201. // will display it as debugging information.
  202. print t('There was not found an instance of @field_name in @entity_type.', array(
  203. '@field_name' => $field_name,
  204. '@entity_type' => $entity_type,
  205. ));
  206. exit;
  207. }
  208. $widget = $instance['widget']['type'] == 'synonyms_autocomplete_entity' ? $instance['widget']['settings'] : field_info_widget_settings('synonyms_autocomplete_entity');
  209. // How many suggestions maximum we are able to output.
  210. $max_suggestions = $widget['suggestion_size'];
  211. // Whether we are allowed to suggest more than one entry per term, shall that
  212. // entry be either term name itself or one of its synonyms.
  213. $suggest_only_unique = $widget['suggest_only_unique'];
  214. $tags_typed = drupal_explode_tags($tags_typed);
  215. $tag_last = drupal_strtolower(array_pop($tags_typed));
  216. $prefix = count($tags_typed) ? drupal_implode_tags($tags_typed) . ', ' : '';
  217. $handler = entityreference_get_selection_handler($field, $instance, $entity_type, NULL);
  218. $tags_typed_entity_ids = array();
  219. if (!empty($tags_typed)) {
  220. foreach ($tags_typed as $v) {
  221. foreach ($handler->getReferencableEntities($v, '=') as $target_entity_ids) {
  222. $tags_typed_entity_ids = array_merge($tags_typed_entity_ids, array_keys($target_entity_ids));
  223. }
  224. }
  225. }
  226. $matches = array();
  227. if ($tag_last) {
  228. foreach ($handler->getReferencableEntities($tag_last) as $target_entity_ids) {
  229. foreach (array_diff_key($target_entity_ids, drupal_map_assoc($tags_typed_entity_ids)) as $target_id => $label) {
  230. // We do not use the label such as given us by
  231. // $handler->getReferencableEntities() because some handlers may include
  232. // more than just plain entity label. However, our validate handler
  233. // expects the exact labels in the text field. So we assure we put a
  234. // label there.
  235. // These entities have already been loaded by $handler, so we shouldn't
  236. // care that much performance-wise about loading them in batch.
  237. $entity = entity_load($field['settings']['target_type'], array($target_id));
  238. $entity = reset($entity);
  239. $matches[] = array(
  240. 'target_id' => $target_id,
  241. 'name' => entity_label($field['settings']['target_type'], $entity),
  242. );
  243. if (count($matches) == $max_suggestions) {
  244. break (2);
  245. }
  246. }
  247. }
  248. if (count($matches) < $max_suggestions) {
  249. $behavior_implementations = synonyms_behavior_get('autocomplete', $field['settings']['target_type'], synonyms_field_target_bundles($field), TRUE);
  250. foreach ($behavior_implementations as $implementation) {
  251. $condition = db_and();
  252. $condition->condition(AbstractSynonymsBehavior::COLUMN_SYNONYM_PLACEHOLDER, '%' . db_like($tag_last) . '%', 'LIKE');
  253. if (!empty($tags_typed_entity_ids)) {
  254. $condition->condition(AbstractSynonymsBehavior::COLUMN_ENTITY_ID_PLACEHOLDER, $tags_typed_entity_ids, 'NOT IN');
  255. }
  256. if ($suggest_only_unique && !empty($matches)) {
  257. $tmp = array();
  258. foreach ($matches as $match) {
  259. $tmp[] = $match['target_id'];
  260. }
  261. $condition->condition(AbstractSynonymsBehavior::COLUMN_ENTITY_ID_PLACEHOLDER, $tmp, 'NOT IN');
  262. }
  263. $new_target_ids = array();
  264. foreach ($implementation['object']->synonymsFind($condition) as $synonym) {
  265. if (!$suggest_only_unique || !in_array($synonym->entity_id, $new_target_ids)) {
  266. $matches[] = array(
  267. 'target_id' => $synonym->entity_id,
  268. 'synonym' => $synonym->synonym,
  269. 'behavior_implementation' => $implementation,
  270. );
  271. $new_target_ids[] = $synonym->entity_id;
  272. if (count($matches) == $max_suggestions) {
  273. break (2);
  274. }
  275. }
  276. }
  277. }
  278. }
  279. $synonym_entities = array();
  280. foreach ($matches as $match) {
  281. if (!isset($match['wording']) && isset($match['synonym'])) {
  282. $synonym_entities[] = $match['target_id'];
  283. }
  284. }
  285. if (!empty($synonym_entities)) {
  286. $synonym_entities = entity_load($field['settings']['target_type'], $synonym_entities);
  287. foreach ($matches as $k => $match) {
  288. if (!isset($match['name']) && isset($match['synonym'])) {
  289. if (entity_access('view', $field['settings']['target_type'], $synonym_entities[$match['target_id']])) {
  290. $entity_ids = entity_extract_ids($field['settings']['target_type'], $synonym_entities[$match['target_id']]);
  291. $matches[$k]['name'] = entity_label($field['settings']['target_type'], $synonym_entities[$match['target_id']]);
  292. $matches[$k]['bundle'] = $entity_ids[2];
  293. }
  294. else {
  295. unset($matches[$k]);
  296. }
  297. }
  298. }
  299. $matches = array_values($matches);
  300. }
  301. }
  302. drupal_json_output(synonyms_autocomplete_format($matches, $prefix));
  303. }
  304. /**
  305. * Supportive function to format autocomplete suggestions.
  306. *
  307. * @param array $matches
  308. * Array of matched entries. It should follow this structure:
  309. * - name: (string) String to be inserted into autocomplete textfield if user
  310. * chooses this autocomplete entry
  311. * - synonym: (string) If this entry is matched through a synonym, put that
  312. * synonym here
  313. * - behavior_implementation: (array) If this entry is matched through a
  314. * synonym, put here the behavior implementation array that provided this
  315. * match
  316. * - bundle: (string) Bundle of the entity that is suggested in this entry
  317. * @param string $prefix
  318. * Any prefix to be appended to 'name' property of $matches array when
  319. * inserting into the autocomplete textfield. Normally it is the already
  320. * entered entries in the textfield
  321. *
  322. * @return array
  323. * Array of formatted autocomplete response entries ready to be returned to
  324. * the autocomplete JavaScript
  325. */
  326. function synonyms_autocomplete_format($matches, $prefix) {
  327. $output = array();
  328. $entity_info = array();
  329. foreach ($matches as $match) {
  330. $n = synonyms_autocomplete_escape($match['name']);
  331. while (isset($output[$prefix . $n])) {
  332. $n .= ' ';
  333. }
  334. $wording = check_plain($match['name']);
  335. if (isset($match['synonym'])) {
  336. if (!isset($entity_info[$match['behavior_implementation']['entity_type']])) {
  337. $entity_info[$match['behavior_implementation']['entity_type']] = entity_get_info($match['behavior_implementation']['entity_type']);
  338. }
  339. $wording = format_string(filter_xss_admin($match['behavior_implementation']['settings']['wording']), array(
  340. '@entity' => $match['name'],
  341. '@synonym' => $match['synonym'],
  342. '@field_name' => drupal_strtolower($match['behavior_implementation']['label']),
  343. '@bundle' => $entity_info[$match['behavior_implementation']['entity_type']]['bundles'][$match['bundle']]['label'],
  344. ));
  345. }
  346. $output[$prefix . $n] = $wording;
  347. }
  348. return $output;
  349. }
  350. /**
  351. * Default theme implementation for behavior settings form element.
  352. */
  353. function theme_synonyms_behaviors_settings($variables) {
  354. drupal_add_css(drupal_get_path('module', 'synonyms') . '/synonyms.css');
  355. $element = &$variables['element'];
  356. $table = array(
  357. 'header' => array(t('Field')),
  358. 'rows' => array(),
  359. 'empty' => t('Seems like there are no fields for which synonyms functionality available. Try adding a text field to get started.'),
  360. );
  361. $instance_ids = array();
  362. foreach (element_children($element) as $behavior) {
  363. $table['header'][] = check_plain($element[$behavior]['#title']);
  364. $instance_ids = array_unique(array_merge($instance_ids, element_children($element[$behavior])));
  365. }
  366. foreach ($instance_ids as $instance_id) {
  367. $row = array();
  368. $row_title = '';
  369. foreach (element_children($element) as $behavior) {
  370. if (isset($element[$behavior][$instance_id]['#title']) && !$row_title) {
  371. $row_title = check_plain($element[$behavior][$instance_id]['#title']);
  372. }
  373. $row[] = array(
  374. 'data' => isset($element[$behavior][$instance_id]) ? drupal_render($element[$behavior][$instance_id]) : t('Not implemented'),
  375. 'class' => array('synonyms-behavior-settings', 'synonyms-behavior-settings-' . $behavior),
  376. );
  377. }
  378. array_unshift($row, $row_title);
  379. $table['rows'][] = $row;
  380. }
  381. return '<div id="' . $element['#id'] . '">' . theme('table', $table) . drupal_render_children($element) . '</div>';
  382. }
  383. /**
  384. * Page menu callback for managing Synonyms settings of entity types.
  385. */
  386. function synonyms_settings_overview() {
  387. $output = array();
  388. $output['table'] = array(
  389. '#theme' => 'table',
  390. '#header' => array(t('Entity type'), t('Bundle'), t('Manage')),
  391. '#rows' => array(),
  392. );
  393. foreach (entity_get_info() as $entity_type => $entity_info) {
  394. if (synonyms_entity_type_load($entity_type)) {
  395. foreach ($entity_info['bundles'] as $bundle => $bundle_info) {
  396. $output['table']['#rows'][] = array(
  397. $entity_info['label'],
  398. $bundle == $entity_type ? '' : $bundle_info['label'],
  399. l(t('Edit'), 'admin/structure/synonyms/' . $entity_type . '/' . $bundle),
  400. );
  401. }
  402. }
  403. }
  404. return $output;
  405. }
  406. /**
  407. * Synonyms settings form for a specific entity type and bundle name.
  408. *
  409. * @param string $entity_type
  410. * Entity type for which to generate synonyms settings form
  411. * @param string $bundle
  412. * Bundle name for which to generate synonyms settings form
  413. */
  414. function synonyms_settings_form($form, &$form_state, $entity_type, $bundle) {
  415. $form['settings'] = array(
  416. '#tree' => TRUE,
  417. '#theme' => 'synonyms_behaviors_settings',
  418. '#id' => 'synonyms-behaviors-settings-wrapper',
  419. '#entity_type' => $entity_type,
  420. '#bundle' => $bundle,
  421. );
  422. $behaviors = synonyms_behaviors();
  423. foreach ($behaviors as $behavior => $behavior_info) {
  424. $form['settings'][$behavior] = array(
  425. '#title' => $behavior_info['title'],
  426. );
  427. $behavior_implementations = synonyms_behavior_get($behavior, $entity_type, $bundle);
  428. foreach ($behavior_implementations as $implementation) {
  429. $form['settings'][$behavior][$implementation['provider']]['#title'] = $implementation['label'];
  430. if (isset($form_state['values']['settings'][$behavior][$implementation['provider']])) {
  431. $behavior_settings = (bool) $form_state['values']['settings'][$behavior][$implementation['provider']]['enabled'];
  432. }
  433. else {
  434. $behavior_settings = isset($implementation['settings']);
  435. }
  436. if ($behavior_settings) {
  437. if (isset($form_state['values']['settings'][$behavior][$implementation['provider']]['settings'])) {
  438. $behavior_settings = $form_state['values']['settings'][$behavior][$implementation['provider']]['settings'];
  439. }
  440. elseif (isset($implementation['settings'])) {
  441. $behavior_settings = $implementation['settings'];
  442. }
  443. else {
  444. $behavior_settings = array();
  445. }
  446. }
  447. $form['settings'][$behavior][$implementation['provider']]['enabled'] = array(
  448. '#type' => 'checkbox',
  449. '#title' => t('Enable'),
  450. '#default_value' => $behavior_settings !== FALSE,
  451. );
  452. $settings_form = ctools_plugin_get_function($behavior_info, 'settings form callback');
  453. if ($settings_form) {
  454. $form['settings'][$behavior][$implementation['provider']]['enabled']['#ajax'] = array(
  455. 'callback' => 'synonyms_settings_form_ajax',
  456. 'wrapper' => $form['settings']['#id'],
  457. );
  458. if ($behavior_settings !== FALSE) {
  459. $form['settings'][$behavior][$implementation['provider']]['settings'] = $settings_form($form, $form_state, $behavior_settings);
  460. }
  461. }
  462. }
  463. }
  464. $form['actions'] = array(
  465. '#type' => '#actions',
  466. );
  467. $form['actions']['submit'] = array(
  468. '#type' => 'submit',
  469. '#value' => t('Save'),
  470. );
  471. return $form;
  472. }
  473. /**
  474. * Submit handler for 'synonyms_settings_form' form.
  475. *
  476. * Store synonyms behavior settings.
  477. */
  478. function synonyms_settings_form_submit($form, &$form_state) {
  479. foreach ($form_state['values']['settings'] as $behavior => $settings) {
  480. foreach ($settings as $provider => $behavior_settings) {
  481. $behavior_implementation = array(
  482. 'entity_type' => $form['settings']['#entity_type'],
  483. 'bundle' => $form['settings']['#bundle'],
  484. 'provider' => $provider,
  485. 'behavior' => $behavior,
  486. 'settings' => isset($behavior_settings['settings']) ? $behavior_settings['settings'] : NULL,
  487. );
  488. if ($behavior_settings['enabled']) {
  489. synonyms_behavior_implementation_save($behavior_implementation);
  490. }
  491. else {
  492. synonyms_behavior_implementation_delete($behavior_implementation);
  493. }
  494. }
  495. }
  496. drupal_set_message(t('Synonyms settings have been successfully saved.'));
  497. $form_state['redirect'] = array('admin/structure/synonyms');
  498. }
  499. /**
  500. * Ajax callback function for synonyms settings form.
  501. */
  502. function synonyms_settings_form_ajax($form, &$form_state) {
  503. return $form['settings'];
  504. }