summaryrefslogtreecommitdiff
path: root/public/app/views/components
diff options
context:
space:
mode:
authorGeorge Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2023-05-27 13:06:44 +0300
committerGeorge Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2023-05-27 13:06:44 +0300
commitd1338cbb59d0752155f17d94b0b9b073df95183f (patch)
tree75b7fe87a47ee6961dc38263582117bb920fa1d4 /public/app/views/components
parent38cc5c0c3abed6cfe4fbe0cbabec60a8ed64784d (diff)
downloadgyraf1gov-d1338cbb59d0752155f17d94b0b9b073df95183f.tar.gz
gyraf1gov-d1338cbb59d0752155f17d94b0b9b073df95183f.tar.bz2
gyraf1gov-d1338cbb59d0752155f17d94b0b9b073df95183f.zip
content model; add petition to database
Diffstat (limited to 'public/app/views/components')
-rw-r--r--public/app/views/components/breadcrumbs.php30
-rw-r--r--public/app/views/components/courses_menu.php97
-rw-r--r--public/app/views/components/footer.php240
-rw-r--r--public/app/views/components/info.php28
-rw-r--r--public/app/views/components/lessons_list.php54
-rw-r--r--public/app/views/components/menu.php28
-rw-r--r--public/app/views/components/subcategories.php19
-rw-r--r--public/app/views/components/top_bar.php40
-rw-r--r--public/app/views/components/user-management.php65
9 files changed, 49 insertions, 552 deletions
diff --git a/public/app/views/components/breadcrumbs.php b/public/app/views/components/breadcrumbs.php
deleted file mode 100644
index 59c0fca..0000000
--- a/public/app/views/components/breadcrumbs.php
+++ /dev/null
@@ -1,30 +0,0 @@
-<?php
-/** breadcrumbs
- * -----------------------------------------------------------------------------
- *
- * imported variables
- * ---
- * @param $id : category_id of last level
- * @param $label : category title of last level
- * @param $parents : array of parent nodes
- * -----------------------------------------------------------------------------
- */
-
-?>
-<div class="breadcrumb">
- <!-- home -->
- <a href="/">Classroom</a>
-
- <!-- parent nodes -->
- <?php if ($id != 0) : ?>
- <?php foreach($parents as $node) : ?>
- <i class="fas fa-angle-right"></i> <a href="/course/<?=$node['id']?>"><?=$node['label']?></a>
- <?php endforeach; ?>
- <?php endif; ?>
-
- <!-- last (current) node -->
- <?php if ($id != 0) : ?>
- <i class="fas fa-angle-right"></i> <a href="/course/<?=$id?>"><?=$label?></a>
- <?php endif; ?>
-
-</div> \ No newline at end of file
diff --git a/public/app/views/components/courses_menu.php b/public/app/views/components/courses_menu.php
deleted file mode 100644
index 6539f8c..0000000
--- a/public/app/views/components/courses_menu.php
+++ /dev/null
@@ -1,97 +0,0 @@
-<?php
-/** Categories Menu
- * -----------------------------------------------------------------------------
- * sits in the (left) sidebar
- *
- * imported variables
- * ---
- * @param $categories (array) : the categories tree
- * @param $open_path (array) : 'id's array of selected categories
- *
- * example call:
- * (draw the categories-menu and set open the categories with ids 1 and 2)
- * ---
- * Render::template("section/categories_menu.php",[
- * 'categories' => $category_tree,
- * 'open_path' => [1 ,2]
- * ]);
- *
- * -----------------------------------------------------------------------------
- */
-
-/** tree_ul
- * creates (recursively) a nested ul-li tree of categories
- * --- -- -- - - -
- * @param $tree (array) : categories array formated as tree
- * @param $open_nodes (array) : array of categor ids that shall be marked open/selected
- * @return $html (string)
- */
-function tree_li($tree, $open_nodes = [], $l = 0)
-{
- $html = "";
-
- foreach($tree as $node) {
-
- // if has childs ...
- // write li ; traverse children recursively
- if ((isset($node['childs'])) && ( $node['childs']!= [])) {
-
- if (in_array(intval($node['rec']['id']), $open_nodes)) {
- $inner_class = "inner show";
- $sign = "–";
- $a_class = "has-childs selected";
-
- } else {
- $inner_class = "inner";
- $sign = "+";
- $a_class = "has-childs";
- }
-
- $html .= "<li>
- <a href='/course/{$node['rec']['id']}' class='{$a_class}'>
- <span class='label'>{$node['rec']['label']}</span>
- <span class='toggler'>{$sign}</span>
- </a>
- <ul class='{$inner_class}'>"
- . tree_li($node['childs'], $open_nodes, $l+1)
- ."</ul>
- </li>";
-
-
- } else { // else just write the li
-
- if (in_array(intval($node['rec']['id']), $open_nodes)) {
- $u_in = "<u>";
- $u_out = "</u>";
- $a_class = "selected";
-
- } else {
- $u_in = "";
- $u_out = "";
- $a_class = "";
-
- }
-
- $html .= "<li>
- <a href='/course/{$node['rec']['id']}' class='{$a_class}'>
- <span class='label'>{$node['rec']['label']}</span>
- </a>
- </li>";
- }
- }
-
- return $html;
-
-}
-
-
-// draw the menu (hidden on XS screens)
-// -----------------------------------------------------------------------------
-echo "<h3>Διαθέσιμη ύλη</h3>";
-echo "<ul class='hidden-xs side-bar'>". tree_li($categories, $open_path) ."</ul>";
-
-
-
-// TODO:
-// draw menu for XS screens (for example, just the 1st-level categories)
-// (maybe in an accordion so it won;t take too much area on small screens)
diff --git a/public/app/views/components/footer.php b/public/app/views/components/footer.php
deleted file mode 100644
index 7cd4a5a..0000000
--- a/public/app/views/components/footer.php
+++ /dev/null
@@ -1,240 +0,0 @@
-<?php
-
-use app\extends\Cache_service;
-
-
-/** DESIGNERS
- * -----------------------------------------------------------------------------
- *
- * structures that combine several design information
- * in a json structrure and parses inta a quite complicated view;
- *
- * co-operate with pages
- *
- * can be used to rended menus, sections like header or footer etc;
- *
- * TODO:
- * + embed it as a core \Render method
- * + dynamic designers
- * + recursive designers
- *
- * Here we implement a simplified version of the consept
- * where entities shall always be `pages`
- *
- *
- * PARAMETRES
- * --- -- -- - - -
- *
- * primary properties of designer structure are 2 properties
- *
- * @var class (string): container class name
- * @var struct (json array): representatoion of the "to-be-designed" structure
- *
- * TODO: support more complx `class` strings ex. `.container>#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 = '<div class="'. $container .'">
- <h4>'. $title .'</h4>
- <ul>';
-
- foreach($list as $id) {
-
- if ($entity[$id]['status'] == 1) { // if entity is published
- $result .= '
- <li>
- <a href="/page/'. $id . '">
- ' . $entity[$id]['title'] .'
- </a>
- </li>';
- }
-
- }
- return $result . '</ul></div>';
-}
-
-/** content_template
- *
- * lists whole title and content of entity
- *
- * @param $list
- * @param $container
- */
-function content_template($list, $container, $entity) {
-
- $parsedown = new Parsedown();
-
- $result = '<div class="'. $container .'"><ul>';
-
- foreach($list as $id) {
-
- if ($entity[$id]['status'] == 1) { // if entity is published
-
- $result .= '
- <li>
- <h4>'. $entity[$id]['title'] .'</h4>
- <div>'. $parsedown->text($entity[$id]['body']) .'</div>
- </li>';
- }
-
- }
- return $result .'</ul></div>';
-}
-
-
-/** ready to start the proccessing
- * -----------------------------------------------------------------------------
- */
-
-// decode ...
-$parse = json_decode($designer);
-
-/** then start parse-proccessing ...
- * -----------------------------------------------------------------------------
- */
-?>
-
-
-
-<div class="<?=$parse->class?>">
-
- <?php
- foreach( $parse->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 '<div class="'. $section->width .'">
- <h4>'. $section->title.'</h4>
- </div>';
- }
-
- }
- ?>
-
-</div>
-
-
diff --git a/public/app/views/components/info.php b/public/app/views/components/info.php
new file mode 100644
index 0000000..02c13e9
--- /dev/null
+++ b/public/app/views/components/info.php
@@ -0,0 +1,28 @@
+<?php
+/** Menu of words (for logged-in user)
+ * -----------------------------------------------------------------------------
+ *
+ * imported:
+ * @var stdClass $user (mandatory)
+ * @var boolen $is_admin (mandatory)
+ */
+?>
+<div class="info">
+ <p>&nbsp;</p>
+ <p>
+ <b><?=$user->first_name?> <?=$user->last_name?></b>
+ <?php if ($is_admin) : ?>
+ (Administrator)
+ <?php endif; ?>
+ </p>
+
+ <p><b><?=$user->position?></b></p>
+ <p><b><?=$user->sector?></b></p>
+
+ <p>AM: <b><?=$user->registration_number?></b></p>
+
+ <p>Email: <b><?=$user->email?></b></p>
+ <p>Tηλέφωνο: <b><?=$user->phone?></b></p>
+
+</div>
+
diff --git a/public/app/views/components/lessons_list.php b/public/app/views/components/lessons_list.php
deleted file mode 100644
index a778d59..0000000
--- a/public/app/views/components/lessons_list.php
+++ /dev/null
@@ -1,54 +0,0 @@
-<?php
-/** lessons list
- * -----------------------------------------------------------------------------
- *
- * imported variables:
- * ---
- * @param $lessons : array of lessons
- * @param $fieldset : array of optional fields to show [category, intro, date]
- *
- * example call:
- * ---
- * Render::template("sections/articles_list.php",[
- * 'articles' => $category_tree,
- * 'fieldset' => ['date', 'intro']
- * ])
- * -----------------------------------------------------------------------------
- */
-?>
-
-
-<?php foreach($lessons as $post) : ?>
-
- <!-- <div class="col-xl-4 col-lg-6"> -->
- <div class="post-card">
-
- <?php if (in_array('date', $fieldset)) : ?>
- <?=$post['date']?>
- <?php endif; ?>
-
- <div class="post-card--content">
-
- <h3>
- <a href="/lesson/<?=$post['id']?>"><?=$post['title']?></a>
- </h3>
-
- <?php if (in_array('level', $fieldset)) : ?>
- <p class="getegory">(επίπεδο πρόσβασης <?=$post['privilege_id']?>)</p>
- <?php endif; ?>
-
- <?php if (in_array('category', $fieldset)) : ?>
- <p class="category"><?=$post['course_id']?></p>
- <?php endif; ?>
-
- <?php if (in_array('intro', $fieldset) && $post['intro']) : ?>
- <p class="intro"><?=$post['intro']?></p>
- <?php endif; ?>
-
- </div>
-
- </div>
- <!-- </div> -->
-
-<?php endforeach; ?>
-
diff --git a/public/app/views/components/menu.php b/public/app/views/components/menu.php
index 60ad395..524547c 100644
--- a/public/app/views/components/menu.php
+++ b/public/app/views/components/menu.php
@@ -1,17 +1,31 @@
+<?php
+/** Menu of words (for logged-in user)
+ * -----------------------------------------------------------------------------
+ *
+ * imported:
+ * @var boolen $is_admin (mandatory)
+ */
+?>
<ul class="list-group">
<li class="list-group-item"><a href="/petition/application">Νέα Αίτηση</a></li>
<li class="list-group-item"><a href="/petition/penalty">Νέo Πρακτικό Πειθαρχικής Υπόθεσης</a></li>
- <li class="list-group-item separator">Αρχείο</li>
- <li class="list-group-item"><a href="/account/petitions">Πρακτικά και οι αιτήσεις</a></li>
+
+ <li class="list-group-item separator">To αρχείο σας</li>
+ <li class="list-group-item"><a href="/user/petitions">Πρακτικά και αιτήσεις</a></li>
+
<li class="list-group-item separator">Προφίλ</li>
- <li class="list-group-item"><a href="/account/update">Ενημέρωση των στοιχείων σας</a></li>
- <li class="list-group-item"><a href="/account/new-password">Αλλαγή password</a></li>
+ <li class="list-group-item"><a href="/user/update">Ενημέρωση στοιχείων</a></li>
+ <li class="list-group-item"><a href="/user/new-password">Αλλαγή password</a></li>
+
+ <?php if ($is_admin) : ?>
<li class="list-group-item separator">Διαχείριση</li>
- <li class="list-group-item"><a href="/account/update">Κατάσταση πρακτικών & αιτήσεων</a></li>
- <li class="list-group-item"><a href="/account/update">Αποστολή προσκλήσεων</a></li>
+ <li class="list-group-item"><a href="/admin/petitions">Κατάσταση πρακτικών & αιτήσεων</a></li>
+ <li class="list-group-item"><a href="/admin/invite">Αποστολή προσκλήσεων</a></li>
+ <?php endif; ?>
+
<li class="list-group-item separator"></li>
+
<li class="list-group-item"><a href="/logout">Αποσύνδεση</a></li>
</ul>
-
diff --git a/public/app/views/components/subcategories.php b/public/app/views/components/subcategories.php
deleted file mode 100644
index 5c05a94..0000000
--- a/public/app/views/components/subcategories.php
+++ /dev/null
@@ -1,19 +0,0 @@
-<!-- Sub-Categories -->
-
-<?php if ($breadcrumbs[ $id ]['childs'] != []) : ?>
-
- <h5>Υποκεφάλαια</h5>
-
- <div class="category-childs">
-
- <?php foreach($breadcrumbs[ $id ]['childs'] as $key => $child) : ?>
-
- <a href="/course/<?=$child['id']?>" class="btn btn-light">
- <?=$child['label']?>
- </a>
-
- <?php endforeach; ?>
-
- </div>
-
-<?php endif; ?> \ No newline at end of file
diff --git a/public/app/views/components/top_bar.php b/public/app/views/components/top_bar.php
deleted file mode 100644
index eaffe76..0000000
--- a/public/app/views/components/top_bar.php
+++ /dev/null
@@ -1,40 +0,0 @@
-<?php
-/** top bar
- * -----------------------------------------------------------------------------
- *
- * rendrers breadcrumbs and user menu
- *
- * imported variables
- * ---
- * @param $id : category_id of last level
- * @param $label : category title of last level
- * @param $parents : array of parent nodes
- * -----------------------------------------------------------------------------
- */
-
-// initialize variables needed if not passed
-// (needed while requiring breadcrumbs)
-if (!isset($id)) {
- $id = 0;
- $label = "";
- $parents = [];
-}
-
-?>
-<div class="top-bar">
-
- <?php // breadcrumbs
- ////////////////////////////////////////////////////////////////////////
- Render::view("components/breadcrumbs", [
- 'id' => $id,
- 'label' => $label,
- 'parents' => $parents
- ]);
- ?>
-
- <?php // User management drop-down
- ////////////////////////////////////////////////////////////////////////
- Render::view('components/user-management');
- ?>
-
-</div><!-- /top-bar --> \ No newline at end of file
diff --git a/public/app/views/components/user-management.php b/public/app/views/components/user-management.php
deleted file mode 100644
index 636f2ff..0000000
--- a/public/app/views/components/user-management.php
+++ /dev/null
@@ -1,65 +0,0 @@
-<div class="user">
-
- <div class="dropdown js-visitor">
- <button type="button" class="btn btn-default dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
- <i class="fa fa-regular fa-user"></i>
- Διαχείριση Λογαριασμού
- <span class="caret"></span>
- </button>
- <ul class="dropdown-menu">
- <li><a class="dropdown-item" href="/login">Είσοδος</a></li>
-
- <li><hr class="dropdown-divider"></li>
-
- <li><a class="dropdown-item" href="/registration">Εγγραφή</a></li>
- <li><a class="dropdown-item disabled" href="/reset-password">Επαναφορά password</a></li>
- </ul>
- </div>
-
- <div class="dropdown js-subscriber">
- <button type="button" class="btn btn-default dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
- <i class="fa fa-regular fa-user"></i>
- Διαχείριση Λογαριασμού <span class="caret"></span>
- </button>
- <ul class="dropdown-menu">
- <li><a class="dropdown-item" href="/account/profile">Διαχείριση Προφίλ</a></li>
- <li><a class="dropdown-item" href="/account/courses">Ύλη μαθημάτων</a></li>
- <li><a class="dropdown-item" href="/account/payments">Πληρωμές</a></li>
-
- <li><hr class="dropdown-divider"></li>
-
- <li><a class="dropdown-item" href="/logout">Έξοδος</a></li>
- </ul>
- </div>
-
-</div>
-
-
-<script>
- // if user is connected hide anonymous user menu and show connected user's content
- if (cookieExists('cluser') && (readCookie('cluser').includes('connected'))) {
- [].forEach.call(document.querySelectorAll('.js-visitor'), function (el) {
- el.style.display = 'none';
- });
- [].forEach.call(document.querySelectorAll('.js-subscriber'), function (el) {
- el.style.display = 'unset';
- });
-
- // also extract user's full name to personalize messages
- let connection = unescape(readCookie('cluser')).split(';');
- connection.shift(); // remove 1st item (="connection")
- let name = connection.join(' '); console.log(name);
- var node = document.querySelectorAll('.js-subscriber button')[0];
- node.innerHTML = `<i class="fa fa-regular fa-user"></i> ${name} <span class="caret"></span>`;
-
-
- } else { // else ... do the opposite
- [].forEach.call(document.querySelectorAll('.js-subscriber'), function (el) {
- el.style.display = 'none';
- });
- [].forEach.call(document.querySelectorAll('.js-visitor'), function (el) {
- el.style.display = 'unset';
- });
- }
-
-</script>