diff options
Diffstat (limited to 'public/app/views')
| -rw-r--r-- | public/app/views/admin/admin-menu.php | 2 | ||||
| -rw-r--r-- | public/app/views/admin/edit_page.php | 139 | ||||
| -rw-r--r-- | public/app/views/admin/pages.php | 109 | ||||
| -rw-r--r-- | public/app/views/components/footer.php | 240 | ||||
| -rw-r--r-- | public/app/views/components/lessons_list.php | 49 | ||||
| -rw-r--r-- | public/app/views/error/general.php | 3 | ||||
| -rw-r--r-- | public/app/views/templates/course.php | 11 | ||||
| -rw-r--r-- | public/app/views/templates/lesson.php | 10 | ||||
| -rw-r--r-- | public/app/views/templates/page.php | 64 | ||||
| -rw-r--r-- | public/app/views/welcome.php | 11 |
10 files changed, 610 insertions, 28 deletions
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 @@ +<?php + // some labels (if editing new or existing record) + // --- -- -- - - - + if ($id == 0) { + $action_title = "Δημιουργία Σελίδας"; + $action_button = "Δημιουργία"; + + } else { + $action_title = "Επεξεργασία Σελίδας"; + $action_button = "Αποθήκευση Αλλαγών"; + } +?> + +<!-- title bar --> +<div class="title-bar"> + <div><h5><?=$action_title?></h5></div> + <div> + <button type="button" class="btn pull-right" + data-bs-toggle="modal" data-bs-target="#editorModal" data-action="preview"> + <i class="fas fa-search"></i> Προεπισκόπηση + </button> + </div> +</div> + +<!-- manage --> +<div class="manage edit-page"> + <form> + <div class="row"> + + + <div class="col col-8"> + + <!-- id (hidden) --> + <input type="hidden" name="id" value="0"><!-- action = (0) ? 'new' : 'edit' --> + + <!-- + <div class="row form-group"> + <input type="date" name="date" value="" readonly=""> + </div> + --> + + <div class="row form-group"> + <label class="control-label col-sm-12" for="title">Τίτλος</label> + <div class="col-sm-12"> + <input class="form-control form-control-sm" type="text" name="title" value="" required=""> + </div> + </div> + + <!-- Post body --> + <div class="row form-group"> + <label class="control-label col-sm-12" for="body">Κείμενο</label> + <div class="col-sm-12"> + <textarea class="form-control form-control-sm" type="text" name="body" value="" required=""></textarea> + </div> + </div> + + </div> + + <div class="col"> + + <div class="row form-group"> + <label class="control-label col-sm-12" for="status">Κατάσταση</label> + <div class="col-sm-12"> + <select class="form-control form-control-sm form-select form-select-sm" name="status" onchange="this.dataset.chosen = this.value;"> + <option value="0">Αδημοσίευτο</option> + <option value="one">ΔΗΜΟΣΙΕΥΜΕΝΟ</option> + </select> + </div> + </div> + + <div class="row form-group"> + <label class="control-label col-sm-12" for="media">Αρχεία</label> + <div class="col-sm-12 post-media"> + + <!-- Button trigger modal --> + <button type="button" class="btn btn-sm btn-success pull-right over-bar" + data-bs-toggle="modal" data-bs-target="#editorModal" data-action="upload_file"> + <i class="fas fa-plus"></i> Προσθήκη + </button> + + <ul id="files_list"> + </ul> + + </div> + </div> + + <?php if ($id != 0) : ?> + <!-- + <div class="row form-group"> + <label class="control-label col-sm-12">Πληροφορίες</label> + <div class="col-sm-12" id="post-info"> + </div> + </div> + --> + <?php endif; ?> + + </div> + + </div> + + <div class="row"> + + <div class="col"> + <hr/> + <!-- close | submit buttons --> + + <div class="form-actions row justify-content-md-center"> + + <div class="col-3"> + <button type="button" id="go-back" class="btn btn-light col-sm-12"> + Επιστροφή + </button> + </div> + + <div class="col-4"> + <button class="btn btn-primary col-sm-12" type="submit"> + <?=$action_button?> + </button> + </div> + + </div> + + </div> + + </form> + + </div> +</div><!-- /manage --> + + +<!-- MODAL for file uploads and preview --> +<div class="modal fade" id="editorModal" aria-labelledby="myModalLabel" aria-hidden="true"> + <div class="modal-dialog modal-lg" role="document"> + <div class="modal-content"> + <!-- content will be dynamic --> + </div> + </div> +</div> + 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 @@ + <!-- title bar --> + <div class="title-bar"> + <div><h5>Διαχείριση Μαθημάτων</h5></div> + <div> + <!-- Button trigger modal --> + <a type="button" class="btn pull-right" href="/admin/edit_page"> + <i class="fas fa-plus"></i> Νέα Σελίδα + </a> + </div> +</div> + +<div class="manage"> + <div class="row"> + <div class="col-md-12"> + + <div id="pages"> + + <table id="dt-pages" class="table table-responsive dt-table" style="width:100%"> + <thead> + <th class="dt-id">α/α</th> + <th class="dt-title">Τίτλος</th> + <th class="dt-actions"></th> + </thead> + </table> + + </div> + + </div> + </div> +</div><!-- /manage --> + + + +<!-- MODAL for new/edit category --> +<!-- NOTE: tabindex="-1" removed, ref:https://github.com/select2/select2-bootstrap-theme/issues/41 --> +<div class="modal fade" id="managePages" aria-labelledby="myModalLabel" aria-hidden="true"> + <div class="modal-dialog modal-lg" role="document"> + <div class="modal-content"> + + <form method="post" action=""> + + <div class="modal-header"> + <h4 class="modal-title" id="myModalLabel">Παράμετροι Μαθήματος</h4> + <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> + </div><!-- /modal-header --> + + <!-- modal-body --> + <div class="modal-body"> + + <!-- form fields --> + + <div class="row form-group"> + <label class="control-label col-sm-12" for="label">Τίτλος</label> + <div class="col-sm-12"> + <input class="form-control form-control-sm" type="text" name="title" value="" required=""> + </div> + </div> + + + <!-- one line / two parts; status: pull right --> + <div class="row"> + <div class="col-md-8"> +  <!-- nothing --> + </div> + <div class="col-md-4"> + + <!-- status: published|unpublished --> + <div class="row form-group"> + <label class="control-label col-sm-12" for="status">Κατάσταση</label> + <div class="col-sm-12"> + <select class="form-control form-control-sm form-select form-select-sm" name="status" onchange="this.dataset.chosen = this.value;"> + <option value="0">Αδημοσίευτο</option> + <option value="one">ΔΗΜΟΣΙΕΥΜΕΝΟ</option> + </select> + </div> + </div> + + + </div> + </div> + + + + + <div class="row form-group"> + <input type="hidden" name="id" value="0"><!-- page-id --> + </div> + + + </div><!-- /modal body --> + + <div class="modal-footer"> + <div class="row" style="width: 50%;"> + <div class="form-actions"> + <div class="col-4"> + <button type="button" class="btn btn-default js-modal-close col-sm-12" data-bs-dismiss="modal">Κλείσιμο</button> + </div> + <div class="col-8"> + <button class="btn btn-success col-sm-12" type="submit">Καταχώριση</button> + </div> + </div> + </div> + </div><!-- /modal-footer --> + + </form><!-- /form --> + + </div> + </div> +</div> 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 @@ +<?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/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 @@ * ----------------------------------------------------------------------------- */ ?> -<div class="row"> - <?php foreach($lessons as $post) : ?> - <!-- <div class="col-xl-4 col-lg-6"> --> - <div class="post-card"> +<?php foreach($lessons as $post) : ?> - <?php if (in_array('date', $fieldset)) : ?> - <?=$post['date']?> - <?php endif; ?> + <!-- <div class="col-xl-4 col-lg-6"> --> + <div class="post-card"> - <div class="post-card--content"> + <?php if (in_array('date', $fieldset)) : ?> + <?=$post['date']?> + <?php endif; ?> - <h3> - <a href="/lesson/<?=$post['id']?>"><?=$post['title']?></a> - </h3> + <div class="post-card--content"> - <?php if (in_array('level', $fieldset)) : ?> - <p class="getegory">(επίπεδο πρόσβασης <?=$post['privilege_id']?>)</p> - <?php endif; ?> + <h3> + <a href="/lesson/<?=$post['id']?>"><?=$post['title']?></a> + </h3> - <?php if (in_array('category', $fieldset)) : ?> - <p class="category"><?=$post['course_id']?></p> - <?php endif; ?> + <?php if (in_array('level', $fieldset)) : ?> + <p class="getegory">(επίπεδο πρόσβασης <?=$post['privilege_id']?>)</p> + <?php endif; ?> - <?php if (in_array('intro', $fieldset) && $post['intro']) : ?> - <p class="intro"><?=$post['intro']?></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> - <!-- </div> --> + </div> + <!-- </div> --> - <?php endforeach; ?> +<?php endforeach; ?> -</div>
\ 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 @@ <div class='container'> <div class='content'> <h3><?= isset($title) ? $title : PAGE_404_TITLE ?></h3> - Oops!<br /> - — + <br /> <br /> <span><?= $message ?? "" ?></span> </div> 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 @@ </div> </div> + <footer> + <div class="container"> + + <?php // render footer + //////////////////////////////////////////////////////////////// + Render::view('components/footer', [ 'entity' => $entity ]); + ?> + + </div> + </footer> + <script src="/assets/js/classroom.js"></script> </body> 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 @@ </div> </div> + <footer> + <div class="container"> + + <?php // render footer + //////////////////////////////////////////////////////////////// + Render::view('components/footer', [ 'entity' => $entity ]); + ?> + + </div> + </footer> <script src="/assets/js/classroom.js"></script> <script src="/assets/js/lesson-features.js"></script> 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 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title><?=SITE_TITLE?> - <?=$page['title']?></title> + + <?php // header includes + //////////////////////////////////////////////////////////////////////// + Render::view('components/header_includes'); + ?> + +</head> +<body class="classroom"> + + <?php // top-bar + //////////////////////////////////////////////////////////////////////// + Render::view('components/top_bar', [ + 'id' => 0, + 'label' => '', + 'parents' => [] + ]); + ?> + + + <div class="main-content container page-container"> + + + <div class="lesson-view"> + + <!-- page Title --> + <h3> + <?=$page['title']?> + </h3> + + <!-- page body --> + <div class="article-body"> + <?php + + $parsedown = new Parsedown(); + echo $parsedown->text($page['body']); + + ?> + </div> + + + </div> + + </div> + + <footer> + <div class="container"> + + <?php // render footer + //////////////////////////////////////////////////////////////// + Render::view('components/footer', [ 'entity' => $entity ]); + ?> + + </div> + </footer> + + <script src="/assets/js/classroom.js"></script> + <script src="/assets/js/lesson-features.js"></script> +</body> +</html> diff --git a/public/app/views/welcome.php b/public/app/views/welcome.php index 08be0a2..c5552a8 100644 --- a/public/app/views/welcome.php +++ b/public/app/views/welcome.php @@ -54,6 +54,17 @@ --- */ ?> + <footer> + <div class="container"> + + <?php // render footer + //////////////////////////////////////////////////////////////// + Render::view('components/footer', [ 'entity' => $entity ]); + ?> + + </div> + </footer> + <script src="/assets/js/classroom.js"></script> </body> |
