<?php
session_start();

$path = $_SERVER['DOCUMENT_ROOT'];
include_once($path."/microsite_functions.php");
include_once($path."/collections/functions_collections.php");
require_once($path.'/collections/classes/Pagination2023.Bootstrap.class.php');
require_once($path.'/collections/classes/FacetBuilder2023.class.php');
include_once($path."/collections/classes/CollectionsFunctions2023.class.php");
include_once($path."/collections/classes/RecordTemplater2023.class.php");
require_once($path.'/collections/new/SolrUrlBuilder.class.php');

$FacetBuilder = new FacetBuilder2023();
$SolrUrlBuilder = new SolrUrlBuilder();
$Pagination = new Pagination();
$CollectionsFunctions2023 = new CollectionsFunctions2023();

if(!isset($_GET['page']) || !ctype_digit($_GET['page'])) { $page = 1; }
else { $page = (int) $_GET['page']; }

try
{
	$curl_string = $SolrUrlBuilder->getLocation('ur');
    $resp = solrCurl($curl_string);
	$result = json_decode($resp, true);

	$response_status = $result['responseHeader']['status'];
	$num_found = $result['response']['numFound'];
	$start_record = $result['response']['start'];
	$documents = $result['response']['docs'];
	$facets = $result['facet_counts']['facet_fields'];

	if($num_found > 0)
	{
		$paginagtion_html = $Pagination->getPagination($page, $num_found, 30, $_SERVER['SCRIPT_NAME'].'?'.$SolrUrlBuilder->getStrippedQueryString(), "search");
		$RecordTemplater =  new RecordTemplater2023();
		$results = $RecordTemplater->displayResultset($documents);
	}
	else { $paginagtion_html = ''; }
	if($response_status !== 0) { echo 'Something went Wrong :('; }

}
catch(Exception $e) { echo CollectionsFunctions::get_exception_text(); }

$MetaDescription = 'Ur (Iraq) was one of the most famous archaeological excavations—along with Tutankhamun’s tomb in Egypt—during the early 20th century.';
$Keywords = 'Iraq, Ur, C. Leonard Woolley, Mesopotamia';
$Title = 'Ur, Iraq - Highlights | Digital Collections';

$collections->get_Header($Keywords,$MetaDescription,$Title);
$collections->get_Microsite_menu($myfinds = true);

?>
<section class="pb-0">
	<div class="main-container">
		<?php echo get_Breadcrumb('/collections', 'Online Collections'); ?>
		<h1>Ur, Iraq</h1>
		<?php echo get_Hero_Img('https://collections.penn.museum/img/collections/ur-lg.jpg', 'Work at Ur.', ''); ?>
	</div>
</section>
<section class="pt-5">
	<div class="main-container">
		<div class="row g-2 pt-5">
			<div class="left-rail">
				<div style="width: 100%; height: 300px" id="map"></div>
			</div>
			<div class="right-rail ms-0">
				<p class="text-lg">Located in southern Iraq, near the former northern limits of the Persian Gulf, Ur was one of the most famous archaeological excavations—along with Tutankhamun’s tomb in Egypt—during the early 20th century. Frequently described in the popular press, the work at Ur brought the magic of archaeology to life, particularly by tying the discoveries into familiar biblical stories. Between 1922 and 1934, the Joint Expedition of the British Museum and the Penn Museum was directed by C. Leonard Woolley and uncovered some of the most well-known and celebrated art from ancient Mesopotamia. These finds were divided between the two partner institutions (25% each) and the Baghdad Museum in Iraq (50%).</p>
			</div>
		</div>
	</div>
</section>
<section class="collections-search-results pt-5">
	<div class="main-container">
		<div class="row g-2">
			<div class="left-rail">
				<div class="collections-facets accordion-item">
					<button id="accordion-title-accordion" class="accordion-title" tabindex="0" aria-expanded="true" aria-controls="accordion-panel-accordion">
						<div class="accordion-arrow">
							<span class="accordion-arrow-item">
								<img src="https://collections.penn.museum/img/brand/svg/arrow-down.svg" alt="">
							</span>
						</div>
						<h4>Search Result Filters</h4>
					</button>
					<div class="accordion-content ps-0" id="accordion-panel-accordion" aria-labelledby="accordion-title-accordion">
						<div class="accordion">
							<div class="accordion-text w-100">
							<?php $FacetBuilder->displayFacets($facets); ?>
						</div>
						</div>
						
					</div>
				</div>
			</div>
			<div class="right-rail">
				<div class="row g-2 mb-4">
					<div class="left-rail-wide">
						<?php echo $FacetBuilder->getFacetRemovalLinks($SolrUrlBuilder->getQueryArray()); ?>
					</div>
					<div class="right-rail-narrow">
						<?php echo $Pagination->calculate_records($page, $num_found, 30, $_SERVER['SCRIPT_NAME'].'?'.$SolrUrlBuilder->getStrippedQueryString(), "search"); ?>
					</div>
				</div>
				<div class="row g-1 four-up pb-5">
					<?php foreach ($results as $result) {
						echo $result;
					}  ?>
				</div>
				<?php echo $paginagtion_html; ?>
			</div>
		</div>
	</div>
</section>

<?php get_Footer($CollectionsFunctions2023->getCollectionsJS().'<script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDYrqTpG5F1ZU0DwZP6IY736X8TJykqYAY&callback=initMap"></script><script type="text/javascript">
jQuery(window).on("load", function() {
    initialize();

    function initialize() {
    	var uluru = {lat: 30.9625, lng: 46.103056};

        var mapOptions = {
            center: uluru,
            zoom: 12
        };
        
        var map = new google.maps.Map(document.getElementById("map"), mapOptions);
        var marker = new google.maps.Marker({
          position: uluru,
          map: map
        });

    }
});
</script>');  ?>
