CaRP: a caching RSS parser Replace Text for CaRP Evolution
The extendable version of CaRP: caching RSS parser
 
Replace Text is a plugin bundled with CaRP Evolution. It enables you to modify the contents of a newsfeed before display. Use it to expand acronyms, add bold or italics to certain words or phrases, "bleep" language you don't want appearing on your site, etc.
 
IMPORTANT NOTE: Altering the contents of a newsfeed may violate copyrights or have other legal consequences. It is your responsibility to ensure that your use of this plugin is legal. You may wish to contact the publisher of a newsfeed to obtain permission before using this plugin to modify it.
 
Installation:
To install Replace Text, put replacetext.php into the "plugins" folder inside the folder containing carp.php. (If no plugins folder exists, create one.)
 
Use:
To use this plugin, do the following:
  1. Enter the following command into your webpage after "require_once '/path/to/carp.php';":
    CarpLoadPlugin('replacetext.php');
  2. For any text you wish to modify, use the following function (you may repeat this step more than once):
    ReplaceTextConf($initem, $field_name, $is_regular_expression, $search_text, $replace_text);
    • $initem: 0 if you want to modify data in the channel section of the newsfeed, 1 to modify data in individual items.
    • $field_name: The name of the field to modify (using CaRP's internal field names). You may leave the field blank to modify all fields. Valid values are: title, link, url, image, date, author, and desc.
    • $is_regular_expression: 0 if you wish to search for an exact match to the text you specify, or 1 if your search string is a regular expression.
    • $search_text: The text or regular expression to search for.
    • $replace_text: The text to replace $search_text with.
Example:
To replace "IMHO" with "in my humble opinion", and bold the word "evolution", when either occurs in item descriptions, do the following:
 
ReplaceTextConf(1,'desc',0,'IMHO','in my humble opinion');
ReplaceTextConf(1,'desc',1,'(evolution)','<b>\\1</b>');
 
Note that when $is_regular_expression is 0, the matching is case sensistive. When using regular expressions, the match is not case sensitive. In the second example, "\\1" inserts the text that matched the text in parenthesis in $search_text. The example uses this style rather than ReplaceTextConf(1,'desc',1,'evolution','<b>evolution</b>'); to ensure that the case of the text is not changed (for example, from "Evolution" to "evolution").
Purchase CaRP Evolution on the CaRP Homepage
CaRP Evolution Plugins
CaRP Evolution API Documentation