Jump to content

MS Word Cleanup


phpbeginner

Recommended Posts

I have a CMS with basic toolbar and have major issues with copying and pasting from MS Word.

 

I have a code below that I would like to test cleaning up MS Word....

 

 

<?php
function word_cleanup ($str)
{
    $pattern = "/<(\w+)>(\s| )*<\/\1>/";
    $str = preg_replace($pattern, '', $str);
    return mb_convert_encoding($str, 'HTML-ENTITIES', 'UTF-8');
}
?>

And would like to add it onClick within code below, but it doesn't seem to do anything......

 

 

<?php
//we will have to dynamically generate either the edit and delete buttons or
//the save button here depending on numevent.
if($numMain!=-1)
{
echo("<tr><td colspan='2' align='center'><input type='submit' id='button' name='edit' value='Save Changes' onClick=\"saveChanges('edit'); onClick=\"function('word_cleanup');\"><input type='submit' id='button' name='delete' value='Delete' onClick=\"saveChanges('delete');\"></td></tr></table></form>");
}
else
{
echo("<tr><td colspan='2' align='center'><input type='submit' id='button' name='save' value=' Save ' onClick=\"saveChanges('save'); onClick=\"function('word_cleanup');\"></td></tr></table></form>");
}

?>

 

 

Any help, tips, suggestions would be so greatly appreciated.

Link to comment
https://forums.phpfreaks.com/topic/260008-ms-word-cleanup/
Share on other sites

You'll need to either create it as a javascript function (I have no idea what you're attempting is possible in JS), or use AJAX to submit the code to your PHP page. Either way, you'll need javascript help.

The third option I see is instead of doing it onclick, make the page submit, use PHP to clean it up, then refill the form with the corrected content.

 

 

Link to comment
https://forums.phpfreaks.com/topic/260008-ms-word-cleanup/#findComment-1332708
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.