diff --git a/plugins/dynamix.plugin.manager/Plugins.page b/plugins/dynamix.plugin.manager/Plugins.page index 6d4688f90..38f2d4552 100644 --- a/plugins/dynamix.plugin.manager/Plugins.page +++ b/plugins/dynamix.plugin.manager/Plugins.page @@ -42,7 +42,20 @@ function resize(bind) { } } -function init() { +function updateInfo(data) { + var updates = data.split('\n'); + for (var n=0,update; update=updates[n]; n++) { + var fields = update.split('\r'); + for (var i=0,field; field=fields[i]; i++) { + var row = field.split('::'); + $('#'+row[0]).attr('data',row[1]).html(row[2]); + } + } +} +function disableButton() { + $('#plugin_list').find('input[type=button]').prop('disabled',true); +} +function initlist() { timers.plugins = setTimeout(function(){$('div.spinner.fixed').show('slow');},500); $.get('/plugins/dynamix.plugin.manager/include/ShowPlugins.php',{init:true},function(data) { clearTimeout(timers.plugins); @@ -57,19 +70,6 @@ function init() { loadlist(); }); } -function updateInfo(data) { - var updates = data.split('\n'); - for (var n=0,update; update=updates[n]; n++) { - var fields = update.split('\r'); - for (var i=0,field; field=fields[i]; i++) { - var row = field.split('::'); - $('#'+row[0]).attr('data',row[1]).html(row[2]); - } - } -} -function disableButton() { - $('#plugin_list').find('input[type=button]').prop('disabled',true); -} function loadlist(id) { $.get('/plugins/dynamix.plugin.manager/include/ShowPlugins.php',{audit:id,check:0},function(d) { var data = d.split(/\0/); @@ -81,7 +81,7 @@ function loadlist(id) { case 'update' : case 'return' : updateInfo(data[0]); break; case 'remove' : list.find(tr).remove(); break; - case 'install': if (!list.find(tr).length) list.append(data[0]).trigger('update'); break; + case 'install': if (!list.find(tr).length) list.append(data[0]); break; } } else { updateInfo(data[0]); @@ -92,7 +92,7 @@ function loadlist(id) { }); } $(function() { - init(); + initlist(); $('#plugin_tree').fileTree({root:'/boot/',filter:'plg'}, function(file) {$('#plugin_file').val(file);}); $('.tabs').append(""); $('.tabs').append("' onclick='openBox(\"/plugins/dynamix.plugin.manager/scripts/checkall\",\"\",600,600,true,\"loadlist\",\":return\")' disabled>"); diff --git a/plugins/dynamix.plugin.manager/Update.page b/plugins/dynamix.plugin.manager/Update.page index d487fa7d5..59d843f4b 100644 --- a/plugins/dynamix.plugin.manager/Update.page +++ b/plugins/dynamix.plugin.manager/Update.page @@ -16,7 +16,6 @@ Tag="upload" */ ?>
"; $version = $branch = $date = _('unknown'); $bzroot = file_exists('/boot/previous/bzroot'); $check = $notify['unraidos'] ? 0 : 1; @@ -43,7 +42,7 @@ span.vhshift{margin-top:13px!important} var original = null; function update_table(branch) { - $('#os_list').html(""); + $('#os_list').html(""); if (original) { if (branch != original) branch = ''; } else { @@ -57,37 +56,54 @@ function update_table(branch) { function downgrade() { $.get('/plugins/dynamix.plugin.manager/include/Downgrade.php',{version:''},function(){refresh();}); } -function loadlist(id) { - $.get('/plugins/dynamix.plugin.manager/include/ShowPlugins.php',{system:'true',audit:id,check:0},function(data) { - var list = $('#os_list'); - if (id) { - var cmd = id.split(':'); - var tr = 'tr#'+cmd[0].replace(/[\. _]/g,''); - switch (cmd[1]) { - case 'return' : list.html(data); break; - case 'update': - case 'install': list.find(tr).remove(); list.append(data); break; - } - } else { - list.html(data); +function updateInfo(data) { + var updates = data.split('\n'); + for (var n=0,update; update=updates[n]; n++) { + var fields = update.split('\r'); + for (var i=0,field; field=fields[i]; i++) { + var row = field.split('::'); + $('#'+row[0]).attr('data',row[1]).html(row[2]); } + } +} +function initlist() { + $.get('/plugins/dynamix.plugin.manager/include/ShowPlugins.php',{init:true,system:true},function(data) { + $('#os_list').html(data); $('#change_branch').prop('disabled',true); $('#previous').show(); + loadlist(); + }); +} +function loadlist(id) { + $.get('/plugins/dynamix.plugin.manager/include/ShowPlugins.php',{system:true,audit:id,check:0},function(data) { + var list = $('#os_list'); + if (id) { + var cmd = id.split(':'); + var tr = 'tr#'+cmd[0].replace(/[\. _]/g,''); + switch (cmd[1]) { + case 'update': + case 'return' : updateInfo(data); break; + case 'install': list.find(tr).remove(); list.append(data); break; + } + } else { + updateInfo(data); + } + $('#os_table').trigger('update'); $('#checkos').prop('disabled',false); }); } $(function() { - loadlist(); + initlist(); $('.tabs').append("' onclick='openBox(\"/plugins/dynamix.plugin.manager/scripts/plugin&arg1=checkos\",\"\",600,600,true,\"loadlist\",\":return\")' disabled>"); }); - + diff --git a/plugins/dynamix.plugin.manager/include/ShowPlugins.php b/plugins/dynamix.plugin.manager/include/ShowPlugins.php index 2860dfa2c..45efa6e70 100644 --- a/plugins/dynamix.plugin.manager/include/ShowPlugins.php +++ b/plugins/dynamix.plugin.manager/include/ShowPlugins.php @@ -29,17 +29,44 @@ $updates = 0; $builtin = ['unRAIDServer']; $plugins = "/var/log/plugins/*.plg"; $ncsi = null; // network connection status indicator -$default = ""; -if ($init) { - foreach (glob($plugins,GLOB_NOSORT) as $plugin_link) { - //only consider symlinks - $plugin_file = @readlink($plugin_link); - if ($plugin_file===false) continue; - //plugin name - $name = plugin('name',$plugin_file) ?: basename($plugin_file,".plg"); - //skip system plugin - if (in_array($name,$builtin)) continue; +if ($audit) { + [$plg,$action] = explode(':',$audit); + switch ($action) { + case 'return' : $check = true; break; + case 'remove' : return; + case 'install': $install = true; + case 'update' : $plugins = "/var/log/plugins/$plg.plg"; break; + } +} + +foreach (glob($plugins,GLOB_NOSORT) as $plugin_link) { + //only consider symlinks + $plugin_file = @readlink($plugin_link); + if ($plugin_file === false) continue; + //plugin name + $name = plugin('name',$plugin_file) ?: basename($plugin_file,".plg"); + $user = in_array($name,$builtin); + //switch between system and user plugins + if (($system && !$user) || (!$system && $user)) continue; + if ($init || $install) { + //OS update? + $os = $system && $name==$builtin[0]; + $past = false; + //toggle stable/next release? + if ($os && $branch) { + $past = plugin('version',$plugin_file); + $tmp_plg = "$name-.plg"; + $tmp_file = "/var/tmp/$name.plg"; + copy($plugin_file,$tmp_file); + exec("sed -ri 's|^(|' $tmp_file"); + symlink($tmp_file,"/var/log/plugins/$tmp_plg"); + $next = end(explode("\n",check_plugin($tmp_plg,$ncsi))); + if (version_compare($next,$past,'>')) { + copy("/tmp/plugins/$tmp_plg",$tmp_file); + $plugin_file = $tmp_file; + } + } //icon + link $launch = plugin('launch',$plugin_file); if ($icon = plugin('icon',$plugin_file)) { @@ -69,6 +96,8 @@ if ($init) { //support $support = plugin('support',$plugin_file) ?: ""; $support = $support ? ""._('Support Thread')."" : ""; + //category + $category = plugin('category',$plugin_file) ?: (strpos($version,'-')!==false ? 'next' : 'stable'); //author $author = plugin('author',$plugin_file) ?: _('anonymous'); //version @@ -84,134 +113,6 @@ if ($init) { echo ""; echo ""; echo ""; - echo ""; - echo ""; - } - if ($empty) echo $default; - return; -} - -if ($audit) { - [$plg,$action] = explode(':',$audit); - switch ($action) { - case 'return' : $check = true; break; - case 'remove' : return; - case 'install': $install = true; - case 'update' : $plugins = "/var/log/plugins/$plg.plg"; break; - } -} - -foreach (glob($plugins,GLOB_NOSORT) as $plugin_link) { -//only consider symlinks - $plugin_file = @readlink($plugin_link); - if ($plugin_file === false) continue; -//plugin name - $name = plugin('name',$plugin_file) ?: basename($plugin_file,".plg"); - $custom = in_array($name,$builtin); -//switch between system and custom plugins - if (($system && !$custom) || (!$system && $custom)) continue; -//forced plugin check? - $checked = (!$audit && !$check) ? check_plugin(basename($plugin_file),$ncsi) : true; -//OS update? - $os = $system && $name==$builtin[0]; - $past = false; -//toggle stable/next release? - if ($os && $branch) { - $past = plugin('version',$plugin_file); - $tmp_plg = "$name-.plg"; - $tmp_file = "/var/tmp/$name.plg"; - copy($plugin_file,$tmp_file); - exec("sed -ri 's|^(|' $tmp_file"); - symlink($tmp_file,"/var/log/plugins/$tmp_plg"); - $next = end(explode("\n",check_plugin($tmp_plg,$ncsi))); - if (version_compare($next,$past,'>')) { - copy("/tmp/plugins/$tmp_plg",$tmp_file); - $plugin_file = $tmp_file; - } - } - if ($system || $install) { -//link/icon - $launch = plugin('launch',$plugin_file); - if ($icon = plugin('icon',$plugin_file)) { - if (substr($icon,-4)=='.png') { - if (file_exists("plugins/$name/images/$icon")) { - $icon = "plugins/$name/images/$icon"; - } elseif (file_exists("plugins/$name/$icon")) { - $icon = "plugins/$name/$icon"; - } else { - $icon = "plugins/dynamix.plugin.manager/images/dynamix.plugin.manager.png"; - } - $icon = ""; - } elseif (substr($icon,0,5)=='icon-') { - $icon = ""; - } else { - if (substr($icon,0,3)!='fa-') $icon = "fa-$icon"; - $icon = ""; - } - $link = $launch ? "$icon" : $icon; - } else { - $icon = icon($name); - $link = $launch ? "" : ""; - } -//description - $readme = "plugins/{$name}/README.md"; - $desc = file_exists($readme) ? Markdown(file_get_contents($readme)) : Markdown("**{$name}**"); -//author - $author = plugin('author',$plugin_file) ?: _('anonymous'); -//support - $support = plugin('support',$plugin_file) ?: ""; - $support = $support ? ""._('Support Thread')."" : ""; -//category - $category = plugin('category',$plugin_file) ?: (strpos($version,'-')!==false ? 'next' : 'stable'); - } -//version - $version = plugin('version',$plugin_file) ?: _('unknown'); - $date = str_replace('.','',$version); -//status - $status = _('unknown'); - $changes_file = $plugin_file; - $url = plugin('pluginURL',$plugin_file); - if ($url !== false) { - $filename = "/tmp/plugins/".(($os && $branch) ? $tmp_plg : basename($url)); - if ($checked && file_exists($filename)) { - if ($past && $past != $version) { - $status = make_link('install',$plugin_file,'forced'); - } else { - $latest = plugin('version',$filename); - if ($os ? version_compare($latest,$version,'>') : strcmp($latest,$version) > 0) { - $version .= "
$latest"; - $status = make_link("update",basename($plugin_file)); - $changes_file = $filename; - if (!$os) $updates++; - } else { - //status is considered outdated when older than 1 day - $status = filectime($filename) > (time()-86400) ? _('up-to-date') : _('need check'); - } - } - } - } - if (strpos($status,'update')!==false) $rank = '0'; - elseif (strpos($status,'install')!==false) $rank = '1'; - elseif ($status=='need check') $rank = '2'; - elseif ($status=='up-to-date') $rank = '3'; - else $rank = '4'; - $changes = plugin('changes',$changes_file); - if ($changes !== false) { - $txtfile = "/tmp/plugins/".basename($plugin_file,'.plg').".txt"; - file_put_contents($txtfile,$changes); - $version .= " "; - } -//write plugin information - $empty = false; - $id = str_replace('.','-',$name); - if ($system || $install) { -// regular table construct for system plugin or manual install - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; echo ""; echo ""; } else { -// selective updates for user plugins + //forced plugin check? + $checked = (!$audit && !$check) ? check_plugin(basename($plugin_file),$ncsi) : true; + //version + $version = plugin('version',$plugin_file) ?: _('unknown'); + $date = str_replace('.','',$version); + //status + $status = _('unknown'); + $changes_file = $plugin_file; + $url = plugin('pluginURL',$plugin_file); + if ($url !== false) { + $filename = "/tmp/plugins/".(($os && $branch) ? $tmp_plg : basename($url)); + if ($checked && file_exists($filename)) { + if ($past && $past != $version) { + $status = make_link('install',$plugin_file,'forced'); + } else { + $latest = plugin('version',$filename); + if ($os ? version_compare($latest,$version,'>') : strcmp($latest,$version) > 0) { + $version .= "
$latest"; + $status = make_link("update",basename($plugin_file)); + $changes_file = $filename; + if (!$os) $updates++; + } else { + //status is considered outdated when older than 1 day + $status = filectime($filename) > (time()-86400) ? _('up-to-date') : _('need check'); + } + } + } + } + if (strpos($status,'update')!==false) $rank = '0'; + elseif (strpos($status,'install')!==false) $rank = '1'; + elseif ($status=='need check') $rank = '2'; + elseif ($status=='up-to-date') $rank = '3'; + else $rank = '4'; + $changes = plugin('changes',$changes_file); + if ($changes !== false) { + $txtfile = "/tmp/plugins/".basename($plugin_file,'.plg').".txt"; + file_put_contents($txtfile,$changes); + $version .= " "; + } + //write plugin information + $empty = false; + $id = str_replace('.','-',$name); echo "vid-$id::$date::$version\rsid-$id::$rank::$status\n"; + //remove temporary symlink + @unlink("/var/log/plugins/$tmp_plg"); } -//remove temporary symlink - @unlink("/var/log/plugins/$tmp_plg"); } -if ($empty) echo $default; -echo "\0".$updates; +if ($empty) echo ""; +if (!$init && !$os) echo "\0".$updates; ?>
_(Component)__(Author)__(Version)__(Status)__(Branch)_
"._('No plugins installed')."
$author$version  $status".make_link('remove',basename($plugin_file))."
$link$desc $support$author$version$status"; if ($os) { $regular = ['stable','next']; @@ -225,12 +126,53 @@ foreach (glob($plugins,GLOB_NOSORT) as $plugin_link) { echo "
"._('No plugins installed')."