[pLog-svn] r5549 - in plog/branches/lifetype-1.2: class/action/admin locale/admin templates/admin

oscar at devel.lifetype.net oscar at devel.lifetype.net
Fri Jun 15 16:49:22 EDT 2007


Author: oscar
Date: 2007-06-15 16:49:21 -0400 (Fri, 15 Jun 2007)
New Revision: 5549

Modified:
   plog/branches/lifetype-1.2/class/action/admin/adminplugincenteraction.class.php
   plog/branches/lifetype-1.2/locale/admin/locale_en_UK.php
   plog/branches/lifetype-1.2/templates/admin/plugincenter.template
Log:
This integrates support into the plugin center for automatic checking of plugin versions. There is now an additional button at the lower right corner labeled "Check versions" that will fetch the RSS feed and compare the current version with the latest one available. In case our plugins are outdated, it will display a message listing the most recent version as well as a link to the download package. Hopefully this will help people stay more up to date...

By the way the plugin feed is located at http://www.lifetype.net/feeds/1.2/plugins.xml. It's an RSS 2.0 feed with just one tag in the "lt" namespace (<lt:version> for storing the plugin version) and it should be consumible with any capable RSS reader.


Modified: plog/branches/lifetype-1.2/class/action/admin/adminplugincenteraction.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/action/admin/adminplugincenteraction.class.php	2007-06-15 20:29:01 UTC (rev 5548)
+++ plog/branches/lifetype-1.2/class/action/admin/adminplugincenteraction.class.php	2007-06-15 20:49:21 UTC (rev 5549)
@@ -4,7 +4,14 @@
     lt_include( PLOG_CLASS_PATH."class/view/admin/admintemplatedview.class.php" );
     lt_include( PLOG_CLASS_PATH."class/view/admin/adminerrorview.class.php" );
     lt_include( PLOG_CLASS_PATH."class/plugin/pluginmanager.class.php" );
+	lt_include( PLOG_CLASS_PATH."class/xml/rssparser/rssparser.class.php" );
 
+	/**
+	 * This needs to be udpated after every major release, so that the plugin feed
+	 * is fetched from the right place
+	 */
+	define( "LIFETYPE_DEFAULT_PLUGIN_VERSION_FEED", "http://www.lifetype.net/feeds/1.2/plugins.xml" );
+
     /**
      * \ingroup Action
      * @private
@@ -41,6 +48,8 @@
         	// initialize the plugin manager and load the plugins
         	$pluginManager =& PluginManager::getPluginManager();
 
+			$doVersionCheck = $this->_request->getValue( "doVersionCheck", false );
+
             // check if the plugin manager is enabled or not, since if it's not
             // there is no point in this feature...
             if( !$pluginManager->isEnabled()) {
@@ -60,10 +69,37 @@
             // create a view and put the plugin objects in the template
             $this->_view = new AdminTemplatedView( $this->_blogInfo, "plugincenter" );
             $this->_view->setValue( "plugins", $plugins );
+
+			// load the feed with plugin versions and display an error if there was a problem
+			if( $doVersionCheck ) {
+				$rss = new RssParser();
+				if( $rss->parse( LIFETYPE_DEFAULT_PLUGIN_VERSION_FEED )) {
+					$items = $rss->getItems();
+
+					// process the parsed rss feed
+					$data = Array();
+					foreach( $items as $pluginData ) {
+						$data[$pluginData->getTitle()] = Array(
+							"version" => $pluginData->_item["lt"]["version"],
+							"downloadLink" => $pluginData->getLink()
+						);
+					}
+
+					$this->_view->setValue( "pluginData", $data );
+				}
+				else {
+					$doVersionCheck = false;
+				}
+			}
+			else {
+				$doVersionCheck = false;
+			}
+
+			$this->_view->setValue( "versionCheck", $doVersionCheck );
             $this->setCommonData();
 
             // better to return true if everything fine
             return true;
         }
     }
-?>
+?>
\ No newline at end of file

Modified: plog/branches/lifetype-1.2/locale/admin/locale_en_UK.php
===================================================================
--- plog/branches/lifetype-1.2/locale/admin/locale_en_UK.php	2007-06-15 20:29:01 UTC (rev 5548)
+++ plog/branches/lifetype-1.2/locale/admin/locale_en_UK.php	2007-06-15 20:49:21 UTC (rev 5549)
@@ -1183,4 +1183,8 @@
 all files should match the expected version. Please be patient, this process may take a while.';
 $messages['check'] = 'Check';
 $messages['all_files_ok'] = 'All files are correct';
+
+/// new strings for LT 1.2.4 ///
+$messages['plugin_latest_version'] = 'Most recent version available: ';
+$messages['check_versions'] = 'Check versions';
 ?>
\ No newline at end of file

Modified: plog/branches/lifetype-1.2/templates/admin/plugincenter.template
===================================================================
--- plog/branches/lifetype-1.2/templates/admin/plugincenter.template	2007-06-15 20:29:01 UTC (rev 5548)
+++ plog/branches/lifetype-1.2/templates/admin/plugincenter.template	2007-06-15 20:49:21 UTC (rev 5549)
@@ -9,21 +9,27 @@
 	});
 {/literal}
 </script>
+ <form id="pluginCenter" action="admin.php" method="post">
         <div id="list">
             <table id="list" class="info" summary="{$locale->tr("pluginCenter")}">
                 <thead>
                     <tr>
                         <th style="width:15%;"><a href="#">{$locale->tr("identifier")}</a></th>
-                        <th style="width:15%;"><a href="#">{$locale->tr("version")}</a></th>
+                        <th style="width:10%;"><a href="#">{$locale->tr("version")}</a></th>
                         <th style="width:20%;"><a href="#">{$locale->tr("author")}</a></th>
-                        <th style="width:65%;"><a href="#">{$locale->tr("description")}</a></th>                        
+                        <th style="width:60%;"><a href="#">{$locale->tr("description")}</a></th>
+						<th style="width:10%;"><a href="#">{$locale->tr("actions")}</a></th>
                     </tr>
                 </thead>
                 <tbody> 
 				  {foreach from=$plugins item=plugin}
+				  {assign var=pluginName value=$plugin->getId()}				
                     <tr>
-                        <td class="col_highlighted">
-                            {$plugin->getId()}
+                        <td class="col_highlighted">	
+							{$plugin->getId()}
+							 {if $versionCheck && $plugin->getVersion() < $pluginData.$pluginName.version}							
+								 <img src="imgs/admin/icon_warning-16.png" alt="{$locale->tr("error")}" />
+							{/if}							
                         </td>
                         <td class="col_highlighted">
                             {$plugin->getVersion()}
@@ -32,12 +38,35 @@
                             {$plugin->getAuthor()}
                         </td>
                         <td>
+							{if $versionCheck && $plugin->getVersion() < $pluginData.$pluginName.version}
+							  <span style="color:red">{$locale->tr("plugin_latest_version")} {$pluginData.$pluginName.version}</span>
+							  (<a href="{$pluginData.$pluginName.downloadLink}">{$locale->tr("download")}</a>)
+							  <br/>
+							{/if}
                             {$plugin->getDescription()}
                         </td>
+						<td>
+                            <a href="http://wiki.lifetype.net/index.php/Plugin_{$plugin->getId()}">
+							  <img src="imgs/admin/icon_info-16.png" alt="Info" />
+							</a>
+							 {if $versionCheck && $plugin->getVersion() < $pluginData.$pluginName.version}
+							     <a href="{$pluginData.$pluginName.downloadLink}">
+								   <img src="imgs/admin/icon_goto-16.png" alt="{$locale->tr("download")}" />
+								 </a>
+							{/if}														
+						</td>
                     </tr>
                     {/foreach}
                 </tbody>
             </table>
         </div>
+	 <div id="list_action_bar">
+	  {check_perms adminperm=view_plugins}
+	  <input type="hidden" name="op" value="pluginCenter"/>
+	  <input type="hidden" name="doVersionCheck" value="1"/>	
+	  <input type="submit" name="check" value="{$locale->tr("check_versions")}"/>
+	  {/check_perms}
+	 </div>
+	 </form>
 {include file="$admintemplatepath/footernavigation.template"}
 {include file="$admintemplatepath/footer.template"}



More information about the pLog-svn mailing list