Subversion Repositories oidplus

Rev

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