<commit_before><?php
	define('ADMIN', true);
	require_once "../includes/common.php";
	
	# Should the Manage tab be shown?
	$show_manage_tab = false;
	$manage_pages = array("post", "page", "user", "group");
	$manage_pages = $trigger->filter("show_admin_manage_tab", $manage_pages);
	foreach($manage_pages as $type)
		if ($user->can("edit_".$type) or $user->can("delete_".$type)) {
			if (!isset($can_manage))
				$can_manage = $type;
			$show_manage_tab = true;
		}
	
	$allowed = ($user->can("add_post") or $user->can("add_page") or $user->can("change_settings") or $show_manage_tab);
	
	if (!$allowed)
		error(__("Access Denied"), __("You are not allowed to view this area."));
	
	$action = (isset($_GET['action'])) ? strip_tags($_GET['action']) : "write" ;
	$sub = (isset($_GET['sub'])) ? strip_tags($_GET['sub']) : null ;
	
	# I know I could just do __(ucfirst($whatever)) with these, but
	# doing it this way lets my gettext scanner live a little easier.
	$actions = array("write" => __("Write"),
	                 "settings" => __("Settings"),
	                 "manage" => __("Manage"),
	                 "extend" => __("Extend"),
	                 "edit" => __("Edit"),
	                 "delete" => __("Delete"));
	$subs = array("website" => __("Website"),
	              "syndication" => __("Syndication"),
	              "routes" => __("Routes"),
	              "post" => __("Posts"),
	              "page" => __("Pages"),
	              "user" => __("Users"),
	              "group" => __("Groups"),
	              "modules" => __("Modules"),
	              "feathers" => __("Feathers"),
	              "themes" => __("Themes"));
	$actions = $trigger->filter("admin_page_titles", $actions);
	$subs = $trigger->filter("admin_sub_page_titles", $subs);
	
	if (!isset($_GET['action']) and !isset($_GET['sub']))
		if (!$user->can("add_post") and !$user->can("add_page"))
			if ($user->can("change_settings"))
				$route->redirect(url("settings", null, true));
			elseif ($show_manage_tab)
				if ($user->can("edit_post") or $user->can("delete_post"))
					$route->redirect("/admin/?action=manage");
				else
					$route->redirect("/admin/?action=manage&sub=".$can_manage);
		elseif ($user->can("add_page"))
			$route->redirect(url("write", "page", true));
	
	if ($action == "manage" and !isset($_GET['sub']) and $show_manage_tab)
		if (!$user->can("edit_post") and !$user->can("delete_post"))
			$route->redirect("/admin/?action=manage&sub=".$can_manage);
	
	function url($action, $sub = null, $return = false) {
		$config = Config::current();
		$url = $config->url."/admin/?action=".$action;
		if (!is_null($sub)) $url.= "&amp;sub=".$sub;
		if ($return) return $url;
		echo $url;
	}
	function admin_selected($the_action, $the_sub = null, $return = false) {
		global $action, $sub;
		if ((!is_null($the_sub) and ($sub == $the_sub)) or (is_null($the_sub)) and ($action == $the_action))
			if ($return)
				return ' class="selected"';
			else
				echo ' class="selected"';
	}
	$action_up = str_replace(array_keys($actions), array_values($actions), $action);
	$sub_title = (isset($sub)) ? ": ".ucfirst(str_replace(array_keys($subs), array_values($subs), $sub)) : "" ;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
		<title><?php echo $theme->title(": ", $action_up.$sub_title); ?></title>
		<link rel="stylesheet" href="style.css" type="text/css" media="screen" charset="utf-8" />
		<script src="<?php echo $config->url; ?>/includes/lib/jquery.js" type="text/javascript" charset="utf-8"></script>
		<script src="<?php echo $config->url; ?>/admin/js/ifixpng.js" type="text/javascript" charset="utf-8"></script>
		<script src="<?php echo $config->url; ?>/admin/js/interface.js" type="text/javascript" charset="utf-8"></script>
		<script src="<?php echo $config->url; ?>/admin/js/javascript.php?action=<?php echo $action; ?>&amp;sub=<?php echo $sub; ?>" type="text/javascript" charset="utf-8"></script>
<?php $trigger->call("admin_head"); ?>
	</head>
	<body>
		<div class="header">
			<a class="view" href="<?php echo $config->url; ?>"><?php echo __("View Site &raquo;"); ?></a>
			<h1><?php echo $config->name; ?></h1>
		</div>
		<div class="main-nav">
			<ul>
<?php if ($user->can("add_post") or $user->can("add_page")): ?><commit_msg>Allow themes to style admin area [#41 state:resolved]<commit_after><?php
	define('ADMIN', true);
	require_once "../includes/common.php";
	
	# Should the Manage tab be shown?
	$show_manage_tab = false;
	$manage_pages = array("post", "page", "user", "group");
	$manage_pages = $trigger->filter("show_admin_manage_tab", $manage_pages);
	foreach($manage_pages as $type)
		if ($user->can("edit_".$type) or $user->can("delete_".$type)) {
			if (!isset($can_manage))
				$can_manage = $type;
			$show_manage_tab = true;
		}
	
	$allowed = ($user->can("add_post") or $user->can("add_page") or $user->can("change_settings") or $show_manage_tab);
	
	if (!$allowed)
		error(__("Access Denied"), __("You are not allowed to view this area."));
	
	$action = (isset($_GET['action'])) ? strip_tags($_GET['action']) : "write" ;
	$sub = (isset($_GET['sub'])) ? strip_tags($_GET['sub']) : null ;
	
	# I know I could just do __(ucfirst($whatever)) with these, but
	# doing it this way lets my gettext scanner live a little easier.
	$actions = array("write" => __("Write"),
	                 "settings" => __("Settings"),
	                 "manage" => __("Manage"),
	                 "extend" => __("Extend"),
	                 "edit" => __("Edit"),
	                 "delete" => __("Delete"));
	$subs = array("website" => __("Website"),
	              "syndication" => __("Syndication"),
	              "routes" => __("Routes"),
	              "post" => __("Posts"),
	              "page" => __("Pages"),
	              "user" => __("Users"),
	              "group" => __("Groups"),
	              "modules" => __("Modules"),
	              "feathers" => __("Feathers"),
	              "themes" => __("Themes"));
	$actions = $trigger->filter("admin_page_titles", $actions);
	$subs = $trigger->filter("admin_sub_page_titles", $subs);
	
	if (!isset($_GET['action']) and !isset($_GET['sub']))
		if (!$user->can("add_post") and !$user->can("add_page"))
			if ($user->can("change_settings"))
				$route->redirect(url("settings", null, true));
			elseif ($show_manage_tab)
				if ($user->can("edit_post") or $user->can("delete_post"))
					$route->redirect("/admin/?action=manage");
				else
					$route->redirect("/admin/?action=manage&sub=".$can_manage);
		elseif ($user->can("add_page"))
			$route->redirect(url("write", "page", true));
	
	if ($action == "manage" and !isset($_GET['sub']) and $show_manage_tab)
		if (!$user->can("edit_post") and !$user->can("delete_post"))
			$route->redirect("/admin/?action=manage&sub=".$can_manage);
	
	function url($action, $sub = null, $return = false) {
		$config = Config::current();
		$url = $config->url."/admin/?action=".$action;
		if (!is_null($sub)) $url.= "&amp;sub=".$sub;
		if ($return) return $url;
		echo $url;
	}
	function admin_selected($the_action, $the_sub = null, $return = false) {
		global $action, $sub;
		if ((!is_null($the_sub) and ($sub == $the_sub)) or (is_null($the_sub)) and ($action == $the_action))
			if ($return)
				return ' class="selected"';
			else
				echo ' class="selected"';
	}
	$action_up = str_replace(array_keys($actions), array_values($actions), $action);
	$sub_title = (isset($sub)) ? ": ".ucfirst(str_replace(array_keys($subs), array_values($subs), $sub)) : "" ;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
		<title><?php echo $theme->title(": ", $action_up.$sub_title); ?></title>
		<link rel="stylesheet" href="<?php echo (file_exists(THEME_DIR.'/stylesheets/admin.css')) ? $config->url.'/themes/'.$config->theme.'/stylesheets/admin.css' : 'style.css'; ?>" type="text/css" media="screen" charset="utf-8" />
		<script src="<?php echo $config->url; ?>/includes/lib/jquery.js" type="text/javascript" charset="utf-8"></script>
		<script src="<?php echo $config->url; ?>/admin/js/ifixpng.js" type="text/javascript" charset="utf-8"></script>
		<script src="<?php echo $config->url; ?>/admin/js/interface.js" type="text/javascript" charset="utf-8"></script>
		<script src="<?php echo $config->url; ?>/admin/js/javascript.php?action=<?php echo $action; ?>&amp;sub=<?php echo $sub; ?>" type="text/javascript" charset="utf-8"></script>
<?php $trigger->call("admin_head"); ?>
	</head>
	<body>
		<div class="header">
			<a class="view" href="<?php echo $config->url; ?>"><?php echo __("View Site &raquo;"); ?></a>
			<h1><?php echo $config->name; ?></h1>
		</div>
		<div class="main-nav">
			<ul>
<?php if ($user->can("add_post") or $user->can("add_page")): ?>
{'fraction_non_alphanumeric': 0.23087144280810543, 'fraction_numerical': 0.0044291883512346366, 'mean_word_length': 4.042992741485204, 'pattern_counts': {'":': 4, '<': 80, '<?xml version=': 0, '>': 178, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '296557', 'n_tokens_mistral': 3350, 'n_tokens_neox': 3082, 'n_words': 625}