1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-11 18:16:21 +02:00

Expanded buildAddonPrefLists() to rebuild lan_global_list as well (Used during Plugin Scan)

This commit is contained in:
Cameron
2019-01-13 13:30:58 -08:00
parent 96a4dc3683
commit 07ad8feba8

View File

@ -368,6 +368,22 @@ class e_plugin
} }
/**
* Check if the current plugin has a global lan file
* @return mixed
*/
public function hasLanGlobal()
{
if(empty($this->_plugdir))
{
e107::getDebug()->log("\$this->_plugdir is empty ".__FILE__." ". __CLASS__ ."::".__METHOD__);
return null;
}
return isset($this->_data[$this->_plugdir]['lan']) ? $this->_data[$this->_plugdir]['lan'] : false;
}
function setInstalled($plug,$version) function setInstalled($plug,$version)
{ {
$this->_installed[$plug] = $version; $this->_installed[$plug] = $version;
@ -774,6 +790,9 @@ class e_plugin
$ret['folder'] = $plugName; // remove the need for <folder> tag in plugin.xml. $ret['folder'] = $plugName; // remove the need for <folder> tag in plugin.xml.
$ret['category'] = (isset($ret['category'])) ? $this->checkCategory($ret['category']) : "misc"; $ret['category'] = (isset($ret['category'])) ? $this->checkCategory($ret['category']) : "misc";
$ret['files'] = preg_grep('/^([^.])/', scandir(e_PLUGIN.$plugName,SCANDIR_SORT_ASCENDING)); $ret['files'] = preg_grep('/^([^.])/', scandir(e_PLUGIN.$plugName,SCANDIR_SORT_ASCENDING));
$ret['lan'] = $this->_detectLanGlobal($plugName);
$ret['@attributes']['version'] = $this->_fixVersion($ret['@attributes']['version']); $ret['@attributes']['version'] = $this->_fixVersion($ret['@attributes']['version']);
$ret['@attributes']['compatibility'] = $this->_fixCompat($ret['@attributes']['compatibility']); $ret['@attributes']['compatibility'] = $this->_fixCompat($ret['@attributes']['compatibility']);
@ -932,12 +951,26 @@ 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['lan'] = $this->_detectLanGlobal($plugName);
$ret['legacy'] = true; $ret['legacy'] = true;
return $ret; return $ret;
} }
private function _detectLanGlobal($pluginDir)
{
$path_a = e_PLUGIN.$pluginDir."/languages/English_global.php"; // always check for English so we have a fall-back
$path_b = e_PLUGIN.$pluginDir."/languages/English/English_global.php";
if(file_exists($path_a) || file_exists($path_b))
{
return $pluginDir;
}
return false;
}
private function _fixVersion($ver) private function _fixVersion($ver)
{ {
@ -1010,7 +1043,8 @@ class e_plugin
// reset // reset
$core->set('bbcode_list', array()) $core->set('bbcode_list', array())
->set('shortcode_legacy_list', array()) ->set('shortcode_legacy_list', array())
->set('shortcode_list', array()); ->set('shortcode_list', array())
->set('lan_global_list', array());
$paths = $this->getDetected(); $paths = $this->getDetected();
@ -1035,6 +1069,11 @@ class e_plugin
if ($is_installed) if ($is_installed)
{ {
if($hasLAN = $this->hasLanGlobal())
{
$core->setPref('lan_global_list/'.$hasLAN, $hasLAN);
}
foreach ($tmp as $val) foreach ($tmp as $val)
{ {
if (strpos($val, 'e_') === 0) if (strpos($val, 'e_') === 0)
@ -3299,7 +3338,6 @@ class e107plugin
/** /**
* Process XML Tag <LanguageFiles> // Tag is DEPRECATED - using _install _log and _global * Process XML Tag <LanguageFiles> // Tag is DEPRECATED - using _install _log and _global
* @deprecated
* @param string $function install|uninstall|upgrade|refresh- should $when have been used? * @param string $function install|uninstall|upgrade|refresh- should $when have been used?
* @param object $tag (not used?) * @param object $tag (not used?)
* @param string $when = install|upgrade|refresh|uninstall * @param string $when = install|upgrade|refresh|uninstall