Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

help.php 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <?php
  2. /**
  3. * Roundcube Help Plugin
  4. *
  5. * @author Aleksander 'A.L.E.C' Machniak
  6. * @author Thomas Bruederli <thomas@roundcube.net>
  7. * @license GNU GPLv3+
  8. *
  9. * Configuration (see config.inc.php.dist)
  10. *
  11. **/
  12. class help extends rcube_plugin
  13. {
  14. // all task excluding 'login' and 'logout'
  15. public $task = '?(?!login|logout).*';
  16. // we've got no ajax handlers
  17. public $noajax = true;
  18. // skip frames
  19. public $noframe = true;
  20. function init()
  21. {
  22. $this->load_config();
  23. $this->add_texts('localization/', false);
  24. // register task
  25. $this->register_task('help');
  26. // register actions
  27. $this->register_action('index', array($this, 'action'));
  28. $this->register_action('about', array($this, 'action'));
  29. $this->register_action('license', array($this, 'action'));
  30. $this->add_hook('startup', array($this, 'startup'));
  31. $this->add_hook('error_page', array($this, 'error_page'));
  32. }
  33. function startup($args)
  34. {
  35. $rcmail = rcmail::get_instance();
  36. // add taskbar button
  37. $this->add_button(array(
  38. 'command' => 'help',
  39. 'class' => 'button-help',
  40. 'classsel' => 'button-help button-selected',
  41. 'innerclass' => 'button-inner',
  42. 'label' => 'help.help',
  43. ), 'taskbar');
  44. $this->include_script('help.js');
  45. $rcmail->output->set_env('help_open_extwin', $rcmail->config->get('help_open_extwin', false), true);
  46. // add style for taskbar button (must be here) and Help UI
  47. $skin_path = $this->local_skin_path();
  48. if (is_file($this->home . "/$skin_path/help.css")) {
  49. $this->include_stylesheet("$skin_path/help.css");
  50. }
  51. }
  52. function action()
  53. {
  54. $rcmail = rcmail::get_instance();
  55. // register UI objects
  56. $rcmail->output->add_handlers(array(
  57. 'helpcontent' => array($this, 'content'),
  58. 'tablink' => array($this, 'tablink'),
  59. ));
  60. if ($rcmail->action == 'about')
  61. $rcmail->output->set_pagetitle($this->gettext('about'));
  62. else if ($rcmail->action == 'license')
  63. $rcmail->output->set_pagetitle($this->gettext('license'));
  64. else
  65. $rcmail->output->set_pagetitle($this->gettext('help'));
  66. $rcmail->output->send('help.help');
  67. }
  68. function tablink($attrib)
  69. {
  70. $rcmail = rcmail::get_instance();
  71. $attrib['name'] = 'helplink' . $attrib['action'];
  72. $attrib['href'] = $rcmail->url(array('_action' => $attrib['action'], '_extwin' => !empty($_REQUEST['_extwin']) ? 1 : null));
  73. // title might be already translated here, so revert to it's initial value
  74. // so button() will translate it correctly
  75. $attrib['title'] = $attrib['label'];
  76. return $rcmail->output->button($attrib);
  77. }
  78. function content($attrib)
  79. {
  80. $rcmail = rcmail::get_instance();
  81. switch ($rcmail->action) {
  82. case 'about':
  83. if (is_readable($this->home . '/content/about.html')) {
  84. return @file_get_contents($this->home . '/content/about.html');
  85. }
  86. $default = $rcmail->url(array('_task' => 'settings', '_action' => 'about', '_framed' => 1));
  87. $src = $rcmail->config->get('help_about_url', $default);
  88. break;
  89. case 'license':
  90. if (is_readable($this->home . '/content/license.html')) {
  91. return @file_get_contents($this->home . '/content/license.html');
  92. }
  93. $src = $rcmail->config->get('help_license_url', 'http://www.gnu.org/licenses/gpl-3.0-standalone.html');
  94. break;
  95. default:
  96. $src = $rcmail->config->get('help_source');
  97. // resolve task/action for depp linking
  98. $index_map = $rcmail->config->get('help_index_map', array());
  99. $rel = $_REQUEST['_rel'];
  100. list($task,$action) = explode('/', $rel);
  101. if ($add = $index_map[$rel])
  102. $src .= $add;
  103. else if ($add = $index_map[$task])
  104. $src .= $add;
  105. break;
  106. }
  107. // default content: iframe
  108. if (!empty($src)) {
  109. $attrib['src'] = $this->resolve_language($src);
  110. }
  111. if (empty($attrib['id']))
  112. $attrib['id'] = 'rcmailhelpcontent';
  113. $attrib['name'] = $attrib['id'];
  114. return $rcmail->output->frame($attrib);
  115. }
  116. function error_page($args)
  117. {
  118. $rcmail = rcmail::get_instance();
  119. if ($args['code'] == 403 && $rcmail->request_status == rcube::REQUEST_ERROR_URL && ($url = $rcmail->config->get('help_csrf_info'))) {
  120. $args['text'] .= '<p>' . html::a(array('href' => $url, 'target' => '_blank'), $this->gettext('csrfinfo')) . '</p>';
  121. }
  122. return $args;
  123. }
  124. private function resolve_language($path)
  125. {
  126. // resolve language placeholder
  127. $rcmail = rcmail::get_instance();
  128. $langmap = $rcmail->config->get('help_language_map', array('*' => 'en_US'));
  129. $lang = $langmap[$_SESSION['language']] ?: $langmap['*'];
  130. return str_replace('%l', $lang, $path);
  131. }
  132. }