<?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(); 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; ?>"> <a class="<?php echo ($ma->get_year == $year ? 'uk-text-bold uk-text-success' : ''); ?>" href="<?php echo ($ma->sef ? JRoute::_('index.php?option=com_monthlyarchive&year='.(int) $year.$ma->menu_item_id) : 'index.php?option=com_monthlyarchive&view=archive&year='.(int) $year.$ma->menu_item_id ); ?>"> <?php echo $year; ?> </a> </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('F'); $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); ?>"> <?php echo $month_name.' '.$year; ?> </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>