Help.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. /**
  3. * Simple Machines Forum (SMF)
  4. *
  5. * @package SMF
  6. * @author Simple Machines http://www.simplemachines.org
  7. * @copyright 2011 Simple Machines
  8. * @license http://www.simplemachines.org/about/smf/license.php BSD
  9. *
  10. * @version 2.0
  11. */
  12. if (!defined('SMF'))
  13. die('Hacking attempt...');
  14. /* This file has the important job of taking care of help messages and the
  15. help center. It does this with two simple functions:
  16. void ShowHelp()
  17. - loads information needed for the help section.
  18. - accesed by ?action=help.
  19. - uses the Help template and Manual language file.
  20. void ShowAdminHelp()
  21. - shows a popup for administrative or user help.
  22. - uses the help parameter to decide what string to display and where
  23. to get the string from. ($helptxt or $txt?)
  24. - loads the ManagePermissions language file if the help starts with
  25. permissionhelp.
  26. - uses the Help template, popup sub template, no layers.
  27. - accessed via ?action=helpadmin;help=??.
  28. */
  29. // Redirect to the user help ;).
  30. function ShowHelp()
  31. {
  32. global $scripturl, $context, $txt;
  33. loadTemplate('Help');
  34. loadLanguage('Manual');
  35. // We need to know where our wiki is.
  36. $context['wiki_url'] = 'http://wiki.simplemachines.org/smf';
  37. // Sections were are going to link...
  38. $context['manual_sections'] = array(
  39. 'registering' => 'Registering',
  40. 'logging_in' => 'Logging_In',
  41. 'profile' => 'Profile',
  42. 'search' => 'Search',
  43. 'posting' => 'Posting',
  44. 'bbc' => 'Bulletin_board_code',
  45. 'personal_messages' => 'Personal_messages',
  46. 'memberlist' => 'Memberlist',
  47. 'calendar' => 'Calendar',
  48. 'features' => 'Features',
  49. );
  50. // Build the link tree.
  51. $context['linktree'][] = array(
  52. 'url' => $scripturl . '?action=help',
  53. 'name' => $txt['help'],
  54. );
  55. // Lastly, some minor template stuff.
  56. $context['page_title'] = $txt['manual_smf_user_help'];
  57. $context['sub_template'] = 'manual';
  58. }
  59. // Show some of the more detailed help to give the admin an idea...
  60. function ShowAdminHelp()
  61. {
  62. global $txt, $helptxt, $context, $scripturl;
  63. if (!isset($_GET['help']) || !is_string($_GET['help']))
  64. fatal_lang_error('no_access', false);
  65. if (!isset($helptxt))
  66. $helptxt = array();
  67. // Load the admin help language file and template.
  68. loadLanguage('Help');
  69. // Permission specific help?
  70. if (isset($_GET['help']) && substr($_GET['help'], 0, 14) == 'permissionhelp')
  71. loadLanguage('ManagePermissions');
  72. loadTemplate('Help');
  73. // Set the page title to something relevant.
  74. $context['page_title'] = $context['forum_name'] . ' - ' . $txt['help'];
  75. // Don't show any template layers, just the popup sub template.
  76. $context['template_layers'] = array();
  77. $context['sub_template'] = 'popup';
  78. // What help string should be used?
  79. if (isset($helptxt[$_GET['help']]))
  80. $context['help_text'] = $helptxt[$_GET['help']];
  81. elseif (isset($txt[$_GET['help']]))
  82. $context['help_text'] = $txt[$_GET['help']];
  83. else
  84. $context['help_text'] = $_GET['help'];
  85. // Does this text contain a link that we should fill in?
  86. if (preg_match('~%([0-9]+\$)?s\?~', $context['help_text'], $match))
  87. $context['help_text'] = sprintf($context['help_text'], $scripturl, $context['session_id'], $context['session_var']);
  88. }
  89. ?>