<?php header('Content-type: text/html; Charset=utf-8'); include 'merlin.php'; //Imports the image files, if merlin ids used. // Load the chapter config file $chapter_config_string = file_get_contents(realpath(dirname(__FILE__)) . '/../app/data/chapters.json') or die('Could not open config file'); $chapter_config = json_decode($chapter_config_string) or die('Invalid JSON in the chapter file'); // Process each chapter. // Spit out tasty content foreach ($chapter_config as $chapter) { if (!empty($chapter->doc) && !empty($chapter->name)) { $chapter->name = str_replace(" ", "-", $chapter->name); create_json_file($chapter->doc, strtolower($chapter->name)); } } /** * Takes the doc and formats it in a JSON file. * The file is output into the data folder inside the app folder. */ function create_json_file($doc_url, $file_name) { //Get the file $string = file_get_contents($doc_url) or die("Could not open {$doc_url} for reading"); //Deal with character encoding $string = mb_convert_encoding($string, 'utf-8', mb_detect_encoding($string)); // if you have not escaped entities use $file = mb_convert_encoding($string, 'html-entities', 'utf-8'); //Set up DOMDocument $doc = new DOMDocument('1.0', 'UTF-8'); $doc->substituteEntities = TRUE;
header('Content-type: text/html; Charset=utf-8'); libxml_use_internal_errors(true); //hide the DomDocument errors. error_reporting(E_ERROR | E_WARNING | E_PARSE); include 'merlin.php'; //Imports the image files, if merlin ids used. // Load the chapter config file $chapter_config_string = file_get_contents(realpath(dirname(__FILE__)) . '/../app/data/chapters.json') or die('Could not open config file'); $chapter_config = json_decode($chapter_config_string) or die('Invalid JSON in the chapter file'); // Process each chapter. // Spit out tasty content foreach ($chapter_config as $chapter) { if (!empty($chapter->doc) && !empty($chapter->slug)) { //$chapter->name = str_replace(" ", "-", $chapter->name); create_json_file($chapter->doc, strtolower($chapter->slug)); } } /** * Takes the doc and formats it in a JSON file. * The file is output into the data folder inside the app folder. */ function create_json_file($doc_url, $file_name) { //Get the file $string = file_get_contents($doc_url) or die("Could not open {$doc_url} for reading"); //Deal with character encoding $string = mb_convert_encoding($string, 'utf-8', mb_detect_encoding($string)); // if you have not escaped entities use $file = mb_convert_encoding($string, 'html-entities', 'utf-8'); // Replaces the italics and the bolds in the string.