From c2c5dd739f9271062d04e7c7aacf8b368c55650a Mon Sep 17 00:00:00 2001 From: Joey Schulze Date: Mon, 14 Dec 2015 21:10:47 +0000 Subject: [PATCH] Add first classes --- class/storage.class.php | 10 +++++ class/teachings.class.php | 77 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 class/storage.class.php create mode 100644 class/teachings.class.php diff --git a/class/storage.class.php b/class/storage.class.php new file mode 100644 index 0000000..1bdc8e4 --- /dev/null +++ b/class/storage.class.php @@ -0,0 +1,10 @@ + $v) + $this->$k = $v; + } +} diff --git a/class/teachings.class.php b/class/teachings.class.php new file mode 100644 index 0000000..faa9372 --- /dev/null +++ b/class/teachings.class.php @@ -0,0 +1,77 @@ +/teachings.txt'); + +class Teachings { + private static $instance = false; + private $list = array(); + + public static function instance() + { + if (self::$instance === false) + self::$instance = new Teachings(TEACHINGS); + + return self::$instance; + } + + private function __construct($path) + { + $this->import($path); + } + + private function import($path) + { + if (($f = fopen($path, 'r')) === false) return; + + while ($line = fgets($f)) { + $a = explode('|', chop($line)); + $this->list[] = new Storage(array('start' => $a[0], + 'end' => $a[1], + 'location' => $a[2], + 'title' => $a[3], + 'url' => $a[4])); + } + + fclose($f); + } + + public function getCurrent() + { + } + + public function getList() + { + $html = ''; + foreach ($this->list as $row) { + if ($row->location != 'Linuxhotel') continue; + + $dstart = explode('-', $row->start); + $dend = explode('-', $row->end); + + if ($dstart[1] == $dend[1]) + $date = sprintf('%d.-%d.%d.%d', $dstart[2], $dend[2], $dstart[1], $dstart[0]); + else + $date = sprintf('%d.%d.-%d.%d.%d', $dstart[2], $dstart[1], $dend[2], $dstart[1], $dstart[0]); + + $link = strlen($row->url) ? sprintf('Details / Buchen', $row->url) : ''; + $html .= sprintf('%s%s%s', + $date, + $row->title, + $link); + } + + if (strlen($html)) { + $html = '' + . '' + . '' + . '' + . '' + . '' + . '' + . $html + . '
DatumBeschreibungLink
'; + } + return $html; + } +} + -- 2.20.1