public static function get_config_xml($app_id, $echo = false, $export_type = 'phonegap-build') { $app_main_infos = WpakApps::get_app_main_infos($app_id); $app_name = $app_main_infos['name']; $app_description = $app_main_infos['desc']; $app_phonegap_id = $app_main_infos['app_phonegap_id']; $app_version = $app_main_infos['version']; $app_version_code = $app_main_infos['version_code']; $app_phonegap_version = $app_main_infos['phonegap_version']; $app_author = $app_main_infos['author']; $app_author_email = $app_main_infos['author_email']; $app_author_website = $app_main_infos['author_website']; $app_platform = $app_main_infos['platform']; $app_icons = $app_main_infos['icons']; $whitelist_settings = self::get_whitelist_settings($app_id, $export_type); //Merge our default Phonegap Build plugins to those set in BO : $app_phonegap_plugins = WpakApps::get_merged_phonegap_plugins_xml($app_id, $app_main_infos['phonegap_plugins']); $xmlns = 'http://www.w3.org/ns/widgets'; $xmlns_gap = 'http://phonegap.com/ns/1.0'; if (!$echo) { ob_start(); } echo '<?xml version="1.0" encoding="UTF-8" ?>'; ?> <widget xmlns = "<?php echo $xmlns; ?> " xmlns:gap = "<?php echo $xmlns_gap; ?> " id = "<?php echo $app_phonegap_id; ?> " versionCode = "<?php echo $app_version_code; ?> " version = "<?php echo $app_version; ?> " > <name><?php echo $app_name; ?> </name> <description><?php echo $app_description; ?> </description> <author href="<?php echo $app_author_website; ?> " email="<?php echo $app_author_email; ?> "><?php echo $app_author; ?> </author> <gap:platform name="<?php echo $app_platform; ?> " /> <?php if (!empty($app_phonegap_version)) { ?> <preference name="phonegap-version" value="<?php echo $app_phonegap_version; ?> " /> <?php } /** * Filter to handle the "Webview bounce effect" on devices. * Pass false to this filter to allow the "Webview bounce effect". * * @param boolean true Bounce effect is disallowed by default. * @param int $app_id Application id */ if (apply_filters('wpak_config_xml_preference_disallow_overscroll', true, $app_id)) { ?> <preference name="<?php echo $app_platform == 'android' ? 'd' : 'D'; ?> isallowOverscroll" value="true" /> <preference name="webviewbounce" value="false" /> <?php } ?> <!-- PhoneGap plugin declaration --> <?php if (!empty($app_phonegap_plugins)) { ?> <?php echo str_replace("\n", "\n\t", $app_phonegap_plugins); ?> <?php } if (!empty($whitelist_settings)) { ?> <!-- Whitelist policy --> <?php foreach ($whitelist_settings as $whitelist_setting => $attributes) { if (empty($attributes) || !is_array($attributes)) { continue; } $attributes_str = ''; foreach ($attributes as $attribute => $value) { $attributes_str .= ' ' . $attribute . '="' . $value . '"'; } ?> <<?php echo $whitelist_setting; echo $attributes_str; ?> /> <?php } } ?> <!-- Icon and Splash screen declaration --> <?php if (!empty($app_icons)) { ?> <?php echo str_replace("\n", "\n\t", $app_icons); ?> <?php } ?> </widget> <?php $content = ''; if (!$echo) { $content = ob_get_contents(); ob_end_clean(); } return !$echo ? $content : ''; }
public static function get_config_xml($app_id, $echo = false, $export_type = '') { $app_main_infos = WpakApps::get_app_main_infos($app_id); $app_name = $app_main_infos['name']; $app_description = $app_main_infos['desc']; $app_phonegap_id = $app_main_infos['app_phonegap_id']; $app_version = $app_main_infos['version']; $app_version_code = $app_main_infos['version_code']; $app_phonegap_version = $app_main_infos['phonegap_version']; $app_author = $app_main_infos['author']; $app_author_email = $app_main_infos['author_email']; $app_author_website = $app_main_infos['author_website']; $app_platform = $app_main_infos['platform']; $app_icons = $app_main_infos['icons']; $access = array(); if ($export_type == 'phonegap-cli') { $access[] = array('origin' => '*', 'subdomains' => ''); } /** * Filter : allows to modify config.xml <access> element * * @param array array array of <access> elements * Each <access> element is an array with the following attributes : * - 'origin' string The domain of where the resource lives * - 'subdomains' bool Whether to allow subdomains on the * host specified in the origin parameter. Pass an empty * string to ignore this optional attribute. * @param int $app_id Application id */ $access = apply_filters('wpak_config_xml_access', $access, $app_id); //Merge our default Phonegap Build plugins to those set in BO : $app_phonegap_plugins = WpakApps::get_merged_phonegap_plugins_xml($app_id, $app_main_infos['phonegap_plugins']); $xmlns = 'http://www.w3.org/ns/widgets'; $xmlns_gap = 'http://phonegap.com/ns/1.0'; if (!$echo) { ob_start(); } echo '<?xml version="1.0" encoding="UTF-8" ?>'; ?> <widget xmlns = "<?php echo $xmlns; ?> " xmlns:gap = "<?php echo $xmlns_gap; ?> " id = "<?php echo $app_phonegap_id; ?> " versionCode = "<?php echo $app_version_code; ?> " version = "<?php echo $app_version; ?> " > <name><?php echo $app_name; ?> </name> <description><?php echo $app_description; ?> </description> <author href="<?php echo $app_author_website; ?> " email="<?php echo $app_author_email; ?> "><?php echo $app_author; ?> </author> <gap:platform name="<?php echo $app_platform; ?> " /> <?php if (!empty($app_phonegap_version)) { ?> <preference name="phonegap-version" value="<?php echo $app_phonegap_version; ?> " /> <?php } if (!empty($access)) { ?> <?php foreach ($access as $access_element) { if (empty($access_element['origin'])) { continue; } $subdomains = ''; if (isset($access_element['subdomains']) && is_bool($access_element['subdomains'])) { $subdomains = ' subdomains="' . ($access_element['subdomains'] ? 'true' : 'false') . '"'; } ?> <access origin="<?php echo $access_element['origin']; ?> "<?php echo $subdomains; ?> /> <?php } } /** * Filter to handle the "Webview bounce effect" on devices. * Pass false to this filter to allow the "Webview bounce effect". * * @param boolean true Bounce effect is disallowed by default. * @param int $app_id Application id */ if (apply_filters('wpak_config_xml_preference_disallow_overscroll', true, $app_id)) { ?> <preference name="<?php echo $app_platform == 'android' ? 'd' : 'D'; ?> isallowOverscroll" value="true" /> <preference name="webviewbounce" value="false" /> <?php } ?> <!-- Add Icon, Splash screen and any PhoneGap plugin declaration here --> <?php if (!empty($app_icons)) { ?> <?php echo str_replace("\n", "\n\t", $app_icons); ?> <?php } if (!empty($app_phonegap_plugins)) { ?> <?php echo str_replace("\n", "\n\t", $app_phonegap_plugins); ?> <?php } ?> </widget> <?php $content = ''; if (!$echo) { $content = ob_get_contents(); ob_end_clean(); } return !$echo ? $content : ''; }