svn: phd/trunk/phpdotnet/phd/Package/PHP/

From: Date: Tue, 14 Jul 2009 06:41:17 +0000
Subject: svn: phd/trunk/phpdotnet/phd/Package/PHP/
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-4447@lists.php.net to get a copy of this message
moacir Tue, 14 Jul 2009 06:41:17 +0000 URL: http://svn.php.net/viewvc?view=revision&revision=284061 Changed paths: A phd/trunk/phpdotnet/phd/Package/PHP/KDevelop.php Log: class Package_PHP_KDevelop added Added: phd/trunk/phpdotnet/phd/Package/PHP/KDevelop.php =================================================================== --- phd/trunk/phpdotnet/phd/Package/PHP/KDevelop.php (rev 0) +++ phd/trunk/phpdotnet/phd/Package/PHP/KDevelop.php 2009-07-14 06:41:17 UTC (rev 284061) @@ -0,0 +1,178 @@ +<?php +namespace phpdotnet\phd; + +class Package_PHP_KDevelop extends Format { + protected $formatname = "PHP-KDevelop"; + protected $title = "PHP Manual"; + + const DEFAULT_HREF = "http://www.php.net/manual/en/"; + + protected $elementmap = array( + 'book' => 'format_tocsect1', + 'bibliography' => array( + /* DEFAULT */ false, + 'book' => 'format_tocsect2', + ), + 'article' => array( + /* DEFAULT */ false, + 'book' => 'format_tocsect2', + ), + 'appendix' => array( + /* DEFAULT */ false, + 'book' => 'format_tocsect2', + ), + 'colophon' => array( + /* DEFAULT */ false, + 'book' => 'format_tocsect2', + ), + 'chapter' => array( + /* DEFAULT */ false, + 'book' => 'format_tocsect2', + ), + 'glossary' => array( + /* DEFAULT */ false, + 'book' => 'format_tocsect2', + ), + 'index' => array( + /* DEFAULT */ false, + 'book' => 'format_tocsect2', + ), + 'part' => array( + /* DEFAULT */ false, + 'book' => 'format_tocsect2', + ), + 'preface' => array( + /* DEFAULT */ false, + 'book' => 'format_tocsect2', + ), + 'reference' => array( + /* DEFAULT */ false, + 'book' => 'format_tocsect2', + ), + 'refentry' => 'format_refentry', + 'refname' => 'format_suppressed_tags', + 'refpurpose' => 'format_suppressed_tags', + 'refsection' => 'format_suppressed_tags', + ); + protected $textmap = array( + 'refname' => 'format_refname_text', + ); + + // Kdevelop TOC file + protected $tocStream; + // TOC Output directory + protected $tocDir; + + protected $ext; + + protected $currentEntryName; + protected $index = array(); + + // CHM Table of contents + protected $currentTocDepth = 0; + protected $lastContent = null; + protected $toc; + // CHM Index Map + protected $hhkStream; + + public function __construct() { + parent::__construct(); + parent::registerFormatName($this->formatname); + $this->ext = "php"; + } + + public function __destruct() { + self::footerToc(); + fclose($this->tocStream); + } + + public function transformFromMap($open, $tag, $name, $attrs, $props) {} + public function UNDEF($open, $name, $attrs, $props) {} + public function TEXT($value) {} + public function CDATA($value) {} + public function createLink($for, &$desc = null, $type = Format::SDESC) {} + public function appendData($data) {} + + public function update($event, $val = null) { + switch($event) { + case Render::STANDALONE: + if ($val) { + $this->registerElementMap($this->elementmap); + $this->registerTextMap($this->textmap); + } + break; + case Render::INIT: + if ($val) { + $this->tocDir = Config::output_dir(); + $this->tocStream = fopen($this->tocDir . strtolower($this->getFormatName()), "w"); + self::headerToc(); + } + break; + case Render::VERBOSE: + v("Starting %s rendering", $this->getFormatName(), VERBOSE_FORMAT_RENDERING); + break; + } + } + + public function format_suppressed_tags($open, $name, $attrs) { + return ""; + } + + protected function headerToc() { + fwrite($this->tocStream, "<!DOCTYPE kdeveloptoc>\n<kdeveloptoc>\n<title>" . $this->title . "</title>\n" . + "<base href=\"" . self::DEFAULT_HREF . "\"/>\n"); + } + + protected function footerToc() { + fwrite($this->tocStream, "<index>\n"); + foreach ($this->index as $name => $url) + fwrite($this->tocStream, "<entry name=\"{$name}\" url=\"{$url}\"/>\n"); + fwrite($this->tocStream, "</index>\n</kdeveloptoc>\n"); + } + + public function format_tocsect1($open, $name, $attrs) { + if (!isset($attrs[Reader::XMLNS_XML]["id"])) return ""; + $id = $attrs[Reader::XMLNS_XML]["id"]; + $hasChild = (count(Format::getChildrens($id)) > 0); + if ($open) { + $name = htmlspecialchars(Format::getShortDescription($id), ENT_QUOTES, 'UTF-8'); + $url = (Format::getFilename($id) ? Format::getFilename($id) : $id) . "." . $this->ext; + fwrite($this->tocStream, "<tocsect1 name=\"{$name}\" url=\"{$url}\"" . ($hasChild ? "" : "/") . ">\n"); + } else { + if ($hasChild) + fwrite($this->tocStream, "</tocsect1>\n"); + } + return ""; + } + + public function format_tocsect2($open, $name, $attrs) { + if (!isset($attrs[Reader::XMLNS_XML]["id"])) return ""; + $id = $attrs[Reader::XMLNS_XML]["id"]; + $hasChild = (count(Format::getChildrens($id)) > 0); + if ($open) { + $name = htmlspecialchars(Format::getShortDescription($id), ENT_QUOTES, 'UTF-8'); + $url = (Format::getFilename($id) ? Format::getFilename($id) : $id) . "." . $this->ext; + fwrite($this->tocStream, " <tocsect2 name=\"{$name}\" url=\"{$url}\"/>\n"); + } + return ""; + } + + public function format_refentry($open, $name, $attrs) { + if (!isset($attrs[Reader::XMLNS_XML]["id"])) return ""; + $id = $attrs[Reader::XMLNS_XML]["id"]; + if ($open) { + $this->currentEntryName = null; + } + if (!$open && $this->currentEntryName) { + $url = (Format::getFilename($id) ? Format::getFilename($id) : $id) . "." . $this->ext; + $this->index[$this->currentEntryName] = $url; + } + return ""; + } + + public function format_refname_text($value, $tag) { + $this->currentEntryName = $value; + return ""; + } + +} Property changes on: phd/trunk/phpdotnet/phd/Package/PHP/KDevelop.php ___________________________________________________________________ Added: svn:keywords + Id Revision Rev Added: svn:eol-style + native

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