Textpattern PHP Cross Reference Content Management Systems

Source: /textpattern/admin-themes/classic/classic.php - 225 lines - 7606 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 classic_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          $out[] = '<div class="txp-masthead">';
  70          $out[] = hed('Textpattern', 1, ' class="txp-branding"');
  71          $out[] = hed(htmlspecialchars($GLOBALS["prefs"]["sitename"]), 2, ' class="txp-accessibility"');
  72          $out[] = navPop(1);
  73          $out[] = '</div>';
  74  
  75          if (!$this->is_popup) {
  76              $out[] = '<nav role="navigation" aria-label="'.gTxt('navigation').'">';
  77              $out[] = '<div class="nav-tabs" id="nav-primary">';
  78              $out[] = '<ul>';
  79  
  80              $secondary = '';
  81  
  82              foreach ($this->menu as $tab) {
  83                  $tc = ($tab['active']) ? ' class="active"' : '';
  84                  $out[] = '<li'.$tc.'>'.
  85                      href($tab["label"], array('event' => $tab['event'])).
  86                      '</li>';
  87  
  88                  if ($tab['active'] && !empty($tab['items'])) {
  89                      $secondary = '<div class="nav-tabs" id="nav-secondary">'.
  90                          n.'<ul>';
  91  
  92                      foreach ($tab['items'] as $item) {
  93                          $tc = ($item['active']) ? ' class="active"' : '';
  94                          $secondary .= n.'<li'.$tc.'>'.
  95                              href($item['label'], array('event' => $item['event'])).
  96                              '</li>';
  97                      }
  98  
  99                      $secondary .= n.'</ul>'.
 100                          n.'</div>';
 101                  }
 102              }
 103  
 104              $out[] = '<li class="txp-view-site">'.
 105                  href(gTxt('tab_view_site'), hu, array('target' => '_blank')).
 106                  '</li>';
 107  
 108              $out[] = '</ul>';
 109              $out[] = '</div>';
 110              $out[] = $secondary;
 111              $out[] = '</nav>';
 112          }
 113  
 114          return join(n, $out);
 115      }
 116  
 117      function footer()
 118      {
 119          global $txp_user;
 120  
 121          $out[] = href('Textpattern CMS'.sp.span(gTxt('opens_external_link'), array('class' => 'ui-icon ui-icon-extlink')), 'http://textpattern.com', array(
 122                  'class'  => 'mothership',
 123                  'rel'    => 'external',
 124                  'target' => '_blank',
 125              )).
 126              n.'('.txp_version.')';
 127  
 128          if ($txp_user) {
 129              $out[] = span('&#183;', array('role' => 'separator')).
 130                  n.gTxt('logged_in_as').
 131                  n.span(txpspecialchars($txp_user), array('class' => 'txp-username')).
 132                  n.span('&#183;', array('role' => 'separator')).
 133                  n.href(gTxt('logout'), 'index.php?logout=1', array(
 134                  'class'   => 'txp-logout',
 135                  'onclick' => 'return verify(\''.gTxt('are_you_sure').'\')',
 136              ));
 137          }
 138  
 139          return join(n, $out);;
 140      }
 141  
 142      function announce($thing = array('', 0), $modal = false)
 143      {
 144          return $this->_announce($thing, false, $modal);
 145      }
 146  
 147      function announce_async($thing = array('', 0), $modal = false)
 148      {
 149          return $this->_announce($thing, true, $modal);
 150      }
 151  
 152      private function _announce($thing, $async, $modal)
 153      {
 154          // $thing[0]: message text.
 155          // $thing[1]: message type, defaults to "success" unless empty or a different flag is set.
 156  
 157          if ($thing === '') {
 158              return '';
 159          }
 160  
 161          if (!is_array($thing) || !isset($thing[1])) {
 162              $thing = array($thing, 0);
 163          }
 164  
 165          switch ($thing[1]) {
 166              case E_ERROR:
 167                  $class = 'error';
 168                  $icon = 'ui-icon-alert';
 169                  break;
 170              case E_WARNING:
 171                  $class = 'warning';
 172                  $icon = 'ui-icon-alert';
 173                  break;
 174              default:
 175                  $class = 'success';
 176                  $icon = 'ui-icon-check';
 177                  break;
 178          }
 179  
 180          if ($modal) {
 181              $html = ''; // TODO: Say what?
 182              $js = 'window.alert("'.escape_js(strip_tags($thing[0])).'")';
 183          } else {
 184              $html = span(
 185                  span(null, array('class' => 'ui-icon '.$icon)).' '.gTxt($thing[0]).
 186                  sp.href('&#215;', '#close', ' class="close" role="button" title="'.gTxt('close').'" aria-label="'.gTxt('close').'"'),
 187                  array(
 188                      'class'     => 'messageflash '.$class,
 189                      'role'      => 'alert',
 190                      'aria-live' => 'assertive',
 191                  )
 192              );
 193  
 194              // Try to inject $html into the message pane no matter when _announce()'s output is printed.
 195              $js = escape_js($html);
 196              $js = <<< EOS
 197                  $(document).ready(function ()
 198                  {
 199                      $("#messagepane").html("{$js}");
 200                      $('#message.success, #message.warning, #message.error').fadeOut('fast').fadeIn('fast');
 201                  });
 202  EOS;
 203          }
 204  
 205          if ($async) {
 206              return $js;
 207          } else {
 208              return script_js(str_replace('</', '<\/', $js), $html);
 209          }
 210      }
 211  
 212      function manifest()
 213      {
 214          global $prefs;
 215  
 216          return array(
 217              'title'       => 'Classic',
 218              'description' => 'Textpattern Classic admin theme',
 219              'version'     => '4.6.2',
 220              'author'      => 'Phil Wareham',
 221              'author_uri'  => 'https://github.com/philwareham',
 222              'help'        => 'https://github.com/philwareham/textpattern-classic-admin-theme',
 223          );
 224      }
 225  }

title

Description

title

Description

title

Description

title

title

Body