UI.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. class UI {
  3. public static function getTitle() {
  4. $title = 'SE';
  5. $host = $_SERVER['SERVER_NAME'];
  6. if (substr($host, 0, 5) == 'biuro') {
  7. $host = substr($host, 6);
  8. }
  9. $title = "{$host}-SE";
  10. return $title;
  11. }
  12. public static function gora() {
  13. UI::startHtml();
  14. }
  15. public static function startHtml() {
  16. Lib::loadClass('S');
  17. UI::loadTemplate('_layout_gora');
  18. }
  19. public static function dol() {
  20. UI::endHtml();
  21. }
  22. public static function endHtml() {
  23. $version = (file_exists(APP_PATH_ROOT . '/VERSION'))? file_get_contents(APP_PATH_ROOT . '/VERSION') : null;
  24. if ($version) {
  25. echo '<div style="border-top:1px solid #ddd;margin-top:10px;padding:0 30px;font-size:xx-small;color:#888;">version: '.$version.'</div>';
  26. }
  27. echo "\n</body></html>";
  28. }
  29. public static function menu() {
  30. if (!User::logged()) return;
  31. if (User::hasAccess('menu')) {
  32. Lib::loadClass('ProcesMenu');
  33. $procesMenu = ProcesMenu::getInstance();
  34. $procesMenu->show();
  35. if (!V::get('MENU_INIT', '', $_GET)) {
  36. Lib::loadClass('UserActivity');
  37. //echo UserActivity::showListInContainer();
  38. }
  39. }
  40. else {
  41. UI::loadTemplate('menuLevel6');
  42. }
  43. }
  44. public static function loadTemplate($tmplName, $data = array()) {
  45. if (is_array($data) && !empty($data)) {
  46. extract($data);
  47. }
  48. include APP_PATH_LIB . "/tmpl/{$tmplName}.php";
  49. }
  50. public static function hotKeyDBG($str) {
  51. if (User::hasAccess('dbg')) {
  52. echo '<span class="hidden-dbg">' . htmlspecialchars($str) . '</span>';
  53. }
  54. }
  55. public static function showMessagesForTable($tblName) {
  56. if (empty($tblName)) return;
  57. $msgsRoute = Router::getRoute('Msgs');
  58. $msgs = $msgsRoute->getActiveMessagesForTable($tblName);
  59. if (!empty($msgs)) {
  60. self::loadTemplate('msgsForTable', array('msgs' => $msgs));
  61. }
  62. }
  63. public static function alert($alertType, $msg) {
  64. ?>
  65. <div class="alert alert-<?php echo $alertType; ?>">
  66. <?php echo $msg; ?>
  67. </div>
  68. <?php
  69. }
  70. public static function setTitleJsTag($title) {
  71. ?>
  72. <script>
  73. document.title = '<?php echo $title; ?>';
  74. </script>
  75. <?php
  76. }
  77. }