svn: /phd/trunk/phpdotnet/phd/Package/Pear/ BigXHTML.php ChunkedXHTML.php Web.php

From: Date: Fri, 14 Aug 2009 16:13:19 +0000
Subject: svn: /phd/trunk/phpdotnet/phd/Package/Pear/ BigXHTML.php ChunkedXHTML.php Web.php
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-4683@lists.php.net to get a copy of this message
moacir Fri, 14 Aug 2009 16:13:19 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=287308 Log: using methods Changed paths: U phd/trunk/phpdotnet/phd/Package/Pear/BigXHTML.php U phd/trunk/phpdotnet/phd/Package/Pear/ChunkedXHTML.php U phd/trunk/phpdotnet/phd/Package/Pear/Web.php Modified: phd/trunk/phpdotnet/phd/Package/Pear/BigXHTML.php =================================================================== --- phd/trunk/phpdotnet/phd/Package/Pear/BigXHTML.php 2009-08-14 15:40:22 UTC (rev 287307) +++ phd/trunk/phpdotnet/phd/Package/Pear/BigXHTML.php 2009-08-14 16:13:19 UTC (rev 287308) @@ -3,13 +3,12 @@ /* $Id$ */ class Package_Pear_BigXHTML extends Package_Pear_XHTML { - protected $formatname = "Pear-BigXHTML"; - protected $title = "Pear Manual"; - public function __construct() { parent::__construct(); - parent::registerFormatName($this->formatname); - $this->chunked = false; + $this->registerFormatName("Pear-BigXHTML"); + $this->setTitle("Pear Manual"); + $this->setExt("html"); + $this->setChunked(false); } public function __destruct() { @@ -21,7 +20,7 @@ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> - <title>$this->title</title> + <title>{$this->getTitle()}</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> </head> <body> @@ -35,28 +34,40 @@ } public function close() { - fwrite($this->fp, $this->footer(true)); - fclose($this->fp); + if ($this->getFileStream()) { + fwrite($this->getFileStream(), $this->footer(true)); + fclose($this->getFileStream()); + } } + public function createFileName() { + return Config::output_dir() . strtolower($this->getFormatName()) . '.' . $this->getExt(); + } + + public function createOutputFile() { + if (!is_resource($this->getFileStream())) { + $this->setFileStream(fopen($this->createFileName(), "w+")); + fwrite($this->getFileStream(), $this->header()); + } + } + public function appendData($data) { if ($this->appendToBuffer) { $this->buffer .= $data; return; } if ($this->flags & Render::CLOSE) { - fwrite($this->fp, $data); + fwrite($this->getFileStream(), $data); /* Append footer */ - fwrite($this->fp, $this->footer()); + fwrite($this->getFileStream(), $this->footer()); $this->flags ^= Render::CLOSE; } elseif ($this->flags & Render::OPEN) { - fwrite($this->fp, $data."<hr />"); + fwrite($this->getFileStream(), $data."<hr />"); $this->flags ^= Render::OPEN; } else { - fwrite($this->fp, $data); + fwrite($this->getFileStream(), $data); } - } public function update($event, $val = null) { @@ -74,11 +85,7 @@ case Render::INIT: if ($val) { - if (!is_resource($this->fp)) { - $filename = Config::output_dir() . strtolower($this->getFormatName()) . '.' . $this->ext; - $this->fp = fopen($filename, "w+"); - fwrite($this->fp, $this->header()); - } + $this->createOutputFile(); } break; Modified: phd/trunk/phpdotnet/phd/Package/Pear/ChunkedXHTML.php =================================================================== --- phd/trunk/phpdotnet/phd/Package/Pear/ChunkedXHTML.php 2009-08-14 15:40:22 UTC (rev 287307) +++ phd/trunk/phpdotnet/phd/Package/Pear/ChunkedXHTML.php 2009-08-14 16:13:19 UTC (rev 287308) @@ -3,13 +3,12 @@ /* $Id$ */ class Package_Pear_ChunkedXHTML extends Package_Pear_XHTML { - protected $formatname = "Pear-Chunked-XHTML"; - protected $title = "Pear Manual"; - public function __construct() { parent::__construct(); - parent::registerFormatName($this->formatname); - $this->chunked = true; + $this->registerFormatName("Pear-Chunked-XHTML"); + $this->setTitle("Pear Manual"); + $this->setExt("html"); + $this->setChunked(true); } public function __destruct() { @@ -22,25 +21,26 @@ return; } elseif ($this->flags & Render::CLOSE) { - $fp = array_pop($this->fp); + $fp = $this->popFileStream(); fwrite($fp, $data); $this->writeChunk($this->CURRENT_CHUNK, $fp); fclose($fp); $this->flags ^= Render::CLOSE; } elseif ($this->flags & Render::OPEN) { - $this->fp[] = $fp = fopen("php://temp/maxmemory", "r+"); + $fp = fopen("php://temp/maxmemory", "r+"); fwrite($fp, $data); + $this->pushFileStream($fp); $this->flags ^= Render::OPEN; } else { - $fp = end($this->fp); - fwrite($fp, $data); + $fp = $this->getFileStream(); + fwrite(end($fp), $data); } } public function writeChunk($id, $fp) { - $filename = $this->outputdir . $id . '.' .$this->ext; + $filename = $this->getOutputDir() . $id . '.' .$this->getExt(); rewind($fp); file_put_contents($filename, $this->header($id)); @@ -49,7 +49,7 @@ } public function close() { - foreach ($this->fp as $fp) { + foreach ($this->getFileStream() as $fp) { fclose($fp); } } @@ -68,13 +68,13 @@ break; case Render::INIT: - $this->outputdir = $tmp = Config::output_dir() . strtolower($this->getFormatName()) . '/'; - if (file_exists($tmp)) { - if (!is_dir($tmp)) { + $this->setOutputDir(Config::output_dir() . strtolower($this->getFormatName()) . '/'); + if (file_exists($this->getOutputDir())) { + if (!is_dir($this->getOutputDir())) { v("Output directory is a file?", E_USER_ERROR); } } else { - if (!mkdir($tmp)) { + if (!mkdir($this->getOutputDir())) { v("Can't create output directory", E_USER_ERROR); } } Modified: phd/trunk/phpdotnet/phd/Package/Pear/Web.php =================================================================== --- phd/trunk/phpdotnet/phd/Package/Pear/Web.php 2009-08-14 15:40:22 UTC (rev 287307) +++ phd/trunk/phpdotnet/phd/Package/Pear/Web.php 2009-08-14 16:13:19 UTC (rev 287308) @@ -3,13 +3,10 @@ /* $Id$ */ class Package_Pear_Web extends Package_Pear_ChunkedXHTML { - protected $formatname = "Pear-Web"; - protected $title = "Pear Manual"; - public function __construct() { parent::__construct(); - parent::registerFormatName($this->formatname); - $this->ext = "php"; + $this->registerFormatName("Pear-Web"); + $this->setExt("php"); } public function __destruct() {

« previous php.doc.cvs (#4683) next »