archive.php
3.57 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
<?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;
class MonthlyArchiveControllerArchive extends JControllerLegacy
{
public function &getModel($name = 'Archive', $prefix = 'StartupModel', $config = array())
{
$model = parent::getModel($name, $prefix, array('ignore_request' => true));
return $model;
}
public function goToURL()
{
// config
$config = JFactory::getConfig();
$sef = $config->get('sef');
// Get menu item
$menu_item = JFactory::getApplication()->getMenu()->getItems( 'link', 'index.php?option=com_monthlyarchive', true );
$default_menu_item_id = (!empty($menu_item)) ? $menu_item->id : '';
// Get the variables from URL
$get_orderby = JFactory::getApplication()->input->get('orderby', '', 'STRING');
$get_category = JFactory::getApplication()->input->get('category', '', 'INT');
$get_author = JFactory::getApplication()->input->get('author', '', 'INT');
$get_year = JFactory::getApplication()->input->get('year', '', 'STRING');
$get_month = JFactory::getApplication()->input->get('month', '', 'INT');
$get_month = (is_numeric($get_month) && $get_month > 0) ? sprintf("%02d", $get_month) : $get_month;
$get_menu_item_id = JFactory::getApplication()->input->get('Itemid', $default_menu_item_id, 'INT');
// build menu item id with property
$menu_item_id = '&Itemid='.$get_menu_item_id;
$app = JFactory::getApplication();
$input = $app->input;
$app->setUserState('com_monthlyarchive.archive.limitstart', 0);
$input->set('limitstart', 0);
$app->setUserState('com_monthlyarchive.archive.filter.orderby', $get_orderby);
$input->set('filter.orderby', $get_orderby);
$app->setUserState('com_monthlyarchive.archive.filter.category', $get_category);
$input->set('filter.category', $get_category);
$app->setUserState('com_monthlyarchive.archive.filter.author', $get_author);
$input->set('filter.author', $get_author);
if ($get_year == 'all')
{
$redirect_link = ($sef) ? JRoute::_('index.php?option=com_monthlyarchive&year=all'.$menu_item_id) : 'index.php?option=com_monthlyarchive&view=archive&year=all'.$menu_item_id;
$this->setRedirect($redirect_link);
}
elseif (!empty($get_month))
{
$input->set('filter.date', $get_year.'-'.$get_month);
$redirect_link = ($sef) ? JRoute::_('index.php?option=com_monthlyarchive&year='.(int) $get_year.'&month='.$get_month.''.$menu_item_id) : 'index.php?option=com_monthlyarchive&view=archive&year='.(int) $get_year.'&month='.$get_month.''.$menu_item_id;
$this->setRedirect($redirect_link);
}
elseif (!empty($get_year))
{
$input->set('filter.date', $get_year);
$redirect_link = ($sef) ? JRoute::_('index.php?option=com_monthlyarchive&year='.(int) $get_year.''.$menu_item_id) : 'index.php?option=com_monthlyarchive&view=archive&year='.(int) $get_year.''.$menu_item_id;
$this->setRedirect($redirect_link);
}
else
{
$redirect_link = ($sef) ? JRoute::_('index.php?option=com_monthlyarchive'.$menu_item_id) : 'index.php?option=com_monthlyarchive&view=archive'.$menu_item_id;
$this->setRedirect($redirect_link);
}
}
}