From 07ad8feba8c085e051a15bf1fee7cd27fbe04d6c Mon Sep 17 00:00:00 2001 From: Cameron Date: Sun, 13 Jan 2019 13:30:58 -0800 Subject: [PATCH] Expanded buildAddonPrefLists() to rebuild lan_global_list as well (Used during Plugin Scan) --- e107_handlers/plugin_class.php | 42 ++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/e107_handlers/plugin_class.php b/e107_handlers/plugin_class.php index bf8d5827e..f3e6a19d7 100644 --- a/e107_handlers/plugin_class.php +++ b/e107_handlers/plugin_class.php @@ -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) { $this->_installed[$plug] = $version; @@ -774,6 +790,9 @@ class e_plugin $ret['folder'] = $plugName; // remove the need for 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['lan'] = $this->_detectLanGlobal($plugName); + + $ret['@attributes']['version'] = $this->_fixVersion($ret['@attributes']['version']); $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['lan'] = $this->_detectLanGlobal($plugName); $ret['legacy'] = true; 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) { @@ -1010,7 +1043,8 @@ class e_plugin // reset $core->set('bbcode_list', array()) ->set('shortcode_legacy_list', array()) - ->set('shortcode_list', array()); + ->set('shortcode_list', array()) + ->set('lan_global_list', array()); $paths = $this->getDetected(); @@ -1035,6 +1069,11 @@ class e_plugin if ($is_installed) { + if($hasLAN = $this->hasLanGlobal()) + { + $core->setPref('lan_global_list/'.$hasLAN, $hasLAN); + } + foreach ($tmp as $val) { if (strpos($val, 'e_') === 0) @@ -3299,7 +3338,6 @@ class e107plugin /** * Process XML Tag // Tag is DEPRECATED - using _install _log and _global - * @deprecated * @param string $function install|uninstall|upgrade|refresh- should $when have been used? * @param object $tag (not used?) * @param string $when = install|upgrade|refresh|uninstall