From 546daa78721e6abdbc89afcecc158118c2239865 Mon Sep 17 00:00:00 2001
From: George Halkiadakis
Date: Wed, 26 Apr 2023 21:43:02 +0300
Subject: alfa.3 version; backend designer and front-end embeder enabled
---
public/app/views/admin/admin-menu.php | 2 +-
public/app/views/admin/edit_page.php | 139 ++++++++++++++++
public/app/views/admin/pages.php | 109 ++++++++++++
public/app/views/components/footer.php | 240 +++++++++++++++++++++++++++
public/app/views/components/lessons_list.php | 49 +++---
public/app/views/error/general.php | 3 +-
public/app/views/templates/course.php | 11 ++
public/app/views/templates/lesson.php | 10 ++
public/app/views/templates/page.php | 64 +++++++
public/app/views/welcome.php | 11 ++
10 files changed, 610 insertions(+), 28 deletions(-)
create mode 100644 public/app/views/admin/edit_page.php
create mode 100644 public/app/views/admin/pages.php
create mode 100644 public/app/views/components/footer.php
create mode 100644 public/app/views/templates/page.php
(limited to 'public/app/views')
diff --git a/public/app/views/admin/admin-menu.php b/public/app/views/admin/admin-menu.php
index b783b39..52e8522 100644
--- a/public/app/views/admin/admin-menu.php
+++ b/public/app/views/admin/admin-menu.php
@@ -21,7 +21,7 @@ $admin_options = [
'edit_lesson' => 'Νέο Μάθημα',
'lessons' => 'Μαθήματα',
'categories' => 'Κεφάλαια',
- // 'pages' => 'Σελίδες',
+ 'pages' => 'Σελίδες',
'files' => 'Αρχεία',
'privileges' => 'Πρόσβαση',
'users' => 'Χρήστες'
diff --git a/public/app/views/admin/edit_page.php b/public/app/views/admin/edit_page.php
new file mode 100644
index 0000000..46c47bc
--- /dev/null
+++ b/public/app/views/admin/edit_page.php
@@ -0,0 +1,139 @@
+
+
+
+
+
=$action_title?>
+
+
+ Προεπισκόπηση
+
+
+
+
+
+
+
+
+
+
+
diff --git a/public/app/views/admin/pages.php b/public/app/views/admin/pages.php
new file mode 100644
index 0000000..dd8f954
--- /dev/null
+++ b/public/app/views/admin/pages.php
@@ -0,0 +1,109 @@
+
+
+
Διαχείριση Μαθημάτων
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/public/app/views/components/footer.php b/public/app/views/components/footer.php
new file mode 100644
index 0000000..7cd4a5a
--- /dev/null
+++ b/public/app/views/components/footer.php
@@ -0,0 +1,240 @@
+#footer>row`
+ *
+ *
+ * Each sub-structure has 2-5 properties:
+ *
+ * @var title (string) : title of the sub-section
+ * @var entity (string) : type of entity (ex: page/lesson/etc; TODO: method of CMS_model?)
+ * @var list (array) : list of entity id(s)
+ * @var template (string) : template that is used to draw the listed pages' info
+ * @var width (string) : class that relates to sub-structure's width
+ *
+ * NOTE:
+ * designer parsing and rendering can be a quite expensive proccess
+ * thus it is strongly recommented to use cached entities
+ *
+ *
+ * Example structure:
+ {
+ "class" : "row", # container class
+ "struct" : [
+ { # block 1
+ "title" : "",
+ "entity" : "page",
+ "list" : [2, 1, 3], # pages to be listed
+ "template" : "list", # list page titles with link to the pages
+ "width" : "col-md-4"
+ },
+ {
+ "template" : "null", # list nothing
+ "width" : "col-md-3"
+ },
+ {
+ "entity" : "page",
+ "list" : [4], # list content of page 4;
+ "template" : "content", # set title to page-title
+ "width" : "col-md-5"
+ }
+
+ TODO: (wish)
+ ,{
+ "template": "struct",
+ "struct" : [
+ {
+ title, entity, list, template, width
+ },
+ ...
+ ]
+ }
+ ]
+ }
+ *
+ * brainstormin: (TODO:)
+ * use some document-describe stucture like the one on the pdfmake js-library
+ * -----------------------------------------------------------------------------
+ */
+
+
+/** check imported variables / data
+ * -----------------------------------------------------------------------------
+ */
+if (!isset($designer)) {
+
+ // default designer (and first case-study)
+ $designer = '{
+ "class" : "row",
+ "struct" : [
+ {
+ "title" : "Πληροφορίες",
+ "entity" : "page",
+ "list" : [2, 1, 3, 4],
+ "template" : "list",
+ "width" : "col-md-4 no-list-mark"
+ },
+ {
+ "entity" : "page",
+ "list" : [6],
+ "template" : "content",
+ "width" : "col-md-3 no-list-mark"
+ },
+ {
+ "entity" : "page",
+ "list" : [5],
+ "template" : "content",
+ "width" : "col-md-5 no-list-mark"
+ }
+ ]
+ }';
+}
+
+// $entity list shall be passed
+// entity link url shall be passed
+
+
+/** templating functions
+ * -----------------------------------------------------------------------------
+ */
+
+/** List template
+ * --- -- -- - - -
+ *
+ * lists entity titles with links
+ * in a `ul>li` html-structure
+ *
+ * @param $title
+ * @param $list
+ * @param $container
+ */
+function list_template($title, $list, $container, $entity) {
+
+ $result = '
+
'. $title .'
+
';
+
+ foreach($list as $id) {
+
+ if ($entity[$id]['status'] == 1) { // if entity is published
+ $result .= '
+
+
+ ' . $entity[$id]['title'] .'
+
+ ';
+ }
+
+ }
+ return $result . ' ';
+}
+
+/** content_template
+ *
+ * lists whole title and content of entity
+ *
+ * @param $list
+ * @param $container
+ */
+function content_template($list, $container, $entity) {
+
+ $parsedown = new Parsedown();
+
+ $result = '';
+}
+
+
+/** ready to start the proccessing
+ * -----------------------------------------------------------------------------
+ */
+
+// decode ...
+$parse = json_decode($designer);
+
+/** then start parse-proccessing ...
+ * -----------------------------------------------------------------------------
+ */
+?>
+
+
+
+
+
+ struct as $section ) {
+
+ switch ($section->template) {
+
+ case 'list':
+ echo list_template(
+ $section->title,
+ $section->list,
+ $section->width,
+ $entity
+ );
+ break;
+
+ case 'content':
+ echo content_template(
+ $section->list,
+ $section->width,
+ $entity
+ );
+ break;
+
+ default: // ex. 'null'
+
+ echo '
+
'. $section->title.'
+ ';
+ }
+
+ }
+ ?>
+
+
+
+
diff --git a/public/app/views/components/lessons_list.php b/public/app/views/components/lessons_list.php
index 46c1f7e..a778d59 100644
--- a/public/app/views/components/lessons_list.php
+++ b/public/app/views/components/lessons_list.php
@@ -16,40 +16,39 @@
* -----------------------------------------------------------------------------
*/
?>
-
-
-
-
+
-
- =$post['date']?>
-
+
+
-
+
+ =$post['date']?>
+
-
+
-
-
(επίπεδο πρόσβασης =$post['privilege_id']?>)
-
+
-
-
=$post['course_id']?>
-
+
+
(επίπεδο πρόσβασης =$post['privilege_id']?>)
+
-
-
=$post['intro']?>
-
+
+
=$post['course_id']?>
+
+
+
+
=$post['intro']?>
+
-
+
-
-
+
+
-
+
-
\ No newline at end of file
diff --git a/public/app/views/error/general.php b/public/app/views/error/general.php
index 0a27e56..6ed984b 100644
--- a/public/app/views/error/general.php
+++ b/public/app/views/error/general.php
@@ -55,8 +55,7 @@
= isset($title) ? $title : PAGE_404_TITLE ?>
- Oops!
- —
+
= $message ?? "" ?>
diff --git a/public/app/views/templates/course.php b/public/app/views/templates/course.php
index 39e177f..1d212b8 100644
--- a/public/app/views/templates/course.php
+++ b/public/app/views/templates/course.php
@@ -76,6 +76,17 @@
+
+
+
+ $entity ]);
+ ?>
+
+
+
+
+
+ 0,
+ 'label' => '',
+ 'parents' => []
+ ]);
+ ?>
+
+
+
+
+
+
+
+
+
+ =$page['title']?>
+
+
+
+
+ text($page['body']);
+
+ ?>
+
+
+
+
+
+
+
+
+
+
+ $entity ]);
+ ?>
+
+
+
+
+
+
+
diff --git a/public/app/views/templates/lesson.php b/public/app/views/templates/lesson.php
index 3baafd0..0867cd3 100644
--- a/public/app/views/templates/lesson.php
+++ b/public/app/views/templates/lesson.php
@@ -65,6 +65,16 @@
+
+
+
+ $entity ]);
+ ?>
+
+
+
diff --git a/public/app/views/templates/page.php b/public/app/views/templates/page.php
new file mode 100644
index 0000000..6afe45e
--- /dev/null
+++ b/public/app/views/templates/page.php
@@ -0,0 +1,64 @@
+
+
+