Skip to content

Commit

Permalink
detect mobile phone browsers and use mobile format if required and av…
Browse files Browse the repository at this point in the history
…ailable
  • Loading branch information
gbateson committed Oct 7, 2005
1 parent 50f7962 commit 4af510f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 27 deletions.
30 changes: 9 additions & 21 deletions mod/hotpot/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

$CFG->hotpotroot = "$CFG->dirroot/mod/hotpot";
$CFG->hotpottemplate = "$CFG->hotpotroot/template";
$CFG->hotpotismobile = preg_match('/Alcatel|ATTWS|DoCoMo|Doris|Hutc3G|J-PHONE|Java|KDDI|KGT|LGE|MOT|Nokia|portalmmm|ReqwirelessWeb|SAGEM|SHARP|SIE-|SonyEricsson|Teleport|UP\.Browser|UPG1|Wapagsim/', $_SERVER['HTTP_USER_AGENT']);

define("HOTPOT_JS", "$CFG->wwwroot/mod/hotpot/hotpot-full.js");

Expand Down Expand Up @@ -1456,27 +1457,14 @@ function hotpot_xml_quiz(&$obj, $read_file=true, $parse_xml=true, $convert_urls=
$this->real_outputformat==HOTPOT_OUTPUTFORMAT_BEST ||
empty($HOTPOT_OUTPUTFORMAT_DIR[$this->real_outputformat])
) {
// set the best output format for this browser
// see http://jp2.php.net/function.get-browser
if (function_exists('get_browser') && ini_get('browscap')) {
$b = get_browser();
// apparently get_browser is a slow
// so we should store the results in $this->browser
} else {
$ua = $_SERVER['HTTP_USER_AGENT'];
$b = NULL;
// store the results in $this->browser
// [parent] => Firefox 0.9
// [platform] => WinXP
// [browser] => Firefox
// [version] => 0.9
// [majorver] => 0
// [minorver] => 9
}
if ($this->quiztype=='jmatch' || $this->quiztype=='jmix') {
$this->real_outputformat = HOTPOT_OUTPUTFORMAT_V6_PLUS;
} else {
$this->real_outputformat = HOTPOT_OUTPUTFORMAT_V6;
if ($CFG->hotpotismobile && isset($HOTPOT_OUTPUTFORMAT_DIR[HOTPOT_OUTPUTFORMAT_MOBILE])) {
$this->real_outputformat = HOTPOT_OUTPUTFORMAT_MOBILE;
} else { // PC
if ($this->quiztype=='jmatch' || $this->quiztype=='jmix') {
$this->real_outputformat = HOTPOT_OUTPUTFORMAT_V6_PLUS;
} else {
$this->real_outputformat = HOTPOT_OUTPUTFORMAT_V6;
}
}
}

Expand Down
10 changes: 4 additions & 6 deletions mod/hotpot/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,10 @@
default:
$hp->remove_nav_buttons();
}
switch ($hotpot->outputformat) {
case HOTPOT_OUTPUTFORMAT_MOBILE:
$hp->insert_submission_form($attemptid, '<!-- BeginSubmissionForm -->', '<!-- EndSubmissionForm -->', true);
break;
default:
$hp->insert_submission_form($attemptid, '<!-- BeginSubmissionForm -->', '<!-- EndSubmissionForm -->');
if ($CFG->hotpotismobile) {
$hp->insert_submission_form($attemptid, '<!-- BeginSubmissionForm -->', '<!-- EndSubmissionForm -->', true);
} else {
$hp->insert_submission_form($attemptid, '<!-- BeginSubmissionForm -->', '<!-- EndSubmissionForm -->');
}

} else {
Expand Down

0 comments on commit 4af510f

Please sign in to comment.