* @author Martin Dougiamas
* @package moodlecore
*/
+
+define('NO_MOODLE_COOKIES', true);
+
require_once('config.php');
+$identifier = required_param('identifier', PARAM_SAFEDIR);
+$component = required_param('component', PARAM_SAFEDIR);
+$lang = required_param('component', PARAM_LANG);
+
+if (!$lang) {
+ $lang = 'en';
+}
+
+$SESSION->lang = $lang; // does not actually modify session because we do not use cookies here
-// Legacy url parameters - just dispaply error
-$file = optional_param('file', '', PARAM_PATH);
-$text = optional_param('text', 'No text to display', PARAM_CLEAN);
-$module = optional_param('module', 'moodle', PARAM_ALPHAEXT);
+// send basic headers only, we do not need full html page here
+@header('Content-Type: text/plain; charset=utf-8');
-// New get_string() parameters
-// $identifier =
-// $component =
+if (strpos('_hlp', $identifier) === false) {
+ echo '<strong>Old 1.9 style help files need to be converted to standard strings with "_hlp" suffix: '.$component.'/'.$identifier.'</strong>';
+ die;
+}
-die('TODO: help files will be soon reimplemented by using normal get_string().');
+echo get_string($identifier, $component);
}
}
+ /**
+ * Add a help button to element,
+ * only one button per element is allowed.
+ *
+ * @param string $elementname name of the element to add the item to
+ * @param string $identifier
+ * @param string $title
+ * @param string $component
+ * @param string $linktext
+ * @return void
+ */
+ function addHelpButton($elementname, $identifier, $title, $component = 'moodle', $linktext = '') {
+ if (array_key_exists($elementname, $this->_elementIndex)) {
+ $element->_helpbutton = $OUTPUT->help_icon($identifier, $title, $component, $linktext);
+ } else if (!$suppresscheck) {
+ debugging(get_string('nonexistentformelements', 'form', $elementname));
+ }
+ }
+
/**
* Set constant value not overriden by _POST or _GET
* note: this does not work for complex names with [] :-(
*/
class help_icon implements renderable {
/**
- * @var string $page name of help page
+ * @var string $helpidentifier lang pack identifier (should inlcude the "_hlp" suffix)
*/
- public $helppage;
+ public $helpidentifier;
/**
* @var string $title A descriptive text for title tooltip
*/
/**
* Constructor: sets up the other components in case they are needed
- * @param string $page The keyword that defines a help page
+ * @param string $helpidentifier The keyword that defines a help page
* @param string $title A descriptive text for accesibility only
* @param string $component
* @param bool $linktext add extra text to icon
* @return void
*/
- public function __construct($helppage, $title, $component = 'moodle') {
+ public function __construct($helpidentifier, $title, $component = 'moodle') {
if (empty($title)) {
throw new coding_exception('A help_icon object requires a $text parameter');
}
- if (empty($helppage)) {
- throw new coding_exception('A help_icon object requires a $helppage parameter');
+ if (empty($helpidentifier)) {
+ throw new coding_exception('A help_icon object requires a $helpidentifier parameter');
}
- $this->helppage = $helppage;
- $this->title = $title;
- $this->component = $component;
+ $this->helpidentifier = $helpidentifier;
+ $this->title = $title;
+ $this->component = $component;
}
}
* Centered heading with attached help button (same title text)
* and optional icon attached
* @param string $text A heading text
- * @param string $page The keyword that defines a help page
+ * @param string $helpidentifier The keyword that defines a help page
* @param string $component component name
* @param string|moodle_url $icon
* @param string $iconalt icon alt text
* @return string HTML fragment
*/
- public function heading_with_help($text, $helppage, $component='moodle', $icon='', $iconalt='') {
+ public function heading_with_help($text, $helpidentifier, $component='moodle', $icon='', $iconalt='') {
$image = '';
if ($icon) {
$image = $this->pix_icon($icon, $iconalt, $component, array('class'=>'icon'));
}
- $help = $this->help_icon($helppage, $text, $component);
+ $help = $this->help_icon($helpidentifier, $text, $component);
return $this->heading($image.$text.$help, 2, 'main help');
}
* @param string|bool $linktext true means use $title as link text, string means link text value
* @return string HTML fragment
*/
- public function help_icon($helppage, $title, $component = 'moodle', $linktext='') {
- $icon = new help_icon($helppage, $title, $component);
+ public function help_icon($helpidentifier, $title, $component = 'moodle', $linktext = '') {
+ $icon = new help_icon($helpidentifier, $title, $component);
if ($linktext === true) {
$icon->linktext = $title;
} else if (!empty($linktext)) {
$output .= $helpicon->linktext;
}
- // now create the link around it - TODO: this will be changed during the big lang cleanup in 2.0
- $url = new moodle_url('/help.php', array('module' => $helpicon->component, 'file' => $helpicon->helppage .'.html'));
+ // now create the link around it
+ $url = new moodle_url('/help.php', array('component' => $helpicon->component, 'identifier' => $helpicon->helpidentifier, 'lang'=>current_language()));
// note: this title is displayed only if JS is disabled, otherwise the link will have the new ajax tooltip
$title = get_string('helpprefix2', '', trim($helpicon->title, ". \t"));