Permalink
Browse files

detect mobile phone browsers and use mobile format if required and av…

…ailable
  • Loading branch information...
1 parent 50f7962 commit 4af510f604908221a2651e9cdf7b9093cf786b7e gbateson committed Oct 7, 2005
Showing with 13 additions and 27 deletions.
  1. +9 −21 mod/hotpot/lib.php
  2. +4 −6 mod/hotpot/view.php
View
@@ -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");
@@ -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;
+ }
}
}
View
@@ -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 {

0 comments on commit 4af510f

Please sign in to comment.