Update of /cvsroot/phpslash/phpslash-dev/include/modules/story/plugins
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29153/phpslash-dev/include/modules/story/plugins
Added Files:
Story_plugin_mssmartquotes.class
Log Message:
added story plugin to remove MS Smart Quotes
--- NEW FILE: Story_plugin_mssmartquotes.class ---
<?php
/* Story_plugin_mssmartquotes.class -> Methods for phpslash specfic story plugins */
/* $Id: Story_plugin_mssmartquotes.class,v 1.1 2004/09/08 19:17:31 joestewart Exp $ */
class Story_plugin_mssmartquotes extends Story_plugin_i {
/* constructor */
function Story_plugin_mssmartquotes() {
$this->Story_plugin_i();
$this->type = "mssmartquotes"; /* set the 'type' */
$this->description = "A plugin that returns the story with MS Smart Quotes converted to html entities";
}
function parse($ary) {
// convert CR to linebreaks
$ary['intro_text'] = $this->superhtmlentities($ary['intro_text']);
$ary['body_text'] = $this->superhtmlentities($ary[body_text]);
$this->output = $ary;
return true;
}
function superhtmlentities($text) {
$entities = array(128 => 'euro',
130 => 'sbquo',
131 => 'fnof',
132 => 'bdquo',
133 => 'hellip',
134 => 'dagger',
135 => 'Dagger',
136 => 'circ',
137 => 'permil',
138 => 'Scaron',
139 => 'lsaquo',
140 => 'OElig',
145 => 'lsquo',
146 => 'rsquo',
147 => 'ldquo',
148 => 'rdquo',
149 => 'bull',
150 => '#45',
151 => 'mdash',
152 => 'tilde',
153 => 'trade',
154 => 'scaron',
155 => 'rsaquo',
156 => 'oelig',
159 => 'Yuml');
$new_text = '';
for($i = 0; $i < strlen($text); $i++) {
$num = ord($text{$i});
if (array_key_exists($num, $entities)) {
switch ($num) {
case 150:
$new_text .= '-';
break;
default:
$new_text .= '&'.$entities[$num].';';
}
}
else
if($num < 127 || $num > 159) {
$new_text .= htmlentities($text{$i});
}
}
return $new_text;
}
}
?>
|