<?php
/**
 * @version    2.7.x
 * @package    K2
 * @author     JoomlaWorks http://www.joomlaworks.net
 * @copyright  Copyright (c) 2006 - 2016 JoomlaWorks Ltd. All rights reserved.
 * @license    GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
 */

// no direct access
defined('_JEXEC') or die;

// Get user stuff (do not change)
$user = JFactory::getUser();

/**
 * @version				1.0.3
 * @package				ui-TopStyle
 * @author / modify		Stephan W. http://www.3d-hobby-art.de/
 * @license				GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
 */

// include config and layout
$base = dirname(dirname(dirname(__FILE__)));
include($base.'/config.php');
?>

<!-- Start K2 User Layout -->
<div id="k2Container" class="uk-panel tm-userView<?php if($this->params->get('pageclass_sfx')) echo ' '.$this->params->get('pageclass_sfx'); ?>">

	<?php if ($this->params->get('userImage') || $this->params->get('userName') || $this->params->get('userDescription') || $this->params->get('userURL') || $this->params->get('userEmail')): ?>
	<div class="uk-grid">
		<div class="uk-width-1-1">
			<div class="uk-panel uk-panel-box">
				<div class="uk-grid uk-flex-top" data-uk-grid-margin>
					<?php if ($this->params->get('userImage') && !empty($this->user->avatar)): ?>
						<div class="uk-width-medium-2-10">
							<div class="uk-panel">
								<img class="uk-thumbnail" src="<?php echo $this->user->avatar; ?>" alt="<?php echo $this->user->name; ?>" style="width:<?php echo $this->params->get('userImageWidth'); ?>px; height:auto;" />
								<?php if(isset($this->addLink) && JRequest::getInt('id')==$user->id): ?>
									<!-- Item add link -->
									<span class="userItemAddLink">
										<a data-k2-modal="edit" href="<?php echo $this->addLink; ?>">
											<?php echo JText::_('K2_POST_A_NEW_ITEM'); ?>
										</a>
									</span>
								<?php endif; ?>
							</div>
						</div>
					<?php endif; ?>
					<div class="uk-width-medium-8-10 uk-flex-top">

						<?php if($this->params->get('userFeedIcon',1)): ?>
						<!-- RSS feed icon -->
						<div class="uk-text-right uk-align-right">
							<a class="uk-icon-rss" href="<?php echo $this->feed; ?>" title="<?php echo JText::_('K2_SUBSCRIBE_TO_THIS_RSS_FEED'); ?>" data-uk-tooltip></a>
						</div>
						<?php endif; ?>

						<?php if ($this->params->get('userName')): ?>
						<h2><?php echo $this->user->name; ?></h2>
						<?php endif; ?>

						<?php if ($this->params->get('userDescription',1) && trim($this->user->profile->description)): ?>
						<div class="userDescription"><?php echo $this->user->profile->description; ?></div>
						<?php endif; ?>

						<?php if (($this->params->get('userURL') && isset($this->user->profile->url) && $this->user->profile->url) || $this->params->get('userEmail')): ?>
						<div class="userAdditionalInfo">
							<?php if ($this->params->get('userURL') && isset($this->user->profile->url) && $this->user->profile->url): ?>
							<span class="userURL">
								<i class="uk-icon-link"></i> <a href="<?php echo $this->user->profile->url; ?>" target="_blank" rel="me"><?php echo $this->user->profile->url; ?></a>
							</span>
							<?php endif; ?>

							<?php if ($this->params->get('userEmail')): ?>
							<?php if ($this->params->get('userURL') && isset($this->user->profile->url) && $this->user->profile->url) echo '|'; ?>
							<span class="userEmail">
								<i class="uk-icon-envelope"></i> <?php echo JHTML::_('Email.cloak', $this->user->email); ?>
							</span>
							<?php endif; ?>
						</div>
						<?php endif; ?>

						<?php echo $this->user->event->K2UserDisplay; ?>

					</div>
				</div>
			</div>
		</div>
	</div>
	<?php endif; ?>


	<?php if(count($this->items)): ?>
	<!-- Item list -->
	<ul class="uk-grid uk-grid-small uk-grid-width-1-1 uk-grid-width-medium-1-2 uk-grid-width-large-1-3" data-uk-grid-margin>
		<?php foreach ($this->items as $item): ?>
			<li>
				<div class="uk-panel-box uk-panel-box-secondary userItemView<?php if(!$item->published || ($item->publish_up != $this->nullDate && $item->publish_up > $this->now) || ($item->publish_down != $this->nullDate && $item->publish_down < $this->now)) echo ' userItemViewUnpublished'; ?><?php echo ($item->featured) ? ' userItemIsFeatured' : ''; ?>">
					
					<?php if($this->params->get('userItemImage') && !empty($item->imageGeneric)): ?>
					<!-- Item Image -->
					<div class="uk-panel-teaser">
						<a href="<?php echo $item->link; ?>" title="<?php if(!empty($item->image_caption)) echo K2HelperUtilities::cleanHtml($item->image_caption); else echo K2HelperUtilities::cleanHtml($item->title); ?>">
							<img src="<?php echo $item->imageGeneric; ?>" alt="<?php if(!empty($item->image_caption)) echo K2HelperUtilities::cleanHtml($item->image_caption); else echo K2HelperUtilities::cleanHtml($item->title); ?>" style="width:<?php echo $this->params->get('itemImageGeneric'); ?>px; height:auto;" />
						</a>
					</div>
					<?php endif; ?>
					
					<!-- Plugins: BeforeDisplay -->
					<?php echo $item->event->BeforeDisplay; ?>

					<!-- K2 Plugins: K2BeforeDisplay -->
					<?php echo $item->event->K2BeforeDisplay; ?>

					<div class="userItemHeader">
						<?php if($this->params->get('userItemDateCreated')): ?>
						<!-- Date created -->
						<span class="uk-article-meta">
							<?php echo JHTML::_('date', $item->created , JText::_('K2_DATE_FORMAT_LC2')); ?>
						</span>
						<?php endif; ?>

						<?php if($this->params->get('userItemTitle')): ?>
							<!-- Item title -->
							<h3 class="userItemTitle">
								<?php if(isset($item->editLink)): ?>
								<!-- Item edit link -->
								<span class="userItemEditLink">
									<a data-k2-modal="edit" href="<?php echo $item->editLink; ?>">
										<?php echo JText::_('K2_EDIT_ITEM'); ?>
									</a>
								</span>
								<?php endif; ?>

							<?php if ($this->params->get('userItemTitleLinked') && $item->published): ?>
								<a href="<?php echo $item->link; ?>">
								<?php echo $item->title; ?>
							</a>
							<?php else: ?>
							<?php echo $item->title; ?>
							<?php endif; ?>
							</h3>
							<?php if(!$item->published || ($item->publish_up != $this->nullDate && $item->publish_up > $this->now) || ($item->publish_down != $this->nullDate && $item->publish_down < $this->now)): ?>
							<div class="uk-panel-badge uk-badge">
									<?php echo JText::_('K2_UNPUBLISHED'); ?>
							</div>
							<?php endif; ?>
						<?php endif; ?>
					</div>

					<!-- Plugins: AfterDisplayTitle -->
					<?php echo $item->event->AfterDisplayTitle; ?>

					<!-- K2 Plugins: K2AfterDisplayTitle -->
					<?php echo $item->event->K2AfterDisplayTitle; ?>

					<div class="userItemBody">
						<!-- Plugins: BeforeDisplayContent -->
						<?php echo $item->event->BeforeDisplayContent; ?>

						<!-- K2 Plugins: K2BeforeDisplayContent -->
						<?php echo $item->event->K2BeforeDisplayContent; ?>

						<?php if($this->params->get('userItemIntroText')): ?>
							<!-- Item introtext -->
							<div class="userItemIntroText">
								<?php echo $item->introtext; ?>
							</div>
						<?php endif; ?>

						<div class="uk-clearfix"></div>

						<!-- Plugins: AfterDisplayContent -->
						<?php echo $item->event->AfterDisplayContent; ?>

						<!-- K2 Plugins: K2AfterDisplayContent -->
						<?php echo $item->event->K2AfterDisplayContent; ?>

						<div class="uk-clearfix"></div>
					</div>

					<?php if($this->params->get('userItemCategory') || $this->params->get('userItemTags')): ?>
						<div class="userItemLinks">
							<?php if($this->params->get('userItemCategory')): ?>
								<!-- Item category name -->
								<p class="uk-article-meta">
									<span><?php echo JText::_('K2_PUBLISHED_IN'); ?></span>
									<a href="<?php echo $item->category->link; ?>"><?php echo $item->category->name; ?></a>
								</p>
							<?php endif; ?>
						</div>
					<?php endif; ?>

					<div class="uk-clearfix"></div>

					<?php if($this->params->get('userItemCommentsAnchor') && ( ($this->params->get('comments') == '2' && !$this->user->guest) || ($this->params->get('comments') == '1')) ): ?>
						<!-- Anchor link to comments below -->
						<div class="userItemCommentsLink">
							<?php if(!empty($item->event->K2CommentsCounter)): ?>
								<!-- K2 Plugins: K2CommentsCounter -->
								<?php echo $item->event->K2CommentsCounter; ?>
							<?php else: ?>
								<?php if($item->numOfComments > 0): ?>
									<a href="<?php echo $item->link; ?>#itemCommentsAnchor">
										<?php echo $item->numOfComments; ?> <?php echo ($item->numOfComments>1) ? JText::_('K2_COMMENTS') : JText::_('K2_COMMENT'); ?>
									</a>
									<?php else: ?>
									<a href="<?php echo $item->link; ?>#itemCommentsAnchor">
										<?php echo JText::_('K2_BE_THE_FIRST_TO_COMMENT'); ?>
									</a>
								<?php endif; ?>
							<?php endif; ?>
						</div>
					<?php endif; ?>

					<?php if ($this->params->get('userItemReadMore')): ?>
						<!-- Item "read more..." link -->
						<div class="uk-margin uk-margin-top uk-text-center">
							<a class="uk-button" href="<?php echo $item->link; ?>">
								<?php echo JText::_('K2_READ_MORE'); ?>
							</a>
						</div>
					<?php endif; ?>

					<!-- Plugins: AfterDisplay -->
					<?php echo $item->event->AfterDisplay; ?>

					<!-- K2 Plugins: K2AfterDisplay -->
					<?php echo $item->event->K2AfterDisplay; ?>
				</div>
			</li>
			<!-- End K2 Item Layout -->
		<?php endforeach; ?>
	</ul>

	<!-- Pagination -->
	<?php if(count($this->pagination->getPagesLinks())): ?>
		<div class="k2Pagination">
			<?php echo $this->pagination->getPagesLinks(); ?>
			<div class="uk-clearfix"></div>
			<?php echo $this->pagination->getPagesCounter(); ?>
		</div>
	<?php endif; ?>

	<?php endif; ?>

</div>
<!-- End K2 User Layout -->