global.func.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <?php
  2. function checkPHPVersion($minimumVersion)
  3. {
  4. return version_compare(PHP_VERSION, $minimumVersion);
  5. }
  6. function exception_handler($exception)
  7. {
  8. echo "<b>Error:</b> ".$exception->getMessage()."<br>";
  9. echo "<pre>".$exception->getTraceAsString()."</pre>";
  10. exit(1);
  11. }
  12. function tr($text, $args=null)
  13. {
  14. global $appTR;
  15. return $appTR->tr($text, $args);
  16. }
  17. ////////////////////////////////////////////////////////////////////////
  18. // LOGGING
  19. ////////////////////////////////////////////////////////////////////////
  20. function if_log_debug($message)
  21. {
  22. error_log($message);
  23. }
  24. // ------------------------------------------ Global template "print" functions.
  25. function GlobalHeader()
  26. {
  27. include_once("pages/global-header.php");
  28. }
  29. function GlobalFooter()
  30. {
  31. include_once("pages/global-footer.php");
  32. }
  33. function ProcessTemplate($file)
  34. {
  35. include_once("pages/".$file);
  36. }
  37. function AppVersion()
  38. {
  39. global $appEngine;
  40. print($appEngine->getAppVersionString());
  41. }
  42. function SessionUsername()
  43. {
  44. if (isset($_SESSION["svnadmin_username"]))
  45. {
  46. print($_SESSION["svnadmin_username"]);
  47. }
  48. }
  49. function ScriptName()
  50. {
  51. print(currentScriptFileName());
  52. }
  53. function PrintApplicationVersion()
  54. {
  55. global $appEngine;
  56. print($appEngine->getAppVersionString());
  57. }
  58. function PrintSessionUsername()
  59. {
  60. if (isset($_SESSION["svnadmin_username"]))
  61. {
  62. print($_SESSION["svnadmin_username"]);
  63. }
  64. }
  65. function PrintCurrentScriptName()
  66. {
  67. print(currentScriptFileName());
  68. }
  69. // -------------------------------------------------- Global template functions.
  70. function AppEngine()
  71. {
  72. global $appEngine;
  73. return $appEngine;
  74. }
  75. function Translate($text, $args=null)
  76. {
  77. global $appTR;
  78. print($appTR->tr($text, $args));
  79. }
  80. function CurrentLocale()
  81. {
  82. if (isset($_COOKIE["locale"]) && !empty($_COOKIE["locale"]))
  83. {
  84. return $_COOKIE["locale"];
  85. }
  86. return "en_US";
  87. }
  88. function SetValue($varName, $varValue)
  89. {
  90. global $appTemplate;
  91. $appTemplate->addReplacement($varName, $varValue);
  92. }
  93. function GetValue($varName)
  94. {
  95. global $appTemplate;
  96. if (isset($appTemplate->m_replacements[$varName]))
  97. {
  98. $v=$appTemplate->m_replacements[$varName];
  99. if (!empty($v))
  100. {
  101. return $v;
  102. }
  103. }
  104. return NULL;
  105. }
  106. function GetArrayValue($varName)
  107. {
  108. $v=NULL;
  109. if (($v=GetValue($varName)) != NULL)
  110. {
  111. if (is_array($v))
  112. {
  113. return $v;
  114. }
  115. else
  116. {
  117. return array($v);
  118. }
  119. }
  120. return array();
  121. }
  122. function GetStringValue($varName)
  123. {
  124. $v=NULL;
  125. if (($v=GetValue($varName)) != NULL)
  126. {
  127. return $v;
  128. }
  129. return "";
  130. }
  131. function GetIntValue($varName, $base=10)
  132. {
  133. $v=NULL;
  134. if (($v=GetValue($varName)) != NULL)
  135. {
  136. if (is_int($v))
  137. {
  138. return $v;
  139. }
  140. else
  141. {
  142. return intval($v, $base);
  143. }
  144. }
  145. return 0;
  146. }
  147. function GetBoolValue($varName)
  148. {
  149. $v=NULL;
  150. if (($v=GetValue($varName)) != NULL)
  151. {
  152. if (is_bool($v))
  153. {
  154. return $v;
  155. }
  156. else
  157. {
  158. return (boolean)$v;
  159. }
  160. }
  161. return false;
  162. }
  163. function PrintStringValue($varName) { print(GetStringValue($varName)); }
  164. function PrintIntValue($varName) { print(GetIntValue($varName)); }
  165. function PrintBoolValue($varName) { print(GetBoolValue($varName)); }
  166. // ---------------------------------------- Global template condition functions.
  167. function IsUserLoggedIn()
  168. {
  169. global $appEngine;
  170. return $appEngine->checkUserAuthentication(false);
  171. }
  172. function IsViewUpdateable()
  173. {
  174. global $appEngine;
  175. return $appEngine->isViewUpdateable();
  176. }
  177. function IsProviderActive($providerTypeId)
  178. {
  179. global $appEngine;
  180. return $appEngine->isProviderActive($providerTypeId);
  181. }
  182. function HasAccess($module, $action)
  183. {
  184. global $appEngine;
  185. return $appEngine->checkUserAccess($module, $action);
  186. }
  187. function HasAppExceptions()
  188. {
  189. global $appEngine;
  190. $a=$appEngine->getExceptions();
  191. if (!empty($a))
  192. {
  193. return true;
  194. }
  195. return false;
  196. }
  197. function HasAppMessages()
  198. {
  199. global $appEngine;
  200. $a=$appEngine->getMessages();
  201. if (!empty($a))
  202. {
  203. return true;
  204. }
  205. return false;
  206. }
  207. // --------------------------------------------------- Complete html components.
  208. /**
  209. * Prints the HTML code for a input box which filter a defined table.
  210. *
  211. * @param string $tableId The HTML-ID of the table.
  212. * @param int $columnIndex The column index of the content in which is to search.
  213. */
  214. function HtmlFilterBox($tableId, $columnIndex=0)
  215. {?>
  216. <div class="datatablesearch">
  217. <?php Translate("Filter"); ?>:
  218. <input type="text" class="filterbox" onkeyup="filterDataTable('<?php print($tableId); ?>', <?php print($columnIndex); ?>,this.value);">
  219. </div>
  220. <?php
  221. }
  222. ?>