Skip to content
Snippets Groups Projects
feedcreator.class.php 57.4 KiB
Newer Older
andi's avatar
andi committed
<?php
/***************************************************************************
 * FeedCreator class v1.7.2-ppt
 * originally (c) Kai Blankenhorn
 * www.bitfolge.de
 * kaib@bitfolge.de
 * v1.3 work by Scott Reynen (scott@randomchaos.com) and Kai Blankenhorn
 * v1.5 OPML support by Dirk Clemens
 * v1.7.2-mod on-the-fly feed generation by Fabian Wolf (info@f2w.de)
 * v1.7.2-ppt ATOM 1.0 support by Mohammad Hafiz bin Ismail (mypapit@gmail.com)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * @author www.bitfolge.de
 *
 * Changelog:
 *
 * this version contains some smaller modifications for DokuWiki as well
 *
 * v1.7.2-ppt   11-21-05
 *  added Atom 1.0 support
 *  added enclosure support for RSS 2.0/ATOM 1.0
 *  added docs for v1.7.2-ppt only!
 *
 * v1.7.2-mod   03-12-05
 *  added output function outputFeed for on-the-fly feed generation
 *
 * v1.7.2   10-11-04
 *  license changed to LGPL
 *
 * v1.7.1
 *  fixed a syntax bug
 *  fixed left over debug code
 *
 * v1.7 07-18-04
 *  added HTML and JavaScript feeds (configurable via CSS) (thanks to Pascal Van Hecke)
 *  added HTML descriptions for all feed formats (thanks to Pascal Van Hecke)
 *  added a switch to select an external stylesheet (thanks to Pascal Van Hecke)
 *  changed default content-type to application/xml
 *  added character encoding setting
 *  fixed numerous smaller bugs (thanks to Sören Fuhrmann of golem.de)
 *  improved changing ATOM versions handling (thanks to August Trometer)
 *  improved the UniversalFeedCreator's useCached method (thanks to Sören Fuhrmann of golem.de)
 *  added charset output in HTTP headers (thanks to Sören Fuhrmann of golem.de)
 *  added Slashdot namespace to RSS 1.0 (thanks to Sören Fuhrmann of golem.de)
 *
 * See www.bitfolge.de for additional changelog info
 */
andi's avatar
andi committed
// your local timezone, set to "" to disable or for GMT
define("TIME_ZONE",date("O", time()));
andi's avatar
andi committed




/**
 * Version string.
 **/

define("FEEDCREATOR_VERSION", "FeedCreator 1.7.2-ppt DokuWiki");
andi's avatar
andi committed



/**
 * A FeedItem is a part of a FeedCreator feed.
 *
 * @author Kai Blankenhorn <kaib@bitfolge.de>
 * @since 1.3
 */
class FeedItem extends HtmlDescribable {
    /**
     * Mandatory attributes of an item.
     */
    var $title, $description, $link;

    /**
     * Optional attributes of an item.
     */
    var $author, $authorEmail, $image, $category, $comments, $guid, $source, $creator;

    /**
     * Publishing date of an item. May be in one of the following formats:
     *
     *  RFC 822:
     *  "Mon, 20 Jan 03 18:05:41 +0400"
     *  "20 Jan 03 18:05:41 +0000"
     *
     *  ISO 8601:
     *  "2003-01-20T18:05:41+04:00"
     *
     *  Unix:
     *  1043082341
     */
    var $date;

    /**
     * Add <enclosure> element tag RSS 2.0
     * modified by : Mohammad Hafiz bin Ismail (mypapit@gmail.com)
     *
     *
     * display :
     * <enclosure length="17691" url="http://something.com/picture.jpg" type="image/jpeg" />
     *
     */
    var $enclosure;

    /**
     * Any additional elements to include as an assiciated array. All $key => $value pairs
     * will be included unencoded in the feed item in the form
     *     <$key>$value</$key>
     * Again: No encoding will be used! This means you can invalidate or enhance the feed
     * if $value contains markup. This may be abused to embed tags not implemented by
     * the FeedCreator class used.
     */
    var $additionalElements = Array();

    // on hold
    // var $source;
andi's avatar
andi committed
}

class EnclosureItem extends HtmlDescribable {
    /*
    *
    * core variables
    *
    **/
    var $url,$length,$type;

    /*
    * For use with another extension like Yahoo mRSS
    * Warning :
    * These variables might not show up in
    * later release / not finalize yet!
    *
    */
    var $width, $height, $title, $description, $keywords, $thumburl;

    var $additionalElements = Array();

}
andi's avatar
andi committed


/**
 * An FeedImage may be added to a FeedCreator feed.
 * @author Kai Blankenhorn <kaib@bitfolge.de>
 * @since 1.3
 */
class FeedImage extends HtmlDescribable {
    /**
     * Mandatory attributes of an image.
     */
    var $title, $url, $link;

    /**
     * Optional attributes of an image.
     */
    var $width, $height, $description;
andi's avatar
andi committed
}



/**
 * An HtmlDescribable is an item within a feed that can have a description that may
 * include HTML markup.
 */
class HtmlDescribable {
    /**
     * Indicates whether the description field should be rendered in HTML.
     */
    var $descriptionHtmlSyndicated;

    /**
     * Indicates whether and to how many characters a description should be truncated.
     */
    var $descriptionTruncSize;

    /**
     * Returns a formatted description field, depending on descriptionHtmlSyndicated and
     * $descriptionTruncSize properties
     * @return    string    the formatted description
     */
    function getDescription() {
        $descriptionField = new FeedHtmlField($this->description);
        $descriptionField->syndicateHtml = $this->descriptionHtmlSyndicated;
        $descriptionField->truncSize = $this->descriptionTruncSize;
        return $descriptionField->output();
    }
andi's avatar
andi committed

}
Loading
Loading full blame...