Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

New modifier: escape_wquotes

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Plugins
View previous topic :: View next topic  
Author Message
charly71
Smarty Rookie


Joined: 10 Jun 2003
Posts: 6

PostPosted: Tue May 11, 2004 5:13 pm    Post subject: New modifier: escape_wquotes Reply with quote

This modifier escapes Ms Word chars like chr(146) or chr(151) from your text. It uses a simple PHP str_replace() function.
I have made this modifier because I had some dirty text stored in a mysql field... Mad

Code:

<?php
/*
 * Smarty plugin
 * -------------------------------------------------------------
 * Type: modifier
 * Name: escape_wquotes
 * Version: 1.0
 * Date: 2004-05-11
 * Author: Carlo Sacripante sacripante[NOSPAM]@libero.it
 * Purpose: Escape chr(146) to chr(151) from MS Word text
 * Notes:  This modifier uses a simple PHP str_replace function to
 *  replace single and double quotes characters from a Microsoft Word
 *    "cut and paste like" string, with an HTML encoded string.
 *
 * Example smarty code:
 *
 * {$dirtyString|escape_wquotes}
 *
 *
 * -------------------------------------------------------------
 */

function smarty_modifier_escape_wquotes ($text)

{
   $badwordchars=array(
                           chr(145),
                           chr(146),
                           chr(147),
                           chr(148),
                           chr(151)
                           );
   $fixedwordchars=array(
                           "& acute;",  //no blank space after & <- erase this comment ;-)
                           "& acute;",
                           '& quot;',
                           '& quot;',
                           '& mdash;'
                           );
   return str_replace($badwordchars,$fixedwordchars,$text);
}

?>
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Plugins All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP