mirror of
https://github.com/e107inc/e107.git
synced 2025-08-01 12:20:44 +02:00
new plugin upgrade xml and sql feature
This commit is contained in:
@@ -1135,7 +1135,7 @@ class e107plugin
|
|||||||
global $pref;
|
global $pref;
|
||||||
|
|
||||||
$sql = e107::getDb();
|
$sql = e107::getDb();
|
||||||
$mes = eMessage::getInstance();
|
$mes = e107::getMessage();
|
||||||
|
|
||||||
$error = array(); // Array of error messages
|
$error = array(); // Array of error messages
|
||||||
$canContinue = TRUE; // Clear flag if must abort part way through
|
$canContinue = TRUE; // Clear flag if must abort part way through
|
||||||
@@ -1175,6 +1175,36 @@ class e107plugin
|
|||||||
$canContinue = FALSE;
|
$canContinue = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NEW upgrade XML
|
||||||
|
* higher priority -> from-to version upgrade XML - e.g. upgrade/upgrade_1.0-1.1.xml (v1.0 to v1.1 only)
|
||||||
|
* when above not present -> generic version upgrade XML - e.g. upgrade/upgrade_1.1.xml (all prior versions to v1.1)
|
||||||
|
* last checked -> generic upgrade file - plugName/plugin_upgrade.xml (all version)
|
||||||
|
* All upgrade XMLs are optional BUT recommended (at least plugin_upgrade.xml)
|
||||||
|
* The reason is plugin prefs will be reset to default values, user classes will be duplicated etx if plugin.xml is used
|
||||||
|
* To avoid this, put upgrade XML with basic data nodes (version, description, category, author etc)
|
||||||
|
*/
|
||||||
|
if ($canContinue && $function === 'upgrade')
|
||||||
|
{
|
||||||
|
$found = false;
|
||||||
|
$search = array(
|
||||||
|
'upgrade/upgrade_'.$this->current_plug['plugin_version'].'-'.$this->plug_vars['@attributes']['version'].'.xml',
|
||||||
|
'upgrade/upgrade_'.$this->plug_vars['@attributes']['version'].'.xml',
|
||||||
|
'plugin_upgrade.xml',
|
||||||
|
);
|
||||||
|
foreach ($search as $case)
|
||||||
|
{
|
||||||
|
if(file_exists($path.$case) && is_readable($path.$case) && $this->parse_plugin_xml($plug['plugin_path'], $case))
|
||||||
|
{
|
||||||
|
// TODO - lan
|
||||||
|
$mes->addSuccess('Upgrade using '.$case);
|
||||||
|
$plug_vars = $this->plug_vars;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// END upgrade XML
|
||||||
|
|
||||||
if (varset($plug_vars['languageFiles']))
|
if (varset($plug_vars['languageFiles']))
|
||||||
{
|
{
|
||||||
$this->XmlLanguageFiles($function, $plug_vars['languageFiles'], 'pre'); // First of all, see if there's a language file specific to install
|
$this->XmlLanguageFiles($function, $plug_vars['languageFiles'], 'pre'); // First of all, see if there's a language file specific to install
|
||||||
@@ -1200,7 +1230,34 @@ class e107plugin
|
|||||||
$txt .= $ret;
|
$txt .= $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($canContinue && count($sql_list)) // TODO - move to it's own function.
|
/*
|
||||||
|
* FIXME - sql upgrade draft - we need better 'parse sql' support, INSERTs, ALTERs, etc
|
||||||
|
* NEW upgrade SQL
|
||||||
|
* higher priority -> from-to version upgrade sql queries - e.g. upgrade/sql_1.0-1.1.php (v1.0 to v1.1 only)
|
||||||
|
* when above not present -> generic version upgrade XML - e.g. upgrade/sql_1.1.php (all prior versions to v1.1)
|
||||||
|
* All upgrade sql scripts are optional, if not found system is using the auto detection mode (diff against main sql file)
|
||||||
|
* ONLY NEW tables should be created here
|
||||||
|
*/
|
||||||
|
$doSql = true;
|
||||||
|
if($canContinue && $function === 'upgrade')
|
||||||
|
{
|
||||||
|
$search = array(
|
||||||
|
'upgrade/sql_'.$this->current_plug['plugin_version'].'-'.$this->plug_vars['@attributes']['version'].'.php',
|
||||||
|
'upgrade/sql_'.$this->plug_vars['@attributes']['version'].'.php',
|
||||||
|
);
|
||||||
|
foreach ($search as $case)
|
||||||
|
{
|
||||||
|
if(file_exists($path.$case) && is_readable($path.$case) && $this->parse_plugin_xml($plug['plugin_path'], $case))
|
||||||
|
{
|
||||||
|
// TODO - lan
|
||||||
|
$mes->addSuccess('(draft) Upgrade using '.$case);
|
||||||
|
$doSql = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($canContinue && $doSql && count($sql_list)) // TODO - move to it's own function.
|
||||||
|
|
||||||
{ // Handle tables
|
{ // Handle tables
|
||||||
|
|
||||||
@@ -2408,7 +2465,7 @@ class e107plugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Called to parse the plugin.xml file if it exists
|
// Called to parse the plugin.xml file if it exists
|
||||||
function parse_plugin_xml($plugName)
|
function parse_plugin_xml($plugName, $where = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
$tp = e107::getParser();
|
$tp = e107::getParser();
|
||||||
@@ -2418,8 +2475,9 @@ class e107plugin
|
|||||||
|
|
||||||
// $xml->setOptArrayTags('extendedField,userclass,menuLink,commentID'); // always arrays for these tags.
|
// $xml->setOptArrayTags('extendedField,userclass,menuLink,commentID'); // always arrays for these tags.
|
||||||
// $xml->setOptStringTags('install,uninstall,upgrade');
|
// $xml->setOptStringTags('install,uninstall,upgrade');
|
||||||
|
if(null === $where) $where = 'plugin.xml';
|
||||||
|
|
||||||
$this->plug_vars = $xml->loadXMLfile(e_PLUGIN.$plugName.'/plugin.xml', 'advanced');
|
$this->plug_vars = $xml->loadXMLfile(e_PLUGIN.$plugName.'/'.$where, 'advanced');
|
||||||
|
|
||||||
if ($this->plug_vars === FALSE)
|
if ($this->plug_vars === FALSE)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user