mirror of
https://github.com/e107inc/e107.git
synced 2025-08-01 20:30:39 +02:00
Plugin Manager fixes.
This commit is contained in:
@@ -37,14 +37,10 @@ if(!deftrue('e_DEBUG_PLUGMANAGER'))
|
|||||||
$plugin = new e107plugin;
|
$plugin = new e107plugin;
|
||||||
$pman = new pluginManager;
|
$pman = new pluginManager;
|
||||||
|
|
||||||
|
define("e_PAGETITLE",ADLAN_98." - ".$pman->pagetitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
define("e_PAGETITLE",ADLAN_98." - ".$pman->pagetitle);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(isset($_POST['uninstall_cancel']))
|
if(isset($_POST['uninstall_cancel']))
|
||||||
{
|
{
|
||||||
header("location:".e_SELF);
|
header("location:".e_SELF);
|
||||||
@@ -248,6 +244,7 @@ class plugin_ui extends e_admin_ui
|
|||||||
$model->set('plugin_author',$plg->getAuthor());
|
$model->set('plugin_author',$plg->getAuthor());
|
||||||
$model->set('plugin_compatible',$plg->getCompat());
|
$model->set('plugin_compatible',$plg->getCompat());
|
||||||
$model->set('plugin_admin_url',$plg->getAdminUrl());
|
$model->set('plugin_admin_url',$plg->getAdminUrl());
|
||||||
|
$model->set('plugin_admin_caption', $plg->getAdminCaption());
|
||||||
$model->set('plugin_description',$plg->getDescription());
|
$model->set('plugin_description',$plg->getDescription());
|
||||||
$model->set('plugin_version_file',$plg->getVersion());
|
$model->set('plugin_version_file',$plg->getVersion());
|
||||||
$model->set('plugin_install_required',$plg->getInstallRequired());
|
$model->set('plugin_install_required',$plg->getInstallRequired());
|
||||||
@@ -297,6 +294,33 @@ class plugin_ui extends e_admin_ui
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function renderHelp()
|
||||||
|
{
|
||||||
|
$plg = e107::getPlug();
|
||||||
|
if(!$list = $plg->getUpgradableList())
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$text = "<ul class='list-unstyled'>";
|
||||||
|
foreach($list as $path=>$ver)
|
||||||
|
{
|
||||||
|
$plg->load($path);
|
||||||
|
$url = e_ADMIN."plugin.php?mode=installed&action=upgrade&id=".$path;
|
||||||
|
$text .= "<li><a href='".$url."'>".$plg->getIcon(32)." ".$plg->getName()."</a></li>";
|
||||||
|
|
||||||
|
}
|
||||||
|
$text .= "</ul>";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return array('caption'=>"Updates to be Installed", 'text'=>$text);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Action Pages.
|
// Action Pages.
|
||||||
|
|
||||||
|
|
||||||
@@ -870,7 +894,8 @@ class plugin_form_ui extends e_admin_form_ui
|
|||||||
|
|
||||||
if($var['plugin_admin_url'] && $var['plugin_installflag'] == true)
|
if($var['plugin_admin_url'] && $var['plugin_installflag'] == true)
|
||||||
{
|
{
|
||||||
$conf_title = LAN_CONFIGURE . ' ' . $tp->toHTML($var['@attributes']['name'], "", "defs,emotes_off, no_make_clickable");
|
|
||||||
|
$conf_title = !empty($var['plugin_admin_caption']) ? $var['plugin_admin_caption'] : LAN_CONFIGURE . ' ' . $tp->toHTML($var['plugin_name'], "", "defs,emotes_off, no_make_clickable");
|
||||||
$plugin_config_icon = "<a class='btn btn-default' title='{$conf_title}' href='" . $var['plugin_admin_url'] . "' >" . ADMIN_CONFIGURE_ICON . "</a>";
|
$plugin_config_icon = "<a class='btn btn-default' title='{$conf_title}' href='" . $var['plugin_admin_url'] . "' >" . ADMIN_CONFIGURE_ICON . "</a>";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -908,9 +933,7 @@ class plugin_form_ui extends e_admin_form_ui
|
|||||||
|
|
||||||
if($var['plugin_version'] != $var['plugin_version_file'] && $var['plugin_installflag'])
|
if($var['plugin_version'] != $var['plugin_version_file'] && $var['plugin_installflag'])
|
||||||
{
|
{
|
||||||
// $text .= "<br /><input type='button' class='btn' onclick=\"location.href='".e_SELF."?upgrade.{$var['plugin_id']}'\" title='".EPL_UPGRADE." to v".$var['@attributes']['version']."' value='".EPL_UPGRADE."' />";
|
$text .= "<a class='btn btn-default' href='" . e_SELF . "?mode=".$mode."&action=upgrade&id={$var['plugin_path']}' title=\"" . EPL_UPGRADE . " v" . $var['plugin_version'] . "\" >" . ADMIN_UPGRADEPLUGIN_ICON . "</a>";
|
||||||
e107::getMessage()->addInfo("<b>" . $tp->toHtml($var['plugin_name'], false, 'TITLE') . "</b> is ready to be upgraded. (see below)"); // TODO LAN
|
|
||||||
$text .= "<a class='btn btn-default' href='" . e_SELF . "?mode=".$mode."&action=upgrade&id={$var['plugin_path']}' title=\"" . EPL_UPGRADE . " v" . $var['@attributes']['version'] . "\" >" . ADMIN_UPGRADEPLUGIN_ICON . "</a>";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($var['plugin_installflag'] && e_DEBUG == true)
|
if($var['plugin_installflag'] && e_DEBUG == true)
|
||||||
|
@@ -139,6 +139,7 @@ class e_plugin
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function getAuthor($type='name')
|
public function getAuthor($type='name')
|
||||||
{
|
{
|
||||||
if(!isset($this->_data[$this->_plugdir]['author']['@attributes'][$type]))
|
if(!isset($this->_data[$this->_plugdir]['author']['@attributes'][$type]))
|
||||||
@@ -152,8 +153,6 @@ class e_plugin
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function getCategory()
|
public function getCategory()
|
||||||
{
|
{
|
||||||
if(!isset($this->_data[$this->_plugdir]['category']))
|
if(!isset($this->_data[$this->_plugdir]['category']))
|
||||||
@@ -234,11 +233,42 @@ class e_plugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the current plugin is a legacy plugin which doesn't use plugin.xml
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function isLegacy()
|
||||||
|
{
|
||||||
|
return $this->_data[$this->_plugdir]['legacy'];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function getUpgradableList()
|
||||||
|
{
|
||||||
|
$needed = array();
|
||||||
|
|
||||||
|
foreach($this->_installed as $path=>$curVal)
|
||||||
|
{
|
||||||
|
|
||||||
|
$version = $this->load($path)->getVersion();
|
||||||
|
|
||||||
|
if(version_compare($curVal,$version,"<")) // check pref version against file version.
|
||||||
|
{
|
||||||
|
$needed[$path] = $version;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return !empty($needed) ? $needed : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private function initIDs()
|
private function initIDs()
|
||||||
{
|
{
|
||||||
$sql = e107::getDb();
|
$sql = e107::getDb();
|
||||||
|
|
||||||
if ($rows = $sql->retrieve("plugin", "plugin_id,plugin_path,plugin_installflag", "plugin_id != '' ORDER by plugin_path ", true))
|
if ($rows = $sql->retrieve("plugin", "*", "plugin_id != '' ORDER by plugin_path ", true))
|
||||||
{
|
{
|
||||||
|
|
||||||
foreach($rows as $row)
|
foreach($rows as $row)
|
||||||
@@ -248,7 +278,7 @@ class e_plugin
|
|||||||
|
|
||||||
if(!empty($row['plugin_installflag']))
|
if(!empty($row['plugin_installflag']))
|
||||||
{
|
{
|
||||||
$this->_installed[$path] = $path;
|
$this->_installed[$path] = $row['plugin_version'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_addons[$path] = !empty($row['plugin_addons']) ? explode(',',$row['plugin_addons']) : null;// $path;
|
$this->_addons[$path] = !empty($row['plugin_addons']) ? explode(',',$row['plugin_addons']) : null;// $path;
|
||||||
@@ -350,7 +380,7 @@ class e_plugin
|
|||||||
$mes = e107::getMessage();
|
$mes = e107::getMessage();
|
||||||
|
|
||||||
|
|
||||||
e107::getDebug()->log("Parsing Plugin: ".$plugName);
|
|
||||||
|
|
||||||
// $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');
|
||||||
@@ -419,7 +449,7 @@ class e_plugin
|
|||||||
$ret['administration']['caption'] = varset($ret['adminLinks']['link'][0]['@attributes']['description']);
|
$ret['administration']['caption'] = varset($ret['adminLinks']['link'][0]['@attributes']['description']);
|
||||||
$ret['administration']['iconSmall'] = varset($ret['adminLinks']['link'][0]['@attributes']['iconSmall']);
|
$ret['administration']['iconSmall'] = varset($ret['adminLinks']['link'][0]['@attributes']['iconSmall']);
|
||||||
$ret['administration']['configFile'] = varset($ret['adminLinks']['link'][0]['@attributes']['url']);
|
$ret['administration']['configFile'] = varset($ret['adminLinks']['link'][0]['@attributes']['url']);
|
||||||
|
$ret['legacy'] = false;
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
|
|
||||||
@@ -523,7 +553,7 @@ class e_plugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
$ret['files'] = preg_grep('/^([^.])/', scandir(e_PLUGIN.$plugName,SCANDIR_SORT_ASCENDING));
|
$ret['files'] = preg_grep('/^([^.])/', scandir(e_PLUGIN.$plugName,SCANDIR_SORT_ASCENDING));
|
||||||
|
$ret['legacy'] = true;
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
|
|
||||||
@@ -846,27 +876,33 @@ class e107plugin
|
|||||||
require_once(e_HANDLER."db_verify_class.php");
|
require_once(e_HANDLER."db_verify_class.php");
|
||||||
$dbv = new db_verify;
|
$dbv = new db_verify;
|
||||||
|
|
||||||
|
|
||||||
|
$plg = e107::getPlug();
|
||||||
|
|
||||||
foreach($plugVersions as $path=>$version)
|
foreach($plugVersions as $path=>$version)
|
||||||
{
|
{
|
||||||
$fullPath = e_PLUGIN.$path."/plugin.xml";
|
if($plg->isLegacy() === true)
|
||||||
if(file_exists(e_PLUGIN.$path."/plugin.xml"))
|
{
|
||||||
{
|
continue;
|
||||||
$data = $xml->loadXMLfile($fullPath, true);
|
}
|
||||||
|
|
||||||
|
$data = $plg->load($path)->getMeta();
|
||||||
|
|
||||||
|
// $data = $xml->loadXMLfile($fullPath, true);
|
||||||
|
|
||||||
if(!isset($this->core_plugins[$path])) // check non-core plugins for sql file changes.
|
if(!isset($this->core_plugins[$path])) // check non-core plugins for sql file changes.
|
||||||
{
|
{
|
||||||
$dbv->errors = array();
|
$dbv->errors = array();
|
||||||
$dbv->compare($path);
|
$dbv->compare($path);
|
||||||
|
|
||||||
if($dbv->errors())
|
if($dbv->errors())
|
||||||
{
|
{
|
||||||
$needed[$path] = $data;
|
$needed[$path] = $data;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$curVal = floatval($version);
|
$curVal = floatval($version);
|
||||||
$fileVal = floatval($data['@attributes']['version']);
|
$fileVal = $plg->getVersion(); // floatval($data['@attributes']['version']);
|
||||||
|
|
||||||
if($ret = $this->execute_function($path, 'upgrade', 'required', array($this, $curVal, $fileVal))) // Check {plugin}_setup.php and run a 'required' method, if true, then update is required.
|
if($ret = $this->execute_function($path, 'upgrade', 'required', array($this, $curVal, $fileVal))) // Check {plugin}_setup.php and run a 'required' method, if true, then update is required.
|
||||||
{
|
{
|
||||||
@@ -893,7 +929,7 @@ class e107plugin
|
|||||||
// $log->flushMessages();
|
// $log->flushMessages();
|
||||||
$needed[$path] = $data;
|
$needed[$path] = $data;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4207,6 +4243,7 @@ class e107plugin
|
|||||||
$eplug_icon = null;
|
$eplug_icon = null;
|
||||||
$eplug_icon_small = null;
|
$eplug_icon_small = null;
|
||||||
|
|
||||||
|
e107::getDebug()->log("Legacy Plugin Parse (php): ".$plugName);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
if (include(e_PLUGIN.$plugName.'/plugin.php'))
|
if (include(e_PLUGIN.$plugName.'/plugin.php'))
|
||||||
@@ -4297,6 +4334,8 @@ class e107plugin
|
|||||||
$xml = e107::getXml();
|
$xml = e107::getXml();
|
||||||
$mes = e107::getMessage();
|
$mes = e107::getMessage();
|
||||||
|
|
||||||
|
e107::getDebug()->log("Legacy Plugin Parse (xml): ".$plugName);
|
||||||
|
|
||||||
// $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';
|
if(null === $where) $where = 'plugin.xml';
|
||||||
|
@@ -990,7 +990,7 @@ i.e-cat_users-32{ background-position: -555px 0; width: 32px; height: 32px; }
|
|||||||
|
|
||||||
$pref = e107::getPref();
|
$pref = e107::getPref();
|
||||||
|
|
||||||
foreach($data as $path)
|
foreach($data as $path=>$ver)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(!e107::isInstalled($path))
|
if(!e107::isInstalled($path))
|
||||||
|
Reference in New Issue
Block a user