Commit 1200ae3c authored by Martyn Smith's avatar Martyn Smith Committed by Martyn Smith
Browse files
parents 7c45b5ee eefbc041
......@@ -71,7 +71,7 @@ var ctxHelp = new Array();
var ctxHelp_selected;
var container;
function contextualHelp(formName, helpName, pluginType, pluginName, language) {
function contextualHelp(formName, helpName, pluginType, pluginName, page) {
var tooltip = $('tooltip');
log(tooltip);
log(ctxHelp_selected);
......@@ -97,12 +97,26 @@ function contextualHelp(formName, helpName, pluginType, pluginName, language) {
log('no help for this key yet, getting...');
ctxHelp[key] = new Object();
processingStart();
var d = loadJSONDoc('../lang/' + language + '/help/' + formName + '.' + helpName + '.html');
var url = '../json/help.php?plugintype=' + pluginType + '&pluginname=' + pluginName;
if (page) {
url += '&page=' + page;
}
else {
url += '&form=' + formName + '&element=' + helpName;
}
var d = loadJSONDoc(url);
d.addCallbacks(
function (data) {
ctxHelp[key].content = data;
container.innerHTML = ctxHelp[key].content;
processingStop();
if (data.error) {
ctxHelp[key].content = data.message;
container.innerHTML = ctxHelp[key].content;
processingStop();
}
else {
ctxHelp[key].content = data.content;
container.innerHTML = ctxHelp[key].content;
processingStop();
}
},
function () {
ctxHelp[key].content = '<p>Sorry, no help for this element could be found</p>';
......
<?php
/**
* This program is part of Mahara
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* @package mahara
* @subpackage core
* @author Penny Leach <penny@catalyst.net.nz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006,2007 Catalyst IT Ltd http://catalyst.net.nz
*
*/
define('INTERNAL', 1);
require(dirname(dirname(__FILE__)) . '/init.php');
json_headers();
$plugintype = param_alpha('plugintype');
$pluginname = param_alpha('pluginname');
$page = param_alpha('page', null);
$form = param_alpha('form', null);
$element = param_alpha('element', null);
$location = get_config('docroot') ;
$file = 'help/';
if ($plugintype != 'core') {
$location .= $plugintype . '/' . $pluginname . '/lang/';
}
else {
$location .= 'lang/';
}
if ($page) {
$file .= $page . '.html';
}
else if (!empty($form) && !empty($element)) {
$file .= 'forms/' . $form . '.' . $element . '.html';
}
else if (!empty($form) && empty($element)) {
$file .= 'forms/' . $form . '.html';
}
else {
json_reply(true, get_string('nohelpfound'));
}
// now we have to try and locate the help file
$lang = current_language();
if ($lang == 'en.utf8') {
$trieden = true;
}
else {
$trieden = false;
}
// try the current language
$langfile = $location . $lang . '/' . $file;
if (is_readable($langfile)) {
$data = file_get_contents($langfile);
}
// if it's not found, try the parent language if there is one...
if (empty($data) && empty($trieden)) {
$langfile = $location . $lang . '/langconfig.php';
if ($parentlang = get_string_from_file('parentlanguage', $langfile)) {
if ($parentlang == 'en.utf8') {
$trieden = true;
}
$langfile = $location . $parentlang . '/' . $file;
if (is_readable($langfile)) {
$data = file_get_contents($langfile);
}
}
}
// if it's STILL not found, and we haven't already tried english ...
if (empty($data) && empty($trieden)) {
$langfile = $location . 'en.utf8/' . $file;
if (is_readable($langfile)) {
$data = file_get_contents($langfile);
}
}
if (empty($data)) {
json_reply(true, get_string('nohelpfound'));
}
$json = array('error' => false, 'content' => $data);
echo json_encode($json);
exit;
?>
......@@ -208,6 +208,8 @@ $string['height'] = 'Height';
$string['widthshort'] = 'w';
$string['heightshort'] = 'h';
$string['nohelpfound'] = 'There was no help found for this item';
// Search
$string['search'] = 'Search';
$string['query'] = 'Query';
......@@ -215,5 +217,4 @@ $string['querydescription'] = 'The words to be searched for';
$string['results'] = 'Results';
$string['noresultsfound'] = 'No results found';
$string['resultsfor'] = 'Results matching "%s"';
?>
......@@ -104,8 +104,9 @@ class FormRendererMultiColumnTable {
}
// Contextual help
if (!empty($rawelement['help'])) {
$result .= ' <span class="help"><a href="#" title="'
. hsc($rawelement['help']) . '">?</a></span>';
$result .= get_help_icon($form->get_property('plugintype'),
$form->get_property('pluginname'),
$form->get_name(), $rawelement['name']);
}
$result .= "</td>\n\t";
}
......
......@@ -77,10 +77,10 @@ function form_renderer_table(Form $form, $builtelement, $rawelement) {
// Contextual help
if (!empty($rawelement['help'])) {
$result .= ' <span class="help"><a href="" onclick="contextualHelp(\'' . $form->get_name() . "', '"
. $rawelement['name'] . "', '" . $form->get_property('plugintype') . "', '"
. $form->get_property('pluginname') . "', '" . $form->get_property('language') . "'); return false;\">"
. '?</a></span>';
$result .= get_help_icon($form->get_property('plugintype'),
$form->get_property('pluginname'),
$form->get_name(), $rawelement['name']);
}
$result .= "</td>\n\t</tr>\n";
......
......@@ -971,4 +971,15 @@ function getoptions_country() {
);
}
/**
*
*/
function get_help_icon($plugintype, $pluginname, $form, $element, $page='') {
return ' <span class="help"><a href="" onclick="contextualHelp(\'' . $form . "', '"
. $element . "', '" . $plugintype . "', '"
. $pluginname . "', '" . $page . "'); return false;\">"
. '?</a></span>';
}
?>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment