Classes

File content/feed/FeedItem.class.php

File content/feed/FeedItem.class.php

  1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 
<?php
/**
 * Contains meta-informations and informations about a feed entry / item
 * @package     Content
 * @subpackage  Feed
 * @copyright   &copy; 2005-2019 PHPBoost
 * @license     https://www.gnu.org/licenses/gpl-3.0.html GNU/GPL-3.0
 * @author      Loic ROUCHON <horn@phpboost.com>
 * @version     PHPBoost 5.2 - last update: 2018 02 12
 * @since       PHPBoost 2.0 - 2008 06 21
 * @contributor Julien BRISWALTER <j1.seth@phpboost.com>
*/

class FeedItem
{
    private $title = '';        // Item Title
    private $link = '';         // Item Url
    private $date = null;       // Feed date
    private $desc = '';         // Item Description
    private $guid = '';         // Item GUID
    private $image_url = '';    // Item Image
    private $enclosure;         // Item Enclosure
    private $auth = null;       // Authorizations

    ## Setters ##
    /**
     * Sets the feed item title
     * @param string $value The title
     */
    public function set_title($value) { $this->title = strip_tags($value); }
    /**
     * Sets the feed item date
     * @param Date $value a date object representing the item date
     */
    public function set_date($value) { $this->date = $value; }
    /**
     * Sets the feed item description
     * @param string $value the feed item description
     */
    public function set_desc($value) { $this->desc = $value; }
    /**
     * Sets the feed item picture
     * @param string $value the picture url
     */
    public function set_image_url($value) { $this->image_url = $value; }
    /**
     * Sets the feed item enclosure
     * @param FeedItemEnclosure $value the enclosure
     */
    public function set_enclosure(FeedItemEnclosure $value) { $this->enclosure = $value; }
    /**
     * Sets the feed item auth, useful to check authorizations
     * @param int[string] $value the item authorizations array
     */
    public function set_auth($auth) { $this->auth = $auth; }
    /**
     * Sets the feed item link
     * @param mixed $value a string url or an Url object
     */
    public function set_link($value)
    {
        if (!($value instanceof Url))
        {
            $value = new Url($value);
        }
        $this->link = $value->absolute();
    }
    /**
     * Sets the feed item guid
     * @param mixed $value a string url or an Url object
     */
    public function set_guid($value)
    {
        if ($value instanceof Url)
        {
            $this->guid = $value->absolute();
        }
        else
        {
            $this->guid = $value;
        }
    }

    ## Getters ##
    public function get_title() { return TextHelper::htmlspecialchars_decode($this->title); }
    public function get_link() { return $this->link; }
    public function get_guid() { return $this->guid; }
    public function get_date() { return $this->date->format(Date::FORMAT_DAY_MONTH, Timezone::USER_TIMEZONE); }
    public function get_date_rfc2822() { return $this->date->format(Date::FORMAT_RFC2822, Timezone::USER_TIMEZONE); }
    public function get_date_iso8601() { return $this->date->format(Date::FORMAT_ISO8601, Timezone::USER_TIMEZONE); }
    public function get_hours() { return $this->date->get_hours(); }
    public function get_minutes() { return $this->date->get_minutes(); }
    public function get_date_text() { return $this->date->format(Date::FORMAT_DAY_MONTH_YEAR_LONG, Timezone::USER_TIMEZONE); }
    public function get_desc() { return TextHelper::htmlspecialchars_decode($this->desc); }
    public function get_image_url() { return $this->image_url; }
    public function get_enclosure() { return $this->enclosure; }
    public function get_auth() { return $this->auth; }
}
?>