mostly filebased Content Presentation System
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

128 lines
3.0KB

  1. <?php
  2. namespace Modules;
  3. class ContentType {
  4. protected $href;
  5. protected $config;
  6. public $keys=array();
  7. public $values=array();
  8. protected $layout;
  9. protected $layouts = array(
  10. 'default' => 'view_default'
  11. );
  12. public $id = "";
  13. function __construct($keys,$config) {
  14. $f3 = \Base::instance();
  15. $available_layouts = array_keys($this->layouts);
  16. $this->layout = $available_layouts[0];
  17. $this->config = $config;
  18. $this->href= $f3->get('SITE_URL').str_replace($f3->get('CONTENT'),"",$this->config['path']);
  19. foreach ($this->keys as $k=>$v) {
  20. if (array_key_exists($k, $keys)) {
  21. $this->values[$v] = $keys[$k];
  22. } else {
  23. $this->values[$v] = '';
  24. }
  25. }
  26. $ke = explode("/",$this->config['path']);
  27. array_pop($ke);
  28. $id = array_pop($ke);
  29. $this->id = $id;
  30. }
  31. function __toString() {
  32. return $this->{$this->layouts[$this->layout]}();
  33. }
  34. function set_layout($new) {
  35. if(array_key_exists($new,$this->layouts)) {
  36. $this->layout = $new;
  37. //echo "changed layout to: ".$new."<br>";
  38. }
  39. }
  40. function view_default() {
  41. return "";
  42. }
  43. function month_name($n) {
  44. $f3 = \Base::instance();
  45. switch (strtolower($f3->get('LANG'))) {
  46. case 'de':
  47. $month_names = array('',
  48. 'Jan',
  49. 'Feb',
  50. 'Mrz',
  51. 'Apr',
  52. 'Mai',
  53. 'Jun',
  54. 'Jul',
  55. 'Aug',
  56. 'Sep',
  57. 'Okt',
  58. 'Nov',
  59. 'Dez'
  60. );
  61. return $month_names[$n];
  62. break;
  63. case 'en':
  64. $month_names = array('',
  65. 'Jan',
  66. 'Feb',
  67. 'Mar',
  68. 'Apr',
  69. 'May',
  70. 'Jun',
  71. 'Jul',
  72. 'Aug',
  73. 'Sep',
  74. 'Oct',
  75. 'Nov',
  76. 'Dec'
  77. );
  78. return $month_names[$n];
  79. break;
  80. default:
  81. return "";
  82. }
  83. }
  84. function week_day_name($n) {
  85. $f3 = \Base::instance();
  86. switch (strtolower($f3->get('LANG'))) {
  87. case 'de':
  88. $wd_names = array('',
  89. 'Montag',
  90. 'Dienstag',
  91. 'Mittwoch',
  92. 'Donnerstag',
  93. 'Freitag',
  94. 'Samstag',
  95. 'Sonntag'
  96. );
  97. return $wd_names[$n];
  98. break;
  99. case 'en':
  100. $wd_names = array('',
  101. 'Monday',
  102. 'Tuesday',
  103. 'Wednesday',
  104. 'Thursday',
  105. 'Friday',
  106. 'Saturday',
  107. 'Sunday'
  108. );
  109. return $wd_names[$n];
  110. break;
  111. default:
  112. return "";
  113. }
  114. }
  115. }