public static function get_components_synchro_data($app_id) { $components = array(); $components_data = array(); WpakAddons::require_app_addons_php_files($app_id); $components_raw = WpakComponentsStorage::get_components($app_id); if (!empty($components_raw)) { $globals = array(); foreach ($components_raw as $component) { $component_data = WpakComponentsTypes::get_component_data($component, $globals); // // Don't include null component into the webservice's return // Component data could be null if an addon's component has been added to the app and the addon isn't activated anymore // An addon could be seen as deactivated either if the corresponding plugin is deactivated, or if the corresponding checkbox is unchecked for the given app // if (null === $component_data) { continue; } $globals = $component_data['globals']; $components[$component->slug] = $component_data['specific']; } $navigation_items = WpakNavigationItemsStorage::get_navigation_indexed_by_components_slugs($app_id, true); $navigation_items = apply_filters('wpak_navigation_items', $navigation_items, WpakApps::get_app_slug($app_id)); $components_data['navigation'] = $navigation_items; $components_data['components'] = $components; $components_data['globals'] = $globals; $components_data['addons'] = WpakAddons::get_app_addons_dynamic_data($app_id); } return $components_data; }
public static function get_app_web_service_url($app_id_or_slug, $web_service_slug) { $url = self::get_app_web_service_base_url($app_id_or_slug); $app_slug = WpakApps::get_app_slug($app_id_or_slug); $app_id = WpakApps::get_app_id($app_id_or_slug); if (WpakApps::get_app_is_secured($app_id)) { $token = WpakToken::get_token($app_slug, $web_service_slug); $url .= '/' . $token; } $url .= '/' . $web_service_slug; return $url; }
public static function get_config_js($app_id, $echo = false) { $wp_ws_url = WpakWebServices::get_app_web_service_base_url($app_id); $theme = WpakThemesStorage::get_current_theme($app_id); $app_slug = WpakApps::get_app_slug($app_id); $app_main_infos = WpakApps::get_app_main_infos($app_id); $app_title = $app_main_infos['title']; $app_version = WpakApps::sanitize_app_version($app_main_infos['version']); $debug_mode = WpakBuild::get_app_debug_mode($app_id); $auth_key = WpakApps::get_app_is_secured($app_id) ? WpakToken::get_hash_key() : ''; //TODO : options to choose if the auth key is displayed in config.js. $options = WpakOptions::get_app_options($app_id); $addons = WpakAddons::get_app_addons_for_config($app_id); if (!$echo) { ob_start(); } //Indentation is a bit funky here so it appears ok in the config.js file source: ?> define( function ( require ) { "use strict"; return { app_slug : '<?php echo $app_slug; ?> ', wp_ws_url : '<?php echo $wp_ws_url; ?> ', theme : '<?php echo addslashes($theme); ?> ', version : '<?php echo $app_version; ?> ', app_title : '<?php echo addslashes($app_title); ?> ', debug_mode : '<?php echo $debug_mode; ?> '<?php if (!empty($auth_key)) { ?> , auth_key : '<?php echo $auth_key; ?> '<?php } ?> , options : <?php echo json_encode($options); ?> , addons : <?php echo json_encode($addons); ?> }; }); <?php $content = ''; if (!$echo) { $content = ob_get_contents(); ob_end_clean(); } return !$echo ? $content : ''; }
private static function get_export_file_base_name($app_id) { return 'phonegap-export-' . WpakApps::get_app_slug($app_id); }