default.php20180321
7.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<?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>