ckeditor_link.i18n_menu.inc

  1. cis7 sites/all/modules/ulmus/ckeditor_link/includes/ckeditor_link.i18n_menu.inc
  2. cle7 sites/all/modules/ulmus/ckeditor_link/includes/ckeditor_link.i18n_menu.inc
  3. ecd7 sites/all/modules/ulmus/ckeditor_link/includes/ckeditor_link.i18n_menu.inc
  4. elmsmedia7 sites/all/modules/ulmus/ckeditor_link/includes/ckeditor_link.i18n_menu.inc
  5. harmony7 sites/all/modules/ulmus/ckeditor_link/includes/ckeditor_link.i18n_menu.inc
  6. icor7 sites/all/modules/ulmus/ckeditor_link/includes/ckeditor_link.i18n_menu.inc
  7. meedjum_blog7 sites/all/modules/ulmus/ckeditor_link/includes/ckeditor_link.i18n_menu.inc
  8. mooc7 sites/all/modules/ulmus/ckeditor_link/includes/ckeditor_link.i18n_menu.inc

Written by Henri MEDOT <henri.medot[AT]absyx[DOT]fr> http://www.absyx.fr

Functions

File

sites/all/modules/ulmus/ckeditor_link/includes/ckeditor_link.i18n_menu.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Written by Henri MEDOT <henri.medot[AT]absyx[DOT]fr>
  5. * http://www.absyx.fr
  6. */
  7. /**
  8. * Implementation of hook_ckeditor_link_TYPE_autocomplete().
  9. */
  10. function ckeditor_link_ckeditor_link_i18n_menu_autocomplete($string, $limit) {
  11. // Currently, this function only supports MySQL.
  12. // TODO: Add support for pgsql.
  13. if (!in_array(db_driver(), array('mysql'))) {
  14. return array();
  15. }
  16. $matches = array();
  17. $menus = array_keys(array_filter(variable_get('ckeditor_link_autocomplete_menus', array())));
  18. if (count($menus)) {
  19. $query = db_select('menu_links', 'ml');
  20. $query->innerJoin('locales_source', 'ls', 'ls.context = CONCAT(:prefix, ml.mlid, :suffix)', array(':prefix' => 'item:', ':suffix' => ':title'));
  21. $query->innerJoin('locales_target', 'lt', 'lt.lid = ls.lid');
  22. $query->fields('ml', array('link_path'));
  23. $query->addExpression('CONVERT(lt.translation USING utf8)', 'link_title');
  24. $query->fields('lt', array('language'));
  25. $query->where('CONVERT(lt.translation USING utf8) LIKE :pattern', array(':pattern' => '%'. db_like($string) .'%'));
  26. $query->condition('ml.hidden', 0);
  27. $query->condition('ml.external', 0);
  28. $query->orderBy('link_title');
  29. $query->range(0, $limit);
  30. if (!in_array('- any -', $menus)) {
  31. $query->condition('ml.menu_name', $menus, 'IN');
  32. }
  33. $result = $query->execute();
  34. foreach ($result as $item) {
  35. if (_ckeditor_link_check_path($item->link_path)) {
  36. $router_item = menu_get_item($item->link_path);
  37. if ($router_item && $router_item['access']) {
  38. $path = ckeditor_link_path_prefix_language($item->link_path, $item->language);
  39. $matches[$path] = $item->link_title;
  40. }
  41. }
  42. }
  43. }
  44. return $matches;
  45. }
  46. /**
  47. * Implementation of hook_ckeditor_link_TYPE_revert().
  48. */
  49. function ckeditor_link_ckeditor_link_i18n_menu_revert($path, &$langcode) {
  50. $router_item = menu_get_item($path);
  51. if ($router_item) {
  52. if (!$router_item['access']) {
  53. return FALSE;
  54. }
  55. $result = db_query('SELECT mlid, link_title, language FROM {menu_links} WHERE link_path = :link_path AND hidden = 0 ORDER BY customized DESC', array(':link_path' => $path));
  56. $default_langcode = language_default('language');
  57. $link_title = NULL;
  58. foreach ($result as $item) {
  59. if ($item->language == $langcode) {
  60. $link_title = $item->link_title;
  61. break;
  62. }
  63. elseif (($item->language == $default_langcode) && ($langcode == LANGUAGE_NONE)) {
  64. $langcode = $default_langcode;
  65. $link_title = $item->link_title;
  66. break;
  67. }
  68. elseif (!$link_title && ($item->language == LANGUAGE_NONE)) {
  69. $link_title = i18n_string_translate(array('menu', 'item', $item->mlid, 'title'), $item->link_title, array('langcode' => $langcode));
  70. }
  71. }
  72. return ($link_title) ? $link_title : NULL;
  73. }
  74. }
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.