update plugin support attribute if necessary whenever a new feed is downloaded

pull/11/head
Squidly271 2022-10-15 06:52:49 -04:00
parent 4a5fdd7926
commit d852e1a57d
3 changed files with 37 additions and 1 deletions

View File

@ -2,7 +2,7 @@
4e55f7483b661af21a25b677179baffe ./CA_notices.page
4c5d4598e1bafa46bd90c27cbe302122 ./ca_settings.page
e8d29607ec792ddf9f6832b10ee70fdc ./default.cfg
b8c45b1d0a811026b8d078a906e758c7 ./include/exec.php
97d647e262ed8cb7787fb2818b0cf78e ./include/exec.php
f25b1ed0b1cddfb4ff95a10ced212a0d ./include/helpers.php
116042a918060278e77379b0dd73482c ./include/paths.php
532fffdf939594c143e679da02bd841e ./javascript/libraries.js

View File

@ -398,9 +398,45 @@ function DownloadApplicationFeed() {
writeJsonFile($caPaths['repositoryList'],$ApplicationFeed['repositories']);
writeJsonFile($caPaths['extraBlacklist'],$ApplicationFeed['blacklisted']);
writeJsonFile($caPaths['extraDeprecated'],$ApplicationFeed['deprecated']);
updatePluginSupport($myTemplates);
return true;
}
function updatePluginSupport($templates) {
$plugins = glob("/boot/config/plugins/*.plg");
foreach ($plugins as $plugin) {
$pluginURL = @plugin("pluginURL",$plugin);
$pluginEntry = searchArray($templates,"PluginURL",$pluginURL);
if ( $pluginEntry === false ) {
$pluginEntry = searchArray($templates,"PluginURL",str_replace("https://raw.github.com/","https://raw.githubusercontent.com/",$pluginURL));
}
if ( $pluginEntry !== false && $templates[$pluginEntry]['PluginURL']) {
$xml = simplexml_load_file($plugin);
if ( ! $templates[$pluginEntry]['Support'] ) {
continue;
}
if ( @plugin("support",$plugin) !== $templates[$pluginEntry]['Support'] ) {
// remove existing support attribute if it exists
if ( @plugin("support",$plugin) ) {
$existing_support = $xml->xpath("//PLUGIN/@support");
foreach ($existing_support as $node) {
unset($node[0]);
}
}
$xml->addAttribute("support",$templates[$pluginEntry]['Support']);
$dom = new DOMDocument('1.0');
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
$dom->loadXML($xml->asXML());
file_put_contents($plugin, $dom->saveXML());
}
}
}
}
function getConvertedTemplates() {
global $caPaths, $caSettings, $statistics;