LoxBerry::System::get_plugins

@plugins = LoxBerry::System::get_plugins(BOOL withcomments, BOOL force, $filename);

Die Funktion get_plugins liest die Pluginliste des LoxBerry und liefert einen Array zurück, der auch direkt in HTML::Template verwendet werden kann. 

Die Funktion ist primär für LoxBerry Core-Entwickler gedacht. 

Innerhalb eines Plugins wäre es denkbar, zu prüfen, ob beispielsweise ein bestimmtes, anderes Plugin installiert ist.

Der zurückgegebene Array kann direkt in HTML::Template benutzt werden. 

Wird die Funktion mit Comments ausgeführt:

Zur Identifikation ob eine Zeile ein Kommentar oder ein Plugin ist:

  • Kommentar: PLUGINDB_COMMENT ist gesetzt, und/oder
  • Plugin: PLUGINDB_NO ist gesetzt

Parameter

Parameter Funktion
(optional)

withcomments
Ist der erste Parameter = 1, werden die Kommentare der Plugindatenbank im Array mitgeliefert. Wird die Funktion von einem Plugin genutzt, kann der Parameter immer ignoriert werden.
(optional)

force
Ist der zweite Parameter = 1, wird ein mehrmaliger Aufruf immer wieder von der Disk lesen (normalerweise würde die DB nach dem ersten Aufruf gecached). In einem Plugin kann dieser Parameter immer igonriert werden.
(optional)

filename
Diese Funktion ist für LoxBerry-Core Entwickler gedacht. Wird als dritter Parameter ein Dateiname mitgegeben, wird die angegebene Datei als Plugindatenbank geöffnet. Standardwert (bei Weglassen des Parameters) ist die Original-Plugindatenbank $lbsdatadir/plugindatabase.dat.

This table describes the keys to read from plugin database, and the log level of the LB module functions LoxBerry::System::get_plugins and LoxBerry::System::plugindata (Perl), and LBSystem::get_plugins (PHP).The parameters of each plugin can be read with the following keys:

Hash-Variable pro Array-ZeileInhalt DB-Spalte
PLUGINDB_NO Plugin Number  
PLUGINDB_MD5_CHECKSUM The MD5 Hash generated of Author and E-Mail 0
PLUGINDB_AUTHOR_NAME The Plugin author name 1
PLUGINDB_AUTHOR_EMAIL The authors email address 2
PLUGINDB_VERSION The version of the plugin 3
PLUGINDB_NAME The short name of your plugin 4
PLUGINDB_FOLDER The installation folder of your plugin. Usually it is equal to NAME, but on uniqueness problems, it will be different 5
PLUGINDB_TITLE The common title of your plugin 6
PLUGINDB_INTERFACE This is the interface version of the plugin interface (currently 1.0 or 2.0) 7
PLUGINDB_AUTOUPDATE 0 … Plugin does not provide automatic updates

1 … Updates disabled

2 … Notify about Updates

3 … Automatic Updates to release versions

4 … Automatic Updates to prerelease versions
8
PLUGINDB_RELEASECFG URL to the plugin's Release Config file. This file contains the new version and the download url for the ZIP archive for new releases. Used in conjunction with AutoUpdate (see above) 9
PLUGINDB_PRERELEASECFG URL to the plugin's Pre-Release Config file. This file contains the new version and the download url for the ZIP archive for new prereleases. Used in conjunction with AutoUpdate (see above) 10
PLUGINDB_LOGLEVEL Log Level 0-7 (Tabelle siehe unten)

If set to -1, this indicates PLUGINDB_LOGLEVELS_ENABLED = 0
11
PLUGINDB_LOGLEVELS_ENABLED 0 … Plugin does not use the loglevel setting from the user in plugin management

1 … Plugin uses the loglevel setting from plugin management
PLUGINDB_ICONURI This is the calulated http URI of the plugin icon (e.g. for <img>). This is not a local filesystem path, but a webserver path  
PLUGINDB_COMMENT Only set if the line is a comment from plugindb  

Log Levels

The Log Levels are leant on the syslog log levels:

LevelName Shortcut Use when
0 Emergency LOGEMERGE… your LoxBerry burns
1 Alert LOGALERT … if the critical information also needs to be pushed to the user
2 Critical LOGCRIT … when user intervention is needed to continue operation
3 Error → Default valueLOGERR … when an error occurs but
4 Warning LOGWARN … when something is strange but does not stop operation
5 Notice LOGOK … is to inform the user that something went ok
6 Informational LOGINF … additional infos to any status
7 Debug LOGDEB … for heavy debugging that a user normally don't need.

If a user select Level 3 (Error), he get's all messages from severity 0 to severity 3. If the user selects 5, he will get everything from 0 to 5.

Verwendung

use LoxBerry::System;
use LoxBerry::Web;
my @plugins = LoxBerry::System::get_plugins();
 
 
# Or, with comments
# my @plugins = LoxBerry::System::get_plugins(1);
 
print STDERR "Plugins:\n";
foreach my $plugin (@plugins) {
    if ($plugin->{PLUGINDB_COMMENT}) {
        print STDERR "$plugin->{PLUGINDB_COMMENT}\n";
        next;
    }
    print STDERR "$plugin->{PLUGINDB_NO} $plugin->{PLUGINDB_TITLE} $plugin->{PLUGINDB_VERSION}\n";
}
 
$htmltemplate->param('PLUGINS' => \@plugins);
 
# Access a single element
print STDERR "Single element: " . $plugins[0]->{PLUGINDB_COMMENT} . "\n";
# Keep in mind, that if comments are loaded, the index also gives you comments. 
# In that case, array index is not equal plugin number

Verwendung mit HTML::Template

<TMPL_LOOP PLUGINS>
            <div style="display: flex">
                <div style="width: 100px"><img src="<TMPL_VAR PLUGINDB_ICONURI>"></div>
                <div style="min-width: 50px"><TMPL_VAR PLUGINDB_NO></div>
                <div style="min-width: 200px"><TMPL_VAR PLUGINDB_TITLE></div>
                <div style="min-width: 200px"><TMPL_VAR PLUGINDB_FOLDER></div>
                <div style="min-width: 100px"><TMPL_VAR PLUGINDB_VERSION></div>
            </div>
    </TMPL_LOOP>

Wenn die Comments geladen sind, kann mit <TMPL_IF PLUGINDB_NO> sichergestellt werden, dass nur Plugins ausgegeben werden.