Textpattern | PHP Cross Reference | Content Management Systems |
Description: Used for generating admin-side headers.
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 /** 25 * Used for generating admin-side headers. 26 * 27 * @package HTML 28 */ 29 30 /** 31 * Creates and outputs an admin-side header. 32 * 33 * The output contains HTML <head> section and the main navigation. 34 * The results are echoed as opposed to returned. 35 * 36 * This function offers a way to invoke modal activity messages and set the 37 * page title. 38 * 39 * Output will automatically become silent on asynchronous script responses 40 * that do not want HTML headers. 41 * 42 * @param string $pagetitle The page title 43 * @param string|array $message A message show to the user 44 * @example 45 * pagetop('Title', array('My error message', E_ERROR)); 46 * echo 'My page contents.'; 47 */ 48 49 function pagetop($pagetitle, $message = '') 50 { 51 global $siteurl, $sitename, $txp_user, $event, $step, $app_mode, $theme; 52 53 if ($app_mode == 'async') { 54 return; 55 } 56 57 $area = gps('area'); 58 $event = (!$event) ? 'article' : $event; 59 $bm = gps('bm'); 60 61 $areas = areas(); 62 $area = false; 63 64 foreach ($areas as $k => $v) { 65 if (in_array($event, $v)) { 66 $area = $k; 67 break; 68 } 69 } 70 71 if (gps('logout')) { 72 $body_id = 'page-logout'; 73 $area = 'login'; 74 } elseif (!$txp_user) { 75 $body_id = 'page-login'; 76 $area = 'login'; 77 } else { 78 $body_id = 'page-'.txpspecialchars($event); 79 } 80 81 header('X-Frame-Options: '.X_FRAME_OPTIONS); 82 header('X-UA-Compatible: '.X_UA_COMPATIBLE); 83 84 $lang_direction = gTxt('lang_dir'); 85 86 if (!in_array($lang_direction, array('ltr', 'rtl'))) { 87 // Apply biased default for missing translations. 88 $lang_direction = 'ltr'; 89 } ?><!DOCTYPE html> 90 <html lang="<?php echo txpspecialchars(LANG); ?>" dir="<?php echo $lang_direction; ?>"> 91 <head> 92 <meta charset="utf-8"> 93 <meta name="robots" content="noindex, nofollow"> 94 <title><?php echo admin_title($pagetitle)?></title><?php echo 95 script_js('vendors/jquery/jquery/jquery.js', TEXTPATTERN_SCRIPT_URL). 96 script_js('vendors/jquery/jquery-ui/jquery-ui.js', TEXTPATTERN_SCRIPT_URL). 97 script_js( 98 'var textpattern = '.json_encode(array( 99 'event' => $event, 100 'step' => $step, 101 '_txp_token' => form_token(), 102 'ajax_timeout' => (int) AJAX_TIMEOUT, 103 'textarray' => (object) null, 104 'do_spellcheck' => get_pref('do_spellcheck', 105 '#page-article #body, #page-article #title,'. 106 '#page-image #alt-text, #page-image #caption,'. 107 '#page-file #description,'. 108 '#page-link #link-title, #page-link #link-description'), 109 'production_status' => get_pref('production_status'), 110 )).';'). 111 script_js('textpattern.js', TEXTPATTERN_SCRIPT_URL).n; 112 gTxtScript(array('form_submission_error', 'are_you_sure', 'cookies_must_be_enabled', 'ok', 'save', 'publish')); 113 // Mandatory un-themable Textpattern core styles ?> 114 <style> 115 .not-ready .doc-ready, 116 .not-ready form.async input[type="submit"], 117 .not-ready a.async 118 { 119 visibility: hidden; 120 } 121 </style> 122 <?php 123 echo $theme->html_head(); 124 callback_event('admin_side', 'head_end'); ?> 125 </head> 126 <body class="not-ready <?php echo $area; ?>" id="<?php echo $body_id; ?>"> 127 <header class="txp-header"> 128 <?php callback_event('admin_side', 'pagetop'); 129 $theme->set_state($area, $event, $bm, $message); 130 echo pluggable_ui('admin_side', 'header', $theme->header()); 131 callback_event('admin_side', 'pagetop_end'); 132 echo n.'</header><!-- /txp-header -->'. 133 n.'<main class="txp-body" aria-label="'.gTxt('main_content').'">'. 134 n.'<div id="messagepane">'.$theme->announce($message).'</div>'; 135 callback_event('admin_side', 'main_content'); 136 } 137 138 /** 139 * Return the HTML <title> contents for an admin-side page. 140 * 141 * The rendered title can be customised via a 'admin_side > html_title' 142 * pluggable UI callback event. 143 * 144 * @param string $pagetitle Specific page title part 145 * @return string 146 * @since 4.6.0 147 */ 148 149 function admin_title($pagetitle) 150 { 151 global $sitename; 152 153 if ((string) $pagetitle === '') { 154 $title = gTxt('untitled'); 155 } else { 156 $title = $pagetitle; 157 } 158 159 $title = escape_title($title).' - '.txpspecialchars($sitename).' | Textpattern CMS'; 160 161 return pluggable_ui('admin_side', 'html_title', $title, compact('pagetitle')); 162 } 163 164 /** 165 * Creates an area tab. 166 * 167 * This can be used to create table based navigation bars. 168 * 169 * @param string $label 170 * @param string $event 171 * @param string $tarea 172 * @param string $area 173 * @return string HTML table column 174 * @deprecated in 4.6.0 175 */ 176 177 function areatab($label, $event, $tarea, $area) 178 { 179 $tc = ($area == $event) ? 'tabup' : 'tabdown'; 180 $atts = ' class="'.$tc.'"'; 181 $hatts = ' href="?event='.$tarea.'"'; 182 183 return tda(tag($label, 'a', $hatts), $atts); 184 } 185 186 /** 187 * Creates a secondary area tab. 188 * 189 * This can be used to create table based navigation bars. 190 * 191 * @param string $label 192 * @param string $tabevent 193 * @param string $event 194 * @return string HTML table column 195 * @deprecated in 4.6.0 196 */ 197 198 function tabber($label, $tabevent, $event) 199 { 200 $tc = ($event == $tabevent) ? 'tabup' : 'tabdown2'; 201 $out = '<td class="'.$tc.'"><a href="?event='.$tabevent.'">'.$label.'</a></td>'; 202 203 return $out; 204 } 205 206 /** 207 * Creates a table based navigation bar row. 208 * 209 * This can be used to create table based navigation bars. 210 * 211 * @param string $area 212 * @param string $event 213 * @return string HTML table columns 214 * @deprecated in 4.6.0 215 */ 216 217 function tabsort($area, $event) 218 { 219 if ($area) { 220 $areas = areas(); 221 222 $out = array(); 223 224 foreach ($areas[$area] as $a => $b) { 225 if (has_privs($b)) { 226 $out[] = tabber($a, $b, $event, 2); 227 } 228 } 229 230 return ($out) ? join('', $out) : ''; 231 } 232 233 return ''; 234 } 235 236 /** 237 * Gets the main menu structure as an array. 238 * 239 * @return array 240 * @example 241 * print_r( 242 * areas() 243 * ); 244 */ 245 246 function areas() 247 { 248 global $plugin_areas; 249 250 $areas['start'] = array( 251 ); 252 253 $areas['content'] = array( 254 gTxt('tab_write') => 'article', 255 gTxt('tab_list') => 'list', 256 gTxt('tab_image') => 'image', 257 gTxt('tab_file') => 'file', 258 gTxt('tab_link') => 'link', 259 gTxt('tab_organise') => 'category', 260 ); 261 262 $areas['presentation'] = array( 263 gTxt('tab_sections') => 'section', 264 gTxt('tab_pages') => 'page', 265 gTxt('tab_forms') => 'form', 266 gTxt('tab_style') => 'css', 267 ); 268 269 $areas['admin'] = array( 270 gTxt('tab_diagnostics') => 'diag', 271 gTxt('tab_preferences') => 'prefs', 272 gTxt('tab_languages') => 'lang', 273 gTxt('tab_site_admin') => 'admin', 274 gTxt('tab_plugins') => 'plugin', 275 ); 276 277 $areas['extensions'] = array( 278 ); 279 280 if (get_pref('use_comments', 1)) { 281 $areas['content'][gTxt('tab_comments')] = 'discuss'; 282 } 283 284 if (get_pref('logging') !== 'none' && get_pref('expire_logs_after')) { 285 $areas['admin'][gTxt('tab_logs')] = 'log'; 286 } 287 288 if (is_array($plugin_areas)) { 289 $areas = array_merge_recursive($areas, $plugin_areas); 290 } 291 292 return $areas; 293 } 294 295 /** 296 * Creates an admin-side main menu as a <select> dropdown. 297 * 298 * @param mixed $inline Is not used. 299 * @return string A HTML form 300 * @example 301 * echo navPop(); 302 */ 303 304 function navPop($inline = '') 305 { 306 $areas = areas(); 307 308 $out = array(); 309 310 foreach ($areas as $a => $b) { 311 if (!has_privs('tab.'.$a)) { 312 continue; 313 } 314 315 if (count($b) > 0) { 316 $out[] = n.'<optgroup label="'.gTxt('tab_'.$a).'">'; 317 318 foreach ($b as $c => $d) { 319 if (has_privs($d)) { 320 $out[] = n.'<option value="'.txpspecialchars($d).'">'.strip_tags($c).'</option>'; 321 } 322 } 323 324 $out[] = n.'</optgroup>'; 325 } 326 } 327 328 if ($out) { 329 return n.'<form class="navpop" method="get" action="index.php">'. 330 n.'<select name="event" data-submit-on="change">'. 331 n.'<option>'.gTxt('go').'…</option>'. 332 join('', $out). 333 n.'</select>'. 334 n.'</form>'; 335 } 336 } 337 338 /** 339 * Generates a button link. 340 * 341 * @param string $label 342 * @param string $link 343 * @deprecated in 4.6.0 344 */ 345 346 function button($label, $link) 347 { 348 return '<span style="margin-right:2em"><a href="?event='.$link.'">'.$label.'</a></span>'; 349 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
title