[pLog-svn] r6714 - in plugins/branches/lifetype-1.2: . rssimport rssimport/class rssimport/class/action rssimport/class/view rssimport/locale rssimport/templates

Jon Daley plogworld at jon.limedaley.com
Mon Sep 1 22:43:12 EDT 2008


I haven't looked into it yet, but I got this error every time I import the 
feed (google reader shared)

Warning: Invalid argument supplied for foreach() in 
/home/jondaley/www/plog/class/view/defaultview.class.php on line 41

Also, it is parsing the RSS feed incorrectly, and generating text like 
this:

 	<li><a 
href="http://blog.wired.com/geekdad/2008/09/geekdad-puzzle.htmlhttp://blog.wired.com/geekdad/">GeekDad 
Puzzle of the Week: Cross Number PrimeGeekdad </a></li>

You mentioned you use it for google reader, so it seems odd that it would 
fail for me?

Lastly, the ideal way to make it work with google reader is to setup a 
daily cron job to look at a feed url that only shows posts on that day, 
and it is smart enough to not generate a post if there aren't any links? 
i.e. if I simply give it my google reader url, then it will always 
generate links for all of my shared items each time, even though it 
already displayed them last time, right?

Looks like I might have some work to make this work how I want it to, but 
a good start for me anyway.

On Thu, 21 Aug 2008, Paul Westbrook wrote:

> Hello,
>   This creates a new post everytime the "import feed action" gets run
> (assuming that the right access key is specified).
>
>   The reason that I wrote this was to have a way to create a daily post that
> contains links to my "shared" items.  For example, my del.icio.us bookmarks
> and Google Reader Shared items.  This timing is why I rely on an external
> action to call the plugin.
>
> --Paul
>
> On Wednesday 20 August 2008 08:15:59 Jon Daley wrote:
>>  	Very nice.  I have been aiming to do something like this.  How
>> does this work - it has one post that gets updated?  Or it makes a new
>> post with the same title every time the rss feed changes?
>>
>> On Wed, 20 Aug 2008, pwestbro at devel.lifetype.net wrote:
>>> Author: pwestbro
>>> Date: 2008-08-20 17:48:02 -0400 (Wed, 20 Aug 2008)
>>> New Revision: 6714
>>>
>>> Added:
>>>   plugins/branches/lifetype-1.2/rssimport/
>>>   plugins/branches/lifetype-1.2/rssimport/README.txt
>>>   plugins/branches/lifetype-1.2/rssimport/class/
>>>   plugins/branches/lifetype-1.2/rssimport/class/action/
>>>
>>> plugins/branches/lifetype-1.2/rssimport/class/action/importrssfeedaction.
>>> class.php
>>> plugins/branches/lifetype-1.2/rssimport/class/action/pluginrssimportconfi
>>> gaction.class.php
>>> plugins/branches/lifetype-1.2/rssimport/class/action/pluginrssimportupdat
>>> econfigaction.class.php
>>> plugins/branches/lifetype-1.2/rssimport/class/view/
>>>
>>> plugins/branches/lifetype-1.2/rssimport/class/view/pluginrssimportconfigv
>>> iew.class.php plugins/branches/lifetype-1.2/rssimport/locale/
>>>   plugins/branches/lifetype-1.2/rssimport/locale/locale_en_UK.php
>>>   plugins/branches/lifetype-1.2/rssimport/pluginrssimport.class.php
>>>   plugins/branches/lifetype-1.2/rssimport/templates/
>>>   plugins/branches/lifetype-1.2/rssimport/templates/rssimport.template
>>> Log:
>>> The rssimport plugin creates a post with the content of an rss feed.  One
>>> use of this is to create a daily post of online activities  (i.e. posted
>>> Flickr photos, Twitter tweets, delicious bookmarks, Google Reader shared
>>> items.)
>>>
>>>
>>> [USAGES]:
>>> 1. Upload: Upload all the extract files and directories to
>>>   $LifeType_Install_Dir/plugin/rssimport
>>> 2. Specify the url to the rss feed to be imported
>>> 3. Specify a title for the generated posts
>>> 4. Speciy a category for the generated posts
>>> 5. (Optionally) Specify a different access key needed to make a post
>>> 6. Press Update
>>>
>>> Now when you access the "Url to import feed", and there are a post will
>>> be created
>>>
>>>
>>>
>>>
>>> Added: plugins/branches/lifetype-1.2/rssimport/README.txt
>>>
> ===================================================================
>>> --- plugins/branches/lifetype-1.2/rssimport/README.txt
>>>      (rev 0) +++
>>> plugins/branches/lifetype-1.2/rssimport/README.txt	2008-08-20 21:48:02
>>> UTC (rev 6714) @@ -0,0 +1,52 @@
>>> +[DESCRIPTION]
>>> +The rssimport plugin creates a post with the content of an rss feed.
>>> One +use of this is to create a daily post of online activities  (i.e.
>>> posted +Flickr photos, Twitter tweets, delicious bookmarks, Google Reader
>>> shared +items.)
>>> +
>>> +[USAGES]:
>>> +1. Upload: Upload all the extract files and directories to
>>> +   $LifeType_Install_Dir/plugin/rssimport
>>> +2. Specify the url to the rss feed to be imported
>>> +3. Specify a title for the generated posts
>>> +4. Speciy a category for the generated posts
>>> +5. (Optionally) Specify a different access key needed to make a post
>>> +6. Press Update
>>> +
>>> +Now when you access the "Url to import feed", and there are a post will
>>> be created +
>>> +
>>> +[ADVANCED USAGES]
>>> +Creating a rss feed for the last 24 hours of posts.
>>> +
>>> +    This Yahoo Pipe will filter a feed by date
>>> +    http://pipes.yahoo.com/pipes/pipe.info?_id=SJDIxkAa3BG7s6ZYmLokhQ
>>> +
>>> +Automatically creating posts
>>> +
>>> +    On Linux and Max OS X, it is easy to schedule access to the "Url to
>>> +    import feed" with cron.  For a cron tutorial
>>> +    http://www.clickmojo.com/code/cron-tutorial.html
>>> +
>>> +
>>> +[SECURITY CONCERNS]
>>> +The rssimport plugin does allow external processes to create posts in a
>>> +LifeType install.  When first configured, the rssimport plugin creates a
>>> +random, relatively unique accessKey.  This key is required to be
>>> specified +in a parameter of the url in order for a post to be created.
>>> +
>>> +It is possible, that if the accessKey is discovered, that a third party
>>> can +create posts.  The third party will not be able to specify the
>>> content of +these posts, as the feed url is in retrieved from the plugin
>>> config. +
>>> +Followon release may add the following addition enhancement.
>>> +   1) Allow a list of ip address/host names to be specified where
>>> posting is +   allowed
>>> +
>>> +
>>> +
>>> +[TODO]
>>> +1) Add the ability to specify a list of the ip address that are
>>> permitted to create the posts. +2) Add an option to include the
>>> description of the rss items or a summary +int the pos
>>> +3) Change the title field, to not require characters to be escaped
>>>
>>> Added:
>>> plugins/branches/lifetype-1.2/rssimport/class/action/importrssfeedaction.
>>> class.php
>>>
> ===================================================================
> ---
>>> plugins/branches/lifetype-1.2/rssimport/class/action/importrssfeedaction.
>>> class.php	                        (rev 0) +++
>>> plugins/branches/lifetype-1.2/rssimport/class/action/importrssfeedaction.
>>> class.php	2008-08-20 21:48:02 UTC (rev 6714) @@ -0,0 +1,157 @@
>>> +<?php
>>> +
>>> +    lt_include( PLOG_CLASS_PATH."class/action/blogaction.class.php" );
>>> +    lt_include(
>>> PLOG_CLASS_PATH."class/view/plugintemplatedview.class.php" ); +
>>> lt_include( PLOG_CLASS_PATH."class/view/errorview.class.php" ); +
>>> +    class ImportRssFeedAction extends BlogAction
>>> +    {
>>> +	var $_enteredPassword;
>>> +	var $_html;
>>> +
>>> +        function ImportRssFeedAction( $actionInfo, $request )
>>> +        {
>>> +
>>> +            $this->BlogAction( $actionInfo, $request );
>>> +        }
>>> +
>>> +        function perform()
>>> +        {
>>> +	   // Get and confirm the password
>>> +	    $this->_enteredPassword =  $this->_request->getValue( "accessKey"
>>> ); +
>>> +	    $this->_html = "";
>>> +
>>> +	    // Check the ip address to make sure that it is the list of
>>> +	    // allowd ip address
>>> +
>>> +	    $blogSettings = $this->_blogInfo->getSettings();
>>> +	    if ($blogSettings->getValue( "plugin_rssimport_enabled" ) == FALSE)
>>> +	    {
>>> +		$this->_view = new ErrorView( $this->_blogInfo );
>>> +		$this->_view->setValue( "message", "Plugin not enabled" );
>>> +
>>> +		$this->setCommonData();
>>> +		return true;
>>> +	    }
>>> +
>>> +	    $feedurl = $blogSettings->getValue( "plugin_rssimport_feedurl" );
>>> +	    $accessKey = $blogSettings->getValue( "plugin_rssimport_accessKey"
>>> ); +//	    $accessHosts = $blogSettings->getValue(
>>> "plugin_rssimport_accessHosts" ); +	    $titleFormat =
>>> $blogSettings->getValue( "plugin_rssimport_titleFormat" ); +
>>> +	    // Compare the access key to that which is in the accessKey
>>> parameter +	    if ($accessKey != $this->_enteredPassword)
>>> +	    {
>>> +		// Passwords don't match
>>> +		$this->_view = new ErrorView( $this->_blogInfo );
>>> +		$this->_view->setValue( "message", "Incorrect Access Key" );
>>> +
>>> +		$this->setCommonData();
>>> +		return true;
>>> +
>>> +	    }
>>> +
>>> +//	    if ( $accessHosts != null && $accessHosts != "" )
>>> +//	    {
>>> +//
>>> +//	    }
>>> +
>>> +
>>> +    	    lt_include(
>>> PLOG_CLASS_PATH."class/xml/rssparser/rssparser.class.php" ); +
>>> +	    $parser = new RSSParser();
>>> +
>>> +	    if ( $parser->parse($feedurl) == FALSE )
>>> +	    {
>>> +		// failed to parse the feed
>>> +		$this->_view = new ErrorView( $this->_blogInfo );
>>> +		$this->_view->setValue( "message", "Failed to parse feed" );
>>> +
>>> +		$this->setCommonData();
>>> +		return true;
>>> +	    }
>>> +
>>> +	    $items = $parser->getItems();
>>> +
>>> +	    // Now add each of the items to our html documen that we are
>>> building +	    foreach ($items as $item) {
>>> +	    	    $this->addItem($item);
>>> +	    }
>>> +
>>> +	    if ( $this->_html == "" )
>>> +	    {
>>> +		// There were no items
>>> +		$this->_view = new ErrorView( $this->_blogInfo );
>>> +		$this->_view->setValue( "message", "No items in feed" );
>>> +
>>> +		$this->setCommonData();
>>> +		return true;
>>> +	    }
>>> +
>>> +	    // Now create an article with the html as the body,
>>> +
>>> +    	    lt_include( PLOG_CLASS_PATH.'class/dao/articles.class.php' );
>>> +   	    $articles = new Articles();
>>> +
>>> +            $postText = Textfilter::xhtmlize("<ul>" . $this->_html .
>>> "</ul>"); +
>>> +	    $postTitle = date($titleFormat);
>>> +
>>> +
>>> +	    // XXX_PW This should pull the category from the settings
>>> +	    // Get the default category
>>> +    	    lt_include(
>>> PLOG_CLASS_PATH.'class/dao/articlecategories.class.php' ); +
>>> $category = new ArticleCategories();
>>> +            $cats =
>>> $category->getBlogCategories($this->_blogInfo->getId()); +
>>> +	    // some protection again blogs without categories
>>> +            if( !$cats ) {
>>> +		$this->_view = new ErrorView( $this->_blogInfo );
>>> +		$this->_view->setValue( "message", "Error getting categories" );
>>> +
>>> +		$this->setCommonData();
>>> +                return true;
>>> +            }
>>> +
>>> +
>>> +	    $idCategory = $blogSettings->getValue(
>>> "plugin_rssimport_article_category_id" ); +
>>> +            $article  = new Article( $postTitle,
>>> +			             $postText,
>>> +				     Array( $idCategory ), // catid
>>> +                                     $this->_blogInfo->getOwner(),
>>> +				     $this->_blogInfo->getId(),
>>> +				     POST_STATUS_PUBLISHED,
>>> +									 0 );
>>> +            $article->setDateObject( new Timestamp());
>>> +            $article->setCommentsEnabled( true );
>>> +
>>> +
>>> +	    // add the article to the db, finally
>>> +	    if( $articles->addArticle( $article )) {
>>> +    	    	lt_include( PLOG_CLASS_PATH."class/view/defaultview.class.php"
>>> ); +		$this->_view = new DefaultView( $this->_blogInfo );
>>> +	    }
>>> +	    else {
>>> +		$this->_view = new ErrorView( $this->_blogInfo );
>>> +		$this->_view->setValue( "message", "Error adding article to the
>>> database" ); +  	   }
>>> +
>>> +	   $this->setCommonData();
>>> +
>>> +
>>> +            return true;
>>> +        }
>>> +
>>> +	function addItem( $item )
>>> +	{
>>> +		// Add this item to the html text
>>> +	    	$this->_html .= "<li>";
>>> +	    	$this->_html .= "<a href=\"" . $item->getLink() . "\">" .
>>> $item->getTitle() . " </a>"; +	    	$this->_html .= "</li>";
>>> +	}
>>> +
>>> +
>>> +    }
>>> +?>
>>>
>>> Added:
>>> plugins/branches/lifetype-1.2/rssimport/class/action/pluginrssimportconfi
>>> gaction.class.php
>>>
> ===================================================================
> ---
>>> plugins/branches/lifetype-1.2/rssimport/class/action/pluginrssimportconfi
>>> gaction.class.php	                        (rev 0) +++
>>> plugins/branches/lifetype-1.2/rssimport/class/action/pluginrssimportconfi
>>> gaction.class.php	2008-08-20 21:48:02 UTC (rev 6714) @@ -0,0 +1,45 @@
>>> +<?php
>>> +
>>> +    /*
>>> +    Copyright 2006, 2008 Paul Westbrook (paul at westbrooks.org)
>>> +
>>> +    This program is free software; you can redistribute it and/or modify
>>> +    it under the terms of the GNU General Public License as published by
>>> +    the Free Software Foundation; either version 2 of the License, or
>>> +    (at your option) any later version.
>>> +
>>> +    This program is distributed in the hope that it will be useful,
>>> +    but WITHOUT ANY WARRANTY; without even the implied warranty of
>>> +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>>> +    GNU General Public License for more details.
>>> +
>>> +    You should have received a copy of the GNU General Public License
>>> +    along with this program; if not, write to the Free Software
>>> +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
>>>  USA +    */
>>> +
>>> +
>>> +	lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php"
>>> ); +	lt_include(
>>> PLOG_CLASS_PATH."plugins/rssimport/class/view/pluginrssimportconfigview.c
>>> lass.php" ); +
>>> +	/**
>>> +	 * shows a form with the current configuration
>>> +	 */
>>> +	class PluginRssImportConfigAction extends AdminAction
>>> +	{
>>> +
>>> +		function PluginRssImportConfigAction( $actionInfo, $request )
>>> +		{
>>> +			$this->AdminAction( $actionInfo, $request );
>>> +		}
>>> +
>>> +		function perform()
>>> +		{
>>> +		        $this->_view = new PluginRssImportConfigView( $this->_blogInfo
>>> ); +
>>> +			$this->setCommonData();
>>> +
>>> +			return true;
>>> +		}
>>> +	}
>>> +?>
>>>
>>> Added:
>>> plugins/branches/lifetype-1.2/rssimport/class/action/pluginrssimportupdat
>>> econfigaction.class.php
>>>
> ===================================================================
> ---
>>> plugins/branches/lifetype-1.2/rssimport/class/action/pluginrssimportupdat
>>> econfigaction.class.php	                        (rev 0) +++
>>> plugins/branches/lifetype-1.2/rssimport/class/action/pluginrssimportupdat
>>> econfigaction.class.php	2008-08-20 21:48:02 UTC (rev 6714) @@ -0,0 +1,165
>>> @@
>>> +<?php
>>> +
>>> +    /*
>>> +    Copyright 2006, 2008 Paul Westbrook (paul at westbrooks.org)
>>> +
>>> +    This program is free software; you can redistribute it and/or modify
>>> +    it under the terms of the GNU General Public License as published by
>>> +    the Free Software Foundation; either version 2 of the License, or
>>> +    (at your option) any later version.
>>> +
>>> +    This program is distributed in the hope that it will be useful,
>>> +    but WITHOUT ANY WARRANTY; without even the implied warranty of
>>> +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>>> +    GNU General Public License for more details.
>>> +
>>> +    You should have received a copy of the GNU General Public License
>>> +    along with this program; if not, write to the Free Software
>>> +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
>>>  USA +    */
>>> +
>>> +	lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php"
>>> ); +	lt_include(
>>> PLOG_CLASS_PATH."plugins/rssimport/class/view/pluginrssimportconfigview.c
>>> lass.php" ); +	lt_include(
>>> PLOG_CLASS_PATH."class/data/validator/httpurlvalidator.class.php" );
>>> +	lt_include(
>>> PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" ); +
>>> +
>>> +	/**
>>> +	 * updates the plugin configuration
>>> +	 */
>>> +	class PluginRssImportUpdateConfigAction extends AdminAction
>>> +	{
>>> +		var $_pluginEnabled;
>>> +		var $_feedurl;
>>> +		var $_accessKey;
>>> +//		var $_accessHosts;
>>> +		var $_titleFormat;
>>> +		var $_categoryId;
>>> +
>>> +		function PluginRssImportUpdateConfigAction( $actionInfo, $request )
>>> +		{
>>> +			$this->AdminAction( $actionInfo, $request );
>>> +		}
>>> +
>>> +		function validate()
>>> +		{
>>> +
>>> +			$this->_pluginEnabled = $this->_request->getValue( "pluginEnabled" );
>>> +            		$this->_pluginEnabled = ($this->_pluginEnabled != "" );
>>> +
>>> +			$this->_feedurl = $this->_request->getValue( "feedurl" );
>>> +
>>> +			$this->_accessKey = $this->_request->getValue( "accessKey" );
>>> +
>>> +//			$this->_accessHosts = $this->_request->getValue( "accessHosts" );
>>> +
>>> +			$this->_titleFormat = $this->_request->getValue( "titleFormat" );
>>> +			$this->_categoryId = $this->_request->getValue( "categoryId" );
>>> +
>>> +			// This should validate the url
>>> +			$val = new HttpUrlValidator();
>>> +            		if( !$val->validate($this->_feedurl) ) {
>>> +                	    $this->_view = new PluginRssImportConfigView(
>>> $this->_blogInfo ); +                	    $this->_view->setErrorMessage(
>>> $this->_locale->tr("rssimport_error_url")); +
>>> $this->setCommonData();
>>> +
>>> +                	    return false;
>>> +            		}
>>> +
>>> +			// Make sure that key is specied
>>> +			if (!$this->_accessKey || $this->_accessKey == "")
>>> +			{
>>> +                	    $this->_view = new PluginRssImportConfigView(
>>> $this->_blogInfo ); +                	    $this->_view->setErrorMessage(
>>> $this->_locale->tr("rssimport_error_missing_accesskey")); +
>>>  	    $this->setCommonData();
>>> +
>>> +                	    return false;
>>> +			}
>>> +
>>> +			// This should validate the url
>>> +			$val = new StringValidator();
>>> +            		if( !$val->validate($this->_accessKey) ) {
>>> +                	    $this->_view = new PluginRssImportConfigView(
>>> $this->_blogInfo ); +                	    $this->_view->setErrorMessage(
>>> $this->_locale->tr("rssimport_error_invalid_accesskey")); +
>>>  	    $this->setCommonData();
>>> +
>>> +                	    return false;
>>> +            		}
>>> +
>>> +			// This should validate the url
>>> +			$val = new StringValidator();
>>> +            		if( !$val->validate($this->_accessKey) ) {
>>> +                	    $this->_view = new PluginRssImportConfigView(
>>> $this->_blogInfo ); +                	    $this->_view->setErrorMessage(
>>> $this->_locale->tr("rssimport_error_invalid_accesskey")); +
>>>  	    $this->setCommonData();
>>> +
>>> +                	    return false;
>>> +            		}
>>> +
>>> +			// Make sure that titleFormat is specied
>>> +			if (!$this->_titleFormat || $this->_titleFormat == "")
>>> +			{
>>> +                	    $this->_view = new PluginRssImportConfigView(
>>> $this->_blogInfo ); +                	    $this->_view->setErrorMessage(
>>> $this->_locale->tr("rssimport_error_missing_titleformat")); +
>>>    	    $this->setCommonData();
>>> +
>>> +                	    return false;
>>> +			}
>>> +
>>> +			// This should validate the url
>>> +			$val = new StringValidator();
>>> +            		if( !$val->validate($this->_titleFormat) ) {
>>> +                	    $this->_view = new PluginRssImportConfigView(
>>> $this->_blogInfo ); +                	    $this->_view->setErrorMessage(
>>> $this->_locale->tr("rssimport_error_invalid_titleformat")); +
>>>    	    $this->setCommonData();
>>> +
>>> +                	    return false;
>>> +            		}
>>> +
>>> +			return true;
>>> +		}
>>> +
>>> +		function perform()
>>> +		{
>>> +		        // update the plugin configurations to blog setting
>>> +			$blogSettings = $this->_blogInfo->getSettings();
>>> +			$blogSettings->setValue( "plugin_rssimport_enabled",
>>> $this->_pluginEnabled ); +
>>> +			$blogSettings->setValue( "plugin_rssimport_feedurl", $this->_feedurl
>>> ); +
>>> +			$blogSettings->setValue( "plugin_rssimport_accessKey",
>>> $this->_accessKey); +
>>> +//			$blogSettings->setValue( "plugin_rssimport_accessHosts",
>>> $this->_accessHosts); +
>>> +			$blogSettings->setValue( "plugin_rssimport_titleFormat",
>>> $this->_titleFormat); +
>>> +			$blogSettings->setValue( "plugin_rssimport_article_category_id",
>>> $this->_categoryId ); +			$this->_blogInfo->setSettings( $blogSettings );
>>> +
>>> +
>>> +			// save the blogs settings
>>> +			$blogs = new Blogs();
>>> +            		if( !$blogs->updateBlog( $this->_blogInfo )) {
>>> +                	    $this->_view = new PluginRssImportConfigView(
>>> $this->_blogInfo ); +                	    $this->_view->setErrorMessage(
>>> $this->_locale->tr("error_updating_settings")); +
>>> $this->setCommonData();
>>> +
>>> +                	    return false;
>>> +            		}
>>> +
>>> +			// if everything went ok...
>>> +			$this->_blogInfo->setSettings( $blogSettings );
>>> +            		$this->_session->setValue( "blogInfo", $this->_blogInfo );
>>> +            		$this->saveSession();
>>> +
>>> +			$this->_view = new PluginRssImportConfigView( $this->_blogInfo );
>>> +			$this->_view->setSuccessMessage(
>>> $this->_locale->tr("rssimport_settings_saved_ok"));
>>> +			$this->setCommonData();
>>> +
>>> +			// clear the cache
>>> +			CacheControl::resetBlogCache( $this->_blogInfo->getId());
>>> +
>>> +			return true;
>>> +		}
>>> +	}
>>> +?>
>>>
>>> Added:
>>> plugins/branches/lifetype-1.2/rssimport/class/view/pluginrssimportconfigv
>>> iew.class.php
>>>
> ===================================================================
> ---
>>> plugins/branches/lifetype-1.2/rssimport/class/view/pluginrssimportconfigv
>>> iew.class.php	                        (rev 0) +++
>>> plugins/branches/lifetype-1.2/rssimport/class/view/pluginrssimportconfigv
>>> iew.class.php	2008-08-20 21:48:02 UTC (rev 6714) @@ -0,0 +1,94 @@
>>> +<?php
>>> +    /*
>>> +    Copyright 2006, 2008 Paul Westbrook (paul at westbrooks.org)
>>> +
>>> +    This program is free software; you can redistribute it and/or modify
>>> +    it under the terms of the GNU General Public License as published by
>>> +    the Free Software Foundation; either version 2 of the License, or
>>> +    (at your option) any later version.
>>> +
>>> +    This program is distributed in the hope that it will be useful,
>>> +    but WITHOUT ANY WARRANTY; without even the implied warranty of
>>> +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>>> +    GNU General Public License for more details.
>>> +
>>> +    You should have received a copy of the GNU General Public License
>>> +    along with this program; if not, write to the Free Software
>>> +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
>>>  USA +    */
>>> +
>>> +
>>> +	lt_include(
>>> PLOG_CLASS_PATH."class/view/admin/adminplugintemplatedview.class.php" );
>>> +
>>> +	/**
>>> +	 * implements the main view of the feed reader plugin
>>> +	 */
>>> +	class PluginRssImportConfigView extends AdminPluginTemplatedView
>>> +	{
>>> +
>>> +
>>> +		function PluginRssImportConfigView( $blogInfo )
>>> +		{
>>> +			$this->AdminPluginTemplatedView( $blogInfo, "rssimport", "rssimport"
>>> ); +
>>> +		}
>>> +
>>> +		function render()
>>> +		{
>>> +			// load some configuration settings
>>> +			$blogSettings = $this->_blogInfo->getSettings();
>>> +			$pluginEnabled = $blogSettings->getValue( "plugin_rssimport_enabled"
>>> ); +
>>> +			$feedurl = $blogSettings->getValue( "plugin_rssimport_feedurl" );
>>> +
>>> +			$accessKey = $blogSettings->getValue( "plugin_rssimport_accessKey" );
>>> +			// If accessKey is not set, generate a new one
>>> +			if ( $accessKey == null || $accessKey == "" )
>>> +			{
>>> +			    $rg =& $this->_blogInfo->getBlogRequestGenerator();
>>> +			    $rg->blogLink();
>>> +
>>> +			    // Generate a unique accessKey for this plugin
>>> +			    $accessKey = md5($rg->blogLink() . time());
>>> +			}
>>> +
>>> +//			$accessHosts = $blogSettings->getValue(
>>> "plugin_rssimport_accessHosts" ); +
>>> +			// Get the title format string
>>> +			$titleFormat = $blogSettings->getValue(
>>> "plugin_rssimport_titleFormat" ); +			if ( $titleFormat == null ||
>>> $titleFormat == "" )
>>> +			{
>>> +			    $locale = $this->_blogInfo->getLocale();
>>> +			    $titleFormat = $locale->tr("rssimport_default_titleformat");
>>> +			}
>>> +
>>> +			$categoryId = $blogSettings->getValue(
>>> "plugin_rssimport_article_category_id" ); +
>>> +			// fetch all the current article categories
>>> +			lt_include( PLOG_CLASS_PATH."class/dao/articlecategories.class.php");
>>> +			$categories = new ArticleCategories();
>>> +			$blogCategories = $categories->getBlogCategories(
>>> $this->_blogInfo->getId()); +
>>> +			// get the update url from rssimport plugin and pass to the plugin
>>> setting view +			$plugins = $this->_pm->getPlugins();
>>> +			$this->setValue( 'importRssUrl',
>>> $plugins['rssimport']->getImportRssUrl($accessKey) ); +
>>> +
>>> +			// create a view and export the settings to the template
>>> +			$this->setValue( "pluginEnabled", $pluginEnabled );
>>> +
>>> +			$this->setValue( "feedurl", $feedurl );
>>> +
>>> +			$this->setValue( "accessKey", $accessKey );
>>> +
>>> +//			$this->setValue( "accessHosts", $accessHosts );
>>> +
>>> +			$this->setValue( "titleFormat", $titleFormat );
>>> +
>>> +			$this->setValue( "categoryId", $categoryId );
>>> +			$this->setValue( "categories", $blogCategories );
>>> +
>>> +			parent::render();
>>> +		}
>>> +	}
>>> +?>
>>>
>>> Added: plugins/branches/lifetype-1.2/rssimport/locale/locale_en_UK.php
>>>
> ===================================================================
>>> --- plugins/branches/lifetype-1.2/rssimport/locale/locale_en_UK.php
>>>                   (rev 0) +++
>>> plugins/branches/lifetype-1.2/rssimport/locale/locale_en_UK.php	2008-08-2
>>> 0 21:48:02 UTC (rev 6714) @@ -0,0 +1,32 @@
>>> +<?php
>>> +$messages["manageIntegrationPlugins"] = "Integration Management";
>>> +$messages["rssimport"] = "RSS Import";
>>> +
>>> +$messages["rssimport_plugin_enabled"] = "Enable this plugin";
>>> +$messages["rssimport_accessKey"] = "Access Key that is required to
>>> import a feed"; +$messages["rssimport_accessHosts"] = "IP address that
>>> are allowed to trigger a feed to be imported (leave blank to allow allow
>>> all hosts)"; +$messages["rssimport_feedurl"] = "Url of the feed to
>>> fetch";
>>> +$messages["rssimport_titleformat"] = "Format string that should be used
>>> for the titles of the new posts.  See <a
>>> href='http://us3.php.net/manual/en/function.date.php'>this page</a> for
>>> format parameters"; +$messages["rssimport_articles_categories_help"] =
>>> "In which category would you like articles posted to be categorized?";
>>> +$messages["rssimport_plugin"] = "RSS Import Plugin";
>>> +
>>> +$messages["detail"] = "Detail";
>>> +
>>> +$messages["rssimport_settings_saved_ok"] = "RSS Import settings saved
>>> successfully!"; +$messages["rssimport_error_url"] = "Invalid url
>>> specified ";
>>> +$messages["rssimport_error_missing_accesskey"] = "Access Key needs to be
>>> specified "; +$messages["rssimport_error_invalid_accesskey"] = "Invalid
>>> Access Key"; +$messages["rssimport_error_missing_titleformat"] = "Title
>>> Format needs to be specified";
>>> +$messages["rssimport_error_invalid_titleformat"] = "Invalid Title
>>> Format"; +
>>> +
>>> +$messages["label_configuration"] = "Configuration";
>>> +$messages["label_enable"] = "Enable";
>>> +$messages["label_rssimport_feedurl"] = "Feed URL";
>>> +$messages["label_rssimport_accessKey"] = "Access Key";
>>> +$messages["label_rssimport_accessHosts"] = "Allowed hosts";
>>> +$messages["label_rssimport_importurl"] = "Url to import feed";
>>> +$messages["label_rssimport_titleformat"] = "Title Format String";
>>> +
>>> +$messages["rssimport_default_titleformat"] = "\l\i\\n\k\s \f\o\\r F j,
>>> Y"; +?>
>>>
>>> Added: plugins/branches/lifetype-1.2/rssimport/pluginrssimport.class.php
>>>
> ===================================================================
>>> --- plugins/branches/lifetype-1.2/rssimport/pluginrssimport.class.php
>>>                     (rev 0) +++
>>> plugins/branches/lifetype-1.2/rssimport/pluginrssimport.class.php	2008-08
>>> -20 21:48:02 UTC (rev 6714) @@ -0,0 +1,93 @@
>>> +<?php
>>> +    /*
>>> +    Copyright 2006, 2008 Paul Westbrook (paul at westbrooks.org)
>>> +
>>> +    This program is free software; you can redistribute it and/or modify
>>> +    it under the terms of the GNU General Public License as published by
>>> +    the Free Software Foundation; either version 2 of the License, or
>>> +    (at your option) any later version.
>>> +
>>> +    This program is distributed in the hope that it will be useful,
>>> +    but WITHOUT ANY WARRANTY; without even the implied warranty of
>>> +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>>> +    GNU General Public License for more details.
>>> +
>>> +    You should have received a copy of the GNU General Public License
>>> +    along with this program; if not, write to the Free Software
>>> +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
>>>  USA +    */
>>> +
>>> +
>>> +
>>> +	lt_include( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php" );
>>> +	lt_include( PLOG_CLASS_PATH."class/plugin/pluginmanager.class.php" );
>>> +
>>> +
>>> +	class PluginRssImport extends PluginBase
>>> +	{
>>> +		var $pluginEnabled;
>>> +
>>> +		function PluginRssImport( $source = "" )
>>> +		{
>>> +			$this->PluginBase($source);
>>> +
>>> +			$this->id      = "rssimport";
>>> +			$this->author  = "Paul Westbrook";
>>> +			$this->desc    = "The Rss Import plugin imports an rss feed and
>>> creates an article with the contentss"; +			$this->version = "20080715";
>>> +
>>> +			$this->locales = Array( "en_UK");
>>> +
>>> +			if( $source == "admin" )
>>> +				$this->initAdmin();
>>> +			else
>>> +				$this->init();
>>> +		}
>>> +
>>> +		function init()
>>> +		{
>>> +			$this->registerBlogAction( "importFeed", "ImportRssFeedAction" );
>>> +		}
>>> +
>>> +
>>> +		function initAdmin()
>>> +		{
>>> +		        $this->registerAdminAction( "rssImportConfig",
>>> "PluginRssImportConfigAction" ); +			$this->registerAdminAction(
>>> "updateRssImportConfig", "PluginRssImportUpdateConfigAction" ); +
>>> +			$menu =& Menu::getMenu();
>>> +			if( !$menu->entryExists(
>>> "/menu/controlCenter/manageIntegrationPlugins" ))
>>> +				$this->addMenuEntry( "/menu/controlCenter",
>>> "manageIntegrationPlugins", "", "", true, false ); +
>>> +			$this->addMenuEntry( "/menu/controlCenter/manageIntegrationPlugins",
>>> "rssimport", "?op=rssImportConfig", "" ); +		}
>>> +
>>> +		function register()
>>> +		{
>>> +		    $blogSettings = $this->blogInfo->getSettings();
>>> +		    $this->pluginEnabled = $blogSettings->getValue(
>>> "plugin_rssimport_enabled" ); +
>>> +		    $this->accessKey = $blogSettings->getValue(
>>> "plugin_rssimport_accessKey" ); +		}
>>> +
>>> +	    	function isEnabled()
>>> +	    	{
>>> +			return $this->pluginEnabled;
>>> +	    	}
>>> +
>>> +		function getImportRssUrl($accessKey)
>>> +		{
>>> +			lt_include( PLOG_CLASS_PATH."class/net/rawrequestgenerator.class.php"
>>> ); +
>>> + 			$rg = new RawRequestGenerator($this->blogInfo);
>>> +
>>> +	            	$rg->addParameter( "op", "importFeed" );
>>> +            		$rg->addParameter( "accessKey", $accessKey);
>>> +
>>> +            		$importRssUrl = $rg->getIndexUrl().$rg->getRequest();
>>> +
>>> +			return $importRssUrl;
>>> +		}
>>> +
>>> +	}
>>> +?>
>>>
>>> Added:
>>> plugins/branches/lifetype-1.2/rssimport/templates/rssimport.template
>>>
> ===================================================================
> ---
>>> plugins/branches/lifetype-1.2/rssimport/templates/rssimport.template
>>>                    (rev 0) +++
>>> plugins/branches/lifetype-1.2/rssimport/templates/rssimport.template	2008
>>> -08-20 21:48:02 UTC (rev 6714) @@ -0,0 +1,65 @@
>>> +{include file="$admintemplatepath/header.template"}
>>> +{include file="$admintemplatepath/navigation.template" showOpt=rssimport
>>> title=$locale->tr("rssimport_plugin")} +<form name="commentPluginConfig"
>>> method="post">
>>> + <fieldset class="inputField">
>>> + <legend>{$locale->tr("label_configuration")}</legend>
>>> +  {include file="$admintemplatepath/successmessage.template"}
>>> +  {include file="$admintemplatepath/errormessage.template"}
>>> +  <div class="field">
>>> +   <label for="pluginEnabled">{$locale->tr("label_enable")}</label>
>>> +   <div class="formHelp">
>>> +    <input class="checkbox" type="checkbox" name="pluginEnabled"
>>> id="pluginEnabled" {if $pluginEnabled} checked="checked" {/if} value="1"
>>> />{$locale->tr("rssimport_plugin_enabled")} +   </div>
>>> +  </div>
>>> +
>>> +  <div class="field">
>>> +   <label
>>> for="accessKey">{$locale->tr("label_rssimport_accessKey")}</label> +
>>> <span class="required">*</span>
>>> +   <div class="formHelp">{$locale->tr("rssimport_accessKey")}
>>> +     <input class="text" type="text" name="accessKey" id="accessKey"
>>> value="{$accessKey}" width="10" /> +   </div>
>>> +  </div>
>>> +
>>> +  <div class="field">
>>> +   <label for="feedurl">{$locale->tr("label_rssimport_feedurl")}</label>
>>> +   <span class="required">*</span>
>>> +   <div class="formHelp">{$locale->tr("rssimport_feedurl")}
>>> +     <input class="text" type="text" name="feedurl" id="feedurl"
>>> value="{$feedurl}" width="10" /> +   </div>
>>> +  </div>
>>> +
>>> +  <div class="field">
>>> +   <label
>>> for="feedurl">{$locale->tr("label_rssimport_titleformat")}</label> +
>>> <span class="required">*</span>
>>> +   <div class="formHelp">{$locale->tr("rssimport_titleformat")}
>>> +     <input class="text" type="text" name="titleFormat" id="titleFormat"
>>> value="{$titleFormat}" width="10" /> +   </div>
>>> +  </div>
>>> +
>>> +  <!-- article categories -->
>>> +  <div class="field">
>>> +   <label for="categoryId">{$locale->tr("posts")}</label>
>>> +   <div
>>> class="formHelp">{$locale->tr("rssimport_articles_categories_help")}</div
>>>> +   <select name="categoryId">
>>> +    {foreach from=$categories item=category}
>>> +	<option value="{$category->getId()}" {if $categoryId ==
>>> $category->getId()}selected="selected"{/if}>{$category->getName()}</optio
>>> n> +	{/foreach}
>>> +   </select>
>>> +  </div>
>>> +
>>> +  <div class="field">
>>> +   <label
>>> for="importurl">{$locale->tr("label_rssimport_importurl")}</label> +<br/>
>>> +   <span><a href="{$importRssUrl}">{$importRssUrl}</a></span>
>>> +  </div>
>>> +
>>> + </fieldset>
>>> +
>>> + <div class="buttons">
>>> +  <input type="hidden" name="op" value="updateRssImportConfig" />
>>> +  <input type="reset" name="{$locale->tr("reset")}" />
>>> +  <input type="submit" name="{$locale->tr("update_settings")}"
>>> value="{$locale->tr("update")}" /> + </div>
>>> +</form>
>>> +{include file="$admintemplatepath/footernavigation.template"}
>>> +{include file="$admintemplatepath/footer.template"}
>>>
>>> _______________________________________________
>>> pLog-svn mailing list
>>> pLog-svn at devel.lifetype.net
>>> http://limedaley.com/mailman/listinfo/plog-svn
>
>

-- 
Jon Daley
http://jon.limedaley.com
~~
And when it rains on your parade, look up rather than down.
Without the rain, there would be no rainbow.
-- Jerry Chin


More information about the pLog-svn mailing list