api.help.php 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. /**
  3. * Returns help chapter content in current locale
  4. *
  5. * @param $chapter Help chapter name
  6. *
  7. * @return string
  8. */
  9. function web_HelpChapterGet($chapter) {
  10. $lang = curlang();
  11. $chapter = vf($chapter);
  12. $wikiChapterMark = 'wiki]';
  13. $wikiBaseUrl = 'https://wiki.ubilling.net.ua/doku.php?id=';
  14. $result = '';
  15. if (file_exists(DATA_PATH . "help/" . $lang . "/" . $chapter)) {
  16. $result .= file_get_contents(DATA_PATH . "help/" . $lang . "/" . $chapter);
  17. if (ispos($result, $wikiChapterMark)) {
  18. $searchRegex = "#\[wiki\](.*?)\[/wiki\]#is";
  19. $wikiIcon = '<img src="skins/icon_wiki_small.png">';
  20. $replace = '<a href="' . $wikiBaseUrl . '\\1" target="_blank" class="ubButton">' . $wikiIcon . ' ' . __('Wiki article') . '</a>';
  21. $result = preg_replace($searchRegex, $replace, $result);
  22. }
  23. $result = nl2br($result);
  24. }
  25. return ($result);
  26. }
  27. /**
  28. * Shows help icon if context chapter available for current language
  29. *
  30. * @return string
  31. */
  32. function web_HelpIconShow() {
  33. global $ubillingConfig;
  34. $normalMode = ($ubillingConfig->getAlterParam('IM_GREEDY_PIDAR')) ? false : true;
  35. $result = '';
  36. if (cfr('HELP')) {
  37. $lang = curlang();
  38. $currentModuleName = (ubRouting::checkGet('module')) ? ubRouting::get('module') : 'taskbar';
  39. $donationUrl = 'https://ubilling.net.ua/rds/donate/';
  40. if (file_exists(DATA_PATH . "help/" . $lang . "/" . $currentModuleName)) {
  41. $helpChapterContent = web_HelpChapterGet($currentModuleName);
  42. $helpChapterContent .= wf_delimiter(1);
  43. if (cfr('PROCRAST')) {
  44. $helpChapterContent .= wf_Link('?module=procrast', wf_img('skins/gamepad.png', __('Procrastination helper'))) . ' ';
  45. }
  46. if (!$normalMode) {
  47. $helpChapterContent .= wf_Link($donationUrl, wf_img('skins/heart16.png', __('Support project'))) . ' ';
  48. }
  49. $containerStyle = 'style="min-width:400px; max-width:800px; min-height:200px; max-height:500px;"';
  50. $helpChapterContent = wf_AjaxContainer('contexthelpchapter', $containerStyle, $helpChapterContent);
  51. $result .= wf_modalAuto(wf_img_sized("skins/help.gif", __('Context help'), 20), __('Context help'), $helpChapterContent, '');
  52. }
  53. if ($normalMode) {
  54. $result .= ' ' . wf_Link($donationUrl, wf_img_sized('skins/heart32.png', __('Support project'), '20'), false, '', 'target="_blank"') . '';
  55. }
  56. } else {
  57. if (!$normalMode) {
  58. $result .= '<!-- pidar detected -->';
  59. }
  60. }
  61. return ($result);
  62. }
  63. /**
  64. * Returns Ubilling release info
  65. *
  66. * @param bool $raw
  67. *
  68. * @return string
  69. */
  70. function web_ReleaseInfo($raw = false) {
  71. $result = '';
  72. $releaseInfoBaseUrl = 'https://ubilling.net.ua/rds/release/';
  73. @$releaseDataRaw = file_get_contents('RELEASE');
  74. if (!empty($releaseDataRaw)) {
  75. if ($raw) {
  76. $result .= $releaseDataRaw;
  77. } else {
  78. $infoParts = explode(' ', $releaseDataRaw);
  79. if (sizeof($infoParts) >= 3) {
  80. $codenameLink = $releaseInfoBaseUrl . vf($infoParts[0], 3);
  81. $result .= wf_Link($codenameLink, $releaseDataRaw, false, '', 'target="_BLANK"');
  82. }
  83. }
  84. }
  85. return ($result);
  86. }