Textpattern PHP Cross Reference Content Management Systems

Source: /textpattern/admin-themes/hive/hive.php - 219 lines - 7814 bytes - Summary - Text - Print

   1  <?php
   2  
   3  /*
   4   * Textpattern Content Management System
   5   * http://textpattern.com
   6   *
   7   * Copyright (C) 2016 The Textpattern Development Team
   8   *
   9   * This file is part of Textpattern.
  10   *
  11   * Textpattern is free software; you can redistribute it and/or
  12   * modify it under the terms of the GNU General Public License
  13   * as published by the Free Software Foundation, version 2.
  14   *
  15   * Textpattern is distributed in the hope that it will be useful,
  16   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18   * GNU General Public License for more details.
  19   *
  20   * You should have received a copy of the GNU General Public License
  21   * along with Textpattern. If not, see <http://www.gnu.org/licenses/>.
  22   */
  23  
  24  if (!defined('txpinterface')) {
  25      die('txpinterface is undefined.');
  26  }
  27  
  28  class hive_theme extends \Textpattern\Admin\Theme
  29  {
  30      function html_head()
  31      {
  32          $cssPath = 'assets'.DS.'css';
  33          $jsPath = 'assets'.DS.'js';
  34  
  35          $out[] = '<link rel="stylesheet" href="'.$this->url.'assets/css/textpattern.min.css">';
  36  
  37          // Custom CSS (see theme README for usage instructions).
  38          if (defined('admin_custom_css')) {
  39              $custom_css = admin_custom_css;
  40          } else {
  41              $custom_css = 'custom.css';
  42          }
  43  
  44          if (file_exists(txpath.DS.THEME.$this->name.DS.$cssPath.DS.$custom_css)) {
  45              $out[] = '<link rel="stylesheet" href="'.$this->url.'assets/css/'.$custom_css.'">';
  46          }
  47  
  48          $out[] = '<link rel="icon" href="'.$this->url.'assets/img/favicon.ico">';
  49          $out[] = '<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">';
  50          $out[] = '<meta name="generator" content="Textpattern CMS">';
  51          $out[] = '<script src="'.$this->url.'assets/js/main.min.js"></script>'.n;
  52  
  53          // Custom JavaScript (see theme README for usage instructions).
  54          if (defined('admin_custom_js')) {
  55              $custom_js = admin_custom_js;
  56          } else {
  57              $custom_js = 'custom.js';
  58          }
  59  
  60          if (file_exists(txpath.DS.THEME.$this->name.DS.$jsPath.DS.$custom_js)) {
  61              $out[] = '<script src="'.$this->url.'assets/js/'.$custom_js.'"></script>'.n;
  62          }
  63  
  64          return join(n, $out);
  65      }
  66  
  67      function header()
  68      {
  69          global $txp_user;
  70  
  71          $default_event = get_pref('default_event');
  72          $homelink = span('Textpattern');
  73  
  74          if (!empty($default_event) && has_privs($default_event)) {
  75              $homelink = href($homelink, array('event' => $default_event));
  76          }
  77  
  78          $out[] = hed($homelink, 1);
  79  
  80          if ($txp_user) {
  81              $out[] = '<button class="txp-nav-toggle collapsed" type="button" data-toggle="collapse" data-target="#txp-nav" aria-expanded="false" aria-controls="txp-nav"><span class="txp-accessibility">'.gTxt('navigation').'</span></button>';
  82              $out[] = '<nav class="txp-nav" id="txp-nav" aria-label="'.gTxt('navigation').'">';
  83              $out[] = '<ul class="data-dropdown">';
  84              $txpnavdrop = 0;
  85  
  86              foreach ($this->menu as $tab) {
  87                  $txpnavdrop++;
  88                  $class = ($tab['active']) ? ' selected' : '';
  89                  $out[] = '<li class="dropdown'.$class.'">'.
  90                      n.href($tab['label'], '#',
  91                      ' class="dropdown-toggle" id="txp-nav-drop'.$txpnavdrop.'" role="button" aria-controls="txp-nav-drop'.$txpnavdrop.'-menu" data-toggle="dropdown"');
  92  
  93                  if (!empty($tab['items'])) {
  94                      $out[] = '<ul class="dropdown-menu" id="txp-nav-drop'.$txpnavdrop.'-menu" role="menu" aria-labelledby="txp-nav-drop'.$txpnavdrop.'">';
  95  
  96                      foreach ($tab['items'] as $item) {
  97                          $class = ($item['active']) ? ' class="selected"' : '';
  98                          $out[] = '<li'.$class.' role="presentation">'.
  99                              href($item['label'], array('event' => $item['event']), ' role="menuitem" tabindex="-1"').
 100                              '</li>';
 101                      }
 102  
 103                      $out[] = '</ul>';
 104                  }
 105  
 106                  $out[] = '</li>';
 107              }
 108  
 109              $out[] = '</ul>';
 110              $out[] = '</nav>';
 111              $out[] = graf(
 112                  href(span(htmlspecialchars($GLOBALS['prefs']['sitename']), array('class' => 'txp-view-site-name')), hu, array(
 113                      'target' => '_blank',
 114                      'title'  => gTxt('tab_view_site'),
 115                  )), array('class' => 'txp-view-site'));
 116              $out[] = graf(
 117                  href(gTxt('logout'), 'index.php?logout=1', ' onclick="return verify(\''.gTxt('are_you_sure').'\')"'), array('class' => 'txp-logout'));
 118          }
 119  
 120          return join(n, $out);
 121      }
 122  
 123      function footer()
 124      {
 125          $out[] = graf(
 126              href('Textpattern CMS'.sp.span(gTxt('opens_external_link'), array('class' => 'ui-icon ui-icon-extlink')), 'http://textpattern.com', array(
 127                  'rel'    => 'external',
 128                  'target' => '_blank',
 129              )).
 130              ' (v'.txp_version.')', array('class' => 'mothership'));
 131  
 132          $out[] = graf(href(gTxt('back_to_top'), '#'), array('class' => 'pagejump'));
 133  
 134          return join(n, $out);
 135      }
 136  
 137      function announce($thing = array('', 0), $modal = false)
 138      {
 139          return $this->_announce($thing, false, $modal);
 140      }
 141  
 142      function announce_async($thing = array('', 0), $modal = false)
 143      {
 144          return $this->_announce($thing, true, $modal);
 145      }
 146  
 147      private function _announce($thing, $async, $modal)
 148      {
 149          // $thing[0]: message text.
 150          // $thing[1]: message type, defaults to "success" unless empty or a different flag is set.
 151  
 152          if ($thing === '') {
 153              return '';
 154          }
 155  
 156          if (!is_array($thing) || !isset($thing[1])) {
 157              $thing = array($thing, 0);
 158          }
 159  
 160          switch ($thing[1]) {
 161              case E_ERROR:
 162                  $class = 'error';
 163                  $icon = 'ui-icon-alert';
 164                  break;
 165              case E_WARNING:
 166                  $class = 'warning';
 167                  $icon = 'ui-icon-alert';
 168                  break;
 169              default:
 170                  $class = 'success';
 171                  $icon = 'ui-icon-check';
 172                  break;
 173          }
 174  
 175          if ($modal) {
 176              $html = ''; // TODO: Say what?
 177              $js = 'window.alert("'.escape_js(strip_tags($thing[0])).'")';
 178          } else {
 179              $html = span(
 180                  span(null, array('class' => 'ui-icon '.$icon)).' '.gTxt($thing[0]).
 181                  sp.href('&#215;', '#close', ' class="close" role="button" title="'.gTxt('close').'" aria-label="'.gTxt('close').'"'),
 182                  array(
 183                      'class'     => 'messageflash '.$class,
 184                      'role'      => 'alert',
 185                      'aria-live' => 'assertive',
 186                  )
 187              );
 188  
 189              // Try to inject $html into the message pane no matter when _announce()'s output is printed.
 190              $js = escape_js($html);
 191              $js = <<< EOS
 192                  $(document).ready(function ()
 193                  {
 194                      $("#messagepane").html("{$js}");
 195                  });
 196  EOS;
 197          }
 198  
 199          if ($async) {
 200              return $js;
 201          } else {
 202              return script_js(str_replace('</', '<\/', $js), $html);
 203          }
 204      }
 205  
 206      function manifest()
 207      {
 208          global $prefs;
 209  
 210          return array(
 211              'title'       => 'Hive',
 212              'description' => 'Textpattern Hive admin theme (Classic Yellow)',
 213              'version'     => '4.6.2',
 214              'author'      => 'Phil Wareham',
 215              'author_uri'  => 'https://github.com/philwareham',
 216              'help'        => 'https://github.com/philwareham/textpattern-hive-admin-theme',
 217          );
 218      }
 219  }

title

Description

title

Description

title

Description

title

title

Body