svn: /phd/trunk/phpdotnet/phd/ PI/DBHTMLHandler.php Package/Generic/XHTML.php

From: Date: Wed, 06 Jan 2010 16:20:43 +0000
Subject: svn: /phd/trunk/phpdotnet/phd/ PI/DBHTMLHandler.php Package/Generic/XHTML.php
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-5769@lists.php.net to get a copy of this message
moacir Wed, 06 Jan 2010 16:20:43 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=293178 Log: Adding support to DBTimestamp Processing Instruction Changed paths: U phd/trunk/phpdotnet/phd/PI/DBHTMLHandler.php U phd/trunk/phpdotnet/phd/Package/Generic/XHTML.php Modified: phd/trunk/phpdotnet/phd/PI/DBHTMLHandler.php =================================================================== --- phd/trunk/phpdotnet/phd/PI/DBHTMLHandler.php 2010-01-06 13:34:13 UTC (rev 293177) +++ phd/trunk/phpdotnet/phd/PI/DBHTMLHandler.php 2010-01-06 16:20:43 UTC (rev 293178) @@ -28,6 +28,10 @@ "term-separator" => "", "term-width" => "", "toc" => "", + + //Attributes for <?dbtimestamp + "format" => "", + "padding" => "", ); public function __construct($format) { @@ -46,6 +50,12 @@ if ($data == "stop-chunking") { $this->setAttribute("stop-chunking", true); } + //Parse <?dbtimestamp + if ($target == 'dbtimestamp') { + $this->parseDBTimestamp(); + $this->setAttribute("padding", ""); + $this->setAttribute("format", ""); + } } public function setAttribute($attr, $value) { @@ -58,6 +68,49 @@ return isset($this->attrs[$attr]) ? $this->attrs[$attr] : false; } + /** + * Function to parse dbtimestamp processing instructions + * Reference: http://www.sagehill.net/docbookxsl/Datetime.html + */ + public function parseDBTimestamp() { + // Array to parse formats from dbtimestamp to date() + $parseArray = array( + "a" => "D", // Day abbreviation + "A" => "l", // Day name + "b" => "M", // Month abbreviation + "c" => "c", // ISO date and time + "B" => "F", // Month name + "d" => "d", // Day in month + "H" => "H", // Hour in day + "j" => "z", // Day in year + "m" => "m", // Month in year + "M" => "i", // Minute in hour + "S" => "s", // Second in minute + "U" => "W", // Week in year + "w" => "w", // Day in week + "x" => "Y-m-dP", // ISO date + "X" => "H:i:sP", // ISO time + "Y" => "Y", // Year + ); + if ($this->getAttribute("padding") == "0") { + $parseArray["d"] = "j"; + $parseArray["H"] = "G"; + $parseArray["m"] = "n"; + } + $format = $this->getAttribute("format"); + if (!$format) { + return $this->format->appendData(date('c')); + } + $dateFormat = ""; + $len = strlen($format); + for ($i = 0; $i < $len; $i++) { + $dateFormat .= isset($parseArray[$format[$i]]) + ? $parseArray[$format[$i]] + : $format[$i]; + } + return $this->format->appendData(date($dateFormat)); + } + } /* Modified: phd/trunk/phpdotnet/phd/Package/Generic/XHTML.php =================================================================== --- phd/trunk/phpdotnet/phd/Package/Generic/XHTML.php 2010-01-06 13:34:13 UTC (rev 293177) +++ phd/trunk/phpdotnet/phd/Package/Generic/XHTML.php 2010-01-06 16:20:43 UTC (rev 293178) @@ -436,6 +436,7 @@ protected $pihandlers = array( 'dbhtml' => 'PI_DBHTMLHandler', + 'dbtimestamp' => 'PI_DBHTMLHandler', ); protected $stylesheets = array();

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