<commit_before><?php

$ROOT = plugin_dir_path( __FILE__ );

include_once $ROOT."controllers/ObjectController.php";
include_once $ROOT."controllers/CategoryController.php";
include_once $ROOT."controllers/AuthorController.php";

add_action('init', 'rules');

function rules() {
	add_rewrite_rule('^katalog/objekt/([^/]*)/?','index.php?objekt=$matches[1]','top');
	add_rewrite_tag('%objekt%','([^/]*)');
	
	add_rewrite_rule('^katalog/kategorie/([^/]*)/?','index.php?kategorie=$matches[1]','top');
	add_rewrite_tag('%kategorie%','([^/]*)');
	
	add_rewrite_rule('^katalog/autor/([^/]*)/?','index.php?autor=$matches[1]','top');
	add_rewrite_tag('%autor%','([^/]*)');
	
	flush_rewrite_rules();
}

function kv_is_object() {
	global $wp_query;
	return isset($wp_query->query_vars['objekt']);
}

function kv_object_title() {
	global $wp_query;
	$oc = new ObjectController();
	
	$id = (int) $wp_query->query_vars['objekt'];
	$obj = $oc->getObjectById($id);
	if ($obj == null) {
		return "";	
	}
	
	return $obj->nazev;
}

function kv_object() {
	global $wp_query;
	$output = "";
	$oc = new ObjectController();
	
	$id = (int) $wp_query->query_vars['objekt'];
	$obj = $oc->getObjectById($id);
	if ($obj == null) {
		$output.= '<h2>Objekt nebyl nalezen</h2>';
		
		return $output;	
	}
	
	
	$output.= '<h2>'.$obj->nazev.'</h2>';
	
	if (strlen ($obj->popis) > 3) {
		$output.= '<p>'.stripslashes($obj->popis).'</p>';
	}
	
	// fotky
	$photos = $oc->getPhotosForObject();
	$upload_dir = wp_upload_dir();
	
	if (count($photos) > 0) {
		$output .= '<div class="gallery">';
		foreach ($photos as $photo) {
			$caption = "";
			if (strlen($photo->autor) > 0) {
				$caption = "Autor: ".$photo->autor;
			}
				
			
			$output .= '<a href="'. $upload_dir['baseurl'].$photo->img_large.'" data-lightbox="gallery" data-title="'.$caption.'"><img src="'. $upload_dir['baseurl'].$photo->img_thumbnail.'" class="gallery-img" /></a>';
		}
		$output .= '</div>';
	}
	
	
	// obsah
	if ($obj->zpracovano) {
		$output .= '<div>'.stripslashes($obj->obsah).'</div>';
	} else {
		$output .= '<p><em>K památce dosud nebyl zpracován text.</em></p>';	
	}
	
	// Mapa
	$output .= '<h3>Umístění</h3>';
	$output .= '<p><strong>GPS</strong>: '.$obj->latitude.', '.$obj->longitude;
	$output .= ' (<a href="https://maps.google.cz/maps?q='.$obj->latitude.','.$obj->longitude.'">Google</a>';
	$output .= ', <a href="http://www.mapy.cz?q='.$obj->latitude.','.$obj->longitude.'">Mapy.cz</a>';
	$output .= ', <a href="http://www.openstreetmap.org/search?query='.$obj->latitude.','.$obj->longitude.'">OpenStreetMap</a>)</p>';
	
	$output .= $oc->getGoogleMapPointContent($obj->latitude, $obj->longitude);
	
	
	return $output;
	
}

function kv_object_infobox() {
	global $wp_query;
	$oc = new ObjectController();
	
	$id = (int) $wp_query->query_vars['objekt'];
	$obj = $oc->getObjectById($id);
	if ($obj == null) {
		return "";	
	}
	
	$infobox = '<div id="infobox">';
	
	// kategorie
	$infobox .= '<p><strong>Kategorie:</strong><br /><a href="'.get_site_url().'/katalog/kategorie/'.$obj->kategorie.'/">'.$oc->getCategoryNameForObject($obj->kategorie).'</a></p>';
	
	// autoři
	if (count($oc->getAuthorsForObject()) > 0) {<commit_msg>Zobrazení souvisejících odkazů na webu<commit_after><?php

$ROOT = plugin_dir_path( __FILE__ );

include_once $ROOT."controllers/ObjectController.php";
include_once $ROOT."controllers/CategoryController.php";
include_once $ROOT."controllers/AuthorController.php";

add_action('init', 'rules');

function rules() {
	add_rewrite_rule('^katalog/objekt/([^/]*)/?','index.php?objekt=$matches[1]','top');
	add_rewrite_tag('%objekt%','([^/]*)');
	
	add_rewrite_rule('^katalog/kategorie/([^/]*)/?','index.php?kategorie=$matches[1]','top');
	add_rewrite_tag('%kategorie%','([^/]*)');
	
	add_rewrite_rule('^katalog/autor/([^/]*)/?','index.php?autor=$matches[1]','top');
	add_rewrite_tag('%autor%','([^/]*)');
	
	flush_rewrite_rules();
}

function kv_is_object() {
	global $wp_query;
	return isset($wp_query->query_vars['objekt']);
}

function kv_object_title() {
	global $wp_query;
	$oc = new ObjectController();
	
	$id = (int) $wp_query->query_vars['objekt'];
	$obj = $oc->getObjectById($id);
	if ($obj == null) {
		return "";	
	}
	
	return $obj->nazev;
}

function kv_object() {
	global $wp_query;
	$output = "";
	$oc = new ObjectController();
	
	$id = (int) $wp_query->query_vars['objekt'];
	$obj = $oc->getObjectById($id);
	if ($obj == null) {
		$output.= '<h2>Objekt nebyl nalezen</h2>';
		
		return $output;	
	}
	
	
	$output.= '<h2>'.$obj->nazev.'</h2>';
	
	if (strlen ($obj->popis) > 3) {
		$output.= '<p>'.stripslashes($obj->popis).'</p>';
	}
	
	// fotky
	$photos = $oc->getPhotosForObject();
	$upload_dir = wp_upload_dir();
	
	if (count($photos) > 0) {
		$output .= '<div class="gallery">';
		foreach ($photos as $photo) {
			$caption = "";
			if (strlen($photo->autor) > 0) {
				$caption = "Autor: ".$photo->autor;
			}
				
			
			$output .= '<a href="'. $upload_dir['baseurl'].$photo->img_large.'" data-lightbox="gallery" data-title="'.$caption.'"><img src="'. $upload_dir['baseurl'].$photo->img_thumbnail.'" class="gallery-img" /></a>';
		}
		$output .= '</div>';
	}
	
	
	// obsah
	if ($obj->zpracovano) {
		$output .= '<div>'.stripslashes($obj->obsah).'</div>';
	} else {
		$output .= '<p><em>K památce dosud nebyl zpracován text.</em></p>';	
	}
	
	// Související odkazy
	if (count($oc->getSourcesForObject()) > 0) {
		$output .= '<h3>Externí zdroje</h3><ul>';
		
		foreach($oc->getSourcesForObject() as $source) {
			if (strlen($source->url) == 0) {
				$output .= 	'<li>'.$source->nazev.'</li>';
			} else {
				$output .= 	'<li><a href="'.$source->url.'">'.$source->nazev.'</a></li>';
			}
		}
		
		$output .= '</ul>';
	} 
	
	// Mapa
	$output .= '<h3>Umístění</h3>';
	$output .= '<p><strong>GPS</strong>: '.$obj->latitude.', '.$obj->longitude;
	$output .= ' (<a href="https://maps.google.cz/maps?q='.$obj->latitude.','.$obj->longitude.'">Google</a>';
	$output .= ', <a href="http://www.mapy.cz?q='.$obj->latitude.','.$obj->longitude.'">Mapy.cz</a>';
	$output .= ', <a href="http://www.openstreetmap.org/search?query='.$obj->latitude.','.$obj->longitude.'">OpenStreetMap</a>)</p>';
	
	$output .= $oc->getGoogleMapPointContent($obj->latitude, $obj->longitude);
	
	
	return $output;
	
}

function kv_object_infobox() {
	global $wp_query;
	$oc = new ObjectController();
	
	$id = (int) $wp_query->query_vars['objekt'];
	$obj = $oc->getObjectById($id);
	if ($obj == null) {
		return "";	
	}
	
	$infobox = '<div id="infobox">';
	
	// kategorie
	$infobox .= '<p><strong>Kategorie:</strong><br /><a href="'.get_site_url().'/katalog/kategorie/'.$obj->kategorie.'/">'.$oc->getCategoryNameForObject($obj->kategorie).'</a></p>';
	
	// autoři
	if (count($oc->getAuthorsForObject()) > 0) {
{'fraction_non_alphanumeric': 0.26305666518715787, 'fraction_numerical': 0.004438526409232135, 'mean_word_length': 4.442834138486313, 'pattern_counts': {'":': 0, '<': 89, '<?xml version=': 0, '>': 168, 'https://': 2, 'lorem ipsum': 0, 'www.': 4, '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': '5470255', 'n_tokens_mistral': 2865, 'n_tokens_neox': 2688, 'n_words': 368}