1056,6 → 1056,7 |
uasort($ary, function($a,$b) { |
if ($a == $b) return 0; |
|
$a = str_replace('\\', '/', $a); |
$ary = explode('/',$a); |
$bry = explode('/',$b); |
|
1091,12 → 1092,13 |
if ($flat) { |
$out[] = $manifest; |
} else { |
$vendor_folder = basename(dirname($ini, 3)); |
$plugintype_folder = basename(dirname($ini, 2)); |
$pluginname_folder = basename(dirname($ini)); |
|
if (!isset($out[$plugintype_folder])) $out[$plugintype_folder] = array(); |
if (!isset($out[$plugintype_folder][$pluginname_folder])) $out[$plugintype_folder][$pluginname_folder] = array(); |
$out[$plugintype_folder][$pluginname_folder] = $manifest; |
if (!isset($out[$plugintype_folder][$vendor_folder])) $out[$plugintype_folder][$vendor_folder] = array(); |
$out[$plugintype_folder][$vendor_folder][$pluginname_folder] = $manifest; |
} |
} |
return $out; |
1128,7 → 1130,8 |
$fake_feature = null; |
} |
foreach ($ary as $plugintype_folder => $bry) { |
foreach ($bry as $pluginname_folder => $manifest) { |
foreach ($bry as $vendor_folder => $cry) { |
foreach ($cry as $pluginname_folder => $manifest) { |
$class_name = $manifest->getPhpMainClass(); |
|
// Before we load the plugin, we want to make some checks to confirm |
1135,7 → 1138,7 |
// that the plugin is working correctly. |
|
if (!$class_name) { |
throw new OIDplusException(_L('Plugin "%1" is erroneous',$plugintype_folder.'/'.$pluginname_folder).': '._L('Manifest does not declare a PHP main class')); |
throw new OIDplusException(_L('Plugin "%1" is erroneous', $vendor_folder . '/' . $plugintype_folder . '/' . $pluginname_folder) . ': ' . _L('Manifest does not declare a PHP main class')); |
} |
if (!self::pluginCheckDisabled($class_name)) { |
continue; // Plugin is disabled |
1143,28 → 1146,28 |
|
// Do some basic checks on the plugin PHP main class |
if (!class_exists($class_name)) { |
throw new OIDplusException(_L('Plugin "%1" is erroneous',$plugintype_folder.'/'.$pluginname_folder).': '._L('Manifest declares PHP main class as "%1", but it could not be found',$class_name)); |
throw new OIDplusException(_L('Plugin "%1" is erroneous', $vendor_folder . '/' . $plugintype_folder . '/' . $pluginname_folder) . ': ' . _L('Manifest declares PHP main class as "%1", but it could not be found', $class_name)); |
} |
if (!is_subclass_of($class_name, $expectedPluginClass)) { |
throw new OIDplusException(_L('Plugin "%1" is erroneous',$plugintype_folder.'/'.$pluginname_folder).': '._L('Plugin main class "%1" is expected to be a subclass of "%2"',$class_name,$expectedPluginClass)); |
throw new OIDplusException(_L('Plugin "%1" is erroneous', $vendor_folder . '/' . $plugintype_folder . '/' . $pluginname_folder) . ': ' . _L('Plugin main class "%1" is expected to be a subclass of "%2"', $class_name, $expectedPluginClass)); |
} |
if (($class_name!=$manifest->getTypeClass()) && (!is_subclass_of($class_name,$manifest->getTypeClass()))) { |
throw new OIDplusException(_L('Plugin "%1" is erroneous',$plugintype_folder.'/'.$pluginname_folder).': '._L('Plugin main class "%1" is expected to be a subclass of "%2", according to type declared in manifest',$class_name,$manifest->getTypeClass())); |
throw new OIDplusException(_L('Plugin "%1" is erroneous', $vendor_folder . '/' . $plugintype_folder . '/' . $pluginname_folder) . ': ' . _L('Plugin main class "%1" is expected to be a subclass of "%2", according to type declared in manifest', $class_name, $manifest->getTypeClass())); |
} |
if (($manifest->getTypeClass()!=$expectedPluginClass) && (!is_subclass_of($manifest->getTypeClass(),$expectedPluginClass))) { |
throw new OIDplusException(_L('Plugin "%1" is erroneous',$plugintype_folder.'/'.$pluginname_folder).': '._L('Class declared in manifest is "%1" does not fit expected class for this plugin type "%2"',$manifest->getTypeClass(),$expectedPluginClass)); |
throw new OIDplusException(_L('Plugin "%1" is erroneous', $vendor_folder . '/' . $plugintype_folder . '/' . $pluginname_folder) . ': ' . _L('Class declared in manifest is "%1" does not fit expected class for this plugin type "%2"', $manifest->getTypeClass(), $expectedPluginClass)); |
} |
|
// Do some basic checks on the plugin OID |
$plugin_oid = $manifest->getOid(); |
if (!$plugin_oid) { |
throw new OIDplusException(_L('Plugin "%1" is erroneous',$plugintype_folder.'/'.$pluginname_folder).': '._L('Does not have an OID')); |
throw new OIDplusException(_L('Plugin "%1" is erroneous', $vendor_folder . '/' . $plugintype_folder . '/' . $pluginname_folder) . ': ' . _L('Does not have an OID')); |
} |
if (!oid_valid_dotnotation($plugin_oid, false, false, 2)) { |
throw new OIDplusException(_L('Plugin "%1" is erroneous',$plugintype_folder.'/'.$pluginname_folder).': '._L('Plugin OID "%1" is invalid (needs to be valid dot-notation)',$plugin_oid)); |
throw new OIDplusException(_L('Plugin "%1" is erroneous', $vendor_folder . '/' . $plugintype_folder . '/' . $pluginname_folder) . ': ' . _L('Plugin OID "%1" is invalid (needs to be valid dot-notation)', $plugin_oid)); |
} |
if (isset($known_plugin_oids[$plugin_oid])) { |
throw new OIDplusException(_L('Plugin "%1" is erroneous',$plugintype_folder.'/'.$pluginname_folder).': '._L('The OID "%1" is already used by the plugin "%2"',$plugin_oid,$known_plugin_oids[$plugin_oid])); |
throw new OIDplusException(_L('Plugin "%1" is erroneous', $vendor_folder . '/' . $plugintype_folder . '/' . $pluginname_folder) . ': ' . _L('The OID "%1" is already used by the plugin "%2"', $plugin_oid, $known_plugin_oids[$plugin_oid])); |
} |
|
// Additional check: Are third-party plugins using ViaThinkSoft plugin folders, OIDs or class namespaces? |
1174,11 → 1177,11 |
$oid_is_viathinksoft = str_starts_with($plugin_oid, '1.3.6.1.4.1.37476.2.5.2.4.'); // { iso(1) identified-organization(3) dod(6) internet(1) private(4) enterprise(1) 37476 products(2) oidplus(5) v2(2) plugins(4) } |
$class_is_viathinksoft = str_starts_with($class_name, 'ViaThinkSoft\\'); |
if ($oid_is_viathinksoft != $class_is_viathinksoft) { |
throw new OIDplusException(_L('Plugin "%1" is erroneous',$plugintype_folder.'/'.$pluginname_folder).': '._L('Third-party plugins must not use the ViaThinkSoft PHP namespace. Please use your own vendor namespace.')); |
throw new OIDplusException(_L('Plugin "%1" is erroneous', $vendor_folder . '/' . $plugintype_folder . '/' . $pluginname_folder) . ': ' . _L('Third-party plugins must not use the ViaThinkSoft PHP namespace. Please use your own vendor namespace.')); |
} |
$plugin_is_viathinksoft = $oid_is_viathinksoft && $class_is_viathinksoft; |
if ($dir_is_viathinksoft != $plugin_is_viathinksoft) { |
throw new OIDplusException(_L('Plugin "%1" is misplaced',$plugintype_folder.'/'.$pluginname_folder).': '._L('The plugin is in the wrong folder. The folder %1 can only be used by official ViaThinkSoft plugins','plugins/viathinksoft/')); |
throw new OIDplusException(_L('Plugin "%1" is misplaced', $vendor_folder . '/' . $plugintype_folder . '/' . $pluginname_folder) . ': ' . _L('The plugin is in the wrong folder. The folder %1 can only be used by official ViaThinkSoft plugins', 'plugins/viathinksoft/')); |
} |
|
// Additional check: does the plugin define JS/CSS although it is not an interactive plugin type? |
1187,10 → 1190,10 |
$is_interactive = in_array(basename($plugintype_folder), OIDplus::INTERACTIVE_PLUGIN_TYPES); |
$is_design = basename($plugintype_folder) === 'design'; |
if (!$is_interactive && $has_js) { |
throw new OIDplusException(_L('Plugin "%1" is erroneous',$plugintype_folder.'/'.$pluginname_folder).': '._L('%1 files are included in the manifest XML, but this plugin type does not allow such files.','JavaScript')); |
throw new OIDplusException(_L('Plugin "%1" is erroneous', $vendor_folder . '/' . $plugintype_folder . '/' . $pluginname_folder) . ': ' . _L('%1 files are included in the manifest XML, but this plugin type does not allow such files.', 'JavaScript')); |
} |
if (!$is_interactive && !$is_design && $has_css) { |
throw new OIDplusException(_L('Plugin "%1" is erroneous',$plugintype_folder.'/'.$pluginname_folder).': '._L('%1 files are included in the manifest XML, but this plugin type does not allow such files.','CSS')); |
throw new OIDplusException(_L('Plugin "%1" is erroneous', $vendor_folder . '/' . $plugintype_folder . '/' . $pluginname_folder) . ': ' . _L('%1 files are included in the manifest XML, but this plugin type does not allow such files.', 'CSS')); |
} |
|
// Additional check: Check "Setup CSS" and "Setup JS" (Allowed for plugin types: database, captcha) |
1199,10 → 1202,10 |
$is_database = basename($plugintype_folder) === 'database'; |
$is_captcha = basename($plugintype_folder) === 'captcha'; |
if (!$is_database && !$is_captcha && $has_js_setup) { |
throw new OIDplusException(_L('Plugin "%1" is erroneous',$plugintype_folder.'/'.$pluginname_folder).': '._L('%1 files are included in the manifest XML, but this plugin type does not allow such files.','Setup JavaScript')); |
throw new OIDplusException(_L('Plugin "%1" is erroneous', $vendor_folder . '/' . $plugintype_folder . '/' . $pluginname_folder) . ': ' . _L('%1 files are included in the manifest XML, but this plugin type does not allow such files.', 'Setup JavaScript')); |
} |
if (!$is_database && !$is_captcha && $has_css_setup) { |
throw new OIDplusException(_L('Plugin "%1" is erroneous',$plugintype_folder.'/'.$pluginname_folder).': '._L('%1 files are included in the manifest XML, but this plugin type does not allow such files.','Setup CSS')); |
throw new OIDplusException(_L('Plugin "%1" is erroneous', $vendor_folder . '/' . $plugintype_folder . '/' . $pluginname_folder) . ': ' . _L('%1 files are included in the manifest XML, but this plugin type does not allow such files.', 'Setup CSS')); |
} |
|
// Additional check: Are all CSS/JS files there? |
1209,7 → 1212,7 |
$tmp = $manifest->getManifestLinkedFiles(); |
foreach ($tmp as $file) { |
if (!file_exists($file)) { |
throw new OIDplusException(_L('Plugin "%1" is erroneous',$plugintype_folder.'/'.$pluginname_folder).': '._L('File %1 was defined in manifest, but it is not existing',$file)); |
throw new OIDplusException(_L('Plugin "%1" is erroneous', $vendor_folder . '/' . $plugintype_folder . '/' . $pluginname_folder) . ': ' . _L('File %1 was defined in manifest, but it is not existing', $file)); |
} |
} |
|
1222,12 → 1225,12 |
if (OIDplus::baseConfig()->getValue('DEBUG')) { |
if ($obj->implementsFeature($fake_feature)) { |
// see https://devblogs.microsoft.com/oldnewthing/20040211-00/?p=40663 |
throw new OIDplusException(_L('Plugin "%1" is erroneous',$plugintype_folder.'/'.$pluginname_folder).': '._L('implementsFeature() always returns true')); |
throw new OIDplusException(_L('Plugin "%1" is erroneous', $vendor_folder . '/' . $plugintype_folder . '/' . $pluginname_folder) . ': ' . _L('implementsFeature() always returns true')); |
} |
} |
|
// Now we can continue |
$known_plugin_oids[$plugin_oid] = $plugintype_folder.'/'.$pluginname_folder; |
$known_plugin_oids[$plugin_oid] = $vendor_folder . '/' . $plugintype_folder . '/' . $pluginname_folder; |
$out[] = $class_name; |
if (!is_null($registerCallback)) { |
call_user_func($registerCallback, $obj); |
1238,8 → 1241,8 |
//forward_static_call($registerCallback, $obj); |
} |
} |
|
} |
} |
return $out; |
} |
|