diff --git a/HOWTO.RELEASE b/HOWTO.RELEASE index 2fba186e9..a4e73bab3 100644 --- a/HOWTO.RELEASE +++ b/HOWTO.RELEASE @@ -55,7 +55,7 @@ Releases are currently made from the PHD_1_1 branch. A. Remove all contents from and increase version/release. Change stability back to "snapshot". If needed, revert PHD_VERSION in - config.php (VERSION in phpdotnet/phd/Config) back to "phd-from-svn". + config.php (VERSION in src/Config) back to "phd-from-svn". B. Hack on. diff --git a/composer.json b/composer.json index c69261080..cf8b62a90 100644 --- a/composer.json +++ b/composer.json @@ -21,14 +21,23 @@ "php": ">=7.1.0", "ext-dom": "*", "ext-sqlite3": "*", - "ext-xmlreader": "*" + "ext-xmlreader": "*", + "ext-simplexml": "*" }, "suggest": { "easybook/geshi": "For using GeSHi as code highlighter" }, "autoload": { - "psr-0": { - "phpdotnet\\": "." + "psr-4": { + "phpdotnet\\phd\\": "src/" + }, + "files": [ + "src/functions.php" + ] + }, + "autoload-dev": { + "psr-4": { + "phpdotnet\\phd\\test\\": "tests/" } } } diff --git a/composer.lock b/composer.lock index 99790ed43..6fd353d89 100644 --- a/composer.lock +++ b/composer.lock @@ -1,10 +1,10 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "0a86baeef26e4be1985b6083fa956efe", + "content-hash": "2d8f035847c1a5817425faefeb572809", "packages": [], "packages-dev": [], "aliases": [], @@ -16,7 +16,9 @@ "php": ">=7.1.0", "ext-dom": "*", "ext-sqlite3": "*", - "ext-xmlreader": "*" + "ext-xmlreader": "*", + "ext-simplexml": "*" }, - "platform-dev": [] + "platform-dev": [], + "plugin-api-version": "2.1.0" } diff --git a/package_ide.xml b/package_ide.xml index 197ebc988..ed3a4eb08 100644 --- a/package_ide.xml +++ b/package_ide.xml @@ -97,7 +97,7 @@ - + diff --git a/phpdotnet/phd/Autoloader.php b/phpdotnet/phd/Autoloader.php deleted file mode 100644 index 05f1c40b9..000000000 --- a/phpdotnet/phd/Autoloader.php +++ /dev/null @@ -1,36 +0,0 @@ -pdfDoc; - } - - public function setPdfDoc($pdfDoc) { - $this->pdfDoc = $pdfDoc; - } - - public function UNDEF($open, $name, $attrs, $props) { - if ($open) { - trigger_error("No mapper found for '{$name}'", E_USER_WARNING); - } - $this->pdfDoc->setFont(PdfWriter::FONT_NORMAL, 14, array(1, 0, 0)); // Helvetica 14 red - $this->pdfDoc->appendText(($open ? "<" : ""); - $this->pdfDoc->revertFont(); - return ""; - } - - public function CDATA($str) { - $this->pdfDoc->appendText(utf8_decode(trim($str))); - return ""; - } - - public function transformFromMap($open, $tag, $name, $attrs, $props) { - return ""; - } - - public function createLink($for, &$desc = null, $type = Format::SDESC){} - - public function TEXT($str) {} - -} - -class PdfWriter { - // Font type constants (for setFont()) - const FONT_NORMAL = 0x01; - const FONT_ITALIC = 0x02; - const FONT_BOLD = 0x03; - const FONT_VERBATIM = 0x04; - const FONT_VERBATIM_ITALIC = 0x05; - const FONT_MANUAL = 0x06; - - // "Objects" constants (for add()) - const PARA = 0x10; - const INDENTED_PARA = 0x11; - const TITLE = 0x12; - const DRAW_LINE = 0x13; - const LINE_JUMP = 0x14; - const PAGE = 0x15; - const TITLE2 = 0x16; - const VERBATIM_BLOCK = 0x17; - const ADMONITION = 0x18; - const ADMONITION_CONTENT = 0x19; - const END_ADMONITION = 0x1A; - const URL_ANNOTATION = 0x1B; - const LINK_ANNOTATION = 0x1C; - const ADD_BULLET = 0x1D; - const FRAMED_BLOCK = 0x1E; - const END_FRAMED_BLOCK = 0x1F; - const TITLE3 = 0x20; - const TABLE = 0x21; - const TABLE_ROW = 0x22; - const TABLE_ENTRY = 0x23; - const TABLE_END_ENTRY = 0x24; - const END_TABLE = 0x25; - const TABLE_END_ROW = 0x26; - const ADD_NUMBER_ITEM = 0x27; - const IMAGE = 0x28; - - // Page format - const VMARGIN = 56.7; // = 1 centimeter - const HMARGIN = 56.7; // = 1 centimeter - const LINE_SPACING = 2; // nb of points between two lines - const INDENT_SPACING = 10; // nb of points for indent - const DEFAULT_SHIFT = 20; // default value (points) for shifted paragraph - private $SCALE; // nb of points for 1 centimeter - private $PAGE_WIDTH; // in points - private $PAGE_HEIGHT; // in points - - private $haruDoc; - private $pages = array(); - private $currentPage; - private $currentPageNumber; - private $currentBookName; - - private $currentFont; - private $currentFontSize; - private $currentFontColor; - private $fonts; - private $oldFonts = array(); - private $text; - - private $vOffset = 0; - private $hOffset = 0; - private $lastPage = array( - "vOffset" => 0, - "hOffset" => 0, - ); - private $permanentLeftSpacing = 0; - private $permanentRightSpacing = 0; - - private $appendToBuffer = false; - // To append afterwards - private $buffer = array( - /* array( - 'text' => "", - 'font' => "", - 'size' => "", - 'color' => "", - )*/ - ); - - private $current = array( - "leftSpacing" => 0, - "rightSpacing" => 0, - "oldVPosition" => 0, - "vOffset" => 0, - "newVOffset" => 0, - "pages" => array(), - "row" => array(), - "align" => "", - "char" => "", - "charOffset" => 0, - ); - - // To temporarily store $current(s) - private $old = array(); - - function __construct($pageWidth = 210, $pageHeight = 297) { - // Initialization of properties - $this->haruDoc = new \HaruDoc; - $this->haruDoc->addPageLabel(1, \HaruPage::NUM_STYLE_DECIMAL, 1, "Page "); - - $this->haruDoc->setPageMode(\HaruDoc::PAGE_MODE_USE_OUTLINE); - $this->haruDoc->setPagesConfiguration(2); - - // Page format - $this->SCALE = 72/25.4; - $this->PAGE_WIDTH = $pageWidth * $this->SCALE; - $this->PAGE_HEIGHT = $pageHeight * $this->SCALE; - - // Set fonts - $this->fonts["Helvetica"] = $this->haruDoc->getFont("Helvetica", "WinAnsiEncoding"); - $this->fonts["Helvetica-Bold"] = $this->haruDoc->getFont("Helvetica-Bold", "WinAnsiEncoding"); - $this->fonts["Helvetica-Oblique"] = $this->haruDoc->getFont("Helvetica-Oblique", "WinAnsiEncoding"); - $this->fonts["Courier"] = $this->haruDoc->getFont("Courier", "WinAnsiEncoding"); - $this->fonts["Courier-Oblique"] = $this->haruDoc->getFont("Courier-Oblique", "WinAnsiEncoding"); - - // Add first page and default font settings - $this->currentFont = $this->fonts["Helvetica"]; - $this->currentFontSize = 12; - $this->currentFontColor = array(0, 0, 0); // Black - $this->nextPage(); - $this->haruDoc->addPageLabel(1, \HaruPage::NUM_STYLE_DECIMAL, 1, "Page "); - } - - public function getCurrentPage() { - return $this->currentPage; - } - - public function setCompressionMode($mode) { - $this->haruDoc->setCompressionMode($mode); - } - - // Append text into the current position - public function appendText($text) { -// if ($this->vOffset > $this->current["charOffset"] + 3*LINE_SPACING + 3*$this->currentFontSize) -// $this->vOffset = $this->current["charOffset"] + 3*LINE_SPACING + 3*$this->currentFontSize; - if ($this->appendToBuffer) { - array_push($this->buffer, array( - "text" => $text, - "font" => $this->currentFont, - "size" => $this->currentFontSize, - "color" => $this->currentFontColor - )); - return; - } - - $this->currentPage->beginText(); - do { - // Clear the whitespace if it begins the line or if last char is a special char - if (strpos($text, " ") === 0 && ($this->hOffset == 0 || in_array($this->current["char"], array("&", "$")))) { - $text = substr($text, 1); - } - - // Number of chars allowed in the current line - $nbCarac = $this->currentFont->measureText($text, - ($this->PAGE_WIDTH - 2*self::HMARGIN - $this->hOffset - $this->permanentLeftSpacing - $this->permanentRightSpacing), - $this->currentFontSize, $this->currentPage->getCharSpace(), - $this->currentPage->getWordSpace(), true); - - // If a the text content can't be appended (either there is no whitespaces, - // either the is not enough space in the line) - if ($nbCarac === 0) { - $isEnoughSpaceOnNextLine = $this->currentFont->measureText($text, - ($this->PAGE_WIDTH - 2*self::HMARGIN - $this->permanentLeftSpacing - $this->permanentRightSpacing), - $this->currentFontSize, $this->currentPage->getCharSpace(), - $this->currentPage->getWordSpace(), true); - if ($isEnoughSpaceOnNextLine) { - $this->vOffset += $this->currentFontSize + self::LINE_SPACING; - $this->hOffset = 0; - $isLastLine = false; - continue; - } else { - $nbCarac = $this->currentFont->measureText($text, - ($this->PAGE_WIDTH - 2*self::HMARGIN - $this->hOffset - $this->permanentLeftSpacing - $this->permanentRightSpacing), - $this->currentFontSize, $this->currentPage->getCharSpace(), - $this->currentPage->getWordSpace(), false); - } - } - $isLastLine = ($nbCarac == strlen($text)); - - $textToAppend = substr($text, 0, $nbCarac); - $text = substr($text, $nbCarac); - - // Append text (in a new page if needed) with align - if ($this->PAGE_HEIGHT - (self::VMARGIN + $this->vOffset) < self::VMARGIN) { - $this->currentPage->endText(); - $this->current["pages"][] = $this->currentPage; - $this->nextPage(); - $this->currentPage->beginText(); - } - if ($this->current["align"] == "center") { - $spacing = $this->PAGE_WIDTH - 2*self::HMARGIN - - $this->permanentLeftSpacing - $this->permanentRightSpacing - $this->currentPage->getTextWidth($textToAppend); - $this->currentPage->textOut(self::HMARGIN + $this->hOffset + $this->permanentLeftSpacing + $spacing/2, - $this->PAGE_HEIGHT - (self::VMARGIN + $this->vOffset), $textToAppend); - } elseif ($this->current["align"] == "right") { - $spacing = $this->PAGE_WIDTH - 2*self::HMARGIN - - $this->permanentLeftSpacing - $this->permanentRightSpacing - $this->currentPage->getTextWidth($textToAppend); - $this->currentPage->textOut(self::HMARGIN + $this->hOffset + $this->permanentLeftSpacing + $spacing, - $this->PAGE_HEIGHT - (self::VMARGIN + $this->vOffset), $textToAppend); - } else { // left - $this->currentPage->textOut(self::HMARGIN + $this->hOffset + $this->permanentLeftSpacing, - $this->PAGE_HEIGHT - (self::VMARGIN + $this->vOffset), $textToAppend); - } - if ($textToAppend) - $this->current["char"] = $textToAppend{strlen($textToAppend)-1}; - - // Offsets for next line - if (!$isLastLine) { - $this->vOffset += $this->currentFontSize + self::LINE_SPACING; - $this->hOffset = 0; - } else { - $this->hOffset += $this->currentPage->getTextWidth($textToAppend); - } - - } - while(!$isLastLine); // While it remains chars to append - $this->currentPage->endText(); - $this->current["charOffset"] = $this->vOffset; - } - - // Same function one line at a time - public function appendOneLine($text) { - if (strpos($text, " ") === 0 && ($this->hOffset == 0 || in_array($this->current["char"], array("&", "$")))) { - $text = substr($text, 1); - } - - $this->currentPage->beginText(); - $nbCarac = $this->currentFont->measureText($text, - ($this->PAGE_WIDTH - 2*self::HMARGIN - $this->hOffset - $this->permanentLeftSpacing - $this->permanentRightSpacing), - $this->currentFontSize, $this->currentPage->getCharSpace(), - $this->currentPage->getWordSpace(), true); - - // If a the text content can't be appended (either there is no whitespaces, - // either the is not enough space in the line) - if ($nbCarac === 0) { - $isEnoughSpaceOnNextLine = $this->currentFont->measureText($text, - ($this->PAGE_WIDTH - 2*self::HMARGIN - $this->permanentLeftSpacing - $this->permanentRightSpacing), - $this->currentFontSize, $this->currentPage->getCharSpace(), - $this->currentPage->getWordSpace(), true); - if ($isEnoughSpaceOnNextLine) { - $this->currentPage->endText(); - return $text; - } else { - $nbCarac = $this->currentFont->measureText($text, - ($this->PAGE_WIDTH - 2*self::HMARGIN - $this->hOffset - $this->permanentLeftSpacing - $this->permanentRightSpacing), - $this->currentFontSize, $this->currentPage->getCharSpace(), - $this->currentPage->getWordSpace(), false); - } - } - - $isLastLine = ($nbCarac == strlen($text)); - - $textToAppend = substr($text, 0, $nbCarac); - $text = substr($text, $nbCarac); - - // Append text (in a new page if needed) - if ($this->PAGE_HEIGHT - (self::VMARGIN + $this->vOffset) < self::VMARGIN) { - $this->currentPage->endText(); - $this->current["pages"][] = $this->currentPage; - $this->nextPage(); - $this->currentPage->beginText(); - } - $this->currentPage->textOut(self::HMARGIN + $this->hOffset + $this->permanentLeftSpacing, - $this->PAGE_HEIGHT - (self::VMARGIN + $this->vOffset), $textToAppend); - if ($textToAppend) - $this->current["char"] = $textToAppend{strlen($textToAppend)-1}; - - $this->hOffset += $this->currentPage->getTextWidth($textToAppend); - - $this->currentPage->endText(); - $this->current["charOffset"] = $this->vOffset; - - return ($isLastLine ? null : $text); - } - - public function setAppendToBuffer($appendToBuffer) { - $this->appendToBuffer = $appendToBuffer; - } - - public function appendBufferNow() { - foreach($this->buffer as $row) { - if ($row["text"] == "\n") { - $this->lineJump(); - } else { - $this->setFont(self::FONT_MANUAL, $row["size"], $row["color"], $row["font"]); - $this->appendText($row["text"]); - $this->revertFont(); - } - } - $this->buffer = array(); - } - - public function add($type, $option = null) { - if ($this->appendToBuffer) return; - switch ($type) { - case self::INDENTED_PARA: - $this->lineJump(); - $this->indent(); - break; - case self::PARA: - $this->lineJump(); - break; - case self::VERBATIM_BLOCK: - $this->setFont(self::FONT_VERBATIM, 10, array(0.3, 0.3, 0.3)); - $this->lineJump(); - break; - case self::TITLE: - $this->setFont(self::FONT_BOLD, 20); - $this->lineJump(); - break; - case self::TITLE2: - $this->setFont(self::FONT_BOLD, 14); - $this->lineJump(); - break; - case self::TITLE3: - $this->setFont(self::FONT_BOLD, 12); - $this->lineJump(); - break; - case self::DRAW_LINE: - $this->traceLine($option); - break; - case self::LINE_JUMP: - if ($option) - $this->lineJump($option); - else $this->lineJump(); - break; - case self::PAGE: - $this->nextPage(); - break; - case self::ADMONITION: - $this->beginAdmonition(); - break; - case self::ADMONITION_CONTENT: - $this->admonitionContent(); - break; - case self::END_ADMONITION: - $this->endAdmonition(); - break; - case self::URL_ANNOTATION: - $this->appendUrlAnnotation($option[0], $option[1]); - break; - case self::LINK_ANNOTATION: - return $this->prepareInternalLinkAnnotation($option); - break; - case self::ADD_BULLET: - $this->indent(-self::INDENT_SPACING-$this->currentPage->getTextWidth(chr(149))); - $this->appendText(chr(149)); // ANSI Bullet - $this->indent(0); - break; - case self::ADD_NUMBER_ITEM: - $this->indent(-self::INDENT_SPACING-$this->currentPage->getTextWidth($option)); - $this->appendText($option); - $this->indent(0); - break; - case self::FRAMED_BLOCK: - $this->beginFrame(); - break; - case self::END_FRAMED_BLOCK: - $this->endFrame($option); - break; - case self::TABLE: - $this->addTable($option); - break; - case self::END_TABLE: - $this->endTable(); - break; - case self::TABLE_ROW: - $this->newTableRow($option[0], $option[1]); - break; - case self::TABLE_END_ROW: - $this->endTableRow(); - break; - case self::TABLE_ENTRY: - $this->beginTableEntry($option[0], $option[1], $option[2]); - break; - case self::TABLE_END_ENTRY: - $this->endTableEntry(); - break; - case self::IMAGE: - $this->addImage($option); - break; - default: - trigger_error("Unknown object type : {$type}", E_USER_WARNING); - break; - } - } - - // Switch font on-the-fly - public function setFont($type, $size = null, $color = null, $font = null) { - if ($this->currentPage == null) - return false; - $this->oldFonts[] = array($this->currentFont, $this->currentFontSize, $this->currentFontColor); - $this->currentFontSize = ($size ? $size : $this->currentFontSize); - if ($color && count($color) === 3) { - $this->setColor($color[0], $color[1], $color[2]); - $this->currentFontColor = $color; - } - else - $this->setColor($this->currentFontColor[0], $this->currentFontColor[1], $this->currentFontColor[2]); - switch ($type) { - case self::FONT_NORMAL: - $this->currentPage->setFontAndSize($this->currentFont = $this->fonts["Helvetica"], - $this->currentFontSize); - break; - case self::FONT_ITALIC: - $this->currentPage->setFontAndSize($this->currentFont = $this->fonts["Helvetica-Oblique"], - $this->currentFontSize); - break; - case self::FONT_BOLD: - $this->currentPage->setFontAndSize($this->currentFont = $this->fonts["Helvetica-Bold"], - $this->currentFontSize); - break; - case self::FONT_VERBATIM: - $this->currentPage->setFontAndSize($this->currentFont = $this->fonts["Courier"], - $this->currentFontSize); - break; - case self::FONT_VERBATIM_ITALIC: - $this->currentPage->setFontAndSize($this->currentFont = $this->fonts["Courier-Oblique"], - $this->currentFontSize); - break; - case self::FONT_MANUAL: - $this->currentPage->setFontAndSize($this->currentFont = $font, $this->currentFontSize); - break; - default: - trigger_error("Unknown font type : {$type}", E_USER_WARNING); - break; - } - } - - // Back to the last used font - public function revertFont() { - $lastFont = array_pop($this->oldFonts); - $this->currentFont = $lastFont[0]; - $this->currentFontSize = $lastFont[1]; - $this->currentFontColor = $lastFont[2]; - $this->currentPage->setFontAndSize($lastFont[0], $lastFont[1]); - $this->setColor($lastFont[2][0], $lastFont[2][1], $lastFont[2][2]); - } - - // Change font color (1, 1, 1 = white, 0, 0, 0 = black) - public function setColor($r, $g, $b) { - if ($r < 0 || $r > 1 || $g < 0 || $g > 1 || $b < 0 || $b > 1) - return false; - $this->currentPage->setRGBStroke($r, $g, $b); - $this->currentPage->setRGBFill($r, $g, $b); - $this->currentFontColor = array($r, $g, $b); - return true; - } - - // Save the current PDF Document to a file - public function saveToFile($filename) { - $this->haruDoc->save($filename); - } - - public function createOutline($description, $parentOutline = null, $opened = false) { - $outline = $this->haruDoc->createOutline($description, $parentOutline); - $dest = $this->currentPage->createDestination(); - $dest->setXYZ(0, $this->currentPage->getHeight(), 1); - $outline->setDestination($dest); - $outline->setOpened($opened); - return $outline; - } - - public function shift($offset = self::DEFAULT_SHIFT) { - $this->permanentLeftSpacing += $offset; - } - - public function unshift($offset = self::DEFAULT_SHIFT) { - $this->permanentLeftSpacing -= $offset; - } - - public function vOffset($offset) { - $this->vOffset += $offset; - } - - private function indent($offset = self::INDENT_SPACING) { - $this->hOffset = $offset; - } - - // Jump to next page (or create a new one if none exists) - private function nextPage() { - $this->lastPage = array( - "vOffset" => $this->vOffset, - "hOffset" => $this->hOffset, - ); - $footerToAppend = false; - $this->currentPageNumber++; - if (isset($this->pages[$this->currentPageNumber])) { - $this->currentPage = $this->pages[$this->currentPageNumber]; - $this->vOffset = $this->currentFontSize; - $this->hOffset = 0; - } else { - $this->pages[$this->currentPageNumber] = $this->haruDoc->addPage(); - $this->currentPage = $this->pages[$this->currentPageNumber]; - $this->currentPage->setTextRenderingMode(\HaruPage::FILL); - $this->vOffset = $this->currentFontSize; - $this->hOffset = ($this->hOffset ? $this->hOffset : 0); - $footerToAppend = true; - } - if ($this->currentFont && $this->currentFontSize && $this->currentFontColor) { - $this->currentPage->setFontAndSize($this->currentFont, $this->currentFontSize); - $this->setColor($this->currentFontColor[0], $this->currentFontColor[1], $this->currentFontColor[2]); - } - if ($footerToAppend && $this->currentPageNumber > 1) { - $this->currentPage->beginText(); - $this->setFont(self::FONT_NORMAL, 12, array(0,0,0)); - $this->currentPage->textOut($this->PAGE_WIDTH - self::HMARGIN - $this->currentPage->getTextWidth($this->currentPageNumber), - self::VMARGIN - 30, $this->currentPageNumber); - $this->revertFont(); - $this->setFont(self::FONT_BOLD, 12, array(0,0,0)); - $this->currentPage->textOut(self::HMARGIN, - self::VMARGIN - 30, $this->currentBookName); - $this->revertFont(); - $this->currentPage->endText(); - - } - - } - - public function setCurrentBookName($currentBookName) { - $this->currentBookName = $currentBookName; - } - - // Set last page as the current page - private function lastPage() { - $this->currentPageNumber--; - $this->currentPage = $this->pages[$this->currentPageNumber]; - $this->vOffset = $this->lastPage["vOffset"]; - $this->hOffset = $this->lastPage["hOffset"]; - } - - // Returns true if a next page exists - private function isNextPage() { - return isset($this->pages[$this->currentPageNumber + 1]); - } - - // Jump a line - private function lineJump($nbLines = 1) { - $this->vOffset += $nbLines * ($this->currentFontSize + self::LINE_SPACING); - $this->hOffset = 0; - } - - // Trace a line from the current position - private function traceLine() { - $this->lineJump(); - $this->currentPage->rectangle(self::HMARGIN + $this->hOffset, $this->PAGE_HEIGHT - self::VMARGIN - $this->vOffset, $this->PAGE_WIDTH - 2*$this->hOffset - 2*self::HMARGIN, 1); - $this->currentPage->stroke(); - } - - private function beginAdmonition() { - // If this admonition is inside another frame - array_push($this->old, $this->current); - - $this->setFont(self::FONT_BOLD, 12); - $this->lineJump(); - // If no space for admonition title + interleave + admonition first line on this page, then creates a new one - if (($this->PAGE_HEIGHT - 2*self::VMARGIN - $this->vOffset) < (3*$this->currentFontSize + 3*self::LINE_SPACING)) - $this->nextPage(); - $this->current["vOffset"] = $this->vOffset; - $this->lineJump(); - $this->permanentLeftSpacing += self::INDENT_SPACING; - $this->permanentRightSpacing += self::INDENT_SPACING; - $this->current["pages"] = array(); - } - - private function admonitionContent() { - if ($this->current["pages"]) - $this->current["vOffset"] = 0; - $this->beginFrame(); - $this->revertFont(); - $this->currentPage->rectangle(self::HMARGIN + ($this->permanentLeftSpacing - self::INDENT_SPACING), - $this->PAGE_HEIGHT - self::VMARGIN - $this->vOffset, - $this->PAGE_WIDTH - 2*self::HMARGIN - ($this->permanentLeftSpacing - self::INDENT_SPACING) - ($this->permanentRightSpacing - self::INDENT_SPACING), - $this->vOffset - $this->current["vOffset"]); - $this->currentPage->stroke(); - } - - private function endAdmonition() { - $this->endFrame(); - $this->permanentLeftSpacing -= self::INDENT_SPACING; - $this->permanentRightSpacing -= self::INDENT_SPACING; - $current = array_pop($this->old); - $current["pages"] = array_merge($current["pages"], $this->current["pages"]); - $this->current = $current; - } - - private function beginFrame() { - $this->lineJump(); - $this->current["newVOffset"] = $this->vOffset; - $this->current["pages"] = array(); - } - - private function endFrame($dash = null) { - $onSinglePage = true; - foreach ($this->current["pages"] as $page) { - $page->setRGBStroke(0, 0, 0); - $page->setLineWidth(1.0); - $page->setDash($dash, 0); - // left border - $page->moveTo(self::HMARGIN + ($this->permanentLeftSpacing - self::INDENT_SPACING), - self::VMARGIN); - $page->lineTo(self::HMARGIN + ($this->permanentLeftSpacing - self::INDENT_SPACING), - $this->PAGE_HEIGHT - self::VMARGIN - $this->current["newVOffset"]); - // right border - $page->moveTo($this->PAGE_WIDTH - self::HMARGIN - ($this->permanentRightSpacing - self::INDENT_SPACING), - self::VMARGIN); - $page->lineTo($this->PAGE_WIDTH - self::HMARGIN - ($this->permanentRightSpacing - self::INDENT_SPACING), - $this->PAGE_HEIGHT - self::VMARGIN - $this->current["newVOffset"]); - $page->stroke(); - $page->setDash(null, 0); - $this->current["newVOffset"] = 0; - $onSinglePage = false; - } - $this->currentPage->setRGBStroke(0, 0, 0); - $this->currentPage->setLineWidth(1.0); - $this->currentPage->setDash($dash, 0); - // left border - $this->currentPage->moveTo(self::HMARGIN + ($this->permanentLeftSpacing - self::INDENT_SPACING), - $this->PAGE_HEIGHT - self::VMARGIN - $this->vOffset); - $this->currentPage->lineTo(self::HMARGIN + ($this->permanentLeftSpacing - self::INDENT_SPACING), - $this->PAGE_HEIGHT - self::VMARGIN - $this->current["newVOffset"]); - // right border - $this->currentPage->moveTo($this->PAGE_WIDTH - self::HMARGIN - ($this->permanentRightSpacing - self::INDENT_SPACING), - $this->PAGE_HEIGHT - self::VMARGIN - $this->vOffset); - $this->currentPage->lineTo($this->PAGE_WIDTH - self::HMARGIN - ($this->permanentRightSpacing - self::INDENT_SPACING), - $this->PAGE_HEIGHT - self::VMARGIN - $this->current["newVOffset"]); - // bottom border - $this->currentPage->moveTo(self::HMARGIN + ($this->permanentLeftSpacing - self::INDENT_SPACING), - $this->PAGE_HEIGHT - self::VMARGIN - $this->vOffset); - $this->currentPage->lineTo($this->PAGE_WIDTH - self::HMARGIN - ($this->permanentRightSpacing - self::INDENT_SPACING), - $this->PAGE_HEIGHT - self::VMARGIN - $this->vOffset); - // top border (if frame's on a single page) - if ($onSinglePage) { - $this->currentPage->moveTo(self::HMARGIN + ($this->permanentLeftSpacing - self::INDENT_SPACING), - $this->PAGE_HEIGHT - self::VMARGIN - $this->current["newVOffset"]); - $this->currentPage->lineTo($this->PAGE_WIDTH - self::HMARGIN - ($this->permanentRightSpacing - self::INDENT_SPACING), - $this->PAGE_HEIGHT - self::VMARGIN - $this->current["newVOffset"]); - } - - $this->currentPage->stroke(); - $this->lineJump(); - $this->currentPage->setDash(null, 0); - $this->current["oldVPosition"] = 0; - } - - // Append $text with an underlined blue style with a link to $url - private function appendUrlAnnotation($text, $url) { - $this->appendText(" "); - $fromHOffset = $this->hOffset; - - // If more than one text line to append - while ($text = $this->appendOneLine($text)) { - // Trace the underline - $this->currentPage->setLineWidth(1.0); - $this->currentPage->setDash(null, 0); - $this->currentPage->moveTo(self::HMARGIN + $this->permanentLeftSpacing + $fromHOffset, - $this->PAGE_HEIGHT - (self::VMARGIN + $this->vOffset + self::LINE_SPACING)); - $this->currentPage->lineTo(self::HMARGIN + $this->permanentLeftSpacing + $this->hOffset, - $this->PAGE_HEIGHT - (self::VMARGIN + $this->vOffset + self::LINE_SPACING)); - $this->currentPage->stroke(); - - // Create link - $annotationArea = array(self::HMARGIN + $this->permanentLeftSpacing + $fromHOffset, - $this->PAGE_HEIGHT - (self::VMARGIN + $this->vOffset + self::LINE_SPACING), - self::HMARGIN + $this->permanentLeftSpacing + $this->hOffset, - $this->PAGE_HEIGHT - (self::VMARGIN + $this->vOffset - $this->currentFontSize)); - $this->currentPage->createURLAnnotation($annotationArea, $url)->setBorderStyle(0, 0, 0); - - // Prepare the next line - $this->vOffset += $this->currentFontSize + self::LINE_SPACING; - $this->hOffset = 0; - $fromHOffset = $this->hOffset; - } - - // Trace the underline - $this->currentPage->setLineWidth(1.0); - $this->currentPage->setDash(null, 0); - $this->currentPage->moveTo(self::HMARGIN + $this->permanentLeftSpacing + $fromHOffset, - $this->PAGE_HEIGHT - (self::VMARGIN + $this->vOffset + self::LINE_SPACING)); - $this->currentPage->lineTo(self::HMARGIN + $this->permanentLeftSpacing + $this->hOffset, - $this->PAGE_HEIGHT - (self::VMARGIN + $this->vOffset + self::LINE_SPACING)); - $this->currentPage->stroke(); - - // Create link - $annotationArea = array(self::HMARGIN + $this->permanentLeftSpacing + $fromHOffset, - $this->PAGE_HEIGHT - (self::VMARGIN + $this->vOffset + self::LINE_SPACING), - self::HMARGIN + $this->permanentLeftSpacing + $this->hOffset, - $this->PAGE_HEIGHT - (self::VMARGIN + $this->vOffset - $this->currentFontSize)); - $this->currentPage->createURLAnnotation($annotationArea, $url)->setBorderStyle(0, 0, 0); - - } - - // Append $text with an underlined blue style and prepare an internal link (which will be resolved later) - private function prepareInternalLinkAnnotation($text) { - $this->appendText(" "); - $fromHOffset = $this->hOffset; - $linkAreas = array(/* page, left, bottom, right, top */); - - // If more than one text line to append - while ($text = $this->appendOneLine($text)) { - // Create link - $linkAreas[] = array($this->currentPage, - self::HMARGIN + $this->permanentLeftSpacing + $fromHOffset, - $this->PAGE_HEIGHT - (self::VMARGIN + $this->vOffset + self::LINE_SPACING), - self::HMARGIN + $this->permanentLeftSpacing + $this->hOffset, - $this->PAGE_HEIGHT - (self::VMARGIN + $this->vOffset - $this->currentFontSize)); - - // Prepare the next line - $this->vOffset += $this->currentFontSize + self::LINE_SPACING; - $this->hOffset = 0; - $fromHOffset = $this->hOffset; - } - - // Prepare link - $linkAreas[] = array($this->currentPage, - self::HMARGIN + $this->permanentLeftSpacing + $fromHOffset, - $this->PAGE_HEIGHT - (self::VMARGIN + $this->vOffset + self::LINE_SPACING), - self::HMARGIN + $this->permanentLeftSpacing + $this->hOffset, - $this->PAGE_HEIGHT - (self::VMARGIN + $this->vOffset - $this->currentFontSize)); - - return $linkAreas; - } - - public function resolveInternalLink($page, $rectangle, $destPage) { - $page->setRGBStroke(0, 0, 1); // blue - // Trace the underline - $page->setLineWidth(1.0); - $page->setDash(array(2), 1); - $page->moveTo($rectangle[0], $rectangle[1]); - $page->lineTo($rectangle[2], $rectangle[1]); - $page->stroke(); - // Create link - $page->createLinkAnnotation($rectangle, $destPage->createDestination()) - ->setBorderStyle(0, 0, 0); - $page->setDash(null, 0); - } - - public function addTable($colCount) { - // If this table is inside another table or frame - array_push($this->old, $this->current); - $this->current["leftSpacing"] = $this->permanentLeftSpacing; - $this->current["rightSpacing"] = $this->permanentRightSpacing; - // First horizontal line - $this->currentPage->moveTo(self::HMARGIN + $this->current["leftSpacing"], $this->PAGE_HEIGHT - self::VMARGIN - $this->vOffset); - $this->currentPage->lineTo($this->PAGE_WIDTH - self::HMARGIN - $this->current["rightSpacing"], $this->PAGE_HEIGHT - self::VMARGIN - $this->vOffset); - $this->currentPage->stroke(); - } - - public function endTable() { - $this->permanentLeftSpacing = $this->current["leftSpacing"]; - $this->permanentRightSpacing = $this->current["rightSpacing"]; - $this->lineJump(); - $current = array_pop($this->old); - $current["pages"] = array_merge($current["pages"], $this->current["pages"]); - $this->current = $current; - } - - public function newTableRow($colCount, $valign) { - $this->current["vOffset"] = $this->vOffset; - $this->current["row"]["cellCount"] = $colCount; - $this->current["row"]["activeCell"] = 0; - $this->current["row"]["hSize"] = ($this->PAGE_WIDTH - 2*self::HMARGIN - - $this->current["leftSpacing"] - $this->current["rightSpacing"]) / $this->current["row"]["cellCount"]; - $this->current["row"]["vPosition"] = 0; - $this->current["row"]["pages"] = array(); - $this->current["row"]["cutPolicy"] = array(1); - $this->current["pages"] = array(); - } - - public function beginTableEntry($colspan, $rowspan, $align) { - $this->permanentLeftSpacing = ($this->current["row"]["activeCell"]++) * $this->current["row"]["hSize"] + - self::LINE_SPACING + $this->current["leftSpacing"]; - $this->permanentRightSpacing = $this->PAGE_WIDTH - 2*self::HMARGIN - - ($this->current["row"]["activeCell"] + $colspan - 1) * $this->current["row"]["hSize"] - - $this->current["leftSpacing"] + self::LINE_SPACING; - - foreach ($this->current["pages"] as $page) { - $this->lastPage(); - } - $this->current["pages"] = array(); - - $this->hOffset = 0; - $this->vOffset = $this->current["vOffset"] + $this->currentFontSize + self::LINE_SPACING; - $this->current["align"] = $align; - - array_push($this->current["row"]["cutPolicy"], $colspan); - } - - public function endTableEntry() { - $this->current["align"] = ""; - $newOffset = $this->vOffset + $this->currentFontSize + self::LINE_SPACING; - if ($newOffset + $this->PAGE_HEIGHT * count($this->current["pages"]) > $this->current["row"]["vPosition"]) { - $this->current["row"]["vPosition"] = $newOffset + $this->PAGE_HEIGHT * count($this->current["pages"]); - } - if (count($this->current["pages"]) > count($this->current["row"]["pages"])) { - $this->current["row"]["pages"] = $this->current["pages"]; - } - } - - public function endTableRow() { - $vOffset = $this->current["vOffset"]; - while($this->isNextPage()) - $this->nextPage(); - // Vertical lines - for ($i = 0, $x = self::HMARGIN + $this->current["leftSpacing"]; $i <= $this->current["row"]["cellCount"]; $i++, $x += $this->current["row"]["hSize"]) { - - // Don't trace vertical line if colspan - if (($cellCount = array_shift($this->current["row"]["cutPolicy"])) > 1) { - array_unshift($this->current["row"]["cutPolicy"], $cellCount - 1); - continue; - } - - foreach ($this->current["row"]["pages"] as $page) { - $page->setRGBStroke(0, 0, 0); - $page->moveTo($x, self::VMARGIN); - $page->lineTo($x, $this->PAGE_HEIGHT - self::VMARGIN - $this->current["vOffset"]); - $page->stroke(); - $this->current["vOffset"] = 0; - } - - $this->currentPage->moveTo($x, $this->PAGE_HEIGHT - self::VMARGIN - ($this->current["vOffset"])); - $this->currentPage->lineTo($x, $this->PAGE_HEIGHT - self::VMARGIN - ($this->current["row"]["vPosition"] % $this->PAGE_HEIGHT)); - $this->currentPage->stroke(); - $this->current["vOffset"] = $vOffset; - } - // Horizontal line - $this->currentPage->moveTo(self::HMARGIN + $this->current["leftSpacing"], $this->PAGE_HEIGHT - self::VMARGIN - ($this->current["row"]["vPosition"] % $this->PAGE_HEIGHT)); - $this->currentPage->lineTo($this->PAGE_WIDTH - self::HMARGIN - $this->current["rightSpacing"], - $this->PAGE_HEIGHT - self::VMARGIN - ($this->current["row"]["vPosition"] % $this->PAGE_HEIGHT)); - $this->currentPage->stroke(); - - // Store position - $this->vOffset = $this->current["row"]["vPosition"] % $this->PAGE_HEIGHT; - - // Store pages - $last = array_pop($this->old); - $last["pages"] = array_merge($last["pages"], $this->current["row"]["pages"]); - array_push($this->old, $last); - - // Erase current properties - $this->current["row"] = array(); - } - - private function endsWith($str, $sub) { - return ( substr( $str, strlen( $str ) - strlen( $sub ) ) === $sub ); - } - - private function addImage($url) { - $image = null; - if ($this->endsWith(strtolower($url), ".png")) { - $image = $this->haruDoc->loadPNG($url); - } elseif ($this->endsWith(strtolower($url), ".jpg") || $this->endsWith(strtolower($url), ".jpeg")) { - $image = $this->haruDoc->loadJPEG($url); - } - if ($image) { - if ($this->PAGE_HEIGHT - $this->vOffset - 2*self::VMARGIN < $image->getHeight()) - $this->nextPage(); - $this->currentPage->drawImage($image, - self::HMARGIN + $this->permanentLeftSpacing + $this->hOffset, - $this->PAGE_HEIGHT - self::HMARGIN - $this->vOffset - $image->getHeight(), - $image->getWidth(), - $image->getHeight()); - - $this->hOffset = 0; - $this->vOffset += $image->getWidth(); - } - } -} - -/* -* vim600: sw=4 ts=4 syntax=php et -* vim<600: sw=4 ts=4 -*/ diff --git a/phpdotnet/phd/Package/Generic/PDF.php b/phpdotnet/phd/Package/Generic/PDF.php deleted file mode 100644 index bfa19c560..000000000 --- a/phpdotnet/phd/Package/Generic/PDF.php +++ /dev/null @@ -1,1134 +0,0 @@ - 'format_suppressed_tags', - 'abbrev' => 'format_suppressed_tags', - 'acronym' => 'format_suppressed_tags', - 'alt' => 'format_suppressed_tags', - 'application' => 'format_suppressed_tags', - 'author' => array( - /* DEFAULT */ 'format_newline', - 'authorgroup' => 'format_authorgroup_author', - ), - 'authorgroup' => 'format_shifted_para', - 'blockquote' => 'format_framed_block', - 'book' => 'format_suppressed_tags', - 'callout' => 'format_callout', - 'calloutlist' => 'format_calloutlist', - 'caution' => 'format_admonition', - 'citerefentry' => 'format_suppressed_tags', - 'classname' => array( - /* DEFAULT */ 'format_suppressed_tags', - 'ooclass' => array( - /* DEFAULT */ 'format_bold', - 'classsynopsisinfo' => 'format_suppressed_tags', - ), - ), - 'co' => 'format_co', - 'command' => 'format_italic', - 'computeroutput' => 'format_suppressed_tags', - 'constant' => 'format_bold', - 'code' => 'format_verbatim_inline', - 'copyright' => 'format_copyright', - 'editor' => 'format_editor', - 'example' => 'format_example', - 'emphasis' => 'format_italic', - 'envar' => 'format_suppressed_tags', - 'errortype' => 'format_suppressed_tags', - 'figure' => 'format_suppressed_tags', - 'filename' => 'format_italic', - 'firstname' => 'format_suppressed_tags', - 'formalpara' => 'format_para', - 'footnote' => 'format_footnote', - 'footnoteref' => 'format_footnoteref', - 'funcdef' => 'format_bold', - 'function' => 'format_suppressed_tags', - 'glossterm' => 'format_suppressed_tags', - 'holder' => 'format_suppressed_tags', - 'imagedata' => 'format_imagedata', - 'imageobject' => 'format_shifted_para', - 'index' => 'format_para', - 'indexdiv' => 'format_para', - 'indexentry' => 'format_shifted_line', - 'info' => 'format_suppressed_tags', - 'informalexample' => 'format_para', - 'itemizedlist' => 'format_shifted_para', - 'legalnotice' => 'format_suppressed_tags', - 'link' => 'format_link', - 'listitem' => array( - /* DEFAULT */ 'format_listitem', - 'varlistentry' => 'format_shifted_para', - ), - 'literal' => 'format_italic', - 'literallayout' => 'format_verbatim_inline', - 'manvolnum' => 'format_manvolnum', - 'mediaobject' => 'format_suppressed_tags', - 'member' => 'format_member', - 'note' => 'format_admonition', - 'option' => 'format_italic', - 'optional' => 'format_suppressed_tags', - 'orderedlist' => 'format_shifted_para', - 'othercredit' => 'format_newline', - 'othername' => 'format_suppressed_tags', - 'para' => array( - /* DEFAULT */ 'format_para', - 'callout' => 'format_suppressed_tags', - 'listitem' => 'format_suppressed_tags', - 'step' => 'format_suppressed_tags', - ), - 'partintro' => 'format_para', - 'personname' => 'format_suppressed_tags', - 'preface' => 'format_suppressed_tags', - 'primaryie' => 'format_suppressed_tags', - 'procedure' => 'format_procedure', - 'productname' => 'format_suppressed_tags', - 'programlisting' => 'format_verbatim_block', - 'property' => array( - /* DEFAULT */ 'format_suppressed_tags', - 'classsynopsisinfo' => 'format_italic', - ), - 'pubdate' => 'format_para', - 'quote' => 'format_suppressed_tags', - 'refentrytitle' => 'format_bold', - 'refname' => 'format_title', - 'refnamediv' => 'format_suppressed_tags', - 'refpurpose' => 'format_refpurpose', - 'refsect1' => 'format_suppressed_tags', - 'refsection' => 'format_refsection', // DUMMY REFSECTION DELETION - 'refsynopsisdiv' => 'format_para', - 'replaceable' => 'format_italic', - 'screen' => 'format_verbatim_block', - 'section' => 'format_suppressed_tags', - 'sect1' => 'format_suppressed_tags', - 'sect2' => 'format_suppressed_tags', - 'sect3' => 'format_suppressed_tags', - 'sect4' => 'format_suppressed_tags', - 'sect5' => 'format_suppressed_tags', - 'seg' => 'format_seg', - 'segmentedlist' => 'format_segmentedlist', - 'seglistitem' => 'format_seglistitem', - 'segtitle' => 'format_suppressed_tags', - 'set' => 'format_suppressed_tags', - 'simpara' => array( - /* DEFAULT */ 'format_para', - 'callout' => 'format_suppressed_tags', - 'listitem' => 'format_suppressed_tags', - 'step' => 'format_suppressed_tags', - ), - 'simplelist' => 'format_shifted_para', - 'simplesect' => 'format_suppressed_tags', - 'step' => 'format_suppressed_tags', - 'subscript' => 'format_indice', - 'superscript' => 'format_indice', - 'surname' => 'format_suppressed_tags', - 'synopsis' => 'format_verbatim_block', - 'systemitem' => 'format_verbatim_inline', - 'tag' => 'format_verbatim_inline', - 'term' => 'format_suppressed_tags', - 'title' => array( - /* DEFAULT */ 'format_title', - 'example' => 'format_example_title', - 'formalpara' => 'format_title3', - 'info' => array( - /* DEFAULT */ 'format_title', - 'example' => 'format_example_title', - 'note' => 'format_title3', - 'table' => 'format_title3', - 'informaltable' => 'format_title3', - 'warning' => 'format_title3', - ), - 'informaltable' => 'format_title3', - 'legalnotice' => 'format_title2', - 'note' => 'format_title3', - 'preface' => 'format_title', - 'procedure' => 'format_bold', - 'refsect1' => 'format_title2', - 'refsect2' => 'format_title3', - 'refsect3' => 'format_title3', - 'section' => 'format_title2', - 'sect1' => 'format_title2', - 'sect2' => 'format_title3', - 'sect3' => 'format_title3', - 'sect4' => 'format_title3', - 'segmentedlist' => 'format_bold', - 'table' => 'format_title3', - 'variablelist' => 'format_bold', - 'warning' => 'format_title3', - ), - 'tip' => 'format_admonition', - 'titleabbrev' => 'format_suppressed_tags', - 'type' => 'format_suppressed_tags', - 'userinput' => 'format_bold', - 'variablelist' => 'format_suppressed_tags', - /* hack for phpdoc:varentry */ - 'phpdoc:varentry' => 'format_suppressed_tags', - 'varlistentry' => 'format_newline', - 'varname' => 'format_italic', - 'warning' => 'format_admonition', - 'xref' => 'format_link', - 'year' => 'format_suppressed_tags', - // TABLES - 'informaltable' => 'format_table', - 'table' => 'format_table', - 'tgroup' => 'format_tgroup', - 'colspec' => 'format_colspec', - 'spanspec' => 'format_suppressed_tags', - 'thead' => 'format_thead', - 'tbody' => 'format_suppressed_tags', - 'row' => 'format_row', - 'entry' => array ( - /* DEFAULT */ 'format_entry', - 'row' => array( - /* DEFAULT */ 'format_entry', - 'thead' => 'format_th_entry', - 'tfoot' => 'format_th_entry', - 'tbody' => 'format_entry', - ), - ), - // SYNOPSISES & OO STUFF - 'void' => 'format_void', - 'methodname' => 'format_bold', - 'methodparam' => 'format_methodparam', - 'methodsynopsis' => 'format_methodsynopsis', - 'parameter' => array( - /* DEFAULT */ 'format_parameter', - 'methodparam' => 'format_methodparam_parameter', - ), - 'interfacename' => 'format_suppressed_tags', - 'ooclass' => array( - /* DEFAULT */ 'format_suppressed_tags', - 'classsynopsis' => 'format_framed_para', - ), - 'oointerface' => array( - /* DEFAULT */ 'format_suppressed_tags', - 'classsynopsisinfo' => 'format_classsynopsisinfo_oointerface', - ), - 'classsynopsis' => 'format_classsynopsis', - 'classsynopsisinfo' => 'format_classsynopsisinfo', - 'fieldsynopsis' => array( - /* DEFAULT */ 'format_fieldsynopsis', - 'entry' => 'format_para', - ), - 'modifier' => 'format_suppressed_tags', - 'constructorsynopsis' => 'format_methodsynopsis', - 'destructorsynopsis' => 'format_methodsynopsis', - 'initializer' => 'format_initializer', - // FAQ - 'qandaset' => 'format_para', - 'qandaentry' => 'format_para', - 'question' => 'format_bold', - 'answer' => 'format_shifted_para', - - ); /* }}} */ - - private $textmap = array( - 'function' => 'format_function_text', - 'link' => 'format_link_text', - 'quote' => 'format_quote_text', - 'refname' => 'format_refname_text', - 'titleabbrev' => 'format_suppressed_text', - 'segtitle' => 'format_segtitle_text', - 'modifier' => array( - /* DEFAULT */ false, - 'fieldsynopsis' => 'format_fieldsynopsis_modifier_text', - ), - 'methodname' => array( - /* DEFAULT */ false, - 'constructorsynopsis' => array( - /* DEFAULT */ false, - 'classsynopsis' => 'format_classsynopsis_methodsynopsis_methodname_text', - ), - 'methodsynopsis' => array( - /* DEFAULT */ false, - 'classsynopsis' => 'format_classsynopsis_methodsynopsis_methodname_text', - ), - 'destructorsynopsis' => array( - /* DEFAULT */ false, - 'classsynopsis' => 'format_classsynopsis_methodsynopsis_methodname_text', - ), - ), - ); - - protected $lang = ""; - - /* Current Chunk variables */ - private $cchunk = array(); - /* Default Chunk variables */ - private $dchunk = array( - "xml-base" => "", - "refsection" => false, - "examplenumber" => 0, - "href" => "", - "is-xref" => false, - "linkend" => "", - "links-to-resolve" => array( - /* $id => array( $target ), */ - ), - "refname" => "", - "table" => false, - "verbatim-block" => false, - "segmentedlist" => array( - "seglistitem" => 0, - "segtitle" => array( - ), - ), - "classsynopsis" => array( - "close" => false, - "classname" => false, - ), - "classsynopsisinfo" => array( - "implements" => false, - "ooclass" => false, - ), - "fieldsynopsis" => array( - "modifier" => "public", - ), - "footnote" => array( - ), - "tablefootnotes" => array( - ), - "footrefs" => array(), - "co" => 0, - "corefs" => array(), - "callouts" => 0, - ); - - public function __construct() { - parent::__construct(); - $this->setExt(Config::ext() === null ? ".pdf" : Config::ext()); - $this->pdfDoc = new PdfWriter(); - } - - public function __destruct() { - unset($this->pdfDoc); - } - - public function getChunkInfo($info) { - if (isset($this->cchunk[$info])) - return $this->cchunk[$info]; - else return null; - } - - public function setChunkInfo($info, $value) { - $this->cchunk[$info] = $value; - } - - public function getDefaultChunkInfo() { - return $this->dchunk; - } - - public function getDefaultElementmap() { - return $this->elementmap; - } - - public function getDefaultTextmap() { - return $this->textmap; - } - - public function TEXT($str) { - if (isset($this->cchunk["refsection"]) && $this->cchunk["refsection"]) // DUMMY REFSECTION DELETION - return ""; - - if (isset($this->cchunk["verbatim-block"]) && $this->cchunk["verbatim-block"]) { - $this->pdfDoc->appendText(utf8_decode($str)); - return ""; - } - - $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); - else $this->pdfDoc->appendText($ret); - return ""; - } - - public function format_suppressed_tags($open, $name) { - /* Ignore it */ - return ""; - } - - public function format_suppressed_text($value, $tag) { - /* Suppress any content */ - return ""; - } - - public function newChunk() { - $this->cchunk = $this->dchunk; - } - - // DUMMY REFSECTION DELETION - public function format_refsection($open, $name, $attrs, $props) { - if ($open) { - $this->cchunk["refsection"] = true; - } else { - $this->cchunk["refsection"] = false; - } - return ""; - } - - public function format_para($open, $name, $attrs, $props) { - if ($open) { - $this->pdfDoc->add(PdfWriter::PARA); - } else { - $this->pdfDoc->add(PdfWriter::LINE_JUMP); - } - return ""; - } - - public function format_shifted_para($open, $name, $attrs, $props) { - if ($open) { - $this->pdfDoc->shift(); - $this->pdfDoc->add(PdfWriter::PARA); - } else { - $this->pdfDoc->unshift(); - $this->pdfDoc->add(PdfWriter::LINE_JUMP); - } - return ""; - } - - public function format_shifted_line($open, $name, $attrs, $props) { - if ($open) { - $this->pdfDoc->shift(); - $this->pdfDoc->add(PdfWriter::LINE_JUMP); - } else { - $this->pdfDoc->unshift(); - } - return ""; - } - - public function format_title($open, $name, $attrs, $props) { - if ($props["empty"]) return ''; - if ($open) { - $this->pdfDoc->add(PdfWriter::TITLE); - } else { - $this->pdfDoc->add(PdfWriter::LINE_JUMP); - $this->pdfDoc->revertFont(); - } - return ""; - } - - public function format_title2($open, $name, $attrs, $props) { - if ($props["empty"]) return ''; - if ($open) { - $this->pdfDoc->add(PdfWriter::TITLE2); - } else { - $this->pdfDoc->add(PdfWriter::LINE_JUMP); - $this->pdfDoc->revertFont(); - } - return ""; - } - - public function format_title3($open, $name, $attrs, $props) { - if ($props["empty"]) return ''; - if ($open) { - $this->pdfDoc->add(PdfWriter::TITLE3); - } else { - $this->pdfDoc->add(PdfWriter::LINE_JUMP); - $this->pdfDoc->revertFont(); - } - return ""; - } - - public function format_bold($open, $name, $attrs, $props) { - if ($props["empty"]) return ''; - if ($open) { - $this->pdfDoc->setFont(PdfWriter::FONT_BOLD); - } else { - $this->pdfDoc->revertFont(); - } - return ""; - } - - public function format_italic($open, $name, $attrs, $props) { - if ($props["empty"]) return ''; - if ($open) { - $this->pdfDoc->setFont(PdfWriter::FONT_ITALIC); - } else { - $this->pdfDoc->revertFont(); - } - return ""; - } - - public function format_admonition($open, $name, $attrs, $props) { - if ($open) { - $this->pdfDoc->add(PdfWriter::ADMONITION); - $this->pdfDoc->appendText($this->autogen($name, $props["lang"])); - $this->pdfDoc->add(PdfWriter::ADMONITION_CONTENT); - } else { - $this->pdfDoc->add(PdfWriter::END_ADMONITION); - } - return ""; - } - - public function format_example($open, $name, $attrs, $props) { - if ($open) { - $this->lang = $props["lang"]; - $this->cchunk["examplenumber"]++; - $this->pdfDoc->add(PdfWriter::ADMONITION); - - } else { - $this->pdfDoc->add(PdfWriter::END_ADMONITION); - } - return ""; - } - - public function format_example_title($open, $name, $attrs, $props) { - if ($props["empty"]) { - $this->pdfDoc->appendText($this->autogen("example", $this->lang) . - $this->cchunk["examplenumber"]); - $this->pdfDoc->add(PdfWriter::ADMONITION_CONTENT); - } elseif ($open) { - $this->pdfDoc->appendText($this->autogen("example", $this->lang) . - $this->cchunk["examplenumber"] . " -"); - } else { - $this->pdfDoc->add(PdfWriter::ADMONITION_CONTENT); - } - return ""; - } - - public function format_newpage($open, $name, $attrs, $props) { - if ($open) { - $this->pdfDoc->add(PdfWriter::PAGE); - } - return ""; - } - - public function format_verbatim_block($open, $name, $attrs, $props) { - if ($open) { - $this->cchunk["verbatim-block"] = true; - $this->pdfDoc->add(PdfWriter::VERBATIM_BLOCK); - } else { - $this->pdfDoc->add(PdfWriter::LINE_JUMP); - $this->pdfDoc->revertFont(); - $this->cchunk["verbatim-block"] = false; - } - return ""; - } - - public function format_verbatim_inline($open, $name, $attrs, $props) { - if ($open) { - $this->pdfDoc->setFont(PdfWriter::FONT_VERBATIM, 10); - } else { - $this->pdfDoc->revertFont(); - } - return ""; - } - - public function format_framed_block($open, $name, $attrs, $props) { - if ($open) { - $this->pdfDoc->add(PdfWriter::FRAMED_BLOCK); - } else { - $this->pdfDoc->add(PdfWriter::END_FRAMED_BLOCK); - } - return ""; - } - - public function format_framed_para($open, $name, $attrs, $props) { - if ($open) { - $this->pdfDoc->add(PdfWriter::FRAMED_BLOCK); - $this->format_para($open, $name, $attrs, $props); - } else { - $this->format_para($open, $name, $attrs, $props); - $this->pdfDoc->add(PdfWriter::END_FRAMED_BLOCK); - } - return ""; - } - - public function format_newline($open, $name, $attrs, $props) { - if ($open) { - $this->pdfDoc->add(PdfWriter::LINE_JUMP); - } - } - - public function format_link($open, $name, $attrs, $props) { - if ($open && ! $props["empty"]) { - $this->pdfDoc->setFont(PdfWriter::FONT_NORMAL, 12, array(0, 0, 1)); // blue - if (isset($attrs[Reader::XMLNS_DOCBOOK]["linkend"])) { - $this->cchunk["linkend"] = $attrs[Reader::XMLNS_DOCBOOK]["linkend"]; - } elseif(isset($attrs[Reader::XMLNS_XLINK]["href"])) { - $this->cchunk["href"] = $attrs[Reader::XMLNS_XLINK]["href"]; - } - } elseif ($open && $name == "xref" && isset($attrs[Reader::XMLNS_DOCBOOK]["linkend"]) - && $linkend = $attrs[Reader::XMLNS_DOCBOOK]["linkend"]) { - $this->cchunk["linkend"] = $linkend; - $this->pdfDoc->setFont(PdfWriter::FONT_NORMAL, 12, array(0, 0, 1)); // blue - $this->format_link_text(Format::getShortDescription($linkend), $name); - $this->pdfDoc->revertFont(); - $this->cchunk["linkend"] = ""; - } elseif (!$open) { - $this->cchunk["href"] = ""; - $this->cchunk["linkend"] = ""; - $this->pdfDoc->revertFont(); - } - return ""; - } - - public function format_link_text($value, $tag) { - $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"]) { - $linkAreas = $this->pdfDoc->add(PdfWriter::LINK_ANNOTATION, $value); - if (!isset($this->cchunk["links-to-resolve"][$linkend])) - $this->cchunk["links-to-resolve"][$linkend] = array(); - foreach ($linkAreas as $area) - $this->cchunk["links-to-resolve"][$linkend][] = $area; - } - return ""; - } - - public function format_function_text($value, $tag, $display_value = null) { - $value = trim(preg_replace('/[ \n\t]+/', ' ', $value)); - if ($display_value === null) { - $display_value = $value; - } - - $ref = strtolower(str_replace(array("_", "::", "->"), array("-", "-", "-"), $value)); - if (($linkend = $this->getRefnameLink($ref)) !== null) { - $this->pdfDoc->setFont(PdfWriter::FONT_NORMAL, 12, array(0, 0, 1)); // blue - $linkAreas = $this->pdfDoc->add(PdfWriter::LINK_ANNOTATION, $display_value.($tag == "function" ? "()" : "")); - if (!isset($this->cchunk["links-to-resolve"][$linkend])) - $this->cchunk["links-to-resolve"][$linkend] = array(); - foreach ($linkAreas as $area) - $this->cchunk["links-to-resolve"][$linkend][] = $area; - } else { - $this->pdfDoc->setFont(PdfWriter::FONT_BOLD); - $this->pdfDoc->appendText(" " . $display_value.($tag == "function" ? "()" : "")); - } - $this->pdfDoc->revertFont(); - return ""; - } - - public function format_authorgroup_author($open, $name, $attrs, $props) { - if ($open) { - if ($props["sibling"] !== $name) { - $this->pdfDoc->setFont(PdfWriter::FONT_BOLD); - $this->pdfDoc->appendText($this->autogen("by", $props["lang"])); - $this->pdfDoc->revertFont(); - } - $this->pdfDoc->add(PdfWriter::LINE_JUMP); - } - return ""; - } - - public function format_editor($open, $name, $attrs, $props) { - if ($open) { - $this->pdfDoc->setFont(PdfWriter::FONT_BOLD); - $this->pdfDoc->appendText($this->autogen("editedby", $props["lang"])); - $this->pdfDoc->revertFont(); - } else { - $this->pdfDoc->add(PdfWriter::LINE_JUMP); - } - return ""; - } - - public function format_copyright($open, $name, $attrs, $props) { - if ($open) { - $this->pdfDoc->add(PdfWriter::PARA); - $this->pdfDoc->appendText(utf8_decode("©")); - } else { - $this->pdfDoc->add(PdfWriter::LINE_JUMP); - } - return ""; - } - - // Lists {{{ - public function format_listitem($open, $name, $attrs, $props) { - if ($open) { - $this->pdfDoc->add(PdfWriter::LINE_JUMP); - $this->pdfDoc->add(PdfWriter::ADD_BULLET); - } else { - $this->pdfDoc->add(PdfWriter::LINE_JUMP, 0.5); - } - return ""; - } - - public function format_procedure($open, $name, $attrs, $props) { - $this->cchunk["step"] = 0; - return $this->format_shifted_para($open, $name, $attrs, $props); - } - - public function format_step($open, $name, $attrs, $props) { - if ($open) { - $this->pdfDoc->add(PdfWriter::LINE_JUMP); - $this->pdfDoc->add(PdfWriter::ADD_NUMBER_ITEM, (++$this->cchunk["step"])."."); - } else { - $this->pdfDoc->add(PdfWriter::LINE_JUMP, 0.5); - } - return ""; - } - - public function format_member($open, $name, $attrs, $props) { - if ($open) { - $this->pdfDoc->add(PdfWriter::LINE_JUMP); - $this->pdfDoc->add(PdfWriter::ADD_BULLET); - } - return ""; - } - - public function format_segmentedlist($open, $name, $attrs, $props) { - $this->cchunk["segmentedlist"] = $this->dchunk["segmentedlist"]; - return $this->format_para($open, $name, $attrs, $props); - } - - public function format_segtitle_text($value, $tag) { - $this->cchunk["segmentedlist"]["segtitle"][count($this->cchunk["segmentedlist"]["segtitle"])] = $value; - return ''; - } - public function format_seglistitem($open, $name, $attrs) { - if ($open) { - $this->cchunk["segmentedlist"]["seglistitem"] = 0; - } - return ''; - } - public function format_seg($open, $name, $attrs) { - if ($open) { - $this->pdfDoc->add(PdfWriter::LINE_JUMP); - $this->pdfDoc->setFont(PdfWriter::FONT_BOLD); - $this->pdfDoc->appendText($this->cchunk["segmentedlist"]["segtitle"][$this->cchunk["segmentedlist"]["seglistitem"]++].":"); - $this->pdfDoc->revertFont(); - } - return ''; - } - // }}} Lists - - // Tables {{{ - public function format_table($open, $name, $attrs, $props) { - if ($open) { - $this->cchunk["table"] = true; - $this->pdfDoc->add(PdfWriter::PARA); - } else { - $this->cchunk["table"] = false; - $this->pdfDoc->add(PdfWriter::END_TABLE); - - if ($this->cchunk["tablefootnotes"]) { - $this->pdfDoc->add(PdfWriter::FRAMED_BLOCK); - $this->pdfDoc->add(PdfWriter::LINE_JUMP); - $this->pdfDoc->appendBufferNow(); - foreach ($this->cchunk["footrefs"] as $ref) - foreach ($ref as $area) - $this->pdfDoc->resolveInternalLink($area[0], array($area[1], $area[2], $area[3], $area[4]), $this->pdfDoc->getCurrentPage()); - $this->pdfDoc->add(PdfWriter::END_FRAMED_BLOCK, array(2)); // With Dash line - $this->cchunk["tablefootnotes"] = $this->dchunk["tablefootnotes"]; - } - } - return ""; - } - - public function format_colspec($open, $name, $attrs) { - if ($open) { - Format::colspec($attrs[Reader::XMLNS_DOCBOOK]); - } - return ""; - } - public function format_thead($open, $name, $attrs) { - if ($open) { - $this->pdfDoc->setFont(PdfWriter::FONT_BOLD); - } else { - $this->pdfDoc->revertFont(); - } - return ""; - } - - public function format_row($open, $name, $attrs) { - if ($open) { - Format::initRow(); - $valign = isset($attrs[Reader::XMLNS_DOCBOOK]['valign']) - ? $attrs[Reader::XMLNS_DOCBOOK]['valign'] : 'middle'; - $colCount = Format::getColCount(); - $this->pdfDoc->add(PdfWriter::TABLE_ROW, array($colCount, $valign)); - } else { - $this->pdfDoc->add(PdfWriter::TABLE_END_ROW); - } - return ""; - } - public function format_th_entry($open, $name, $attrs, $props) { - $align = (isset($attrs["align"]) ? $attrs["align"] : "center"); - if ($props["empty"]) { - $this->pdfDoc->add(PdfWriter::TABLE_ENTRY, array(1, 1, $align)); - $this->pdfDoc->add(PdfWriter::TABLE_END_ENTRY); - } - if ($open) { - $dbattrs = Format::getColspec($attrs[Reader::XMLNS_DOCBOOK]); - $align = (isset($dbattrs["align"]) ? $dbattrs["align"] : $align); - $colspan = Format::colspan($attrs[Reader::XMLNS_DOCBOOK]); - $this->pdfDoc->add(PdfWriter::TABLE_ENTRY, array($colspan, 1, $align)); - } else { - $this->pdfDoc->add(PdfWriter::TABLE_END_ENTRY); - } - return ""; - } - public function format_entry($open, $name, $attrs, $props) { - $align = (isset($attrs["align"]) ? $attrs["align"] : "left"); - if ($props["empty"]) { - $this->pdfDoc->add(PdfWriter::TABLE_ENTRY, array(1, 1, $align)); - $this->pdfDoc->add(PdfWriter::TABLE_END_ENTRY); - return; - } - if ($open) { - $dbattrs = Format::getColspec($attrs[Reader::XMLNS_DOCBOOK]); - $align = (isset($dbattrs["align"]) ? $dbattrs["align"] : $align); - $retval = ""; - if (isset($dbattrs["colname"])) { - for($i=Format::getEntryOffset($dbattrs); $i>0; --$i) { - $this->pdfDoc->add(PdfWriter::TABLE_ENTRY, array(1, 1, $align)); - $this->pdfDoc->add(PdfWriter::TABLE_END_ENTRY); - } - } - - /* - * "colspan" is *not* an standard prop, only used to overwrite the - * colspan for s in tables - */ - if (isset($props["colspan"])) { - $colspan = $props["colspan"]; - } else { - $colspan = Format::colspan($dbattrs); - } - - $rowspan = Format::rowspan($dbattrs); - $this->pdfDoc->add(PdfWriter::TABLE_ENTRY, array($colspan, $rowspan, $align)); - } else { - $this->pdfDoc->add(PdfWriter::TABLE_END_ENTRY); - } - return ""; - } - - public function format_tgroup($open, $name, $attrs, $props) { - if ($open) { - Format::tgroup($attrs[Reader::XMLNS_DOCBOOK]); - if (isset($attrs[Reader::XMLNS_DOCBOOK]["cols"])) - $this->pdfDoc->add(PdfWriter::TABLE, $attrs[Reader::XMLNS_DOCBOOK]["cols"]); - } else { - } - return ""; - } - // }}} Tables - - // Synopsises {{{ - public function format_methodsynopsis($open, $name, $attrs, $props) { - if ($open) { - $this->params = array("count" => 0, "opt" => 0, "content" => ""); - return $this->format_para($open, $name, $attrs, $props); - } - $content = ""; - if ($this->params["opt"]) { - $content = str_repeat(" ]", $this->params["opt"]); - } - $content .= " )"; - - $this->pdfDoc->appendText($content); - return $this->format_para($open, $name, $attrs, $props); - } - - public function format_classsynopsis_methodsynopsis_methodname_text($value, $tag) { - $value = $this->TEXT($value); - if ($this->cchunk["classsynopsis"]["classname"] === false) { - $this->pdfDoc->appendText($value); - return ''; - } - if (strpos($value, '::')) { - $explode = '::'; - } elseif (strpos($value, '->')) { - $explode = '->'; - } else { - $this->pdfDoc->appendText($value); - return ''; - } - - list($class, $method) = explode($explode, $value); - if ($class !== $this->cchunk["classsynopsis"]["classname"]) { - $this->pdfDoc->appendText($value); - return ''; - } - $this->pdfDoc->appendText($method); - return ''; - } - - public function format_methodparam_parameter($open, $name, $attrs, $props) { - if ($props["empty"]) return ''; - if ($open) { - if (isset($attrs[Reader::XMLNS_DOCBOOK]["role"])) { - $this->pdfDoc->setFont(PdfWriter::FONT_VERBATIM, 10); - $this->pdfDoc->appendText(" &$"); - return ''; - } - $this->pdfDoc->setFont(PdfWriter::FONT_VERBATIM, 10); - $this->pdfDoc->appendText(" $"); - return ''; - } - $this->pdfDoc->revertFont(); - return ''; - } - - public function format_parameter($open, $name, $attrs, $props) { - if ($props["empty"]) return ''; - if ($open) { - if (isset($attrs[Reader::XMLNS_DOCBOOK]["role"])) { - $this->pdfDoc->setFont(PdfWriter::FONT_VERBATIM_ITALIC, 10); - $this->pdfDoc->appendText(" &"); - return ''; - } - $this->pdfDoc->setFont(PdfWriter::FONT_VERBATIM_ITALIC, 10); - return ''; - } - $this->pdfDoc->revertFont(); - return ''; - } - - public function format_methodparam($open, $name, $attrs) { - if ($open) { - $content = ''; - if ($this->params["count"] == 0) { - $content .= " ("; - } - if (isset($attrs[Reader::XMLNS_DOCBOOK]["choice"]) && $attrs[Reader::XMLNS_DOCBOOK]["choice"] == "opt") { - $this->params["opt"]++; - $content .= " ["; - } else if($this->params["opt"]) { - $content .= str_repeat(" ]", $this->params["opt"]); - $this->params["opt"] = 0; - } - if ($this->params["count"]) { - $content .= ","; - } - $content .= ''; - ++$this->params["count"]; - $this->pdfDoc->appendText($content); - return ''; - } - return ''; - } - - public function format_void($open, $name, $attrs) { - $this->pdfDoc->appendText(" ( void"); - return ''; - } - - public function format_classsynopsisinfo($open, $name, $attrs, $props) { - $this->cchunk["classsynopsisinfo"] = $this->dchunk["classsynopsisinfo"]; - if ($open) { - if (isset($attrs[Reader::XMLNS_DOCBOOK]["role"]) && $attrs[Reader::XMLNS_DOCBOOK]["role"] == "comment") { - $this->format_para($open, $name, $attrs, $props); - $this->pdfDoc->appendText("/* "); - return ''; - } - return $this->format_para($open, $name, $attrs, $props); - } - - if (isset($attrs[Reader::XMLNS_DOCBOOK]["role"]) && $attrs[Reader::XMLNS_DOCBOOK]["role"] == "comment") { - $this->pdfDoc->appendText(" */"); - return $this->format_para($open, $name, $attrs, $props); - } - $this->cchunk["classsynopsis"]["close"] = true; - $this->pdfDoc->appendText(" {"); - $this->pdfDoc->shift(); - return $this->format_para($open, $name, $attrs, $props); - } - - public function format_classsynopsisinfo_oointerface($open, $name, $attrs) { - if ($open) { - if ($this->cchunk["classsynopsisinfo"]["implements"] === false) { - $this->cchunk["classsynopsisinfo"]["implements"] = true; - $this->pdfDoc->appendText(" implements"); - return ''; - } - $this->pdfDoc->appendText(","); - return ''; - } - return ''; - } - - public function format_classsynopsis($open, $name, $attrs, $props) { - if ($open) { - return $this->format_para($open, $name, $attrs, $props); - } - - if ($this->cchunk["classsynopsis"]["close"] === true) { - $this->cchunk["classsynopsis"]["close"] = false; - $this->pdfDoc->unshift(); - $this->pdfDoc->appendText("}"); - } - return $this->format_para($open, $name, $attrs, $props); - } - - public function format_fieldsynopsis_modifier_text($value, $tag) { - $this->cchunk["fieldsynopsis"]["modifier"] = trim($value); - $this->pdfDoc->appendText($this->TEXT($value)); - return ''; - } - - public function format_fieldsynopsis($open, $name, $attrs, $props) { - $this->cchunk["fieldsynopsis"] = $this->dchunk["fieldsynopsis"]; - if ($open) { - return $this->format_para($open, $name, $attrs, $props); - } - $this->pdfDoc->appendText(";"); - return $this->format_para($open, $name, $attrs, $props); - } - - public function format_initializer($open, $name, $attrs) { - if ($open) { - $this->pdfDoc->appendText(" = "); - } - return ''; - } - // }}} Synopsises - - - // Footnotes & Callouts {{{ - public function format_footnoteref($open, $name, $attrs, $props) { - if ($open) { - $linkend = $attrs[Reader::XMLNS_DOCBOOK]["linkend"]; - $found = false; - foreach($this->cchunk["footnote"] as $k => $note) { - if ($note["id"] === $linkend) { - $this->pdfDoc->setFont(PdfWriter::FONT_NORMAL, 12, array(0,0,1)); - $this->cchunk["footrefs"][] = $this->pdfDoc->add(PdfWriter::LINK_ANNOTATION, "[".($k + 1)."]"); - $this->pdfDoc->revertFont(); - } - } - return ''; - } - } - - public function format_footnote($open, $name, $attrs, $props) { - if ($open) { - $count = count($this->cchunk["footnote"]); - $noteid = isset($attrs[Reader::XMLNS_XML]["id"]) ? $attrs[Reader::XMLNS_XML]["id"] : $count + 1; - $note = array("id" => $noteid, "str" => ""); - $this->cchunk["footnote"][$count] = $note; - if ($this->cchunk["table"]) { - $this->cchunk["tablefootnotes"][$count] = $noteid; - } - $this->pdfDoc->setFont(PdfWriter::FONT_NORMAL, 12, array(0,0,1)); - $this->cchunk["footrefs"][] = $this->pdfDoc->add(PdfWriter::LINK_ANNOTATION, "[".($count + 1)."]"); - $this->pdfDoc->revertFont(); - $this->pdfDoc->setAppendToBuffer(true); - $this->pdfDoc->setFont(PdfWriter::FONT_BOLD, 12, array(0,0,1)); - $this->pdfDoc->appendText("[".($count + 1)."]"); - $this->pdfDoc->revertFont(); - return ""; - } - $this->pdfDoc->appendText("\n"); - $this->pdfDoc->setAppendToBuffer(false); - return ""; - } - - public function format_co($open, $name, $attrs, $props) { - if (($open || $props["empty"]) && isset($attrs[Reader::XMLNS_XML]["id"]) && $id = $attrs[Reader::XMLNS_XML]["id"]) { - $co = ++$this->cchunk["co"]; - $this->pdfDoc->setFont(PdfWriter::FONT_NORMAL, 12, array(0,0,1)); - if (isset($attrs[Reader::XMLNS_DOCBOOK]["linkends"]) && $linkends = $attrs[Reader::XMLNS_DOCBOOK]["linkends"]) { - $linkAreas = $this->pdfDoc->add(PdfWriter::LINK_ANNOTATION, "[{$co}]"); - if (!isset($this->cchunk["links-to-resolve"][$linkends])) - $this->cchunk["links-to-resolve"][$linkends] = array(); - foreach ($linkAreas as $area) - $this->cchunk["links-to-resolve"][$linkends][] = $area; - } - $this->pdfDoc->revertFont(); - } - return ""; - } - - public function format_calloutlist($open, $name, $attrs) { - if ($open) { - $this->pdfDoc->add(PdfWriter::FRAMED_BLOCK); - $this->pdfDoc->add(PdfWriter::LINE_JUMP); - $this->cchunk["co"] = 0; - } else { - $this->pdfDoc->add(PdfWriter::END_FRAMED_BLOCK, array(2)); // With Dash line - $this->cchunk["co"] = 0; - } - return ''; - } - - public function format_callout($open, $name, $attrs) { - if ($open) { - $co = ++$this->cchunk["co"]; - $this->pdfDoc->setFont(PdfWriter::FONT_BOLD, 12, array(0,0,1)); - if (isset($attrs[Reader::XMLNS_DOCBOOK]["arearefs"]) && $ref = $attrs[Reader::XMLNS_DOCBOOK]["arearefs"]) { - $linkAreas = $this->pdfDoc->add(PdfWriter::LINK_ANNOTATION, "[{$co}]"); - if (!isset($this->cchunk["links-to-resolve"][$ref])) - $this->cchunk["links-to-resolve"][$ref] = array(); - foreach ($linkAreas as $area) - $this->cchunk["links-to-resolve"][$ref][] = $area; - } - $this->pdfDoc->revertFont(); - } else { - $this->pdfDoc->add(PdfWriter::LINE_JUMP); - } - return ''; - } - // }}} Footnotes & Callouts - - public function format_quote_text($value, $tag) { - $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(preg_replace('/[ \n\t]+/', ' ', $value))); - return ""; - } - - public function format_refpurpose($open, $tag, $attrs, $props) { - if ($props["empty"]) { - $this->pdfDoc->add(PdfWriter::PARA); - foreach($this->cchunk["refname"] as $refname) { - $this->pdfDoc->appendText(" " . $refname . " --"); - } - $this->pdfDoc->add(PdfWriter::LINE_JUMP); - $this->cchunk["refname"] = array(); - } elseif ($open) { - $this->pdfDoc->add(PdfWriter::PARA); - foreach($this->cchunk["refname"] as $refname) { - $this->pdfDoc->appendText(" " . $refname . " --"); - } - } else { - $this->pdfDoc->add(PdfWriter::LINE_JUMP); - $this->cchunk["refname"] = array(); - } - return ""; - } - - public function format_manvolnum($open, $name, $attrs) { - if ($open) { - $this->pdfDoc->appendText(")"); - return ''; - } - $this->pdfDoc->appendText(")"); - return ''; - return ")"; - } - - public function format_indice($open, $name, $attrs) { - if (($open && $name == "subscript") || (!$open && $name == "superscript")) { - $this->pdfDoc->vOffset("-4"); - return ''; - } - $this->pdfDoc->vOffset("4"); - return ''; - } - - public function format_imagedata($open, $name, $attrs, $props) { - if ($props["empty"] && isset($this->cchunk["xml-base"]) && ($base = $this->cchunk["xml-base"]) && - isset($attrs[Reader::XMLNS_DOCBOOK]["fileref"]) && ($fileref = $attrs[Reader::XMLNS_DOCBOOK]["fileref"])) { - $imagePath = Config::xml_root() . DIRECTORY_SEPARATOR . $base . $fileref; - if (file_exists($imagePath)) - $this->pdfDoc->add(PdfWriter::IMAGE, $imagePath); - - } - return ''; - } - -} - -/* -* vim600: sw=4 ts=4 syntax=php et -* vim<600: sw=4 ts=4 -*/ diff --git a/phpdotnet/phd/Package/IDE/Factory.php b/phpdotnet/phd/Package/IDE/Factory.php deleted file mode 100644 index abbbda261..000000000 --- a/phpdotnet/phd/Package/IDE/Factory.php +++ /dev/null @@ -1,29 +0,0 @@ - 'Package_IDE_XML', - 'funclist' => 'Package_IDE_Funclist', - 'json' => 'Package_IDE_JSON', - 'php' => 'Package_IDE_PHP', - 'phpstub' => 'Package_IDE_PHPStub', - 'sqlite' => 'Package_IDE_SQLite', - ); - - /** - * The package version - */ - private $version = '@phd_ide_version@'; - - public function __construct() { - parent::setPackageName("IDE"); - parent::setPackageVersion($this->version); - parent::registerOutputFormats($this->formats); - } -} - -/* -* vim600: sw=4 ts=4 syntax=php et -* vim<600: sw=4 ts=4 -*/ diff --git a/phpdotnet/phd/Package/PEAR/Factory.php b/phpdotnet/phd/Package/PEAR/Factory.php deleted file mode 100644 index 2534e8051..000000000 --- a/phpdotnet/phd/Package/PEAR/Factory.php +++ /dev/null @@ -1,28 +0,0 @@ - 'Package_PEAR_ChunkedXHTML', - 'bigxhtml' => 'Package_PEAR_BigXHTML', - 'php' => 'Package_PEAR_Web', - 'chm' => 'Package_PEAR_CHM', - 'tocfeed' => 'Package_PEAR_TocFeed', - ); - - /** - * The package version - */ - private $version = '@phd_pear_version@'; - - public function __construct() { - parent::setPackageName("PEAR"); - parent::setPackageVersion($this->version); - parent::registerOutputFormats($this->formats); - } -} - -/* -* vim600: sw=4 ts=4 syntax=php et -* vim<600: sw=4 ts=4 -*/ diff --git a/phpdotnet/phd/Package/PHP/BigPDF.php b/phpdotnet/phd/Package/PHP/BigPDF.php deleted file mode 100644 index 54469f5f0..000000000 --- a/phpdotnet/phd/Package/PHP/BigPDF.php +++ /dev/null @@ -1,80 +0,0 @@ -registerFormatName("PHP-BigPDF"); - } - - public function update($event, $val = null) { - switch($event) { - case Render::STANDALONE: - if ($val) { - $this->registerElementMap(parent::getDefaultElementMap()); - $this->registerTextMap(parent::getDefaultTextMap()); - } - break; - - case Render::INIT: - $this->setOutputDir(Config::output_dir()); - break; - - case Render::VERBOSE: - v("Starting %s rendering", $this->getFormatName(), VERBOSE_FORMAT_RENDERING); - break; - } - } - - // Do nothing - public function appendData($data) {} - - public function format_root_set($open, $name, $attrs, $props) { - if ($open) { - parent::newChunk(); - $this->cchunk = $this->dchunk; - $pdfDoc = new PdfWriter(); - try { - $pdfDoc->setCompressionMode(\HaruDoc::COMP_ALL); - } catch (\HaruException $e) { - v("PDF Compression failed, you need to compile libharu with Zlib...", E_USER_WARNING); - } - parent::setPdfDoc($pdfDoc); - - if (isset($attrs[Reader::XMLNS_XML]["base"]) && $base = $attrs[Reader::XMLNS_XML]["base"]) - parent::setChunkInfo("xml-base", $base); - $id = $attrs[Reader::XMLNS_XML]["id"]; - $this->cchunk["root-outline"] = $this->cchunk["id-to-outline"][$id] = - $pdfDoc->createOutline(Format::getShortDescription($id), null, true); - $this->setIdToPage($id); - } else { - $this->resolveLinks($this->cchunk["setname"]); - $pdfDoc = parent::getPdfDoc(); - v("Writing Full PDF Manual (%s)", $this->cchunk["setname"], VERBOSE_TOC_WRITING); - - $filename = $this->getOutputDir(); - if (Config::output_filename()) { - $filename .= Config::output_filename(); - } else { - $filename .= strtolower($this->getFormatName()) . $this->getExt(); - } - - $pdfDoc->saveToFile($filename); - unset($pdfDoc); - } - return ""; - } - - public function format_set($open, $name, $attrs, $props) { - return $this->format_tocnode_newpage($open, $name, $attrs, $props); - } - - public function format_book($open, $name, $attrs, $props) { - return $this->format_tocnode_newpage($open, $name, $attrs, $props); - } -} - -/* -* vim600: sw=4 ts=4 syntax=php et -* vim<600: sw=4 ts=4 -*/ diff --git a/phpdotnet/phd/Package/PHP/Factory.php b/phpdotnet/phd/Package/PHP/Factory.php deleted file mode 100644 index 6b61f1da9..000000000 --- a/phpdotnet/phd/Package/PHP/Factory.php +++ /dev/null @@ -1,35 +0,0 @@ - 'Package_PHP_ChunkedXHTML', - 'bigxhtml' => 'Package_PHP_BigXHTML', - 'php' => 'Package_PHP_Web', - 'howto' => 'Package_PHP_HowTo', - 'manpage' => 'Package_PHP_Manpage', - 'pdf' => 'Package_PHP_PDF', - 'bigpdf' => 'Package_PHP_BigPDF', - 'kdevelop' => 'Package_PHP_KDevelop', - 'chm' => 'Package_PHP_CHM', - 'tocfeed' => 'Package_PHP_TocFeed', - 'epub' => 'Package_PHP_Epub', - 'enhancedchm' => 'Package_PHP_EnhancedCHM', - ); - - /** - * The package version - */ - private $version = '@phd_php_version@'; - - public function __construct() { - parent::setPackageName("PHP"); - parent::setPackageVersion($this->version); - parent::registerOutputFormats($this->formats); - } -} - -/* -* vim600: sw=4 ts=4 syntax=php et -* vim<600: sw=4 ts=4 -*/ diff --git a/phpdotnet/phd/Package/PHP/PDF.php b/phpdotnet/phd/Package/PHP/PDF.php deleted file mode 100644 index 9aab2742f..000000000 --- a/phpdotnet/phd/Package/PHP/PDF.php +++ /dev/null @@ -1,327 +0,0 @@ - 'format_tocnode_newpage', - 'appendix' => 'format_tocnode_newpage', - 'book' => 'format_book', - 'bibliography' => array( - /* DEFAULT */ 'format_suppressed_tags', - 'article' => 'format_tocnode_newpage', - 'book' => 'format_tocnode_newpage', - 'part' => 'format_tocnode_newpage', - ), - 'callout' => 'format_collect_id', - 'chapter' => 'format_tocnode_newpage', - 'co' => 'format_collect_id', - 'colophon' => 'format_tocnode_newpage', - 'footnote' => 'format_collect_id', - 'glossary' => array( - /* DEFAULT */ 'format_suppressed_tags', - 'article' => 'format_tocnode_newpage', - 'book' => 'format_tocnode_newpage', - 'part' => 'format_tocnode_newpage', - ), - 'index' => array( - /* DEFAULT */ 'format_suppressed_tags', - 'article' => 'format_tocnode_newpage', - 'book' => 'format_tocnode_newpage', - 'part' => 'format_tocnode_newpage', - ), - 'legalnotice' => 'format_tocnode_newpage', - 'part' => 'format_tocnode_newpage', - 'phpdoc:exceptionref' => 'format_tocnode_exception', - 'phpdoc:classref' => 'format_tocnode_class', - 'preface' => 'format_tocnode_newpage', - 'refentry' => 'format_tocnode_newpage', - 'reference' => 'format_tocnode_newpage', - 'phpdoc:varentry' => 'format_tocnode_newpage', - 'sect1' => 'format_tocnode', - 'sect2' => 'format_tocnode', - 'sect3' => 'format_tocnode', - 'sect4' => 'format_tocnode', - 'sect5' => 'format_tocnode', - 'section' => 'format_tocnode', - 'set' => array( - /* DEFAULT */ 'format_root_set', - 'set' => 'format_set', - ), - 'setindex' => 'format_tocnode_newpage', - - ); - - protected $textmap = array( - 'title' => array( - /* DEFAULT */ false, - 'book' => 'format_bookname', - 'set' => array( - /* DEFAULT */ 'format_setname', - 'set' => false, - ), - ), - 'type' => array( - /* DEFAULT */ 'format_type_text', - 'classsynopsisinfo' => false, - 'fieldsynopsis' => 'format_type_if_object_or_pseudo_text', - 'methodparam' => 'format_type_if_object_or_pseudo_text', - 'methodsynopsis' => array( - /* DEFAULT */ 'format_type_if_object_or_pseudo_text', - 'classsynopsis' => false, - ), - ), - 'titleabbrev' => array( - /* DEFAULT */ 'format_suppressed_tags', - 'phpdoc:classref' => 'format_grep_classname_text', - 'phpdoc:exceptionref' => 'format_grep_classname_text', - ), - - - ); - - private $acronyms = array(); - - /* Common properties for all functions pages */ - protected $bookName = ""; - - /* Current Chunk settings */ - protected $cchunk = array(); - /* Default Chunk settings */ - protected $dchunk = array( - "phpdoc:classref" => null, - "bookname" => null, - "setname" => null, - "toc-root" => null, - "id-to-outline" => array(), - "id-to-page" => array(), - "root-outline" => null, - ); - - public function __construct() { - parent::__construct(); - $this->registerFormatName("PHP-PDF"); - $this->setTitle("PHP Manual"); - } - - public function __destruct() {} - - public function update($event, $val = null) { - switch($event) { - case Render::STANDALONE: - if ($val) { - $this->registerElementMap($this->getDefaultElementMap()); - $this->registerTextMap($this->getDefaultTextMap()); - } else { - $this->registerElementMap($this->elementmap); - $this->registerTextMap($this->elementmap); - } - break; - - case Render::INIT: - if (!class_exists("HaruDoc")) die ("PDF output needs libharu & haru/pecl extensions... Please install them and start PhD again.\n"); - $this->setOutputDir(Config::output_dir() . strtolower($this->getFormatName()) . DIRECTORY_SEPARATOR); - if(!file_exists($this->getOutputDir()) || is_file($this->getOutputDir())) mkdir($this->getOutputDir(), 0777, true) or die("Can't create the cache directory.\n"); - break; - case Render::VERBOSE: - v("Starting %s rendering", $this->getFormatName(), VERBOSE_FORMAT_RENDERING); - break; - } - } - - public function getDefaultElementMap() { - return array_merge(parent::getDefaultElementMap(), $this->elementmap); - } - - public function getDefaultTextMap() { - return array_merge(parent::getDefaultTextMap(), $this->textmap); - } - - // Do nothing - public function appendData($data) {} - - // 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) { - parent::newChunk(); - $this->cchunk = $this->dchunk; - $pdfDoc = new PdfWriter(); - try { - $pdfDoc->setCompressionMode(\HaruDoc::COMP_ALL); - } catch (\HaruException $e) { - v("PDF Compression failed, you need to compile libharu with Zlib...", E_USER_WARNING); - } - parent::setPdfDoc($pdfDoc); - if (isset($attrs[Reader::XMLNS_XML]["base"]) && $base = $attrs[Reader::XMLNS_XML]["base"]) - parent::setChunkInfo("xml-base", $base); - - $id = $attrs[Reader::XMLNS_XML]["id"]; - $this->cchunk["root-outline"] = $this->cchunk["id-to-outline"][$id] = - $pdfDoc->createOutline(Format::getShortDescription($id), null, true); - $this->setIdToPage($id); - } else { - $this->resolveLinks($this->cchunk["bookname"]); - $pdfDoc = parent::getPdfDoc(); - v("Writing PDF Manual (%s)", $this->cchunk["bookname"], VERBOSE_TOC_WRITING); - $pdfDoc->saveToFile($this->getOutputDir() . $this->toValidName($this->cchunk["bookname"]) . $this->getExt()); - unset($pdfDoc); - } - return false; - } - - public function format_bookname($value, $tag) { - $this->cchunk["bookname"] = trim($value); - parent::getPdfDoc()->setCurrentBookName($this->cchunk["bookname"]); - parent::getPdfDoc()->appendText($this->cchunk["bookname"]); - return false; - } - - public function format_setname($value, $tag) { - $this->cchunk["setname"] = trim($value); - parent::getPdfDoc()->appendText($this->cchunk["setname"]); - return false; - } - - public function format_tocnode($open, $name, $attrs, $props, $newpage = false) { - if ($open) { - if ($newpage) { - parent::getPdfDoc()->add(PdfWriter::PAGE); - } else { - parent::getPdfDoc()->add(PdfWriter::LINE_JUMP); - } - if (isset($attrs[Reader::XMLNS_XML]["base"]) && $base = $attrs[Reader::XMLNS_XML]["base"]) { - parent::setChunkInfo("xml-base", $base); - } - - if (isset($attrs[Reader::XMLNS_XML]["id"]) && $id = $attrs[Reader::XMLNS_XML]["id"]) { - $parentId = Format::getParent($id); - if (isset($this->cchunk["id-to-outline"][$parentId])) { - $this->cchunk["id-to-outline"][$id] = parent::getPdfDoc()->createOutline - (Format::getShortDescription($id), $this->cchunk["id-to-outline"][$parentId], false); - } else { - $this->cchunk["id-to-outline"][$id] = parent::getPdfDoc()->createOutline - (Format::getShortDescription($id), $this->cchunk["root-outline"], false); - } - $this->setIdToPage($id); - } - parent::setChunkInfo("examplenumber", 0); - } - 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); - } - - 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] = parent::getPdfDoc()->getCurrentPage(); - } - } - - protected function resolveLinks($name) { - v("Resolving Internal Links... (%s)", $name, VERBOSE_TOC_WRITING); - $linksToResolve = parent::getChunkInfo("links-to-resolve"); - foreach ($linksToResolve as $link => $targets) { - if (isset($this->cchunk["id-to-page"][$link]) && $destPage = $this->cchunk["id-to-page"][$link]) { - foreach ($targets as $target) { - $page = $target[0]; - $rectangle = array($target[1], $target[2], $target[3], $target[4]); - parent::getPdfDoc()->resolveInternalLink($page, $rectangle, $destPage); - - } - } - } - } - - public function format_type_text($type, $tagname) { - $type = trim(preg_replace('/[ \n\t]+/', ' ', $type)); - $t = strtolower($type); - $href = $fragment = ""; - - switch($t) { - case "bool": - $href = "language.types.boolean"; - break; - case "int": - case "long": - $href = "language.types.integer"; - break; - case "double": - $href = "language.types.float"; - break; - case "void": - case "boolean": - case "integer": - case "float": - case "string": - case "array": - case "object": - case "resource": - case "null": - case "callable": - case "iterable": - $href = "language.types.$t"; - break; - case "mixed": - $href = "language.types.declarations"; - $fragment = "language.types.declarations.$t"; - break; - default: - /* Check if its a classname. */ - $t = strtolower(str_replace(array("_", "::", "->"), array("-", "-", "-"), $t)); - $href = Format::getFilename("class.$t"); - } - - parent::getPdfDoc()->setFont(PdfWriter::FONT_NORMAL, 12, array(0, 0, 1)); // blue - $linkAreas = parent::getPdfDoc()->add(PdfWriter::LINK_ANNOTATION, $type); - $linksToResolve = parent::getChunkInfo("links-to-resolve"); - if (!isset($linksToResolve[$href])) - $linksToResolve[$href] = array(); - foreach ($linkAreas as $area) - $linksToResolve[$href][] = $area; - parent::setChunkInfo("links-to-resolve", $linksToResolve); - parent::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"))) { - parent::getPdfDoc()->appendText(" " . $type); - return false; - } - return self::format_type_text($type, $tagname); - } - - public function format_collect_id($open, $name, $attrs, $props, $newpage = false) { - if ($open && isset($attrs[Reader::XMLNS_XML]["id"]) && $id = $attrs[Reader::XMLNS_XML]["id"]) { - $this->setIdToPage($id); - } - return false; - } - -} - -/* -* vim600: sw=4 ts=4 syntax=php et -* vim<600: sw=4 ts=4 -*/ diff --git a/render.php b/render.php index 6002596ab..5346d6be4 100644 --- a/render.php +++ b/render.php @@ -4,13 +4,11 @@ // @php_dir@ gets replaced by pear with the install dir. use __DIR__ when // running from SVN -define("__INSTALLDIR__", '@php_dir@' == '@'.'php_dir@' ? __DIR__ : '@php_dir@'); - -require __INSTALLDIR__ . '/phpdotnet/phd/Autoloader.php'; -require __INSTALLDIR__ . '/phpdotnet/phd/functions.php'; - -spl_autoload_register(array(__NAMESPACE__ . "\\Autoloader", "autoload")); +use phpdotnet\phd\Format\Factory; +use phpdotnet\phd\Options\Parser; +use phpdotnet\phd\Reader\Partial; +require_once __DIR__ . "/vendor/autoload.php"; $conf = array(); if (file_exists("phd.config.php")) { @@ -22,7 +20,7 @@ Config::init(array()); } -Options_Parser::getopt(); +Parser::getopt(); /* If no docbook file was passed, die */ if (!is_dir(Config::xml_root()) || !is_file(Config::xml_file())) { @@ -63,7 +61,7 @@ function make_reader() { $idlist = Config::render_ids() + Config::skip_ids(); if (!empty($idlist)) { v("Running partial build", VERBOSE_RENDER_STYLE); - $reader = new Reader_Partial(); + $reader = new Partial(); } else { v("Running full build", VERBOSE_RENDER_STYLE); $reader = new Reader(); @@ -99,7 +97,7 @@ function make_reader() { } foreach((array)Config::package() as $package) { - $factory = Format_Factory::createFactory($package); + $factory = Factory::createFactory($package); // Default to all output formats specified by the package if (count(Config::output_format()) == 0) { diff --git a/phpdotnet/phd/Config.php b/src/Config.php similarity index 95% rename from phpdotnet/phd/Config.php rename to src/Config.php index 686870a98..43d54dda1 100644 --- a/phpdotnet/phd/Config.php +++ b/src/Config.php @@ -1,9 +1,7 @@ '01;32', // Green 'phd_warning_output' => STDOUT, 'phd_warning_color' => '01;35', // Magenta - 'highlighter' => 'phpdotnet\\phd\\Highlighter', + 'highlighter' => Highlighter::class, 'package' => array( 'Generic', ), @@ -143,7 +141,7 @@ public static function __callStatic($name, $params) public static function getSupportedPackages() { $packageList = array(); foreach(Config::package_dirs() as $dir) { - foreach (glob($dir . "/phpdotnet/phd/Package/*", GLOB_ONLYDIR) as $item) { + foreach (glob($dir . "/src/Package/*", GLOB_ONLYDIR) as $item) { $baseitem = basename($item); if ($baseitem[0] != '.') { $packageList[] = $baseitem; diff --git a/phpdotnet/phd/Format.php b/src/Format.php similarity index 99% rename from phpdotnet/phd/Format.php rename to src/Format.php index 29aa37230..5b6fb56ba 100644 --- a/phpdotnet/phd/Format.php +++ b/src/Format.php @@ -125,8 +125,7 @@ public final function parsePI($target, $data) { } public final function registerPIHandlers($pihandlers) { - foreach ($pihandlers as $target => $classname) { - $class = __NAMESPACE__ . "\\" . $classname; + foreach ($pihandlers as $target => $class) { $this->pihandlers[$target] = new $class($this); } } diff --git a/phpdotnet/phd/Format/Factory.php b/src/Format/Factory.php similarity index 82% rename from phpdotnet/phd/Format/Factory.php rename to src/Format/Factory.php index 0e6e54888..ec64c3110 100644 --- a/phpdotnet/phd/Format/Factory.php +++ b/src/Format/Factory.php @@ -1,7 +1,10 @@ optionsHandler; } - public final function registerOptionsHandler(Options_Interface $optionsHandler) { + public final function registerOptionsHandler(OptionsInterface $optionsHandler) { $this->optionsHandler = $optionsHandler; } @@ -41,7 +44,7 @@ public final function getPackageName() { public final function createFormat($format) { if (isset($this->formats[$format]) && $this->formats[$format]) { - $classname = __NAMESPACE__ . "\\" . $this->formats[$format]; + $classname = $this->formats[$format]; $obj = new $classname(); if (!($obj instanceof Format)) { @@ -60,11 +63,11 @@ public static final function createFactory($package) { } if (!isset($factories[$package])) { - $classname = __NAMESPACE__ . "\\Package_" . $package . "_Factory"; + $classname = __NAMESPACE__ . "\\Package\\" . $package . "\\Factory"; $factory = new $classname(); - if (!($factory instanceof Format_Factory)) { - throw new \Exception("All Factories must inherit Format_Factory"); + if (!($factory instanceof Factory)) { + throw new \Exception("All Factories must inherit " . Factory::class); } $factories[$package] = $factory; } diff --git a/phpdotnet/phd/Format/Abstract/Manpage.php b/src/Format/_Abstract/Manpage.php similarity index 92% rename from phpdotnet/phd/Format/Abstract/Manpage.php rename to src/Format/_Abstract/Manpage.php index 845e185f2..2160edeb9 100644 --- a/phpdotnet/phd/Format/Abstract/Manpage.php +++ b/src/Format/_Abstract/Manpage.php @@ -1,7 +1,9 @@ 'PI_DBHTMLHandler', - 'phpdoc' => 'PI_PHPDOCHandler', + 'dbhtml' => DBHTMLHandler::class, + 'phpdoc' => PHPDOCHandler::class, ); private $chunks = array(); @@ -168,6 +171,7 @@ public function update($event, $value = null) if (Config::memoryindex()) { $db = new \SQLite3(":memory:"); } else { + var_dump(Config::output_dir() . 'index.sqlite'); $db = new \SQLite3(Config::output_dir() . 'index.sqlite'); $db->exec('DROP TABLE IF EXISTS ids'); $db->exec('DROP TABLE IF EXISTS indexing'); diff --git a/phpdotnet/phd/MediaManager.php b/src/MediaManager.php similarity index 100% rename from phpdotnet/phd/MediaManager.php rename to src/MediaManager.php diff --git a/phpdotnet/phd/ObjectStorage.php b/src/ObjectStorage.php similarity index 85% rename from phpdotnet/phd/ObjectStorage.php rename to src/ObjectStorage.php index 5810d5524..dc964a8e0 100644 --- a/phpdotnet/phd/ObjectStorage.php +++ b/src/ObjectStorage.php @@ -6,7 +6,7 @@ class ObjectStorage extends \SplObjectStorage public function attach($obj, $inf = array()): void { if (!($obj instanceof Format)) { throw new \InvalidArgumentException( - 'Only classess inheriting ' . __NAMESPACE__ . '\\Format supported' + 'Only classess inheriting ' . Format::class . ' supported' ); } if (empty($inf)) { diff --git a/phpdotnet/phd/Options/Handler.php b/src/Options/Handler.php similarity index 97% rename from phpdotnet/phd/Options/Handler.php rename to src/Options/Handler.php index df3c7c2e3..5736922d2 100644 --- a/phpdotnet/phd/Options/Handler.php +++ b/src/Options/Handler.php @@ -1,7 +1,13 @@ getOutputFormats(); + $formats = Factory::createFactory($package)->getOutputFormats(); echo "\t" . $package . "\n\t\t" . implode("\n\t\t", $formats) . "\n"; } @@ -375,7 +381,7 @@ public function option_version($k, $v) $packageList = Config::getSupportedPackages(); foreach ($packageList as $package) { - $version = Format_Factory::createFactory($package)->getPackageVersion(); + $version = Factory::createFactory($package)->getPackageVersion(); fprintf($output, "\t%s: %s\n", term_color($package, $color), term_color($version, $color)); } fprintf($output, "%s\n", term_color('PHP Version: ' . phpversion(), $color)); diff --git a/phpdotnet/phd/Options/Interface.php b/src/Options/OptionsInterface.php similarity index 62% rename from phpdotnet/phd/Options/Interface.php rename to src/Options/OptionsInterface.php index a2a77f472..6641380b2 100644 --- a/phpdotnet/phd/Options/Interface.php +++ b/src/Options/OptionsInterface.php @@ -1,7 +1,7 @@ defaultHandler = new Options_Handler(); + $this->defaultHandler = new Handler(); $this->packageHandlers = $this->loadPackageHandlers(); } @@ -24,7 +28,7 @@ private function loadPackageHandlers() { $packageList = Config::getSupportedPackages(); $list = array(); foreach ($packageList as $package) { - if ($handler = Format_Factory::createFactory($package)->getOptionsHandler()) { + if ($handler = Factory::createFactory($package)->getOptionsHandler()) { $list[strtolower($package)] = $handler; } } diff --git a/phpdotnet/phd/PI/DBHTMLHandler.php b/src/PI/DBHTMLHandler.php similarity index 97% rename from phpdotnet/phd/PI/DBHTMLHandler.php rename to src/PI/DBHTMLHandler.php index 7eca27f0e..7814b93e8 100644 --- a/phpdotnet/phd/PI/DBHTMLHandler.php +++ b/src/PI/DBHTMLHandler.php @@ -1,7 +1,9 @@ "", "bgcolor" => "", diff --git a/phpdotnet/phd/PI/PHPDOCHandler.php b/src/PI/PHPDOCHandler.php similarity index 98% rename from phpdotnet/phd/PI/PHPDOCHandler.php rename to src/PI/PHPDOCHandler.php index 2101cd0d9..a95e2b105 100644 --- a/phpdotnet/phd/PI/PHPDOCHandler.php +++ b/src/PI/PHPDOCHandler.php @@ -1,7 +1,10 @@ registerFormatName("Big-XHTML"); diff --git a/phpdotnet/phd/Package/Generic/ChunkedXHTML.php b/src/Package/Generic/ChunkedXHTML.php similarity index 96% rename from phpdotnet/phd/Package/Generic/ChunkedXHTML.php rename to src/Package/Generic/ChunkedXHTML.php index 62412491c..4d302ea42 100644 --- a/phpdotnet/phd/Package/Generic/ChunkedXHTML.php +++ b/src/Package/Generic/ChunkedXHTML.php @@ -1,7 +1,13 @@ registerFormatName("Chunked-XHTML"); diff --git a/phpdotnet/phd/Package/Generic/Factory.php b/src/Package/Generic/Factory.php similarity index 60% rename from phpdotnet/phd/Package/Generic/Factory.php rename to src/Package/Generic/Factory.php index 53893d1b5..6d4b89a78 100644 --- a/phpdotnet/phd/Package/Generic/Factory.php +++ b/src/Package/Generic/Factory.php @@ -1,7 +1,10 @@ 'Package_Generic_ChunkedXHTML', - 'bigxhtml' => 'Package_Generic_BigXHTML', - 'manpage' => 'Package_Generic_Manpage', + 'xhtml' => ChunkedXHTML::class, + 'bigxhtml' => BigXHTML::class, + 'manpage' => Manpage::class, ); /** diff --git a/phpdotnet/phd/Package/Generic/Manpage.php b/src/Package/Generic/Manpage.php similarity index 99% rename from phpdotnet/phd/Package/Generic/Manpage.php rename to src/Package/Generic/Manpage.php index 9d792336b..dcfcc3410 100644 --- a/phpdotnet/phd/Package/Generic/Manpage.php +++ b/src/Package/Generic/Manpage.php @@ -1,7 +1,13 @@ 'div', /* Docbook-xsl prints "abstract"... */ 'abbrev' => 'abbr', @@ -458,8 +466,8 @@ abstract class Package_Generic_XHTML extends Format_Abstract_XHTML { ); protected $pihandlers = array( - 'dbhtml' => 'PI_DBHTMLHandler', - 'dbtimestamp' => 'PI_DBHTMLHandler', + 'dbhtml' => DBHTMLHandler::class, + 'dbtimestamp' => DBHTMLHandler::class, ); protected $stylesheets = array(); diff --git a/phpdotnet/phd/Package/IDE/API.php b/src/Package/IDE/API.php similarity index 91% rename from phpdotnet/phd/Package/IDE/API.php rename to src/Package/IDE/API.php index 6764f8a31..d64e83f5a 100644 --- a/phpdotnet/phd/Package/IDE/API.php +++ b/src/Package/IDE/API.php @@ -10,7 +10,9 @@ * @license http://www.opensource.org/licenses/bsd-license.php BSD Style * @link https://doc.php.net/phd/ */ -namespace phpdotnet\phd; +namespace phpdotnet\phd\Package\IDE; + +use phpdotnet\phd\Package\IDE\API\_Function; /** * Class to load and parse the files generated by the PhD IDE Package. @@ -28,7 +30,7 @@ * @license http://www.opensource.org/licenses/bsd-license.php BSD Style * @link https://doc.php.net/phd/ */ -class Package_IDE_API +class API { /** * Output directory of the functions format in the IDE Package. @@ -59,7 +61,7 @@ class Package_IDE_API private $funclist; /** - * Creates a new instace of Package_IDE_API. + * Creates a new instance of API. * * @param string $dir PhD output directory. */ @@ -80,10 +82,10 @@ public function __construct($dir) } /** - * Loads a function file and returns a Package_IDE_API_Function. + * Loads a function file and returns a _Function. * * @param string $filename File of the function. - * @return Package_IDE_API_Function Object representing the function. + * @return _Function Object representing the function. */ private function loadFunction($filename) { @@ -91,7 +93,7 @@ private function loadFunction($filename) return NULL; } $xml = simplexml_load_file($filename); - return new Package_IDE_API_Function($xml); + return new _Function($xml); } /** @@ -122,7 +124,7 @@ public function getFunctionList() * * @param string $functionName Function name. * @param string $class TODO. - * @return Package_IDE_API_Function A function object. + * @return _Function A function object. */ public function getFunctionByName($functionName, $class = null) { @@ -150,7 +152,6 @@ public function getMethodsByClass($className) return $methods; } } - /* * vim600: sw=4 ts=4 syntax=php et * vim<600: sw=4 ts=4 diff --git a/phpdotnet/phd/Package/IDE/API/Param.php b/src/Package/IDE/API/Param.php similarity index 97% rename from phpdotnet/phd/Package/IDE/API/Param.php rename to src/Package/IDE/API/Param.php index 4b67f7f96..7564fe683 100644 --- a/phpdotnet/phd/Package/IDE/API/Param.php +++ b/src/Package/IDE/API/Param.php @@ -10,7 +10,9 @@ * @license http://www.opensource.org/licenses/bsd-license.php BSD Style * @link https://doc.php.net/phd/ */ -namespace phpdotnet\phd; +namespace phpdotnet\phd\Package\IDE\API; + +use SimpleXMLElement; /** * Class to parse the function parameters. @@ -21,7 +23,7 @@ * @license http://www.opensource.org/licenses/bsd-license.php BSD Style * @link https://doc.php.net/phd/ */ -class Package_IDE_API_Param +class Param { /** * Parameter name. diff --git a/phpdotnet/phd/Package/IDE/API/Function.php b/src/Package/IDE/API/_Function.php similarity index 97% rename from phpdotnet/phd/Package/IDE/API/Function.php rename to src/Package/IDE/API/_Function.php index b7de4275f..f6b458e98 100644 --- a/phpdotnet/phd/Package/IDE/API/Function.php +++ b/src/Package/IDE/API/_Function.php @@ -10,7 +10,10 @@ * @license http://www.opensource.org/licenses/bsd-license.php BSD Style * @link https://doc.php.net/phd/ */ -namespace phpdotnet\phd; +namespace phpdotnet\phd\Package\IDE\API; + +use phpdotnet\phd\Package\IDE\API\Param; +use SimpleXMLElement; /** * Class to parse the IDE Function xml. @@ -21,7 +24,7 @@ * @license http://www.opensource.org/licenses/bsd-license.php BSD Style * @link https://doc.php.net/phd/ */ -class Package_IDE_API_Function +class _Function { /** * Function name. @@ -123,7 +126,7 @@ public function __construct(\SimpleXMLElement $xmlElement) if (isset($xmlElement->params->param)) { foreach ($xmlElement->params->param as $param) { - $this->params[] = new Package_IDE_API_Param($param); + $this->params[] = new Param($param); } } if (isset($xmlElement->seealso->entry)) { diff --git a/phpdotnet/phd/Package/IDE/Base.php b/src/Package/IDE/Base.php similarity index 97% rename from phpdotnet/phd/Package/IDE/Base.php rename to src/Package/IDE/Base.php index 0b23ba3bc..9976b236a 100644 --- a/phpdotnet/phd/Package/IDE/Base.php +++ b/src/Package/IDE/Base.php @@ -1,7 +1,15 @@ 'format_notes', 'entry' => 'format_changelog_entry', @@ -112,7 +120,7 @@ function writeChunk() { public function renderHTML() { static $format = null; if ($format == null) { - $format = new Package_Generic_ChunkedXHTML(); + $format = new ChunkedXHTML(); } return $format->parse(trim(ReaderKeeper::getReader()->readInnerXML())); } diff --git a/src/Package/IDE/Factory.php b/src/Package/IDE/Factory.php new file mode 100644 index 000000000..5c4898520 --- /dev/null +++ b/src/Package/IDE/Factory.php @@ -0,0 +1,29 @@ + XML::class, + 'funclist' => Funclist::class, + 'json' => JSON::class, + 'php' => PHP::class, + 'phpstub' => PHPStub::class, + 'sqlite' => SQLite::class, + ); + + /** + * The package version + */ + private $version = '@phd_ide_version@'; + + public function __construct() { + parent::setPackageName("IDE"); + parent::setPackageVersion($this->version); + parent::registerOutputFormats($this->formats); + } +} + +/* +* vim600: sw=4 ts=4 syntax=php et +* vim<600: sw=4 ts=4 +*/ diff --git a/phpdotnet/phd/Package/IDE/Funclist.php b/src/Package/IDE/Funclist.php similarity index 91% rename from phpdotnet/phd/Package/IDE/Funclist.php rename to src/Package/IDE/Funclist.php index 4a3cec0b3..904a823ab 100644 --- a/phpdotnet/phd/Package/IDE/Funclist.php +++ b/src/Package/IDE/Funclist.php @@ -1,7 +1,13 @@ 'format_refname', 'set' => 'format_set', diff --git a/phpdotnet/phd/Package/IDE/JSON.php b/src/Package/IDE/JSON.php similarity index 72% rename from phpdotnet/phd/Package/IDE/JSON.php rename to src/Package/IDE/JSON.php index 024206c1d..2f94827d5 100644 --- a/phpdotnet/phd/Package/IDE/JSON.php +++ b/src/Package/IDE/JSON.php @@ -1,7 +1,10 @@ registerFormatName('IDE-JSON'); diff --git a/phpdotnet/phd/Package/IDE/PHP.php b/src/Package/IDE/PHP.php similarity index 77% rename from phpdotnet/phd/Package/IDE/PHP.php rename to src/Package/IDE/PHP.php index 3a4a9a216..b7206e769 100644 --- a/phpdotnet/phd/Package/IDE/PHP.php +++ b/src/Package/IDE/PHP.php @@ -1,7 +1,10 @@ registerFormatName('IDE-PHP'); diff --git a/phpdotnet/phd/Package/IDE/PHPStub.php b/src/Package/IDE/PHPStub.php similarity index 95% rename from phpdotnet/phd/Package/IDE/PHPStub.php rename to src/Package/IDE/PHPStub.php index d00c05383..324576eee 100644 --- a/phpdotnet/phd/Package/IDE/PHPStub.php +++ b/src/Package/IDE/PHPStub.php @@ -1,6 +1,9 @@ registerFormatName('IDE-PHPStub'); diff --git a/phpdotnet/phd/Package/IDE/SQLite.php b/src/Package/IDE/SQLite.php similarity index 97% rename from phpdotnet/phd/Package/IDE/SQLite.php rename to src/Package/IDE/SQLite.php index 4a2e747a0..5c76fc03f 100644 --- a/phpdotnet/phd/Package/IDE/SQLite.php +++ b/src/Package/IDE/SQLite.php @@ -1,7 +1,10 @@ registerFormatName('IDE-XML'); diff --git a/phpdotnet/phd/Package/IDE/demo.php b/src/Package/IDE/demo.php similarity index 92% rename from phpdotnet/phd/Package/IDE/demo.php rename to src/Package/IDE/demo.php index 35786a5f8..6fb508d0c 100644 --- a/phpdotnet/phd/Package/IDE/demo.php +++ b/src/Package/IDE/demo.php @@ -2,13 +2,7 @@ getMethodsByClass($OPTION['class']); diff --git a/phpdotnet/phd/Package/PEAR/BigXHTML.php b/src/Package/PEAR/BigXHTML.php old mode 100755 new mode 100644 similarity index 94% rename from phpdotnet/phd/Package/PEAR/BigXHTML.php rename to src/Package/PEAR/BigXHTML.php index f3de3d79e..9d24b361a --- a/phpdotnet/phd/Package/PEAR/BigXHTML.php +++ b/src/Package/PEAR/BigXHTML.php @@ -1,7 +1,12 @@ registerFormatName("PEAR-BigXHTML"); diff --git a/phpdotnet/phd/Package/PEAR/CHM.php b/src/Package/PEAR/CHM.php old mode 100755 new mode 100644 similarity index 98% rename from phpdotnet/phd/Package/PEAR/CHM.php rename to src/Package/PEAR/CHM.php index b6fc58f5f..139c9c8dd --- a/phpdotnet/phd/Package/PEAR/CHM.php +++ b/src/Package/PEAR/CHM.php @@ -1,7 +1,14 @@ registerFormatName("PEAR-Chunked-XHTML"); diff --git a/src/Package/PEAR/Factory.php b/src/Package/PEAR/Factory.php new file mode 100644 index 000000000..2dd7cf3e3 --- /dev/null +++ b/src/Package/PEAR/Factory.php @@ -0,0 +1,32 @@ + ChunkedXHTML::class, + 'bigxhtml' => BigXHTML::class, + 'php' => Web::class, + 'chm' => CHM::class, + 'tocfeed' => TocFeed::class, + ); + + /** + * The package version + */ + private $version = '@phd_pear_version@'; + + public function __construct() { + parent::setPackageName("PEAR"); + parent::setPackageVersion($this->version); + parent::registerOutputFormats($this->formats); + } +} + +/* +* vim600: sw=4 ts=4 syntax=php et +* vim<600: sw=4 ts=4 +*/ diff --git a/phpdotnet/phd/Package/PEAR/TocFeed.php b/src/Package/PEAR/TocFeed.php similarity index 94% rename from phpdotnet/phd/Package/PEAR/TocFeed.php rename to src/Package/PEAR/TocFeed.php index da3490325..f9a9f7933 100644 --- a/phpdotnet/phd/Package/PEAR/TocFeed.php +++ b/src/Package/PEAR/TocFeed.php @@ -1,5 +1,7 @@ 'format_div', 'abbrev' => 'abbr', diff --git a/phpdotnet/phd/Package/PHP/BigXHTML.php b/src/Package/PHP/BigXHTML.php similarity index 94% rename from phpdotnet/phd/Package/PHP/BigXHTML.php rename to src/Package/PHP/BigXHTML.php index 89662faa7..0c7618801 100644 --- a/phpdotnet/phd/Package/PHP/BigXHTML.php +++ b/src/Package/PHP/BigXHTML.php @@ -1,7 +1,12 @@ registerFormatName("PHP-BigXHTML"); diff --git a/phpdotnet/phd/Package/PHP/CHM.php b/src/Package/PHP/CHM.php similarity index 98% rename from phpdotnet/phd/Package/PHP/CHM.php rename to src/Package/PHP/CHM.php index 36692bf61..d3330524d 100644 --- a/phpdotnet/phd/Package/PHP/CHM.php +++ b/src/Package/PHP/CHM.php @@ -1,7 +1,13 @@ ChunkedXHTML::class, + 'bigxhtml' => BigXHTML::class, + 'php' => Web::class, + 'howto' => HowTo::class, + 'manpage' => Manpage::class, + 'kdevelop' => KDevelop::class, + 'chm' => CHM::class, + 'tocfeed' => TocFeed::class, + 'epub' => Epub::class, + 'enhancedchm' => EnhancedCHM::class, + ); + + /** + * The package version + */ + private $version = '@phd_php_version@'; + + public function __construct() { + parent::setPackageName("PHP"); + parent::setPackageVersion($this->version); + parent::registerOutputFormats($this->formats); + } +} + +/* +* vim600: sw=4 ts=4 syntax=php et +* vim<600: sw=4 ts=4 +*/ diff --git a/phpdotnet/phd/Package/PHP/HOWTO.GENERATE_CHM b/src/Package/PHP/HOWTO.GENERATE_CHM similarity index 100% rename from phpdotnet/phd/Package/PHP/HOWTO.GENERATE_CHM rename to src/Package/PHP/HOWTO.GENERATE_CHM diff --git a/phpdotnet/phd/Package/PHP/HowTo.php b/src/Package/PHP/HowTo.php similarity index 93% rename from phpdotnet/phd/Package/PHP/HowTo.php rename to src/Package/PHP/HowTo.php index 4648d9492..7f0c3e7d3 100644 --- a/phpdotnet/phd/Package/PHP/HowTo.php +++ b/src/Package/PHP/HowTo.php @@ -1,7 +1,13 @@ 'format_chunk', diff --git a/phpdotnet/phd/Package/PHP/README b/src/Package/PHP/README similarity index 100% rename from phpdotnet/phd/Package/PHP/README rename to src/Package/PHP/README diff --git a/phpdotnet/phd/Package/PHP/TocFeed.php b/src/Package/PHP/TocFeed.php similarity index 96% rename from phpdotnet/phd/Package/PHP/TocFeed.php rename to src/Package/PHP/TocFeed.php index 70b33f6fa..2eb707bfb 100644 --- a/phpdotnet/phd/Package/PHP/TocFeed.php +++ b/src/Package/PHP/TocFeed.php @@ -1,5 +1,8 @@ 'format_suppressed_tags', 'appendix' => 'format_container_chunk', @@ -171,9 +179,9 @@ abstract class Package_PHP_XHTML extends Package_Generic_XHTML { private $simple_nullable = null; protected $pihandlers = array( - 'dbhtml' => 'PI_DBHTMLHandler', - 'dbtimestamp' => 'PI_DBHTMLHandler', - 'phpdoc' => 'PI_PHPDOCHandler', + 'dbhtml' => DBHTMLHandler::class, + 'dbtimestamp' => DBHTMLHandler::class, + 'phpdoc' => PHPDOCHandler::class, ); public function __construct() { @@ -534,7 +542,7 @@ public function format_type_if_object_or_pseudo_text($type, $tagname) { } public function format_type_text($type, $tagname) { - $t = strtr(strtolower($type), ["_" => "-", "\\" => "-"]); + $t = \strtr(strtolower($type), ["_" => "-", "\\" => "-"]); $href = $fragment = ""; switch($t) { diff --git a/phpdotnet/phd/Reader.php b/src/Reader.php similarity index 100% rename from phpdotnet/phd/Reader.php rename to src/Reader.php diff --git a/phpdotnet/phd/Reader/Partial.php b/src/Reader/Partial.php similarity index 96% rename from phpdotnet/phd/Reader/Partial.php rename to src/Reader/Partial.php index 0c8cda3f2..a6063546a 100644 --- a/phpdotnet/phd/Reader/Partial.php +++ b/src/Reader/Partial.php @@ -1,7 +1,11 @@ notify(Render::STANDALONE, true); diff --git a/phpdotnet/phd/data/langs/bg.ini b/src/data/langs/bg.ini similarity index 100% rename from phpdotnet/phd/data/langs/bg.ini rename to src/data/langs/bg.ini diff --git a/phpdotnet/phd/data/langs/cs.ini b/src/data/langs/cs.ini similarity index 100% rename from phpdotnet/phd/data/langs/cs.ini rename to src/data/langs/cs.ini diff --git a/phpdotnet/phd/data/langs/da.ini b/src/data/langs/da.ini similarity index 100% rename from phpdotnet/phd/data/langs/da.ini rename to src/data/langs/da.ini diff --git a/phpdotnet/phd/data/langs/de.ini b/src/data/langs/de.ini similarity index 100% rename from phpdotnet/phd/data/langs/de.ini rename to src/data/langs/de.ini diff --git a/phpdotnet/phd/data/langs/en.ini b/src/data/langs/en.ini similarity index 100% rename from phpdotnet/phd/data/langs/en.ini rename to src/data/langs/en.ini diff --git a/phpdotnet/phd/data/langs/es.ini b/src/data/langs/es.ini similarity index 100% rename from phpdotnet/phd/data/langs/es.ini rename to src/data/langs/es.ini diff --git a/phpdotnet/phd/data/langs/fr.ini b/src/data/langs/fr.ini similarity index 100% rename from phpdotnet/phd/data/langs/fr.ini rename to src/data/langs/fr.ini diff --git a/phpdotnet/phd/data/langs/it.ini b/src/data/langs/it.ini similarity index 100% rename from phpdotnet/phd/data/langs/it.ini rename to src/data/langs/it.ini diff --git a/phpdotnet/phd/data/langs/ja.ini b/src/data/langs/ja.ini similarity index 100% rename from phpdotnet/phd/data/langs/ja.ini rename to src/data/langs/ja.ini diff --git a/phpdotnet/phd/data/langs/no.ini b/src/data/langs/no.ini similarity index 100% rename from phpdotnet/phd/data/langs/no.ini rename to src/data/langs/no.ini diff --git a/phpdotnet/phd/data/langs/pl.ini b/src/data/langs/pl.ini similarity index 100% rename from phpdotnet/phd/data/langs/pl.ini rename to src/data/langs/pl.ini diff --git a/phpdotnet/phd/data/langs/pt_BR.ini b/src/data/langs/pt_BR.ini similarity index 100% rename from phpdotnet/phd/data/langs/pt_BR.ini rename to src/data/langs/pt_BR.ini diff --git a/phpdotnet/phd/data/langs/ro.ini b/src/data/langs/ro.ini similarity index 100% rename from phpdotnet/phd/data/langs/ro.ini rename to src/data/langs/ro.ini diff --git a/phpdotnet/phd/data/langs/ru.ini b/src/data/langs/ru.ini similarity index 100% rename from phpdotnet/phd/data/langs/ru.ini rename to src/data/langs/ru.ini diff --git a/phpdotnet/phd/data/langs/sr.ini b/src/data/langs/sr.ini similarity index 100% rename from phpdotnet/phd/data/langs/sr.ini rename to src/data/langs/sr.ini diff --git a/phpdotnet/phd/data/langs/sv.ini b/src/data/langs/sv.ini similarity index 100% rename from phpdotnet/phd/data/langs/sv.ini rename to src/data/langs/sv.ini diff --git a/phpdotnet/phd/data/langs/tr.ini b/src/data/langs/tr.ini similarity index 100% rename from phpdotnet/phd/data/langs/tr.ini rename to src/data/langs/tr.ini diff --git a/phpdotnet/phd/data/langs/uk.ini b/src/data/langs/uk.ini similarity index 100% rename from phpdotnet/phd/data/langs/uk.ini rename to src/data/langs/uk.ini diff --git a/phpdotnet/phd/data/langs/zh.ini b/src/data/langs/zh.ini similarity index 100% rename from phpdotnet/phd/data/langs/zh.ini rename to src/data/langs/zh.ini diff --git a/phpdotnet/phd/functions.php b/src/functions.php similarity index 98% rename from phpdotnet/phd/functions.php rename to src/functions.php index 5c620d8d2..540f712ca 100644 --- a/phpdotnet/phd/functions.php +++ b/src/functions.php @@ -32,8 +32,8 @@ define('VERBOSE_ALL', (VERBOSE_OLD_LIBXML << 1) - 1); define('VERBOSE_DEFAULT', (VERBOSE_ALL^(VERBOSE_PARTIAL_CHILD_READING|VERBOSE_CHUNK_WRITING|VERBOSE_WARNINGS|VERBOSE_TOC_WRITING))); -$olderrrep = error_reporting(); -error_reporting($olderrrep | VERBOSE_DEFAULT); +$GLOBALS['olderrrep'] = error_reporting(); +error_reporting($GLOBALS['olderrrep'] | VERBOSE_DEFAULT); /* {{{ Print info messages: v("printf-format-text" [, $arg1, ...], $verbose-level) */ // trigger_error() only accepts E_USER_* errors :( diff --git a/tests/.gitignore b/tests/.gitignore new file mode 100644 index 000000000..6f5c29e26 --- /dev/null +++ b/tests/.gitignore @@ -0,0 +1,8 @@ +*.sh +*.php +*.out +*.exp +*.log +*.diff +!/setup.php +!/TestRender.php \ No newline at end of file diff --git a/tests/TestRender.php b/tests/TestRender.php index cfbd4b7fe..caddd911d 100644 --- a/tests/TestRender.php +++ b/tests/TestRender.php @@ -1,5 +1,10 @@ format = new $classname(); } diff --git a/tests/php/TestBigXHTML.php b/tests/php/TestBigXHTML.php index bae3950a9..15915eeae 100644 --- a/tests/php/TestBigXHTML.php +++ b/tests/php/TestBigXHTML.php @@ -1,7 +1,10 @@ __DIR__ . "/../../phpdotnet/phd/data/langs/", + "lang_dir" => __DIR__ . "/../../src/data/langs/", "phpweb_version_filename" => dirname($xml_file) . '/version.xml', "phpweb_acronym_filename" => dirname($xml_file) . '/acronyms.xml', ); diff --git a/tests/php/bug49101-2.phpt b/tests/php/bug49101-2.phpt index 8f03faa83..fe0ab8eaf 100644 --- a/tests/php/bug49101-2.phpt +++ b/tests/php/bug49101-2.phpt @@ -2,13 +2,13 @@ Bug #49101 - Thick border again - Big XHTML --FILE-- __DIR__ . "/../../phpdotnet/phd/data/langs/", + "lang_dir" => __DIR__ . "/../../src/data/langs/", "phpweb_version_filename" => dirname($xml_file) . '/version.xml', "phpweb_acronym_filename" => dirname($xml_file) . '/acronyms.xml', ); diff --git a/tests/php/bug49102-1.phpt b/tests/php/bug49102-1.phpt index b8f657cf1..7769c9994 100644 --- a/tests/php/bug49102-1.phpt +++ b/tests/php/bug49102-1.phpt @@ -2,13 +2,12 @@ Bug #49102 - Class reference pages don't normalize the methodnames in PhD trunk/ --FILE-- __DIR__ . "/../../phpdotnet/phd/data/langs/", + "lang_dir" => __DIR__ . "/../../src/data/langs/", "phpweb_version_filename" => dirname($xml_file) . '/version.xml', "phpweb_acronym_filename" => dirname($xml_file) . '/acronyms.xml', ); diff --git a/tests/php/faq001.phpt b/tests/php/faq001.phpt index ae9de799c..f71f4997c 100644 --- a/tests/php/faq001.phpt +++ b/tests/php/faq001.phpt @@ -2,13 +2,12 @@ Testing a simple FAQ --FILE-- __DIR__ . "/../../phpdotnet/phd/data/langs/", + "lang_dir" => __DIR__ . "/../../src/data/langs/", "phpweb_version_filename" => dirname($xml_file) . '/version.xml', "phpweb_acronym_filename" => dirname($xml_file) . '/acronyms.xml', ); diff --git a/tests/setup.php b/tests/setup.php deleted file mode 100644 index ec946228f..000000000 --- a/tests/setup.php +++ /dev/null @@ -1,21 +0,0 @@ -getMap(); diff --git a/tests/xhtml/002.phpt b/tests/xhtml/002.phpt index ae46da529..394193f85 100644 --- a/tests/xhtml/002.phpt +++ b/tests/xhtml/002.phpt @@ -2,12 +2,14 @@ CALS Table rendering#002 --FILE-- getMap(); diff --git a/tests/xhtml/003.phpt b/tests/xhtml/003.phpt index ce65a28cc..38d39123d 100644 --- a/tests/xhtml/003.phpt +++ b/tests/xhtml/003.phpt @@ -2,12 +2,14 @@ CALS Table rendering#003 --FILE-- getMap(); diff --git a/util/check-langs.php b/util/check-langs.php index 2eaab5a7b..1d8c07e02 100644 --- a/util/check-langs.php +++ b/util/check-langs.php @@ -6,7 +6,7 @@ exit; } -chdir('../phpdotnet/phd/data/langs/'); +chdir('../src/data/langs/'); if ($argv[1] === 'all') { $languages = glob('*.ini');