'"',
'”' => '"',
'®' => '(R)',
'®' => '(R)'
);
/**
* Provide the form field to specify character count limit.
*/
function additionalFormParameters() {
?>
getCurrTag();
$should_summarize = array_search($tag, $this->SUMMARIZE_TAGS);
if ($this->in_item && $should_summarize !== false) {
// Yes, so just buffer up all CDATA before queuing events.
$this->appendCDATA($data);
} else {
// No, proceed as normal.
FeedMagick_SaxFeedFilter::data($data);
}
}
/**
* For tags subject to summarizing, strip HTML tags and constrain to
* final space-delimited word of the text that fits within the
* character count limit.
*/
function close(&$tag) {
// Should the data for this element be summarized?
$should_summarize = array_search($tag, $this->SUMMARIZE_TAGS);
if ($this->in_item && $should_summarize !== false) {
// Grab all the buffered up CDATA.
$data = $this->getCDATA();
// Strip any HTML tags from this data.
$data = strip_tags($data);
// Replace arbitrary entities with "safer" characters
foreach ($this->ENTITY_REPLACEMENTS as $entity=>$replacement) {
$data = str_replace($entity, $replacement, $data);
}
// Determine the actual length and constrained length for the text.
$actual_len = strlen($data);
$limit_len = ($_GET['char_limit']) ? $_GET['char_limit'] : 150;
$final_len = min($actual_len, $limit_len);
if ($final_len < $actual_len) {
// Constrain the string length.
$data = substr($data, 0, $final_len);
// Snip a bit at the end so that it finishes on a whole word.
$data = substr($data, 0, strrpos($data, ' '))."...";
}
// Finally, queue up an event for this pent-up data.
$this->queueData($data);
}
// Proceed as normal with closing this tag.
FeedMagick_SaxFeedFilter::close($tag);
}
}
// Instantiate and run the filter only when not being used as an include.
if (strpos(basename(__FILE__), basename($_SERVER['SCRIPT_FILENAME'])) !== false) {
processFilter(new SummarizeFilter());
}
?>