<?php
/**
 * @package     Joomla.Site
 * @subpackage  com_content
 *
 * @copyright   Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');

// Create some shortcuts.
$params    = &$this->item->params;
$n         = count($this->items);
$listOrder = $this->escape($this->state->get('list.ordering'));
$listDirn  = $this->escape($this->state->get('list.direction'));

// Check for at least one editable article
$isEditable = false;

if (!empty($this->items))
{
	foreach ($this->items as $article)
	{
		if ($article->params->get('access-edit'))
		{
			$isEditable = true;
			break;
		}
	}
}

// For B/C we also add the css classes inline. This will be removed in 4.0.
JFactory::getDocument()->addStyleDeclaration('
	.hide { display: none; }
	.table-noheader { border-collapse: collapse; }
	.table-noheader thead { display: none; }
	');

$tableClass = $this->params->get('show_headings') != 1 ? ' table-noheader' : '';
?>
<form action="<?php echo htmlspecialchars(JUri::getInstance()->toString()); ?>" method="post" name="adminForm" id="adminForm" class="form-inline">
	<?php if ($this->params->get('filter_field') !== 'hide' || $this->params->get('show_pagination_limit')) : ?>
		<fieldset class="filters btn-toolbar clearfix">
			<legend class="hide"><?php echo JText::_('COM_CONTENT_FORM_FILTER_LEGEND'); ?></legend>
			<?php if ($this->params->get('filter_field') !== 'hide') : ?>
				<div class="btn-group">
					<?php if ($this->params->get('filter_field') !== 'tag') : ?>
						<label class="filter-search-lbl element-invisible" for="filter-search">
							<?php echo JText::_('COM_CONTENT_' . $this->params->get('filter_field') . '_FILTER_LABEL') . '&#160;'; ?>
						</label>
						<input type="text" name="filter-search" id="filter-search" value="<?php echo $this->escape($this->state->get('list.filter')); ?>" class="inputbox" onchange="document.adminForm.submit();" title="<?php echo JText::_('COM_CONTENT_FILTER_SEARCH_DESC'); ?>" placeholder="<?php echo JText::_('COM_CONTENT_' . $this->params->get('filter_field') . '_FILTER_LABEL'); ?>" />
					<?php else : ?>
						<select name="filter_tag" id="filter_tag" onchange="document.adminForm.submit();" >
							<option value=""><?php echo JText::_('JOPTION_SELECT_TAG'); ?></option>
							<?php echo JHtml::_('select.options', JHtml::_('tag.options', true, true), 'value', 'text', $this->state->get('filter.tag')); ?>
						</select>
					<?php endif; ?>
				</div>
			<?php endif; ?>
			<?php if ($this->params->get('show_pagination_limit')) : ?>
				<div class="btn-group pull-right">
					<label for="limit" class="element-invisible">
						<?php echo JText::_('JGLOBAL_DISPLAY_NUM'); ?>
					</label>
					<?php echo $this->pagination->getLimitBox(); ?>
				</div>
			<?php endif; ?>

			<input type="hidden" name="filter_order" value="" />
			<input type="hidden" name="filter_order_Dir" value="" />
			<input type="hidden" name="limitstart" value="" />
			<input type="hidden" name="task" value="" />
		</fieldset>

		<div class="control-group hide pull-right">
			<div class="controls">
				<button type="submit" name="filter_submit" class="btn btn-primary"><?php echo JText::_('COM_CONTENT_FORM_FILTER_SUBMIT'); ?></button>
			</div>
		</div>
	<?php endif; ?>
	<?php if (empty($this->items)) : ?>
		<?php if ($this->params->get('show_no_articles', 1)) : ?>
			<p><?php echo JText::_('COM_CONTENT_NO_ARTICLES'); ?></p>
		<?php endif; ?>
	<?php else : ?>
		<div class="uec-news">
			<?php foreach($this->items as $i => $article): ?>
				<div class="row wow animated fadeInUp">
					<?php if($this->params->get('list_show_date')): ?>
						<div class="col-md-1">
							<div class="news-date">
								<?php 
								echo JHtml::_('date', $article->displayDate,$this->escape($this->params->get('date_format', JText::_('DATE_FORMAT_LC3')))); 
								?>
							</div>
						</div>
					<?php endif; ?>
					<div class="col-md-9 news-title">
						<div>
							<?php echo $this->escape($article->title); ?>
							<span>
								<?php $atircle_images = $article->images;  ?>
								<?php $pictures = json_decode($atircle_images); ?>
								<?php echo JText::sprintf($pictures->{'image_intro_caption'}); ?>
							</span>
						</div>
						<p>
							<?php echo JText::sprintf($pictures->{'image_fulltext_caption'}) ?>
						</p>
					</div>
					<div class="col-md-2">
						<div class="ban_download news-btn">
							<p>
								<a class="btn btn-primary btn-wide btn-icon" href="<?php echo JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catid, $article->language)); ?>">
									<?php echo JText::_("詳細內容") ?>
								</a>
							</p>
						</div>
					</div>
				</div>
			<?php endforeach; ?>
		</div>
	<?php endif; ?>
	<?php // Code to add a link to submit an article. ?>
	<?php if ($this->category->getParams()->get('access-create')) : ?>
		<?php echo JHtml::_('icon.create', $this->category, $this->category->params); ?>
	<?php endif; ?>

	<?php // Add pagination links ?>
	<?php if (!empty($this->items)) : ?>
		<?php if (($this->params->def('show_pagination', 2) == 1  || ($this->params->get('show_pagination') == 2)) && ($this->pagination->pagesTotal > 1)) : ?>
			<div class="pagination_uec">
				<?php echo $this->pagination->getPagesLinks(); ?>
			</div>
		<?php endif; ?>
	<?php endif; ?>
</form>
