[pLog-svn] r5055 - in plugins/branches/lifetype-1.2: . rsd rsd/class rsd/class/action rsd/class/view rsd/locale rsd/templates
pwestbro at devel.lifetype.net
pwestbro at devel.lifetype.net
Mon Mar 12 02:51:10 EDT 2007
Author: pwestbro
Date: 2007-03-12 02:51:10 -0400 (Mon, 12 Mar 2007)
New Revision: 5055
Added:
plugins/branches/lifetype-1.2/rsd/
plugins/branches/lifetype-1.2/rsd/README.txt
plugins/branches/lifetype-1.2/rsd/class/
plugins/branches/lifetype-1.2/rsd/class/action/
plugins/branches/lifetype-1.2/rsd/class/action/pluginrsdconfigaction.class.php
plugins/branches/lifetype-1.2/rsd/class/action/pluginrsdupdateconfigaction.class.php
plugins/branches/lifetype-1.2/rsd/class/view/
plugins/branches/lifetype-1.2/rsd/class/view/pluginrsdconfigview.class.php
plugins/branches/lifetype-1.2/rsd/locale/
plugins/branches/lifetype-1.2/rsd/locale/locale_en_UK.php
plugins/branches/lifetype-1.2/rsd/pluginrsd.class.php
plugins/branches/lifetype-1.2/rsd/templates/
plugins/branches/lifetype-1.2/rsd/templates/rsd.template
Log:
Added a Really Simple Discovery plugin.
This allows xmlrpc clients to automatically discover the xmlrpc url, and the
xmlrpc APIs that LifeType supports.
http://cyber.law.harvard.edu/blogs/gems/tech/rsd.html
Added: plugins/branches/lifetype-1.2/rsd/README.txt
===================================================================
--- plugins/branches/lifetype-1.2/rsd/README.txt (rev 0)
+++ plugins/branches/lifetype-1.2/rsd/README.txt 2007-03-12 06:51:10 UTC (rev 5055)
@@ -0,0 +1,50 @@
+Plugin: SiteMap
+Author: paul at westbrooks.org
+Release Date: 2005/06/23
+Version: 1.2
+
+Generates an RSD file for a lifetype blog. This allows xmlrpc clients to automatically
+discover the xml rpc endpoint.
+
+In order for the rsd file to be accessible,
+change lifetype/tmp/.htacess to allow the rsd file to be read by a web browser
+
+<Files "*">
+ Order deny,allow
+ Deny from all
+</Files>
+
+<Files "rsd.xml">
+ Allow from all
+</files>
+
+
+
+Add the following lines to the lifetype/.htaccess
+
+
+
+<IfModule mod_rewrite.c>
+
+RewriteEngine On
+
+ RewriteBase /
+
+
+ # Point to the rsd file that is local to the blog
+
+ RewriteRule ^rsd([0-9]+)\.xml$ tmp/rsd/$1/rsd.xml [L,NC]
+
+
+</IfModule>
+
+
+
+[EXAMPLE]:
+Add the following code in header.template before the </head> tag:
+
+Code:
+{if $rsd}
+{$rsd->show()}
+{/if}
+
Added: plugins/branches/lifetype-1.2/rsd/class/action/pluginrsdconfigaction.class.php
===================================================================
--- plugins/branches/lifetype-1.2/rsd/class/action/pluginrsdconfigaction.class.php (rev 0)
+++ plugins/branches/lifetype-1.2/rsd/class/action/pluginrsdconfigaction.class.php 2007-03-12 06:51:10 UTC (rev 5055)
@@ -0,0 +1,26 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+ lt_include( PLOG_CLASS_PATH."plugins/rsd/class/view/pluginrsdconfigview.class.php" );
+
+ /**
+ * shows a form with the current configuration
+ */
+ class PluginRsdConfigAction extends AdminAction
+ {
+
+ function PluginRsdConfigAction( $actionInfo, $request )
+ {
+ $this->AdminAction( $actionInfo, $request );
+ }
+
+ function perform()
+ {
+ $this->_view = new PluginRsdConfigView( $this->_blogInfo );
+
+ $this->setCommonData();
+
+ return true;
+ }
+ }
+?>
\ No newline at end of file
Added: plugins/branches/lifetype-1.2/rsd/class/action/pluginrsdupdateconfigaction.class.php
===================================================================
--- plugins/branches/lifetype-1.2/rsd/class/action/pluginrsdupdateconfigaction.class.php (rev 0)
+++ plugins/branches/lifetype-1.2/rsd/class/action/pluginrsdupdateconfigaction.class.php 2007-03-12 06:51:10 UTC (rev 5055)
@@ -0,0 +1,66 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+ lt_include( PLOG_CLASS_PATH."plugins/rsd/class/view/pluginrsdconfigview.class.php" );
+
+ /**
+ * updates the plugin configuration
+ */
+ class PluginRsdUpdateConfigAction extends AdminAction
+ {
+ var $_pluginEnabled;
+
+ function PluginRsdUpdateConfigAction( $actionInfo, $request )
+ {
+ $this->AdminAction( $actionInfo, $request );
+ }
+
+ function validate()
+ {
+ $this->_pluginEnabled = $this->_request->getValue( "pluginEnabled" );
+ $this->_pluginEnabled = ($this->_pluginEnabled != "" );
+
+ return true;
+ }
+
+ function perform()
+ {
+ // update the plugin configurations to blog setting
+ $blogSettings = $this->_blogInfo->getSettings();
+ $blogSettings->setValue( "plugin_rsd_enabled", $this->_pluginEnabled );
+ $this->_blogInfo->setSettings( $blogSettings );
+
+ // save the blogs settings
+ $blogs = new Blogs();
+ if( !$blogs->updateBlog( $this->_blogInfo )) {
+ $this->_view = new PluginRsdConfigView( $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 PluginRsdConfigView( $this->_blogInfo );
+ $this->_view->setSuccessMessage( $this->_locale->tr("rsd_settings_saved_ok"));
+ $this->setCommonData();
+
+ if( $this->_pluginEnabled ) {
+ $plugins = $this->_pm->getPlugins();
+
+ $plugin = $plugins["rsd"];
+ $plugin->createRSD();
+ }
+
+
+ // clear the cache
+ CacheControl::resetBlogCache( $this->_blogInfo->getId());
+
+ return true;
+ }
+ }
+?>
\ No newline at end of file
Added: plugins/branches/lifetype-1.2/rsd/class/view/pluginrsdconfigview.class.php
===================================================================
--- plugins/branches/lifetype-1.2/rsd/class/view/pluginrsdconfigview.class.php (rev 0)
+++ plugins/branches/lifetype-1.2/rsd/class/view/pluginrsdconfigview.class.php 2007-03-12 06:51:10 UTC (rev 5055)
@@ -0,0 +1,28 @@
+<?php
+
+ lt_include( PLOG_CLASS_PATH."class/view/admin/adminplugintemplatedview.class.php" );
+
+ /**
+ * implements the main view of the feed reader plugin
+ */
+ class PluginRsdConfigView extends AdminPluginTemplatedView
+ {
+
+ function PluginRsdConfigView( $blogInfo )
+ {
+ $this->AdminPluginTemplatedView( $blogInfo, "rsd", "rsd" );
+ }
+
+ function render()
+ {
+ // load some configuration settings
+ $blogSettings = $this->_blogInfo->getSettings();
+ $pluginEnabled = $blogSettings->getValue( "plugin_rsd_enabled" );
+
+ // create a view and export the settings to the template
+ $this->setValue( "pluginEnabled", $pluginEnabled );
+
+ parent::render();
+ }
+ }
+?>
\ No newline at end of file
Added: plugins/branches/lifetype-1.2/rsd/locale/locale_en_UK.php
===================================================================
--- plugins/branches/lifetype-1.2/rsd/locale/locale_en_UK.php (rev 0)
+++ plugins/branches/lifetype-1.2/rsd/locale/locale_en_UK.php 2007-03-12 06:51:10 UTC (rev 5055)
@@ -0,0 +1,13 @@
+<?php
+$messages["manageIntegrationPlugins"] = "Integration Management";
+$messages["rsd"] = "Really Simple Discovery";
+
+$messages["rsd_plugin_enabled"] = "Enable this plugin";
+$messages["rsd_plugin"] = "Really Simple Discovery Plugin";
+$messages["detail"] = "Detail";
+
+$messages["rsd_settings_saved_ok"] = "Really Simple Discovery settings saved successfully!";
+
+$messages["label_configuration"] = "Configuration";
+$messages["label_enable"] = "Enable";
+?>
\ No newline at end of file
Added: plugins/branches/lifetype-1.2/rsd/pluginrsd.class.php
===================================================================
--- plugins/branches/lifetype-1.2/rsd/pluginrsd.class.php (rev 0)
+++ plugins/branches/lifetype-1.2/rsd/pluginrsd.class.php 2007-03-12 06:51:10 UTC (rev 5055)
@@ -0,0 +1,143 @@
+<?php
+ /*
+ Copyright 2006 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" );
+
+ class PluginRsd extends PluginBase
+ {
+ var $pluginEnabled;
+
+ function PluginRsd( $source = "" )
+ {
+ $this->PluginBase($source);
+
+ $this->id = "rsd";
+ $this->author = "Paul Westbrook";
+ $this->desc = "Plugin to implement Really Simple Discovery.";
+ $this->version = "20070311";
+
+ $this->locales = Array( "en_UK");
+
+ if( $source == "admin" )
+ $this->initAdmin();
+ }
+
+ function initAdmin()
+ {
+ $this->registerAdminAction( "rsdConfig", "PluginRsdConfigAction" );
+ $this->registerAdminAction( "updateRsdConfig", "PluginRsdUpdateConfigAction" );
+
+ $menu =& Menu::getMenu();
+ if( !$menu->entryExists( "/menu/controlCenter/manageIntegrationPlugins" ))
+ $this->addMenuEntry( "/menu/controlCenter", "manageIntegrationPlugins", "", "", true, false );
+ $this->addMenuEntry( "/menu/controlCenter/manageIntegrationPlugins", "rsd", "?op=rsdConfig", "" );
+ }
+
+ function register()
+ {
+ $config =& Config::getConfig();
+
+ $this->cacheFolder = $config->getValue('temp_folder');
+ $this->cacheFolder = $this->cacheFolder.'/rsd/'.$this->blogInfo->getId();
+ if( !File::exists( $this->cacheFolder )) {
+ File::createDir( $this->cacheFolder );
+ }
+
+ $blogSettings = $this->blogInfo->getSettings();
+ $this->pluginEnabled = $blogSettings->getValue( "plugin_rsd_enabled" );
+ }
+
+ function isEnabled()
+ {
+ return $this->pluginEnabled;
+ }
+
+ function show()
+ {
+ $str = '';
+
+ if ($this->isEnabled())
+ {
+ $rg = $this->blogInfo->getBlogRequestGenerator();
+
+ $rsdFile = "/rsd" . $this->blogInfo->getId() . ".xml";
+ $rsdFileUrl = $rg->getUrl($rsdFile);
+
+ $str = '<link rel="EditURI" type="application/rsd+xml" title="RSD" href="' . $rsdFileUrl . '" />';
+ }
+ return $str;
+ }
+
+ function createRSD()
+ {
+ $rsdFile = $this->cacheFolder."/rsd.xml";
+
+ // Save this to a compressed file.
+ $fd = fopen($rsdFile,'w9');
+
+ if ( $fd )
+ {
+
+ // Data from the xml file that needs to be there.
+ $xmlData = "<?xml version=\"1.0\" ?>\n".
+ "<rsd version=\"1.0\" xmlns=\"http://archipelago.phrasewise.com/rsd\" >\n".
+ " <service>\n".
+ "<engineName>LifeType</engineName> \n".
+ "<engineLink>http://www.lifetype.net/</engineLink>\n";
+
+
+ fwrite($fd, $xmlData);
+
+ $rg = $this->blogInfo->getBlogRequestGenerator();
+
+ $xmlData = "<homePageLink>" . $rg->blogLink() . "</homePageLink>\n";
+ fwrite($fd, $xmlData);
+
+ fwrite($fd, "<apis>\n");
+
+ $xmlrpcUrl = $rg->getUrl("/xmlrpc.php");
+
+ $xmlData = "<api name=\"Movable Type\" preferred=\"true\" apiLink=\"" . $xmlrpcUrl . "\" blogID=\"" . $this->blogInfo->getId() . "\" />\n";
+ fwrite($fd, $xmlData);
+
+ $xmlData = "<api name=\"MetaWeblog\" preferred=\"false\" apiLink=\"" . $xmlrpcUrl . "\" blogID=\"" . $this->blogInfo->getId() . "\" />\n";
+ fwrite($fd, $xmlData);
+
+ $xmlData = "<api name=\"Blogger\" preferred=\"false\" apiLink=\"" . $xmlrpcUrl . "\" blogID=\"" . $this->blogInfo->getId() . "\" />\n";
+ fwrite($fd, $xmlData);
+
+
+ $xmlData = "</apis>\n".
+ "</service>\n".
+ "</rsd>\n";
+ fwrite($fd, $xmlData);
+ fclose($fd);
+ }
+ }
+
+ function getPluginConfigurationKeys()
+ {
+ return( Array(
+ Array( "name" => "plugin_rsd_enabled", "type" => "boolean" ),
+ ));
+ }
+
+ }
+?>
\ No newline at end of file
Added: plugins/branches/lifetype-1.2/rsd/templates/rsd.template
===================================================================
--- plugins/branches/lifetype-1.2/rsd/templates/rsd.template (rev 0)
+++ plugins/branches/lifetype-1.2/rsd/templates/rsd.template 2007-03-12 06:51:10 UTC (rev 5055)
@@ -0,0 +1,24 @@
+{include file="$admintemplatepath/header.template"}
+{include file="$admintemplatepath/navigation.template" showOpt=rsd title=$locale->tr("rsd_plugin")}
+<form name="rsdPluginConfig" 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("rsd_plugin_enabled")}
+ </div>
+ </div>
+
+ </fieldset>
+
+ <div class="buttons">
+ <input type="hidden" name="op" value="updateRsdConfig" />
+ <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"}
\ No newline at end of file
More information about the pLog-svn
mailing list