open) return false; $language = lang_base(Config::current()->locale); $link = url("/", MainController::current()); $feed = ''."\n"; $feed.= ''."\n"; $feed.= ''."\n"; $feed.= ''.fix($language).''."\n"; $feed.= ''.strip_tags($title).''."\n"; if (!empty($subtitle)) $feed.= ''. strip_tags($subtitle). ''. "\n"; $feed.= ''. when(DATE_RSS, oneof($updated, time())). ''. "\n"; $feed.= ''.$link.''."\n"; $feed.= ''.CHYRP_IDENTITY.''."\n"; $this->xml = array( "feed" => $feed, "items" => array() ); return $this->open = true; } /** * Function: entry * Adds an individual feed item. * * Parameters: * $title - Title for this item. * $id - The unique ID. * $content - Content for this item. * $link - The URL to the resource. * $published - Time of creation. * $updated - Time of update (optional). * $name - Name of the author (optional). * $uri - URI of the author (optional). * $email - Email address of the author (optional). * * Notes: * The item remains open to allow triggered insertions. */ public function entry( $title, $id, $content, $link, $published, $updated = null, $name = "", $uri = "", $email = "" ): bool { if (!$this->open) return false; $this->count++; $entry = ''.strip_tags($title).''."\n"; $entry.= ''.fix($id).''."\n"; $entry.= ''. when(DATE_RSS, $published). ''. "\n"; $entry.= ''.fix($link).''."\n"; $entry.= ''. fix($content, false, true). ''. "\n"; if (!empty($email) and is_email($email)) $entry.= ''.fix($email).''."\n"; $item = $this->count - 1; $this->xml["items"][$item] = $entry; return true; } /** * Function: category * Adds a category element for an item. * * Parameters: * $term - String that identifies the category. * $scheme - URI for the categorization scheme (optional). * $label - Human-readable label for the category (optional). */ public function category($term, $scheme = "", $label = ""): bool { if (!$this->open) return false; if (!$this->count) return false; $category = ''."\n"; $item = $this->count - 1; $this->xml["items"][$item].= $category; return true; } /** * Function: rights * Not implemented in RSS 2.0.11. */ public function rights($text): bool { return false; } /** * Function: enclosure * Adds an enclosure element for a resource that is potentially large in size. * * Parameters: * $link - The URL to the resource. * $length - Size in bytes of the resource (optional). * $type - The media type of the resource (optional). * $title - Title for the resource (optional). */ public function enclosure( $link, $length = 0, $type = "", $title = "" ): bool { if (!$this->open) return false; $enclosure = ''. "\n"; if (!$this->count) { $this->xml["feed"].= $enclosure; } else { $item = $this->count - 1; $this->xml["items"][$item].= $enclosure; } return true; } /** * Function: related * Not implemented in RSS 2.0.11. */ public function related($link): bool { return false; } /** * Function: feed * Returns the generated feed. */ public function feed(): string { $feed = $this->xml["feed"]; $items = $this->xml["items"]; foreach ($items as $item) { $feed.= ''."\n". $item. ''."\n"; } $feed.= ''."\n"; $feed.= ''."\n"; return $feed; } /** * Function: output * Displays the generated feed. */ public function display(): bool { if (headers_sent()) return false; header("Content-Type: ".self::type()."; charset=UTF-8"); echo $this->feed(); return true; } }