1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 20:58:30 +01:00

Moved theme/plugin release notification function to new class. Should be fully functional for both themes and plugins now. To-Do Ajax checking.

This commit is contained in:
CaMer0n 2009-08-17 18:42:22 +00:00
parent cb8cc9fcb9
commit 123fdf4d13
7 changed files with 180 additions and 82 deletions

View File

@ -11,9 +11,9 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_admin/plugin.php,v $
| $Revision: 1.37 $
| $Date: 2009-08-15 15:44:37 $
| $Author: marj_nl_fr $
| $Revision: 1.38 $
| $Date: 2009-08-17 18:42:19 $
| $Author: e107coders $
+----------------------------------------------------------------------------+
*/
@ -87,6 +87,7 @@ class pluginManager{
"plugin_description" => array("title" => EPL_ADLAN_14, "type"=>"text", "width" => "auto", "thclass" => "middle center", "url" => ""),
"plugin_compatible" => array("title" => EPL_ADLAN_13, "type"=>"text", "width" => "auto", "thclass" => "middle", "url" => ""),
"plugin_compliant" => array("title" => EPL_ADLAN_81, "type"=>"text", "width" => "5%", "thclass" => "middle center", "url" => ""),
"plugin_release" => array("title" => EPL_ADLAN_81, "type"=>"text", "width" => "5%", "thclass" => "middle center", "url" => ""),
"options" => array("title" => LAN_OPTIONS, "width" => "15%", "thclass" => "middle center last", "url" => "")
);

View File

@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_admin/sql/core_sql.php,v $
| $Revision: 1.20 $
| $Date: 2009-08-16 23:58:31 $
| $Revision: 1.21 $
| $Date: 2009-08-17 18:42:21 $
| $Author: e107coders $
+----------------------------------------------------------------------------+
*/
@ -387,6 +387,7 @@ CREATE TABLE plugin (
plugin_installflag tinyint(1) unsigned NOT NULL default '0',
plugin_addons text NOT NULL,
plugin_category varchar(100) NOT NULL default '',
plugin_releaseUrl varchar(255) NOT NULL default '',
PRIMARY KEY (plugin_id),
UNIQUE KEY plugin_path (plugin_path)
) TYPE=MyISAM;

View File

@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_admin/update_routines.php,v $
| $Revision: 1.43 $
| $Date: 2009-08-17 15:45:20 $
| $Revision: 1.44 $
| $Date: 2009-08-17 18:42:20 $
| $Author: e107coders $
+----------------------------------------------------------------------------+
*/
@ -174,14 +174,12 @@ function update_check()
}
}
$curTheme = e107::getPref('sitetheme');
$curVersion = e107::getPref('sitetheme_version');
$curUrl = e107::getPref('sitetheme_releaseUrl');
require_once(e_HANDLER."theme_handler.php");
$thm = new themeHandler;
$thm->themeReleaseCheck($curTheme,$curVersion,$curUrl);
require_once(e_HANDLER."e_upgrade_class.php");
$upg = new e_upgrade;
$upg->checkSiteTheme();
$upg->checkAllPlugins();
//--------------------------------------------

View File

@ -0,0 +1,158 @@
<?php
/*
+ ----------------------------------------------------------------------------+
| e107 website system
|
| Copyright (c) e107 Inc. 2001-2009
| http://e107.org
|
| Released under the terms and conditions of the
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_handlers/e_upgrade_class.php,v $
| $Revision: 1.1 $
| $Date: 2009-08-17 18:42:22 $
| $Author: e107coders $
+----------------------------------------------------------------------------+
*/
if (!defined('e107_INIT')) { exit; }
/**
Usage: A file with the following format should be stored on a server, and included in the releaseUrl attribute of theme.xml or plugin.xml
' <?xml version='1.0' encoding='utf-8' ?>
<e107Release>
<theme name='e107.v4' folder='e107v4a' version='3.1' date='2009-06-11' compatibility='0.8' url='http://www.e107.org/edownload.php?".$_GET['folder']."' />
<theme name='e107.v5' folder='e107v5a' version='3.6' date='2009-06-11' compatibility='0.8' url='http://www.e107.org/edownload.php' />
</e107Release>
For themes, use <theme name='... etc.
For plugins, use <plugin name='.... etc
*/
class e_upgrade
{
protected $_options = array();
/**
*
* @param string $curFolder - folder name of the plugin or theme to check
* @param string $curVersions - installed version of the plugin or theme.
* @param string $releaseUrl - url of the XML file in the above format.
* @param boolean $cache
*/
public function setOptions($dataArray)
{
$this->_options = $dataArray;
return $this;
}
public function getOption($key, $default = '')
{
return varset($this->_options[$key], $default);
}
public function releaseCheck($mode='plugin', $cache=TRUE)
{
global $e107cache;
if(!$this->getOption('releaseUrl'))
{
return;
}
$cacheString = $mode. 'UpdateCheck';
$e107cache->CachePageMD5 = md5($cacheString.$this->getOption('curFolder').$this->getOption('curVersion', 1.0));
if(($cache==TRUE) && ($cacheData = $e107cache->retrieve($cacheString, 3600, TRUE)))
{
require_once(e_HANDLER."message_handler.php");
$emessage = &eMessage::getInstance();
$emessage->add($cacheData);
$e107cache->CachePageMD5 = "";
return;
}
require_once(e_HANDLER.'xml_class.php');
$xml = new xmlClass;
$feed = $this->getOption('releaseUrl');
if(substr($feed,-4) == ".php")
{
$feed .= "?folder=".$this->getOption('curFolder')."&version=".$this->getOption('curVersion');
}
if($rawData = $xml -> loadXMLfile($feed, TRUE))
{
if(!$rawData[$mode][1])
{
$rawData[$mode] = $rawData;
}
$txt = "";
$lan_text = ($mode == "theme") ? ADLAN_162 : ADLAN_163;
foreach($rawData[$mode] as $val)
{
$name = $val['@attributes']['name'];
$folder = $val['@attributes']['folder'];
$version = $val['@attributes']['version'];
$url = $val['@attributes']['url'];
if(($folder == $this->getOption('curFolder')) && version_compare($version,$this->getOption('curVersion'))==1)
{
$txt .= $lan_text." <a href='".$url."'>".$name ." v".$version."</a><br />";
break;
}
}
if($txt)
{
require_once (e_HANDLER."message_handler.php");
$emessage = &eMessage::getInstance();
$emessage->add($txt);
if($cache==TRUE)
{
$e107cache->set($cacheString, $txt, TRUE);
}
$e107cache->CachePageMD5 = "";
}
}
}
function checkAllPlugins()
{
global $pref;
$sql = e107::getDB();
if($sql -> db_Select_Gen("SELECT * FROM #plugin WHERE plugin_installflag = 1 AND plugin_releaseUrl !=''"))
{
while($row = $sql-> db_Fetch())
{
$options = array('curFolder' => $row['plugin_path'], 'curVersion' => $row['plugin_version'], 'releaseUrl' => $row['plugin_releaseUrl']);
$this->setOptions($options);
$this->releaseCheck('plugin',FALSE);
}
}
}
function checkSiteTheme()
{
$curTheme = e107::getPref('sitetheme');
$curVersion = e107::getPref('sitetheme_version');
$curUrl = e107::getPref('sitetheme_releaseUrl');
$options = array('curFolder' => $curTheme, 'curVersion' => $curVersion, 'releaseUrl' => $curUrl);
$this->setOptions($options);
$this->releaseCheck('theme');
}
}

View File

@ -11,9 +11,9 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_handlers/plugin_class.php,v $
| $Revision: 1.73 $
| $Date: 2009-08-08 23:09:08 $
| $Author: marj_nl_fr $
| $Revision: 1.74 $
| $Date: 2009-08-17 18:42:21 $
| $Author: e107coders $
+----------------------------------------------------------------------------+
*/
@ -236,7 +236,7 @@ class e107plugin
// Can just add to DB - shouldn't matter that its not in our current table
// echo "Trying to insert: ".$eplug_folder."<br />";
$_installed = ($plug_info['@attributes']['installRequired'] == 'true' || $plug_info['@attributes']['installRequired'] == 1 ? 0 : 1 );
$sql->db_Insert("plugin", "0, '".$tp -> toDB($plug_info['@attributes']['name'], true)."', '".$tp -> toDB($plug_info['@attributes']['version'], true)."', '".$tp -> toDB($plugin_path, true)."', {$_installed}, '{$eplug_addons}', '".$plug_info['category']."' ");
$sql->db_Insert("plugin", "0, '".$tp -> toDB($plug_info['@attributes']['name'], true)."', '".$tp -> toDB($plug_info['@attributes']['version'], true)."', '".$tp -> toDB($plugin_path, true)."', {$_installed}, '{$eplug_addons}', '".$plug_info['category']."', '".varset($plug_info['@attributes']['releaseUrl'])."' ");
}
}
}

View File

@ -10,8 +10,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_handlers/theme_handler.php,v $
| $Revision: 1.47 $
| $Date: 2009-08-17 16:08:11 $
| $Revision: 1.48 $
| $Date: 2009-08-17 18:42:21 $
| $Author: e107coders $
+----------------------------------------------------------------------------+
*/
@ -1252,68 +1252,7 @@ class themeHandler{
function themeReleaseCheck($curTheme,$curVersion,$releaseUrl,$cache=TRUE)
{
global $e107cache;
if(!$releaseUrl)
{
return;
}
$e107cache->CachePageMD5 = md5($curTheme.$curVersion);
if(($cache==TRUE) && ($cacheData = $e107cache->retrieve('themeUpdateCheck', 3600, TRUE)))
{
require_once(e_HANDLER."message_handler.php");
$emessage = &eMessage::getInstance();
$emessage->add($cacheData);
return;
}
require_once(e_HANDLER.'xml_class.php');
$xml = new xmlClass;
if(substr($releaseUrl,-4) == ".php")
{
$releaseUrl .= "?folder=".$curTheme."&ver=".$curVersion;
}
if($rawData = $xml -> loadXMLfile($releaseUrl, TRUE))
{
if(!$rawData['theme'][1])
{
$rawData['theme'] = $rawData;
}
$txt = "";
foreach($rawData['theme'] as $val)
{
$name = $val['@attributes']['name'];
$folder = $val['@attributes']['folder'];
$version = $val['@attributes']['version'];
$url = $val['@attributes']['url'];
if(($folder == $curTheme) && version_compare($version,$curVersion)==1)
{
$txt .= ADLAN_162." <a href='".$url."'>".$name ." v".$version."</a><br />";
break;
}
}
if($txt)
{
require_once (e_HANDLER."message_handler.php");
$emessage = &eMessage::getInstance();
$emessage->add($txt);
if($cache==TRUE)
{
$e107cache->set('themeUpdateCheck', $txt, TRUE);
}
}
}
}
}
?>

View File

@ -1,7 +1,7 @@
<?php
/*
* Copyright e107 Inc e107.org, Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id: lan_admin.php,v 1.25 2009-08-17 14:26:57 e107coders Exp $
* $Id: lan_admin.php,v 1.26 2009-08-17 18:42:22 e107coders Exp $
*
* Admin Language File
*/
@ -182,6 +182,7 @@ define("ADLAN_159", "URL Configuration");
define("ADLAN_160", "Configure Site URLs");
define("ADLAN_161", "");
define("ADLAN_162", "A newer version of your site-theme is available:");
define("ADLAN_163", "A newer version of an installed plugin is available:");
define('ADLAN_CL_1', 'Settings');
define('ADLAN_CL_2', 'Users');