The front page just displays the right-hand panel and, where the plugin would appear. the error "no element found".
The plugin admin page stops at the point where the links to the plugin config would appear:
It's installed on a fairly standard setup - the only difference is I had to comment out the php settings in the .htaccess due to the way my host sets things up.
Any suggestions as to where I'm going wrong?
Code for the plugin is as follows.
Code: Select all
<?php # $Id: $
/* RSS reader plugin by Auz (www.auzsoft.net). Reads RSS. Based on rss-reader by Kailash Nadh */
class serendipity_plugin_rssreader extends serendipity_plugin {
function introspect(&$propbag)
{
$propbag->add('name', 'RSS Reader Plugin');
$propbag->add('description', 'Reads RSS Feed');
$propbag->add('configuration', array(
'title',
'url',
'items',
'chop'
)
);
}
function introspect_config_item($name, &$propbag)
{
switch($name) {
case 'title':
$propbag->add('type', 'string');
$propbag->add('name', 'Feed Title');
$propbag->add('description', 'Title of the RSS feed (leave blank to use feed\'s)');
break;
case 'url':
$propbag->add('type', 'string');
$propbag->add('name', 'URL');
$propbag->add('description', 'URL of the RSS feed');
break;
case 'chop':
$propbag->add('type', 'string');
$propbag->add('name', 'Truncate');
$propbag->add('description', 'Max length of headlines');
break;
case 'items':
$select["1"] = "One";
$select["2"] = "Two";
$select["3"] = "Three";
$select["4"] = "Four";
$select["5"] = "Five";
$select["10"] = "Ten";
$propbag->add('type', 'select');
$propbag->add('name', 'Display');
$propbag->add('description', 'No. of items to display');
$propbag->add('select_values', $select);
break;
default:
return false;
}
return true;
}
function generate_content(&$title, $output = true)
{
$title = $this->get_config('title');
$url = $this->get_config('url');
$disp = $this->get_config('items');
$chop = $this->get_config('chop');
//echo "Viewing $disp items from $url";
$data = @fread( fopen("$url","r"), 10000 );
$myar = $this->getXmlData($data);
if (!$title) {
$title = $myar["TITLE"][0];
}
echo "<div>";
for ( $i=1; $i<=$disp; $i++ ) {
$head = $myar["TITLE"][$i];
$full = $head;
$link = $myar["LINK"][$i];
if ( $chop ) {
if ( strlen($head) > $chop ) {
$head = rtrim(substr( $head, 0, $chop-3 )) . "...";
}
}
echo "<a href=\"$link\" target=\"_blank\" title=\"$full\">$head</a><br>\n";
}
echo "</div>";
//echo "<!--\n ".print_r($myar,TRUE)." \n-->";
}
/*##############################################
RSS parser written for bMachine feed.
This script can be used to read ANY kind of RSS feeds from anywhere!
*--------------------------------------------*
Written by Kailash Nadh,
http://bnsoft.net , kailash@bnsoft.net
Author of bMachine, http://boastology.com
I wrote this script on the 1st day I studied
XML by running through the documentation at www.php.net ;)
*--------------------------------------------*
WARNING!: This script is Heavily commented! :)
This is how the script works.
> Reads the XML file
> Parses it into an array using xml_parse_into_struct()
> Converts that array into a more sensible, easily usable array
[ See the structure.txt file to get an idea of the array structure ]
> Finally, Display the data in anyway you want!
This script demonstrates the use of simple logic
to do Complex XML/RSS parsing functions
This script can be easily developed into a powerful application.
##############################################*/
//#####################################################################
// This is the function. It returns the array of the parsed XML data
function getXmlData($xml_doc) {
$n=0; // Counter used for arraying the XML data
$ar=array(); // The main array for storing parsed xml using xml_parse_into_struct()
// Parse the XML document
$parser = xml_parser_create();
xml_parse_into_struct($parser,$xml_doc,$vals,$index) or die(xml_error_string(xml_get_error_code($parser)));
xml_parser_free($parser);
$ttags=array(); // Temporary arry for storing tag names
// The main part. This is MY CREATION
// and this piece of code makes this script simple :)
// This is the "MAGIC LOOP" !! :)
for($n=0;$n<=count($vals)-1;$n++) {
if(trim($vals[$n][value])) {
$ar[$vals[$n][tag]][count($ar[$vals[$n][tag]])]=$vals[$n][value];
$ttags[$vals[$n][tag]]=$vals[$n][tag];
}
}
// Array for storing all the tag names
// This array will hold all the Tag names found in the XML document
// eg: ("TITLE","LINK","AUTHOR","DOMAIN")..
// Use this if you need it.
$tags=array();
// Extract and save the tag names to the array
foreach($ttags as $tagi) { array_push($tags,$tagi); }
return $ar;
}
}
?>