bjori Wed Aug 8 23:46:19 2007 UTC
Added files:
/phd/themes/php bightml.php chunkedhtml.php phpdotnet.php
phpweb.php
Log:
Initial commit of php.net themes
http://cvs.php.net/viewvc.cgi/phd/themes/php/bightml.php?view=markup&rev=1.1
Index: phd/themes/php/bightml.php
+++ phd/themes/php/bightml.php
<?php
/* $Id: bightml.php,v 1.1 2007/08/08 23:46:19 bjori Exp $ */
class bightml extends phpdotnet implements PhDTheme {
public function __construct(array $IDs, array $IDMap, $filename, $ext =
"html") {
parent::__construct($IDs, $IDMap, $filename, $ext, false);
$this->stream = fopen("bightml.html", "w");
self::header();
}
public function appendData($data, $isChunk) {
if($isChunk) {
$data .= "<hr />";
}
return fwrite($this->stream, $data);
}
public function __destruct() {
self::footer();
fclose($this->stream);
}
public function header() {
fwrite($this->stream, "<html><body>");
}
public function footer() {
fwrite($this->stream, "</body></html>");
}
}
/*
* vim600: sw=4 ts=4 fdm=syntax syntax=php et
* vim<600: sw=4 ts=4
*/
http://cvs.php.net/viewvc.cgi/phd/themes/php/chunkedhtml.php?view=markup&rev=1.1
Index: phd/themes/php/chunkedhtml.php
+++ phd/themes/php/chunkedhtml.php
<?php
class chunkedhtml extends phpweb {
public function __construct(array $IDs, array $IDMap, $filename, $ext =
"html") {
parent::__construct($IDs, $IDMap, $filename, $ext, true);
}
public function header($id) {
return "<html><body>\n";
}
public function footer($id) {
return "</body></html>\n";
}
}
http://cvs.php.net/viewvc.cgi/phd/themes/php/phpdotnet.php?view=markup&rev=1.1
Index: phd/themes/php/phpdotnet.php
+++ phd/themes/php/phpdotnet.php
<?php
/* $Id: phpdotnet.php,v 1.1 2007/08/08 23:46:19 bjori Exp $ */
class phpdotnet extends PhDHelper {
protected $elementmap = array(
'function' => 'format_suppressed_tags',
'link' => 'format_link',
'refpurpose' => 'format_refpurpose',
'type' => array(
/* DEFAULT */ 'format_suppressed_tags',
'methodparam' => false,
'methodsynopsis' => false,
),
'xref' => 'format_link',
'article' => 'format_container_chunk',
'appendix' => 'format_container_chunk',
'bibliography' => array(
/* DEFAULT */ false,
'article' => 'format_chunk',
'book' => 'format_chunk',
'part' => 'format_chunk',
),
'book' => 'format_container_chunk',
'chapter' => 'format_container_chunk',
'colophon' => 'format_chunk',
'glossary' => array(
/* DEFAULT */ false,
'article' => 'format_chunk',
'book' => 'format_chunk',
'part' => 'format_chunk',
),
'index' => array(
/* DEFAULT */ false,
'article' => 'format_chunk',
'book' => 'format_chunk',
'part' => 'format_chunk',
),
'part' => 'format_container_chunk',
'preface' => 'format_chunk',
'refentry' => 'format_chunk',
'reference' => 'format_container_chunk',
'sect1' => 'format_chunk',
'sect2' => 'format_chunk',
'sect3' => 'format_chunk',
'sect4' => 'format_chunk',
'sect5' => 'format_chunk',
'section' => 'format_chunk',
'set' => 'format_chunk',
'setindex' => 'format_chunk',
);
protected $textmap = array(
'function' => 'format_function_text',
'type' => array(
/* DEFAULT */ 'format_type_text',
'methodparam' => false,
'methodsynopsis' => false,
),
'refname' => 'format_refname_text',
);
private $versions = array();
protected $chunked = true;
protected $CURRENT_ID = "";
protected $refname;
public function __construct(array $IDs, array $IDMap, $filename, $ext =
"php", $chunked = true) {
parent::__construct($IDs, $IDMap, $ext);
$this->ext = $ext;
$this->versions = self::generateVersionInfo($filename);
$this->chunked = $chunked;
}
public static function generateVersionInfo($filename) {
static $info;
if ($info) {
return $info;
}
$r = new XMLReader;
if (!$r->open($filename)) {
throw new Exception;
}
$versions = array();
while($r->read()) {
if (
$r->moveToAttribute("name")
&& ($funcname = str_replace(
array("::", "->", "__", "_", '$'),
array("-", "-", "-", "-", ""),
$r->value))
&& $r->moveToAttribute("from")
&& ($from = $r->value)
) {
$versions[strtolower($funcname)] = $from;
$r->moveToElement();
}
}
$r->close();
$info = $versions;
return $versions;
}
public function format_link($open, $name, $attrs) {
if ($open) {
$content = $fragment = "";
$class = $name;
if(isset($attrs[PhDReader::XMLNS_DOCBOOK]["linkend"])) {
$linkto = $attrs[PhDReader::XMLNS_DOCBOOK]["linkend"];
$id = $href = PhDHelper::getFilename($linkto);
if ($id != $linkto) {
$fragment = "#$linkto";
}
$href .= ".".$this->ext;
} elseif(isset($attrs[PhDReader::XMLNS_XLINK]["href"])) {
$href = $attrs[PhDReader::XMLNS_XLINK]["href"];
$content = "» ";
$class .= " external";
}
if ($name == "xref") {
sprintf('<a href="%s%s" class="%s">%s</a>',
$this->chunked ? "" : "#",
$this->chunked ?
$href : (isset($linkto) ? $linkto : $href),
$class, $content . PhDHelper::getDescription($id, false));
} else {
return sprintf('<a href="%s%s%s" class="%s">', $this->chunked ?
"" : "#", $href, $fragment, $class);
}
}
return "</a>";
}
public function versionInfo($funcname) {
$funcname = str_replace(
array("::", "->", "__", "_", '$'),
array("-", "-", "-", "-", ""),
strtolower($funcname));
return isset($this->versions[$funcname]) ? $this->versions[$funcname] :
"No version information available, might be only in CVS";
}
public function format_refpurpose($open, $tag, $attrs) {
if ($open) {
return sprintf('<p class="verinfo">(%s)</p><p class="refpurpose">%s
â ', $this->versionInfo($this->refname), $this->refname);
}
return "</p>\n";
}
public function format_refname_text($value, $tag) {
$this->refname = $value;
return false;
}
public function format_chunk($open, $name, $attrs) {
if (isset($attrs[PhDReader::XMLNS_XML]["id"])) {
$this->CURRENT_ID = $attrs[PhDReader::XMLNS_XML]["id"];
}
return false;
}
public function format_container_chunk($open, $name, $attrs) {
$this->CURRENT_ID = $id = $attrs[PhDReader::XMLNS_XML]["id"];
if ($open) {
return "<div>";
}
$chunks = PhDHelper::getContainer($id);
$content = "";
if (count($chunks) > 1) {
$content = '<ul class="chunklist chunklist_'.$name.'">';
if ($name == "reference") {
foreach($chunks as $chunkid => $junk) {
if ($chunkid == "parent") { continue; }
$content .= sprintf('<li><a href="%s%s.%s">%s</a> â
%s</li>', $this->chunked ? "" : "#", $chunkid, $this->ext,
PhDHelper::getDescription($chunkid, false), PhDHelper::getDescription($chunkid,
true));
}
} else {
foreach($chunks as $chunkid => $junk) {
if ($chunkid == "parent") { continue; }
$content .= sprintf('<li><a href="%s%s.%s">%s</a></li>',
$this->chunked ? "" : "#", $chunkid, $this->ext,
PhDHelper::getDescription($chunkid, true));
}
}
$content .= "</ul>\n";
}
$content .= "</div>\n";
return $content;
}
public function format_suppressed_tags($open, $name) {
/* ignore it */
return "";
}
public function format_function_text($value, $tag) {
$link = str_replace(array("_", "::", "->"), "-", $value);
if (!substr_compare($this->CURRENT_ID, $link, -strlen($link)) ||
!($filename = PhDHelper::getFilename("function.$link"))) {
return sprintf("<b>%s()</b>", $value);
}
return sprintf('<a href="%s%s.%s" class="function">%s()</a>',
$this->chunked ? "" : "#", $filename, $this->ext, $value);
}
public function format_type_text($type, $tagname) {
$t = strtolower($type);
$href = $fragment = "";
switch($t) {
case "bool":
$href = "language.types.boolean";
break;
case "int":
$href = "language.types.integer";
break;
case "double":
$href = "language.types.float";
break;
case "boolean":
case "integer":
case "float":
case "string":
case "array":
case "object":
case "resource":
case "null":
$href = "language.types.$t";
break;
case "mixed":
case "number":
case "callback":
$href = "language.pseudo-types";
$fragment = "language.types.$t";
break;
}
if ($href && $this->chunked) {
return sprintf('<a href="%s.%s%s" class="%s %s">%5$s</a>', $href,
$this->ext, ($fragment ? "#$fragment" : ""), $tagname, $type);
}
if ($href) {
return sprintf('<a href="#%s" class="%s %s">%3$s</a>', $fragment ?
$fragment : $href, $tagname, $type);
}
return sprintf('<span class="%s %s">%2$s</span>', $tagname, $type);
}
}
/*
* vim600: sw=4 ts=4 fdm=syntax syntax=php et
* vim<600: sw=4 ts=4
*/
http://cvs.php.net/viewvc.cgi/phd/themes/php/phpweb.php?view=markup&rev=1.1
Index: phd/themes/php/phpweb.php
+++ phd/themes/php/phpweb.php
<?php
/* $Id: phpweb.php,v 1.1 2007/08/08 23:46:19 bjori Exp $ */
class phpweb extends phpdotnet implements PhDTheme {
protected $streams = array();
protected $writeit = false;
public function writeChunk($id, $stream) {
rewind($stream);
file_put_contents($this->ext."/$id.".$this->ext, $this->header($id));
file_put_contents($this->ext."/$id.".$this->ext, $stream, FILE_APPEND);
file_put_contents($this->ext."/$id.".$this->ext, $this->footer($id),
FILE_APPEND);
}
public function appendData($data, $isChunk) {
switch($isChunk) {
case PhDReader::CLOSE_CHUNK:
$id = $this->CURRENT_ID;
$stream = array_pop($this->streams);
$retval = fwrite($stream, $data);
$this->writeChunk($id, $stream);
fclose($stream);
return $retval;
break;
case PhDReader::OPEN_CHUNK:
$this->streams[] = fopen("php://temp/maxmemory", "r+");
default:
$stream = end($this->streams);
$retval = fwrite($stream, $data);
return $retval;
}
}
public function header($id) {
$toc = "";
$parent = PhDHelper::getParent($id);
foreach(PhDHelper::getContainer($parent) as $k => $v) {
if ($k == "parent") { continue; }
$toc .= sprintf("array('%s.php', '%s'),\n", $k,
addslashes(PhDHelper::getDescription($k, false)));
}
/* Yes. This is scary. I know. */
return '<?php
include_once $_SERVER[\'DOCUMENT_ROOT\'] . \'/include/shared-manual.inc\';
manual_setup(
array(
"home" => array("index.php", "PHP Manual"),
"head" => array("UTF-8", "en"),
"this" => array("'.$id.'.php",
"'.addslashes(PhDHelper::getDescription($id)).'"),
"prev" => array("function.previous.php", "prevous"),
"next" => array("function.next.php", "next"),
"up" => array("'.$this->getFilename($parent).'.'.$this->ext.'",
"'.addslashes(PhDHelper::getDescription($parent, true)). '"),
"toc" => array('.$toc.'),
)
);
manual_header();
?>
';
}
public function footer($id) {
return "<?php manual_footer(); ?>";
}
}
/*
* vim600: sw=4 ts=4 fdm=syntax syntax=php et
* vim<600: sw=4 ts=4
*/