ckeditor_link.node.inc

  1. cis7 sites/all/modules/ulmus/ckeditor_link/includes/ckeditor_link.node.inc
  2. cle7 sites/all/modules/ulmus/ckeditor_link/includes/ckeditor_link.node.inc
  3. ecd7 sites/all/modules/ulmus/ckeditor_link/includes/ckeditor_link.node.inc
  4. elmsmedia7 sites/all/modules/ulmus/ckeditor_link/includes/ckeditor_link.node.inc
  5. harmony7 sites/all/modules/ulmus/ckeditor_link/includes/ckeditor_link.node.inc
  6. icor7 sites/all/modules/ulmus/ckeditor_link/includes/ckeditor_link.node.inc
  7. meedjum_blog7 sites/all/modules/ulmus/ckeditor_link/includes/ckeditor_link.node.inc
  8. mooc7 sites/all/modules/ulmus/ckeditor_link/includes/ckeditor_link.node.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.node.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_node_autocomplete($string, $limit) {
  11. $matches = array();
  12. $node_types = array_keys(array_filter(variable_get('ckeditor_link_autocomplete_node_types', array('- any -' => '- any -'))));
  13. if (count($node_types)) {
  14. $query = db_select('node', 'n')
  15. ->fields('n', array('nid', 'title'))
  16. ->condition('n.title', '%'. db_like($string) .'%', 'LIKE')
  17. ->orderBy('n.title')
  18. ->orderBy('n.type')
  19. ->range(0, $limit)
  20. ->addTag('node_access');
  21. if (!in_array('- any -', $node_types)) {
  22. $query->condition('n.type', $node_types, 'IN');
  23. }
  24. $result = $query->execute();
  25. foreach ($result as $node) {
  26. $matches['node/'. $node->nid] = $node->title;
  27. }
  28. }
  29. return $matches;
  30. }
  31. /**
  32. * Implementation of hook_ckeditor_link_TYPE_revert().
  33. */
  34. function ckeditor_link_ckeditor_link_node_revert($path, &$langcode) {
  35. if (!preg_match('`^node/(\d+)$`', $path, $matches)) {
  36. return;
  37. }
  38. $nid = $matches[1];
  39. $query = db_select('node', 'n')
  40. ->fields('n', array('title', 'language'))
  41. ->condition('n.nid', $nid)
  42. ->addTag('node_access');
  43. if ($node = $query->execute()->fetchObject()) {
  44. if ($node->language != LANGUAGE_NONE) {
  45. $langcode = LANGUAGE_NONE;
  46. }
  47. return $node->title;
  48. }
  49. return FALSE;
  50. }
  51. /**
  52. * Implementation of hook_ckeditor_link_TYPE_url().
  53. */
  54. function ckeditor_link_ckeditor_link_node_url($path, $langcode) {
  55. if (!preg_match('`^node/(\d+)$`', $path, $matches)) {
  56. return;
  57. }
  58. $nid = $matches[1];
  59. $languages = ckeditor_link_get_languages();
  60. if ($languages) {
  61. $language = db_query('SELECT language FROM {node} WHERE nid = :nid', array(':nid' => $nid))->fetchField();
  62. if ($language && ($language != LANGUAGE_NONE) && isset($languages[$language])) {
  63. $langcode = $language;
  64. }
  65. }
  66. return ckeditor_link_url("node/$nid", $langcode);
  67. }
  68. /**
  69. * Implementation of hook_ckeditor_link_TYPE_settings().
  70. */
  71. function ckeditor_link_ckeditor_link_node_settings() {
  72. $form['node'] = array(
  73. '#type' => 'fieldset',
  74. '#title' => t('Nodes'),
  75. );
  76. $form['node']['ckeditor_link_autocomplete_node_types'] = array(
  77. '#type' => 'checkboxes',
  78. '#title' => t('Content types'),
  79. '#options' => array('- any -' => t('<em>Any content type</em>')) + array_map('check_plain', node_type_get_names()),
  80. '#default_value' => variable_get('ckeditor_link_autocomplete_node_types', array('- any -' => '- any -')),
  81. '#description' => t('Select the content types to be available as autocomplete suggestions.'),
  82. );
  83. return $form;
  84. }
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.