Subversion Repositories oidplus

Rev

Rev 1116 | Rev 1131 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. <?php
  2.  
  3. /*
  4.  * OIDplus 2.0
  5.  * Copyright 2019 - 2023 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. // ATTENTION: If you change something, please make sure that the changes
  21. //            are synchronous with OIDplusPageRaAutomatedAJAXCalls
  22.  
  23. namespace ViaThinkSoft\OIDplus;
  24.  
  25. // phpcs:disable PSR1.Files.SideEffects
  26. \defined('INSIDE_OIDPLUS') or die;
  27. // phpcs:enable PSR1.Files.SideEffects
  28.  
  29. class OIDplusPageAdminNostalgia extends OIDplusPagePluginAdmin {
  30.  
  31.         /**
  32.          * @param string $id
  33.          * @param array $out
  34.          * @param bool $handled
  35.          * @return void
  36.          * @throws OIDplusException
  37.          */
  38.         public function gui(string $id, array &$out, bool &$handled) {
  39.                 if ($id === 'oidplus:nostalgia') {
  40.                         $handled = true;
  41.                         $out['title'] = _L('Nostalgia');
  42.                         $out['icon'] = file_exists(__DIR__.'/img/main_icon.png') ? OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon.png' : '';
  43.  
  44.                         if (!OIDplus::authUtils()->isAdminLoggedIn()) {
  45.                                 $out['icon'] = 'img/error.png';
  46.                                 $out['text'] = '<p>'._L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin')).'</p>';
  47.                                 return;
  48.                         }
  49.  
  50.                         $out['text'] = '<p>'._L('Did you ever wonder what OIDplus would look like if it had been created in the era of MS-DOS, Windows 3.11, or Windows 95? Just download the ZIP files below and have a look!').'</p>';
  51.  
  52.                         if (class_exists('ZipArchive')) {
  53.                                 $out['text'] .= '<ul>';
  54.                                 $out['text'] .= '<li><a href="'.OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'export_dos.php">'._L('Download OIDplus for DOS').'</a>, '._L('including your database* (only OIDs)').'</li>';
  55.                                 $out['text'] .= '<li><a href="https://www.viathinksoft.de/download/252/oidplus_dos.zip">'._L('Download OIDplus for DOS').'</a>, '._L('without data').'</li>';
  56.                                 $out['text'] .= '<li><a href="'.OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'export_win.php">'._L('Download OIDplus for Windows 3.11, 95, or later').'</a>, '._L('including your database* (only OIDs)').'</li>';
  57.                                 $out['text'] .= '<li><a href="https://www.viathinksoft.de/download/254/oidplus_win311.zip">'._L('Download OIDplus for Windows 3.11').'</a>, '._L('without data').'</li>';
  58.                                 $out['text'] .= '<li><a href="https://www.viathinksoft.de/download/253/oidplus_win95.zip">'._L('Download OIDplus for Windows 95 or later').'</a>, '._L('without data').'</li>';
  59.                                 $out['text'] .= '</ul>';
  60.                                 $out['text'] .= '<p>'._L('* Please note that the download might be delayed since your OID database is exported and added to the ZIP file.').'</p>';
  61.                         } else {
  62.                                 $out['text'] .= '<ul>';
  63.                                 $out['text'] .= '<li><a href="https://www.viathinksoft.de/download/252/oidplus_dos.zip">'._L('Download OIDplus for DOS').'</a>, '._L('without data').'</li>';
  64.                                 $out['text'] .= '<li><a href="https://www.viathinksoft.de/download/254/oidplus_win311.zip">'._L('Download OIDplus for Windows 3.11').'</a>, '._L('without data').'</li>';
  65.                                 $out['text'] .= '<li><a href="https://www.viathinksoft.de/download/253/oidplus_win95.zip">'._L('Download OIDplus for Windows 95 or later').'</a>, '._L('without data').'</li>';
  66.                                 $out['text'] .= '</ul>';
  67.                                 $out['text'] .= '<p><font color="red">'._L('The PHP extension "ZipArchive" needs to be installed to create a ZIP archive with an included database. Otherwise, you can just download the plain program without data.').'</font></p>';
  68.                         }
  69.                 }
  70.         }
  71.  
  72.         /**
  73.          * @param array $json
  74.          * @param string|null $ra_email
  75.          * @param bool $nonjs
  76.          * @param string $req_goto
  77.          * @return bool
  78.          * @throws OIDplusException
  79.          */
  80.         public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool {
  81.                 if (!OIDplus::authUtils()->isAdminLoggedIn()) return false;
  82.  
  83.                 if (file_exists(__DIR__.'/img/main_icon16.png')) {
  84.                         $tree_icon = OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon16.png';
  85.                 } else {
  86.                         $tree_icon = null; // default icon (folder)
  87.                 }
  88.  
  89.                 $json[] = array(
  90.                         'id' => 'oidplus:nostalgia',
  91.                         'icon' => $tree_icon,
  92.                         'text' => _L('Nostalgia')
  93.                 );
  94.  
  95.                 return true;
  96.         }
  97.  
  98.         /**
  99.          * @param string $request
  100.          * @return array|false
  101.          */
  102.         public function tree_search(string $request) {
  103.                 return false;
  104.         }
  105.  
  106.         /**
  107.          * @param string $id
  108.          * @return bool
  109.          */
  110.         public function implementsFeature(string $id): bool {
  111.                 if (strtolower($id) == '1.3.6.1.4.1.37476.2.5.2.3.8') return true; // getNotifications()
  112.                 return false;
  113.         }
  114.  
  115.         /**
  116.          * Implements interface 1.3.6.1.4.1.37476.2.5.2.3.8
  117.          * @param string|null $user
  118.          * @return array
  119.          * @throws OIDplusException
  120.          */
  121.         public function getNotifications(string $user=null): array {
  122.                 $notifications = array();
  123.                 if ((!$user || ($user == 'admin')) && OIDplus::authUtils()->isAdminLoggedIn()) {
  124.                         if (!class_exists('ZipArchive')) {
  125.                                 $title = _L('Nostalgia');
  126.                                 $notifications[] = array('ERR', _L('OIDplus plugin "%1" is enabled, but the required PHP extension "%2" is not installed.', '<a '.OIDplus::gui()->link('oidplus:nostalgia').'>'.htmlentities($title).'</a>', 'Zip'));
  127.                         }
  128.                 }
  129.                 return $notifications;
  130.         }
  131.  
  132. }
  133.