<commit_before><?php

require_once 'MetaTags.php';
require_once 'BibLink.php';
require_once 'Export.php';

class PublicationView extends View {
	
	private $publication;
	private $template;


	public function __construct(PublicationModel $model, $template = 'dev') {

		$this -> publication = $model -> getPublication();
		$this -> template = './templates/'.$template.'/publication.html';
	}


	public function getContent() {
		return parent::getContent($this -> template);
	}


	public function viewPageTitle() {
		return $this -> publication -> getTitle();
	}


	public function viewMetaTags() {

		$string = '';

		foreach (MetaTags::getStyles() as $style) {
			$string .= MetaTags::getPublicationsMetaTags($this -> publication, $style);
		}

		return $string;
	}


	public function viewTitle() {
		return $this -> publication -> getTitle();
	}


	public function viewAuthors($separator = ' and ') {

		$string = '';
		$url = '?p=author&amp;id=';

		foreach ($this -> publication -> getAuthors() as $author) {
			$string .= '<a href ="'.$url.$author -> getId().'">'
							.$author -> getName().'</a>'.$separator;
		}

		return substr($string, 0, -(strlen($separator)));	
	}


	public function viewPublishDate() {
		return $this -> publication -> getMonth().'.'.$this -> publication -> getYear();
	}


	public function viewType() {
		return $this -> publication -> getType();
	}


	public function viewAbstract() {
		return $this -> publication -> getAbstract();
	}


	public function viewReferences() {
		// TODO: Implementation
		return 'TODO';
	}


	public function viewKeyTerms($separator = ', ') {

		$string = '';
		$url = '?p=browse&amp;by=key_term&amp;id=';

		foreach ($this -> publication -> getKeyTerms() as $key_term) {
			$string .= '<a href="'.$url.$key_term -> getId().'">'
								.$key_term -> getName().'</a>'.$separator;
		}

		return substr($string, 0, -(strlen($separator)));
	}


	public function viewBibLinks() {

		$string = '';

		foreach (BibLink::getServices() as $service) {
			$string .= '<li><a href="'.BibLink::getPublicationsLink($this -> publication, $service).'" target="_blank">'.$service.'</a></li>';
		}

		return $string;
	}


	public function viewExport() {
		$string = '';

		foreach (Export::getStyles() as $style) {
			$string .= '<li><a href="'.Export::getPublicationsExport($this -> publication, $style).'" target="_blank">'.$style.' (TODO)</a></li>';
		}

		return $string;
	}
		
}<commit_msg>changed behaviour when data is missing<commit_after><?php

require_once 'MetaTags.php';
require_once 'BibLink.php';
require_once 'Export.php';

class PublicationView extends View {
	
	private $publication;
	private $template;


	public function __construct(PublicationModel $model, $template = 'dev') {

		$this -> publication = $model -> getPublication();
		$this -> template = './templates/'.$template.'/publication.html';
	}


	public function getContent() {
		return parent::getContent($this -> template);
	}


	public function viewPageTitle() {
		return $this -> publication -> getTitle();
	}


	public function viewMetaTags() {

		$string = '';

		foreach (MetaTags::getStyles() as $style) {
			$string .= MetaTags::getPublicationsMetaTags($this -> publication, $style);
		}

		return $string;
	}


	public function viewTitle() {
		return $this -> publication -> getTitle();
	}


	public function viewAuthors($separator = ' and ') {

		$string = '';
		$url = '?p=author&amp;id=';

		foreach ($this -> publication -> getAuthors() as $author) {
			$string .= '<a href ="'.$url.$author -> getId().'">'
							.$author -> getName().'</a>'.$separator;
		}

		return substr($string, 0, -(strlen($separator)));	
	}


	public function viewPublishDate() {
		return $this -> publication -> getMonth().'.'.$this -> publication -> getYear();
	}


	public function viewType() {
		return $this -> publication -> getType();
	}


	public function viewAbstract() {
		$string = $this -> publication -> getAbstract();

		if (!empty($string)) {
			return $string;
		}
		else {
			return 'no abstract given';
		}
	}


	public function viewReferences() {
		// TODO: Implementation
		return 'TODO';
	}


	public function viewKeyTerms($separator = ', ') {
		$key_terms = $this -> publication -> getKeyTerms();

		if (!empty($key_terms)) {

			$string = '';
			$url = '?p=browse&amp;by=key_term&amp;id=';

			foreach ($this -> publication -> getKeyTerms() as $key_term) {
				$string .= '<a href="'.$url.$key_term -> getId().'">'
									.$key_term -> getName().'</a>'.$separator;
			}

			return substr($string, 0, -(strlen($separator)));
		}
		else {

			return 'no key terms assigned';
		}


	}


	public function viewBibLinks() {

		$string = '';

		foreach (BibLink::getServices() as $service) {
			$string .= '<li><a href="'.BibLink::getPublicationsLink($this -> publication, $service).'" target="_blank">'.$service.'</a></li>';
		}

		return $string;
	}


	public function viewExport() {
		$string = '';

		foreach (Export::getStyles() as $style) {
			$string .= '<li><a href="'.Export::getPublicationsExport($this -> publication, $style).'" target="_blank">'.$style.' (TODO)</a></li>';
		}

		return $string;
	}
		
}
{'fraction_non_alphanumeric': 0.19393703847648658, 'fraction_numerical': 0.000777302759424796, 'mean_word_length': 3.696167883211679, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 83, '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': '6116655', 'n_tokens_mistral': 1853, 'n_tokens_neox': 1602, 'n_words': 368}