.
*/
if (!defined('txpinterface')) {
die('txpinterface is undefined.');
}
class hive_theme extends \Textpattern\Admin\Theme
{
function html_head()
{
$cssPath = 'assets'.DS.'css';
$jsPath = 'assets'.DS.'js';
$out[] = '';
// Custom CSS (see theme README for usage instructions).
if (defined('admin_custom_css')) {
$custom_css = admin_custom_css;
} else {
$custom_css = 'custom.css';
}
if (file_exists(txpath.DS.THEME.$this->name.DS.$cssPath.DS.$custom_css)) {
$out[] = '';
}
$out[] = '';
$out[] = '';
$out[] = '';
$out[] = ''.n;
// Custom JavaScript (see theme README for usage instructions).
if (defined('admin_custom_js')) {
$custom_js = admin_custom_js;
} else {
$custom_js = 'custom.js';
}
if (file_exists(txpath.DS.THEME.$this->name.DS.$jsPath.DS.$custom_js)) {
$out[] = ''.n;
}
return join(n, $out);
}
function header()
{
global $txp_user;
$default_event = get_pref('default_event');
$homelink = span('Textpattern');
if (!empty($default_event) && has_privs($default_event)) {
$homelink = href($homelink, array('event' => $default_event));
}
$out[] = hed($homelink, 1);
if ($txp_user) {
$out[] = '';
$out[] = '';
$out[] = graf(
href(span(htmlspecialchars($GLOBALS['prefs']['sitename']), array('class' => 'txp-view-site-name')), hu, array(
'target' => '_blank',
'title' => gTxt('tab_view_site'),
)), array('class' => 'txp-view-site'));
$out[] = graf(
href(gTxt('logout'), 'index.php?logout=1', ' onclick="return verify(\''.gTxt('are_you_sure').'\')"'), array('class' => 'txp-logout'));
}
return join(n, $out);
}
function footer()
{
$out[] = graf(
href('Textpattern CMS'.sp.span(gTxt('opens_external_link'), array('class' => 'ui-icon ui-icon-extlink')), 'http://textpattern.com', array(
'rel' => 'external',
'target' => '_blank',
)).
' (v'.txp_version.')', array('class' => 'mothership'));
$out[] = graf(href(gTxt('back_to_top'), '#'), array('class' => 'pagejump'));
return join(n, $out);
}
function announce($thing = array('', 0), $modal = false)
{
return $this->_announce($thing, false, $modal);
}
function announce_async($thing = array('', 0), $modal = false)
{
return $this->_announce($thing, true, $modal);
}
private function _announce($thing, $async, $modal)
{
// $thing[0]: message text.
// $thing[1]: message type, defaults to "success" unless empty or a different flag is set.
if ($thing === '') {
return '';
}
if (!is_array($thing) || !isset($thing[1])) {
$thing = array($thing, 0);
}
switch ($thing[1]) {
case E_ERROR:
$class = 'error';
$icon = 'ui-icon-alert';
break;
case E_WARNING:
$class = 'warning';
$icon = 'ui-icon-alert';
break;
default:
$class = 'success';
$icon = 'ui-icon-check';
break;
}
if ($modal) {
$html = ''; // TODO: Say what?
$js = 'window.alert("'.escape_js(strip_tags($thing[0])).'")';
} else {
$html = span(
span(null, array('class' => 'ui-icon '.$icon)).' '.gTxt($thing[0]).
sp.href('×', '#close', ' class="close" role="button" title="'.gTxt('close').'" aria-label="'.gTxt('close').'"'),
array(
'class' => 'messageflash '.$class,
'role' => 'alert',
'aria-live' => 'assertive',
)
);
// Try to inject $html into the message pane no matter when _announce()'s output is printed.
$js = escape_js($html);
$js = <<< EOS
$(document).ready(function ()
{
$("#messagepane").html("{$js}");
});
EOS;
}
if ($async) {
return $js;
} else {
return script_js(str_replace('', '<\/', $js), $html);
}
}
function manifest()
{
global $prefs;
return array(
'title' => 'Hive',
'description' => 'Textpattern Hive admin theme (Classic Yellow)',
'version' => '4.6.2',
'author' => 'Phil Wareham',
'author_uri' => 'https://github.com/philwareham',
'help' => 'https://github.com/philwareham/textpattern-hive-admin-theme',
);
}
}