svn: /phd/trunk/phpdotnet/phd/Package/PHP/ CHM.php
| From: | Richard Quadling | Date: | Tue, 08 Sep 2009 10:02:03 +0000 |
| Subject: | svn: /phd/trunk/phpdotnet/phd/Package/PHP/ CHM.php | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-4864@lists.php.net to get a copy of this message | ||
rquadling Tue, 08 Sep 2009 10:02:03 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=288155
Log:
CHM TOC and images working
Changed paths:
U phd/trunk/phpdotnet/phd/Package/PHP/CHM.php
Modified: phd/trunk/phpdotnet/phd/Package/PHP/CHM.php
===================================================================
--- phd/trunk/phpdotnet/phd/Package/PHP/CHM.php 2009-09-08 07:47:25 UTC (rev 288154)
+++ phd/trunk/phpdotnet/phd/Package/PHP/CHM.php 2009-09-08 10:02:03 UTC (rev 288155)
@@ -257,7 +257,7 @@
fwrite($this->hhkStream,
" <LI><OBJECT type=\"text/sitemap\">\n" .
" <param name=\"Local\"
value=\"{$ref}\">\n" .
- " <param name=\"Name\"
value=\"{$name}\">\n" .
+ " <param name=\"Name\" value=\"" .
htmlentities(self::cleanIndexName($name)) . "\">\n" .
" </OBJECT>\n");
} elseif ($this->flags & Render::CLOSE) {
if ($hasChild) {
@@ -267,6 +267,24 @@
}
}
+ /**
+ * Clean up the index name.
+ * Newlines and double spaces don't look that good in some chm viewer apps.
+ *
+ * @param string $value Value to fix
+ *
+ * @return string Fixed/cleaned value
+ */
+ protected static function cleanIndexName($value)
+ {
+ return str_replace(
+ array("\n", "\r", ' '),
+ array('', '', ' '),
+ $value
+ );
+ }
+
+
protected function headerChm() {
$lang = Config::language();
fwrite($this->hhpStream, '[OPTIONS]
@@ -279,6 +297,7 @@
Default Window=doc
Display compile progress=Yes
Enhanced decompilation=Yes
+Flat=Yes
Full-text search=Yes
Index file=php_manual_' . $lang . '.hhk
Language=' . $this->LANGUAGES[$lang]["langcode"] . '
@@ -409,6 +428,17 @@
$link = preg_replace($search, $replacement, $link);
return $link;
}
+
+ public function format_imagedata($open, $name, $attrs) {
+ // Due to flattening of the CHM build process, the links to the images cannot be relative.
+ preg_match('
src="([^"]++)"', $image =
parent::format_imagedata($open, $name, $attrs), $imageMatches);
+ $image = str_replace($imageMatches[1], basename($imageMatches[1]), $image);
+
+ // Add the image to the hhp project file as the automatic build won't find it.
+ fwrite($this->hhpStream, 'res\\images\\' . basename($imageMatches[1]) .
"\n");
+
+ return $image;
+ }
}
/*