Re: svn: /phd/trunk/phpdotnet/phd/ PI/DBHTMLHandler.php PIHandler.php

From: Date: Tue, 28 Jul 2009 07:54:38 +0000
Subject: Re: svn: /phd/trunk/phpdotnet/phd/ PI/DBHTMLHandler.php PIHandler.php
References: 1  Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-4537@lists.php.net to get a copy of this message
2009/7/28 Moacir de Oliveira Miranda Júnior <moacir@php.net>: > moacir                                   Tue, 28 Jul 2009 05:35:48 +0000 > > Revision: > http://svn.php.net/viewvc?view=revision&revision=286436 > > Log: > adding PI suport > > Changed paths: >    A   phd/trunk/phpdotnet/phd/PI/ >    A   phd/trunk/phpdotnet/phd/PI/DBHTMLHandler.php >    A   phd/trunk/phpdotnet/phd/PIHandler.php > > Added: phd/trunk/phpdotnet/phd/PI/DBHTMLHandler.php > =================================================================== > --- phd/trunk/phpdotnet/phd/PI/DBHTMLHandler.php                               >  (rev 0) > +++ phd/trunk/phpdotnet/phd/PI/DBHTMLHandler.php        2009-07-28 05:35:48 UTC (rev > 286436) > @@ -0,0 +1,62 @@ > +<?php > +namespace phpdotnet\phd; > + > +class PI_DBHTMLHandler extends PIHandler { > +    private $attrs = array( > +        "background-color"              => "", > +        "bgcolor"                       => "", > +        "cellpadding"                   => "", > +        "cellspacing"                   => "", > +        "class"                         => "", > +        "dir"                           => "", > +        "filename"                      => "", > +        "funcsynopsis-style"            => "", > +        "img.src.path"                  => "", > +        "label-width"                   => "", > +        "linenumbering.everyNth"        => "", > +        "linenumbering.separator"       => "", > +        "linenumbering.width"           => "", > +        "list-presentation"             => "", > +        "list-width"                    => "", > +        "row-height"                    => "", > +        "start"                         => "", > +        "stop-chunking"                 => "", > +        "table-summary"                 => "", > +        "table-width"                   => "", > +        "term-presentation"             => "", > +        "term-separator"                => "", > +        "term-width"                    => "", > +        "toc"                           => "", > +    ); > + > +    public function __construct($format) { > +        parent::__construct($format); > +    } > + > +    public function parse($target, $data) { > +        $pattern = > "/(?<attr>[\w]+[\w\-\.]*)[\s]*=[\s]*\"(?<value>[^\"]*)\"/"; > +        preg_match_all($pattern, $data, $matches); > +        for ($i = 0; $i < count($matches["attr"]); $i++) { > +            $attr = trim($matches["attr"][$i]); > +            $value = trim($matches["value"][$i]); > +            $this->setAttribute($attr, $value); > +        } > +        //Hack for stop-chunking > +        if ($data == "stop-chunking") { > +            $this->setAttribute("stop-chunking", true); > +        } > +    } > + > +    public function setAttribute($attr, $value) { > +        if (isset($this->attrs[$attr])) { > +            $this->attrs[$attr] = $value; > +        } > +    } > + > +    public function getAttribute($attr) { > +        return isset($this->attrs[$attr]) ? $this->attrs[$attr] : false; > +    } Since you initialize all possible attributes, the isset() calls are quite useless, aren't they? > Added: phd/trunk/phpdotnet/phd/PIHandler.php > =================================================================== > --- phd/trunk/phpdotnet/phd/PIHandler.php                               (rev 0) > +++ phd/trunk/phpdotnet/phd/PIHandler.php       2009-07-28 05:35:48 UTC (rev 286436) > @@ -0,0 +1,15 @@ > +<?php > +namespace phpdotnet\phd; > + > +abstract class PIHandler { > +    protected $format; You are missing a getter for this variable. -Hannes

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