32 Settings::setDefaultValue(
"phonegap",
"enable_phonegap",
true, Boolean,
"Enables support for Phonegap/Cordova applications");
33 Settings::setDefaultValue(
"phonegap",
"enable_phonegap_debugging",
false, Boolean,
"Enables PhoneGap debugging mode - append phonegap=1 to any URL in your desktop browser to turn on PhoneGap mode");
34 Settings::setDefaultValue(
"phonegap",
"phonegap_debug_version",
"2.4.0", String,
"The version of Phonegap that is assumed in debugging mode");
35 Settings::setDefaultValue(
"phonegap",
"phonegap_debug_os",
"android", String,
"The OS of Phonegap that is assumed in debugging mode");
36 Settings::setDefaultValue(
"phonegap",
"use_local_phonegap_files",
false, Boolean,
"Check this box to pull the local cordova files in the packaged app, instead of pulling them from the server (EXPERIMENTAL)");
46 trace(
"Detecting PhoneGap", 4);
56 trace(
"Phonegap flag without OS or version detected in session for {$_SERVER["REMOTE_ADDR
"]} - resetting", 2);
62 if (preg_match(
"/PhoneGap\\/Cordova (\\w+) (\\d+\\.\\d+\\.\\d+)/i", $_SERVER[
'HTTP_USER_AGENT'], $matches))
66 $_SESSION[
"phonegap_version"] = $matches[2];
68 trace(
"PhoneGap {$_SESSION["phonegap_version
"]} for {$_SESSION["phonegap_os
"]} enabled for {$_SERVER["REMOTE_ADDR
"]} via User Agent", 2);
70 else if (
$_POST[
"phonegap"] &&
$_POST[
"phonegap_version"] !=
"" &&
$_POST[
"phonegap_os"] !=
"")
76 trace(
"PhoneGap {$_SESSION["phonegap_version
"]} for {$_SESSION["phonegap_os
"]} enabled for {$_SERVER["REMOTE_ADDR
"]} via POST", 2);
78 else if (
Settings::getValue(
"phonegap",
"enable_phonegap_debugging") && $_GET[
"phonegap"])
84 trace(
"PhoneGap {$_SESSION["phonegap_version
"]} for {$_SESSION["phonegap_os
"]} enabled for {$_SERVER["REMOTE_ADDR
"]} in debugging mode", 2);
93 return (isset(
$_SESSION[
"phonegap"]) &&
$_SESSION[
"phonegap"] ==
true) || stripos($_SERVER[
'HTTP_USER_AGENT'],
"PhoneGap/Cordova") !==
false;
100 echo
"<p>Using Phonegap version ".$_SESSION[
"phonegap_version"].
" on ".
$_SESSION[
"phonegap_os"].
"</p>";
104 echo
"<p>Not using Phonegap</p>";
115 if ($os ==
"droid") $os =
"android";
122 global $phonegap_csp;
142 $phonegap =
"<script type='text/javascript' src='{$app}'></script>\n".$phonegap;
147 $phonegap_csp =
"gap: cdvfile:";
148 $phonegap =
"<script type='text/javascript' src='cdvfile://localhost/bundle/www/cordova.js'></script>".$phonegap;
152 $phonegap_csp =
"gap:";
153 $phonegap =
"<script type='text/javascript' src='{$file}'></script>\n".$phonegap;
157 $phonegap .=
"<script type='text/javascript' src='{$supportScript}'></script>\n";
170 trace(
"Registering Phonegap file for $platform $version: $file", 3);
177 $key =
"{$platform}-{$version}";
185 return "/components/phonegap/js/{$platform}/cordova-{$version}.js";
190 trace(
"Registering Phonegap App Script for $platform $version: $file", 3);
196 $key =
"{$platform}-{$version}";
202 $key =
"*-{$version}";
static fireEvent($event, $parameter=null, $mustBeConsumed=false)
Fire an event to all subscribers as detailed in their manifests.
Provides support for managing Phonegap apps.
static getOS()
Retrieve the current client device's OS (assuming it is running in Phonegap / Cordova)
static detectPhonegap()
Detects whether a phonegap / cordova app is being used to access the current page.
static addScript($script)
static registerPhonegapFile($platform, $version, $file)
static getPhonegapFile($platform, $version)
static defaultSupportScripts()
static registerPhonegapSupportScript($s)
static getPhonegapAppScript($platform, $version)
static registerPhonegapAppScript($platform, $version, $file)
static getValue($component, $name)
Retrieve the value of the specified Setting.
static setDefaultValue($component, $name, $value, $field_type="String", $annotation="", $category="", $options="", $weight=0)
Sets the default value of the given component setting.
global $phonegap
Provides a central management class for event handlers and common functionality for the phonegap comp...