Subversion Repositories oidplus

Rev

Rev 348 | Rev 362 | 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 Daniel Marschall, ViaThinkSoft
  6.  *
  7.  * Licensed under the Apache License, Version 2.0 (the "License");
  8.  * you may not use this file except in compliance with the License.
  9.  * You may obtain a copy of the License at
  10.  *
  11.  *     http://www.apache.org/licenses/LICENSE-2.0
  12.  *
  13.  * Unless required by applicable law or agreed to in writing, software
  14.  * distributed under the License is distributed on an "AS IS" BASIS,
  15.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16.  * See the License for the specific language governing permissions and
  17.  * limitations under the License.
  18.  */
  19.  
  20. class OIDplusGui {
  21.  
  22.         public static function generateContentPage($id) {
  23.                 $out = array();
  24.  
  25.                 $handled = false;
  26.                 $out['title'] = '';
  27.                 $out['icon'] = '';
  28.                 $out['text'] = '';
  29.  
  30.                 foreach (OIDplus::getPagePlugins() as $plugin) {
  31.                         try {
  32.                                 $plugin->gui($id, $out, $handled);
  33.                         } catch (Exception $e) {
  34.                                 $out['title'] = _L('Error');
  35.                                 $out['icon'] = 'img/error_big.png';
  36.                                 $out['text'] = $e->getMessage();
  37.                         }
  38.                         if ($handled) break;
  39.                 }
  40.  
  41.                 if (!$handled) {
  42.                         $out['title'] = _L('Error');
  43.                         $out['icon'] = 'img/error_big.png';
  44.                         $out['text'] = _L('The resource cannot be found.');
  45.                 }
  46.  
  47.                 return $out;
  48.         }
  49.  
  50.         public static function link($goto, $new_window=false) {
  51.                 if ($new_window) {
  52.                         return 'href="?goto='.urlencode($goto).'" target="_blank"';
  53.                 } else {
  54.                         if (strpos($goto, '#') !== false) {
  55.                                 list($goto, $anchor) = explode('#', $goto, 2);
  56.                                 return 'href="?goto='.urlencode($goto).'#'.htmlentities($anchor).'" onclick="openOidInPanel('.js_escape($goto).', true, '.js_escape($anchor).'); return false;"';
  57.                         } else {
  58.                                 return 'href="?goto='.urlencode($goto).'" onclick="openOidInPanel('.js_escape($goto).', true); return false;"';
  59.                         }
  60.                 }
  61.         }
  62. }