Source for file simple_smarty.php

Documentation is available at simple_smarty.php

  1. <?php
  2.  
  3. // Define path to Smarty files (don't forget trailing slash)
  4. // and load library.  (you'll want to change this value)
  5. //
  6. // NOTE:  you can also simply add Smarty to your include path
  7. define('SMARTY_DIR''/home/kellan/projs/magpierss/scripts/Smarty/');
  8. require_once(SMARTY_DIR.'Smarty.class.php');
  9.  
  10. // define path to Magpie files and load library
  11. // (you'll want to change this value)
  12. //
  13. // NOTE: you can also simple add MagpieRSS to your include path
  14. define('MAGPIE_DIR''/home/kellan/projs/magpierss/');
  15. require_once(MAGPIE_DIR.'rss_fetch.inc');
  16. require_once(MAGPIE_DIR.'rss_utils.inc');
  17.  
  18.  
  19. // optionally show lots of debugging info
  20. # define('MAGPIE_DEBUG', 2);
  21.  
  22. // optionally flush cache quickly for debugging purposes, 
  23. // don't do this on a live site
  24. # define('MAGPIE_CACHE_AGE', 10);
  25.  
  26. // use cache?  default is yes.  see rss_fetch for other Magpie options
  27. # define('MAGPIE_CACHE_ON', 1)
  28.  
  29. // setup template object
  30. $smarty new Smarty;
  31. $smarty->compile_check true;
  32.  
  33. // url of an rss file
  34. $url $_GET['rss_url'];
  35.  
  36.  
  37. if $url {
  38.     // assign a variable to smarty for use in the template
  39.     $smarty->assign('rss_url'$url);
  40.     
  41.     // use MagpieRSS to fetch remote RSS file, and parse it
  42.     $rss fetch_rss$url );
  43.     
  44.     // if fetch_rss returned false, we encountered an error
  45.     if !$rss {
  46.         $smarty->assign'error'magpie_error() );
  47.     }
  48.     $smarty->assign('rss'$rss );
  49.     
  50.     $item $rss->items[0];
  51.     $date parse_w3cdtf$item['dc']['date');
  52.     $smarty->assign'date'$date );
  53. }
  54.  
  55. // parse smarty template, and display using the variables we assigned
  56. $smarty->display('simple.smarty');
  57.  
  58. ?>

Documentation generated on Tue, 01 May 2007 16:47:13 +0200 by phpDocumentor 1.3.2