summaryrefslogtreecommitdiff
path: root/public/app/views/simple/Render.php
diff options
context:
space:
mode:
authorGeorge Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2023-06-07 02:10:58 +0300
committerGeorge Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2023-06-07 02:10:58 +0300
commitc3574fcb263668189f9592ffc7505b944c49d1a8 (patch)
treec5c38b0f7898ff2ab8e10fd13bcd66c4c227e6f7 /public/app/views/simple/Render.php
parentb6fea434ad2888de8dbc87d25ba0444c991d42d6 (diff)
downloadgyraf1gov-c3574fcb263668189f9592ffc7505b944c49d1a8.tar.gz
gyraf1gov-c3574fcb263668189f9592ffc7505b944c49d1a8.tar.bz2
gyraf1gov-c3574fcb263668189f9592ffc7505b944c49d1a8.zip
self-host all needed libraries; get rid of unused files
Diffstat (limited to 'public/app/views/simple/Render.php')
-rw-r--r--public/app/views/simple/Render.php182
1 files changed, 0 insertions, 182 deletions
diff --git a/public/app/views/simple/Render.php b/public/app/views/simple/Render.php
deleted file mode 100644
index 79a93a0..0000000
--- a/public/app/views/simple/Render.php
+++ /dev/null
@@ -1,182 +0,0 @@
-<?php
-/** Wiki Render Class
- * -----------------------------------------------------------------------------
- *
- * + automates the creation of common html elements used in Wiki
- *
- * + methods are called statically (without object-instantiation)
- *
- * + Render class constructs the Render::all_breadcrumbs() super-array
- *
- * -----------------------------------------------------------------------------
- */
-class Render_example
-{
-
- /** Render::template($data)
- * (as any render function in anom framework)
- *
- * @param $file (string) : filename [with path] of a php/html (acting as template)
- * @param $data : array of variable-name:value pairs (extracted/used into template)
- */
- static function template($file, $data) {
-
- if (file_exists($file)) {
- extract( $data );
- require( $file );
-
- } else {
- echo "<!-- view ". $file ." is missing -->";
- }
-
- }
-
-
- /** all_breadcrumbs
- * -------------------------------------------------------------------------
- *
- * returns an array of all breadcrumbs
- * where array-key of each record is category[id]
- *
- * NOTE:
- * ---
- * Render::all_breadcrumbs returns an indexed super-array;
- * each array item includes a banch of information: [
- * breadcrumb,
- * rec: [ id , title ],
- * parents: [ [id, title] , ... ]
- * childs: [ [id, title] , ... ],
- * level
- * ]
- *
- * Use Cases:
- * ---
- * as a super-array, the output can be used in many cases
- * for example...
- * into <select-option> form elements
- * .. while selecting category for a post
- * .. or editing a category
- * or directry referring to category's parents/childs
- *
- * Arguments:
- * ---
- * @param $tree (array) : category tree (with childs and parents parts)
- * @param $detimiter (string, optional) : string to split breadcrumb's path-nodes
- * @param $exception (int, optional) : id of category to exclude (subcategories shall be excluded too)
- * @param $l (int, not-pass) : depth level of the node; DO NOT SET (takes values automaticaly)
- * @return array of breadcrumbs
- * -------------------------------------------------------------------------
- */
- static public function all_breadcrumbs($tree, $delimiter = " / ", $exception = 0, $l = 0)
- {
- $all = []; // results array
-
- foreach($tree as $node) { // loop through all nodes
-
- if (intval($node['rec']['id']) != $exception) { // if node is not exception
-
- // construct breadcrumb html of node
- // --- -- -- - - -
- $breadcrumb = "";
- foreach($node['parents'] as $par) { // first: join path titles
- $breadcrumb .= $par['title'] . $delimiter;
- }
- $breadcrumb .= $node['rec']['title']; // last: append title
-
- // make a new super record
- // --- -- -- - - -
- $all[$node['rec']['id']] = [ // set record is as key
- 'breadcrumb' => $breadcrumb, // add breadcrump to results
- 'rec' => $node['rec'], // + node info
- 'parents' => $node['parents'], // + parents array
- 'childs' => self::first_level_childs($node), // + direct childs
- 'level' => $l // + level
- ];
-
- // recursively traverse children nodes
- // --- -- -- - - -
- if (isset($node['childs']) && $node['childs'] != []) {
- $child_breadcrumbs = self::all_breadcrumbs(
- $node['childs'],
- $delimiter,
- $exception,
- $l+1
- );
-
- $all = $all + $child_breadcrumbs; // concatenate arrays (keep array-keys)
- }
- }
-
- }
- return $all;
-
- }
-
- /** first_level_childs
- * --- -- -- - - -
- * used by all_breadcrumbs()
- */
- static private function first_level_childs($node)
- {
- $childs = [];
- if ($node['childs'] == []) {
- return [];
- }
- foreach($node['childs'] as $key => $kid) {
- $childs[] = [
- 'id' => $kid['rec']['id'],
- 'title' => $kid['rec']['title']
- ];
- }
- return $childs;
- }
-
-
- /** date_box
- * creates a pretty date box; outputs greek months
- *
- * @param $date (string) in 'Y-m-d H:i:s' format
- * @return html (string) of the date-box
- */
- static public function date_box($date)
- {
- $months_Gr = ['',
- 'Ιαν', 'Φεβ', 'Μαρ', 'Απρ',
- 'Μάι', 'Ιουν', 'Ιουλ', 'Αυγ',
- 'Σεπ', 'Οκτ', 'Νοε', 'Δεκ'
- ];
- $date = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $date);
- $day = $date->format("j");
- $month = $months_Gr[intval($date->format("m"))];
- $year = $date->format("Y");
-
- // print_r([$date, $day, $month, $year]); die();
-
- return "<div class='date'>
- <p class='day'>{$day}</p>
- <p class='month'>{$month}</p>
- <p class='year'>{$year}</p>
- </div>";
- }
-
- /** date_friendly
- * outputs an unformated greek-language date string
- *
- * @param $date (string) in 'Y-m-d H:i:s' format
- */
- static public function date_friendly($date, $display_time = false)
- {
- $months_Gr = ['',
- 'Ιαν', 'Φεβ', 'Μαρ', 'Απρ', 'Μάι', 'Ιουν',
- 'Ιουλ', 'Αυγ', 'Σεπ', 'Οκτ', 'Νοε', 'Δεκ'
- ];
- $date = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $date);
- $day = $date->format("j");
- $month = $months_Gr[intval($date->format("m"))];
- $year = $date->format("Y");
- $time = ($display_time) ? $date->format("H:i") : '';
-
- return "{$day} {$month} {$year} {$time}";
- }
-
-}