| 1 |
<?php
|
| 2 |
// $Id: ajax_spellcheck.module,v 1.2 2005/08/15 10:02:22 thox Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* Implementation of hook_help().
|
| 6 |
*/
|
| 7 |
function ajax_spellcheck_help($section) {
|
| 8 |
switch ($section) {
|
| 9 |
case 'admin/modules#description':
|
| 10 |
return t('Enables spellchecking of nodes.');
|
| 11 |
}
|
| 12 |
}
|
| 13 |
|
| 14 |
/**
|
| 15 |
* Implementation of hook_menu().
|
| 16 |
*/
|
| 17 |
function ajax_spellcheck_menu($may_cache) {
|
| 18 |
$items = array();
|
| 19 |
|
| 20 |
if ($may_cache) {
|
| 21 |
$items[] = array(
|
| 22 |
'path' => 'spellcheck',
|
| 23 |
'title' => t('Spellcheck'),
|
| 24 |
'access' => true,
|
| 25 |
'callback' => 'ajax_spellcheck_page',
|
| 26 |
'type' => MENU_CALLBACK
|
| 27 |
);
|
| 28 |
}
|
| 29 |
else {
|
| 30 |
$path = drupal_get_path('module', 'ajax_spellcheck');
|
| 31 |
drupal_add_js($path . '/spellcheck.js');
|
| 32 |
theme_add_style($path . '/spellcheck.css');
|
| 33 |
}
|
| 34 |
|
| 35 |
return $items;
|
| 36 |
}
|
| 37 |
|
| 38 |
function ajax_spellcheck_page() {
|
| 39 |
$text = $GLOBALS['HTTP_RAW_POST_DATA'];
|
| 40 |
|
| 41 |
header('Content-type: text/xml');
|
| 42 |
|
| 43 |
$xml = '<spellrequest textalreadyclipped="0" ignoredups="1" ignoredigits="1" ignoreallcaps="0"><text><![CDATA['.$text.']]></text></spellrequest>';
|
| 44 |
$result = drupal_http_request('http://www.google.com/tbproxy/spell?lang=en', array('Content-Type' => 'text/xml'), 'POST', $xml);
|
| 45 |
echo $result->data;
|
| 46 |
}
|