<?xml version="1.0" encoding="ISO-8859-1"?>
<rss version="2.0">
  <channel>
    <title>blogHOUSTON - Podcast</title>
    <link>http://www.bloghouston.net/podcast/</link>
    <description>bH audio</description>
    <language>en-us</language>           
    <generator>Nucleus CMS v3.71</generator>
    <copyright>©</copyright>             
    <category>Weblog</category>
    <docs>http://backend.userland.com/rss</docs>
    <image>
      <url>http://www.bloghouston.net/podcast//images/bhmedbutton.jpg</url>
      <title>blogHOUSTON - Podcast</title>
      <link>http://www.bloghouston.net/podcast/</link>
    </image>
    <?
class NP_SmartParagraphs extends NucleusPlugin {
function getName() { return 'SmartParagraphs'; }
function getAuthor() { return 'Moni @ Traweb'; }
function getURL() { return 'http://www.traweb.com/extra/nucleusplugin/'; }
function getVersion() { return '1.5'; }
function getDescription() {
   return 'This plugin will convert line breaks and paragraphs in your entries, by adding the corresponding markup tags to produce valid HTML or XHTML. It is smart enough not to insert these tags in places where they may conflict with block elements and other HTML markup tags you may already be using in your posts. Basically, this is a more powerful line break converter than the default one embedded in Nucleus. It is now based entirely on the autop script by Matthew Mullenweg - see at see at http://photomatt.net/scripts/autop.';
}

function getEventList() {
return array('PreItem','PrepareItemForEdit');
}

function event_PreItem($data) {
$this->doSmartParagraphs($data['item']->body);
if ( !($data['item']->more == "") ) {
   $this->doSmartParagraphs($data['item']->more);
}
}

// remove before editing if auto convert breaks had been enabled
function event_PrepareItemForEdit($data) {
$this->undoSmartParagraphs($data['item']->body);
$this->undoSmartParagraphs($data['item']->more);
}

function autop(&$pee, $br=1) {
if ($pee == '') return;

$pee = $pee . "\n"; // just to make things a little easier, pad the end
$pee = preg_replace('|<br />\s*<br />|', "\n\n", $pee);
$pee = preg_replace('!(<(?:table|ul|ol|li|pre|form|blockquote|h[1-6])[^>]*>)!', "\n$1", $pee); // Space things out a little
$pee = preg_replace('!(</(?:table|ul|ol|li|pre|form|blockquote|h[1-6])>)!', "$1\n", $pee); // Space things out a little
$pee = preg_replace("/(\r\n|\r)/", "\n", $pee); // cross-platform newlines
$pee = preg_replace("/\n\n+/", "\n\n", $pee); // take care of duplicates
$pee = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "<p>$1</p>\n", $pee); // make paragraphs, including one at the end
$pee = preg_replace('|<p>\s*?</p>|', '', $pee); // under certain strange conditions it could create a P of entirely whitespace
$pee = preg_replace("|<p>(<li.+?)</p>|", "$1", $pee); // problem with nested lists
$pee = preg_replace('|<p><blockquote([^>]*)>|i', "<blockquote$1><p>", $pee);
$pee = str_replace('</blockquote></p>', '</p></blockquote>', $pee);
$pee = preg_replace('!<p>\s*(</?(?:table|tr|td|th|div|ul|ol|li|pre|select|form|blockquote|p|h[1-6])[^>]*>)!', "$1", $pee);
$pee = preg_replace('!(</?(?:table|tr|td|th|div|ul|ol|li|pre|select|form|blockquote|p|h[1-6])[^>]*>)\s*</p>!', "$1", $pee);
if ($br) $pee = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $pee); // optionally make line breaks
$pee = preg_replace('!(</?(?:table|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|p|h[1-6])[^>]*>)\s*<br />!', "$1", $pee);
$pee = preg_replace('!<br />(\s*</?(?:p|li|div|th|pre|td|ul|ol)>)!', '$1', $pee);
$pee = preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $pee);
$pee = preg_replace_callback('!(<pre.*?>)(.*?)</pre>!s', create_function('$matches', 'return $matches[1] . str_replace(array("</p>\n<p>","<p>", "</p>", "<br />"), array("\n\n","","",""), $matches[2]) . "</pre>";'), $pee);
}

function doSmartParagraphs(&$data) {
$this->autop($data);
}

function undoSmartParagraphs(&$data) {

$data = str_replace("<p>",'',$data);
$data = str_replace("</p>\n\n","\n\n",$data);
$data = str_replace("<br />\n","\n",$data);
}

}
?><?
/*
  NP_Podcast - provide support for podcasting in Nucleus
 
  Usage:
    1) install the plugin
    2) modify the feeds/rss20 template and add <%Podcast%> inside the item tag after
       <pubDate>...</pubDate>
    3) upload the mp3 and use the skinvar <%Podcast(filename|text)%>. For offshore mp3 file that
       stored elsewhere, put in the URL directly
 
  Known issue:
    - only one podcast in per post is assumed
 
  v0.1
    - Initialize release
  v0.2 Nov 4, 2004
    - <%Podcast%> skinvar
  v0.3 Apr 14, 2005
    - add supportsFeature
    - support to torrent and mp3
    - audio.weblogs.com ping
    - able to point enclosure offshore
  v0.4 May 6, 2005
    - fix ping...
    - option to enable/disable ping
  v0.5 Sep 22, 2005
    - file name error bug fix (thanks to Andy)
 
*/
 
// plugin needs to work on Nucleus versions <=2.0 as well
if (!function_exists('sql_table'))
{
        function sql_table($name) {
                return 'nucleus_' . $name;
        }
}
 
class NP_Podcast extends NucleusPlugin {
 
  var $authorid;
 
  function getEventList() { return array('PreItem', 'PreAddItem', 'PostAddItem'); }
  function getName() { return 'Podcast'; }
  function getAuthor() { return 'Edmond Hui (admun)'; }
  function getURL() { return; }
  function getVersion() { return '0.5'; }
  function getDescription() { return 'This plugin provides podcasting support in Nucleus via a new <%Podcast%> template var'; }
  // Note: I never run this plugin on 2.0 and have no idea whether it
  //       wil work on <2.5. A user can simply chnage it to return
  //       '200' and see if it works (likely will). I will gladly
  //       change the min version to 2.0 and add the sql_table fix
  //       upon such report. 8)
  function getMinNucleusVersion() { return '250'; }
 
  function supportsFeature($what) {
    switch($what)
    {
      case 'SqlTablePrefix':
        return 1;
      default:
        return 0;
    }
  }
 
  function install() {
    $this->createOption('ping','Enable audio.weblogs.com ping','yesno','yes');
  }
 
  // This function generates the actual URL to the podcast
  function event_PreItem($data) {
    global $item;
    $item = &$data["item"];
    $this->authorid = $item->authorid;
    if (strstr($item->body . " " . $item->more, "<%Podcast(")) {
      $item->body = preg_replace_callback("#<\%Podcast\((.*?)\|(.*?)\)%\>#", array(&$this, 'replaceCallback'), $item->body);
      $item->mmore = preg_replace_callback("#<\%Podcast\((.*?)\|(.*?)\)%\>#", array(&$this, 'replaceCallback'), $item->more);
    }
  }
 
  function replaceCallback($matches) {
    global $CONF;
    $file = $matches[1];
    if ($matches[2] == '') {
      $text = $matches[1];
    } else {
      $text = $matches[2];
    }
    // not strstr...
    if (strstr($file, "http:"))
    {
      return "<div class=\"podcast\"><a href=\"" . $file . "\">" . $text . "</a></div>";
    } else {
      return "<div class=\"podcast\"><a href=\"" . $CONF['MediaURL'] . $this->authorid . "/" .  $file . "\">" . $text . "</a></div>";
    }
 
 
  }
 
  // This function generates the enclosure in RSS feed
  function doTemplateVar(&$item) {
    global $DIR_MEDIA, $CONF;
 
    // see if there is a podcast file here
    if (strstr($item->body." ".$item->more, "<div class=\"podcast\"")) {
 
      if (strstr($item->body." ".$item->more, ".mp3")) {
        $search = "/http:\/\/.*?\.mp3/i";
        $type = "audio/mpeg";
      } else {
        $search = "/http:\/\/.*?\.torrent/i";
        $type = "application/x-bittorrent";
      }
 
      $mem = MEMBER::createFromName($item->author);
      $id = $mem->getId();
      preg_match($search, $item->body." ".$item->more, $result);
      $mfile = explode("/", $result[0]);
      $file = $DIR_MEDIA . $id . '/' . $mfile[sizeof($mfile)-1];
      $size = filesize($file);
 
      $url = $result[0];
      echo "<enclosure url=\"$url\" length=\"$size\" type=\"$type\"/>";
    }
  }
 
  function event_PreAddItem($data) {
    $this->myBlogId    = $data['blog']->blogid;
    $this->draft = "no";
    $this->podcast = false;
 
    if (strstr($data['more'] . " " . $data['body'], "<%Podcast(")) {
      $this->podcast = true;
    }
 
    if ($data['draft'] == '1') {
      $this->draft = "yes";
    }
  }
 
  function event_PostAddItem($data) {
 
    if ($this->draft == "no" && $this->podcast == true && $this->getOption('ping') == "yes")
    {
      $b = new BLOG($this->myBlogId);
 
      if (!class_exists('xmlrpcmsg')) {
        global $DIR_LIBS;
        include($DIR_LIBS . 'xmlrpc.inc.php');
      }
 
      $message = new xmlrpcmsg(
                     'weblogUpdates.ping', array(
                     new xmlrpcval($b->getName(),'string'),
                     new xmlrpcval($b->getURL(),'string'),
                     ));
 
      $c = new xmlrpc_client('/RPC2', 'audiorpc.weblogs.com', 80);
 
      //$c->setDebug(1);
 
      $r = $c->send($message,15); // 15 seconds timeout...
    }
  }
}
?><item>
 <title><![CDATA[New home for Bad Sports]]></title>
 <link>http://www.bloghouston.net/podcast/item/3508</link>
<description><![CDATA[The Bad Sports podcast has a new home.

Please check out http://www.bloghouston.net/badsports

The new page offers various syndication options, so please update your newsreaders/podcatchers with the new syndication info. You don&#039;t want to miss...]]></description>
 <category>Sports Podcast</category>
 <author>_@_ (Kevin Whited)</author>
 <pubDate>Sun, 11 Jun 2006 23:39:41 +0000</pubDate>
</item>
  </channel>
</rss>