Working on Baïkal Admin
This commit is contained in:
parent
a2553e1c1f
commit
9fc46479d9
10 changed files with 160 additions and 11 deletions
|
@ -26,6 +26,8 @@
|
|||
|
||||
define("BAIKAL_FRAMEWORK_ROOT", dirname(__FILE__) . "/");
|
||||
define("BAIKAL_FRAMEWORK_LIBDIR", BAIKAL_FRAMEWORK_ROOT . "lib/");
|
||||
define("BAIKAL_FRAMEWORK_RESDIR", BAIKAL_FRAMEWORK_ROOT . "res/");
|
||||
|
||||
require_once(BAIKAL_FRAMEWORK_LIBDIR . "BaikalTemplate.php");
|
||||
require_once(BAIKAL_FRAMEWORK_LIBDIR . "BaikalAdmin.php");
|
||||
require_once(BAIKAL_FRAMEWORK_LIBDIR . "BaikalTools.php");
|
|
@ -96,13 +96,21 @@ class BaikalAdmin {
|
|||
return md5('admin:' . BAIKAL_AUTH_REALM . ':' . $sPassword);
|
||||
}
|
||||
|
||||
static function wrapWithInterface($sHtml) {
|
||||
$oTemplate = new BaikalTemplate(BAIKAL_FRAMEWORK_RESDIR . "template.html");
|
||||
return $oTemplate->parse(array(
|
||||
"pagetitle" => "Users",
|
||||
"pagecontent" => $sHtml
|
||||
));
|
||||
}
|
||||
|
||||
static function displayUsers() {
|
||||
$aUsers = BaikalTools::getUsers();
|
||||
|
||||
$oTabulator = new TabulatorHtml();
|
||||
$oTabulator = new TabulatorHtml("table table-bordered");
|
||||
$oTabulator->addColumn(self::makeColumn("id", "Id", "numeric"));
|
||||
$oTabulator->addColumn(self::makeColumn("username", "Username"));
|
||||
$oTabulator->render($aUsers);
|
||||
return $oTabulator->render($aUsers);
|
||||
}
|
||||
|
||||
static function &makeColumn($sName, $sHeader = "", $sType = "text") {
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
/***************************************************************
|
||||
* Copyright notice
|
||||
*
|
||||
* (c) 2012 Jérôme Schneider <mail@jeromeschneider.fr>
|
||||
* All rights reserved
|
||||
*
|
||||
* http://baikal.codr.fr
|
||||
*
|
||||
* This script is part of the Baïkal Server project. The Baïkal
|
||||
* Server project is free software; you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* The GNU General Public License can be found at
|
||||
* http://www.gnu.org/copyleft/gpl.html.
|
||||
*
|
||||
* This script is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* This copyright notice MUST APPEAR in all copies of the script!
|
||||
***************************************************************/
|
||||
|
||||
class BaikalTemplate {
|
||||
|
||||
private $sAbsPath = "";
|
||||
private $sHtml = "";
|
||||
|
||||
public function __construct($sAbsPath) {
|
||||
$this->sAbsPath = $sAbsPath;
|
||||
$this->sHtml = self::getTemplateFile(
|
||||
$this->sAbsPath
|
||||
);
|
||||
}
|
||||
|
||||
public function parse($aMarkers = array()) {
|
||||
return self::parseTemplateCodePhp(
|
||||
$this->sHtml,
|
||||
$aMarkers
|
||||
);
|
||||
}
|
||||
|
||||
protected static function getTemplateFile($sAbsPath) {
|
||||
return file_get_contents($sAbsPath);
|
||||
}
|
||||
|
||||
protected static function parseTemplateCodePhp($sCode, $aMarkers) {
|
||||
extract($aMarkers);
|
||||
ob_start();
|
||||
echo eval('?>' . $sCode . '<?');
|
||||
$sHtml = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
return $sHtml;
|
||||
}
|
||||
}
|
61
CoreVersions/Baikal_0.1/Frameworks/Baikal/res/template.html
Normal file
61
CoreVersions/Baikal_0.1/Frameworks/Baikal/res/template.html
Normal file
|
@ -0,0 +1,61 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Baïkal Admin</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="description" content="">
|
||||
<meta name="author" content="">
|
||||
|
||||
<!-- Le styles -->
|
||||
<link href="/res/TwitterBootstrap/css/bootstrap.css" rel="stylesheet">
|
||||
<style>
|
||||
body {
|
||||
padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
|
||||
}
|
||||
</style>
|
||||
<link href="/res/TwitterBootstrap/css/bootstrap-responsive.css" rel="stylesheet">
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="navbar navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container">
|
||||
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</a>
|
||||
<a class="brand" href="#">Baïkal Admin</a>
|
||||
<div class="nav-collapse">
|
||||
<ul class="nav">
|
||||
<li class="active"><a href="#">Home</a></li>
|
||||
<li><a href="#about">About</a></li>
|
||||
<li><a href="#contact">Contact</a></li>
|
||||
</ul>
|
||||
</div><!--/.nav-collapse -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
|
||||
<h1><?= $pagetitle ?></h1>
|
||||
<p>Use this document as a way to quick start any new project.<br> All you get is this message and a barebones HTML document.</p>
|
||||
<?= $pagecontent ?>
|
||||
|
||||
</div> <!-- /container -->
|
||||
|
||||
<!-- Le javascript
|
||||
================================================== -->
|
||||
<!-- Placed at the end of the document so the pages load faster -->
|
||||
<script src="/res/TwitterBootstrap/js/jquery-1.7.1.min.js"></script>
|
||||
<script src="/res/TwitterBootstrap/js/bootstrap.min.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -7,13 +7,21 @@ require_once($sDir . "Tabulator.php");
|
|||
class TabulatorColumnHtml extends TabulatorColumn {
|
||||
|
||||
protected function wrap($sString) {
|
||||
return $this->htmlWrap($sString, "td");
|
||||
}
|
||||
|
||||
protected function wrapHeader($sString) {
|
||||
return $this->htmlWrap($sString, "th");
|
||||
}
|
||||
|
||||
protected function htmlWrap($sString, $sTag) {
|
||||
if(in_array($this->getType(), array("numeric", "duration"))) {
|
||||
$sAlign = "right";
|
||||
} else {
|
||||
$sAlign = "left";
|
||||
}
|
||||
|
||||
return "<td class=\"col-" . $this->getName() . " align-" . $sAlign . "\">" . $sString . "</td>";
|
||||
return "<" . $sTag . " class=\"col-" . $this->getName() . " align-" . $sAlign . "\">" . $sString . "</" . $sTag . ">";
|
||||
}
|
||||
|
||||
public function renderUnderline() {
|
||||
|
|
|
@ -50,10 +50,15 @@ abstract class Tabulator {
|
|||
return implode("", $aRes) . "\n";
|
||||
}
|
||||
|
||||
public function renderAndDisplay($aValues) {
|
||||
echo $this->render($aValues);
|
||||
}
|
||||
|
||||
public function render($aValues) {
|
||||
|
||||
$this->iNbValues = count($aValues);
|
||||
|
||||
$sRes = "";
|
||||
|
||||
reset($aValues);
|
||||
while(list($iRow,) = each($aValues)) {
|
||||
reset($aValues[$iRow]);
|
||||
|
@ -64,10 +69,12 @@ abstract class Tabulator {
|
|||
}
|
||||
}
|
||||
|
||||
echo $this->renderOpen();
|
||||
echo $this->renderHeader();
|
||||
echo $this->renderValues();
|
||||
echo $this->renderClose();
|
||||
$sRes .= $this->renderOpen();
|
||||
$sRes .= $this->renderHeader();
|
||||
$sRes .= $this->renderValues();
|
||||
$sRes .= $this->renderClose();
|
||||
|
||||
return $sRes;
|
||||
}
|
||||
|
||||
abstract protected function getSep();
|
||||
|
|
4
CoreVersions/Baikal_0.1/Frameworks/Versions/TwitterBootstrap.2.0.2/js/jquery-1.7.1.min.js
vendored
Normal file
4
CoreVersions/Baikal_0.1/Frameworks/Versions/TwitterBootstrap.2.0.2/js/jquery-1.7.1.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
|
@ -35,6 +35,4 @@ require_once(BAIKAL_PATH_FRAMEWORKS . "Baikal/Includes.php");
|
|||
BaikalAdmin::assertEnabled();
|
||||
BaikalAdmin::assertAuthentified();
|
||||
|
||||
echo "<h1>Baïkal Admin</h1>";
|
||||
|
||||
BaikalAdmin::displayUsers();
|
||||
echo BaikalAdmin::wrapWithInterface(BaikalAdmin::displayUsers());
|
1
CoreVersions/Baikal_0.1/WWWRoot/res/TwitterBootstrap
Symbolic link
1
CoreVersions/Baikal_0.1/WWWRoot/res/TwitterBootstrap
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../Frameworks/TwitterBootstrap
|
1
html/res
Symbolic link
1
html/res
Symbolic link
|
@ -0,0 +1 @@
|
|||
../Core/WWWRoot/res
|
Loading…
Reference in a new issue