source: sipes/modules_contrib/ctools/includes/content.menu.inc @ 92213c1

stableversion-3.0
Last change on this file since 92213c1 was 2efe680, checked in by José Gregorio Puentes <jpuentes@…>, 8 años ago

se actualizo el modulo

  • Propiedad mode establecida a 100755
File size: 1.5 KB
Línea 
1<?php
2
3/**
4 * @file
5 * Contains menu item registration for the content tool.
6 *
7 * The menu items registered are AJAX callbacks for the things like
8 * autocomplete and other tools needed by the content types.
9 */
10
11function ctools_content_menu(&$items) {
12  $base = array(
13    'access arguments' => array('access content'),
14    'type' => MENU_CALLBACK,
15    'file' => 'includes/content.menu.inc',
16  );
17  $items['ctools/autocomplete/node'] = array(
18    'page callback' => 'ctools_content_autocomplete_node',
19  ) + $base;
20}
21
22/**
23 * Helper function for autocompletion of node titles.
24 */
25function ctools_content_autocomplete_node($string) {
26  if ($string != '') {
27    $preg_matches = array();
28    $match = preg_match('/\[nid: (\d+)\]/', $string, $preg_matches);
29    if (!$match) {
30      $match = preg_match('/^nid: (\d+)/', $string, $preg_matches);
31    }
32    if ($match) {
33      $arg = $preg_matches[1];
34      $where = "n.nid = %d";
35    }
36    else {
37      $arg = $string;
38      $where = "LOWER(n.title) LIKE LOWER('%%%s%%')";
39    }
40    if (!user_access('administer nodes')) {
41      $where .= ' AND n.status = 1';
42    }
43
44    $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.title, u.name FROM {node} n INNER JOIN {users} u ON u.uid = n.uid WHERE $where"), $arg, 0, 10);
45
46    $matches = array();
47    while ($node = db_fetch_object($result)) {
48      $matches[$node->title . " [nid: $node->nid]"] = '<span class="autocomplete_title">' . check_plain($node->title) . '</span>';
49    }
50    drupal_json($matches);
51  }
52}
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.