summaryrefslogtreecommitdiff
path: root/html
diff options
context:
space:
mode:
authorGeorge Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2023-03-12 18:00:00 +0200
committerGeorge Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2023-03-12 18:00:00 +0200
commit221af3a2e035bd6689294509feb52f286d3bd5be (patch)
tree811188225d6edc9f303c777f86aa8604c6f21743 /html
parent8b1a9cca9ca949d431f6ef5cf2b1fba0f27b4209 (diff)
downloadclassroom-221af3a2e035bd6689294509feb52f286d3bd5be.tar.gz
classroom-221af3a2e035bd6689294509feb52f286d3bd5be.tar.bz2
classroom-221af3a2e035bd6689294509feb52f286d3bd5be.zip
database connection and documentation API
Diffstat (limited to 'html')
-rw-r--r--html/app/models/Jorge.php33
-rw-r--r--html/app/models/cms/Media_model.php36
-rw-r--r--html/app/models/user/Validate_model.php (renamed from html/app/models/Validate_model.php)0
-rw-r--r--html/app/views/error/404.php38
-rw-r--r--html/app/views/error/general.php38
5 files changed, 130 insertions, 15 deletions
diff --git a/html/app/models/Jorge.php b/html/app/models/Jorge.php
index 011b8c0..5d79007 100644
--- a/html/app/models/Jorge.php
+++ b/html/app/models/Jorge.php
@@ -43,21 +43,23 @@ class Jorge
// define relations
$this->tables['relate'] = [
- 'products' => [
- 'brands' => 'products.BrandID = brands.ID',
- 'products_to_product_categories' => 'products.ID = products_to_product_categories.SimpleProductID',
- 'products_to_images' => 'products.ID = products_to_images.SimpleProductID',
- 'prices' => 'products.SKU = prices.SKU'
+ 'lesson' => [
+ 'course' => 'course.id = lesson.course_id',
+ 'lesson_media' => 'lesson_media.lesson_id = lesson.id',
+ 'lesson_privilege' => 'lesson_privilege.lesson_id = lesson.id'
],
- 'products_to_product_categories' => [
- 'product_categories' => 'product_categories.ID = products_to_product_categories.ProductCategoryID'
+ 'page' => [
+ 'page_media' => 'page_media.page_id = page.id'
],
- 'products_to_images' => [
- 'products' => 'products_to_images.SimpleProductID = products.ID',
- 'assets' => 'products_to_images.ImageID = assets.ID'
- ]
+ 'user' => [
+ 'user_privilege' => 'user_privilege.user_id = user.id'
+ ],
+
+ 'privilege' => [
+ 'user_privilege' => 'user_privilege.privilege_id = privilege.id'
+ ],
];
@@ -113,7 +115,7 @@ class Jorge
private function extractTableFields()
{
// words used by SQL that can not be field names
- $nonFields = ['PRIMARY', 'KEY', '(', ')']; // reduced list (used on CREATE)
+ $nonFields = ['PRIMARY', 'KEY', '(', ')', 'CONSTRAINT', 'UNIQUE']; // reduced list (used on CREATE)
foreach( $this->tables['create'] as $table => $sqlCreate ) {
@@ -130,10 +132,11 @@ class Jorge
// remove 1st+last parentesis
$mainDefinitions = substr($match[0][0], 1, -1);
- // replace comma (,) on decimal definitions
- // example: 'decimal(18, 2)' turns to 'decimal(18: 2)'
+ // replace comma (,) on sub-parenthesis
+ // ex: 'decimal(18, 2)' turns to 'decimal(18: 2)'
+ // or: 'PRIMARY KEY (id1, id2)' turns to 'PRIMARY KEY (id1: id2)'
$sentences = preg_replace(
- '/\\(([0-9]*)[ ,]([0-9 ]*)\\)/',
+ '/\\(([0-9a-zA-Z_`]*)[ ,]([0-9a-zA-Z_` ]*)\\)/',
'($1:$2)',
$mainDefinitions,
-1
diff --git a/html/app/models/cms/Media_model.php b/html/app/models/cms/Media_model.php
index e69de29..6a4a681 100644
--- a/html/app/models/cms/Media_model.php
+++ b/html/app/models/cms/Media_model.php
@@ -0,0 +1,36 @@
+<?php
+
+namespace app\models\cms;
+
+use \Registry;
+
+
+class Media_model
+{
+ public static function serve($type, $id, $ticket)
+ {
+
+ // get media data
+ // [ type =>, rights =>, path => ]
+
+ // validate ticket
+ // ValidateAccess::for($ticket)
+
+ // serve
+ // header("Content-type: type");
+ // passthru('cat $media_path');
+
+
+ return Registry::use('database')->query(
+ "SELECT * FROM pages
+ WHERE FullFriendlyUrl = :url AND IsActive = 1",
+ [ ':url' => $url ]
+ )->getFirst();
+ }
+
+}
+
+
+
+// check:
+// https://stackoverflow.com/questions/1353850/serve-image-with-php-script-vs-direct-loading-an-image \ No newline at end of file
diff --git a/html/app/models/Validate_model.php b/html/app/models/user/Validate_model.php
index ec60d72..ec60d72 100644
--- a/html/app/models/Validate_model.php
+++ b/html/app/models/user/Validate_model.php
diff --git a/html/app/views/error/404.php b/html/app/views/error/404.php
new file mode 100644
index 0000000..a7ea624
--- /dev/null
+++ b/html/app/views/error/404.php
@@ -0,0 +1,38 @@
+<html>
+ <head>
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <title>404: Not Found</title>
+ <style>
+ html,body{ padding:0; margin:0;
+ font-size:1.25em; color: #037 /*#a05*/; font-family: 'Roboto Slab', Consolas, Monaco, "Ubuntu Mono", fixed;
+ line-height:1.2em; background: ##f3f4f5;
+ }
+ h3 { font-size: 5.2em; font-style: normal; color: #05a /*#a05*/;
+ margin: 0; padding: 0;
+ opacity: 0.27;
+ }
+ .container { display: flex; height: 100vh; align-items:center; }
+ .content { position: relative;
+ max-width:520px; width: 100%; margin: auto auto; padding: 1.5em;
+ /* text-align: center; justify-center: center; */
+ font-size: .75em; opacity: .33; font-style: italic;
+ }
+ @media screen and ( max-width: 720px) {
+ html, body { font-size: 1.24em; }
+ h3 { font-size: 4em; }
+ }
+ </style>
+ </head>
+ <body>
+ <div class='container'>
+ <div class='content'>
+ <h3>4O4</h3>
+ NOT FOUND<br />
+ —
+ <br />
+ <span><?= $message ?? "and I still haven't found what I'm looking for." ?></span>
+ </div>
+ </div>
+ </body>
+</html>
diff --git a/html/app/views/error/general.php b/html/app/views/error/general.php
new file mode 100644
index 0000000..1c3c6ae
--- /dev/null
+++ b/html/app/views/error/general.php
@@ -0,0 +1,38 @@
+<html>
+ <head>
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <title>404: Not Found</title>
+ <style>
+ html,body{ padding:0; margin:0;
+ font-size:1.25em; color: #037 /*#a05*/; font-family: 'Roboto Slab', Consolas, Monaco, "Ubuntu Mono", fixed;
+ line-height:1.2em; background: ##f3f4f5;
+ }
+ h3 { font-size: 5.2em; font-style: normal; color: #05a /*#a05*/;
+ margin: 0; padding: 0;
+ opacity: 0.27;
+ }
+ .container { display: flex; height: 100vh; align-items:center; }
+ .content { position: relative;
+ max-width:720px; width: 100%; margin: auto auto; padding: 1.5em;
+ /* text-align: center; justify-center: center; */
+ font-size: .75em; opacity: .33; font-style: italic;
+ }
+ @media screen and ( max-width: 720px) {
+ html, body { font-size: 1.24em; }
+ h3 { font-size: 4em; }
+ }
+ </style>
+ </head>
+ <body>
+ <div class='container'>
+ <div class='content'>
+ <h3>Error</h3>
+ Oops!<br />
+ —
+ <br />
+ <span><?= $message ?? "" ?></span>
+ </div>
+ </div>
+ </body>
+</html>