Subversion Repositories oidplus

Rev

Rev 279 | 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. class OIDplusPageAdminPlugins extends OIDplusPagePluginAdmin {
  21.  
  22.         public function action(&$handled) {
  23.         }
  24.  
  25.         public function init($html=true) {
  26.         }
  27.  
  28.         public function gui($id, &$out, &$handled) {
  29.                 $parts = explode('.',$id,2);
  30.                 if (!isset($parts[1])) $parts[1] = '';
  31.                 if ($parts[0] != 'oidplus:system_plugins') return;
  32.                 $handled = true;
  33.                 $out['title'] = "Installed plugins";
  34.                 $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
  35.  
  36.                 if (!OIDplus::authUtils()::isAdminLoggedIn()) {
  37.                         $out['icon'] = 'img/error_big.png';
  38.                         $out['text'] = '<p>You need to <a '.OIDplus::gui()->link('oidplus:login').'>log in</a> as administrator.</p>';
  39.                         return;
  40.                 }
  41.  
  42.                 if (substr($parts[1],0,1) == '$') {
  43.                         $classname = substr($parts[1],1);
  44.                         $out['title'] = htmlentities($classname);
  45.                         $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
  46.  
  47.                         $reflector = new \ReflectionClass($classname);
  48.                         $pluginInfo = OIDplus::getPluginInfo($classname);
  49.  
  50.                         if (!isset($pluginInfo['name']) || empty($pluginInfo['name'])) $pluginInfo['name'] = 'n/a';
  51.                         if (!isset($pluginInfo['author']) || empty($pluginInfo['author'])) $pluginInfo['author'] = 'n/a';
  52.                         if (!isset($pluginInfo['version']) || empty($pluginInfo['version'])) $pluginInfo['version'] = 'n/a';
  53.                         if (!isset($pluginInfo['descriptionHTML']) || empty($pluginInfo['descriptionHTML'])) $pluginInfo['descriptionHTML'] = '';
  54.  
  55.                         $out['text'] .= '<div><label class="padding_label">Classname</label><b>'.htmlentities($classname).'</b></div>'.
  56.                                         '<div><label class="padding_label">Location</label><b>'.htmlentities(dirname($reflector->getFileName())).'</b></div>'.
  57.                                         '<div><label class="padding_label">Plugin type</label><b>'.htmlentities(get_parent_class($classname)).'</b></div>'.
  58.                                         '<div><label class="padding_label">Plugin name</label><b>'.htmlentities($pluginInfo['name']).'</b></div>'.
  59.                                         '<div><label class="padding_label">Plugin author</label><b>'.htmlentities($pluginInfo['author']).'</b></div>'.
  60.                                         '<div><label class="padding_label">Plugin version</label><b>'.htmlentities($pluginInfo['version']).'</b></div>'.
  61.                                         (!empty($pluginInfo['descriptionHTML']) ? '<br><p><b>Additional information:</b></p>' : '').
  62.                                         $pluginInfo['descriptionHTML'];
  63.                 } else {
  64.                         $show_pages_public = false;
  65.                         $show_pages_ra = false;
  66.                         $show_pages_admin = false;
  67.                         $show_db_active = false;
  68.                         $show_db_inactive = false;
  69.                         $show_sql_active = false;
  70.                         $show_sql_inactive = false;
  71.                         $show_obj_active = false;
  72.                         $show_obj_inactive = false;
  73.                         $show_auth = false;
  74.  
  75.                         if ($parts[1] == '') {
  76.                                 $out['title'] = "Installed plugins";
  77.                                 $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
  78.                                 $show_pages_public = true;
  79.                                 $show_pages_ra = true;
  80.                                 $show_pages_admin = true;
  81.                                 $show_db_active = true;
  82.                                 $show_db_inactive = true;
  83.                                 $show_sql_active = true;
  84.                                 $show_sql_inactive = true;
  85.                                 $show_obj_active = true;
  86.                                 $show_obj_inactive = true;
  87.                                 $show_auth = true;
  88.                         } else if ($parts[1] == 'pages') {
  89.                                 $out['title'] = "Page plugins";
  90.                                 $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
  91.                                 $show_pages_public = true;
  92.                                 $show_pages_ra = true;
  93.                                 $show_pages_admin = true;
  94.                         } else if ($parts[1] == 'pages.public') {
  95.                                 $out['title'] = "Public page plugins";
  96.                                 $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
  97.                                 $show_pages_public = true;
  98.                         } else if ($parts[1] == 'pages.ra') {
  99.                                 $out['title'] = "RA page plugins";
  100.                                 $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
  101.                                 $show_pages_ra = true;
  102.                         } else if ($parts[1] == 'pages.admin') {
  103.                                 $out['title'] = "Admin page plugins";
  104.                                 $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
  105.                                 $show_pages_admin = true;
  106.                         } else if ($parts[1] == 'objects') {
  107.                                 $out['title'] = "Object type plugins";
  108.                                 $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
  109.                                 $show_obj_active = true;
  110.                                 $show_obj_inactive = true;
  111.                         } else if ($parts[1] == 'objects.enabled') {
  112.                                 $out['title'] = "Object type plugins (enabled)";
  113.                                 $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
  114.                                 $show_obj_active = true;
  115.                         } else if ($parts[1] == 'objects.disabled') {
  116.                                 $out['title'] = "Object type plugins (disabled)";
  117.                                 $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
  118.                                 $show_obj_inactive = true;
  119.                         } else if ($parts[1] == 'database') {
  120.                                 $out['title'] = "Database provider plugins";
  121.                                 $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
  122.                                 $show_db_active = true;
  123.                                 $show_db_inactive = true;
  124.                         } else if ($parts[1] == 'database.enabled') {
  125.                                 $out['title'] = "Database provider plugins (active)";
  126.                                 $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
  127.                                 $show_db_active = true;
  128.                         } else if ($parts[1] == 'database.disabled') {
  129.                                 $out['title'] = "Database provider plugins (inactive)";
  130.                                 $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
  131.                                 $show_db_inactive = true;
  132.                         } else if ($parts[1] == 'sql') {
  133.                                 $out['title'] = "SQL slang plugins";
  134.                                 $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
  135.                                 $show_sql_active = true;
  136.                                 $show_sql_inactive = true;
  137.                         } else if ($parts[1] == 'sql.enabled') {
  138.                                 $out['title'] = "SQL slang plugins (active)";
  139.                                 $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
  140.                                 $show_sql_active = true;
  141.                         } else if ($parts[1] == 'sql.disabled') {
  142.                                 $out['title'] = "SQL slang plugins (inactive)";
  143.                                 $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
  144.                                 $show_sql_inactive = true;
  145.                         } else if ($parts[1] == 'auth') {
  146.                                 $out['title'] = "RA authentication";
  147.                                 $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
  148.                                 $show_auth = true;
  149.                         } else {
  150.                                 $out['icon'] = 'img/error_big.png';
  151.                                 $out['text'] = '<p>Invalid arguments.</p>';
  152.                                 return;
  153.                         }
  154.  
  155.                         $pp_public = array();
  156.                         $pp_ra = array();
  157.                         $pp_admin = array();
  158.                        
  159.                         foreach (OIDplus::getPagePlugins() as $plugin) {
  160.                                 if (is_subclass_of($plugin, OIDplusPagePluginPublic::class)) {
  161.                                         $pp_public[] = $plugin;
  162.                                 }
  163.                                 if (is_subclass_of($plugin, OIDplusPagePluginRa::class)) {
  164.                                         $pp_ra[] = $plugin;
  165.                                 }
  166.                                 if (is_subclass_of($plugin, OIDplusPagePluginAdmin::class)) {
  167.                                         $pp_admin[] = $plugin;
  168.                                 }
  169.                         }
  170.  
  171.                         if ($show_pages_public) {
  172.                                 if (count($plugins = $pp_public) > 0) {
  173.                                         $out['text'] .= '<h2>Public page plugins</h2>';
  174.                                         $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
  175.                                         $out['text'] .= '<table class="table table-bordered table-striped">';
  176.                                         $out['text'] .= '       <tr>';
  177.                                         $out['text'] .= '               <th width="25%">Class name</th>';
  178.                                         $out['text'] .= '               <th width="25%">Plugin name</th>';
  179.                                         $out['text'] .= '               <th width="25%">Plugin version</th>';
  180.                                         $out['text'] .= '               <th width="25%">Plugin author</th>';
  181.                                         $out['text'] .= '       </tr>';
  182.                                         foreach ($plugins as $plugin) {
  183.                                                 $out['text'] .= '       <tr>';
  184.                                                 $pluginInfo = OIDplus::getPluginInfo($plugin);
  185.                                                 $out['text'] .= '<td><a '.OIDplus::gui()->link('oidplus:system_plugins.$'.get_class($plugin)).'>'.htmlentities(get_class($plugin)).'</a></td>';
  186.                                                 if (!isset($pluginInfo['name']) || empty($pluginInfo['name'])) $pluginInfo['name'] = 'n/a';
  187.                                                 if (!isset($pluginInfo['author']) || empty($pluginInfo['author'])) $pluginInfo['author'] = 'n/a';
  188.                                                 if (!isset($pluginInfo['version']) || empty($pluginInfo['version'])) $pluginInfo['version'] = 'n/a';
  189.                                                 $out['text'] .= '<td>' . htmlentities($pluginInfo['name']) . '</td>';
  190.                                                 $out['text'] .= '<td>' . htmlentities($pluginInfo['version']) . '</td>';
  191.                                                 $out['text'] .= '<td>' . htmlentities($pluginInfo['author']) . '</td>';
  192.                                                 $out['text'] .= '       </tr>';
  193.                                         }
  194.                                         $out['text'] .= '</table>';
  195.                                         $out['text'] .= '</div></div>';
  196.                                 }
  197.                         }
  198.  
  199.                         if ($show_pages_ra) {
  200.                                 if (count($plugins = $pp_ra) > 0) {
  201.                                         $out['text'] .= '<h2>RA page plugins</h2>';
  202.                                         $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
  203.                                         $out['text'] .= '<table class="table table-bordered table-striped">';
  204.                                         $out['text'] .= '       <tr>';
  205.                                         $out['text'] .= '               <th width="25%">Class name</th>';
  206.                                         $out['text'] .= '               <th width="25%">Plugin name</th>';
  207.                                         $out['text'] .= '               <th width="25%">Plugin version</th>';
  208.                                         $out['text'] .= '               <th width="25%">Plugin author</th>';
  209.                                         $out['text'] .= '       </tr>';
  210.                                         foreach ($plugins as $plugin) {
  211.                                                 $out['text'] .= '       <tr>';
  212.                                                 $pluginInfo = OIDplus::getPluginInfo($plugin);
  213.                                                 $out['text'] .= '<td><a '.OIDplus::gui()->link('oidplus:system_plugins.$'.get_class($plugin)).'>'.htmlentities(get_class($plugin)).'</a></td>';
  214.                                                 if (!isset($pluginInfo['name']) || empty($pluginInfo['name'])) $pluginInfo['name'] = 'n/a';
  215.                                                 if (!isset($pluginInfo['author']) || empty($pluginInfo['author'])) $pluginInfo['author'] = 'n/a';
  216.                                                 if (!isset($pluginInfo['version']) || empty($pluginInfo['version'])) $pluginInfo['version'] = 'n/a';
  217.                                                 $out['text'] .= '<td>' . htmlentities($pluginInfo['name']) . '</td>';
  218.                                                 $out['text'] .= '<td>' . htmlentities($pluginInfo['version']) . '</td>';
  219.                                                 $out['text'] .= '<td>' . htmlentities($pluginInfo['author']) . '</td>';
  220.                                                 $out['text'] .= '       </tr>';
  221.                                         }
  222.                                         $out['text'] .= '</table>';
  223.                                         $out['text'] .= '</div></div>';
  224.                                 }
  225.                         }
  226.  
  227.                         if ($show_pages_admin) {
  228.                                 if (count($plugins = $pp_admin) > 0) {
  229.                                         $out['text'] .= '<h2>Admin page plugins</h2>';
  230.                                         $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
  231.                                         $out['text'] .= '<table class="table table-bordered table-striped">';
  232.                                         $out['text'] .= '       <tr>';
  233.                                         $out['text'] .= '               <th width="25%">Class name</th>';
  234.                                         $out['text'] .= '               <th width="25%">Plugin name</th>';
  235.                                         $out['text'] .= '               <th width="25%">Plugin version</th>';
  236.                                         $out['text'] .= '               <th width="25%">Plugin author</th>';
  237.                                         $out['text'] .= '       </tr>';
  238.                                         foreach ($plugins as $plugin) {
  239.                                                 $out['text'] .= '       <tr>';
  240.                                                 $pluginInfo = OIDplus::getPluginInfo($plugin);
  241.                                                 $out['text'] .= '<td><a '.OIDplus::gui()->link('oidplus:system_plugins.$'.get_class($plugin)).'>'.htmlentities(get_class($plugin)).'</a></td>';
  242.                                                 if (!isset($pluginInfo['name']) || empty($pluginInfo['name'])) $pluginInfo['name'] = 'n/a';
  243.                                                 if (!isset($pluginInfo['author']) || empty($pluginInfo['author'])) $pluginInfo['author'] = 'n/a';
  244.                                                 if (!isset($pluginInfo['version']) || empty($pluginInfo['version'])) $pluginInfo['version'] = 'n/a';
  245.                                                 $out['text'] .= '<td>' . htmlentities($pluginInfo['name']) . '</td>';
  246.                                                 $out['text'] .= '<td>' . htmlentities($pluginInfo['version']) . '</td>';
  247.                                                 $out['text'] .= '<td>' . htmlentities($pluginInfo['author']) . '</td>';
  248.                                                 $out['text'] .= '       </tr>';
  249.                                         }
  250.                                         $out['text'] .= '</table>';
  251.                                         $out['text'] .= '</div></div>';
  252.                                 }
  253.                         }
  254.  
  255.                         if ($show_obj_active || $show_obj_inactive) {
  256.                                 $enabled = $show_obj_active ? OIDplus::getObjectTypePluginsEnabled() : array();
  257.                                 $disabled = $show_obj_inactive ? OIDplus::getObjectTypePluginsDisabled() : array();
  258.                                 if (count($plugins = array_merge($enabled, $disabled)) > 0) {
  259.                                         $out['text'] .= '<h2>Object types</h2>';
  260.                                         $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
  261.                                         $out['text'] .= '<table class="table table-bordered table-striped">';
  262.                                         $out['text'] .= '       <tr>';
  263.                                         $out['text'] .= '               <th width="25%">Class name</th>';
  264.                                         $out['text'] .= '               <th width="25%">Plugin name</th>';
  265.                                         $out['text'] .= '               <th width="25%">Plugin version</th>';
  266.                                         $out['text'] .= '               <th width="25%">Plugin author</th>';
  267.                                         $out['text'] .= '       </tr>';
  268.                                         foreach ($plugins as $plugin) {
  269.                                                 $out['text'] .= '       <tr>';
  270.                                                 $pluginInfo = OIDplus::getPluginInfo($plugin);
  271.                                                 if (in_array($plugin, $enabled)) {
  272.                                                         $out['text'] .= '<td><a '.OIDplus::gui()->link('oidplus:system_plugins.$'.get_class($plugin)).'>'.htmlentities(get_class($plugin)).'</a></td>';
  273.                                                 } else {
  274.                                                         $out['text'] .= '<td><a '.OIDplus::gui()->link('oidplus:system_plugins.$'.get_class($plugin)).'><font color="gray">'.htmlentities(get_class($plugin)).' (disabled)</font></a></td>';
  275.                                                 }
  276.                                                 if (!isset($pluginInfo['name']) || empty($pluginInfo['name'])) $pluginInfo['name'] = 'n/a';
  277.                                                 if (!isset($pluginInfo['author']) || empty($pluginInfo['author'])) $pluginInfo['author'] = 'n/a';
  278.                                                 if (!isset($pluginInfo['version']) || empty($pluginInfo['version'])) $pluginInfo['version'] = 'n/a';
  279.                                                 $out['text'] .= '<td>' . htmlentities($pluginInfo['name']) . '</td>';
  280.                                                 $out['text'] .= '<td>' . htmlentities($pluginInfo['version']) . '</td>';
  281.                                                 $out['text'] .= '<td>' . htmlentities($pluginInfo['author']) . '</td>';
  282.                                                 $out['text'] .= '       </tr>';
  283.                                         }
  284.                                         $out['text'] .= '</table>';
  285.                                         $out['text'] .= '</div></div>';
  286.                                 }
  287.                         }
  288.  
  289.                         if ($show_db_active || $show_db_inactive) {
  290.                                 if (count($plugins = OIDplus::getDatabasePlugins()) > 0) {
  291.                                         $out['text'] .= '<h2>Database providers</h2>';
  292.                                         $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
  293.                                         $out['text'] .= '<table class="table table-bordered table-striped">';
  294.                                         $out['text'] .= '       <tr>';
  295.                                         $out['text'] .= '               <th width="25%">Class name</th>';
  296.                                         $out['text'] .= '               <th width="25%">Plugin name</th>';
  297.                                         $out['text'] .= '               <th width="25%">Plugin version</th>';
  298.                                         $out['text'] .= '               <th width="25%">Plugin author</th>';
  299.                                         $out['text'] .= '       </tr>';
  300.                                         foreach ($plugins as $plugin) {
  301.                                                 $active = $plugin::id() == OIDplus::baseConfig()->getValue('DATABASE_PLUGIN');
  302.                                                 if ($active && !$show_db_active) continue;
  303.                                                 if (!$active && !$show_db_inactive) continue;
  304.  
  305.                                                 $out['text'] .= '       <tr>';
  306.                                                 $pluginInfo = OIDplus::getPluginInfo($plugin);
  307.                                                 if ($active) {
  308.                                                         $out['text'] .= '<td><a '.OIDplus::gui()->link('oidplus:system_plugins.$'.get_class($plugin)).'><b>'.htmlentities(get_class($plugin)).'</b> (active)</a></td>';
  309.                                                 } else {
  310.                                                         $out['text'] .= '<td><a '.OIDplus::gui()->link('oidplus:system_plugins.$'.get_class($plugin)).'>'.htmlentities(get_class($plugin)).'</a></td>';
  311.                                                 }
  312.                                                 if (!isset($pluginInfo['name']) || empty($pluginInfo['name'])) $pluginInfo['name'] = 'n/a';
  313.                                                 if (!isset($pluginInfo['author']) || empty($pluginInfo['author'])) $pluginInfo['author'] = 'n/a';
  314.                                                 if (!isset($pluginInfo['version']) || empty($pluginInfo['version'])) $pluginInfo['version'] = 'n/a';
  315.                                                 $out['text'] .= '<td>' . htmlentities($pluginInfo['name']) . '</td>';
  316.                                                 $out['text'] .= '<td>' . htmlentities($pluginInfo['version']) . '</td>';
  317.                                                 $out['text'] .= '<td>' . htmlentities($pluginInfo['author']) . '</td>';
  318.                                                 $out['text'] .= '       </tr>';
  319.                                         }
  320.                                         $out['text'] .= '</table>';
  321.                                         $out['text'] .= '</div></div>';
  322.                                 }
  323.                         }
  324.  
  325.                         if ($show_sql_active || $show_sql_inactive) {
  326.                                 if (count($plugins = OIDplus::getSqlSlangPlugins()) > 0) {
  327.                                         $out['text'] .= '<h2>SQL slang plugins</h2>';
  328.                                         $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
  329.                                         $out['text'] .= '<table class="table table-bordered table-striped">';
  330.                                         $out['text'] .= '       <tr>';
  331.                                         $out['text'] .= '               <th width="25%">Class name</th>';
  332.                                         $out['text'] .= '               <th width="25%">Plugin name</th>';
  333.                                         $out['text'] .= '               <th width="25%">Plugin version</th>';
  334.                                         $out['text'] .= '               <th width="25%">Plugin author</th>';
  335.                                         $out['text'] .= '       </tr>';
  336.                                         foreach ($plugins as $plugin) {
  337.                                                 $active = $plugin::id() == OIDplus::db()->getSlang()::id();
  338.                                                 if ($active && !$show_sql_active) continue;
  339.                                                 if (!$active && !$show_sql_inactive) continue;
  340.  
  341.                                                 $out['text'] .= '       <tr>';
  342.                                                 $pluginInfo = OIDplus::getPluginInfo($plugin);
  343.                                                 if ($active) {
  344.                                                         $out['text'] .= '<td><a '.OIDplus::gui()->link('oidplus:system_plugins.$'.get_class($plugin)).'><b>'.htmlentities(get_class($plugin)).'</b> (active)</a></td>';
  345.                                                 } else {
  346.                                                         $out['text'] .= '<td><a '.OIDplus::gui()->link('oidplus:system_plugins.$'.get_class($plugin)).'>'.htmlentities(get_class($plugin)).'</a></td>';
  347.                                                 }
  348.                                                 if (!isset($pluginInfo['name']) || empty($pluginInfo['name'])) $pluginInfo['name'] = 'n/a';
  349.                                                 if (!isset($pluginInfo['author']) || empty($pluginInfo['author'])) $pluginInfo['author'] = 'n/a';
  350.                                                 if (!isset($pluginInfo['version']) || empty($pluginInfo['version'])) $pluginInfo['version'] = 'n/a';
  351.                                                 $out['text'] .= '<td>' . htmlentities($pluginInfo['name']) . '</td>';
  352.                                                 $out['text'] .= '<td>' . htmlentities($pluginInfo['version']) . '</td>';
  353.                                                 $out['text'] .= '<td>' . htmlentities($pluginInfo['author']) . '</td>';
  354.                                                 $out['text'] .= '       </tr>';
  355.                                         }
  356.                                         $out['text'] .= '</table>';
  357.                                         $out['text'] .= '</div></div>';
  358.                                 }
  359.                         }
  360.  
  361.                         if ($show_auth) {
  362.                                 if (count($plugins = OIDplus::getAuthPlugins()) > 0) {
  363.                                         $out['text'] .= '<h2>RA authentication providers</h2>';
  364.                                         $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
  365.                                         $out['text'] .= '<table class="table table-bordered table-striped">';
  366.                                         $out['text'] .= '       <tr>';
  367.                                         $out['text'] .= '               <th width="25%">Class name</th>';
  368.                                         $out['text'] .= '               <th width="25%">Plugin name</th>';
  369.                                         $out['text'] .= '               <th width="25%">Plugin version</th>';
  370.                                         $out['text'] .= '               <th width="25%">Plugin author</th>';
  371.                                         $out['text'] .= '       </tr>';
  372.                                         foreach ($plugins as $plugin) {
  373.                                                 $out['text'] .= '       <tr>';
  374.                                                 $pluginInfo = OIDplus::getPluginInfo($plugin);
  375.                                                 $out['text'] .= '<td><a '.OIDplus::gui()->link('oidplus:system_plugins.$'.get_class($plugin)).'>'.htmlentities(get_class($plugin)).'</a></td>';
  376.                                                 if (!isset($pluginInfo['name']) || empty($pluginInfo['name'])) $pluginInfo['name'] = 'n/a';
  377.                                                 if (!isset($pluginInfo['author']) || empty($pluginInfo['author'])) $pluginInfo['author'] = 'n/a';
  378.                                                 if (!isset($pluginInfo['version']) || empty($pluginInfo['version'])) $pluginInfo['version'] = 'n/a';
  379.                                                 $out['text'] .= '<td>' . htmlentities($pluginInfo['name']) . '</td>';
  380.                                                 $out['text'] .= '<td>' . htmlentities($pluginInfo['version']) . '</td>';
  381.                                                 $out['text'] .= '<td>' . htmlentities($pluginInfo['author']) . '</td>';
  382.                                                 $out['text'] .= '       </tr>';
  383.                                         }
  384.                                         $out['text'] .= '</table>';
  385.                                         $out['text'] .= '</div></div>';
  386.                                 }
  387.                         }
  388.                 }
  389.         }
  390.  
  391.         public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
  392.                 if (!OIDplus::authUtils()::isAdminLoggedIn()) return false;
  393.                
  394.                 if (file_exists(__DIR__.'/treeicon.png')) {
  395.                         $tree_icon = OIDplus::webpath(__DIR__).'treeicon.png';
  396.                 } else {
  397.                         $tree_icon = null; // default icon (folder)
  398.                 }
  399.  
  400.                 $tree_icon_pages = $tree_icon; // TODO
  401.                 $tree_icon_pages_public = $tree_icon; // TODO
  402.                 $tree_icon_pages_ra = $tree_icon; // TODO
  403.                 $tree_icon_pages_admin = $tree_icon; // TODO
  404.                 $tree_icon_db_active = $tree_icon; // TODO
  405.                 $tree_icon_db_inactive = $tree_icon; // TODO
  406.                 $tree_icon_sql_active = $tree_icon; // TODO
  407.                 $tree_icon_sql_inactive = $tree_icon; // TODO
  408.                 $tree_icon_obj_active = $tree_icon; // TODO
  409.                 $tree_icon_obj_inactive = $tree_icon; // TODO
  410.                 $tree_icon_auth = $tree_icon; // TODO
  411.  
  412.                 $pp_public = array();
  413.                 $pp_ra = array();
  414.                 $pp_admin = array();
  415.  
  416.                 foreach (OIDplus::getPagePlugins() as $plugin) {
  417.                         if (is_subclass_of($plugin, OIDplusPagePluginPublic::class)) {
  418.                                 $pp_public[] = $plugin;
  419.                         }
  420.                         if (is_subclass_of($plugin, OIDplusPagePluginRa::class)) {
  421.                                 $pp_ra[] = $plugin;
  422.                         }
  423.                         if (is_subclass_of($plugin, OIDplusPagePluginAdmin::class)) {
  424.                                 $pp_admin[] = $plugin;
  425.                         }
  426.                 }
  427.  
  428.  
  429.                 $public_plugins = array();
  430.                 foreach ($pp_public as $plugin) {
  431.                         $pluginInfo = OIDplus::getPluginInfo($plugin);
  432.                         $txt = (!isset($pluginInfo['name']) || empty($pluginInfo['name'])) ? get_class($plugin) : $pluginInfo['name'];
  433.  
  434.                         $public_plugins[] = array(
  435.                                 'id' => 'oidplus:system_plugins.$'.get_class($plugin),
  436.                                 'icon' => $tree_icon_pages_public,
  437.                                 'text' => $txt,
  438.                         );
  439.                 }
  440.                 $ra_plugins = array();
  441.                 foreach ($pp_ra as $plugin) {
  442.                         $pluginInfo = OIDplus::getPluginInfo($plugin);
  443.                         $txt = (!isset($pluginInfo['name']) || empty($pluginInfo['name'])) ? get_class($plugin) : $pluginInfo['name'];
  444.  
  445.                         $ra_plugins[] = array(
  446.                                 'id' => 'oidplus:system_plugins.$'.get_class($plugin),
  447.                                 'icon' => $tree_icon_pages_ra,
  448.                                 'text' => $txt,
  449.                         );
  450.                 }
  451.                 $admin_plugins = array();
  452.                 foreach ($pp_admin as $plugin) {
  453.                         $pluginInfo = OIDplus::getPluginInfo($plugin);
  454.                         $txt = (!isset($pluginInfo['name']) || empty($pluginInfo['name'])) ? get_class($plugin) : $pluginInfo['name'];
  455.  
  456.                         $admin_plugins[] = array(
  457.                                 'id' => 'oidplus:system_plugins.$'.get_class($plugin),
  458.                                 'icon' => $tree_icon_pages_admin,
  459.                                 'text' => $txt,
  460.                         );
  461.                 }
  462.                 $db_plugins = array();
  463.                 foreach (OIDplus::getDatabasePlugins() as $plugin) {
  464.                         $pluginInfo = OIDplus::getPluginInfo($plugin);
  465.                         $txt = (!isset($pluginInfo['name']) || empty($pluginInfo['name'])) ? get_class($plugin) : $pluginInfo['name'];
  466.  
  467.                         if ($plugin::id() == OIDplus::baseConfig()->getValue('DATABASE_PLUGIN')) {
  468.                                 $db_plugins[] = array(
  469.                                         'id' => 'oidplus:system_plugins.$'.get_class($plugin),
  470.                                         'icon' => $tree_icon_db_active,
  471.                                         'text' => $txt,
  472.                                  );
  473.                         } else {
  474.                                 $db_plugins[] = array(
  475.                                         'id' => 'oidplus:system_plugins.$'.get_class($plugin),
  476.                                         'icon' => $tree_icon_db_inactive,
  477.                                         'text' => '<font color="gray">'.$txt.'</font>',
  478.                                  );
  479.                         }
  480.                 }
  481.                 $sql_plugins = array();
  482.                 foreach (OIDplus::getSqlSlangPlugins() as $plugin) {
  483.                         $pluginInfo = OIDplus::getPluginInfo($plugin);
  484.                         $txt = (!isset($pluginInfo['name']) || empty($pluginInfo['name'])) ? get_class($plugin) : $pluginInfo['name'];
  485.  
  486.                         if ($plugin::id() == OIDplus::db()->getSlang()::id()) {
  487.                                 $sql_plugins[] = array(
  488.                                         'id' => 'oidplus:system_plugins.$'.get_class($plugin),
  489.                                         'icon' => $tree_icon_db_active,
  490.                                         'text' => $txt,
  491.                                  );
  492.                         } else {
  493.                                 $sql_plugins[] = array(
  494.                                         'id' => 'oidplus:system_plugins.$'.get_class($plugin),
  495.                                         'icon' => $tree_icon_db_inactive,
  496.                                         'text' => '<font color="gray">'.$txt.'</font>',
  497.                                  );
  498.                         }
  499.                 }
  500.                 $obj_plugins = array();
  501.                 $enabled = OIDplus::getObjectTypePluginsEnabled();
  502.                 $disabled = OIDplus::getObjectTypePluginsDisabled();
  503.                 foreach (array_merge($enabled, $disabled) as $plugin) {
  504.                         $pluginInfo = OIDplus::getPluginInfo($plugin);
  505.                         $txt = (!isset($pluginInfo['name']) || empty($pluginInfo['name'])) ? get_class($plugin) : $pluginInfo['name'];
  506.                         if (in_array($plugin, $enabled)) {
  507.                                 $obj_plugins[] = array(
  508.                                         'id' => 'oidplus:system_plugins.$'.get_class($plugin),
  509.                                         'icon' => $tree_icon_obj_active,
  510.                                         'text' => $txt,
  511.                                  );
  512.                         } else {
  513.                                 $obj_plugins[] = array(
  514.                                         'id' => 'oidplus:system_plugins.$'.get_class($plugin),
  515.                                         'icon' => $tree_icon_obj_inactive,
  516.                                         'text' => '<font color="gray">'.$txt.'</font>',
  517.                                  );
  518.                         }
  519.                 }
  520.                 $auth_plugins = array();
  521.                 foreach (OIDplus::getAuthPlugins() as $plugin) {
  522.                         $pluginInfo = OIDplus::getPluginInfo($plugin);
  523.                         $txt = (!isset($pluginInfo['name']) || empty($pluginInfo['name'])) ? get_class($plugin) : $pluginInfo['name'];
  524.  
  525.                         $auth_plugins[] = array(
  526.                                 'id' => 'oidplus:system_plugins.$'.get_class($plugin),
  527.                                 'icon' => $tree_icon_auth,
  528.                                 'text' => $txt,
  529.                         );
  530.                 }
  531.                 $json[] = array(
  532.                         'id' => 'oidplus:system_plugins',
  533.                         'icon' => $tree_icon,
  534.                         'text' => 'Plugins',
  535.                         'children' => array(
  536.                         array(
  537.                                 'id' => 'oidplus:system_plugins.pages',
  538.                                 'icon' => $tree_icon,
  539.                                 'text' => 'Page plugins',
  540.                                 'children' => array(
  541.                                         array(
  542.                                                 'id' => 'oidplus:system_plugins.pages.public',
  543.                                                 'icon' => $tree_icon,
  544.                                                 'text' => 'Public',
  545.                                                 'children' => $public_plugins
  546.                                         ),
  547.                                         array(
  548.                                                 'id' => 'oidplus:system_plugins.pages.ra',
  549.                                                 'icon' => $tree_icon,
  550.                                                 'text' => 'RA',
  551.                                                 'children' => $ra_plugins
  552.                                         ),
  553.                                         array(
  554.                                                 'id' => 'oidplus:system_plugins.pages.admin',
  555.                                                 'icon' => $tree_icon,
  556.                                                 'text' => 'Admin',
  557.                                                 'children' => $admin_plugins
  558.                                         )
  559.                                 )
  560.                                 ),
  561.                                 array(
  562.                                         'id' => 'oidplus:system_plugins.objects',
  563.                                         'icon' => $tree_icon,
  564.                                         'text' => 'Object types',
  565.                                         'children' => $obj_plugins
  566.                                 ),
  567.                                 array(
  568.                                         'id' => 'oidplus:system_plugins.database',
  569.                                         'icon' => $tree_icon,
  570.                                         'text' => 'Database providers',
  571.                                         'children' => $db_plugins
  572.                                 ),
  573.                                 array(
  574.                                         'id' => 'oidplus:system_plugins.sql',
  575.                                         'icon' => $tree_icon,
  576.                                         'text' => 'SQL slangs',
  577.                                         'children' => $sql_plugins
  578.                                 ),
  579.                                 array(
  580.                                         'id' => 'oidplus:system_plugins.auth',
  581.                                         'icon' => $tree_icon,
  582.                                         'text' => 'RA authentication',
  583.                                         'children' => $auth_plugins
  584.                                 )
  585.                         )
  586.                 );
  587.  
  588.                 return true;
  589.         }
  590.  
  591.         public function tree_search($request) {
  592.                 return false;
  593.         }
  594. }
  595.