default.php 9.47 KB
<?php
/* ======================================================
# Monthly Archive - Joomla! Component v4.3.3 (PRO version)
# -------------------------------------------------------
# For Joomla! 3.x
# Author: Yiannis Christodoulou (yiannis@web357.eu)
# Copyright (©) 2009-2018 Web357. All rights reserved.
# License: GNU/GPLv3, http://www.gnu.org/licenses/gpl-3.0.html
# Website: https://www.web357.eu/
# Demo: http://demo.web357.eu/?item=monthlyarchive
# Support: support@web357.eu
# Last modified: 09 Feb 2018, 13:55:18
========================================================= */

defined('_JEXEC') or die; ?>

<div class="uk-scope">
	<div class="uk-margin-small-top uk-margin-small-bottom ma-mod-container <?php echo $moduleclass_sfx; ?>">

		<?php
		// =============================================
		// LIST OF MONTHS AND YEARS
		// =============================================
		?>

		<?php 
		$monthsyears_arr = array();
		$getfid = $_GET['filter_category'] ;
		$getpid = JRequest::getInt('id');
		$getcid = JRequest::getInt('catid');
		$pid == '';
		if($getpid == 122 || $getcid == 122 || $getfid == 122){
		$pid = 122;
		}
		if($getpid == 123 || $getcid == 123 || $getfid == 123){
		$pid = 123;
		}
		if($getpid == 124 || $getcid == 124 || $getfid == 124){
		$pid = 124;
		}
		if($getpid == 125 || $getcid == 125 || $getfid == 125){
		$pid = 125;
		}
		if($getpid == 126 || $getcid == 126 || $getfid == 126){
		$pid = 126;
		}
		if($getpid == 127 || $getcid == 127 || $getfid == 127){
		$pid = 127;
		}
		if($getpid == 128 || $getcid == 128 || $getfid == 128){
		$pid = 128;
		}
		if($getpid == 129 || $getcid == 129 || $getfid == 129){
		$pid = 129;
		}
		if($getpid == 130 || $getcid == 130 || $getfid == 130){
		$pid = 130;
		}
		if($getpid == 131 || $getcid == 131 || $getfid == 131){
		$pid = 131;
		}
		if($getpid == 132 || $getcid == 132 || $getfid == 132){
		$pid = 132;
		}
		if($getpid == 133 || $getcid == 133 || $getfid == 133){
		$pid = 133;
		}
		if($getpid == 134 || $getcid == 134 || $getfid == 134){
		$pid = 134;
		}
		if($getpid == 135 || $getcid == 135 || $getfid == 135){
		$pid = 135;
		}
		if($getpid == 136 || $getcid == 136 || $getfid == 136){
		$pid = 136;
		}
		if($getpid == 137 || $getcid == 137 || $getfid == 137){
		$pid = 137;
		}
		if($getpid == 138 || $getcid == 138 || $getfid == 138){
		$pid = 138;
		}
		if($getpid == 139 || $getcid == 139 || $getfid == 139){
		$pid = 139;
		}
		if($getpid == 93 || $getcid == 93 || $getfid == 93){
		$pid = 93;
		}
		if($getpid == 94 || $getcid == 94 || $getfid == 94){
		$pid = 94;
		}
		if($getpid == 95 || $getcid == 95 || $getfid == 95){
		$pid = 95;
		}
		if($getpid == 96 || $getcid == 96 || $getfid == 96){
		$pid = 96;
		}
		if($getpid == 141 || $getcid == 141 || $getfid == 141){
		$pid = 141;
		}
		if($getpid == 142 || $getcid == 142 || $getfid == 142){
		$pid = 142;
		}
		if($getpid == 143 || $getcid == 143 || $getfid == 143){
		$pid = 143;
		}
		//echo $getpid . '>' . $getfid . '>' . $pid;
		
		foreach ($ma->items as $i => $item)
		{
			if ($ma->show_date_beside_articles_type == 'publish_up')
			{
				$year = JHTML::_('date', strtotime($item->publish_up), "Y");
				$month = JHTML::_('date', strtotime($item->publish_up), "m");
			}
			else
			{
				$year = JHTML::_('date', strtotime($item->created), "Y");
				$month = JHTML::_('date', strtotime($item->created), "m");
			}
			$monthsyears_arr[$year][] 						= $month;
			$monthsyears_arr_count_years[$year][] 			= $item->id;
			$monthsyears_arr_count_months[$year][$month][] 	= $item->id;
		}
		
		if ($ma->ma_layout == 'accordion')
		{
			?><ul class="uk-margin-remove" uk-accordion="multiple: true"><?php 
		} 

		// Years ordering
		if ($ma->sort_years_by == 'newest_first')
		{
			krsort($monthsyears_arr); // high to low (most recent years first)
		}
		elseif ($ma->sort_years_by == 'oldest_first')
		{
			ksort($monthsyears_arr); // low to high (oldest years first)
		}

		$count_year = 1;
		$count_month = 1;
		foreach ($monthsyears_arr as $year=>$months)
		{

			if ($ma->show_year || $ma->ma_layout == 'accordion')
			{
				$limit_of_years = $ma->limit_of_years;
			}
			else
			{
				$limit_of_years = 24;
			}
			
				if ($count_year++ <= $limit_of_years):
				
					if ($ma->ma_layout == 'accordion')
					{ ?> 
					<li<?php echo ($ma->get_year == $year ? ' class="uk-open"' : ''); ?>><?php }

					if ($ma->show_year || $ma->ma_layout == 'accordion'): ?>

					<?php $count_articles_by_year = count($monthsyears_arr_count_years[$year]); ?>
					
					<?php if ($ma->ma_layout == 'accordion'): ?>

						<h3 class="uk-accordion-title ma-accordion-title">
							<?php echo $year; ?>
							<?php if($ma->show_count_of_articles_beside_years): ?>
								<div class="uk-display-inline-block uk-text-small ma-count">
									(<?php echo $count_articles_by_year; ?> <?php echo ($count_articles_by_year > 1 ? JText::_('COM_MONTHLYARCHIVE_ARTICLES') : JText::_('COM_MONTHLYARCHIVE_ARTICLE')); ?>)
								</div>
							<?php endif; ?>
						</h3>
					
					<?php elseif ($ma->ma_layout == 'default'): ?>

						<?php $margin_year = (($ma->show_year && !$ma->show_month) || $ma->ma_layout == 'accordion') ? 'uk-margin-small-bottom' : 'uk-margin-remove'; ?>

						<div class="uk-clearfix">
							<h3 class="uk-h4 uk-text-bold uk-display-inline-block ma-year-heading <?php echo $margin_year; ?>">
									<?php echo $year; ?>
							</h3>

							<?php if($ma->show_count_of_articles_beside_years): ?>
								<div class="uk-display-inline-block uk-text-small ma-count">
									(<?php echo $count_articles_by_year; ?> <?php echo ($count_articles_by_year > 1 ? JText::_('COM_MONTHLYARCHIVE_ARTICLES') : JText::_('COM_MONTHLYARCHIVE_ARTICLE')); ?>)
								</div>
							<?php endif; ?>
							
						</div>

					<?php endif; ?>
						
				<?php endif; ?>
				
				<?php if ($ma->show_month || $ma->ma_layout == 'accordion'): ?>

					<?php 
					if (($ma->show_year && $ma->show_month) || $ma->ma_layout == 'accordion')
					{
						$margin_class = ($ma->ma_layout == 'accordion') ? 'uk-margin-remove-left' : 'uk-margin-remove-left uk-margin-bottom uk-margin-small-top';
					}
					elseif (($ma->show_year && !$ma->show_month) || $ma->ma_layout == 'accordion')
					{
						$margin_class = 'uk-margin-remove';
					}
					elseif ((!$ma->show_year && $ma->show_month) || $ma->ma_layout == 'accordion')
					{
						$margin_class = 'uk-margin-small-bottom uk-margin-remove-left uk-margin-remove-top';
					}
					else
					{
						$margin_class = '';
					}
					?>

						<?php if ($ma->ma_layout == 'accordion'): ?>
							<div class="uk-accordion-content ma-accordion-content">
						<?php endif; ?>

						<ul class="uk-list ma-list <?php echo $margin_class; ?>">
							<?php 

							$months_arr_reverse = array_reverse(array_values(array_unique($months)));
							$months_arr = array_values(array_unique($months));

							// Months ordering
							if ($ma->sort_months_by == 'asc'):
								asort($months_arr); // low to high (order months desc)
							elseif ($ma->sort_months_by == 'desc'):
								arsort($months_arr); // high to low (order months asc)
							endif;
								
							// re-index array
							$months_arr = array_values($months_arr);

							for ($i=0;$i<count($months_arr);$i++): 

								if (!$ma->show_year && $ma->ma_layout == 'default' && $count_month > $ma->limit_of_months):
									break;
								endif; 

								$month = $months_arr[$i] < 10 ? '0'. (int) $months_arr[$i] : (int) $months_arr[$i];
								$dateObj   = DateTime::createFromFormat('!m', (int) $month);
								$month_name = $dateObj->format('m');
								//$month_name = JText::_($month_name."_FULL");
								$count_articles_by_month = count($monthsyears_arr_count_months[$year][$month]);
								?>
									<li>
										<a class="<?php echo ($ma->get_year == $year && $ma->get_month == $month ? 'uk-text-bold uk-text-success ma-month-title' : 'ma-month-title'); ?>" href="<?php echo ($ma->sef ? JRoute::_('index.php?option=com_monthlyarchive&year='.(int) $year.'&month='.$month.$ma->menu_item_id) : 'index.php?option=com_monthlyarchive&view=archive&year='.(int) $year.'&month='.$month.$ma->menu_item_id).'?filter_category='.$pid; ?>">
											<?php echo $year.'年 '.$month_name.'月'; ?>
										</a>
										<?php if($ma->show_count_of_articles_beside_months): ?>
											<span class="uk-text-small ma-count">(<?php echo $count_articles_by_month; ?> <?php echo ($count_articles_by_month > 1 ? JText::_('COM_MONTHLYARCHIVE_ARTICLES') : JText::_('COM_MONTHLYARCHIVE_ARTICLE')); ?>)</span>
										<?php endif; ?>
									</li>

							<?php
							$count_month++;
							endfor;
							?>
						</ul>

						<?php if ($ma->ma_layout == 'accordion'): ?>
							</div>
						<?php endif; ?>
				
				<?php endif; ?>

				<?php if ($ma->ma_layout == 'accordion'): ?>
					</li>
				<?php endif; ?>

			<?php endif; ?>

		<?php 
		} // endforeach
		?>

		<?php if ($ma->ma_layout == 'accordion'): ?>
			</ul>
		<?php endif; ?>

		<?php if (count($ma->items) == 0): ?>

			<div class="uk-margin-small-top ma-no-results">
				<?php 
				echo JText::_( 'MOD_MONTHLYARCHIVE_NO_ITEMS' );
				?>
			</div>

		<?php endif; ?>

		<?php
		// Copyright message
		if ($ma->copyright):
			echo '<div class="uk-margin-medium-top uk-text-center uk-text-muted uk-text-small ma-copyright">'.JText::_('COM_MONTHLYARCHIVE_POWERED_BY').' <a href="https://www.web357.eu/joomla-extensions/monthly-archive?utm_source=CLIENT&utm_medium=CLIENT-CopyrightLink-monthlyarchive&utm_content=CLIENT-CopyrightLink&utm_campaign=monthlyarchive" rel="nofollow" target="_blank">'.JText::_('MONTHLY_ARCHIVE').'</a></div>';
		endif;
		?>

	</div>
</div>