some backend stuff for apps
This commit is contained in:
parent
8b233723c5
commit
e68bb132a7
53
include/apps.php
Normal file
53
include/apps.php
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<?php /** @file */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* apps
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once('include/plugin.php');
|
||||||
|
|
||||||
|
function get_system_apps() {
|
||||||
|
|
||||||
|
$ret = array();
|
||||||
|
$files = glob('app/*.apd');
|
||||||
|
if($files) {
|
||||||
|
foreach($files as $f) {
|
||||||
|
$x = parse_app_description($f);
|
||||||
|
if($x) {
|
||||||
|
$ret[] = $x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$files = glob('addon/*/*.apd');
|
||||||
|
if($files) {
|
||||||
|
foreach($files as $f) {
|
||||||
|
$n = basename($f,'.apd');
|
||||||
|
if(plugin_is_installed($n)) {
|
||||||
|
$x = parse_app_description($f);
|
||||||
|
if($x) {
|
||||||
|
$ret[] = $x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $ret;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function parse_app_description($f) {
|
||||||
|
$ret = array();
|
||||||
|
|
||||||
|
$lines = @file($f);
|
||||||
|
if($lines) {
|
||||||
|
foreach($lines as $x) {
|
||||||
|
if(preg_match('/^([a-zA-Z].*?):(.*?)$/ism',$x,$matches)) {
|
||||||
|
$ret[$matches[1]] = trim($matches[2]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $ret;
|
||||||
|
}
|
@ -94,6 +94,17 @@ function load_plugin($plugin) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function plugin_is_installed($name) {
|
||||||
|
$r = q("select name from addon where name = '%s' and installed = 1 limit 1",
|
||||||
|
dbesc($name)
|
||||||
|
);
|
||||||
|
if($r)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// reload all updated plugins
|
// reload all updated plugins
|
||||||
|
|
||||||
function reload_plugins() {
|
function reload_plugins() {
|
||||||
|
22
mod/apps.php
22
mod/apps.php
@ -1,17 +1,21 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
require_once('include/apps.php');
|
||||||
|
|
||||||
function apps_content(&$a) {
|
function apps_content(&$a) {
|
||||||
|
|
||||||
$apps = $a->get_apps();
|
|
||||||
|
|
||||||
if(count($apps) == 0)
|
|
||||||
notice( t('No installed applications.') . EOL);
|
|
||||||
|
|
||||||
|
|
||||||
$tpl = get_markup_template("apps.tpl");
|
$apps = get_system_apps();
|
||||||
return replace_macros($tpl, array(
|
|
||||||
'$title' => t('Applications'),
|
$o .= print_r($apps,true);
|
||||||
'$apps' => $apps,
|
|
||||||
));
|
return $o;
|
||||||
|
|
||||||
|
// $tpl = get_markup_template("apps.tpl");
|
||||||
|
// return replace_macros($tpl, array(
|
||||||
|
// '$title' => t('Applications'),
|
||||||
|
// '$apps' => $apps,
|
||||||
|
// ));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1 +1 @@
|
|||||||
2014-05-14.675
|
2014-05-15.676
|
||||||
|
Reference in New Issue
Block a user