<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
function AMPD_import_photos_page() {?>

<div id="wp-script">
	<div class="content-tabs">
		<div class="row">
			<div class="col-xs-12 padding-top-10 padding-bottom-10">
				<div class="logo"><h2><a href="https://www.wp-script.com" target="_blank"><img class="panda" src="<?php echo WPSCORE_URL; ?>admin/assets/images/logo-wp-script.svg" width="250"/></a></h2></div>
			</div>
		</div>

		<?php WPSCORE()->display_tabs(); ?>

		<div class="tab-content">
			<div class="tab-pane fade in active" id="import-photos">
				<!-- empty div for auto margin -->
				<div></div>
				<div v-cloak class="padding-top-15">

					<div class="row text-center v-cloak--block">
						<div class="col-xs-12 loading"><p><i class="fa fa-cog fa-spin fa-2x fa-fw" aria-hidden="true"></i><br><?php _e( 'Loading Page', 'ampd_lang' ); ?>...</span></p></div>
					</div>

					<div class="v-cloak--hidden fuelux">

						<!--**************-->
						<!-- LOADING DATA -->
						<!--**************-->
						<template v-if="loading.loadingData">
							<div class="row text-center">
								<div class="col-xs-12 loading"><p><i class="fa fa-cog fa-spin-reverse fa-2x fa-fw" aria-hidden="true"></i><br><?php _e( 'Loading Data', 'ampd_lang' ); ?>...</span></p></div>
							</div>
						</template>
						<transition name="fade">

							<div v-if="dataLoaded">

								<!-- search galleries block -->
								<div class="row">
									<div class="col-xs-12">
										<h3><?php _e( 'Search photos galleries', 'ampd_lang' ); ?></h3>
										<div id="block-search" class="margin-bottom-15">
											<div class="row">
												<div class="col-xs-12 col-md-6 col-lg-4">
													<div class="input-group float-left">
														<input v-model="selectedKW" v-bind:disabled="searchingGalleries" id="kw_s" type="text" placeholder="<?php _e( 'Keyword', 'ampd_lang' ); ?>" name="kw_s" class="form-control" v-on:keyup.enter="searchGalleries(1)">
														<div class="input-group-btn">
														<button class="btn btn-default" v-on:click="toggleFilters"><i class="fa fa-filter" aria-hidden="true"></i> <?php _e( 'Filters', 'ampd_lang' ); ?> <i class="fa" v-bind:class="[showFilters ? 'fa-caret-up':'fa-caret-down']" aria-hidden="true"></i></button>
														</div>
													</div>
												</div>
												<div class="col-xs-12 col-md-6">
													<button v-if="!searchingGalleries" v-on:click.prevent="searchGalleries(1)" class="btn btn-pink" v-bind:class="searchBtnClass"><?php _e( 'Search photos galleries', 'ampd_lang' ); ?></button>
													<button v-else="searchingGalleries" disabled="disabled" class="btn btn-pink"><i class="fa fa-spinner fa-pulse" aria-hidden="true"></i> <?php _e( 'Searching', 'ampd_lang' ); ?>...</button>
												</div>
											</div>
											<div id="filters" v-show="showFilters" class="row margin-top-20">
												<div class="col-xs-12 col-md-6 col-lg-8">
													<strong><?php _e( 'Orientation', 'ampd_lang' ); ?></strong>
													<ul>
														<li v-bind:class="{'active':filters.orientations == 'straight'}"><a href="#" v-on:click.prevent="updateFilter('orientations', 'straight')"><?php _e( 'Straight', 'ampd_lang' ); ?></a></li>
														<li v-bind:class="{'active':filters.orientations == 'gay'}"><a href="#" v-on:click.prevent="updateFilter('orientations', 'gay')"><?php _e( 'Gay', 'ampd_lang' ); ?></a></li>
														<li v-bind:class="{'active':filters.orientations == 'shemale'}"><a href="#" v-on:click.prevent="updateFilter('orientations', 'shemale')"><?php _e( 'Shemale', 'ampd_lang' ); ?></a></li>
													</ul>
												</div>
												<div class="col-xs-12 col-md-3">
													<strong><?php _e( 'Upload date', 'ampd_lang' ); ?></strong>
													<ul>
														<li v-bind:class="{'active':filters.date == ''}"><a href="#" v-on:click.prevent="updateFilter('date', '')"><?php _e( 'Any', 'ampd_lang' ); ?></a></li>
														<li v-bind:class="{'active':filters.date == 'daily'}"><a href="#" v-on:click.prevent="updateFilter('date', 'daily')"><?php _e( 'Today', 'ampd_lang' ); ?></a></li>
														<li v-bind:class="{'active':filters.date == 'weekly'}"><a href="#" v-on:click.prevent="updateFilter('date', 'weekly')"><?php _e( 'This week', 'ampd_lang' ); ?></a></li>
														<li v-bind:class="{'active':filters.date == 'monthly'}"><a href="#" v-on:click.prevent="updateFilter('date', 'monthly')"><?php _e( 'This month', 'ampd_lang' ); ?></a></li>
														<li v-bind:class="{'active':filters.date == 'yearly'}"><a href="#" v-on:click.prevent="updateFilter('date', 'yearly')"><?php _e( 'This year', 'ampd_lang' ); ?></a></li>
													</ul>
												</div>
												<div class="col-xs-12 col-md-3">
													<strong><?php _e( 'Sort by', 'ampd_lang' ); ?></strong>
													<ul>
														<li v-bind:class="{'active':filters.sort == ''}"><a href="#" v-on:click.prevent="updateFilter('sort', '')"><?php _e( 'Relevance', 'ampd_lang' ); ?></a></li>
														<li v-bind:class="{'active':filters.sort == 'newest'}"><a href="#" v-on:click.prevent="updateFilter('sort', 'newest')"><?php _e( 'Upload date', 'ampd_lang' ); ?></a></li>
														<li v-bind:class="{'active':filters.sort == 'views'}"><a href="#" v-on:click.prevent="updateFilter('sort', 'views')"><?php _e( 'View count', 'ampd_lang' ); ?></a></li>
														<li v-bind:class="{'active':filters.sort == 'best'}"><a href="#" v-on:click.prevent="updateFilter('sort', 'best')"><?php _e( 'Rating', 'ampd_lang' ); ?></a></li>
													</ul>
												</div>
											</div>
										</div>
									</div>
								</div>
								<!-- / search galleries block -->

								<!-- results success block -->
								<div class="row mt-5">
									<div class="col-xs-12" v-show="galleriesCounter <= 0 && galleriesHasBeenSearched">
										<div v-if="galleriesSearchedErrors" class="alert alert-danger margin-top-10 text-center" role="alert">
											<p><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> <strong>{{galleriesSearchedErrors.code}}</strong><br>{{galleriesSearchedErrors.message}}<br>-<br>{{galleriesSearchedErrors.solution}}</p>
										</div>
										<div v-else class="alert alert-info margin-top-10 text-center" role="alert">
											<p><i class="fa fa-meh-o" aria-hidden="true"></i> <strong><?php _e( 'No result', 'ampd_lang' ); ?></strong><br>
												<?php _e( 'There is no result for this keyword', 'ampd_lang' ); ?>
											</p>
										</div>
									</div>
									<transition name="fade">
										<div v-show="galleriesCounter > 0" id="galleries-found" class="col-xs-12 margin-top-10">
											<h3>
												<?php _e( 'Search results', 'ampd_lang' ); ?>
												<button v-on:click.prevent="resetSearch" class="btn btn-default btn-sm"><?php _e( 'Close search results', 'ampd_lang' ); ?></button>
											</h3>
											<div id="galleries" class="row" class="cards">
												<div v-for="(gallery, index) in galleries" class="col-xs-12 col-sm-6 col-md-4 col-lg-2 item-cards" v-bind:key="gallery.index">
													<div class="gallery gallery-cover" data-toggle="modal" data-target="#gallery-preview-modal" v-on:click.prevent="setCurrentGallery(gallery)" v-bind:style='"background-image:url(" + gallery.g_thumb + ")"'>
														<span v-if="gallery.g_count" class="gallery-count"><i class="fa fa-camera" aria-hidden="true"></i> {{gallery.g_count}}</span>
													</div>
													<div class="gallery-title">{{gallery.g_title}}</div>
												</div>
											</div>
											<div class="clear"></div>
											<div v-show="galleriesCounter >= 56" class="text-center pagination-block">
												<ul class="pagination">
													<li v-for="n in maxPage" @click="searchGalleries(n)" v-bind:class="{ active: currentPage == n }"><span>{{n}}</span></li>
												</ul>
											</div>
										</div>
									</transition>
								</div>
								<!-- /results success block -->
								<!-- Gallery Modal -->
								<div class="modal fade" id="gallery-preview-modal" tabindex="-1" role="dialog">
									<div class="modal-dialog modal-lg">
										<div class="modal-content">
											<div class="modal-header">
												<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
												<?php _e( 'Photos from gallery', 'ampd_lang' ); ?>: {{currentGallery.g_title}}
											</div>
											<transition name="fade">
												<div class="modal-body">
													<div class="row" v-show="currentGallery.g_photos.length <= 0">
														<div class="col-xs-12">
															<p class="text-center">
																<i class="fa fa-spinner fa-pulse fa-3x fa-fw text-pink"></i><br><br>
																<?php _e( 'Loading photos', 'ampd_lang' ); ?>...
															</p>
														</div>
													</div>
													<div class="row" v-show="currentGallery.g_photos.length > 0">
														<div v-for="(photo, index) in currentGallery.g_photos" class="col-xs-12 col-sm-6 col-md-4 item-cards text-center" v-bind:class="{'item-exists': photo.p_exists}" v-bind:key="photo.id">
															<a target="_blank" v-bind:href="photo.p_url" class="gallery gallery-contain" v-img="photo">
																<img v-bind:src="photo.p_thumb_url" v-bind:alt="photo.p_title"  v-bind:style="{ 'width': '100%', 'height': '100%', 'object-fit': 'contain' }">
															</a>
															<template v-if="!photo.p_exists">
																<div class="gallery-size">{{photo.p_width}}x{{photo.p_height}}</div>
																<div v-if="photo.p_loaded == false || (photo.p_width > 0 && photo.p_height > 0)" class="input-group input-group-sm margin-bottom-15">
																	<span class="input-group-addon"><?php _e( 'Title', 'ampd_lang' ); ?></span>
																	<input v-bind:disabled="photo.p_downloading || (photo.p_width <= 0 && photo.p_height <= 0)" v-on:keyup.enter="downloadPhoto(photo)" type="text" class="form-control" placeholder="Title" v-model="photo.p_title">
																	<span class="input-group-btn">
																		<button v-bind:disabled="photo.p_downloading || (photo.p_width <= 0 && photo.p_height <= 0)" v-on:click="downloadPhoto(photo)" type="button" class="btn btn-default btn-success-text">
																			<span v-if="photo.p_downloading"><i class="fa fa-spinner fa-pulse fa-fw"></i></span>
																			<span v-else><?php _e( 'Download', 'ampd_lang' ); ?></span>
																		</button>
																	</span>
																</div>
															</template>
															<template v-else>
																<div class="gallery-size"><?php _e( 'Photo downloaded in media', 'ampd_lang' ); ?></div>
																<a v-bind:href="'post.php?post=' + photo.p_post_id +'&action=edit'" target="_blank" class="btn btn-default btn-sm margin-bottom-15"><?php _e( 'Edit', 'ampd_lang' ); ?></a>
															</template>
														</div>
													</div>
												</div>
											</transition>
											<div class="modal-footer">
												<div class="row">
													<div class="col-xs-3 col-md-3">
														<button v-on:click.prevent="prevGalleryModal()" type="button" class="btn btn-default btn-block"><i class="fa fa-arrow-left"></i></button>
													</div>
													<div class="col-xs-6 col-md-6">
														<template v-if="currentGallery.g_photos.length > 0">
															<button v-if="currentGalleryCptPhotos > 0" v-on:click="downloadAllPhoto()" v-show="currentGallery.g_photos.length > 0" type="button" class="btn btn-success btn-block" v-bind:disabled="loading.downloadingAllPhotos">
<span v-if="!loading.downloadingAllPhotos"><?php _e( 'Download all photos', 'ampd_lang' ); ?> ({{currentGalleryCptPhotos}})</span>
<span v-if="loading.downloadingAllPhotos"><i class="fa fa-spinner fa-pulse fa-fw"></i> <?php _e( 'Downloading', 'ampd_lang' ); ?>...</span>
</button>
															<button v-else class="btn btn-block btn-no-style"><?php _e( 'All photos are downloaded', 'ampd_lang' ); ?></button>
														</template>
													</div>
													<div class="col-xs-3 col-md-3">
														<button v-on:click.prevent="nextGalleryModal()" type="button" class="btn btn-default btn-block"><i class="fa fa-arrow-right"></i></button>
													</div>
												</div>
											</div>
										</div>
									</div>
								</div>
								<!--/ gallery modal-->
							</div>
						</transition>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<?php } ?>
