This repository has been archived by the owner on Sep 2, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_admin_layout.php
143 lines (127 loc) · 4.45 KB
/
_admin_layout.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<?php
function get_configured_title() {
$menu_title = admin_find_title();
if ($menu_title) {
return $menu_title;
} else {
return view('title');
}
}
function admin_find_title($menu='', $uri='') {
if ($menu == '') {
$menu = config('admin_menu');
if (empty($menu)) {
$menu = array();
}
}
if ($uri == '') {
$uri = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
}
foreach( $menu as $title => $link ) {
if (is_array($link)) {
$nested_title = admin_find_title( $link, $uri );
if ($nested_title) {
return $nested_title;
}
} else {
if (! (false === strpos($uri, $link)) ) {
return $title;
}
}
}
// try again with the referer param, if it exists
$uri = parse_url($uri);
$params = array();
if (array_key_exists('query', $uri)) parse_str($uri['query'], $params);
if (isset($params['referer']) && $params['referer'] != '') {
return admin_find_title($menu, $params['referer']);
}
return false;
}
view_set('title', get_configured_title());
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
<head>
<title><?php echo view('title') ?></title>
<script type="text/javascript" src="<?php echo config('greenroom_path')->url ?>/vendor/jquery-1.4.2.min.js"></script>
<link rel="stylesheet" href="<?php echo config('greenroom_path')->url ?>/vendor/blueprint/screen.css" type="text/css" media="screen, projection">
<link rel="stylesheet" href="<?php echo config('greenroom_path')->url ?>/vendor/blueprint/print.css" type="text/css" media="print">
<!--[if lt IE 8]>
<link rel="stylesheet" href="<?php echo config('greenroom_path')->url ?>/vendor/blueprint/ie.css" type="text/css" media="screen, projection">
<![endif]-->
<?php Form::client_setup_html_head() ?>
</head>
<body>
<div class="container">
<h2>Blueline Admin</h2>
<hr>
<ul class="span-4 admin_menu">
<?php
// prepare menu by adding contextual information
$menu_classes = array();
foreach( config('admin_menu') as $label => $link ) {
if (view('title') == $label) $menu_classes[$label][] = 'current';
if (is_array($link)) {
if (in_array(view('title'), array_keys($link))) {
$menu_classes[$label][] = 'current';
}
}
}
foreach( config('admin_menu') as $label => $link ) {
// seperators
if (is_string($link) && preg_match('/^-+$/', $link)) {
?><li><hr></li><?php
continue;
}
if (isset($menu_classes[$label])) {
$classes = implode(' ', $menu_classes[$label]);
} else {
$classes = '';
}
// individual links
if (is_string($link)) {
?>
<li class="<?php echo $classes ?>">
<a href='<?php echo config('base_url') . $link ?>'><?php echo $label ?></a></li>
<?php
continue;
}
// links with submenus
if (is_array($link)) {
$first_link = $link[array_shift(array_keys($link))];
if (preg_match('|^http://|', $first_link)) {
$first_link = '#';
} else {
$first_link = config('base_url').$first_link;
}
?>
<li class="<?php echo $classes ?>">
<a href='<?php echo $first_link ?>' class="<?php echo $classes ?>"><?php echo $label ?></a>
<ul>
<?php
$sub_class = array('sub-nav');
foreach( $link as $sub_label => $sub_link ) {
if (view('title') == $sub_label) $sub_class[] = 'current';
if (!preg_match('|^http://|', $sub_link)) {
$sub_link = config('base_url').$sub_link;
}
?><li class="<?php echo implode(' ', $sub_class) ?>"><a href='<?php echo $sub_link ?>'><?php echo $sub_label ?></a></li><?php
$sub_class = array();
}
?>
</ul>
</li>
<?php
continue;
}
}
?>
</ul>
<div class="content span-20 last"><?php echo view('content'); ?></div>
<hr>
<div class="footer">
© <?php echo date('Y'); ?> <a href="http://responsivedevelopment.com">Responsive Development</a>
</div>
</div>
</body>
</html>