public function update($event, $val = null) { switch ($event) { case Render::INIT: $this->parentdir = Config::output_dir() . strtolower($this->getFormatName()) . DIRECTORY_SEPARATOR; if (!file_exists($this->parentdir) || is_file($this->parentdir)) { mkdir($this->parentdir, 0777, true) or die("Can't create the output directory"); } $this->setOutputDir($this->parentdir . 'OPS' . DIRECTORY_SEPARATOR); if (!file_exists($this->getOutputDir()) || is_file($this->getOutputDir())) { mkdir($this->outputdir, 0777, true) or die("Can't create the cache directory"); } $this->info = $this->initInfo(); $this->openOPF($this->info, $this->getOutputDir()); $this->openNCX($this->info, $this->getOutputDir()); $this->createMimeTypeFile($this->parentdir); $this->createContainerFile($this->parentdir); $this->createBuildFile($this->parentdir, $this->info['epub_file']); $this->createCSSFile($this->getOutputDir()); $this->loadVersionAcronymInfo(); $this->postConstruct(); break; case Render::FINALIZE: $this->closeOPF(); $this->closeNCX(); break; default: parent::update($event, $val); } }
public function update($event, $val = null) { switch ($event) { case Render::CHUNK: parent::update($event, $val); break; case Render::STANDALONE: parent::update($event, $val); break; case Render::INIT: $this->loadVersionAcronymInfo(); $this->chmdir = Config::output_dir() . strtolower($this->getFormatName()) . DIRECTORY_SEPARATOR; if (!file_exists($this->chmdir) || is_file($this->chmdir)) { mkdir($this->chmdir) or die("Can't create the CHM project directory"); } $this->outputdir = Config::output_dir() . strtolower($this->getFormatName()) . DIRECTORY_SEPARATOR . "res" . DIRECTORY_SEPARATOR; $this->postConstruct(); if (!file_exists($this->outputdir) || is_file($this->outputdir)) { mkdir($this->outputdir) or die("Can't create the cache directory"); } $lang = Config::language(); $this->hhpStream = fopen($this->chmdir . "php_manual_{$lang}.hhp", "w"); $this->hhcStream = fopen($this->chmdir . "php_manual_{$lang}.hhc", "w"); $this->hhkStream = fopen($this->chmdir . "php_manual_{$lang}.hhk", "w"); file_put_contents($this->outputdir . "style.css", $this->fetchStylesheet() . PHP_EOL . 'body { padding : 3px;}'); self::headerChm(); break; case Render::VERBOSE: parent::update($event, $val); break; } }
public function update($event, $val = null) { switch ($event) { case Render::CHUNK: parent::update($event, $val); break; case Render::STANDALONE: parent::update($event, $val); break; case Render::INIT: $this->loadVersionAcronymInfo(); $this->chmdir = Config::output_dir() . strtolower($this->getFormatName()) . DIRECTORY_SEPARATOR; if (!file_exists($this->chmdir) || is_file($this->chmdir)) { mkdir($this->chmdir, 0777, true) or die("Can't create the CHM project directory"); } $this->outputdir = Config::output_dir() . strtolower($this->getFormatName()) . DIRECTORY_SEPARATOR . "res" . DIRECTORY_SEPARATOR; $this->postConstruct(); if (!file_exists($this->outputdir) || is_file($this->outputdir)) { mkdir($this->outputdir, 0777, true) or die("Can't create the cache directory"); } $lang = Config::language(); $this->hhpStream = fopen($this->chmdir . "php_manual_{$lang}.hhp", "w"); $this->hhcStream = fopen($this->chmdir . "php_manual_{$lang}.hhc", "w"); $this->hhkStream = fopen($this->chmdir . "php_manual_{$lang}.hhk", "w"); $stylesheet = $this->generateStylesheet(); $this->headerChm(); // Save the stylesheet. file_put_contents($this->outputdir . "style.css", $stylesheet . '#usernotes {margin-left : inherit;}' . PHP_EOL . '#layout-content { width: 100% !important; }' . PHP_EOL); break; case Render::VERBOSE: parent::update($event, $val); break; } }
public function update($event, $val = null) { switch ($event) { case Render::CHUNK: parent::update($event, $val); break; case Render::STANDALONE: parent::update($event, $val); break; case Render::INIT: $this->setOutputDir(Config::output_dir() . strtolower($this->getFormatName()) . '/'); break; //No verbose } }
public function update($event, $val = null) { switch ($event) { case Render::CHUNK: parent::update($event, $val); break; case Render::STANDALONE: parent::update($event, $val); break; case Render::INIT: $this->loadVersionAcronymInfo(); $this->chmdir = Config::output_dir() . strtolower($this->getFormatName()) . DIRECTORY_SEPARATOR; if (!file_exists($this->chmdir) || is_file($this->chmdir)) { mkdir($this->chmdir, 0777, true) or die("Can't create the CHM project directory"); } $this->outputdir = Config::output_dir() . strtolower($this->getFormatName()) . DIRECTORY_SEPARATOR . "res" . DIRECTORY_SEPARATOR; $this->postConstruct(); if (!file_exists($this->outputdir) || is_file($this->outputdir)) { mkdir($this->outputdir, 0777, true) or die("Can't create the cache directory"); } $lang = Config::language(); $this->hhpStream = fopen($this->chmdir . "php_manual_{$lang}.hhp", "w"); $this->hhcStream = fopen($this->chmdir . "php_manual_{$lang}.hhc", "w"); $this->hhkStream = fopen($this->chmdir . "php_manual_{$lang}.hhk", "w"); $stylesheet = ''; if (Config::css()) { foreach (Config::css() as $cssname) { $stylesheet .= $this->fetchStylesheet($cssname) . PHP_EOL; } } else { $stylesheet = $this->fetchStylesheet() . PHP_EOL; } self::headerChm(); // Find referenced content - background images, sprites, etc. if (0 !== preg_match_all('`url\\((([\'"]|)((?:(?!file:).)*)\\2)\\)`', $stylesheet, $stylesheet_urls)) { foreach (array_unique($stylesheet_urls[3]) as $stylesheet_url) { // Parse the url, getting content from http://www.php.net if there is no scheme and host. if (False !== ($parsed_url = parse_url($stylesheet_url))) { if (!isset($parsed_url['scheme']) && !isset($parsed_url['host'])) { $url_content = file_get_contents('http://www.php.net/' . $stylesheet_url); } else { // Otherwise content is fully identified. $url_content = file_get_contents($stylesheet_url); } // Make sure the location to save the content is available. @mkdir(dirname($content_filename = $this->outputdir . $parsed_url['path'])); // Save the referenced content to the new location. file_put_contents($content_filename, $url_content); // Add the content to the hpp file. fwrite($this->hhpStream, 'res' . DIRECTORY_SEPARATOR . ($relative_url = trim(substr(realpath($content_filename), strlen(realpath($this->outputdir))), DIRECTORY_SEPARATOR)) . PHP_EOL); // Force URLS to be relative to the "res" directory, but make them use the unix path separator as they will be processed by HTML. $stylesheet = str_replace($stylesheet_url, str_replace(DIRECTORY_SEPARATOR, '/', $relative_url), $stylesheet); v('Saved content from css : %s.', $parsed_url['path'], VERBOSE_MESSAGES); } else { v('Unable to save content from css : %s.', $stylesheet_url, E_USER_WARNING); } } } // Save the stylesheet. file_put_contents($this->outputdir . "style.css", $stylesheet . 'body {padding : 3px;}' . PHP_EOL . '#usernotes {margin-left : inherit;}' . PHP_EOL); break; case Render::VERBOSE: parent::update($event, $val); break; } }