cvs: phd /formats pdf.php /themes/php phppdf.php
| From: | Christian Weiske | Date: | Sat, 24 Jan 2009 21:50:09 +0000 |
| Subject: | cvs: phd /formats pdf.php /themes/php phppdf.php | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-3076@lists.php.net to get a copy of this message | ||
cweiske Sat Jan 24 21:50:09 2009 UTC
Modified files:
/phd/formats pdf.php
/phd/themes/php phppdf.php
Log:
More and final ereg_replace->preg_replace
http://cvs.php.net/viewvc.cgi/phd/formats/pdf.php?r1=1.8&r2=1.9&diff_format=u Index: phd/formats/pdf.php diff -u phd/formats/pdf.php:1.8 phd/formats/pdf.php:1.9 --- phd/formats/pdf.php:1.8 Fri Nov 7 23:46:17 2008 +++ phd/formats/pdf.php Sat Jan 24 21:50:08 2009 @@ -334,7 +334,7 @@ return ""; } - $ret = utf8_decode(trim(ereg_replace( "[ \n\t]+", ' ', $str))); + $ret = utf8_decode(trim(preg_replace('/[ \n\t]+/', ' ', $str))); // No whitespace if current text value begins with ',', ';', ':', '.' if (strncmp($ret, ",", 1) && strncmp($ret, ";", 1) && strncmp($ret, ":", 1) && strncmp($ret, ".", 1)) $this->pdfDoc->appendText(" " . $ret); @@ -572,7 +572,7 @@ } public function format_link_text($value, $tag) { - $value = trim(ereg_replace( "[ \n\t]+", ' ', $value)); + $value = trim(preg_replace('/[ \n\t]+/', ' ', $value)); if (isset($this->cchunk["href"]) && $this->cchunk["href"]) { $this->pdfDoc->add(PdfWriter::URL_ANNOTATION, array(chr(187) . chr(160) . $value, $this->cchunk["href"])); // links with >> symbol } elseif (isset($this->cchunk["linkend"]) && $linkend = $this->cchunk["linkend"]) { @@ -586,7 +586,7 @@ } public function format_function_text($value, $tag, $display_value = null) { - $value = trim(ereg_replace( "[ \n\t]+", ' ', $value)); + $value = trim(preg_replace('/[ \n\t]+/', ' ', $value)); if ($display_value === null) { $display_value = $value; } @@ -1076,14 +1076,14 @@ // }}} Footnotes & Callouts public function format_quote_text($value, $tag) { - $value = trim(ereg_replace( "[ \n\t]+", ' ', $value)); + $value = trim(preg_replace('/[ \n\t]+/', ' ', $value)); $this->pdfDoc->appendText(' "'.$value.'"'); return ""; } public function format_refname_text($value, $tag) { $this->cchunk["refname"][] = $value; - $this->pdfDoc->appendText(trim(ereg_replace( "[ \n\t]+", ' ', $value))); + $this->pdfDoc->appendText(trim(preg_replace('/[ \n\t]+/', ' ', $value))); return ""; } http://cvs.php.net/viewvc.cgi/phd/themes/php/phppdf.php?r1=1.8&r2=1.9&diff_format=u Index: phd/themes/php/phppdf.php diff -u phd/themes/php/phppdf.php:1.8 phd/themes/php/phppdf.php:1.9 --- phd/themes/php/phppdf.php:1.8 Sun Oct 19 14:25:39 2008 +++ phd/themes/php/phppdf.php Sat Jan 24 21:50:08 2009 @@ -1,8 +1,8 @@ <?php -/* $Id: phppdf.php,v 1.8 2008/10/19 14:25:39 bjori Exp $ */ +/* $Id: phppdf.php,v 1.9 2009/01/24 21:50:08 cweiske Exp $ */ class phppdf extends PhDTheme { - + protected $elementmap = array( 'article' => 'format_tocnode_newpage', 'appendix' => 'format_tocnode_newpage', @@ -79,14 +79,14 @@ ); - - + + private $acronyms = array(); - + /* Common properties for all functions pages */ protected $bookName = ""; protected $outputdir = ""; - + /* Current Chunk settings */ protected $cchunk = array(); /* Default Chunk settings */ @@ -99,7 +99,7 @@ "id-to-page" => array(), "root-outline" => null, ); - + public function __construct(array $IDs, array $filenames, $format = "pdf", $chunked = true) { parent::__construct($IDs); $this->format = $format; @@ -107,17 +107,17 @@ $this->outputdir = PhDConfig::output_dir() . $this->format . DIRECTORY_SEPARATOR; if(!file_exists($this->outputdir) || is_file($this->outputdir)) mkdir($this->outputdir) or die("Can't create the cache directory.\n"); } - + public function __destruct() {} - - + + // Do nothing public function appendData($data, $isChunk) {} - + // To override public function format_root_set($open, $name, $attrs, $props) {} public function format_set($open, $name, $attrs, $props) {} - + public function format_book($open, $name, $attrs, $props) { if ($open) { $this->format->newChunk(); @@ -125,15 +125,15 @@ $pdfDoc = new PdfWriter(); try { $pdfDoc->setCompressionMode(HaruDoc::COMP_ALL); - } catch (HaruException $e) { + } catch (HaruException $e) { v("PDF Compression failed, you need to compile libharu with Zlib...", E_USER_WARNING); } $this->format->setPdfDoc($pdfDoc); if (isset($attrs[PhDReader::XMLNS_XML]["base"]) && $base = $attrs[PhDReader::XMLNS_XML]["base"]) $this->format->setChunkInfo("xml-base", $base); - + $id = $attrs[PhDReader::XMLNS_XML]["id"]; - $this->cchunk["root-outline"] = $this->cchunk["id-to-outline"][$id] = + $this->cchunk["root-outline"] = $this->cchunk["id-to-outline"][$id] = $pdfDoc->createOutline(PhDHelper::getDescription($id), null, true); $this->setIdToPage($id); } else { @@ -145,28 +145,28 @@ } return false; } - + public function format_bookname($value, $tag) { $this->cchunk["bookname"] = trim($value); $this->format->getPdfDoc()->setCurrentBookName($this->cchunk["bookname"]); return false; } - + public function format_setname($value, $tag) { $this->cchunk["setname"] = trim($value); return false; } - + public function format_tocnode($open, $name, $attrs, $props, $newpage = false) { if ($open) { if ($newpage) $this->format->getPdfDoc()->add(PdfWriter::PAGE); - else + else $this->format->getPdfDoc()->add(PdfWriter::LINE_JUMP); - + if (isset($attrs[PhDReader::XMLNS_XML]["base"]) && $base = $attrs[PhDReader::XMLNS_XML]["base"]) $this->format->setChunkInfo("xml-base", $base); - + if (isset($attrs[PhDReader::XMLNS_XML]["id"]) && $id = $attrs[PhDReader::XMLNS_XML]["id"]) { $parentId = PhDHelper::getParent($id); if (isset($this->cchunk["id-to-outline"][$parentId])) { @@ -182,14 +182,14 @@ } return ""; } - + public function format_tocnode_newpage($open, $name, $attrs, $props) { return $this->format_tocnode($open, $name, $attrs, $props, true); - } - + } + public function format_tocnode_exception($open, $name, $attrs, $props) { return $this->format_tocnode($open, "reference", $attrs, $props, true); - } + } public function format_tocnode_class($open, $name, $attrs, $props) { return $this->format_tocnode($open, "reference", $attrs, $props, true); @@ -198,18 +198,18 @@ public function format_grep_classname_text($value, $tag) { $this->cchunk["phpdoc:classref"] = strtolower($value); } - + // Convert the book name to a Unix valid filename protected function toValidName($functionName) { return str_replace(array(":", "::", "->", "/", "\\", " "), array(".", ".", ".", "-", "-", "-"), $functionName); - } - + } + protected function setIdToPage($id) { if (isset($this->cchunk["id-to-page"]) && is_array($this->cchunk["id-to-page"])) { $this->cchunk["id-to-page"][$id] = $this->format->getPdfDoc()->getCurrentPage(); } } - + protected function resolveLinks($name) { v("Resolving Internal Links... (%s)", $name, VERBOSE_TOC_WRITING); $linksToResolve = $this->format->getChunkInfo("links-to-resolve"); @@ -223,10 +223,10 @@ } } } - } - + } + public function format_type_text($type, $tagname) { - $type = trim(ereg_replace( "[ \n\t]+", ' ', $type)); + $type = trim(preg_replace('/[ \n\t]+/', ' ', $type)); $t = strtolower($type); $href = $fragment = ""; @@ -272,14 +272,14 @@ $this->format->getPdfDoc()->revertFont(); return ''; } - + public function format_type_if_object_or_pseudo_text($type, $tagname) { if (in_array(strtolower($type), array("bool", "int", "double", "boolean", "integer", "float", "string", "array", "object", "resource", "null"))) { return false; } return self::format_type_text($type, $tagname); } - + public function format_collect_id($open, $name, $attrs, $props, $newpage = false) { if ($open && isset($attrs[PhDReader::XMLNS_XML]["id"]) && $id = $attrs[PhDReader::XMLNS_XML]["id"]) { $this->setIdToPage($id);
http://cvs.php.net/viewvc.cgi/phd/formats/pdf.php?r1=1.8&r2=1.9&diff_format=u Index: phd/formats/pdf.php diff -u phd/formats/pdf.php:1.8 phd/formats/pdf.php:1.9 --- phd/formats/pdf.php:1.8 Fri Nov 7 23:46:17 2008 +++ phd/formats/pdf.php Sat Jan 24 21:50:08 2009 @@ -334,7 +334,7 @@ return ""; } - $ret = utf8_decode(trim(ereg_replace( "[ \n\t]+", ' ', $str))); + $ret = utf8_decode(trim(preg_replace('/[ \n\t]+/', ' ', $str))); // No whitespace if current text value begins with ',', ';', ':', '.' if (strncmp($ret, ",", 1) && strncmp($ret, ";", 1) && strncmp($ret, ":", 1) && strncmp($ret, ".", 1)) $this->pdfDoc->appendText(" " . $ret); @@ -572,7 +572,7 @@ } public function format_link_text($value, $tag) { - $value = trim(ereg_replace( "[ \n\t]+", ' ', $value)); + $value = trim(preg_replace('/[ \n\t]+/', ' ', $value)); if (isset($this->cchunk["href"]) && $this->cchunk["href"]) { $this->pdfDoc->add(PdfWriter::URL_ANNOTATION, array(chr(187) . chr(160) . $value, $this->cchunk["href"])); // links with >> symbol } elseif (isset($this->cchunk["linkend"]) && $linkend = $this->cchunk["linkend"]) { @@ -586,7 +586,7 @@ } public function format_function_text($value, $tag, $display_value = null) { - $value = trim(ereg_replace( "[ \n\t]+", ' ', $value)); + $value = trim(preg_replace('/[ \n\t]+/', ' ', $value)); if ($display_value === null) { $display_value = $value; } @@ -1076,14 +1076,14 @@ // }}} Footnotes & Callouts public function format_quote_text($value, $tag) { - $value = trim(ereg_replace( "[ \n\t]+", ' ', $value)); + $value = trim(preg_replace('/[ \n\t]+/', ' ', $value)); $this->pdfDoc->appendText(' "'.$value.'"'); return ""; } public function format_refname_text($value, $tag) { $this->cchunk["refname"][] = $value; - $this->pdfDoc->appendText(trim(ereg_replace( "[ \n\t]+", ' ', $value))); + $this->pdfDoc->appendText(trim(preg_replace('/[ \n\t]+/', ' ', $value))); return ""; } http://cvs.php.net/viewvc.cgi/phd/themes/php/phppdf.php?r1=1.8&r2=1.9&diff_format=u Index: phd/themes/php/phppdf.php diff -u phd/themes/php/phppdf.php:1.8 phd/themes/php/phppdf.php:1.9 --- phd/themes/php/phppdf.php:1.8 Sun Oct 19 14:25:39 2008 +++ phd/themes/php/phppdf.php Sat Jan 24 21:50:08 2009 @@ -1,8 +1,8 @@ <?php -/* $Id: phppdf.php,v 1.8 2008/10/19 14:25:39 bjori Exp $ */ +/* $Id: phppdf.php,v 1.9 2009/01/24 21:50:08 cweiske Exp $ */ class phppdf extends PhDTheme { - + protected $elementmap = array( 'article' => 'format_tocnode_newpage', 'appendix' => 'format_tocnode_newpage', @@ -79,14 +79,14 @@ ); - - + + private $acronyms = array(); - + /* Common properties for all functions pages */ protected $bookName = ""; protected $outputdir = ""; - + /* Current Chunk settings */ protected $cchunk = array(); /* Default Chunk settings */ @@ -99,7 +99,7 @@ "id-to-page" => array(), "root-outline" => null, ); - + public function __construct(array $IDs, array $filenames, $format = "pdf", $chunked = true) { parent::__construct($IDs); $this->format = $format; @@ -107,17 +107,17 @@ $this->outputdir = PhDConfig::output_dir() . $this->format . DIRECTORY_SEPARATOR; if(!file_exists($this->outputdir) || is_file($this->outputdir)) mkdir($this->outputdir) or die("Can't create the cache directory.\n"); } - + public function __destruct() {} - - + + // Do nothing public function appendData($data, $isChunk) {} - + // To override public function format_root_set($open, $name, $attrs, $props) {} public function format_set($open, $name, $attrs, $props) {} - + public function format_book($open, $name, $attrs, $props) { if ($open) { $this->format->newChunk(); @@ -125,15 +125,15 @@ $pdfDoc = new PdfWriter(); try { $pdfDoc->setCompressionMode(HaruDoc::COMP_ALL); - } catch (HaruException $e) { + } catch (HaruException $e) { v("PDF Compression failed, you need to compile libharu with Zlib...", E_USER_WARNING); } $this->format->setPdfDoc($pdfDoc); if (isset($attrs[PhDReader::XMLNS_XML]["base"]) && $base = $attrs[PhDReader::XMLNS_XML]["base"]) $this->format->setChunkInfo("xml-base", $base); - + $id = $attrs[PhDReader::XMLNS_XML]["id"]; - $this->cchunk["root-outline"] = $this->cchunk["id-to-outline"][$id] = + $this->cchunk["root-outline"] = $this->cchunk["id-to-outline"][$id] = $pdfDoc->createOutline(PhDHelper::getDescription($id), null, true); $this->setIdToPage($id); } else { @@ -145,28 +145,28 @@ } return false; } - + public function format_bookname($value, $tag) { $this->cchunk["bookname"] = trim($value); $this->format->getPdfDoc()->setCurrentBookName($this->cchunk["bookname"]); return false; } - + public function format_setname($value, $tag) { $this->cchunk["setname"] = trim($value); return false; } - + public function format_tocnode($open, $name, $attrs, $props, $newpage = false) { if ($open) { if ($newpage) $this->format->getPdfDoc()->add(PdfWriter::PAGE); - else + else $this->format->getPdfDoc()->add(PdfWriter::LINE_JUMP); - + if (isset($attrs[PhDReader::XMLNS_XML]["base"]) && $base = $attrs[PhDReader::XMLNS_XML]["base"]) $this->format->setChunkInfo("xml-base", $base); - + if (isset($attrs[PhDReader::XMLNS_XML]["id"]) && $id = $attrs[PhDReader::XMLNS_XML]["id"]) { $parentId = PhDHelper::getParent($id); if (isset($this->cchunk["id-to-outline"][$parentId])) { @@ -182,14 +182,14 @@ } return ""; } - + public function format_tocnode_newpage($open, $name, $attrs, $props) { return $this->format_tocnode($open, $name, $attrs, $props, true); - } - + } + public function format_tocnode_exception($open, $name, $attrs, $props) { return $this->format_tocnode($open, "reference", $attrs, $props, true); - } + } public function format_tocnode_class($open, $name, $attrs, $props) { return $this->format_tocnode($open, "reference", $attrs, $props, true); @@ -198,18 +198,18 @@ public function format_grep_classname_text($value, $tag) { $this->cchunk["phpdoc:classref"] = strtolower($value); } - + // Convert the book name to a Unix valid filename protected function toValidName($functionName) { return str_replace(array(":", "::", "->", "/", "\\", " "), array(".", ".", ".", "-", "-", "-"), $functionName); - } - + } + protected function setIdToPage($id) { if (isset($this->cchunk["id-to-page"]) && is_array($this->cchunk["id-to-page"])) { $this->cchunk["id-to-page"][$id] = $this->format->getPdfDoc()->getCurrentPage(); } } - + protected function resolveLinks($name) { v("Resolving Internal Links... (%s)", $name, VERBOSE_TOC_WRITING); $linksToResolve = $this->format->getChunkInfo("links-to-resolve"); @@ -223,10 +223,10 @@ } } } - } - + } + public function format_type_text($type, $tagname) { - $type = trim(ereg_replace( "[ \n\t]+", ' ', $type)); + $type = trim(preg_replace('/[ \n\t]+/', ' ', $type)); $t = strtolower($type); $href = $fragment = ""; @@ -272,14 +272,14 @@ $this->format->getPdfDoc()->revertFont(); return ''; } - + public function format_type_if_object_or_pseudo_text($type, $tagname) { if (in_array(strtolower($type), array("bool", "int", "double", "boolean", "integer", "float", "string", "array", "object", "resource", "null"))) { return false; } return self::format_type_text($type, $tagname); } - + public function format_collect_id($open, $name, $attrs, $props, $newpage = false) { if ($open && isset($attrs[PhDReader::XMLNS_XML]["id"]) && $id = $attrs[PhDReader::XMLNS_XML]["id"]) { $this->setIdToPage($id);