autoformat, minor corrections
This commit is contained in:
parent
8b3023aca7
commit
0974466e37
19 changed files with 334 additions and 290 deletions
|
@ -3,21 +3,25 @@
|
|||
// All credit goes to Chad Minick:
|
||||
// http://chadminick.com/articles/simple-php-template-engine.html
|
||||
|
||||
class Template {
|
||||
class Template
|
||||
{
|
||||
private $vars = array();
|
||||
|
||||
public function __get($name) {
|
||||
public function __get($name)
|
||||
{
|
||||
return $this->vars[$name];
|
||||
}
|
||||
|
||||
public function __set($name, $value) {
|
||||
public function __set($name, $value)
|
||||
{
|
||||
if ($name == 'view_template_file') {
|
||||
throw new Exception("Cannot bind variable named 'view_template_file'");
|
||||
}
|
||||
$this->vars[$name] = $value;
|
||||
}
|
||||
|
||||
public function render($view_template_file) {
|
||||
public function render($view_template_file)
|
||||
{
|
||||
if (array_key_exists('view_template_file', $this->vars)) {
|
||||
throw new Exception("Cannot bind variable called 'view_template_file'");
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
<div class="text document edit-form">
|
||||
<form method="post" id="form" action="admin.php?action=edit_item<?= empty($doc) ? "" : "&item=" . $doc["ID"] ?>" enctype="multipart/form-data">
|
||||
<form method="post" id="form" action="admin.php?action=edit_item<?= empty($doc) ? "" : "&item=" . $doc["ID"] ?>"
|
||||
enctype="multipart/form-data">
|
||||
<strong>Title:</strong> <input type="text" name="Title" value="<?= empty($doc) ? "" : $doc["Title"] ?>"><br>
|
||||
<strong>Author:</strong> <input type="text" name="Author" value="<?= empty($doc) ? "" : $doc["Author"] ?>"><br>
|
||||
<strong>Date published:</strong> <input type="text" name="Published" value="<?= empty($doc) ? "" : $doc["Published"] ?>"><br>
|
||||
<strong>Date published:</strong> <input type="text" name="Published"
|
||||
value="<?= empty($doc) ? "" : $doc["Published"] ?>"><br>
|
||||
<strong>Description:</strong><br>
|
||||
<textarea name="Description" cols="120" rows="20">
|
||||
<?= empty($doc) ? "" : $doc["Description"] ?>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<div class="text">
|
||||
<p>Confirm deletion of <strong>"<?= $doc["Title"] ?>"</strong>:</p>
|
||||
<a href="admin.php?action=remove&confirm=yes&item=<?= $doc["ID"] ?>&ret=<?= $_SERVER['HTTP_REFERER']; ?>" class="button">Remove from database</a>
|
||||
<a href="admin.php?action=remove&confirm=yes&item=<?= $doc["ID"] ?>&ret=<?= $_SERVER['HTTP_REFERER']; ?>"
|
||||
class="button">Remove from database</a>
|
||||
</div>
|
||||
|
|
|
@ -20,10 +20,13 @@
|
|||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($doc["Description"])): ?>
|
||||
<p class="doc-description"><span class="doc-description-intro"><?= empty($doc["URL"]) ? "Content" : "Description" ?>: </span><?= $doc["Description"] ?></p>
|
||||
<p class="doc-description"><span
|
||||
class="doc-description-intro"><?= empty($doc["URL"]) ? "Content" : "Description" ?>
|
||||
: </span><?= $doc["Description"] ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($doc["URL"])): ?>
|
||||
<div class="doc-link"><span class="doc-link-intro">Access file at: </span><a href="<?= $doc["URL"] ?>"><?= urldecode($doc["URL"]) ?></a></div>
|
||||
<div class="doc-link"><span class="doc-link-intro">Access file at: </span><a
|
||||
href="<?= $doc["URL"] ?>"><?= urldecode($doc["URL"]) ?></a></div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
<div class="text">
|
||||
<p class="intro"> This site is the sdbs pile, where we upload the stuff we consider important to the larger conceptual and thematic landscape of what we do: "confronting apathy", inter-subjectivity, the human right to self-determination, counter-culture and such...</p>
|
||||
<p class="intro czech">Tohle je hromádka zajímavýho materiálu co něco znamená v kontextu sdbs - budeme sem postupně dávat ty nejdůležitější nebo nejzajímavější věci, zatim se o tom ale nikde moc nešiřte.</p>
|
||||
<p class="intro"> This site is the sdbs pile, where we upload the stuff we consider important to the larger
|
||||
conceptual and thematic landscape of what we do: "confronting apathy", inter-subjectivity, the human right to
|
||||
self-determination, counter-culture and such...</p>
|
||||
<p class="intro czech">Tohle je hromádka zajímavýho materiálu co něco znamená v kontextu sdbs - budeme sem postupně
|
||||
dávat ty nejdůležitější nebo nejzajímavější věci, zatim se o tom ale nikde moc nešiřte.</p>
|
||||
<p class="intro sign">/-\</p>
|
||||
</div>
|
|
@ -19,7 +19,11 @@
|
|||
_paq.push(['setTrackerUrl', u + 'piwik.php']);
|
||||
_paq.push(['setSiteId', '2']);
|
||||
var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0];
|
||||
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
|
||||
g.type = 'text/javascript';
|
||||
g.async = true;
|
||||
g.defer = true;
|
||||
g.src = u + 'piwik.js';
|
||||
s.parentNode.insertBefore(g, s);
|
||||
})();
|
||||
</script>
|
||||
<noscript><p><img src="//www.sdbs.cz/piwik/piwik.php?idsite=2" style="border:0;" alt=""/></p></noscript>
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
<div class="text">
|
||||
<p class="intro"> This site is the sdbs pile, where we upload the stuff we consider important to the larger conceptual and thematic landscape of what we do: "confronting apathy", inter-subjectivity, the human right to self-determination, counter-culture and such...</p>
|
||||
<p class="intro czech">Tohle je hromádka zajímavýho materiálu co něco znamená v kontextu sdbs - budeme sem postupně dávat ty nejdůležitější nebo nejzajímavější věci, zatim se o tom ale nikde moc nešiřte.</p>
|
||||
<p class="intro"> This site is the sdbs pile, where we upload the stuff we consider important to the larger
|
||||
conceptual and thematic landscape of what we do: "confronting apathy", inter-subjectivity, the human right to
|
||||
self-determination, counter-culture and such...</p>
|
||||
<p class="intro czech">Tohle je hromádka zajímavýho materiálu co něco znamená v kontextu sdbs - budeme sem postupně
|
||||
dávat ty nejdůležitější nebo nejzajímavější věci, zatim se o tom ale nikde moc nešiřte.</p>
|
||||
<p class="intro sign">/-\</p>
|
||||
</div>
|
|
@ -1,25 +1,32 @@
|
|||
<?php
|
||||
class PileDB {
|
||||
|
||||
class PileDB
|
||||
{
|
||||
private $db;
|
||||
|
||||
function __construct() {
|
||||
function __construct()
|
||||
{
|
||||
$this->db = new SQLite3("pile.db");
|
||||
}
|
||||
|
||||
function prepare($statement){
|
||||
function prepare($statement)
|
||||
{
|
||||
return $this->db->prepare($statement);
|
||||
}
|
||||
|
||||
function query($statement){
|
||||
function query($statement)
|
||||
{
|
||||
return $this->db->query($statement);
|
||||
}
|
||||
|
||||
public function getDocCount(){
|
||||
public function getDocCount()
|
||||
{
|
||||
$ret_count = $this->db->query("SELECT count(ID) FROM Documents")->fetchArray(SQLITE3_NUM);
|
||||
return $ret_count[0];
|
||||
}
|
||||
|
||||
public function getUntaggedDocCount(){
|
||||
public function getUntaggedDocCount()
|
||||
{
|
||||
$ret_count = $this->db->query("SELECT
|
||||
count(ID)
|
||||
FROM
|
||||
|
@ -30,7 +37,8 @@ class PileDB {
|
|||
return $ret_count[0];
|
||||
}
|
||||
|
||||
public function getTags(){
|
||||
public function getTags()
|
||||
{
|
||||
$tag_query = "SELECT
|
||||
ID, Name, count(Document)
|
||||
FROM
|
||||
|
@ -51,7 +59,8 @@ class PileDB {
|
|||
return $tags;
|
||||
}
|
||||
|
||||
public function fetchDoc($id){
|
||||
public function fetchDoc($id)
|
||||
{
|
||||
$stmt_doc = $this->db->prepare("SELECT * FROM Documents WHERE ID = :id");
|
||||
$stmt_doc->bindValue(":id", $id, SQLITE3_INTEGER);
|
||||
$doc = $stmt_doc->execute()->fetchArray(SQLITE3_ASSOC);
|
||||
|
@ -69,7 +78,8 @@ class PileDB {
|
|||
return $doc;
|
||||
}
|
||||
|
||||
public function listDocs(){
|
||||
public function listDocs()
|
||||
{
|
||||
if (func_num_args() > 0) {
|
||||
$tag = func_get_arg(0);
|
||||
if ($tag > 0) {
|
||||
|
@ -103,7 +113,8 @@ class PileDB {
|
|||
return $docs;
|
||||
}
|
||||
|
||||
public function updateDoc($id, $title, $author, $description, $published, $url, $tag_ids){
|
||||
public function updateDoc($id, $title, $author, $description, $published, $url, $tag_ids)
|
||||
{
|
||||
if (empty($id)) {
|
||||
$stmt = $this->db->prepare("INSERT INTO Documents
|
||||
(ID, Title, Author, Description, Published, URL)
|
||||
|
@ -145,7 +156,8 @@ class PileDB {
|
|||
}
|
||||
}
|
||||
|
||||
public function removeDoc($id){
|
||||
public function removeDoc($id)
|
||||
{
|
||||
$doc_stmt = $this->db->prepare("DELETE FROM Documents
|
||||
WHERE ID = :id");
|
||||
$doc_stmt->bindValue("id", $id, SQLITE3_INTEGER);
|
||||
|
@ -157,19 +169,22 @@ class PileDB {
|
|||
$tag_stmt->execute();
|
||||
}
|
||||
|
||||
public function findTag($name){
|
||||
public function findTag($name)
|
||||
{
|
||||
$stmt = $this->db->prepare("SELECT * FROM Tags WHERE Name == :name COLLATE NOCASE");
|
||||
$stmt->bindValue(":name", $name, SQLITE3_TEXT);
|
||||
return $stmt->execute()->fetchArray(SQLITE3_ASSOC);
|
||||
}
|
||||
|
||||
public function fetchTag($tag){
|
||||
public function fetchTag($tag)
|
||||
{
|
||||
$stmt = $this->db->prepare("SELECT * FROM Tags WHERE ID == :tag");
|
||||
$stmt->bindValue(":tag", $tag, SQLITE3_INTEGER);
|
||||
return $stmt->execute()->fetchArray(SQLITE3_ASSOC);
|
||||
}
|
||||
|
||||
public function updateTag($id, $name, $description){
|
||||
public function updateTag($id, $name, $description)
|
||||
{
|
||||
if (empty($id)) {
|
||||
$stmt = $this->db->prepare("INSERT INTO Tags
|
||||
(ID, Name, Description)
|
||||
|
@ -188,7 +203,8 @@ class PileDB {
|
|||
return $stmt->execute();
|
||||
}
|
||||
|
||||
public function authenticate($username, $password){
|
||||
public function authenticate($username, $password)
|
||||
{
|
||||
$stmt = $this->db->prepare("SELECT
|
||||
*
|
||||
FROM
|
||||
|
@ -206,4 +222,5 @@ class PileDB {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
<?
|
||||
class Uploader {
|
||||
public function handle($files, $dir){
|
||||
|
||||
class Uploader
|
||||
{
|
||||
public function handle($files, $dir)
|
||||
{
|
||||
if (is_array($files['upfile']['error'])) {
|
||||
throw new RuntimeException('Invalid parameters.');
|
||||
}
|
||||
|
@ -46,4 +49,5 @@ class Uploader {
|
|||
return $name;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -4,11 +4,13 @@
|
|||
}
|
||||
|
||||
*, *:before, *:after {
|
||||
-moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
-webkit-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: Prociono;
|
||||
font-family: Prociono, serif;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
position: relative;
|
||||
|
@ -27,7 +29,7 @@ a {
|
|||
|
||||
#sidebar-head {
|
||||
background-color: #f2f2f2;
|
||||
color: 202020;
|
||||
color: #202020;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
|
@ -214,7 +216,7 @@ input[type="text"] {
|
|||
height: 14pt;
|
||||
font-size: 8pt;
|
||||
border: 1px solid lightgray;
|
||||
background: 202020;
|
||||
background: #202020;
|
||||
}
|
||||
|
||||
.czech {
|
||||
|
|
|
@ -4,7 +4,9 @@
|
|||
}
|
||||
|
||||
*, *:before, *:after {
|
||||
-moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
-webkit-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
|
@ -109,7 +111,6 @@ a {
|
|||
}
|
||||
|
||||
.tag-text
|
||||
|
||||
.document h1 {
|
||||
margin: 0;
|
||||
font-size: 24pt;
|
||||
|
|
Loading…
Reference in a new issue