function parse_template() { $data = TemplateParser::parse($this->data, file_get_contents($this->template_file)); # post-parse JSON if (strtolower($this->template_type) == 'json') { # minfy it $data = json_minify($data); # strip any trailing commas # (run it twice to get partial matches) $data = preg_replace('/([}\\]"]),([}\\]])/', '$1$2', $data); $data = preg_replace('/([}\\]"]),([}\\]])/', '$1$2', $data); } return $data; }
appdeck_error("failed to create embedresource directory {$output_dir}", __FILE__, __LINE__); } // set beacon if needed // this beacon is used to clear cache on startup after a clean build $beacon_output_file_path = $output_dir_path . "/beacon"; if (defined('FORCE_DOWNLOAD') && FORCE_DOWNLOAD === true && file_exists($beacon_output_file_path)) { unlink($beacon_output_file_path); } if (!file_exists($beacon_output_file_path)) { file_put_contents($beacon_output_file_path, mt_rand()); } list($json_headers, $json_data) = ezcurl($app_json_url, $error); if ($json_data == false) { appdeck_error("failed to download: {$app_json_url}: {$error}", $app_plist_path); } $info = json_decode(json_minify($json_data)); if ($info == false) { appdeck_error("{$app_json_url}: invalid json data: {$json_data}"); } $base_url = isset($info->base_url) ? $info->base_url : $app_json_url; if (!isset($info->embed_url) && !isset($info->embed)) { appdeck_warning("no embed ressources defined in app.json"); } // by default we always embed app.json appdeck_add_ressource($app_json_url, $json_data, true); // try to add files from embed url if (isset($info->embed_url)) { $embed_url = resolve_url($info->embed_url, $base_url); embed_url($embed_url); } if (isset($info->embed_url_tablet)) {
/** * Takes a json file and returns an stdClass object * * @param string $pathJsonFile * @return stdClass */ function parseJsonFile($pathJsonFile, $assoc = FALSE) { // Get Json data from file, clean and decode it if (file_exists($pathJsonFile) === FALSE) { return FALSE; } $jsonContent = file_get_contents($pathJsonFile); $result = json_minify($jsonContent); return json_decode($result, $assoc); }