Help.php 3.1 KB

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