Quellcode durchsuchen

Document List fully added

Moritz Schmidt vor 10 Jahren
Ursprung
Commit
2fdf6b29e6
4 geänderte Dateien mit 46 neuen und 11 gelöschten Zeilen
  1. 23 5
      includes/document.inc.php
  2. 1 1
      includes/functions.inc.php
  3. 21 4
      templates/documentlist.php
  4. 1 1
      templates/label.php

+ 23 - 5
includes/document.inc.php

@@ -5,12 +5,18 @@ class Document {
     private $fileName   =   NULL;
     private $path       =   NULL;
     private $labelId    =   NULL;
+    private $draft      =   NULL;
+    private $created    =   NULL;
+    private $lastChange =   NULL;
 
-    public function __construct($id, $fileName, $path, $labelId) {
-        $this->id = $id;
-        $this->fileName = $fileName;
-        $this->path = $path;
-        $this->labelId = $labelId;
+    public function __construct($id, $fileName, $path, $labelId, $draft, $created, $lastChange) {
+        $this->id           = $id;
+        $this->fileName     = $fileName;
+        $this->path         = $path;
+        $this->labelId      = $labelId;
+        $this->draft        = $draft;
+        $this->created      = $created;
+        $this->lastChange   = $lastChange;
     }
 
     public function getId() {
@@ -25,6 +31,18 @@ class Document {
         return $this->path;
     }
 
+    public function getDraft() {
+        return $this->draft;
+    }
+
+    public function getCreated() {
+        return $this->created;
+    }
+
+    public function getLastChange() {
+        return $this->lastChange;
+    }
+
 }
 
 ?>

+ 1 - 1
includes/functions.inc.php

@@ -35,7 +35,7 @@ function getDocumentsByLabelId($labelId) {
 	$documents = $db->query("SELECT * FROM `documents` WHERE `label_id` = " . $labelId . ";");
 
 	foreach($documents as $document) {
-		$return[] = new Document($document->id, $document->filename, $document->path, $document->labelId);
+		$return[] = new Document($document->id, $document->filename, $document->path, $document->label_id, $document->draft, $document->created, $document->last_change);
 	}
 
 	return $return;

+ 21 - 4
templates/documentlist.php

@@ -1,10 +1,27 @@
 <?php
+// TODO: Make this MVC-style
+$documents = getDocumentsByLabelId(2); // TODO: get documents via labelID
 
-$documents = getDocumentsByLabelId(2);
+//print_r($documents);
+?>
 
+<table class="table table-striped">
+    <thead>
+        <tr>
+            <th>Name</th>
+            <th>Vorlage</th>
+            <th>Erstellt am</th>
+            <th>Letzte Änderung</th>
+        </tr>
+    </thead>
+<?php
 foreach($documents as $document) {
-    echo $document->getFileName();
+    echo '<tr>';
+    echo '<td>' . $document->getFileName() . '</td>';
+    echo '<td>' . $document->getDraft() . '</td>';
+    echo '<td>' . $document->getCreated() . '</td>';
+    echo '<td>' . $document->getLastChange() . '</td>';
+    echo '</tr>';
 }
-
-
 ?>
+</table>

+ 1 - 1
templates/label.php

@@ -12,7 +12,7 @@ foreach($this->_['entries'] as $entry){
 <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
     <h1 class="page-header"><?php echo $this->_['label'][0]->getName(); ?></h1>
 
-    <div class="row placeholders">
+    <div class="row">
         <div role="tabpanel">
             <!-- Nav tabs -->
             <ul class="nav nav-tabs" role="tablist">