<commit_before><?php

class RSSAggEntry extends DataObject {
	static $has_one = array(
		"Page" => "RSSAggregatingPage",
		"Source" => "RSSAggSource",		
	);
	
	static $db = array(
		"Displayed" => "Boolean",
		"Date" => "SSDatetime",
		"Title" => "Varchar(255)",
		"Content" => "HTMLText",
		"Permalink" => "Varchar(255)",
		"EnclosureURL" => "Varchar(255)",
	);
	
	static $casting = array(
		"PlainContentSummary" => "Text",
	);
	
	/*
	 * Set new feed item to true if feed moderation is turned off
	 */
	public function populateDefaults() { 
		parent::populateDefaults();
		if ( !RSSAggregatingPage::get_moderation_required() ) {
			$this->Displayed = true;
		}
	}
	
	
	function getPlainContentSummary() {
		$content = trim(
			strip_tags(
				ereg_replace("&#[0-9]+;", " ", 
					str_replace(array("<p>","<br/>","<br />", "<br>"), array("\n\n","\n","\n","\n"), 
						ereg_replace("[\t\r\n ]+", " ", $this->Content)
					)
				)
			)
		);
		
		$parts = explode("\n\n", $content, 2);
		return $parts[0];
	}
	
	function isNews() {
		if($source = DataObject::get_by_id('SiteTree', $this->PageID)) {
			if($source->URLSegment == 'aggregated-news') {
				return true;
			}
		}
	}
	
	function Image() {
		if($this->isNews()) {
			$img = new NewsArticle_ArticleImage();
		} else {
			$img = new EventPage_Image();
		}
		$img->Filename = $this->EnclosureURL;
		return $img;
	}

	function getDateNice() {
		return $this->obj('Date')->Nice();
	}
	
	function Link() {
		return $this->Permalink;
	}
	
	function Permalink() {
		return str_replace('&amp;', '&', $this->Permalink);
	}

	// These functions are included for improved compatability with SiteTree
	function MenuTitle() {
		return $this->Title;
	}
	
	function LinkOrCurrent() {
		return "link";<commit_msg>BUGFIX: added method to display 'Source' on 'Items' list<commit_after><?php

class RSSAggEntry extends DataObject {
	static $has_one = array(
		"Page" => "RSSAggregatingPage",
		"Source" => "RSSAggSource",		
	);
	
	static $db = array(
		"Displayed" => "Boolean",
		"Date" => "SSDatetime",
		"Title" => "Varchar(255)",
		"Content" => "HTMLText",
		"Permalink" => "Varchar(255)",
		"EnclosureURL" => "Varchar(255)",
	);
	
	static $casting = array(
		"PlainContentSummary" => "Text",
	);
	
	/*
	 * Set new feed item to true if feed moderation is turned off
	 */
	public function populateDefaults() { 
		parent::populateDefaults();
		if ( !RSSAggregatingPage::get_moderation_required() ) {
			$this->Displayed = true;
		}
	}
	
	
	function getPlainContentSummary() {
		$content = trim(
			strip_tags(
				ereg_replace("&#[0-9]+;", " ", 
					str_replace(array("<p>","<br/>","<br />", "<br>"), array("\n\n","\n","\n","\n"), 
						ereg_replace("[\t\r\n ]+", " ", $this->Content)
					)
				)
			)
		);
		
		$parts = explode("\n\n", $content, 2);
		return $parts[0];
	}
	
	function isNews() {
		if($source = DataObject::get_by_id('SiteTree', $this->PageID)) {
			if($source->URLSegment == 'aggregated-news') {
				return true;
			}
		}
	}
	
	function Image() {
		if($this->isNews()) {
			$img = new NewsArticle_ArticleImage();
		} else {
			$img = new EventPage_Image();
		}
		$img->Filename = $this->EnclosureURL;
		return $img;
	}

	function getDateNice() {
		return $this->obj('Date')->Nice();
	}
	
	function getSourceNice() {
		$sourceID = $this->SourceID;
		$Source = DataObject::get_by_id('RSSAggSource',$sourceID);
		if($Source) return $Source->Title;
		return;
	}
	
	function Link() {
		return $this->Permalink;
	}
	
	function Permalink() {
		return str_replace('&amp;', '&', $this->Permalink);
	}

	// These functions are included for improved compatability with SiteTree
	function MenuTitle() {
		return $this->Title;
	}
	
	function LinkOrCurrent() {
		return "link";
{'fraction_non_alphanumeric': 0.19651006711409397, 'fraction_numerical': 0.00697986577181208, 'mean_word_length': 3.6285714285714286, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4470823', 'n_tokens_mistral': 1571, 'n_tokens_neox': 1351, 'n_words': 261}