svn: /phd/trunk/ package_php.xml phpdotnet/phd/Package/PHP/CHM.php
| From: | Richard Quadling | Date: | Thu, 03 Feb 2011 17:21:14 +0000 |
| Subject: | svn: /phd/trunk/ package_php.xml phpdotnet/phd/Package/PHP/CHM.php | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-7705@lists.php.net to get a copy of this message | ||
rquadling Thu, 03 Feb 2011 17:21:14 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=307979
Log:
Prepare CHM rendering to use the new CSS rules.
Disply a message when loading an external stylesheet.
Incorporate stylesheet names supplied at the command line into the CHM file.
Changed paths:
U phd/trunk/package_php.xml
U phd/trunk/phpdotnet/phd/Package/PHP/CHM.php
Modified: phd/trunk/package_php.xml
===================================================================
--- phd/trunk/package_php.xml 2011-02-03 17:07:48 UTC (rev 307978)
+++ phd/trunk/package_php.xml 2011-02-03 17:21:14 UTC (rev 307979)
@@ -41,6 +41,9 @@
<license uri="http://www.opensource.org/licenses/bsd-license.php">BSD
Style</license>
<notes>
New output format Epub (Moacir)
+ Prepare CHM rendering to use the new CSS rules (Richard Quadling)
+ Disply a message when loading an external stylesheet (Richard Quadling)
+ Incorporate stylesheet names supplied at the command line into the CHM file (Richard Quadling)
</notes>
<contents>
Modified: phd/trunk/phpdotnet/phd/Package/PHP/CHM.php
===================================================================
--- phd/trunk/phpdotnet/phd/Package/PHP/CHM.php 2011-02-03 17:07:48 UTC (rev 307978)
+++ phd/trunk/phpdotnet/phd/Package/PHP/CHM.php 2011-02-03 17:21:14 UTC (rev 307979)
@@ -238,8 +238,17 @@
$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;}');
+ $stylesheet = '';
+ if (Config::css()) {
+ foreach(Config::css() as $cssname) {
+ $stylesheet .= $this->fetchStylesheet($cssname) . PHP_EOL;
+ }
+ } else {
+ $stylesheet = $this->fetchStylesheet() . PHP_EOL;
+ }
+ file_put_contents($this->outputdir . "style.css", $stylesheet . 'body
{ padding : 3px;}');
+
self::headerChm();
break;
case Render::VERBOSE:
@@ -391,11 +400,19 @@
public function header($id) {
$header = parent::header($id);
- // Add CSS link to <head>
- $pattern = '/(.*)(\r|\n|\r\n|\n\r)(.*)<\/head>/';
- $replacement = '$1 <link media="all" rel="stylesheet"
type="text/css" href="style.css"/>$2$3</head>';
- $header = preg_replace($pattern, $replacement, $header);
+ $patterns = array(
+ '/(.*)(\r|\n|\r\n|\n\r)(.*)<\/head>/', // Add CSS link to <head>
+ '/(<body)/', // Add 'docs' class to
body - the new CSS styling requires a parent of class 'docs'.
+ );
+
+ $replacements = array(
+ '$1 <link media="all" rel="stylesheet"
type="text/css" href="style.css"/>$2$3</head>',
+ '$1 class="docs"',
+ );
+
+ $header = preg_replace($patterns, $replacements, $header);
+
return $header;
}
@@ -412,10 +429,12 @@
}
protected function fetchStylesheet($name = null) {
- $stylesheet = file_get_contents("http://www.php.net/styles/site.css");
- if ($stylesheet) return $stylesheet;
- else {
- v("Stylesheet not fetched. Uses default rendering style.", E_USER_WARNING);
+ $stylesheet = file_get_contents($name = "http://www.php.net/styles/" . (is_null($name) ?
"site.css" : $name));
+ if ($stylesheet) {
+ v('Loaded %s stylesheet.', $name, VERBOSE_MESSAGES);
+ return $stylesheet;
+ } else {
+ v('Stylesheet %s not fetched. Uses default rendering style.', $name,
E_USER_WARNING);
return "";
}
}