<?php
/**
* Implementation of hook_menu().
*/
function nrc_authormerge_menu($may_cache) {
if ($may_cache) {
'path' => 'author/autocomplete',
'callback' => 'nrc_authormerge_autocomplete',
'title' =>
t('Search matching authors'),
);
}
return $items;
}
/**
* Implementation of hook_nodeapi().
* @todo show only on certain criteria (ie body empty etc)
*/
function nrc_authormerge_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
if ($node->
type ==
'author' &&
$op ==
'view' &&
$a4 !=
false &&
user_access('administer nodes')) {
$node->content['searchbox']['#value'] = $form;
//dpm($node);
}
}
/**
* Autocomplete callback, returns authors.
*/
function nrc_authormerge_autocomplete($string = '') {
/*$result = db_query("SELECT n.nid, n.title AS node_title FROM {node} n WHERE n.type = 'author' AND n.title LIKE '%%%s%' ORDER BY n.title", $string);
while ($row = db_fetch_object($result)) {
$matches[$row->node_title .' [nid:'. $row->nid .']'] = check_plain($row->node_title);
}*/
// watchdog here shows that this function is called
// but still, even this simple array doesn't popup in the autocomplete textfield.
$matches['blah'] = 'test 1';
$matches['blah2'] = 'test 2';
}
/**
* Search block with autocomplete form
*/
function nrc_authormerge_searchbox($nid) {
$form['author_search'] =
array(
'#required' => true,
'#type' => 'textfield',
'#title' =>
t('Zoek een auteur'),
'#autocomplete_path' => 'author/autocomplete'
);
$form['thisnid'] =
array(
'#type' => 'hidden',
'#value' => $nid
);
'#type' => 'submit',
);
return $form;
}