Help.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <?php
  2. /**
  3. * This file has the important job of taking care of help messages and the help center.
  4. *
  5. * Simple Machines Forum (SMF)
  6. *
  7. * @package SMF
  8. * @author Simple Machines http://www.simplemachines.org
  9. * @copyright 2014 Simple Machines and individual contributors
  10. * @license http://www.simplemachines.org/about/smf/license.php BSD
  11. *
  12. * @version 2.1 Alpha 1
  13. */
  14. if (!defined('SMF'))
  15. die('No direct access...');
  16. /**
  17. * Redirect to the user help ;).
  18. * It loads information needed for the help section.
  19. * It is accessed by ?action=help.
  20. * @uses Help template and Manual language file.
  21. */
  22. function ShowHelp()
  23. {
  24. loadTemplate('Help');
  25. loadLanguage('Manual');
  26. $subActions = array(
  27. 'index' => 'HelpIndex',
  28. 'rules' => 'HelpRules',
  29. );
  30. $sa = isset($_GET['sa'], $subActions[$_GET['sa']]) ? $_GET['sa'] : 'index';
  31. $subActions[$sa]();
  32. }
  33. function HelpIndex()
  34. {
  35. global $scripturl, $context, $txt;
  36. // We need to know where our wiki is.
  37. $context['wiki_url'] = 'http://wiki.simplemachines.org/smf';
  38. $context['canonical_url'] = $scripturl . '?action=help';
  39. // Sections were are going to link...
  40. $context['manual_sections'] = array(
  41. 'registering' => 'Registering',
  42. 'logging_in' => 'Logging_In',
  43. 'profile' => 'Profile',
  44. 'search' => 'Search',
  45. 'posting' => 'Posting',
  46. 'bbc' => 'Bulletin_board_code',
  47. 'personal_messages' => 'Personal_messages',
  48. 'memberlist' => 'Memberlist',
  49. 'calendar' => 'Calendar',
  50. 'features' => 'Features',
  51. );
  52. // Build the link tree.
  53. $context['linktree'][] = array(
  54. 'url' => $scripturl . '?action=help',
  55. 'name' => $txt['help'],
  56. );
  57. // Lastly, some minor template stuff.
  58. $context['page_title'] = $txt['manual_smf_user_help'];
  59. $context['sub_template'] = 'manual';
  60. }
  61. function HelpRules()
  62. {
  63. global $context, $txt, $boarddir, $user_info, $scripturl;
  64. // Build the link tree.
  65. $context['linktree'][] = array(
  66. 'url' => $scripturl . '?action=help',
  67. 'name' => $txt['help'],
  68. );
  69. $context['linktree'][] = array(
  70. 'url' => $scripturl . '?action=help;sa=rules',
  71. 'name' => $txt['terms_and_rules'],
  72. );
  73. // Have we got a localized one?
  74. if (file_exists($boarddir . '/agreement.' . $user_info['language'] . '.txt'))
  75. $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']);
  76. elseif (file_exists($boarddir . '/agreement.txt'))
  77. $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.txt'), true, 'agreement');
  78. else
  79. $context['agreement'] = '';
  80. // Nothing to show, so let's get out of here
  81. if (empty($context['agreement']))
  82. {
  83. // No file found or a blank file! Just leave...
  84. redirectexit();
  85. }
  86. $context['canonical_url'] = $scripturl . '?action=help;sa=rules';
  87. $context['page_title'] = $txt['terms_and_rules'];
  88. $context['sub_template'] = 'terms';
  89. }
  90. /**
  91. * Show some of the more detailed help to give the admin an idea...
  92. * It shows a popup for administrative or user help.
  93. * It uses the help parameter to decide what string to display and where to get
  94. * the string from. ($helptxt or $txt?)
  95. * It is accessed via ?action=helpadmin;help=?.
  96. * @uses ManagePermissions language file, if the help starts with permissionhelp.
  97. * @uses Help template, popup sub template, no layers.
  98. */
  99. function ShowAdminHelp()
  100. {
  101. global $txt, $helptxt, $context, $scripturl;
  102. if (!isset($_GET['help']) || !is_string($_GET['help']))
  103. fatal_lang_error('no_access', false);
  104. if (!isset($helptxt))
  105. $helptxt = array();
  106. // Load the admin help language file and template.
  107. loadLanguage('Help');
  108. // Permission specific help?
  109. if (isset($_GET['help']) && substr($_GET['help'], 0, 14) == 'permissionhelp')
  110. loadLanguage('ManagePermissions');
  111. loadTemplate('Help');
  112. // Allow mods to load their own language file here
  113. call_integration_hook('integrate_helpadmin');
  114. // Set the page title to something relevant.
  115. $context['page_title'] = $context['forum_name'] . ' - ' . $txt['help'];
  116. // Don't show any template layers, just the popup sub template.
  117. $context['template_layers'] = array();
  118. $context['sub_template'] = 'popup';
  119. // What help string should be used?
  120. if (isset($helptxt[$_GET['help']]))
  121. $context['help_text'] = $helptxt[$_GET['help']];
  122. elseif (isset($txt[$_GET['help']]))
  123. $context['help_text'] = $txt[$_GET['help']];
  124. else
  125. $context['help_text'] = $_GET['help'];
  126. // Does this text contain a link that we should fill in?
  127. if (preg_match('~%([0-9]+\$)?s\?~', $context['help_text'], $match))
  128. $context['help_text'] = sprintf($context['help_text'], $scripturl, $context['session_id'], $context['session_var']);
  129. }
  130. ?>