Subversion Repositories oidplus

Rev

Rev 224 | Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. <?php
  2.  
  3. /*
  4.  * OIDplus 2.0
  5.  * Copyright 2019 Daniel Marschall, ViaThinkSoft
  6.  *
  7.  * Licensed under the Apache License, Version 2.0 (the "License");
  8.  * you may not use this file except in compliance with the License.
  9.  * You may obtain a copy of the License at
  10.  *
  11.  *     http://www.apache.org/licenses/LICENSE-2.0
  12.  *
  13.  * Unless required by applicable law or agreed to in writing, software
  14.  * distributed under the License is distributed on an "AS IS" BASIS,
  15.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16.  * See the License for the specific language governing permissions and
  17.  * limitations under the License.
  18.  */
  19.  
  20. if (!defined('IN_OIDPLUS')) die();
  21.  
  22. class OIDplusPageAdminPlugins extends OIDplusPagePlugin {
  23.         public static function getPluginInformation() {
  24.                 $out = array();
  25.                 $out['name'] = 'Plugins';
  26.                 $out['author'] = 'ViaThinkSoft';
  27.                 $out['version'] = null;
  28.                 $out['descriptionHTML'] = null;
  29.                 return $out;
  30.         }
  31.  
  32.         public function type() {
  33.                 return 'admin';
  34.         }
  35.  
  36.         public function priority() {
  37.                 return 800;
  38.         }
  39.  
  40.         public function action(&$handled) {
  41.         }
  42.  
  43.         public function init($html=true) {
  44.         }
  45.  
  46.         public function cfgSetValue($name, $value) {
  47.         }
  48.  
  49.         public function gui($id, &$out, &$handled) {
  50.                 $parts = explode('.',$id,2);
  51.                 if (!isset($parts[1])) $parts[1] = '';
  52.                 if ($parts[0] != 'oidplus:system_plugins') return;
  53.                 $handled = true;
  54.                 $out['title'] = "Installed plugins";
  55.                 $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? 'plugins/'.basename(dirname(__DIR__)).'/'.basename(__DIR__).'/icon_big.png' : '';
  56.  
  57.                 if (!OIDplus::authUtils()::isAdminLoggedIn()) {
  58.                         $out['icon'] = 'img/error_big.png';
  59.                         $out['text'] = '<p>You need to <a '.oidplus_link('oidplus:login').'>log in</a> as administrator.</p>';
  60.                         return $out;
  61.                 }
  62.  
  63.                 if (substr($parts[1],0,1) == '$') {
  64.                         $classname = substr($parts[1],1);
  65.                         $out['title'] = htmlentities($classname);
  66.                         $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? 'plugins/'.basename(dirname(__DIR__)).'/'.basename(__DIR__).'/icon_big.png' : '';
  67.  
  68.                         $reflector = new \ReflectionClass($classname);
  69.  
  70.                         $pluginInfo = $classname::getPluginInformation();
  71.  
  72.                         if (!isset($pluginInfo['name']) || empty($pluginInfo['name'])) $pluginInfo['name'] = 'n/a';
  73.                         if (!isset($pluginInfo['author']) || empty($pluginInfo['author'])) $pluginInfo['author'] = 'n/a';
  74.                         if (!isset($pluginInfo['version']) || empty($pluginInfo['version'])) $pluginInfo['version'] = 'n/a';
  75.                         if (!isset($pluginInfo['descriptionHTML']) || empty($pluginInfo['descriptionHTML'])) $pluginInfo['descriptionHTML'] = '';
  76.  
  77.                         $out['text'] .= '<div><label class="padding_label">Classname</label><b>'.htmlentities($classname).'</b></div>'.
  78.                                         '<div><label class="padding_label">Location</label><b>'.htmlentities(dirname($reflector->getFileName())).'</b></div>'.
  79.                                         '<div><label class="padding_label">Plugin type</label><b>'.htmlentities(get_parent_class($classname)).'</b></div>'.
  80.                                         '<div><label class="padding_label">Plugin name</label><b>'.htmlentities($pluginInfo['name']).'</b></div>'.
  81.                                         '<div><label class="padding_label">Plugin author</label><b>'.htmlentities($pluginInfo['author']).'</b></div>'.
  82.                                         '<div><label class="padding_label">Plugin version</label><b>'.htmlentities($pluginInfo['version']).'</b></div>'.
  83.                                         (!empty($pluginInfo['descriptionHTML']) ? '<br><p><b>Additional information:</b></p>' : '').
  84.                                         $pluginInfo['descriptionHTML'];
  85.                 } else {
  86.                         $show_pages_public = false;
  87.                         $show_pages_ra = false;
  88.                         $show_pages_admin = false;
  89.                         $show_db_active = false;
  90.                         $show_db_inactive = false;
  91.                         $show_obj_active = false;
  92.                         $show_obj_inactive = false;
  93.                         $show_auth = false;
  94.  
  95.                         if ($parts[1] == '') {
  96.                                 $out['title'] = "Installed plugins";
  97.                                 $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? 'plugins/'.basename(dirname(__DIR__)).'/'.basename(__DIR__).'/icon_big.png' : '';
  98.                                 $show_pages_public = true;
  99.                                 $show_pages_ra = true;
  100.                                 $show_pages_admin = true;
  101.                                 $show_db_active = true;
  102.                                 $show_db_inactive = true;
  103.                                 $show_obj_active = true;
  104.                                 $show_obj_inactive = true;
  105.                                 $show_auth = true;
  106.                         } else if ($parts[1] == 'pages') {
  107.                                 $out['title'] = "Page plugins";
  108.                                 $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? 'plugins/'.basename(dirname(__DIR__)).'/'.basename(__DIR__).'/icon_big.png' : '';
  109.                                 $show_pages_public = true;
  110.                                 $show_pages_ra = true;
  111.                                 $show_pages_admin = true;
  112.                         } else if ($parts[1] == 'pages.public') {
  113.                                 $out['title'] = "Public page plugins";
  114.                                 $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? 'plugins/'.basename(dirname(__DIR__)).'/'.basename(__DIR__).'/icon_big.png' : '';
  115.                                 $show_pages_public = true;
  116.                         } else if ($parts[1] == 'pages.ra') {
  117.                                 $out['title'] = "RA page plugins";
  118.                                 $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? 'plugins/'.basename(dirname(__DIR__)).'/'.basename(__DIR__).'/icon_big.png' : '';
  119.                                 $show_pages_ra = true;
  120.                         } else if ($parts[1] == 'pages.admin') {
  121.                                 $out['title'] = "Admin page plugins";
  122.                                 $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? 'plugins/'.basename(dirname(__DIR__)).'/'.basename(__DIR__).'/icon_big.png' : '';
  123.                                 $show_pages_admin = true;
  124.                         } else if ($parts[1] == 'objects') {
  125.                                 $out['title'] = "Object type plugins";
  126.                                 $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? 'plugins/'.basename(dirname(__DIR__)).'/'.basename(__DIR__).'/icon_big.png' : '';
  127.                                 $show_obj_active = true;
  128.                                 $show_obj_inactive = true;
  129.                         } else if ($parts[1] == 'objects.enabled') {
  130.                                 $out['title'] = "Object type plugins (enabled)";
  131.                                 $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? 'plugins/'.basename(dirname(__DIR__)).'/'.basename(__DIR__).'/icon_big.png' : '';
  132.                                 $show_obj_active = true;
  133.                         } else if ($parts[1] == 'objects.disabled') {
  134.                                 $out['title'] = "Object type plugins (disabled)";
  135.                                 $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? 'plugins/'.basename(dirname(__DIR__)).'/'.basename(__DIR__).'/icon_big.png' : '';
  136.                                 $show_obj_inactive = true;
  137.                         } else if ($parts[1] == 'database') {
  138.                                 $out['title'] = "Database provider plugins";
  139.                                 $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? 'plugins/'.basename(dirname(__DIR__)).'/'.basename(__DIR__).'/icon_big.png' : '';
  140.                                 $show_db_active = true;
  141.                                 $show_db_inactive = true;
  142.                         } else if ($parts[1] == 'database.enabled') {
  143.                                 $out['title'] = "Database provider plugins (active)";
  144.                                 $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? 'plugins/'.basename(dirname(__DIR__)).'/'.basename(__DIR__).'/icon_big.png' : '';
  145.                                 $show_db_active = true;
  146.                         } else if ($parts[1] == 'database.disabled') {
  147.                                 $out['title'] = "Database provider plugins (inactive)";
  148.                                 $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? 'plugins/'.basename(dirname(__DIR__)).'/'.basename(__DIR__).'/icon_big.png' : '';
  149.                                 $show_db_inactive = true;
  150.                         } else if ($parts[1] == 'auth') {
  151.                                 $out['title'] = "RA authentication";
  152.                                 $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? 'plugins/'.basename(dirname(__DIR__)).'/'.basename(__DIR__).'/icon_big.png' : '';
  153.                                 $show_auth = true;
  154.                         } else {
  155.                                 $out['icon'] = 'img/error_big.png';
  156.                                 $out['text'] = '<p>Invalid arguments.</p>';
  157.                                 return $out;
  158.                         }
  159.  
  160.                         if ($show_pages_public) {
  161.                                 if (count($plugins = OIDplus::getPagePlugins('public')) > 0) {
  162.                                         $out['text'] .= '<h2>Public page plugins</h2>';
  163.                                         $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
  164.                                         $out['text'] .= '<table class="table table-bordered table-striped">';
  165.                                         $out['text'] .= '       <tr>';
  166.                                         $out['text'] .= '               <th width="25%">Class name</th>';
  167.                                         $out['text'] .= '               <th width="25%">Plugin name</th>';
  168.                                         $out['text'] .= '               <th width="25%">Plugin version</th>';
  169.                                         $out['text'] .= '               <th width="25%">Plugin author</th>';
  170.                                         $out['text'] .= '       </tr>';
  171.                                         foreach ($plugins as $plugin) {
  172.                                                 $out['text'] .= '       <tr>';
  173.                                                 $pluginInfo = $plugin::getPluginInformation();
  174.                                                 $out['text'] .= '<td><a '.oidplus_link('oidplus:system_plugins.$'.get_class($plugin)).'>'.htmlentities(get_class($plugin)).'</a></td>';
  175.                                                 if (!isset($pluginInfo['name']) || empty($pluginInfo['name'])) $pluginInfo['name'] = 'n/a';
  176.                                                 if (!isset($pluginInfo['author']) || empty($pluginInfo['author'])) $pluginInfo['author'] = 'n/a';
  177.                                                 if (!isset($pluginInfo['version']) || empty($pluginInfo['version'])) $pluginInfo['version'] = 'n/a';
  178.                                                 $out['text'] .= '<td>' . htmlentities($pluginInfo['name']) . '</td>';
  179.                                                 $out['text'] .= '<td>' . htmlentities($pluginInfo['version']) . '</td>';
  180.                                                 $out['text'] .= '<td>' . htmlentities($pluginInfo['author']) . '</td>';
  181.                                                 $out['text'] .= '       </tr>';
  182.                                         }
  183.                                         $out['text'] .= '</table>';
  184.                                         $out['text'] .= '</div></div>';
  185.                                 }
  186.                         }
  187.  
  188.                         if ($show_pages_ra) {
  189.                                 if (count($plugins = OIDplus::getPagePlugins('ra')) > 0) {
  190.                                         $out['text'] .= '<h2>RA page plugins</h2>';
  191.                                         $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
  192.                                         $out['text'] .= '<table class="table table-bordered table-striped">';
  193.                                         $out['text'] .= '       <tr>';
  194.                                         $out['text'] .= '               <th width="25%">Class name</th>';
  195.                                         $out['text'] .= '               <th width="25%">Plugin name</th>';
  196.                                         $out['text'] .= '               <th width="25%">Plugin version</th>';
  197.                                         $out['text'] .= '               <th width="25%">Plugin author</th>';
  198.                                         $out['text'] .= '       </tr>';
  199.                                         foreach ($plugins as $plugin) {
  200.                                                 $out['text'] .= '       <tr>';
  201.                                                 $pluginInfo = $plugin::getPluginInformation();
  202.                                                 $out['text'] .= '<td><a '.oidplus_link('oidplus:system_plugins.$'.get_class($plugin)).'>'.htmlentities(get_class($plugin)).'</a></td>';
  203.                                                 if (!isset($pluginInfo['name']) || empty($pluginInfo['name'])) $pluginInfo['name'] = 'n/a';
  204.                                                 if (!isset($pluginInfo['author']) || empty($pluginInfo['author'])) $pluginInfo['author'] = 'n/a';
  205.                                                 if (!isset($pluginInfo['version']) || empty($pluginInfo['version'])) $pluginInfo['version'] = 'n/a';
  206.                                                 $out['text'] .= '<td>' . htmlentities($pluginInfo['name']) . '</td>';
  207.                                                 $out['text'] .= '<td>' . htmlentities($pluginInfo['version']) . '</td>';
  208.                                                 $out['text'] .= '<td>' . htmlentities($pluginInfo['author']) . '</td>';
  209.                                                 $out['text'] .= '       </tr>';
  210.                                         }
  211.                                         $out['text'] .= '</table>';
  212.                                         $out['text'] .= '</div></div>';
  213.                                 }
  214.                         }
  215.  
  216.                         if ($show_pages_admin) {
  217.                                 if (count($plugins = OIDplus::getPagePlugins('admin')) > 0) {
  218.                                         $out['text'] .= '<h2>Admin page plugins</h2>';
  219.                                         $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
  220.                                         $out['text'] .= '<table class="table table-bordered table-striped">';
  221.                                         $out['text'] .= '       <tr>';
  222.                                         $out['text'] .= '               <th width="25%">Class name</th>';
  223.                                         $out['text'] .= '               <th width="25%">Plugin name</th>';
  224.                                         $out['text'] .= '               <th width="25%">Plugin version</th>';
  225.                                         $out['text'] .= '               <th width="25%">Plugin author</th>';
  226.                                         $out['text'] .= '       </tr>';
  227.                                         foreach ($plugins as $plugin) {
  228.                                                 $out['text'] .= '       <tr>';
  229.                                                 $pluginInfo = $plugin::getPluginInformation();
  230.                                                 $out['text'] .= '<td><a '.oidplus_link('oidplus:system_plugins.$'.get_class($plugin)).'>'.htmlentities(get_class($plugin)).'</a></td>';
  231.                                                 if (!isset($pluginInfo['name']) || empty($pluginInfo['name'])) $pluginInfo['name'] = 'n/a';
  232.                                                 if (!isset($pluginInfo['author']) || empty($pluginInfo['author'])) $pluginInfo['author'] = 'n/a';
  233.                                                 if (!isset($pluginInfo['version']) || empty($pluginInfo['version'])) $pluginInfo['version'] = 'n/a';
  234.                                                 $out['text'] .= '<td>' . htmlentities($pluginInfo['name']) . '</td>';
  235.                                                 $out['text'] .= '<td>' . htmlentities($pluginInfo['version']) . '</td>';
  236.                                                 $out['text'] .= '<td>' . htmlentities($pluginInfo['author']) . '</td>';
  237.                                                 $out['text'] .= '       </tr>';
  238.                                         }
  239.                                         $out['text'] .= '</table>';
  240.                                         $out['text'] .= '</div></div>';
  241.                                 }
  242.                         }
  243.  
  244.                         if ($show_obj_active || $show_obj_inactive) {
  245.                                 $enabled = $show_obj_active ? OIDplus::getObjectTypePluginsEnabled() : array();
  246.                                 $disabled = $show_obj_inactive ? OIDplus::getObjectTypePluginsDisabled() : array();
  247.                                 if (count($plugins = array_merge($enabled, $disabled)) > 0) {
  248.                                         $out['text'] .= '<h2>Object types</h2>';
  249.                                         $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
  250.                                         $out['text'] .= '<table class="table table-bordered table-striped">';
  251.                                         $out['text'] .= '       <tr>';
  252.                                         $out['text'] .= '               <th width="25%">Class name</th>';
  253.                                         $out['text'] .= '               <th width="25%">Plugin name</th>';
  254.                                         $out['text'] .= '               <th width="25%">Plugin version</th>';
  255.                                         $out['text'] .= '               <th width="25%">Plugin author</th>';
  256.                                         $out['text'] .= '       </tr>';
  257.                                         foreach ($plugins as $plugin) {
  258.                                                 $out['text'] .= '       <tr>';
  259.                                                 $pluginInfo = $plugin::getPluginInformation();
  260.                                                 if (in_array($plugin, $enabled)) {
  261.                                                         $out['text'] .= '<td><a '.oidplus_link('oidplus:system_plugins.$'.get_class($plugin)).'>'.htmlentities(get_class($plugin)).'</a></td>';
  262.                                                 } else {
  263.                                                         $out['text'] .= '<td><a '.oidplus_link('oidplus:system_plugins.$'.get_class($plugin)).'><font color="gray">'.htmlentities(get_class($plugin)).' (disabled)</font></a></td>';
  264.                                                 }
  265.                                                 if (!isset($pluginInfo['name']) || empty($pluginInfo['name'])) $pluginInfo['name'] = 'n/a';
  266.                                                 if (!isset($pluginInfo['author']) || empty($pluginInfo['author'])) $pluginInfo['author'] = 'n/a';
  267.                                                 if (!isset($pluginInfo['version']) || empty($pluginInfo['version'])) $pluginInfo['version'] = 'n/a';
  268.                                                 $out['text'] .= '<td>' . htmlentities($pluginInfo['name']) . '</td>';
  269.                                                 $out['text'] .= '<td>' . htmlentities($pluginInfo['version']) . '</td>';
  270.                                                 $out['text'] .= '<td>' . htmlentities($pluginInfo['author']) . '</td>';
  271.                                                 $out['text'] .= '       </tr>';
  272.                                         }
  273.                                         $out['text'] .= '</table>';
  274.                                         $out['text'] .= '</div></div>';
  275.                                 }
  276.                         }
  277.  
  278.                         if ($show_db_active || $show_db_inactive) {
  279.                                 if (count($plugins = OIDplus::getDatabasePlugins()) > 0) {
  280.                                         $out['text'] .= '<h2>Database providers</h2>';
  281.                                         $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
  282.                                         $out['text'] .= '<table class="table table-bordered table-striped">';
  283.                                         $out['text'] .= '       <tr>';
  284.                                         $out['text'] .= '               <th width="25%">Class name</th>';
  285.                                         $out['text'] .= '               <th width="25%">Plugin name</th>';
  286.                                         $out['text'] .= '               <th width="25%">Plugin version</th>';
  287.                                         $out['text'] .= '               <th width="25%">Plugin author</th>';
  288.                                         $out['text'] .= '       </tr>';
  289.                                         foreach ($plugins as $plugin) {
  290.                                                 $active = $plugin::name() == OIDPLUS_DATABASE_PLUGIN;
  291.                                                 if ($active && !$show_db_active) continue;
  292.                                                 if (!$active && !$show_db_inactive) continue;
  293.  
  294.                                                 $out['text'] .= '       <tr>';
  295.                                                 $pluginInfo = $plugin::getPluginInformation();
  296.                                                 if ($plugin::name() == OIDPLUS_DATABASE_PLUGIN) {
  297.                                                         $out['text'] .= '<td><a '.oidplus_link('oidplus:system_plugins.$'.get_class($plugin)).'><b>'.htmlentities(get_class($plugin)).'</b> (active)</a></td>';
  298.                                                 } else {
  299.                                                         $out['text'] .= '<td><a '.oidplus_link('oidplus:system_plugins.$'.get_class($plugin)).'>'.htmlentities(get_class($plugin)).'</a></td>';
  300.                                                 }
  301.                                                 if (!isset($pluginInfo['name']) || empty($pluginInfo['name'])) $pluginInfo['name'] = 'n/a';
  302.                                                 if (!isset($pluginInfo['author']) || empty($pluginInfo['author'])) $pluginInfo['author'] = 'n/a';
  303.                                                 if (!isset($pluginInfo['version']) || empty($pluginInfo['version'])) $pluginInfo['version'] = 'n/a';
  304.                                                 $out['text'] .= '<td>' . htmlentities($pluginInfo['name']) . '</td>';
  305.                                                 $out['text'] .= '<td>' . htmlentities($pluginInfo['version']) . '</td>';
  306.                                                 $out['text'] .= '<td>' . htmlentities($pluginInfo['author']) . '</td>';
  307.                                                 $out['text'] .= '       </tr>';
  308.                                         }
  309.                                         $out['text'] .= '</table>';
  310.                                         $out['text'] .= '</div></div>';
  311.                                 }
  312.                         }
  313.  
  314.                         if ($show_auth) {
  315.                                 if (count($plugins = OIDplus::getAuthPlugins()) > 0) {
  316.                                         $out['text'] .= '<h2>RA authentication providers</h2>';
  317.                                         $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
  318.                                         $out['text'] .= '<table class="table table-bordered table-striped">';
  319.                                         $out['text'] .= '       <tr>';
  320.                                         $out['text'] .= '               <th width="25%">Class name</th>';
  321.                                         $out['text'] .= '               <th width="25%">Plugin name</th>';
  322.                                         $out['text'] .= '               <th width="25%">Plugin version</th>';
  323.                                         $out['text'] .= '               <th width="25%">Plugin author</th>';
  324.                                         $out['text'] .= '       </tr>';
  325.                                         foreach ($plugins as $plugin) {
  326.                                                 $out['text'] .= '       <tr>';
  327.                                                 $pluginInfo = $plugin::getPluginInformation();
  328.                                                 $out['text'] .= '<td><a '.oidplus_link('oidplus:system_plugins.$'.get_class($plugin)).'>'.htmlentities(get_class($plugin)).'</a></td>';
  329.                                                 if (!isset($pluginInfo['name']) || empty($pluginInfo['name'])) $pluginInfo['name'] = 'n/a';
  330.                                                 if (!isset($pluginInfo['author']) || empty($pluginInfo['author'])) $pluginInfo['author'] = 'n/a';
  331.                                                 if (!isset($pluginInfo['version']) || empty($pluginInfo['version'])) $pluginInfo['version'] = 'n/a';
  332.                                                 $out['text'] .= '<td>' . htmlentities($pluginInfo['name']) . '</td>';
  333.                                                 $out['text'] .= '<td>' . htmlentities($pluginInfo['version']) . '</td>';
  334.                                                 $out['text'] .= '<td>' . htmlentities($pluginInfo['author']) . '</td>';
  335.                                                 $out['text'] .= '       </tr>';
  336.                                         }
  337.                                         $out['text'] .= '</table>';
  338.                                         $out['text'] .= '</div></div>';
  339.                                 }
  340.                         }
  341.                 }
  342.         }
  343.  
  344.         public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
  345.                 if (file_exists(__DIR__.'/treeicon.png')) {
  346.                         $tree_icon = 'plugins/'.basename(dirname(__DIR__)).'/'.basename(__DIR__).'/treeicon.png';
  347.                 } else {
  348.                         $tree_icon = null; // default icon (folder)
  349.                 }
  350.  
  351.                 $tree_icon_pages = $tree_icon; // TODO
  352.                 $tree_icon_pages_public = $tree_icon; // TODO
  353.                 $tree_icon_pages_ra = $tree_icon; // TODO
  354.                 $tree_icon_pages_admin = $tree_icon; // TODO
  355.                 $tree_icon_db_active = $tree_icon; // TODO
  356.                 $tree_icon_db_inactive = $tree_icon; // TODO
  357.                 $tree_icon_obj_active = $tree_icon; // TODO
  358.                 $tree_icon_obj_inactive = $tree_icon; // TODO
  359.                 $tree_icon_auth = $tree_icon; // TODO
  360.  
  361.                 $public_plugins = array();
  362.                 foreach (OIDplus::getPagePlugins('public') as $plugin) {
  363.                         $pluginInfo = $plugin::getPluginInformation();
  364.                         $txt = (!isset($pluginInfo['name']) || empty($pluginInfo['name'])) ? get_class($plugin) : $pluginInfo['name'];
  365.  
  366.                         $public_plugins[] = array(
  367.                                 'id' => 'oidplus:system_plugins.$'.get_class($plugin),
  368.                                 'icon' => $tree_icon_pages_public,
  369.                                 'text' => $txt,
  370.                         );
  371.                 }
  372.                 $ra_plugins = array();
  373.                 foreach (OIDplus::getPagePlugins('ra') as $plugin) {
  374.                         $pluginInfo = $plugin::getPluginInformation();
  375.                         $txt = (!isset($pluginInfo['name']) || empty($pluginInfo['name'])) ? get_class($plugin) : $pluginInfo['name'];
  376.  
  377.                         $ra_plugins[] = array(
  378.                                 'id' => 'oidplus:system_plugins.$'.get_class($plugin),
  379.                                 'icon' => $tree_icon_pages_ra,
  380.                                 'text' => $txt,
  381.                         );
  382.                 }
  383.                 $admin_plugins = array();
  384.                 foreach (OIDplus::getPagePlugins('admin') as $plugin) {
  385.                         $pluginInfo = $plugin::getPluginInformation();
  386.                         $txt = (!isset($pluginInfo['name']) || empty($pluginInfo['name'])) ? get_class($plugin) : $pluginInfo['name'];
  387.  
  388.                         $admin_plugins[] = array(
  389.                                 'id' => 'oidplus:system_plugins.$'.get_class($plugin),
  390.                                 'icon' => $tree_icon_pages_admin,
  391.                                 'text' => $txt,
  392.                         );
  393.                 }
  394.                 $db_plugins = array();
  395.                 foreach (OIDplus::getDatabasePlugins() as $plugin) {
  396.                         $pluginInfo = $plugin::getPluginInformation();
  397.                         $txt = (!isset($pluginInfo['name']) || empty($pluginInfo['name'])) ? get_class($plugin) : $pluginInfo['name'];
  398.  
  399.                         if ($plugin::name() == OIDPLUS_DATABASE_PLUGIN) {
  400.                                 $db_plugins[] = array(
  401.                                         'id' => 'oidplus:system_plugins.$'.get_class($plugin),
  402.                                         'icon' => $tree_icon_db_active,
  403.                                         'text' => $txt,
  404.                                  );
  405.                         } else {
  406.                                 $db_plugins[] = array(
  407.                                         'id' => 'oidplus:system_plugins.$'.get_class($plugin),
  408.                                         'icon' => $tree_icon_db_inactive,
  409.                                         'text' => '<font color="gray">'.$txt.'</font>',
  410.                                  );
  411.                         }
  412.                 }
  413.                 $obj_plugins = array();
  414.                 $enabled = OIDplus::getObjectTypePluginsEnabled();
  415.                 $disabled = OIDplus::getObjectTypePluginsDisabled();
  416.                 foreach (array_merge($enabled, $disabled) as $plugin) {
  417.                         $pluginInfo = $plugin::getPluginInformation();
  418.                         $txt = (!isset($pluginInfo['name']) || empty($pluginInfo['name'])) ? $plugin : $pluginInfo['name'];
  419.  
  420.                         if (in_array($plugin, $enabled)) {
  421.                                 $obj_plugins[] = array(
  422.                                         'id' => 'oidplus:system_plugins.$'.get_class($plugin),
  423.                                         'icon' => $tree_icon_obj_active,
  424.                                         'text' => $txt,
  425.                                  );
  426.                         } else {
  427.                                 $obj_plugins[] = array(
  428.                                         'id' => 'oidplus:system_plugins.$'.get_class($plugin),
  429.                                         'icon' => $tree_icon_obj_inactive,
  430.                                         'text' => '<font color="gray">'.$txt.'</font>',
  431.                                  );
  432.                         }
  433.                 }
  434.                 $auth_plugins = array();
  435.                 foreach (OIDplus::getAuthPlugins() as $plugin) {
  436.                         $pluginInfo = $plugin::getPluginInformation();
  437.                         $txt = (!isset($pluginInfo['name']) || empty($pluginInfo['name'])) ? get_class($plugin) : $pluginInfo['name'];
  438.  
  439.                         $auth_plugins[] = array(
  440.                                 'id' => 'oidplus:system_plugins.$'.get_class($plugin),
  441.                                 'icon' => $tree_icon_auth,
  442.                                 'text' => $txt,
  443.                         );
  444.                 }
  445.                 $json[] = array(
  446.                         'id' => 'oidplus:system_plugins',
  447.                         'icon' => $tree_icon,
  448.                         'text' => 'Plugins',
  449.                         'children' => array(
  450.                         array(
  451.                                 'id' => 'oidplus:system_plugins.pages',
  452.                                 'icon' => $tree_icon,
  453.                                 'text' => 'Page plugins',
  454.                                 'children' => array(
  455.                                         array(
  456.                                                 'id' => 'oidplus:system_plugins.pages.public',
  457.                                                 'icon' => $tree_icon,
  458.                                                 'text' => 'Public',
  459.                                                 'children' => $public_plugins
  460.                                         ),
  461.                                         array(
  462.                                                 'id' => 'oidplus:system_plugins.pages.ra',
  463.                                                 'icon' => $tree_icon,
  464.                                                 'text' => 'RA',
  465.                                                 'children' => $ra_plugins
  466.                                         ),
  467.                                         array(
  468.                                                 'id' => 'oidplus:system_plugins.pages.admin',
  469.                                                 'icon' => $tree_icon,
  470.                                                 'text' => 'Admin',
  471.                                                 'children' => $admin_plugins
  472.                                         )
  473.                                 )
  474.                                 ),
  475.                                 array(
  476.                                         'id' => 'oidplus:system_plugins.objects',
  477.                                         'icon' => $tree_icon,
  478.                                         'text' => 'Object types',
  479.                                         'children' => $obj_plugins
  480.                                 ),
  481.                                 array(
  482.                                         'id' => 'oidplus:system_plugins.database',
  483.                                         'icon' => $tree_icon,
  484.                                         'text' => 'Database providers',
  485.                                         'children' => $db_plugins
  486.                                 ),
  487.                                 array(
  488.                                         'id' => 'oidplus:system_plugins.auth',
  489.                                         'icon' => $tree_icon,
  490.                                         'text' => 'RA authentication',
  491.                                         'children' => $auth_plugins
  492.                                 )
  493.                         )
  494.                 );
  495.  
  496.                 return true;
  497.         }
  498.  
  499.         public function tree_search($request) {
  500.                 return false;
  501.         }
  502. }
  503.