Subversion Repositories oidplus

Rev

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