commit a30eb74e3e566d25bab3a1cad8ab1a39db71b144
Author: Joshua Perry <45966243+jpez-development@users.noreply.github.com>
Date: Sat Jan 21 23:12:42 2023 +0000
first commit
diff --git a/CSY2028 Assignment 2.pdf b/CSY2028 Assignment 2.pdf
new file mode 100644
index 0000000..2b7692b
Binary files /dev/null and b/CSY2028 Assignment 2.pdf differ
diff --git a/CSY2028/DatabaseTable.php b/CSY2028/DatabaseTable.php
new file mode 100644
index 0000000..ed1f060
--- /dev/null
+++ b/CSY2028/DatabaseTable.php
@@ -0,0 +1,70 @@
+table = $table;
+ $this->pk = $pk;
+ $this->entityClass = $entityClass;
+ $this->entityConstructor = $entityConstructor;
+ }
+
+ private function startDB() { //TODO: Maybe move
+ $server = 'mysql';
+ $username = 'student';
+ $password = 'student';
+ $schema = 'job';
+ return new \PDO('mysql:dbname='.$schema.';host='.$server, $username, $password);
+ }
+
+ private function insert($record) {
+ $keys = \array_keys($record);
+ $columns = \implode(', ', $keys);
+ $values = \implode(', :', $keys);
+ startDB()->prepare('INSERT INTO '. $this->table . ' (' . $columns . ') VALUES (:' . $values . ')')->execute($record);
+ }
+
+ private function update($record) {
+ $params = [];
+ foreach ($record as $key => $value) {
+ $params[] = $key . ' = :' .$key;
+ }
+ $record['primaryKey'] = $record[$this->pk];
+ startDB()->prepare('UPDATE '. $this->table .' SET '. \implode(', ', $params) .' WHERE '. $this->pk .' = :primaryKey')->execute($record);
+ }
+
+ public function find($column, $value) {
+ $values = [
+ 'value' => $value
+ ];
+ return startDB()->prepare('SELECT * FROM '. $this->table . ' WHERE '. $field . ' = :value')->setFetchMode(\PDO::FETCH_CLASS, $this->entityClass, $this->entityConstructor)->execute($values)->fetchAll();
+ }
+
+ public function findAll() {
+ return startDB()->prepare('SELECT * FROM ' . $this->table)->execute()->fetchAll();
+ }
+
+ public function delete($column, $value) {
+ $values = [
+ 'value' => $value
+ ];
+ startDB()->prepare('DELETE FROM '. $this->$table .' WHERE '. $column .' = :value')->execute($values);
+ }
+
+ public function save($record) {
+ if (\empty($record[$pk])) {
+ \unset($record[$pk]);
+ }
+ try {
+ insert($record);
+ }
+ catch (\Exception $e) {
+ update($record);
+ }
+ }
+}
+?>
\ No newline at end of file
diff --git a/CSY2028/EntryPoint.php b/CSY2028/EntryPoint.php
new file mode 100644
index 0000000..b9d780f
--- /dev/null
+++ b/CSY2028/EntryPoint.php
@@ -0,0 +1,34 @@
+routes = $routes;
+ }
+
+ public function loadTemplate($fileName, $templateData) {
+ \extract($templateData);
+ \ob_start();
+ require $fileName;
+ return \ob_get_clean();
+ }
+
+ public function run() {
+ $route = \ltrim(\explode('?', $_SERVER['REQUEST_URI'])[0], '/');
+ if ($route == '') {
+ $route = $this->routes->getDefaultRoute();
+ }
+
+ list($controllerName, $functionName) = \explode('/', $route);
+
+ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
+ $functionName = $functionName . 'Submit';
+ }
+
+ $page = $this->routes->getController($controllerName)->$functionName();
+ $content = $this->loadTemplate('../templates/' . $page['template'], $page['vars']);
+ $title = $page['title'];
+ require '../templates/layout.html.php';
+ }
+}
\ No newline at end of file
diff --git a/CSY2028/Routes.php b/CSY2028/Routes.php
new file mode 100644
index 0000000..defb9cf
--- /dev/null
+++ b/CSY2028/Routes.php
@@ -0,0 +1,7 @@
+
\ No newline at end of file
diff --git a/jobs/Routes.php b/jobs/Routes.php
new file mode 100644
index 0000000..970efb4
--- /dev/null
+++ b/jobs/Routes.php
@@ -0,0 +1,33 @@
+jobTable = $jobTable;
+ }
+
+ public function home() {
+ return ['template' => 'home.html.php',
+ 'title' => 'Jo\'s Jobs- Home',
+ 'vars' => []
+ ];
+ }
+}
+?>
\ No newline at end of file
diff --git a/pages/about.html b/pages/about.html
new file mode 100644
index 0000000..1d16eb0
--- /dev/null
+++ b/pages/about.html
@@ -0,0 +1,55 @@
+
+
+
+
+ Jo's Jobs - About
+
+
+
+
+
+
Jo's Jobs
+
+
+
+
+
+
+
Welcome to Jo's Jobs, we're a recruitment agency based in Northampton. We offer a range of different office jobs. Get in touch if you'd like to list a job with us.
Welcome to Jo's Jobs, we're a recruitment agency based in Northampton. We offer a range of different office jobs. Get in touch if you'd like to list a job with us.
\ No newline at end of file
diff --git a/templates/layout.html.php b/templates/layout.html.php
new file mode 100644
index 0000000..c52c243
--- /dev/null
+++ b/templates/layout.html.php
@@ -0,0 +1,40 @@
+
+
+
+
+ =$title;?>
+
+
+
+
+
+
Jo's Jobs
+
+
+
+
+
+ =$content;?>
+
+
+
+
diff --git a/todo b/todo
new file mode 100644
index 0000000..12fbbea
--- /dev/null
+++ b/todo
@@ -0,0 +1,26 @@
+Assignment 2:
+ - Copyright updates to current year @done
+ - Add FAQs page
+ - Placeholder text ('FAQs coming soon')
+ - Menu link
+ - Admin can update categories but are not visable on site
+ - Add cats to Jobs page
+ - Add cats to nav bar
+ - Job list in admin area lists all jobs
+ - Add cat name as new column in table
+ - Add filter to be able to filter by cat
+ - Allow customers to filter by location
+ - Add admin user control to admin panel
+ - Client user accounts
+ - restricted admin panel
+ - add and remove jobs
+ - see who has applied for jobs
+ - Client can only see their jobs
+ - Homepage has 10 jobs that are about to reach closing date
+ - Contact form on contact page
+ - forms store data in db
+ - stored enquiries can be accessed from admin panel
+ - can mark enquieries as Completed once admin has responded
+ - Keep list of all previous enquieries and which admin dealt with it
+ - Create entity classes for database entities (topic 18)
+ - page 37-38 for implementation