Dashboard.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. use Template\RenderableTemplate as RenderableTemplate;
  3. class Dashboard extends RenderableTemplate {
  4. public $content;
  5. public function render() {
  6. global $DROPDOWN, $SIDEBAR;
  7. if (is_ajax_request()) {
  8. if(is_file($this->getView()['location'])){
  9. $this->content = file_get_contents($this->getView()['location']);
  10. $this->implate();
  11. }else{
  12. $this->content = '';
  13. $this->implate();
  14. }
  15. return;
  16. }
  17. //global $DROPDOWN, $SIDEBAR;
  18. $head = '';
  19. $head .= '<script src="/plugins/jquery/jquery.min.js"></script>';
  20. $head .= '<script src="/plugins/mousetrap/mousetrap.min.js"></script>';
  21. $head .= '<script src="/plugins/jquery-mask-plugin/jquery.mask.min.js"></script>';
  22. $head .= '<link href="/plugins/bootstrap/bootstrap.min.css" rel="stylesheet" />';
  23. $head .= '<script src="/plugins/bootstrap/bootstrap.bundle.min.js"></script>';
  24. $head .= '<link href="/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" />';
  25. $head .= '<link href="/plugins/normalize-css/normalize.css" rel="stylesheet">';
  26. $head .= '<link href="/dist/style.css" rel="stylesheet">';
  27. $head .= '<link href="/dist/themes/black_and_white.css" rel="stylesheet">';
  28. $head .= '<link href="/plugins/metisMenu/metisMenu.min.css" rel="stylesheet">';
  29. $head .= '<script src="/plugins/metisMenu/metisMenu.min.js"></script>';
  30. $head .= '<link rel="stylesheet" href="/plugins/datatables/dataTables.css">';
  31. $head .= '<script src="/plugins/datatables/dataTables.js"></script>';
  32. $foot = '';
  33. $foot .= '<script src="/dist/script.js"></script>';
  34. $this->content = file_get_contents(__DIR__ . '/template.html');
  35. $this->content = str_replace("{{usermenu}}", "", $this->content);
  36. $this->content = str_replace("{{elements}}", $SIDEBAR->render(), $this->content);
  37. $header = '';
  38. //HACK
  39. foreach ($DROPDOWN as $item){
  40. $header .= "<a class='dropdown-item' href='".$item['route']."'>".$item['name']."</a>";
  41. }
  42. $this->content = str_replace("{{dropdown}}", $header, $this->content);
  43. $this->content = str_replace("{{head}}", $head, $this->content);
  44. if(isset($this->getView()['location']) && is_file($this->getView()['location'])){
  45. $this->content = str_replace('{{>content}}', $this->replaceSections(file_get_contents($this->getView()['location']), $this->_view['values']), $this->content);
  46. }else{
  47. $this->content = str_replace('{{>content}}', '', $this->content);
  48. }
  49. $this->content = str_replace("{{footer}}", $foot, $this->content);
  50. $this->implate();
  51. }
  52. }