Commit e16ea1ae authored by Mario's avatar Mario
Browse files

pdl editor for addon iitial commit

parent 941135a0
Pipeline #562627 passed with stage
in 1 minute and 2 seconds
......@@ -78,6 +78,23 @@ class Pdledit extends Controller {
}
}
// addons
$o .= '<h2>Addons</h2>';
$addons = plugins_installed_list();
foreach ($addons as $addon) {
$path = 'addon/' . $addon . '/Mod_' . ucfirst($addon) . '.php';
if (!file_exists($path))
continue;
$o .= '<a href="pdledit/' . $addon . '" >' . $addon . '</a>' . ((in_array($addon, $edited)) ? ' ' . t('(modified)') . ' <a href="pdledit/' . $addon . '/reset" >' . t('Reset') . '</a>': '' ) . '<br />';
}
$o .= '</div>';
// list module pdl files
......@@ -85,11 +102,25 @@ class Pdledit extends Controller {
}
$t = get_pconfig(local_channel(),'system',$module);
$s = file_get_contents(theme_include($module));
if(! $t) {
$s = '';
if(!$t) {
$sys_path = theme_include($module);
if ($sys_path) {
$s = file_get_contents($sys_path);
}
else {
$addon_path = 'addon/' . argv(1) . '/' . $module;
if (file_exists($addon_path)) {
$s = file_get_contents($addon_path);
}
}
$t = $s;
}
if(! $t) {
if(!$t) {
notice( t('Layout not found.') . EOL);
return '';
}
......
......@@ -237,18 +237,45 @@ class Pdledit_gui extends Controller {
}
}
$addons = plugins_installed_list();
if ($addons) {
foreach ($addons as $name) {
$path = 'addon/' . $name . '/Mod_' . ucfirst($name) . '.php';
if (!file_exists($path)) {
continue;
}
$ret .= '<div class="mb-2"><a href="pdledit_gui/' . $name . '">' . $name . '</a></div>';
}
}
return $ret;
}
function get_widgets($module) {
$ret = [];
$checkpaths = [
'Zotlabs/Widget/*.php'
];
$addons = plugins_installed_list();
if ($addons) {
foreach ($addons as $name) {
$path = 'addon/' . $name . '/Widget';
if (is_dir($path)) {
$checkpaths[] = $path . '/*.php';
}
}
}
foreach ($checkpaths as $path) {
$files = glob($path);
if($files) {
foreach($files as $f) {
$name = lcfirst(basename($f, '.php'));
......@@ -536,12 +563,21 @@ class Pdledit_gui extends Controller {
'modified' => true
];
$pdl_path = 'mod_' . $module . '.pdl';
$pdl = 'mod_' . $module . '.pdl';
$pdl_path = '';
$ret['pdl'] = get_pconfig(local_channel(), 'system', $pdl_path);
$ret['pdl'] = get_pconfig(local_channel(), 'system', $pdl);
if(!$ret['pdl']) {
$pdl_path = theme_include($pdl_path);
$pdl_path = theme_include($pdl);
if (!$pdl_path) {
$addon_path = 'addon/' . $module . '/' . $pdl;
if (file_exists($addon_path)) {
$pdl_path = $addon_path;
}
}
if ($pdl_path) {
$ret['pdl'] = file_get_contents($pdl_path);
$ret['modified'] = false;
......
......@@ -3,7 +3,7 @@
/**
* * Name: Categories
* * Description: Display a menu with links to categories
* * Requires: channel, articles, cards, cloud
* * Requires: channel, cloud
*/
namespace Zotlabs\Widget;
......
......@@ -2268,6 +2268,7 @@ function load_pdl() {
'module' => App::$module,
'layout' => ''
];
/**
* @hooks load_pdl
* Called when we load a PDL file or description.
......@@ -2281,20 +2282,26 @@ function load_pdl() {
$u = App::$comanche->get_channel_id();
$s = '';
if ($u)
if ($u) {
$s = get_pconfig($u, 'system', $n);
if (!$s)
}
if (!$s) {
$s = $layout;
}
if ((!$s) && (($p = theme_include($n)) != ''))
if ((!$s) && (($p = theme_include($n)) != '')) {
$s = @file_get_contents($p);
elseif (file_exists('addon/' . App::$module . '/' . $n))
}
elseif ((!$s) && file_exists('addon/' . App::$module . '/' . $n)) {
$s = @file_get_contents('addon/' . App::$module . '/' . $n);
}
$arr = [
'module' => App::$module,
'layout' => $s
];
call_hooks('alter_pdl', $arr);
$s = $arr['layout'];
......
......@@ -189,7 +189,7 @@ function plugin_is_installed($name) {
function reload_plugins() {
$plugins = get_config('system', 'addon');
if(strlen($plugins)) {
$r = q("SELECT * FROM addon WHERE installed = 1");
$r = dbq("SELECT * FROM addon WHERE installed = 1");
if(count($r))
$installed = $r;
else
......@@ -243,7 +243,7 @@ function reload_plugins() {
function plugins_installed_list() {
$r = q("select * from addon where installed = 1 order by aname asc");
$r = dbq("select * from addon where installed = 1 order by aname asc");
return(($r) ? ids_to_array($r,'aname') : []);
}
......@@ -313,7 +313,7 @@ function plugins_sync() {
*/
function visible_plugin_list() {
$r = q("select * from addon where hidden = 0 order by aname asc");
$r = dbq("select * from addon where hidden = 0 order by aname asc");
$x = (($r) ? ids_to_array($r,'aname') : array());
$y = [];
if($x) {
......@@ -392,7 +392,7 @@ function load_hooks() {
App::$hooks = [];
$r = q("SELECT * FROM hook WHERE true ORDER BY priority DESC");
$r = dbq("SELECT * FROM hook WHERE true ORDER BY priority DESC");
if($r) {
foreach($r as $rv) {
......@@ -613,6 +613,17 @@ function get_widget_info($widget){
"addon/$widget.php"
];
$addons = plugins_installed_list();
if ($addons) {
foreach ($addons as $name) {
$path = 'addon/' . $name . '/Widget/' . $ucwidget . '.php';
if (is_file($path)) {
$checkpaths[] = $path ;
}
}
}
$widget_found = false;
foreach ($checkpaths as $path) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment