Re: [phpwiki-checkins] SF.net SVN: phpwiki:[7466] trunk

Sébastien Le Callonnec <[email protected]> Mon, 07 Jun 2010 10:03:55 +0100
Newsgroups gmane.comp.web.wiki.phpwiki.talk
Message-ID <[email protected]>
Hi Reini,

Changing the single-line comments (//) with /* ... */ in your split-up 
broke the build I’m afraid, as within the comment (that contains the 
script to generate the HTML class functions), there is a closing comment:

public static function $tag (/*...*/) {"

(That being said, thanks for applying the patch! ;) )

Regards,
Seb

On 07/06/2010 09:12, [email protected] wrote:
> Revision: 7466
>            http://phpwiki.svn.sourceforge.net/phpwiki/?rev=7466&view=rev
> Author:   rurban
> Date:     2010-06-07 08:12:29 +0000 (Mon, 07 Jun 2010)
>
> Log Message:
> -----------
> - Atom Parser and Feed Plugin
>    with unit tests by S?\195?\169bastien Le Callonnec
>    patches ID 3012033
> - HtmlElement5.php split up for php-5.3
>
> Modified Paths:
> --------------
>      trunk/lib/HtmlElement.php
>      trunk/lib/IniConfig.php
>      trunk/lib/XmlParser.php
>      trunk/tests/unit/test.php
>
> Added Paths:
> -----------
>      trunk/lib/AtomParser.php
>      trunk/lib/HtmlElement5.php
>      trunk/lib/plugin/AtomFeed.php
>      trunk/tests/unit/lib/AtomParserTest.php
>      trunk/tests/unit/lib/plugin/AtomFeedTest.php
>      trunk/tests/unit/lib/plugin/atom-example.xml
>
> Added: trunk/lib/AtomParser.php
> ===================================================================
> --- trunk/lib/AtomParser.php	                        (rev 0)
> +++ trunk/lib/AtomParser.php	2010-06-07 08:12:29 UTC (rev 7466)
> @@ -0,0 +1,257 @@
> +<?php // -*-php-*-
> +// $Id$
> +/*
> + * Copyright 2010 Sébastien Le Callonnec
> + *
> + * This file is part of PhpWiki.
> + *
> + * PhpWiki is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * PhpWiki is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with PhpWiki; if not, write to the Free Software
> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
> + */
> +/**
> + * This class is a poor-man Atom parser, it does no validation of the feed.
> + * The content of an entry ("payload") is not parsed but rather returned "as-is",
> + * as its format can be text, html or xhtml.
> + *
> + * @author: Sébastien Le Callonnec
> + */
> +require_once('lib/XmlParser.php');
> +
> +class AtomParser
> +extends XmlParser
> +{
> +    // Feed
> +    var $feed = array();
> +    var $feed_title = '';
> +    var $feed_links = array();
> +    var $feed_subtitle = '';
> +    var $feed_id = '';
> +    var $feed_updated = '';
> +    var $feed_authors = array();
> +    var $feed_contributors = array();
> +    var $generator = '';
> +    var $icon = '';
> +    var $rights = '';
> +    var $logo = '';
> +
> +    var $categories = array();
> +
> +    var $authors = array();
> +    var $contributors = array();
> +
> +    // Author, Contributor
> +    var $name = '';
> +    var $email = '';
> +    var $uri = '';
> +
> +    // Entries
> +    var $entries = array();
> +    var $inside_entry = false;
> +    var $title = '';
> +    var $updated = '';
> +    var $published = '';
> +    var $id = '';
> +    var $links = array();
> +    var $summary = '';
> +
> +    var $inside_content = false;
> +    var $content = '';
> +
> +    function tag_open($parser, $name, $attrs='') {
> +        global $current_tag, $current_attrs;
> +
> +        $current_tag = $name;
> +        $current_attrs = $attrs;
> +
> +        if ($name == "ENTRY") {
> +            $this->inside_entry = true;
> +        } elseif ($this->inside_content) {
> +            $this->content .= $this->serialize_tag(strtolower($name), $attrs);
> +        } elseif ($name == "CONTENT") {
> +            $this->inside_content = true;
> +        }
> +    }
> +
> +    function tag_close($parser, $name, $attrs='') {
> +        if ($name == "AUTHOR") {
> +            $an_author = $this->trim_data(array(
> +                "name" =>  $this->name,
> +                "email" =>  $this->email,
> +                "uri" =>  $this->uri
> +            ));
> +            if ($this->inside_entry) {
> +                $this->authors[] = $an_author;
> +            } else {
> +                $this->feed_authors[] = $an_author;
> +            }
> +            $this->name = '';
> +            $this->email = '';
> +            $this->uri = '';
> +        } elseif ($name == "FEED") {
> +            $this->feed[] = $this->trim_data(array(
> +                "id" =>  $this->feed_id,
> +                "title" =>  $this->feed_title,
> +                "links" =>  $this->feed_links,
> +                "subtitle" =>  $this->feed_subtitle,
> +                "updated" =>  $this->feed_updated,
> +                "generator" =>  $this->generator,
> +                "icon" =>  $this->icon,
> +                "rights" =>  $this->rights,
> +                "logo" =>  $this->logo,
> +                "authors" =>  $this->feed_authors,
> +                "contributors" =>  $this->feed_contributors
> +            ));
> +            $this->feed_title = '';
> +            $this->feed_id = '';
> +            $this->feed_links = array();
> +            $this->feed_subtitle = '';
> +            $this->feed_updated = '';
> +            $this->feed_authors = array();
> +            $this->feed_contributors = array();
> +            $this->generator = '';
> +            $this->icon = '';
> +            $this->rights = '';
> +            $this->logo = '';
> +        } elseif ($name == "ENTRY") {
> +            $this->entries[] = $this->trim_data(array(
> +                "id" =>  $this->id,
> +                "title" =>  $this->title,
> +                "updated" =>  $this->updated,
> +                "links" =>  $this->links,
> +                "published" =>  $this->published,
> +                "content" =>  $this->content,
> +                "summary" =>  $this->summary,
> +                "authors" =>  $this->authors,
> +                "contributors" =>  $this->contributors
> +            ));
> +            $this->id = '';
> +            $this->title = '';
> +            $this->updated = '';
> +            $this->links = '';
> +            $this->published = '';
> +            $this->content = '';
> +            $this->authors = array();
> +            $this->contributors = array();
> +            $this->inside_entry = false;
> +        } elseif ($name == "CONTENT") {
> +            $this->inside_content = false;
> +        } elseif ($name == "CONTRIBUTOR") {
> +            $a_contributor = $this->trim_data(array(
> +                "name" =>  $this->name,
> +                "email" =>  $this->email
> +            ));
> +            if ($this->inside_entry) {
> +                $this->contributors[] = $a_contributor;
> +            } else {
> +                $this->feed_contributors[] = $a_contributor;
> +            }
> +            $this->name = '';
> +            $this->email = '';
> +        } elseif ($this->inside_content) {
> +            $this->content .= "</" . strtolower($name) . ">";
> +        }
> +    }
> +
> +    function cdata($parser, $data) {
> +        global $current_tag, $current_attrs;
> +
> +        if ($this->inside_content) {
> +            $this->content .= $data;
> +        } else {
> +            switch ($current_tag) {
> +                case "ID":
> +                    if ($this->inside_entry)
> +                        $this->id .= $data;
> +                    else
> +                        $this->feed_id .= $data;
> +                    break;
> +                case "LINK":
> +                    $a_link = array();
> +                    foreach ($current_attrs as $k =>  $v) {
> +                        $a_link[strtolower($k)] = $v;
> +                    }
> +                    if ($this->inside_entry) {
> +                        $this->links[] = $a_link;
> +                    } else {
> +                        $this->feed_links[] = $a_link;
> +                    }
> +                    break;
> +                case "NAME":
> +                    $this->name .= $data;
> +                    break;
> +                case "EMAIL":
> +                    $this->email .= $data;
> +                    break;
> +                case "TITLE" :
> +                    if ($this->inside_entry)
> +                        $this->title .= $data;
> +                    else
> +                        $this->feed_title .= $data;
> +                    break;
> +                case "UPDATED":
> +                    if ($this->inside_entry)
> +                        $this->updated .= $data;
> +                    else
> +                        $this->feed_updated .= $data;
> +                    break;
> +                case "SUBTITLE":
> +                    $this->feed_subtitle .= $data;
> +                    break;
> +                case "PUBLISHED":
> +                    $this->published .= $data;
> +                    break;
> +                case "SUMMARY":
> +                    $this->summary .= $data;
> +                    break;
> +                case "URI":
> +                    $this->uri .= $data;
> +                    break;
> +                case "GENERATOR":
> +                    $this->generator .= $data;
> +                    break;
> +                case "ICON":
> +                    $this->icon .= $data;
> +                    break;
> +                case "LOGO":
> +                    $this->logo .= $data;
> +                    break;
> +                case "RIGHTS":
> +                    $this->rights .= $data;
> +                    break;
> +            }
> +        }
> +    }
> +
> +    private function trim_data($array) {
> +        return array_map(array("self", "trim_element"), $array);
> +    }
> +
> +    private function trim_element($element) {
> +        if (is_array($element)) {
> +            return $this->trim_data($element);
> +        } elseif (is_string($element)) {
> +            return trim($element);
> +        }
> +    }
> +
> +    private function serialize_tag($tag_name, $attributes) {
> +        $tag = "<" . $tag_name;
> +        foreach ($attributes as $k =>  $v) {
> +            $tag .= " " . strtolower($k). "=\"$v\"";
> +        }
> +        $tag .= ">";
> +        return $tag;
> +    }
> +}
> +?>
>
>
> Property changes on: trunk/lib/AtomParser.php
> ___________________________________________________________________
> Added: svn:keywords
>     + Id
>
> Modified: trunk/lib/HtmlElement.php
> ===================================================================
> --- trunk/lib/HtmlElement.php	2010-06-04 14:46:09 UTC (rev 7465)
> +++ trunk/lib/HtmlElement.php	2010-06-07 08:12:29 UTC (rev 7466)
> @@ -87,12 +87,17 @@
>           if (!empty($this->_attr['title'])) {
>   	    if (preg_match("/\[(alt-)?(.)\]$/", $this->_attr['title'], $m))
>   	    {
> -		$this->_attr['title'] = preg_replace("/\[(alt-)?(.)\]$/", "[".$WikiTheme->tooltipAccessKeyPrefix()."-\\2]", $this->_attr['title']);
> +		$this->_attr['title'] = preg_replace
> +                    ("/\[(alt-)?(.)\]$/",
> +                     "[".$WikiTheme->tooltipAccessKeyPrefix()."-\\2]",
> +                     $this->_attr['title']);
>   	    } else  {
> -		$this->_attr['title'] .= " [".$WikiTheme->tooltipAccessKeyPrefix()."-$key]";
> +		$this->_attr['title'] .=
> +                    " [".$WikiTheme->tooltipAccessKeyPrefix()."-$key]";
>   	    }
>   	} else {
> -	    $this->_attr['title'] = "[".$WikiTheme->tooltipAccessKeyPrefix()."-$key]";
> +	    $this->_attr['title'] =
> +                "[".$WikiTheme->tooltipAccessKeyPrefix()."-$key]";
>   	}
>       }
>
> @@ -142,39 +147,43 @@
>
>       //
>       // Shell script to generate the following static methods:
> -    //
> -    // #!/bin/sh
> -    // function mkfuncs () {
> -    //     for tag in "$@"
> -    //     do
> -    //         echo "    function $tag (/*...*/) {"
> -    //         echo "        \$el = new HtmlElement('$tag');"
> -    //         echo "        return \$el->_init2(func_get_args());"
> -    //         echo "    }"
> -    //     done
> -    // }
> -    // d='
> -    //     /****************************************/'
> -    // mkfuncs link meta style script noscript
> -    // echo "$d"
> -    // mkfuncs a img br span
> -    // echo "$d"
> -    // mkfuncs h1 h2 h3 h4 h5 h6
> -    // echo "$d"
> -    // mkfuncs hr div p pre blockquote
> -    // echo "$d"
> -    // mkfuncs em strong small
> -    // echo "$d"
> -    // mkfuncs tt u sup sub
> -    // echo "$d"
> -    // mkfuncs ul ol dl li dt dd
> -    // echo "$d"
> -    // mkfuncs table caption thead tbody tfoot tr td th colgroup col
> -    // echo "$d"
> -    // mkfuncs form input option select textarea
> -    // echo "$d"
> -    // mkfuncs area map frame frameset iframe nobody
> +/*
>
> +#!/bin/sh
> +mkfuncs () {
> +    for tag in "$@"
> +    do
> +        echo "    public static function $tag (/*...*/) {"
> +        echo "        \$el = new HtmlElement('$tag');"
> +        echo "        return \$el->_init2(func_get_args());"
> +        echo "    }"
> +    done
> +}
> +d='
> +    /****************************************/'
> +mkfuncs link meta style script noscript
> +echo "$d"
> +mkfuncs a img br span
> +echo "$d"
> +mkfuncs h1 h2 h3 h4 h5 h6
> +echo "$d"
> +mkfuncs hr div p pre blockquote
> +echo "$d"
> +mkfuncs em strong small
> +echo "$d"
> +mkfuncs tt u sup sub
> +echo "$d"
> +mkfuncs ul ol dl li dt dd
> +echo "$d"
> +mkfuncs table caption thead tbody tfoot tr td th colgroup col
> +echo "$d"
> +mkfuncs form input option select textarea label fieldset legend
> +echo "$d"
> +mkfuncs area map frame frameset iframe nobody object embed param
> +echo "$d"
> +mkfuncs video
> +*/
> +
>       function link (/*...*/) {
>           $el = new HtmlElement('link');
>           return $el->_init2(func_get_args());
>
> Added: trunk/lib/HtmlElement5.php
> ===================================================================
> --- trunk/lib/HtmlElement5.php	                        (rev 0)
> +++ trunk/lib/HtmlElement5.php	2010-06-07 08:12:29 UTC (rev 7466)
> @@ -0,0 +1,593 @@
> +<?php // rcs_id('$Id$');
> +/**
> + * Code for writing the HTML subset of XML.
> + * @author: Jeff Dairiki
> + *
> + * This code is now php5 compatible. --2004-04-19 23:51:43 rurban
> + * Specialized for php-5.3: added public static 2010-06-07 09:51:37 rurban
> + *
> + * Todo: Add support for a JavaScript backend, a php2js compiler.
> + * HTML::div(array('onclick' =>  'HTML::div(...)'))
> + */
> +if (!class_exists("XmlElement"))
> +    require_once(dirname(__FILE__)."/XmlElement.php");
> +if (class_exists("HtmlElement"))
> +    return;
> +
> +/**
> + * An XML element.
> + */
> +//apd_set_session_trace(35);
> +
> +class HtmlElement extends XmlElement
> +{
> +    function __construct ($tagname /* , $attr_or_content , ...*/) {
> +        $this->_init(func_get_args());
> +        $this->_properties = HTML::getTagProperties($tagname);
> +    }
> +
> +    function _init ($args) {
> +        if (!is_array($args))
> +            $args = func_get_args();
> +
> +        assert(count($args)>= 1);
> +        assert(is_string($args[0]));
> +        $this->_tag = array_shift($args);
> +
> +        if ($args&&  is_array($args[0]))
> +            $this->_attr = array_shift($args);
> +        else {
> +            $this->_attr = array();
> +            if ($args&&  $args[0] === false)
> +                array_shift($args);
> +        }
> +        $this->setContent($args);
> +        $this->_properties = HTML::getTagProperties($this->_tag);
> +    }
> +
> +    /**
> +     * @access protected
> +     * This is used by the static factory methods is class HTML.
> +     */
> +    function _init2 ($args) {
> +        if ($args) {
> +            if (is_array($args[0]))
> +                $this->_attr = array_shift($args);
> +            elseif ($args[0] === false)
> +                array_shift($args);
> +        }
> +
> +        if (count($args) == 1&&  is_array($args[0]))
> +            $args = $args[0];
> +        $this->_content = $args;
> +        return $this;
> +    }
> +
> +    /** Add a "tooltip" to an element.
> +     *
> +     * @param $tooltip_text string The tooltip text.
> +     */
> +    function addTooltip ($tooltip_text, $accesskey = null) {
> +        $this->setAttr('title', $tooltip_text);
> +	if ($accesskey) $this->setAccesskey($accesskey);
> +
> +        // FIXME: this should be initialized from title by an onLoad() function.
> +        //        (though, that may not be possible.)
> +        $qtooltip = str_replace("'", "\\'", $tooltip_text);
> +        $this->setAttr('onmouseover',
> +                       sprintf('window.status="%s"; return true;',
> +                               addslashes($tooltip_text)));
> +        $this->setAttr('onmouseout', "window.status='';return true;");
> +    }
> +
> +    function setAccesskey ($key) {
> +	global $WikiTheme;
> +	if (strlen($key) != 1) return;
> +	$this->setAttr("accesskey", $key);
> +
> +        if (!empty($this->_attr['title'])) {
> +	    if (preg_match("/\[(alt-)?(.)\]$/", $this->_attr['title'], $m))
> +	    {
> +		$this->_attr['title'] = preg_replace
> +                    ("/\[(alt-)?(.)\]$/",
> +                     "[".$WikiTheme->tooltipAccessKeyPrefix()."-\\2]",
> +                     $this->_attr['title']);
> +	    } else  {
> +		$this->_attr['title'] .=
> +                    " [".$WikiTheme->tooltipAccessKeyPrefix()."-$key]";
> +	    }
> +	} else {
> +	    $this->_attr['title'] =
> +                "[".$WikiTheme->tooltipAccessKeyPrefix()."-$key]";
> +	}
> +    }
> +
> +    function emptyTag () {
> +        if (($this->_properties&  HTMLTAG_EMPTY) == 0)
> +            return $this->startTag() . "</$this->_tag>";
> +
> +        return substr($this->startTag(), 0, -1) . " />";
> +    }
> +
> +    function hasInlineContent () {
> +        return ($this->_properties&  HTMLTAG_ACCEPTS_INLINE) != 0;
> +    }
> +
> +    function isInlineElement () {
> +        return ($this->_properties&  HTMLTAG_INLINE) != 0;
> +    }
> +};
> +
> +function HTML (/* $content, ... */) {
> +    return new XmlContent(func_get_args());
> +}
> +
> +class HTML extends HtmlElement {
> +    public static function raw ($html_text) {
> +        return new RawXml($html_text);
> +    }
> +
> +    function getTagProperties($tag) {
> +        $props =&$GLOBALS['HTML_TagProperties'];
> +        return isset($props[$tag]) ? $props[$tag] : 0;
> +    }
> +
> +    function _setTagProperty($prop_flag, $tags) {
> +        $props =&$GLOBALS['HTML_TagProperties'];
> +        if (is_string($tags))
> +            $tags = preg_split('/\s+/', $tags);
> +        foreach ($tags as $tag) {
> +            $tag = trim($tag);
> +            if ($tag)
> +                if (isset($props[$tag]))
> +                    $props[$tag] |= $prop_flag;
> +                else
> +                    $props[$tag] = $prop_flag;
> +        }
> +    }
> +
> +    //
> +    // Shell script to generate the following static methods:
> +/*
> +
> +#!/bin/sh
> +mkfuncs () {
> +    for tag in "$@"
> +    do
> +        echo "    public static function $tag (/*...*/) {"
> +        echo "        \$el = new HtmlElement('$tag');"
> +        echo "        return \$el->_init2(func_get_args());"
> +        echo "    }"
> +    done
> +}
> +d='
> +    /****************************************/'
> +mkfuncs link meta style script noscript
> +echo "$d"
> +mkfuncs a img br span
> +echo "$d"
> +mkfuncs h1 h2 h3 h4 h5 h6
> +echo "$d"
> +mkfuncs hr div p pre blockquote
> +echo "$d"
> +mkfuncs em strong small
> +echo "$d"
> +mkfuncs tt u sup sub
> +echo "$d"
> +mkfuncs ul ol dl li dt dd
> +echo "$d"
> +mkfuncs table caption thead tbody tfoot tr td th colgroup col
> +echo "$d"
> +mkfuncs form input option select textarea label fieldset legend
> +echo "$d"
> +mkfuncs area map frame frameset iframe nobody object embed param
> +echo "$d"
> +mkfuncs video
> +*/
> +
> +    public static function link (/*...*/) {
> +        $el = new HtmlElement('link');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function meta (/*...*/) {
> +        $el = new HtmlElement('meta');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function style (/*...*/) {
> +        $el = new HtmlElement('style');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function script (/*...*/) {
> +        $el = new HtmlElement('script');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function noscript (/*...*/) {
> +        $el = new HtmlElement('noscript');
> +        return $el->_init2(func_get_args());
> +    }
> +
> +    /****************************************/
> +    public static function a (/*...*/) {
> +        $el = new HtmlElement('a');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function img (/*...*/) {
> +        $el = new HtmlElement('img');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function br (/*...*/) {
> +        $el = new HtmlElement('br');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function span (/*...*/) {
> +        $el = new HtmlElement('span');
> +        return $el->_init2(func_get_args());
> +    }
> +
> +    /****************************************/
> +    public static function h1 (/*...*/) {
> +        $el = new HtmlElement('h1');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function h2 (/*...*/) {
> +        $el = new HtmlElement('h2');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function h3 (/*...*/) {
> +        $el = new HtmlElement('h3');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function h4 (/*...*/) {
> +        $el = new HtmlElement('h4');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function h5 (/*...*/) {
> +        $el = new HtmlElement('h5');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function h6 (/*...*/) {
> +        $el = new HtmlElement('h6');
> +        return $el->_init2(func_get_args());
> +    }
> +
> +    /****************************************/
> +    public static function hr (/*...*/) {
> +        $el = new HtmlElement('hr');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function div (/*...*/) {
> +        $el = new HtmlElement('div');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function p (/*...*/) {
> +        $el = new HtmlElement('p');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function pre (/*...*/) {
> +        $el = new HtmlElement('pre');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function blockquote (/*...*/) {
> +        $el = new HtmlElement('blockquote');
> +        return $el->_init2(func_get_args());
> +    }
> +
> +    /****************************************/
> +    public static function em (/*...*/) {
> +        $el = new HtmlElement('em');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function strong (/*...*/) {
> +        $el = new HtmlElement('strong');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function small (/*...*/) {
> +        $el = new HtmlElement('small');
> +        return $el->_init2(func_get_args());
> +    }
> +
> +    /****************************************/
> +    public static function tt (/*...*/) {
> +        $el = new HtmlElement('tt');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function u (/*...*/) {
> +        $el = new HtmlElement('u');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function sup (/*...*/) {
> +        $el = new HtmlElement('sup');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function sub (/*...*/) {
> +        $el = new HtmlElement('sub');
> +        return $el->_init2(func_get_args());
> +    }
> +
> +    /****************************************/
> +    public static function ul (/*...*/) {
> +        $el = new HtmlElement('ul');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function ol (/*...*/) {
> +        $el = new HtmlElement('ol');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function dl (/*...*/) {
> +        $el = new HtmlElement('dl');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function li (/*...*/) {
> +        $el = new HtmlElement('li');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function dt (/*...*/) {
> +        $el = new HtmlElement('dt');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function dd (/*...*/) {
> +        $el = new HtmlElement('dd');
> +        return $el->_init2(func_get_args());
> +    }
> +
> +    /****************************************/
> +    public static function table (/*...*/) {
> +        $el = new HtmlElement('table');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function caption (/*...*/) {
> +        $el = new HtmlElement('caption');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function thead (/*...*/) {
> +        $el = new HtmlElement('thead');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function tbody (/*...*/) {
> +        $el = new HtmlElement('tbody');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function tfoot (/*...*/) {
> +        $el = new HtmlElement('tfoot');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function tr (/*...*/) {
> +        $el = new HtmlElement('tr');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function td (/*...*/) {
> +        $el = new HtmlElement('td');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function th (/*...*/) {
> +        $el = new HtmlElement('th');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function colgroup (/*...*/) {
> +        $el = new HtmlElement('colgroup');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function col (/*...*/) {
> +        $el = new HtmlElement('col');
> +        return $el->_init2(func_get_args());
> +    }
> +
> +    /****************************************/
> +    public static function form (/*...*/) {
> +        $el = new HtmlElement('form');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function input (/*...*/) {
> +        $el = new HtmlElement('input');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function button (/*...*/) {
> +        $el = new HtmlElement('button');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function option (/*...*/) {
> +        $el = new HtmlElement('option');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function select (/*...*/) {
> +        $el = new HtmlElement('select');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function textarea (/*...*/) {
> +        $el = new HtmlElement('textarea');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function label (/*...*/) {
> +        $el = new HtmlElement('label');
> +        return $el->_init2(func_get_args());
> +    }
> +
> +    /****************************************/
> +    public static function area (/*...*/) {
> +        $el = new HtmlElement('area');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function map (/*...*/) {
> +        $el = new HtmlElement('map');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function frame (/*...*/) {
> +        $el = new HtmlElement('frame');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function frameset (/*...*/) {
> +        $el = new HtmlElement('frameset');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function iframe (/*...*/) {
> +        $el = new HtmlElement('iframe');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function nobody (/*...*/) {
> +        $el = new HtmlElement('nobody');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function object (/*...*/) {
> +        $el = new HtmlElement('object');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function embed (/*...*/) {
> +        $el = new HtmlElement('embed');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function param (/*...*/) {
> +        $el = new HtmlElement('param');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function fieldset (/*...*/) {
> +        $el = new HtmlElement('fieldset');
> +        return $el->_init2(func_get_args());
> +    }
> +    public static function legend (/*...*/) {
> +        $el = new HtmlElement('legend');
> +        return $el->_init2(func_get_args());
> +    }
> +
> +    /****************************************/
> +    public static function video (/*...*/) {
> +        $el = new HtmlElement('video');
> +        return $el->_init2(func_get_args());
> +    }
> +}
> +
> +define('HTMLTAG_EMPTY', 1);
> +define('HTMLTAG_INLINE', 2);
> +define('HTMLTAG_ACCEPTS_INLINE', 4);
> +
> +
> +HTML::_setTagProperty(HTMLTAG_EMPTY,
> +                      'area base basefont br col frame hr img input isindex link meta param');
> +HTML::_setTagProperty(HTMLTAG_ACCEPTS_INLINE,
> +                      // %inline elements:
> +                      'b big i small tt ' // %fontstyle
> +                      . 's strike u ' // (deprecated)
> +                      . 'abbr acronym cite code dfn em kbd samp strong var ' //%phrase
> +                      . 'a img object embed br script map q sub sup span bdo '//%special
> +                      . 'button input label option select textarea label ' //%formctl
> +
> +                      // %block elements which contain inline content
> +                      . 'address h1 h2 h3 h4 h5 h6 p pre '
> +                      // %block elements which contain either block or inline content
> +                      . 'div fieldset frameset'
> +
> +                      // other with inline content
> +                      . 'caption dt label legend video '
> +                      // other with either inline or block
> +                      . 'dd del ins li td th colgroup');
> +
> +HTML::_setTagProperty(HTMLTAG_INLINE,
> +                      // %inline elements:
> +                      'b big i small tt ' // %fontstyle
> +                      . 's strike u ' // (deprecated)
> +                      . 'abbr acronym cite code dfn em kbd samp strong var ' //%phrase
> +                      . 'a img object br script map q sub sup span bdo '//%special
> +                      . 'button input label option select textarea ' //%formctl
> +                      . 'nobody iframe'
> +                      );
> +
> +/**
> + * Generate hidden form input fields.
> + *
> + * @param $query_args hash  A hash mapping names to values for the hidden inputs.
> + * Values in the hash can themselves be hashes.  The will result in hidden inputs
> + * which will reconstruct the nested structure in the resulting query args as
> + * processed by PHP.
> + *
> + * Example:
> + *
> + * $args = array('x' =>  '2',
> + *               'y' =>  array('a' =>  'aval', 'b' =>  'bval'));
> + * $inputs = HiddenInputs($args);
> + *
> + * Will result in:
> + *
> + *<input type="hidden" name="x" value = "2" />
> + *<input type="hidden" name="y[a]" value = "aval" />
> + *<input type="hidden" name="y[b]" value = "bval" />
> + *
> + * @return object An XmlContent object containing the inputs.
> + */
> +function HiddenInputs ($query_args, $pfx = false, $exclude = array()) {
> +    $inputs = HTML();
> +
> +    foreach ($query_args as $key =>  $val) {
> +        if (in_array($key, $exclude)) continue;
> +        $name = $pfx ? $pfx . "[$key]" : $key;
> +        if (is_array($val))
> +            $inputs->pushContent(HiddenInputs($val, $name));
> +        else
> +            $inputs->pushContent(HTML::input(array('type' =>  'hidden',
> +                                                   'name' =>  $name,
> +                                                   'value' =>  $val)));
> +    }
> +    return $inputs;
> +}
> +
> +
> +/** Generate a<script>  tag containing javascript.
> + *
> + * @param string $js  The javascript.
> + * @param string $script_args  (optional) hash of script tags options
> + *                             e.g. to provide another version or the defer attr
> + * @return HtmlElement A<script>  element.
> + */
> +function JavaScript ($js, $script_args = false) {
> +    $default_script_args = array(//'version' =>  'JavaScript', // not xhtml conformant
> +                                 'type' =>  'text/javascript');
> +    $script_args = $script_args ? array_merge($default_script_args, $script_args)
> +                                : $default_script_args;
> +    if (empty($js))
> +        return HTML(HTML::script($script_args),"\n");
> +    else
> +        // see http://devedge.netscape.com/viewsource/2003/xhtml-style-script/
> +        return HTML(HTML::script($script_args,
> +                            new RawXml((ENABLE_XHTML_XML ? "\n//<![CDATA[" : "\n<!--//")
> +                                       . "\n".trim($js)."\n"
> +                                       . (ENABLE_XHTML_XML ? "//]]>\n" : "// -->"))),"\n");
> +}
> +
> +/** Conditionally display content based of whether javascript is supported.
> + *
> + * This conditionally (on the client side) displays one of two alternate
> + * contents depending on whether the client supports javascript.
> + *
> + * NOTE:
> + * The content you pass as arguments to this function must be block-level.
> + * (This is because the<noscript>  tag is block-level.)
> + *
> + * @param mixed $if_content Content to display if the browser supports
> + * javascript.
> + *
> + * @param mixed $else_content Content to display if the browser does
> + * not support javascript.
> + *
> + * @return XmlContent
> + */
> +function IfJavaScript($if_content = false, $else_content = false) {
> +    $html = array();
> +    if ($if_content) {
> +        $xml = AsXML($if_content);
> +        $js = sprintf('document.write("%s");',
> +                      addcslashes($xml, "\0..\37!@\\\177..\377"));
> +        $html[] = JavaScript($js);
> +    }
> +    if ($else_content) {
> +        $html[] = HTML::noscript(false, $else_content);
> +    }
> +    return HTML($html);
> +}
> +
> +// (c-file-style: "gnu")
> +// Local Variables:
> +// mode: php
> +// tab-width: 8
> +// c-basic-offset: 4
> +// c-hanging-comment-ender-p: nil
> +// indent-tabs-mode: nil
> +// End:
> +?>
>
>
> Property changes on: trunk/lib/HtmlElement5.php
> ___________________________________________________________________
> Added: svn:keywords
>     + Id
>
> Modified: trunk/lib/IniConfig.php
> ===================================================================
> --- trunk/lib/IniConfig.php	2010-06-04 14:46:09 UTC (rev 7465)
> +++ trunk/lib/IniConfig.php	2010-06-07 08:12:29 UTC (rev 7466)
> @@ -154,7 +154,7 @@
>            'PLUGIN_CACHED_DATABASE', 'PLUGIN_CACHED_FILENAME_PREFIX',
>            'PLUGIN_CACHED_HIGHWATER', 'PLUGIN_CACHED_LOWWATER', 'PLUGIN_CACHED_MAXLIFETIME',
>            'PLUGIN_CACHED_MAXARGLEN', 'PLUGIN_CACHED_IMGTYPES',
> -         'WYSIWYG_BACKEND',
> +         'WYSIWYG_BACKEND', 'PLUGIN_MARKUP_MAP',
>            // extra logic:
>            'SERVER_NAME','SERVER_PORT','SCRIPT_NAME', 'DATA_PATH', 'PHPWIKI_DIR', 'VIRTUAL_PATH',
>   	 'EXTERNAL_HTML2PDF_PAGELIST', 'PLUGIN_CACHED_CACHE_DIR'
> @@ -196,7 +196,8 @@
>            'BLOG_DEFAULT_EMPTY_PREFIX', 'DATABASE_PERSISTENT',
>            'ENABLE_DISCUSSION_LINK', 'ENABLE_CAPTCHA',
>            'ENABLE_WYSIWYG', 'WYSIWYG_DEFAULT_PAGETYPE_HTML',
> -         'DISABLE_MARKUP_WIKIWORD', 'ENABLE_MARKUP_COLOR',
> +         'DISABLE_MARKUP_WIKIWORD', 'ENABLE_MARKUP_COLOR', 'ENABLE_MARKUP_TEMPLATE',
> +         'ENABLE_MARKUP_MEDIAWIKI_TABLE',
>            'ENABLE_MARKUP_DIVSPAN', 'USE_BYTEA', 'UPLOAD_USERDIR', 'DISABLE_UNITS',
>   	 'ENABLE_SEARCHHIGHLIGHT', 'DISABLE_UPLOAD_ONLY_ALLOWED_EXTENSIONS',
>            'ENABLE_AUTH_OPENID', 'INSECURE_ACTIONS_LOCALHOST_ONLY',
> @@ -418,6 +419,18 @@
>                  in_array(DATABASE_TYPE, array('SQL','ADODB','PDO')) ? 2 : 0);
>       }
>
> +    global $PLUGIN_MARKUP_MAP;
> +    $PLUGIN_MARKUP_MAP = array();
> +    if (defined('PLUGIN_MARKUP_MAP') and trim(PLUGIN_MARKUP_MAP) != "") {
> +	$_map = preg_split('/\s+/', PLUGIN_MARKUP_MAP);
> +	foreach ($_map as $v) {
> +	    list($xml,$plugin) = split(':', $v);
> +	    if (!empty($xml) and !empty($plugin))
> +	        $PLUGIN_MARKUP_MAP[$xml] = $plugin;
> +	}
> +	unset($_map); unset($xml); unset($plugin); unset($v);
> +    }
> +
>       if (empty($rs['TEMP_DIR'])) {
>   	$rs['TEMP_DIR'] = "/tmp";
>   	if (getenv("TEMP"))
> @@ -633,6 +646,7 @@
>       $AllAllowedPlugins = $ActionPages;
>       // Add plugins that have no corresponding action page
>       $AllAllowedPlugins[] = 'AsciiSVG';
> +    $AllAllowedPlugins[] = 'AtomFeed';
>       $AllAllowedPlugins[] = 'BoxRight';
>       $AllAllowedPlugins[] = 'CalendarList';
>       $AllAllowedPlugins[] = 'Calendar';
>
> Modified: trunk/lib/XmlParser.php
> ===================================================================
> --- trunk/lib/XmlParser.php	2010-06-04 14:46:09 UTC (rev 7465)
> +++ trunk/lib/XmlParser.php	2010-06-07 08:12:29 UTC (rev 7466)
> @@ -56,8 +56,10 @@
>               $this->_parser = xml_parser_create($encoding);
>           else
>               $this->_parser = xml_parser_create();
> -	xml_parser_set_option($this->_parser, XML_OPTION_TARGET_ENCODING, $GLOBALS['charset']);
> -        //xml_set_object($this->_parser,&$this);
> +
> +        if (isset($GLOBALS['charset']))
> +            xml_parser_set_option($this->_parser, XML_OPTION_TARGET_ENCODING, $GLOBALS['charset']);
> +
>           xml_set_element_handler($this->_parser,
>                                   array(&$this, 'tag_open'),
>                                   array(&$this, 'tag_close' ));
>
> Added: trunk/lib/plugin/AtomFeed.php
> ===================================================================
> --- trunk/lib/plugin/AtomFeed.php	                        (rev 0)
> +++ trunk/lib/plugin/AtomFeed.php	2010-06-07 08:12:29 UTC (rev 7466)
> @@ -0,0 +1,85 @@
> +<?php // -*-php-*-
> +// $Id$
> +/*
> + * Copyright 2010 Sébastien Le Callonnec
> + *
> + * This file is part of PhpWiki.
> + *
> + * PhpWiki is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * PhpWiki is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with PhpWiki; if not, write to the Free Software
> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
> +*/
> +/**
> + * @author: Sébastien Le Callonnec
> + */
> +require_once('lib/WikiPlugin.php');
> +require_once('lib/AtomParser.php');
> +
> +class WikiPlugin_AtomFeed
> +extends WikiPlugin
> +{
> +    function getName() {
> +        return _('AtomFeed');
> +    }
> +
> +    function getDescription() {
> +        return _('Atom Aggregator Plugin');
> +    }
> +
> +    function getDefaultArguments() {
> +        return array(
> +           'feed' =>  "",
> +           'description' =>  "",
> +           'url' =>  "",
> +           'maxitem' =>  0,
> +           'titleonly' =>  false
> +        );
> +    }
> +
> +    function run($dbi, $argstr,&$request, $basepage) {
> +        extract($this->getArgs($argstr, $request));
> +        $parser = new AtomParser();
> +
> +        assert(!empty($url));
> +        $parser->parse_url($url);
> +
> +        $html = '';
> +
> +        $items = HTML::dl();
> +        foreach ($parser->feed as $feed) {
> +            $title = HTML::h3(HTML::a(array('href' =>  $feed["links"]["0"]["href"]), $feed["title"]));
> +            $counter = 1;
> +            foreach($parser->entries as $entry) {
> +                $item = HTML::dt(HTML::a(array('href' =>  $entry["links"]["0"]["href"]), $entry["title"]));
> +                $items->pushContent($item);
> +
> +                if (!$titleonly) {
> +                    $description = HTML::dd(HTML::raw(html_entity_decode($entry["content"])));
> +                } else {
> +                    $description = HTML::dd();
> +                }
> +                $items->pushContent($description);
> +
> +                if ($maxitem>  0&&  $counter>= $maxitem) {
> +                    break;
> +                }
> +                $counter++;
> +            }
> +            $html = HTML::div(array('class'=>  'rss'), $title);
> +            $html->pushContent($items);
> +        }
> +
> +        return $html;
> +    }
> +}
> +?>
> \ No newline at end of file
>
>
> Property changes on: trunk/lib/plugin/AtomFeed.php
> ___________________________________________________________________
> Added: svn:keywords
>     + Id
>
> Added: trunk/tests/unit/lib/AtomParserTest.php
> ===================================================================
> --- trunk/tests/unit/lib/AtomParserTest.php	                        (rev 0)
> +++ trunk/tests/unit/lib/AtomParserTest.php	2010-06-07 08:12:29 UTC (rev 7466)
> @@ -0,0 +1,220 @@
> +<?php
> +// $Id$
> +/*
> + * Copyright 2010 Sébastien Le Callonnec
> + *
> + * This file is part of PhpWiki.
> + *
> + * PhpWiki is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * PhpWiki is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with PhpWiki; if not, write to the Free Software
> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
> + */
> +/**
> + * @author: Sébastien Le Callonnec
> + */
> +require_once('lib/AtomParser.php');
> +require_once('PHPUnit/Framework.php');
> +
> +class AtomParserTest
> +extends phpwiki_TestCase
> +{
> +    function testSimpleAtomFileParsing() {
> +        $fake_atom_file =<<<ATOM
> +<?xml version="1.0" encoding="utf-8"?>
> +<feed xmlns="http://www.w3.org/2005/Atom"
> +      xmlns:georss="http://www.georss.org/georss">
> +<link href="http://www.phpwiki.org/fakeurl" rel="self" type="application/atom+xml" />
> +<title>This is a fake feed</title>
> +<updated>2010-05-15T01:00:00Z</updated>
> +<id>http://www.phpwiki.org/fakeurl</id>
> +<subtitle>Cool feed</subtitle>
> +<author>
> +<name>Sébastien Le Callonnec</name>
> +<email>[email protected]</email>
> +</author>
> +
> +<entry>
> +<title>Foobar Éire</title>
> +<link href="http://maps.google.com/maps?f=q&amp;sll=53.125728,-6.068907&amp;ie=UTF8"/>
> +<content type="xhtml">
> +<div xmlns="http://www.w3.org/1999/xhtml">Millenium Spire, Dublin
> +<div class="geo">Geo coordinates:
> +<abbr class="latitude" title="53.349441">53.349441</abbr>
> +<abbr class="longitude" title="-6.260282">-6.260282</abbr>
> +</div>
> +</div>
> +</content>
> +<updated>2010-05-15T01:00:00Z</updated>
> +<published>2010-05-15T01:00:00Z</published>
> +<georss:box>53.349441 -6.26234 53.35078 -6.260282</georss:box>
> +<id>tag:www.phpwiki.org,2010-05-15:/fakeurl/20100515223621</id>
> +</entry>
> +
> +</feed>
> +ATOM;
> +        $parser = new AtomParser();
> +        $parser->parse($fake_atom_file);
> +
> +        $this->assertFalse(count($parser->feed) == 0);
> +
> +        $current_feed = $parser->feed[0];
> +        $this->assertEquals("This is a fake feed", $current_feed["title"]);
> +
> +        $this->assertFalse(count($current_feed["links"]) == 0);
> +        $this->assertEquals("http://www.phpwiki.org/fakeurl", $current_feed["links"][0]["href"]);
> +        $this->assertEquals("Cool feed", $current_feed["subtitle"]);
> +        $this->assertEquals("2010-05-15T01:00:00Z", $current_feed["updated"]);
> +
> +        $this->assertFalse(count($current_feed["authors"]) == 0);
> +
> +        $current_author = $current_feed["authors"][0];
> +        $this->assertEquals("Sébastien Le Callonnec", $current_author["name"]);
> +        $this->assertEquals("[email protected]", $current_author["email"]);
> +
> +        $this->assertFalse(count($parser->entries) == 0);
> +
> +        $current_entry = $parser->entries[0];
> +        $this->assertEquals("Foobar Éire", $current_entry["title"]);
> +        $this->assertEquals("http://maps.google.com/maps?f=q&sll=53.125728,-6.068907&ie=UTF8", $current_entry["links"][0]["href"]);
> +        $this->assertEquals("2010-05-15T01:00:00Z", $current_entry["updated"]);
> +        $this->assertEquals("2010-05-15T01:00:00Z", $current_entry["published"]);
> +        $this->assertEquals("tag:www.phpwiki.org,2010-05-15:/fakeurl/20100515223621", $current_entry["id"]);
> +
> +        $payload =<<<CONTENT
> +<div xmlns="http://www.w3.org/1999/xhtml">Millenium Spire, Dublin
> +<div class="geo">Geo coordinates:
> +<abbr class="latitude" title="53.349441">53.349441</abbr>
> +<abbr class="longitude" title="-6.260282">-6.260282</abbr>
> +</div>
> +</div>
> +CONTENT;
> +        $this->assertEquals($payload, $current_entry["content"]);
> +    }
> +
> +    function testExtensiveAtomExampleFromRFC4287() {
> +        $fake_atom_file =<<<ATOM
> +<?xml version="1.0" encoding="utf-8"?>
> +
> +<feed xmlns="http://www.w3.org/2005/Atom">
> +<title type="text">dive into mark</title>
> +<subtitle type="html">
> +    A&lt;em&gt;lot&lt;/em&gt; of effort
> +    went into making this effortless
> +</subtitle>
> +
> +<updated>2005-07-31T12:29:29Z</updated>
> +<id>tag:example.org,2003:3</id>
> +<link rel="alternate" type="text/html"
> +   hreflang="en" href="http://example.org/"/>
> +<link rel="self" type="application/atom+xml"
> +   href="http://example.org/feed.atom"/>
> +<rights>Copyright (c) 2003, Mark Pilgrim</rights>
> +
> +<generator uri="http://www.example.com/" version="1.0">
> +    Example Toolkit
> +</generator>
> +<entry>
> +<title>Atom draft-07 snapshot</title>
> +<link rel="alternate" type="text/html"
> +     href="http://example.org/2005/04/02/atom"/>
> +
> +<link rel="enclosure" type="audio/mpeg" length="1337"
> +     href="http://example.org/audio/ph34r_my_podcast.mp3"/>
> +<id>tag:example.org,2003:3.2397</id>
> +<updated>2005-07-31T12:29:29Z</updated>
> +<published>2003-12-13T08:29:29-04:00</published>
> +
> +<author>
> +<name>Mark Pilgrim</name>
> +<uri>http://example.org/</uri>
> +<email>[email protected]</email>
> +
> +</author>
> +<contributor>
> +<name>Sam Ruby</name>
> +</contributor>
> +<contributor>
> +
> +<name>Joe Gregorio</name>
> +</contributor>
> +<content type="xhtml" xml:lang="en"
> +     xml:base="http://diveintomark.org/">
> +<div xmlns="http://www.w3.org/1999/xhtml">
> +<p><i>[Update: The Atom draft is finished.]</i></p>
> +
> +</div>
> +</content>
> +</entry>
> +</feed>
> +ATOM;
> +        $parser = new AtomParser();
> +        $parser->parse($fake_atom_file);
> +
> +        $this->assertFalse(count($parser->feed) == 0);
> +
> +        $current_feed = $parser->feed[0];
> +        $this->assertEquals("dive into mark", $current_feed["title"]);
> +        $this->assertEquals("Copyright (c) 2003, Mark Pilgrim", $current_feed["rights"]);
> +        $this->assertEquals("A<em>lot</em>  of effort\n    went into making this effortless", $current_feed["subtitle"]);
> +        $this->assertEquals("2005-07-31T12:29:29Z", $current_feed["updated"]);
> +        $this->assertEquals("tag:example.org,2003:3", $current_feed["id"]);
> +        $this->assertEquals("Example Toolkit", $current_feed["generator"]);
> +
> +        $this->assertTrue(count($current_feed["authors"]) == 0);
> +        $this->assertTrue(count($current_feed["contributors"]) == 0);
> +
> +
> +        $this->assertFalse(count($parser->entries) == 0);
> +
> +        $current_entry = $parser->entries[0];
> +        $this->assertEquals("Atom draft-07 snapshot", $current_entry["title"]);
> +        $this->assertEquals("2005-07-31T12:29:29Z", $current_entry["updated"]);
> +        $this->assertEquals("2003-12-13T08:29:29-04:00", $current_entry["published"]);
> +        $this->assertEquals("tag:example.org,2003:3.2397", $current_entry["id"]);
> +        $this->assertEquals(2, count($current_entry["links"]));
> +
> +        $this->assertTrue(count($current_entry["authors"]) == 1);
> +        $this->assertTrue(count($current_entry["contributors"]) == 2);
> +
> +        $current_author = $current_entry["authors"][0];
> +        $this->assertEquals("Mark Pilgrim", $current_author["name"]);
> +        $this->assertEquals("[email protected]", $current_author["email"]);
> +
> +        $first_contributor = $current_entry["contributors"][0];
> +        $second_contributor = $current_entry["contributors"][1];
> +
> +        $this->assertEquals("Sam Ruby", $first_contributor["name"]);
> +        $this->assertEquals("Joe Gregorio", $second_contributor["name"]);
> +
> +        $first_link = $current_entry["links"][0];
> +        $this->assertEquals("alternate", $first_link["rel"]);
> +        $this->assertEquals("text/html", $first_link["type"]);
> +        $this->assertEquals("http://example.org/2005/04/02/atom", $first_link["href"]);
> +
> +        $second_link = $current_entry["links"][1];
> +        $this->assertEquals("enclosure", $second_link["rel"]);
> +        $this->assertEquals("audio/mpeg", $second_link["type"]);
> +        $this->assertEquals("1337", $second_link["length"]);
> +        $this->assertEquals("http://example.org/audio/ph34r_my_podcast.mp3", $second_link["href"]);
> +
> +        $payload =<<<CONTENT
> +<div xmlns="http://www.w3.org/1999/xhtml">
> +<p><i>[Update: The Atom draft is finished.]</i></p>
> +
> +</div>
> +CONTENT;
> +
> +        $this->assertEquals($payload, $current_entry["content"]);
> +    }
> +}
> +?>
> \ No newline at end of file
>
>
> Property changes on: trunk/tests/unit/lib/AtomParserTest.php
> ___________________________________________________________________
> Added: svn:keywords
>     + Id
>
> Added: trunk/tests/unit/lib/plugin/AtomFeedTest.php
> ===================================================================
> --- trunk/tests/unit/lib/plugin/AtomFeedTest.php	                        (rev 0)
> +++ trunk/tests/unit/lib/plugin/AtomFeedTest.php	2010-06-07 08:12:29 UTC (rev 7466)
> @@ -0,0 +1,80 @@
> +<?php
> +// $Id$
> +/*
> + * Copyright 2010 Sébastien Le Callonnec
> + *
> + * This file is part of PhpWiki.
> + *
> + * PhpWiki is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * PhpWiki is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with PhpWiki; if not, write to the Free Software
> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
> + */
> +/**
> + * @author: Sébastien Le Callonnec
> + */
> +require_once('lib/plugin/AtomFeed.php');
> +require_once('lib/AtomParser.php');
> +require_once('lib/HtmlElement.php');
> +
> +class AtomFeedTest
> +extends phpwiki_TestCase
> +{
> +    var $atom_feed_plugin;
> +
> +    public function setUp() {
> +        parent::setUp();
> +        $this->atom_feed_plugin = new WikiPlugin_AtomFeed();
> +    }
> +
> +    public function testRunMaxItem() {
> +        global $request;
> +        $expected_html =<<<EXPECTED
> +<div class="rss"><h3><a href="http://www.phpwiki.org/fakeurl">This is a fake feed</a></h3>
> +<dl>
> +<dt><a href="http://maps.google.com/maps?f=q&sll=53.125728,-6.068907&ie=UTF8">Foobar Éire</a></dt>
> +<dd><div xmlns="http://www.w3.org/1999/xhtml">Millenium Spire, Dublin
> +<div class="geo">Geo coordinates:
> +<abbr class="latitude" title="53.349441">53.349441</abbr>
> +<abbr class="longitude" title="-6.260282">-6.260282</abbr>
> +</div>
> +</div></dd>
> +</dl>
> +</div>
> +EXPECTED;
> +        $html = $this->atom_feed_plugin->run(null, 'url=file://' . dirname(__FILE__) . '/atom-example.xml maxitem=1', $request, '.');
> +        $this->assertEquals($expected_html, trim(html_entity_decode($html->asXML())));
> +    }
> +
> +    public function testRunTitleOnly() {
> +        global $request;
> +        $expected_html =<<<EXPECTED
> +<div class="rss"><h3><a href="http://www.phpwiki.org/fakeurl">This is a fake feed</a></h3>
> +<dl>
> +<dt><a href="http://maps.google.com/maps?f=q&sll=53.125728,-6.068907&ie=UTF8">Foobar Éire</a></dt>
> +<dd></dd>
> +<dt><a href="http://maps.google.com/maps?f=q&sll=53.125728,-6.068907&ie=UTF8">Foobar Éire 2</a></dt>
> +<dd></dd>
> +<dt><a href="http://maps.google.com/maps?f=q&sll=53.125728,-6.068907&ie=UTF8">Foobar Éire 3</a></dt>
> +<dd></dd>
> +<dt><a href="http://maps.google.com/maps?f=q&sll=53.125728,-6.068907&ie=UTF8">Foobar Éire 4</a></dt>
> +<dd></dd>
> +<dt><a href="http://maps.google.com/maps?f=q&sll=53.125728,-6.068907&ie=UTF8">Foobar Éire 5</a></dt>
> +<dd></dd>
> +</dl>
> +</div>
> +EXPECTED;
> +        $html = $this->atom_feed_plugin->run(null, 'url=file://' . dirname(__FILE__) . '/atom-example.xml titleonly=true', $request, '.');
> +        $this->assertEquals($expected_html, trim(html_entity_decode($html->asXML())));
> +    }
> +}
> +?>
> \ No newline at end of file
>
>
> Property changes on: trunk/tests/unit/lib/plugin/AtomFeedTest.php
> ___________________________________________________________________
> Added: svn:keywords
>     + Id
>
> Added: trunk/tests/unit/lib/plugin/atom-example.xml
> ===================================================================
> --- trunk/tests/unit/lib/plugin/atom-example.xml	                        (rev 0)
> +++ trunk/tests/unit/lib/plugin/atom-example.xml	2010-06-07 08:12:29 UTC (rev 7466)
> @@ -0,0 +1,94 @@
> +<?xml version="1.0" encoding="utf-8"?>
> +<feed xmlns="http://www.w3.org/2005/Atom"
> +      xmlns:georss="http://www.georss.org/georss">
> +<link href="http://www.phpwiki.org/fakeurl" rel="self" type="application/atom+xml" />
> +<title>This is a fake feed</title>
> +<updated>2010-05-15T01:00:00Z</updated>
> +<id>http://www.phpwiki.org/fakeurl</id>
> +<subtitle>Cool feed</subtitle>
> +<author>
> +<name>Sébastien Le Callonnec</name>
> +<email>[email protected]</email>
> +</author>
> +
> +<entry>
> +<title>Foobar Éire</title>
> +<link href="http://maps.google.com/maps?f=q&amp;sll=53.125728,-6.068907&amp;ie=UTF8"/>
> +<content type="xhtml">
> +<div xmlns="http://www.w3.org/1999/xhtml">Millenium Spire, Dublin
> +<div class="geo">Geo coordinates:
> +<abbr class="latitude" title="53.349441">53.349441</abbr>
> +<abbr class="longitude" title="-6.260282">-6.260282</abbr>
> +</div>
> +</div>
> +</content>
> +<updated>2010-05-15T01:00:00Z</updated>
> +<published>2010-05-15T01:00:00Z</published>
> +<georss:box>53.349441 -6.26234 53.35078 -6.260282</georss:box>
> +<id>tag:www.phpwiki.org,2010-05-15:/fakeurl/20100515223621</id>
> +</entry>
> +<entry>
> +<title>Foobar Éire 2</title>
> +<link href="http://maps.google.com/maps?f=q&amp;sll=53.125728,-6.068907&amp;ie=UTF8"/>
> +<content type="xhtml">
> +<div xmlns="http://www.w3.org/1999/xhtml">Again Millenium Spire, Dublin
> +<div class="geo">Geo coordinates:
> +<abbr class="latitude" title="53.349441">53.349441</abbr>
> +<abbr class="longitude" title="-6.260282">-6.260282</abbr>
> +</div>
> +</div>
> +</content>
> +<updated>2010-05-15T01:00:00Z</updated>
> +<published>2010-05-15T01:00:00Z</published>
> +<georss:box>53.349441 -6.26234 53.35078 -6.260282</georss:box>
> +<id>tag:www.phpwiki.org,2010-05-15:/fakeurl/20100515223622</id>
> +</entry>
> +<entry>
> +<title>Foobar Éire 3</title>
> +<link href="http://maps.google.com/maps?f=q&amp;sll=53.125728,-6.068907&amp;ie=UTF8"/>
> +<content type="xhtml">
> +<div xmlns="http://www.w3.org/1999/xhtml">Still Millenium Spire, Dublin
> +<div class="geo">Geo coordinates:
> +<abbr class="latitude" title="53.349441">53.349441</abbr>
> +<abbr class="longitude" title="-6.260282">-6.260282</abbr>
> +</div>
> +</div>
> +</content>
> +<updated>2010-05-15T01:00:00Z</updated>
> +<published>2010-05-15T01:00:00Z</published>
> +<georss:box>53.349441 -6.26234 53.35078 -6.260282</georss:box>
> +<id>tag:www.phpwiki.org,2010-05-15:/fakeurl/20100515223623</id>
> +</entry>
> +<entry>
> +<title>Foobar Éire 4</title>
> +<link href="http://maps.google.com/maps?f=q&amp;sll=53.125728,-6.068907&amp;ie=UTF8"/>
> +<content type="xhtml">
> +<div xmlns="http://www.w3.org/1999/xhtml">Yet Again Millenium Spire, Dublin
> +<div class="geo">Geo coordinates:
> +<abbr class="latitude" title="53.349441">53.349441</abbr>
> +<abbr class="longitude" title="-6.260282">-6.260282</abbr>
> +</div>
> +</div>
> +</content>
> +<updated>2010-05-15T01:00:00Z</updated>
> +<published>2010-05-15T01:00:00Z</published>
> +<georss:box>53.349441 -6.26234 53.35078 -6.260282</georss:box>
> +<id>tag:www.phpwiki.org,2010-05-15:/fakeurl/20100515223624</id>
> +</entry>
> +<entry>
> +<title>Foobar Éire 5</title>
> +<link href="http://maps.google.com/maps?f=q&amp;sll=53.125728,-6.068907&amp;ie=UTF8"/>
> +<content type="xhtml">
> +<div xmlns="http://www.w3.org/1999/xhtml">Yes, yes Millenium Spire, Dublin
> +<div class="geo">Geo coordinates:
> +<abbr class="latitude" title="53.349441">53.349441</abbr>
> +<abbr class="longitude" title="-6.260282">-6.260282</abbr>
> +</div>
> +</div>
> +</content>
> +<updated>2010-05-15T01:00:00Z</updated>
> +<published>2010-05-15T01:00:00Z</published>
> +<georss:box>53.349441 -6.26234 53.35078 -6.260282</georss:box>
> +<id>tag:www.phpwiki.org,2010-05-15:/fakeurl/20100515223625</id>
> +</entry>
> +</feed>
> \ No newline at end of file
>
>
> Property changes on: trunk/tests/unit/lib/plugin/atom-example.xml
> ___________________________________________________________________
> Added: svn:keywords
>     + Id
>
> Modified: trunk/tests/unit/test.php
> ===================================================================
> --- trunk/tests/unit/test.php	2010-06-04 14:46:09 UTC (rev 7465)
> +++ trunk/tests/unit/test.php	2010-06-07 08:12:29 UTC (rev 7466)
> @@ -400,6 +400,7 @@
>                     /* valid tests only with clean virgin setup */
>                     'AllPagesTest','AllUsersTest','OrphanedPagesTest',
>                     'WantedPagesTest','TextSearchTest','IncludePageTest',
> +                  'AtomParserTest','AtomFeedTest',
>                     /* final tests which require all valid pages and consumes>  32MB */
>                     'DumpHtml');
>   // support db=file db=dba test=SetupWiki test=DumpHtml debug=num -dconstant=value
>
>
> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
>
> ------------------------------------------------------------------------------
> ThinkGeek and WIRED's GeekDad team up for the Ultimate
> GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
> lucky parental unit.  See the prize list and enter to win:
> http://p.sf.net/sfu/thinkgeek-promo
> _______________________________________________
> phpwiki-checkins mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/phpwiki-checkins

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Phpwiki-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/phpwiki-talk