[pLog-svn] r2030 - in plog/branches/plog-1.0.1: class/dao
templates/rss
oscar at devel.plogworld.net
oscar at devel.plogworld.net
Fri May 20 09:55:21 GMT 2005
Author: oscar
Date: 2005-05-20 09:55:20 +0000 (Fri, 20 May 2005)
New Revision: 2030
Modified:
plog/branches/plog-1.0.1/class/dao/article.class.php
plog/branches/plog-1.0.1/templates/rss/rss20.template
Log:
yay! native support for rss 2.0 enclosures :)
Modified: plog/branches/plog-1.0.1/class/dao/article.class.php
===================================================================
--- plog/branches/plog-1.0.1/class/dao/article.class.php 2005-05-20 08:04:30 UTC (rev 2029)
+++ plog/branches/plog-1.0.1/class/dao/article.class.php 2005-05-20 09:55:20 UTC (rev 2030)
@@ -828,6 +828,44 @@
}
return( $this->_nextArticle );
- }
+ }
+
+ /**
+ * returns all the resources which are linked in this post. It basically looks
+ * at the "id" attribute of all links. When the resource has been added via the
+ * "add resource" pop-up window from the "new post" and "edit post" pages
+ * from the admin interface contains something like "res_XX" where "XX" is the
+ * internal id of the resource.
+ *
+ * If this id attribute is not found this method will not work. We could not find
+ * a better way to identify these resources...
+ *
+ * @return An array of GalleryResource objects containing all the resources
+ */
+ function getArticleResources()
+ {
+ include_once( PLOG_CLASS_PATH."class/data/stringutils.class.php" );
+ include_once( PLOG_CLASS_PATH."class/gallery/dao/galleryresources.class.php" );
+
+ // extract all the "res_XX" values
+ $regexp ="/<a.*id=\"res_([0-9]+)\".*>.*<\/a>/im";
+ $resources = Array();
+ $galleryResources = new GalleryResources();
+ if( preg_match_all( $regexp, $this->getText(), $out, PREG_SET_ORDER )) {
+ // process the results
+ foreach( $out as $match ) {
+ $resourceId = $match[1];
+ // try to load the resource
+ $resource = $galleryResources->getResource( $resourceId, $this->getBlog());
+ if( $resource ) {
+ // add it to the array
+ $resources[] = $resource;
+ // and continue...
+ }
+ }
+ }
+
+ return( $resources );
+ }
}
?>
Modified: plog/branches/plog-1.0.1/templates/rss/rss20.template
===================================================================
--- plog/branches/plog-1.0.1/templates/rss/rss20.template 2005-05-20 08:04:30 UTC (rev 2029)
+++ plog/branches/plog-1.0.1/templates/rss/rss20.template 2005-05-20 09:55:20 UTC (rev 2030)
@@ -3,7 +3,7 @@
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
->
+>
{$locale->setLocale("en_UK")}
<channel>
<title>{$blog->getBlog()|escape}</title>
@@ -27,7 +27,15 @@
{/foreach}
{assign var="postDate" value=$post->getDateObject()}
<pubDate>{$locale->formatDate($postDate, "%a, %d %b %Y %H:%M:%S")}</pubDate>
- <source url="{$url->rssLink("rss20")}">{$blog->getBlog()|escape}</source>
+ <source url="{$url->rssLink("rss20")}">{$blog->getBlog()|escape}</source>
+ {foreach from=$post->getArticleResources() item=resource}
+ {** please uncomment the line below if you'd like to server everything but images, instead of
+ only audio and video **}
+ {** if !$resource->isImage() **}
+ {if $resource->isSound() || $resource->isVideo()}
+ <enclosure type="{$resource->getMimeType()}" length="{$resource->getFileSize()}" url="{$url->resourceDownloadLink($resource)}" />
+ {/if}
+ {/foreach}
</item>
{/foreach}
</channel>
More information about the pLog-svn
mailing list