/system/classes/sys.php

https://gitlab.com/srueegger/Social-Meal · PHP · 216 lines · 111 code · 17 blank · 88 comment · 7 complexity · 432aa9fb3bb5feeec6a2faff099d1e3a MD5 · raw file

  1. <?PHP
  2. /*
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation; either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program; if not, write to the Free Software
  15. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  16. * MA 02110-1301, USA.
  17. *
  18. */
  19. class sys{
  20. static function includeContent(){
  21. Page::Current()->getContent();
  22. }
  23. static function includeHeader(){
  24. echo "<title>".htmlentities(Page::Current()->title).Settings::getValue("title_extention")."</title>";
  25. if(Cache::contains("htmlmeta", Page::Current()->id)){
  26. echo Cache::getData ("htmlmeta", Page::Current()->id);
  27. }
  28. else{
  29. $cache = "";
  30. $rows = DataBase::Current()->ReadRows("SELECT name, content
  31. FROM {'dbprefix'}meta_global
  32. UNION SELECT name, content
  33. FROM {'dbprefix'}meta_local
  34. WHERE page = '". Page::Current()->id."'");
  35. if($rows){
  36. foreach($rows as $row){
  37. echo "<meta name=\"".htmlentities(utf8_encode($row->name))."\" content=\"".htmlentities(utf8_encode($row->content))."\" />";
  38. $cache .= "<meta name=\"".htmlentities(utf8_encode($row->name))."\" content=\"".htmlentities(utf8_encode($row->content))."\" />";
  39. }
  40. }
  41. Cache::setData("htmlmeta", Page::Current()->id, $cache);
  42. }
  43. echo Page::Current()->getHeader();
  44. EventManager::RaiseEvent("header_included",null);
  45. }
  46. /**
  47. *
  48. * @param string $separator
  49. * @param string $class
  50. * @param string $idpraefix
  51. */
  52. static function displayBreadcrumb($separator,$class,$idpraefix){
  53. Page::Current()->displayBreadcrumb($separator,$class,$idpraefix);
  54. }
  55. /**
  56. *
  57. * @param int $id
  58. * @param string $globalstart
  59. * @param string $globalend
  60. * @param string $elementstart
  61. * @param string $elementend
  62. * @param string $class
  63. */
  64. static function displayMenu($id, $globalstart,$globalend, $elementstart,$elementend,
  65. $class){
  66. Menu::display($id, $globalstart,$globalend, $elementstart,$elementend,$class);
  67. }
  68. /**
  69. *
  70. * @param string $globalstart
  71. * @param string $globalend
  72. * @param string $elementstart
  73. * @param string $elementend
  74. * @param string $class
  75. */
  76. static function displayGlobalMenu($globalstart,$globalend, $elementstart,$elementend,
  77. $class){
  78. Menu::display(Settings::getInstance()->get("mainmenu"),
  79. $globalstart,
  80. $globalend,
  81. $elementstart,
  82. $elementend,
  83. $class);
  84. }
  85. /**
  86. *
  87. * @param string $globalstart
  88. * @param string $globalend
  89. * @param string $elementstart
  90. * @param string $elementend
  91. * @param string $class
  92. */
  93. static function displayLocalMenu($globalstart,$globalend, $elementstart,$elementend,
  94. $class){
  95. if(Page::Current()->menu > -1){
  96. Menu::display(Page::Current()->menu, $globalstart,$globalend, $elementstart,$elementend,$class);
  97. }
  98. }
  99. /**
  100. *
  101. * @param string $area
  102. * @param string $areaType
  103. * @param string $id
  104. * @return string
  105. */
  106. static function getColor($area,$areaType,$id){
  107. return "#".Settings::getInstance()->specify($areaType,$area)->get("skin".$id);
  108. }
  109. /**
  110. *
  111. * @return boolean
  112. */
  113. static function localMenuExists(){
  114. if(Page::Current()->menu){
  115. return true;
  116. }
  117. else{
  118. return false;
  119. }
  120. }
  121. /**
  122. *
  123. * @return string
  124. */
  125. static function getTitle(){
  126. return Settings::getInstance()->get("title");
  127. }
  128. /**
  129. *
  130. * @return string
  131. */
  132. static function getFullSkinPath(){
  133. return Settings::getInstance()->get("host").SkinController::getCurrentSkinPath()."/";
  134. }
  135. /**
  136. *
  137. * @param string $dir
  138. * @return array
  139. */
  140. static function getMenues($dir){
  141. $dir = DataBase::Current()->EscapeString($dir);
  142. return DataBase::Current()->ReadRows("SELECT id, name, (
  143. SELECT COUNT( * )
  144. FROM {'dbprefix'}menu
  145. WHERE menuID = {'dbprefix'}menu_names.id
  146. )count
  147. FROM `{'dbprefix'}menu_names`
  148. WHERE dir = '".$dir."'");
  149. }
  150. /**
  151. *
  152. * @return array
  153. */
  154. public static function getAllMenues(){
  155. return DataBase::Current()->ReadRows("SELECT id, name, (
  156. SELECT COUNT( * )
  157. FROM {'dbprefix'}menu
  158. WHERE menuID = {'dbprefix'}menu_names.id
  159. )count
  160. FROM `{'dbprefix'}menu_names`");
  161. }
  162. /**
  163. *
  164. * @return string
  165. */
  166. static function getFooter(){
  167. return VERSION_TEXT;
  168. }
  169. /**
  170. *
  171. * @return string
  172. */
  173. static function getCurrentUserName(){
  174. return User::Current()->name;
  175. }
  176. public static function parseGetParams(){
  177. $pos = strpos($_SERVER['REQUEST_URI'],'?');
  178. foreach(explode("&", substr($_SERVER['REQUEST_URI'], $pos + 1, strlen($_SERVER['REQUEST_URI']) - 8)) as $param){
  179. $splitter = explode('=', $param);
  180. if(sizeOf($splitter) > 1){
  181. $_GET[$splitter[0]] = urldecode($splitter[1]);
  182. if(strpos($_GET[$splitter[0]], "&#") !== false){
  183. $_GET[$splitter[0]] = urldecode($splitter[1]);
  184. }
  185. }
  186. }
  187. }
  188. /**
  189. *
  190. * @return string
  191. */
  192. public static function getAlias(){
  193. if(!isset($_GET['include'])){
  194. $_GET['include'] = "home";
  195. }
  196. return $_GET['include'];
  197. }
  198. }
  199. ?>