From: dhawes Date: Sun, 23 Jan 2005 15:52:52 +0000 (+0000) Subject: magpie templates. SMARTY examplesls X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=b6442a5e3a988c19912529ec63bf0d61e39f855b;p=moodle.git magpie templates. SMARTY examplesls --- diff --git a/rss/magpie/scripts/README b/rss/magpie/scripts/README new file mode 100644 index 0000000000..e37afe543c --- /dev/null +++ b/rss/magpie/scripts/README @@ -0,0 +1,27 @@ +Some example on how to use Magpie: + +* magpie_simple.php * + Simple example of fetching and parsing an RSS file. Expects to be + called with a query param 'rss_url=http://' + +* simple_smarty.php * + Similiar to magpie_simple, but using the Smarty template engine to do + display. Also demostrates using rss_utils.inc and a smarty plugin to + parse and display when each RSS item was published. + +* magpie_debug.php * + Displays all the information available from a parsed feed. + +* smarty_plugin/modifier.rss_date_parse.php * + + A Smarty plugin for parsing RSS style dates. You must include rss_utils.inc + for this plugin to work. It also must be installed in the Smarty plugin + directory, see the Smarty docs for details. + +* templates/simple.smarty + A Smarty template used by simple_smarty.php which demostrates + displaying an RSS feed and using the date parse plugin. + + +The Smarty template engine and documentation on how to use it are available from +http://smarty.php.net diff --git a/rss/magpie/scripts/magpie_debug.php b/rss/magpie/scripts/magpie_debug.php new file mode 100755 index 0000000000..43ed1ad01f --- /dev/null +++ b/rss/magpie/scripts/magpie_debug.php @@ -0,0 +1,41 @@ +channel['title'] . "

"; + echo "

"; + } + else { + echo "Error: " . magpie_error(); + } +} +?> + +
+ RSS URL:
+ +
+ +
+
+
\ No newline at end of file diff --git a/rss/magpie/scripts/magpie_simple.php b/rss/magpie/scripts/magpie_simple.php new file mode 100755 index 0000000000..8617be3d82 --- /dev/null +++ b/rss/magpie/scripts/magpie_simple.php @@ -0,0 +1,25 @@ +channel['title'] . "

"; + echo "

"; +} +?> + +
+ RSS URL:
+ +
diff --git a/rss/magpie/scripts/magpie_slashbox.php b/rss/magpie/scripts/magpie_slashbox.php new file mode 100755 index 0000000000..bbef30bedc --- /dev/null +++ b/rss/magpie/scripts/magpie_slashbox.php @@ -0,0 +1,66 @@ + + + + +
+ +
+ +"; + $rss = fetch_rss( $url ); + echo slashbox ($rss); +} + +echo "
";
+print_r($rss);
+echo "
"; +?> + + + + +"; + echo ""; + + # get the channel title and link properties off of the rss object + # + $title = $rss->channel['title']; + $link = $rss->channel['link']; + + echo "$title"; + echo ""; + + # foreach over each item in the array. + # displaying simple links + # + # we could be doing all sorts of neat things with the dublin core + # info, or the event info, or what not, but keeping it simple for now. + # + foreach ($rss->items as $item ) { + echo ""; + echo ""; + echo $item['title']; + echo ""; + } + + echo ""; +} + +?> diff --git a/rss/magpie/scripts/simple_smarty.php b/rss/magpie/scripts/simple_smarty.php new file mode 100755 index 0000000000..a904d88da1 --- /dev/null +++ b/rss/magpie/scripts/simple_smarty.php @@ -0,0 +1,58 @@ +compile_check = true; + +// url of an rss file +$url = $_GET['rss_url']; + + +if ( $url ) { + // assign a variable to smarty for use in the template + $smarty->assign('rss_url', $url); + + // use MagpieRSS to fetch remote RSS file, and parse it + $rss = fetch_rss( $url ); + + // if fetch_rss returned false, we encountered an error + if ( !$rss ) { + $smarty->assign( 'error', magpie_error() ); + } + $smarty->assign('rss', $rss ); + + $item = $rss->items[0]; + $date = parse_w3cdtf( $item['dc']['date'] ); + $smarty->assign( 'date', $date ); +} + +// parse smarty template, and display using the variables we assigned +$smarty->display('simple.smarty'); + +?>