Template icon indicating copy to clipboard operation
Template copied to clipboard

Adapters

Open augustohp opened this issue 13 years ago • 3 comments

We must implement/create a number of Adapters that transform `arraystoDomElements`` to be appended to the document. There is a simple adapter example (Adapters/A.php), but we must accept more situations to adapt:

  • ul, li, dl
  • tables

Can you come up with more ideas?

augustohp avatar Mar 28 '12 21:03 augustohp

Are the adapters still a requirement as it seems HtmlElement manages quite fine without?

<?php
    public function getDOMNode(DOMDocument $dom, $current=null)
    {
        if (is_string($current))
            return new DOMText($current);

        $current = $current ?: $this ;
        $node    = $dom->createElement($current->nodeName);
        foreach ($current->attributes as $name=>$value)
            $node->setAttribute($name, $value);

        if (!count($current->childrenNodes))
            return $node;

        foreach ($current->childrenNodes as $child)
            $node->appendChild($this->getDOMNode($dom, $child));

        return $node;
    }

Should we maybe refactor and remove adapters?

nickl- avatar Jun 03 '12 06:06 nickl-

Been following this for quite some time. This week discussions came up and this document was raised again. I don't like it and maybe I didn't get it, but we really COULD use the insertion modes described as ou Adapters implementation.

Let me know what you think on the HTML Template

augustohp avatar Jul 05 '12 19:07 augustohp

Will need to read it again, why they want to make things so complicating no one will know.

That comment of mine is very dated and I answered myself by rewriting the module 5 times now already. Have yo looked at the simple_html_dom?

nickl- avatar Jul 07 '12 03:07 nickl-