mirror of
https://github.com/e107inc/e107.git
synced 2025-08-10 08:34:09 +02:00
Plugin Manager rewrite - finally using admin-ui.
This commit is contained in:
@@ -71,7 +71,9 @@ class e_plugin
|
||||
|
||||
public function clearCache()
|
||||
{
|
||||
e107::getCache()->clear(self::CACHETAG);
|
||||
$this->init(true);
|
||||
$this->initIDs();
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getInstalled()
|
||||
@@ -90,6 +92,43 @@ class e_plugin
|
||||
}
|
||||
|
||||
|
||||
public function getCompat()
|
||||
{
|
||||
|
||||
if(isset($this->_data[$this->_plugdir]['@attributes']['compatibility']))
|
||||
{
|
||||
return $this->_data[$this->_plugdir]['@attributes']['compatibility'];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getInstallRequired()
|
||||
{
|
||||
|
||||
if(isset($this->_data[$this->_plugdir]['@attributes']['installRequired']))
|
||||
{
|
||||
return ($this->_data[$this->_plugdir]['@attributes']['installRequired'] === 'true') ? true : false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getVersion()
|
||||
{
|
||||
|
||||
if(isset($this->_data[$this->_plugdir]['@attributes']['version']))
|
||||
{
|
||||
return $this->_data[$this->_plugdir]['@attributes']['version'];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getDate()
|
||||
{
|
||||
if(isset($this->_data[$this->_plugdir]['@attributes']['date']))
|
||||
@@ -100,21 +139,21 @@ class e_plugin
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getAuthor()
|
||||
public function getAuthor($type='name')
|
||||
{
|
||||
if(!isset($this->_data[$this->_plugdir]['author']))
|
||||
if(!isset($this->_data[$this->_plugdir]['author']['@attributes'][$type]))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return print_r($this->_data[$this->_plugdir]['author'],true);
|
||||
|
||||
return (string) $this->_data[$this->_plugdir]['author'];
|
||||
return $this->_data[$this->_plugdir]['author']['@attributes'][$type];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function getCategory()
|
||||
{
|
||||
if(!isset($this->_data[$this->_plugdir]['category']))
|
||||
@@ -163,7 +202,7 @@ class e_plugin
|
||||
return e107::getParser()->createConstants(e_PLUGIN_ABS.$this->_plugdir.'/'.$link[$key]);
|
||||
}
|
||||
|
||||
return "<img src='".e_PLUGIN_ABS.$this->_plugdir.'/'.$link[$key] ."' alt=\"".$caption."\" class='icon S".$size."' />";
|
||||
return "<img src='".e_PLUGIN.$this->_plugdir.'/'.$link[$key] ."' alt=\"".$caption."\" class='icon S".$size."' />";
|
||||
}
|
||||
|
||||
|
||||
@@ -185,7 +224,7 @@ class e_plugin
|
||||
|
||||
public function getAdminUrl()
|
||||
{
|
||||
if(isset($this->_data[$this->_plugdir]['administration']['configFile']))
|
||||
if(!empty($this->_data[$this->_plugdir]['administration']['configFile']))
|
||||
{
|
||||
return e_PLUGIN_ABS.$this->_plugdir.'/'.$this->_data[$this->_plugdir]['administration']['configFile'];
|
||||
}
|
||||
@@ -331,7 +370,8 @@ class e_plugin
|
||||
$ret['folder'] = $plugName; // remove the need for <folder> tag in plugin.xml.
|
||||
$ret['category'] = (isset($ret['category'])) ? $this->checkCategory($ret['category']) : "misc";
|
||||
$ret['files'] = preg_grep('/^([^.])/', scandir(e_PLUGIN.$plugName,SCANDIR_SORT_ASCENDING));
|
||||
|
||||
$ret['@attributes']['version'] = $this->_fixVersion($ret['@attributes']['version']);
|
||||
$ret['@attributes']['compatibility'] = $this->_fixCompat($ret['@attributes']['compatibility']);
|
||||
|
||||
if(varset($ret['description']))
|
||||
{
|
||||
@@ -405,6 +445,8 @@ class e_plugin
|
||||
$eplug_latest = null;
|
||||
$eplug_icon = null;
|
||||
$eplug_icon_small = null;
|
||||
$eplug_compatible = null;
|
||||
$eplug_version = null;
|
||||
|
||||
|
||||
ob_start();
|
||||
@@ -419,9 +461,9 @@ class e_plugin
|
||||
|
||||
$ret['@attributes']['name'] = varset($eplug_name);
|
||||
$ret['@attributes']['lan'] = varset($eplug_name);
|
||||
$ret['@attributes']['version'] = varset($eplug_version);
|
||||
$ret['@attributes']['version'] = $this->_fixVersion($eplug_version);
|
||||
$ret['@attributes']['date'] = varset($eplug_date);
|
||||
$ret['@attributes']['compatibility'] = varset($eplug_compatible);
|
||||
$ret['@attributes']['compatibility'] = $this->_fixCompat($eplug_compatible);
|
||||
$ret['@attributes']['installRequired'] = ($eplug_conffile || is_array($eplug_table_names) || is_array($eplug_prefs) || $eplug_module || $eplug_userclass || $eplug_status || $eplug_latest) ? 'true' : '';
|
||||
$ret['@attributes']['xhtmlcompliant'] = vartrue($eplug_compliant) ? 'true' : '';
|
||||
$ret['folder'] = $plugName; // (varset($eplug_folder)) ? $eplug_folder : $plugName;
|
||||
@@ -449,18 +491,22 @@ class e_plugin
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// For BC.
|
||||
$ret['administration']['icon'] = str_replace($plugName."/","",$eplug_icon);
|
||||
$ret['administration']['icon'] = $this->_fixPath($eplug_icon,$plugName);
|
||||
$ret['administration']['caption'] = varset($eplug_caption);
|
||||
$ret['administration']['iconSmall'] = str_replace($plugName."/","",$eplug_icon_small);
|
||||
$ret['administration']['iconSmall'] = $this->_fixPath($eplug_icon_small,$plugName);
|
||||
$ret['administration']['configFile'] = varset($eplug_conffile);
|
||||
|
||||
|
||||
|
||||
if(isset($eplug_conffile))
|
||||
{
|
||||
$ret['adminLinks']['link'][0]['@attributes']['url'] = varset($eplug_conffile);
|
||||
$ret['adminLinks']['link'][0]['@attributes']['description'] = LAN_CONFIGURE;
|
||||
$ret['adminLinks']['link'][0]['@attributes']['icon'] = str_replace($plugName."/","",$eplug_icon);
|
||||
$ret['adminLinks']['link'][0]['@attributes']['iconSmall'] = str_replace($plugName."/","",$eplug_icon_small);
|
||||
$ret['adminLinks']['link'][0]['@attributes']['icon'] = $this->_fixPath($eplug_icon,$plugName); // str_replace($plugName."/","",$eplug_icon);
|
||||
$ret['adminLinks']['link'][0]['@attributes']['iconSmall'] = $this->_fixPath($eplug_icon_small,$plugName);
|
||||
$ret['adminLinks']['link'][0]['@attributes']['primary'] = 'true';
|
||||
}
|
||||
if(!empty($eplug_link) && isset($eplug_link_name) && isset($eplug_link_url))
|
||||
@@ -484,6 +530,47 @@ class e_plugin
|
||||
}
|
||||
|
||||
|
||||
private function _fixVersion($ver)
|
||||
{
|
||||
|
||||
if(empty($ver))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
$ver = str_replace('e107','',$ver);
|
||||
|
||||
|
||||
return preg_replace('/([^\d\.])/','',$ver);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private function _fixCompat($ver)
|
||||
{
|
||||
$ver = $this->_fixVersion($ver);
|
||||
$ver = str_replace('0.8','2.0',$ver);
|
||||
if($ver == 7 || intval($ver) < 1)
|
||||
{
|
||||
$ver = "1.0";
|
||||
}
|
||||
|
||||
return $ver;
|
||||
}
|
||||
|
||||
|
||||
private function _fixPath($path, $plugName)
|
||||
{
|
||||
$pathFilter = array(
|
||||
e_PLUGIN.$plugName.'/',
|
||||
$plugName."/"
|
||||
|
||||
);
|
||||
|
||||
return str_replace($pathFilter,'', $path);
|
||||
}
|
||||
|
||||
|
||||
private function checkCategory($cat)
|
||||
{
|
||||
if (!empty($cat) && in_array($cat, $this->_accepted_categories))
|
||||
|
Reference in New Issue
Block a user