Ver Fonte

Little updates, dunno exactly

Moritz Schmidt há 10 anos atrás
pai
commit
eb67ab7deb

+ 5 - 4
includes/config.inc.php

@@ -1,10 +1,11 @@
 <?php
 
 $CONFIG = array(
-	"dbHost"		=>		"127.0.0.1",
-	"dbUser"		=>		"root",
-	"dbPassword"	=>		"root",
-	"dbDatabase"	=>		"atoffice"
+	"dbHost"		=>		"127.0.0.1", // Database Host
+	"dbUser"		=>		"root", // Database Username
+	"dbPassword"	=>		"root", // Database Password
+	"dbDatabase"	=>		"atoffice", // Database name
+	"documentPath"	=> 		"/home/moritz/atOffice/documents" // Full path to documents folder
 
 );
 

+ 4 - 1
includes/controller.inc.php

@@ -56,7 +56,10 @@ class Controller {
 				break;
 			case 'label':
 				$innerView->setTemplate('label');
-				$innerView->assign('label', getLabelFromId($this->request['labelId']));
+				$innerView->assign('label', getLabelById($this->request['labelId']));
+				$documentView = new View();
+				$documentView->setTemplate('documentlist');
+				$innerView->assign('documentlist', $documentView->loadTemplate());
 				break;
 			case 'default':
 			default:

+ 30 - 0
includes/document.inc.php

@@ -0,0 +1,30 @@
+<?php
+
+class Document {
+    private $id         =   NULL;
+    private $fileName   =   NULL;
+    private $path       =   NULL;
+    private $labelId    =   NULL;
+
+    public function __construct($id, $fileName, $path, $labelId) {
+        $this->id = $id;
+        $this->fileName = $fileName;
+        $this->path = $path;
+        $this->labelId = $labelId;
+    }
+
+    public function getId() {
+        return $this->id;
+    }
+
+    public function getFileName() {
+        return $this->fileName;
+    }
+
+    public function getPath() {
+        return $this->path;
+    }
+
+}
+
+?>

+ 14 - 1
includes/functions.inc.php

@@ -15,7 +15,7 @@ function getLabels() {
 	return $return;
 }
 
-function getLabelFromId($labelId) {
+function getLabelById($labelId) {
 	global $db;
 
 	$return = array();
@@ -28,4 +28,17 @@ function getLabelFromId($labelId) {
 	return $return;
 }
 
+function getDocumentsByLabelId($labelId) {
+	global $db;
+
+	$return = array();
+	$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 $return;
+}
+
 ?>

+ 1 - 0
index.php

@@ -10,6 +10,7 @@ include('includes/view.inc.php');
 include('includes/openvpn.inc.php');
 include('includes/functions.inc.php');
 include('includes/label.inc.php');
+include('includes/document.inc.php');
 
 $db = new Database($CONFIG['dbHost'], $CONFIG['dbUser'], $CONFIG['dbPassword'], $CONFIG['dbDatabase']);
 //$user = new User($_SESSION['username']);

+ 10 - 0
templates/documentlist.php

@@ -0,0 +1,10 @@
+<?php
+
+$documents = getDocumentsByLabelId(2);
+
+foreach($documents as $document) {
+    echo $document->getFileName();
+}
+
+
+?>

+ 5 - 1
templates/label.php

@@ -24,7 +24,11 @@ foreach($this->_['entries'] as $entry){
 
             <!-- Tab panes -->
             <div class="tab-content">
-                <div role="tabpanel" class="tab-pane active" id="home">Dokumente</div>
+                <div role="tabpanel" class="tab-pane active" id="home">
+                    <?php
+                    echo $this->_['documentlist'];
+                    ?>
+                </div>
                 <div role="tabpanel" class="tab-pane" id="profile">PROFILE</div>
                 <div role="tabpanel" class="tab-pane" id="messages">MESSAGE</div>
                 <div role="tabpanel" class="tab-pane" id="settings">SETTINGS</div>