ich habe einmal den Standard RSS-Reader um 2 Einstellungen erweitert.
Man kan nun im Inputbereich den Charset zwischen Standard (Contenido Einstellung), UTF-8 und iso-8859-1 und die max Ausgabe der Zeichen des RSS-Feeds eingeben.
Ich hatte bei ein paar RSS-Feeds Probleme mit den Umlauten bei dem Standardmodul wie zum Beispiel bei http://www.viruslist.com/de/rss/popularnews. Dort habe ich nun im Modul UTF-8 eingestellt und weil manschmal der Text zu lang war die Zeichenanzahl zum Beispiel auf 100, und nun funktioniert alles wunderbar.
INPUT
Code: Alles auswählen
?><?php
/**
* $RCSfile$
*
* Description: Display an RSS Feed. Module "Input".
*
* @version 1.0.0
* @author Timo Hummel, Andreas Lindner
* @copyright four for business AG <www.4fb.de>
*
* {@internal
* created 2005-09-30
* }}
*
* $Id$
*/
echo '<table>';
echo '<tr><td>'.mi18n("URL").'</td><td><input type="text" name="'."CMS_VAR[0]".'" value="'."CMS_VALUE[0]".'" style="width: 320px"></td></tr>';
echo '<tr><td>';
echo mi18n("RSS-Template auswählen").':</td><td><select name="CMS_VAR[1]" size="1" style="width: 320px">
<option value="">Nichts ausgewählt</option>';
$strPath_fs = $cfgClient[$client]["path"]["frontend"].'templates/';
$handle = opendir($strPath_fs);
while ($entryName = readdir($handle)) {
if (is_file($strPath_fs.$entryName)) {
if ("CMS_VALUE[1]"==$entryName) {
echo '<option selected value="'.$entryName.'">'.$entryName.'</option>';
} else {
echo '<option value="'.$entryName.'">'.$entryName.'</option>';
}
}
}
echo '</select></td></tr>';
echo '<tr><td>'.mi18n("Anzahl Einträge").'</td><td><input type="text" name="'."CMS_VAR[2]".'" value="'."CMS_VALUE[2]".'"</td></tr>';
echo '<tr><td>'.mi18n("Charset").'</td><td>';
$SelectCode="CMS_VALUE[3]";
?>
<select name="<?php echo "CMS_VAR[3]"; ?>">
<option value="" <?php if($SelectCode==""){echo "selected=\"selected\"";} ?>>Standard</option>
<option value="UTF-8" <?php if($SelectCode=="UTF-8"){echo "selected=\"selected\"";} ?>>UTF-8</option>
<option value="iso-8859-1" <?php if($SelectCode=="iso-8859-1"){echo "selected=\"selected\"";} ?>>iso-8859-1</option>
</select>
<?php
echo '</td></tr>';
echo '<tr><td>'.mi18n("max. Zeichenanzahl").'</td><td><input type="text" name="'."CMS_VAR[4]".'" value="'."CMS_VALUE[4]".'"</td></tr>';
echo '</table>';
?><?php
Code: Alles auswählen
<?php
/**
* $RCSfile$
*
* Description: Display an RSS Feed. Module "Output".
*
* @version 1.0.0
* @author Timo Hummel, Andreas Lindner
* @copyright four for business AG <www.4fb.de>
*
* {@internal
* created 2005-09-30
* }}
*
* $Id$
*/
cInclude("pear", "XML/Parser.php");
cInclude("pear", "XML/RSS.php");
$SelectCode="CMS_VALUE[3]";
if ("CMS_VALUE[0]" == "")
{
$sFeed = "http://www.contenido.org/rss/de/news";
} else {
$sFeed = "CMS_VALUE[0]";
}
if ("CMS_VALUE[2]" == "")
{
$FeedMaxItems = 999;
} else {
$FeedMaxItems = intval("CMS_VALUE[2]");
}
if ("CMS_VALUE[4]" == "")
{
$FeedMaxChars = 999;
} else {
$FeedMaxChars = intval("CMS_VALUE[4]");
}
/* Preparse feed for an encoding due to the poorly designed
PHP XML parser */
$sFeedContent = substr(@file_get_contents($sFeed),0,1024);
$regExp = "/<\?xml.*encoding=[\"\'](.*)[\"\']\?>/i";
preg_match($regExp,trim($sFeedContent),$matches);
if ($matches[1])
{
$rss =& new XML_RSS($sFeed, $matches[1]);
} else {
$rss =& new XML_RSS($sFeed);
}
$rss->parse();
if (!isset($tpl) || !is_object($tpl)) {
$tpl = new Template();
}
$tpl->reset();
$i = 0;
foreach ($rss->getItems() as $item)
{
if ($i < $FeedMaxItems) {
$tpl->set("d", "TITLE", htmlentities($item['title'],ENT_QUOTES,$SelectCode));
$tpl->set("d", "LINK", htmlentities($item['link'],ENT_QUOTES,$SelectCode));
$tpl->set("d", "DESCRIPTION", substr(htmlentities($item['description'],ENT_QUOTES,$SelectCode),0,$FeedMaxChars));
$tpl->set("d", "READ_ON", mi18n("weiterlesen"));
$tpl->next();
}
$i++;
}
$tpl->generate($cfgClient[$client]["path"]["frontend"]."templates/"."CMS_VALUE[1]");
?>