public function update($event, $val = null) { switch ($event) { case Render::CHUNK: case Render::STANDALONE: case Render::VERBOSE: parent::update($event, $val); break; case Render::INIT: $this->setOutputDir(Config::output_dir() . strtolower($this->getFormatName()) . '/'); $this->postConstruct(); if (file_exists($this->getOutputDir())) { if (!is_dir($this->getOutputDir())) { v("Output directory is a file?", E_USER_ERROR); } } else { if (!mkdir($this->getOutputDir(), 0777, true)) { v("Can't create output directory", E_USER_ERROR); } } if (Config::css()) { $this->fetchStylesheet(); } break; } }
public function update($event, $val = null) { switch ($event) { case Render::CHUNK: $this->flags = $val; break; case Render::STANDALONE: if ($val) { $this->registerElementMap(static::getDefaultElementMap()); $this->registerTextMap(static::getDefaultTextMap()); } break; case Render::INIT: $this->setOutputDir(Config::output_dir() . strtolower($this->getFormatName()) . '/'); $this->postConstruct(); if (file_exists($this->getOutputDir())) { if (!is_dir($this->getOutputDir())) { v("Output directory is a file?", E_USER_ERROR); } } else { if (!mkdir($this->getOutputDir())) { v("Can't create output directory", E_USER_ERROR); } } if (Config::css()) { $this->fetchStylesheet(); } break; case Render::VERBOSE: v("Starting %s rendering", $this->getFormatName(), VERBOSE_FORMAT_RENDERING); break; } }
public function update($event, $val = null) { switch ($event) { case Render::CHUNK: $this->flags = $val; break; case Render::STANDALONE: if ($val) { $this->registerElementMap(parent::getDefaultElementMap()); $this->registerTextMap(parent::getDefaultTextMap()); } break; case Render::INIT: if ($val) { if (!is_resource($this->getFileStream())) { $filename = Config::output_dir(); if (Config::output_filename()) { $filename .= Config::output_filename(); } else { $filename .= strtolower($this->getFormatName()) . $this->getExt(); } $this->postConstruct(); if (Config::css()) { $this->fetchStylesheet(); } $this->setFileStream(fopen($filename, "w+")); fwrite($this->getFileStream(), $this->header()); } } break; case Render::VERBOSE: v("Starting %s rendering", $this->getFormatName(), VERBOSE_FORMAT_RENDERING); break; } }
public function update($event, $val = null) { switch ($event) { case Render::CHUNK: $this->flags = $val; break; case Render::STANDALONE: if ($val) { $this->registerElementMap(parent::getDefaultElementMap()); $this->registerTextMap(parent::getDefaultTextMap()); } break; case Render::INIT: if ($val) { $this->postConstruct(); if (Config::css()) { $this->fetchStylesheet(); } $this->createOutputFile(); } break; case Render::VERBOSE: v("Starting %s rendering", $this->getFormatName(), VERBOSE_FORMAT_RENDERING); break; } }
public function update($event, $val = null) { switch ($event) { case Render::FINALIZE: $this->writeJsonIndex(); break; case Render::CHUNK: $this->flags = $val; break; case Render::STANDALONE: if ($val) { $this->registerElementMap(static::getDefaultElementMap()); $this->registerTextMap(static::getDefaultTextMap()); } break; case Render::INIT: $this->loadVersionAcronymInfo(); $this->setOutputDir(Config::output_dir() . strtolower($this->getFormatName()) . '/'); $this->postConstruct(); if (file_exists($this->getOutputDir())) { if (!is_dir($this->getOutputDir())) { v("Output directory is a file?", E_USER_ERROR); } } else { if (!mkdir($this->getOutputDir(), 0777, true)) { v("Can't create output directory", E_USER_ERROR); } } if ($this->getFormatName() == "PHP-Web") { if (!Config::no_toc() && is_dir($this->getOutputDir() . 'toc')) { removeDir($this->getOutputDir() . 'toc'); } if (!file_exists($this->getOutputDir() . "toc") || is_file($this->getOutputDir() . "toc")) { mkdir($this->getOutputDir() . "toc", 0777, true) or die("Can't create the toc directory"); } } if (Config::css()) { $this->fetchStylesheet(); } break; case Render::VERBOSE: v("Starting %s rendering", $this->getFormatName(), VERBOSE_FORMAT_RENDERING); break; } }
/** * Load stylesheets from the config to include in the project stylesheet * @return string */ protected function loadStylesheets() { $stylesheet = ''; if (Config::css()) { foreach (Config::css() as $cssname) { $stylesheet .= $this->fetchStylesheet($cssname) . PHP_EOL; } } else { $stylesheet = $this->fetchStylesheet() . PHP_EOL; } return $stylesheet; }
protected function fetchStylesheet($name = null) { if (!$this->isChunked()) { foreach ((array) Config::css() as $css) { if ($style = file_get_contents($css)) { $this->stylesheets[] = $style; } else { v("Stylesheet %s not fetched.", $css, E_USER_WARNING); } } return; } $stylesDir = $this->getOutputDir(); if (!$stylesDir) { $stylesDir = Config::output_dir(); } $stylesDir .= 'styles/'; if (file_exists($stylesDir)) { if (!is_dir($stylesDir)) { v("The styles/ directory is a file?", E_USER_ERROR); } } else { if (!mkdir($stylesDir)) { v("Can't create the styles/ directory.", E_USER_ERROR); } } foreach ((array) Config::css() as $css) { $basename = basename($css); $dest = md5(substr($css, 0, -strlen($basename))) . '-' . $basename; if (@copy($css, $stylesDir . $dest)) { $this->stylesheets[] = $dest; } else { v('Impossible to copy the %s file.', $css, E_USER_WARNING); } } }
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; } }
public function getConfigParams() { //$doctype_str = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'; $doctype_str = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'; self::$doctype = $doctype_str; $godaddy_analytics_str = "<!--GODADDY ANALYTICS:--><script type=\"text/javascript\">\nvar gaJsHost = ((\"https:\" == document.location.protocol) ? \"https://ssl.\" : \"http://www.\");\ndocument.write(unescape(\"%3Cscript src='\" + gaJsHost + \"google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E\"));\n</script>\n<script type=\"text/javascript\">\ntry {\nvar pageTracker = _gat._getTracker(\"UA-15905158-1\");\npageTracker._trackPageview();\n} catch(err) {}\n</script>\n<script type=\"text/JavaScript\">var TFN='';var TFA='';var TFI='0';var TFL='0';var tf_RetServer=\"rt.trafficfacts.com\";\nvar tf_SiteId=\"14120g9493f85cbde65e99dd8c83e9c3f3473b29529d1fh10\";\nvar tf_ScrServer=document.location.protocol+\"//rt.trafficfacts.com/tf.php?k=14120g9493f85cbde65e99dd8c83e9c3f3473b29529d1fh10;c=s;v=5\";\ndocument.write(unescape('%3Cscript type=\"text/JavaScript\" src=\"'+tf_ScrServer+'\">%3C/script>'));</script>\n<noscript>\n<img src=\"http://rt.trafficfacts.com/ns.php?k=14120g9493f85cbde65e99dd8c83e9c3f3473b29529d1fh10\" height=\"1\" width=\"1\" alt=\"\"/>\n</noscript>"; $google_analytics_str = "<!--GOOGLE ANALYTICS:--><script type=\"text/javascript\">\n var _gaq = _gaq || [];\n _gaq.push(['_setAccount', 'UA-15905158-1']);\n _gaq.push(['_trackPageview']);\n\n (function() {\n var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\n ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';\n var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\n })();\n</script>"; self::$docroot = $_SERVER['DOCUMENT_ROOT']; if (self::$server_name == 'twextra') { self::$godaddy_analytics = $godaddy_analytics_str; self::$google_analytics = ''; self::$hostname = "http://twextra.com"; //self::$cookie_name = "tw_tok"; self::$cookie_name = "tw_user_id"; self::$hostdb = '173.201.185.107'; self::$database = 'twextra'; self::$userdb = 'twextra'; self::$pwdb = 'Spearmint1'; self::$linkedin_access = 'U6zyYyGUwE5o0zvIkMnGosw2WpQusl-Pa4JNQyIy9IDdsDLKdp2by6qzwFM7H6Rv'; //linkedin-twextra self::$linkedin_secret = 'GB-ssm8NUpUVD2h1X2dNxv2eESi8Tgc57hxciklT8-KsSPwNC9KcbOP1drSHSNUL'; //linkedin-twextra self::$consumer_key = 'OIWt7zoGUChqHkELTyYx8g'; //twitter-twextra self::$consumer_secret = 'oqLgz87EFUCNZYxNr7yEeZqHwTTPwv4CcwWS2K7YIg'; //twitter-twextra self::$oauth_callback = self::$hostname . "/twitter/page2.php"; //twitter-twextra self::$fb_app_id = '144934438868111'; } else { if (self::$server_name == 'twetest') { self::$godaddy_analytics = ''; self::$google_analytics = ''; self::$hostname = "http://twetest.com"; //self::$cookie_name = "tw_tok"; self::$cookie_name = "tw_user_id"; self::$hostdb = '173.201.217.33'; self::$database = 'twetest'; self::$userdb = 'twetest'; self::$pwdb = 'Spearmint1'; self::$linkedin_access = 'YMKaHlPF6xv8YTMs_FftnoC1tq_0Fgoz9Y8me0PvcR1Sm9WxzuPI18hZr2yP3fFq'; //linkedin-twetest self::$linkedin_secret = 'PuKdmBOQFdR1vibAe0LX3yRkKhu-NWlZaqC3EwnsiiMw1OL0EZ_J_rmh5PjzHXfg'; //linkedin-twetest self::$consumer_key = 'JBRzgN0LeUJFzCo2K1koGw'; //twitter-twetest self::$consumer_secret = '1DuqRvKXXGHSs77XlkYFUiIqWaL0XFgymL1iprZV8'; //twitter-twetest self::$oauth_callback = self::$hostname . "/twitter/page2.php"; //twitter-twetest self::$fb_app_id = '138321036207048'; //$auth_header = header('WWW-Authenticate: Basic realm="My Realm"',true,401); // //self::$doctype = $auth_header.self::$doctype; // } else { exit("Error: server not found"); } } //.......................................................................... if (isset($_SESSION['useragent']) && $_SESSION['useragent'] == 'device') { self::$css = "/scripts/main.css"; //docroot not included for href tags.. } else { self::$css = "/scripts/main.css"; //docroot not included for href tags.. } //............................................................................. //.......................................................................... self::$footer = ''; self::$footer .= "\n<div class='footer'>\nViewista, Inc. © 2010 <br /> \n<a href='http://twitter.com/twextradotcom'>Follow On Twitter</a> |\n<a href='" . self::$hostname . "/contact.php'>Contact</a> |\n<a href='" . self::$hostname . "/about.php'>About</a> |\n<a href='" . self::$hostname . "/privacy.php'>Privacy Policy</a> |\n<a href='" . self::$hostname . "/terms.php'>Terms</a> |\n<a href='" . self::$hostname . "/faqs.php'>FAQs</a> |\n<a href='http://twitter.com/twextradotcom'>Blog</a> |\n<a href='" . self::$hostname . "/api_support.php'>API Support</a>\n</div>"; //.......................................................................... $config_params = array('debug' => self::$debug, 'docroot' => self::$docroot, 'watch_demo' => self::$watch_demo, 'tweet_size_max' => self::$tweet_size_max, 'tweet_size_max_google' => self::$tweet_size_max_google, 'session_time_max' => self::$session_time_max, 'prefix_size_max' => self::$prefix_size_max, 'doctype' => self::$doctype, 'html_attribute' => self::$html_attribute, 'google_analytics' => self::$google_analytics, 'godaddy_analytics' => self::$godaddy_analytics, 'hostname' => self::$hostname, 'cookie_name' => self::$cookie_name, 'hostdb' => self::$hostdb, 'database' => self::$database, 'userdb' => self::$userdb, 'pwdb' => self::$pwdb, 'linkedin_access' => self::$linkedin_access, 'linkedin_secret' => self::$linkedin_secret, 'consumer_key' => self::$consumer_key, 'consumer_secret' => self::$consumer_secret, 'oauth_callback' => self::$oauth_callback, 'css' => self::$css, 'docroot' => $_SERVER['DOCUMENT_ROOT'], 'footer' => self::$footer, 'twitter_embedded_token_max' => self::$twitter_embedded_token_max, 'ep4' => self::$ep4, 'fb_app_id' => self::$fb_app_id); return $config_params; }