|
- <?php
-
- namespace Modules;
-
- class ContentType {
-
- protected $href;
- protected $config;
- public $keys=array();
- public $values=array();
- protected $layout;
- protected $layouts = array(
- 'default' => 'view_default'
- );
- public $id = "";
-
- function __construct($keys,$config) {
- $f3 = \Base::instance();
- $available_layouts = array_keys($this->layouts);
- $this->layout = $available_layouts[0];
- $this->config = $config;
-
- $this->href= $f3->get('SITE_URL').str_replace($f3->get('CONTENT'),"",$this->config['path']);
-
- foreach ($this->keys as $k=>$v) {
- if (array_key_exists($k, $keys)) {
- $this->values[$v] = $keys[$k];
- } else {
- $this->values[$v] = '';
- }
- }
-
- $ke = explode("/",$this->config['path']);
- array_pop($ke);
- $id = array_pop($ke);
- $this->id = $id;
- }
-
- function __toString() {
- return $this->{$this->layouts[$this->layout]}();
- }
-
- function set_layout($new) {
- if(array_key_exists($new,$this->layouts)) {
- $this->layout = $new;
- //echo "changed layout to: ".$new."<br>";
- }
- }
-
- function view_default() {
- return "";
- }
-
- function month_name($n) {
- $f3 = \Base::instance();
- switch (strtolower($f3->get('LANG'))) {
- case 'de':
- $month_names = array('',
- 'Jan',
- 'Feb',
- 'Mrz',
- 'Apr',
- 'Mai',
- 'Jun',
- 'Jul',
- 'Aug',
- 'Sep',
- 'Okt',
- 'Nov',
- 'Dez'
- );
- return $month_names[$n];
- break;
- case 'en':
- $month_names = array('',
- 'Jan',
- 'Feb',
- 'Mar',
- 'Apr',
- 'May',
- 'Jun',
- 'Jul',
- 'Aug',
- 'Sep',
- 'Oct',
- 'Nov',
- 'Dec'
- );
- return $month_names[$n];
- break;
- default:
- return "";
- }
- }
- function week_day_name($n) {
- $f3 = \Base::instance();
- switch (strtolower($f3->get('LANG'))) {
- case 'de':
- $wd_names = array('',
- 'Montag',
- 'Dienstag',
- 'Mittwoch',
- 'Donnerstag',
- 'Freitag',
- 'Samstag',
- 'Sonntag'
- );
- return $wd_names[$n];
- break;
- case 'en':
- $wd_names = array('',
- 'Monday',
- 'Tuesday',
- 'Wednesday',
- 'Thursday',
- 'Friday',
- 'Saturday',
- 'Sunday'
- );
- return $wd_names[$n];
- break;
- default:
- return "";
- }
- }
-
- }
|