summaryrefslogtreecommitdiffstats
path: root/admin
diff options
context:
space:
mode:
authorMaurice Svay <maurice@svay.com>2012-03-07 13:34:53 -0800
committerMaurice Svay <maurice@svay.com>2012-03-07 13:34:53 -0800
commit41ec00699d5f86cc868984600d3676821caed83f (patch)
tree39a2af3455602f73745df2f935a7f6d5479c6b81 /admin
parent06579a78d35606f2741b80d54a9a4ad992a4b4d2 (diff)
parent4fd51adf879e376220f7d97a9e084a62892870ad (diff)
downloadplanet-41ec00699d5f86cc868984600d3676821caed83f.tar
planet-41ec00699d5f86cc868984600d3676821caed83f.tar.gz
planet-41ec00699d5f86cc868984600d3676821caed83f.tar.bz2
planet-41ec00699d5f86cc868984600d3676821caed83f.tar.xz
planet-41ec00699d5f86cc868984600d3676821caed83f.zip
Merge pull request #13 from pascalchevrel/admin_template
Admin template
Diffstat (limited to 'admin')
-rw-r--r--admin/administration.php54
-rw-r--r--admin/inc/nav.inc.php5
-rw-r--r--admin/index.php163
-rw-r--r--admin/login.php35
-rw-r--r--admin/template.php44
5 files changed, 148 insertions, 153 deletions
diff --git a/admin/administration.php b/admin/administration.php
index 1f02e78..894ebd3 100644
--- a/admin/administration.php
+++ b/admin/administration.php
@@ -1,21 +1,12 @@
<?php
-require_once dirname(__FILE__).'/inc/auth.inc.php';
-
-require_once dirname(__FILE__).'/../app/lib/lib.opml.php';
-$opml = OpmlManager::load(dirname(__FILE__).'/../custom/people.opml');
-$opml_people = $opml->getPeople();
-?>
-<!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" xml:lang="en" lang="en">
-<head>
- <meta http-equiv="Content-Type" content="text/HTML; charset=UTF-8" />
- <meta http-equiv="Content-Script-Type" content="text/javascript" />
- <meta http-equiv="Content-Style-Type" content="text/css" />
- <meta http-equiv="Content-Language" content="en" />
-
- <title>moonmoon administration</title>
- <link rel="stylesheet" media="screen" type="text/css" href="default.css" />
+
+require_once dirname(__FILE__) . '/inc/auth.inc.php';
+require_once dirname(__FILE__) . '/../app/lib/lib.opml.php';
+
+$opml = OpmlManager::load(dirname(__FILE__) . '/../custom/people.opml');
+$opml_people = $opml->getPeople();
+$page_id = 'admin-admin';
+$header_extra = <<<"HTML"
<script>
window.onload = function(){
var formManage = document.getElementById('frmPurge');
@@ -24,18 +15,11 @@ $opml_people = $opml->getPeople();
}
}
</script>
-</head>
-
-<body id="admin-admin">
- <div id="page">
- <div id="header">
- <h1>moonmoon</h1>
- <p><a href="../">Back to main page</a></p>
- </div>
-
- <?php readfile("inc/nav.inc.php"); ?>
-
- <div id="content">
+
+HTML;
+
+$page_content = <<<"FRAGMENT"
+
<div class="widget">
<h3>Clear cache</h3>
<form action="purgecache.php" method="post" id="frmPurge">
@@ -43,14 +27,16 @@ $opml_people = $opml->getPeople();
<p class="help">Clearing the cache will make moonmoon reload all feeds.</p>
</form>
</div>
-
+
<div class="widget">
<h3>Change administrator password</h3>
<form action="changepassword.php" method="post" id="frmPassword">
<p><label for="password">New password:</label> <input type="password" class="text" value="" name="password" id="password" size="20" /> <input type="submit" class="submit delete" name="changepwd" id="changepwd" value="Change password" /></p>
</form>
</div>
- </div>
- </div>
-</body>
-</html> \ No newline at end of file
+
+FRAGMENT;
+
+$footer_extra = '';
+$admin_access = 1;
+require_once dirname(__FILE__) . '/template.php';
diff --git a/admin/inc/nav.inc.php b/admin/inc/nav.inc.php
deleted file mode 100644
index d524348..0000000
--- a/admin/inc/nav.inc.php
+++ /dev/null
@@ -1,5 +0,0 @@
-<p class="logout"><a href="logout.php">Logout</a></p>
-<ul id="nav">
- <li id="nav-feed"><a href="index.php">Feeds</a></li>
- <li id="nav-admin"><a href="administration.php">Administration</a></li>
-</ul> \ No newline at end of file
diff --git a/admin/index.php b/admin/index.php
index feee813..b075206 100644
--- a/admin/index.php
+++ b/admin/index.php
@@ -1,52 +1,75 @@
<?php
-require_once dirname(__FILE__).'/inc/auth.inc.php';
-include_once(dirname(__FILE__).'/../app/classes/Planet.class.php');
+require_once dirname(__FILE__) . '/inc/auth.inc.php';
+require_once(dirname(__FILE__) . '/../app/classes/Planet.class.php');
-//Load configuration
-if (is_file(dirname(__FILE__).'/../custom/config.yml')){
- $conf = Spyc::YAMLLoad(dirname(__FILE__).'/../custom/config.yml');
- $PlanetConfig = new PlanetConfig($conf);
-} else {
- die('Config file (custom/config.yml) is missing.');
+//Load configuration
+$config_file = dirname(__FILE__) . '/../custom/config.yml';
+
+if (is_file($config_file)){
+ $conf = Spyc::YAMLLoad($config_file);
+ $PlanetConfig = new PlanetConfig($conf);
+} else {
+ die('Config file (custom/config.yml) is missing.');
}
-//Instantiate app
+//Instantiate app
$Planet = new Planet($PlanetConfig);
-
+
//Load
-if (0 < $Planet->loadOpml(dirname(__FILE__).'/../custom/people.opml')) {
- $Planet->loadFeeds();
- $items = $Planet->getItems();
+if (0 < $Planet->loadOpml(dirname(__FILE__) . '/../custom/people.opml')) {
+ $Planet->loadFeeds();
+ $items = $Planet->getItems();
}
-
-$everyone = $Planet->getPeople();
-header('Content-type: text/HTML; charset=UTF-8');
-?>
-<!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" xml:lang="en" lang="en">
-<head>
- <meta http-equiv="Content-Type" content="text/HTML; charset=UTF-8" />
- <meta http-equiv="Content-Script-Type" content="text/javascript" />
- <meta http-equiv="Content-Style-Type" content="text/css" />
- <meta http-equiv="Content-Language" content="en" />
+$everyone = $Planet->getPeople();
+$count_feeds = count($everyone);
+$page_id = 'admin-feed';
+$footer_extra = <<<FRAGMENT
+ <script>
+ var allCheckboxes = function(status){
+ var form = document.getElementById('feedmanage');
+ var selectboxes = form.getElementsByTagName('input');
+ for (var i=0; i<selectboxes.length; i++){
+ if ('checkbox' == selectboxes[i].type){
+ selectboxes[i].checked = status;
+ }
+ }
+ }
+
+ window.onload = function(){
+ //Select/unselect rows
+ var form = document.getElementById('feedmanage');
+ var selectboxes = form.getElementsByTagName('input');
+ for (var i=0; i<selectboxes.length; i++){
+ if ('checkbox' == selectboxes[i].type) {
+ selectboxes[i].onchange = function() {
+ var tr = this.parentNode.parentNode;
+ if (this.checked) {
+ tr.className += ' selected';
+ } else {
+ tr.className = tr.className.replace('selected','');
+ }
+ }
+ }
+ }
+
+ var btSelectall = document.getElementById('selectall');
+ btSelectall.onclick = function(){
+ allCheckboxes('checked');
+ }
- <title>moonmoon administration</title>
- <link rel="stylesheet" media="screen" type="text/css" href="default.css" />
-</head>
+ var btSelectnone = document.getElementById('selectnone');
+ btSelectnone.onclick = function(){
+ allCheckboxes('');
+ }
+ }
+ </script>
+FRAGMENT;
-<body id="admin-feed">
- <div id="page">
- <div id="header">
- <h1>moonmoon</h1>
- <p><a href="../">Back to main page</a></p>
- </div>
-
- <?php readfile("inc/nav.inc.php"); ?>
+ob_start();
+?>
- <div id="content">
<div class="widget">
<h3>Add a new feed</h3>
<form action="subscriptions.php" method="post" id="feedimport">
@@ -63,7 +86,7 @@ header('Content-type: text/HTML; charset=UTF-8');
<h3>Manage existing feeds</h3>
<form action="subscriptions.php" method="post" id="feedmanage">
<p class="action">
- <span class="count">Number of feeds: <?php echo count($everyone); ?></span>
+ <span class="count">Number of feeds: <?=$count_feeds?></span>
<input type="submit" class="submit save" name="save" id="save" value="Save changes" />
<input type="submit" class="submit delete" name="delete" id="delete" value="Delete selected" />
</p>
@@ -79,16 +102,16 @@ header('Content-type: text/HTML; charset=UTF-8');
</tr>
</thead>
<tbody>
- <?php
+ <?php
$i = 0;
foreach ($everyone as $opml_person){
$i++;
?>
- <tr class="<?php echo ($i%2)?'odd':'even'; ?>">
- <td><input type="checkbox" class="checkbox" name="opml[<?php echo $i; ?>][delete]" /></td>
- <td><input type="text" size="10" class="text" name="opml[<?php echo $i; ?>][name]" value="<?php echo $opml_person->getName(); ?>" /></td>
+ <tr class="<?=($i%2)?'odd':'even'; ?>">
+ <td><input type="checkbox" class="checkbox" name="opml[<?=$i; ?>][delete]" /></td>
+ <td><input type="text" size="10" class="text" name="opml[<?=$i; ?>][name]" value="<?=$opml_person->getName(); ?>" /></td>
<td>
- <?php
+ <?php
$items = $opml_person->get_items();
if (count($items) > 0) {
echo $items[0]->get_date();
@@ -97,55 +120,17 @@ header('Content-type: text/HTML; charset=UTF-8');
}
?>
</td>
- <td><input type="text" size="30" class="text" name="opml[<?php echo $i; ?>][website]" value="<?php echo $opml_person->getWebsite(); ?>" /></td>
- <td><input type="text" size="30" class="text" name="opml[<?php echo $i; ?>][feed]" value="<?php echo $opml_person->getFeed(); ?>" /></td>
+ <td><input type="text" size="30" class="text" name="opml[<?=$i; ?>][website]" value="<?=$opml_person->getWebsite(); ?>" /></td>
+ <td><input type="text" size="30" class="text" name="opml[<?=$i; ?>][feed]" value="<?=$opml_person->getFeed(); ?>" /></td>
</tr>
<?php } ?>
</tbody>
</table>
</form>
</div>
- </div>
- </div>
-
- <script>
- var allCheckboxes = function(status){
- var form = document.getElementById('feedmanage');
- var selectboxes = form.getElementsByTagName('input');
- for (var i=0; i<selectboxes.length; i++){
- if ('checkbox' == selectboxes[i].type){
- selectboxes[i].checked = status;
- }
- }
- }
-
- window.onload = function(){
- //Select/unselect rows
- var form = document.getElementById('feedmanage');
- var selectboxes = form.getElementsByTagName('input');
- for (var i=0; i<selectboxes.length; i++){
- if ('checkbox' == selectboxes[i].type) {
- selectboxes[i].onchange = function() {
- var tr = this.parentNode.parentNode;
- if (this.checked) {
- tr.className += ' selected';
- } else {
- tr.className = tr.className.replace('selected','');
- }
- }
- }
- }
-
- var btSelectall = document.getElementById('selectall');
- btSelectall.onclick = function(){
- allCheckboxes('checked');
- }
-
- var btSelectnone = document.getElementById('selectnone');
- btSelectnone.onclick = function(){
- allCheckboxes('');
- }
- }
- </script>
-</body>
-</html>
+<?php
+$page_content = ob_get_contents();
+ob_end_clean();
+
+$admin_access = 1;
+require_once dirname(__FILE__) . '/template.php';
diff --git a/admin/login.php b/admin/login.php
index 0dbc794..b779b36 100644
--- a/admin/login.php
+++ b/admin/login.php
@@ -3,40 +3,21 @@ if (isset($_POST['password'])) {
setcookie('auth',md5($_POST['password']));
header('Location: index.php');
}
-header('Content-type: text/html; charset=UTF-8');
-?><!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" xml:lang="en" lang="en">
-<head>
- <meta http-equiv="Content-Type" content="text/HTML; charset=UTF-8" />
- <meta http-equiv="Content-Script-Type" content="text/javascript" />
- <meta http-equiv="Content-Style-Type" content="text/css" />
- <meta http-equiv="Content-Language" content="en" />
- <title>moonmoon administration</title>
- <link rel="stylesheet" media="screen" type="text/css" href="default.css" />
-</head>
-<body id="admin-feed">
- <div id="page">
- <div id="header">
- <h1>moonmoon</h1>
- <p><a href="../">Back to main page</a></p>
- </div>
-
- <div id="content">
+$page_content = <<<FRAGMENT
<form action="" method="post" class="login">
<fieldset>
<p class="field">
<label for="password">Password:</label>
<input type="password" name="password" id="password"/>
-
<input type="submit" class="submit" value="OK"/>
</p>
</fieldset>
</form>
- </div>
- </div>
+FRAGMENT;
+
+$footer_extra = <<<FRAGMENT
<script type="text/javascript">
<!--
window.onload = function() {
@@ -44,5 +25,9 @@ header('Content-type: text/html; charset=UTF-8');
}
-->
</script>
-</body>
-</html> \ No newline at end of file
+
+FRAGMENT;
+
+$page_id = 'admin-login';
+$admin_access = 0;
+require_once dirname(__FILE__) . '/template.php';
diff --git a/admin/template.php b/admin/template.php
new file mode 100644
index 0000000..2c95d5b
--- /dev/null
+++ b/admin/template.php
@@ -0,0 +1,44 @@
+<?php if(!isset($admin_access)) return; ?>
+
+<!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" xml:lang="en" lang="en">
+<head>
+ <meta http-equiv="Content-Type" content="text/HTML; charset=UTF-8" />
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <meta http-equiv="Content-Language" content="en" />
+
+ <title>moonmoon administration</title>
+ <link rel="stylesheet" media="screen" type="text/css" href="default.css" />
+ <?=@$header_extra ?: ''; ?>
+</head>
+
+<body id="<?=@$page_id ?: ''; ?>">
+ <div id="page">
+ <div id="header">
+ <h1>moonmoon</h1>
+ <p><a href="../">Back to main page</a></p>
+ </div>
+
+ <?php if($admin_access == 1) : ?>
+
+ <p class="logout"><a href="logout.php">Logout</a></p>
+ <ul id="nav">
+ <li id="nav-feed"><a href="index.php">Feeds</a></li>
+ <li id="nav-admin"><a href="administration.php">Administration</a></li>
+ </ul>
+
+ <?php endif; ?>
+
+ <div id="content">
+
+ <?=@$page_content ?: ''; ?>
+
+ </div>
+ </div>
+
+<?=@$footer_extra ?: ''; ?>
+
+</body>
+</html>