diff options
Diffstat (limited to 'platform/www/vendor/openpsa/universalfeedcreator/lib/Element')
5 files changed, 293 insertions, 0 deletions
diff --git a/platform/www/vendor/openpsa/universalfeedcreator/lib/Element/FeedDate.php b/platform/www/vendor/openpsa/universalfeedcreator/lib/Element/FeedDate.php new file mode 100644 index 0000000..249f96c --- /dev/null +++ b/platform/www/vendor/openpsa/universalfeedcreator/lib/Element/FeedDate.php @@ -0,0 +1,124 @@ +<?php + +/** + * FeedDate is an internal class that stores a date for a feed or feed item. + * Usually, you won't need to use this. + */ +class FeedDate +{ + protected $unix; + + /** + * Creates a new instance of FeedDate representing a given date. + * Accepts RFC 822, ISO 8601 date formats as well as unix time stamps. + * + * @param mixed $dateString optional the date this FeedDate will represent. If not specified, the current date and + * time is used. + */ + public function __construct($dateString = "") + { + if ($dateString == "") { + $dateString = date("r"); + } + + if (is_integer($dateString)) { + $this->unix = $dateString; + + return; + } + $tzOffset = 0; + if (preg_match( + "~(?:(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun),\\s+)?(\\d{1,2})\\s+([a-zA-Z]{3})\\s+(\\d{4})\\s+(\\d{2}):(\\d{2}):(\\d{2})\\s+(.*)~", + $dateString, + $matches + )) { + $months = Array( + "Jan" => 1, + "Feb" => 2, + "Mar" => 3, + "Apr" => 4, + "May" => 5, + "Jun" => 6, + "Jul" => 7, + "Aug" => 8, + "Sep" => 9, + "Oct" => 10, + "Nov" => 11, + "Dec" => 12, + ); + $this->unix = mktime($matches[4], $matches[5], $matches[6], $months[$matches[2]], $matches[1], $matches[3]); + if (substr($matches[7], 0, 1) == '+' OR substr($matches[7], 0, 1) == '-') { + $tzOffset = (((int)substr($matches[7], 0, 3) * 60) + (int)substr($matches[7], -2)) * 60; + } else { + if (strlen($matches[7]) == 1) { + $oneHour = 3600; + $ord = ord($matches[7]); + if ($ord < ord("M")) { + $tzOffset = (ord("A") - $ord - 1) * $oneHour; + } elseif ($ord >= ord("M") AND $matches[7] != "Z") { + $tzOffset = ($ord - ord("M")) * $oneHour; + } elseif ($matches[7] == "Z") { + $tzOffset = 0; + } + } + switch ($matches[7]) { + case "UT": + case "GMT": + $tzOffset = 0; + } + } + $this->unix += $tzOffset; + + return; + } + if (preg_match("~(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})(.*)~", $dateString, $matches)) { + $this->unix = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); + if (substr($matches[7], 0, 1) == '+' OR substr($matches[7], 0, 1) == '-') { + $tzOffset = (((int)substr($matches[7], 0, 3) * 60) + (int)substr($matches[7], -2)) * 60; + } else { + if ($matches[7] == "Z") { + $tzOffset = 0; + } + } + $this->unix += $tzOffset; + + return; + } + $this->unix = 0; + } + + /** + * Gets the date stored in this FeedDate as an RFC 822 date. + * + * @return string a date in RFC 822 format + */ + public function rfc822() + { + //return gmdate("r",$this->unix); + $date = gmdate("D, d M Y H:i:s O", $this->unix); + + return $date; + } + + /** + * Gets the date stored in this FeedDate as an ISO 8601 date. + * + * @return string a date in ISO 8601 format + */ + public function iso8601() + { + $date = gmdate("Y-m-d\TH:i:sP", $this->unix); + + return $date; + } + + /** + * Gets the date stored in this FeedDate as unix time stamp. + * + * @return int a date as a unix time stamp + */ + public function unix() + { + return $this->unix; + } +} diff --git a/platform/www/vendor/openpsa/universalfeedcreator/lib/Element/FeedHtmlField.php b/platform/www/vendor/openpsa/universalfeedcreator/lib/Element/FeedHtmlField.php new file mode 100644 index 0000000..84f0ac4 --- /dev/null +++ b/platform/www/vendor/openpsa/universalfeedcreator/lib/Element/FeedHtmlField.php @@ -0,0 +1,59 @@ +<?php + +/** + * A FeedHtmlField describes and generates + * a feed, item or image html field (probably a description). Output is + * generated based on $truncSize, $syndicateHtml properties. + * + * @author Pascal Van Hecke <feedcreator.class.php@vanhecke.info> + * @version 1.6 + */ +class FeedHtmlField +{ + /** + * Mandatory attributes of a FeedHtmlField. + */ + protected $rawFieldContent; + + /** + * Optional attributes of a FeedHtmlField. + */ + public $truncSize, $syndicateHtml; + + /** + * Creates a new instance of FeedHtmlField. + * + * @param string $parFieldContent if given, sets the rawFieldContent property + */ + public function __construct($parFieldContent) + { + if ($parFieldContent) { + $this->rawFieldContent = $parFieldContent; + } + } + + /** + * Creates the right output, depending on $truncSize, $syndicateHtml properties. + * + * @return string the formatted field + */ + public function output() + { + // when field available and syndicated in html we assume + // - valid html in $rawFieldContent and we enclose in CDATA tags + // - no truncation (truncating risks producing invalid html) + if (!$this->rawFieldContent) { + $result = ""; + } elseif ($this->syndicateHtml) { + $result = "<![CDATA[".$this->rawFieldContent."]]>"; + } else { + if ($this->truncSize and is_int($this->truncSize)) { + $result = FeedCreator::iTrunc(htmlspecialchars($this->rawFieldContent), $this->truncSize); + } else { + $result = htmlspecialchars($this->rawFieldContent); + } + } + + return $result; + } +} diff --git a/platform/www/vendor/openpsa/universalfeedcreator/lib/Element/FeedImage.php b/platform/www/vendor/openpsa/universalfeedcreator/lib/Element/FeedImage.php new file mode 100644 index 0000000..cc9df46 --- /dev/null +++ b/platform/www/vendor/openpsa/universalfeedcreator/lib/Element/FeedImage.php @@ -0,0 +1,20 @@ +<?php + +/** + * A 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. + */ + public $title, $url, $link; + + /** + * Optional attributes of an image. + */ + public $width, $height, $description; +} diff --git a/platform/www/vendor/openpsa/universalfeedcreator/lib/Element/FeedItem.php b/platform/www/vendor/openpsa/universalfeedcreator/lib/Element/FeedItem.php new file mode 100644 index 0000000..3b51cc2 --- /dev/null +++ b/platform/www/vendor/openpsa/universalfeedcreator/lib/Element/FeedItem.php @@ -0,0 +1,53 @@ +<?php + +/** + * 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. + */ + public $title, $description, $link; + + /** + * Optional attributes of an item. + */ + public $author, $authorEmail, $authorURL, $image, $category, $categoryScheme, $comments, $guid, $source, $creator, $contributor, $lat, $long, $thumb; + + /** + * 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 + */ + public $date; + + /** + * Add <enclosure> element tag RSS 2.0, supported by ATOM 1.0 too + * modified by : Mohammad Hafiz bin Ismail (mypapit@gmail.com) + * display : + * <enclosure length="17691" url="http://something.com/picture.jpg" type="image/jpeg" /> + */ + public $enclosure; + + /** + * Any additional elements to include as an associated 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. + */ + public $additionalElements = Array(); + + // on hold + // var $source; +} diff --git a/platform/www/vendor/openpsa/universalfeedcreator/lib/Element/HtmlDescribable.php b/platform/www/vendor/openpsa/universalfeedcreator/lib/Element/HtmlDescribable.php new file mode 100644 index 0000000..e34e2b1 --- /dev/null +++ b/platform/www/vendor/openpsa/universalfeedcreator/lib/Element/HtmlDescribable.php @@ -0,0 +1,37 @@ +<?php + +/** + * 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. + */ + public $descriptionHtmlSyndicated; + + /** + * Indicates whether and to how many characters a description should be truncated. + */ + public $descriptionTruncSize; + + /** @var string the Description */ + public $description; + + /** + * Returns a formatted description field, depending on descriptionHtmlSyndicated and + * $descriptionTruncSize properties + * + * @param bool $overrideSyndicateHtml + * @return string the formatted description + */ + public function getDescription($overrideSyndicateHtml = false) + { + $descriptionField = new FeedHtmlField($this->description); + $descriptionField->syndicateHtml = $overrideSyndicateHtml || $this->descriptionHtmlSyndicated; + $descriptionField->truncSize = $this->descriptionTruncSize; + + return $descriptionField->output(); + } +} |