| 1 |
|
<?php |
| 2 |
|
// $Id$ |
| 3 |
|
/** |
| 4 |
|
* @file |
| 5 |
|
* Filter Microsoft Word tags. |
| 6 |
|
*/ |
| 7 |
|
|
| 8 |
|
/** |
| 9 |
|
* Implementation of hook_filter(). |
| 10 |
|
*/ |
| 11 |
|
function word2web_filter_filter($op, $delta = 0, $format = -1, $text = '') { |
| 12 |
|
// |
| 13 |
|
switch ($op) { |
| 14 |
|
case 'list': |
| 15 |
|
return array(0 => t('MS Word Cleanup')); |
| 16 |
|
|
| 17 |
|
case 'description': |
| 18 |
|
return t('Removes pesky Word tags added from "HTML" code pasted from MS Word.'); |
| 19 |
|
|
| 20 |
|
case 'no cache': |
| 21 |
|
return false; |
| 22 |
|
|
| 23 |
|
case 'settings': |
| 24 |
|
return _word2web_filter_settings($format); |
| 25 |
|
|
| 26 |
|
case 'process': |
| 27 |
|
// Include our helper file. |
| 28 |
|
module_load_include('inc', 'word2web'); |
| 29 |
|
return _word2web_filter($text, variable_get("word2web_strip_images_$format", FALSE)); |
| 30 |
|
|
| 31 |
|
default: |
| 32 |
|
return $text; |
| 33 |
|
} |
| 34 |
|
} |
| 35 |
|
|
| 36 |
|
/** |
| 37 |
|
* Setting form for word2web MS Word cleanup filter. |
| 38 |
|
* |
| 39 |
|
* @param $format |
| 40 |
|
* The filter format name. |
| 41 |
|
* @return |
| 42 |
|
* FormAPI array. |
| 43 |
|
*/ |
| 44 |
|
function _word2web_filter_settings($format) { |
| 45 |
|
$form['word2web_filter'] = array( |
| 46 |
|
'#type' => 'fieldset', |
| 47 |
|
'#title' => t('MS Word Cleanup'), |
| 48 |
|
'#collapsible' => TRUE, |
| 49 |
|
); |
| 50 |
|
|
| 51 |
|
$form['word2web_filter']["word2web_strip_images_$format"] = array( |
| 52 |
|
'#type' => 'checkbox', |
| 53 |
|
'#title' => t('Strip Word image tags.'), |
| 54 |
|
'#default_value' => variable_get("word2web_strip_images_$format", FALSE), |
| 55 |
|
'#description' => t('If enabled, Microsoft Word image tags will be striped. Otherwise they will be converted to html image tags.<br /> Note: The filter will not make sure these images exist.'), |
| 56 |
|
); |
| 57 |
|
|
| 58 |
|
return $form; |
| 59 |
|
} |