mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-19 23:55:19 +00:00
code optimisation
This commit is contained in:
parent
9c9d6363af
commit
ed16660867
4 changed files with 13 additions and 30 deletions
|
@ -27,27 +27,11 @@ class Siteinfo extends \Zotlabs\Web\Controller {
|
|||
else {
|
||||
$version = $commit = '';
|
||||
}
|
||||
$visible_plugins = array();
|
||||
if(is_array(\App::$plugins) && count(\App::$plugins)) {
|
||||
$r = q("select * from addon where hidden = 0");
|
||||
if(count($r))
|
||||
foreach($r as $rr)
|
||||
$visible_plugins[] = $rr['aname'];
|
||||
}
|
||||
$plugins_list = '';
|
||||
if(count($visible_plugins)) {
|
||||
$plugins_text = t('Installed plugins/addons/apps:');
|
||||
$sorted = $visible_plugins;
|
||||
$s = '';
|
||||
sort($sorted);
|
||||
foreach($sorted as $p) {
|
||||
if(strlen($p)) {
|
||||
if(strlen($s)) $s .= ', ';
|
||||
$s .= $p;
|
||||
}
|
||||
}
|
||||
$plugins_list .= $s;
|
||||
}
|
||||
|
||||
$plugins_list = implode(', ',visible_plugin_list());
|
||||
|
||||
if($plugins_list)
|
||||
$plugins_text = t('Installed plugins/addons/apps:');
|
||||
else
|
||||
$plugins_text = t('No installed plugins/addons/apps');
|
||||
|
||||
|
|
|
@ -1992,14 +1992,7 @@ function get_site_info() {
|
|||
else
|
||||
$service_class = false;
|
||||
|
||||
$visible_plugins = array();
|
||||
if(is_array(App::$plugins) && count(App::$plugins)) {
|
||||
$r = q("select * from addon where hidden = 0");
|
||||
if(count($r))
|
||||
foreach($r as $rr)
|
||||
$visible_plugins[] = $rr['aname'];
|
||||
}
|
||||
sort($visible_plugins);
|
||||
$visible_plugins = visible_plugin_list();
|
||||
|
||||
if(@is_dir('.git') && function_exists('shell_exec'))
|
||||
$commit = trim(@shell_exec('git log -1 --format="%h"'));
|
||||
|
|
|
@ -167,6 +167,12 @@ function reload_plugins() {
|
|||
}
|
||||
}
|
||||
|
||||
function visible_plugin_list() {
|
||||
$r = q("select * from addon where hidden = 0 order by aname asc");
|
||||
return(($r) ? ids_to_array($r,'aname') : array());
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief registers a hook.
|
||||
|
|
|
@ -2050,7 +2050,7 @@ function ids_to_array($arr,$idx = 'id') {
|
|||
$t = array();
|
||||
if($arr) {
|
||||
foreach($arr as $x) {
|
||||
if(! in_array($x[$idx],$t)) {
|
||||
if(strlen($x[$idx]) && (! in_array($x[$idx],$t))) {
|
||||
$t[] = $x[$idx];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue