[pLog-svn] r2827 - in plog/trunk/class: misc plugin
oscar at devel.lifetype.net
oscar at devel.lifetype.net
Thu Jan 19 23:07:26 GMT 2006
Author: oscar
Date: 2006-01-19 23:07:25 +0000 (Thu, 19 Jan 2006)
New Revision: 2827
Modified:
plog/trunk/class/misc/version.class.php
plog/trunk/class/plugin/pluginbase.class.php
plog/trunk/class/plugin/pluginmanager.class.php
Log:
Soon we should retake regarding plugin versioning. Not many of the plugins designed for 1.0 can run in 1.1 at the moment without any changes...
Modified: plog/trunk/class/misc/version.class.php
===================================================================
--- plog/trunk/class/misc/version.class.php 2006-01-19 22:30:34 UTC (rev 2826)
+++ plog/trunk/class/misc/version.class.php 2006-01-19 23:07:25 UTC (rev 2827)
@@ -1,10 +1,7 @@
<?php
+ define( "PLOG_PROJECT_PAGE", "http://www.lifetype.net" );
- include_once( PLOG_CLASS_PATH."class/file/file.class.php" );
-
- define( "PLOG_PROJECT_PAGE", "http://www.plogworld.net" );
-
if ( !defined("DEFAULT_VERSION_FILE") )
define( "DEFAULT_VERSION_FILE", PLOG_CLASS_PATH . "version.php" );
@@ -25,6 +22,7 @@
*/
function getVersion()
{
+ include_once( PLOG_CLASS_PATH."class/file/file.class.php" );
$versionFile = PLOG_CLASS_PATH."version.php";
if( File::isReadable( $versionFile ))
include_once( $versionFile );
@@ -44,5 +42,19 @@
{
return PLOG_PROJECT_PAGE;
}
+
+ /**
+ * Compares two LT versions
+ *
+ * @param v1
+ * @param v2
+ * @return 1 if v1>v2, 0 if v1==v2 and -1 if v1<v2
+ * @see http://www.php.net/manual/en/function.version-compare.php
+ * @static
+ */
+ function compare( $v1, $v2 )
+ {
+ return( version_compare( $v1, $v2 ));
+ }
}
?>
\ No newline at end of file
Modified: plog/trunk/class/plugin/pluginbase.class.php
===================================================================
--- plog/trunk/class/plugin/pluginbase.class.php 2006-01-19 22:30:34 UTC (rev 2826)
+++ plog/trunk/class/plugin/pluginbase.class.php 2006-01-19 23:07:25 UTC (rev 2827)
@@ -40,7 +40,7 @@
/**
* This should be filled with the author of the plugins
*/
- var $version = "";
+ var $version = "1.0";
/**
* Set this to the html code that you would like to display when
@@ -343,5 +343,20 @@
{
return true;
}
+
+ /**
+ * returns the plugin version
+ *
+ * @return the version of LT for which this plugin was created. This is later on used by the plugin loader
+ * to determine whether a plugin can be used with a certain version of LT. If
+ * PluginBase::version is not defined, this method will return "1.0".
+ */
+ function getVersion()
+ {
+ if( $this->version == "" )
+ $this->version = "1.0";
+
+ return( $this->version );
+ }
}
?>
Modified: plog/trunk/class/plugin/pluginmanager.class.php
===================================================================
--- plog/trunk/class/plugin/pluginmanager.class.php 2006-01-19 22:30:34 UTC (rev 2826)
+++ plog/trunk/class/plugin/pluginmanager.class.php 2006-01-19 23:07:25 UTC (rev 2827)
@@ -146,6 +146,21 @@
{
return( array_key_exists( $blogId, $this->_pluginList ));
}
+
+ /**
+ * Checks whether the version reported by the plugin is compatible with the current version of LT
+ *
+ * @return True if compatible or false otherwise.
+ */
+ function _pluginCanRun( $version )
+ {
+ /**
+ * :TODO:
+ *
+ * to define this!!
+ */
+ return true;
+ }
/**
* Loads all the plugins from disk
@@ -153,7 +168,7 @@
* @private
*/
function loadPlugins()
- {
+ {
$classLoader =& ResourceClassLoader::getLoader();
foreach( $this->_pluginList as $plugin ) {
@@ -230,14 +245,17 @@
include_once( $pluginFullPath );
$classInstance = new $className();
$classInstance->setPluginFolder( PLOG_CLASS_PATH.$pluginFile."/" );
- $name = $classInstance->getId();
+ $name = $classInstance->getId();
if( $name == "" ) {
throw( new Exception( "Plugin file $pluginFile has no identifier defined!" ));
die();
- }
-
- $this->_pluginInstances["$name"] = &$classInstance;
+ }
+
+ // create an instance only if the plugin is allowed to run in this version of LT
+ if( $this->_pluginCanRun( $classInstance->getVersion())) {
+ $this->_pluginInstances["$name"] = &$classInstance;
+ }
}
}
More information about the pLog-svn
mailing list