function compress_template($file_path) { $temp = new mb_template($file_path, array('temp_dir' => ROOT_PATH, 'compile_dir' => ROOT_PATH . '_cache', 'force_compression' => true, 'compressHTML' => true, 'output_template' => true), null); $output = $temp->output_string(); $file_dir = get_dir_of_path($file_path); make_dir($file_dir, ROOT_PATH); write_file(rtrim(OUTPUT_DIR, '\\/\\') . $file_path, $output); $output = null; }
$template_file = null; foreach ($template_exts as $v) { $_file_path = PAGE_DIR . $file_path . '.' . $v; if (file_exists($_file_path)) { $template_file = $file_path . '.' . $v; break; } } if (!$template_file) { $template_file = '404.html'; } } if ($template_file) { $temp_dir = PAGE_DIR; $compressHTML = true; $temp = new mb_template($template_file, array('temp_dir' => $temp_dir, 'compile_dir' => ROOT_PATH . '_cache', 'force_compression' => true, 'compressHTML' => true), null); $json = new Services_JSON(); $global_data = array(); $data = array(); $data_file = DATA_DIR . 'global.json'; if (file_exists($data_file)) { $data_content = file_get_contents($data_file); $global_data = $json->decode($data_content); } $data_file = DATA_DIR . wipe_ext($template_file) . '.json'; if (file_exists($data_file)) { $data_content = file_get_contents($data_file); $data = $json->decode($data_content); if ($data) { $data = array_merge($global_data, $data); }