helper.php 3.68 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;

class modMonthlyArchivesHelper
{
	function __construct($params)
	{
		// params
		$this->params = $params;
		$this->app = JFactory::getApplication();
		$this->document = JFactory::getDocument();
		$menu = $this->app->getMenu();
		$active = $menu->getActive();

		// Load model
		JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_monthlyarchive/models', 'MonthlyarchiveModel');
		$ma_model = JModelLegacy::getInstance( 'Archive', 'MonthlyarchiveModel' );
		$this->items = $ma_model->getItems($params, true);
		
		// config
		$config = JFactory::getConfig();
		$this->sef = $config->get('sef');

		// Params
		$this->ma_language 								= $this->params->get('ma_language', '*');
		$this->itemid 									= $this->params->get('itemid', '');
		$this->content_type 							= $this->params->get('content_type', 'default');

		// LAYOUT: LIST OF ALL MONTHS & YEARS
		$this->ma_layout 								= $this->params->get('ma_layout', 'default');
		$this->show_date_beside_articles_type 			= $this->params->get('show_date_beside_articles_type', 'created');
		$this->show_year 								= $this->params->get('show_year', '1');
		$this->sort_years_by 							= $this->params->get('sort_years_by', 'newest_first');
		$this->limit_of_years 							= $this->params->get('limit_of_years', '24');
		$this->show_month 								= $this->params->get('show_month', '1');
		$this->sort_months_by 							= $this->params->get('sort_months_by', 'desc');
		$this->limit_of_months 							= $this->params->get('limit_of_months', '12');
		$this->show_count_of_articles_beside_years 		= $this->params->get('show_count_of_articles_beside_years', '1');
		$this->show_count_of_articles_beside_months 	= $this->params->get('show_count_of_articles_beside_months', '1');

		// design
		$moduleclass_sfx 								= htmlspecialchars($this->params->get('moduleclass_sfx'));

		// Copyright message
		$this->copyright 								= $this->params->get('copyright', '1');

		// menu item
		$menu_item 										= $this->app->getMenu()->getItems( 'link', 'index.php?option=com_monthlyarchive&view=archive', true );
		if (!empty($this->itemid))
		{
			$this->menu_item_id = '&Itemid='.$this->itemid;
		}
		else if (!empty($menu_item))
		{
			$this->menu_item_id = '&Itemid='.$menu_item->id;
		}
		else
		{
			$this->menu_item_id = '';
		}

		// jQuery
		JHtml::_('jquery.framework', false);

		// load url
		jimport('joomla.environment.uri' );
		$host = JURI::root();

		// UIkit CSS framework
		$this->document->addStyleSheet($host.'components/com_monthlyarchive/assets/uikit/uikit.min.css');
		$this->document->addScript($host.'components/com_monthlyarchive/assets/uikit/uikit.min.js');
		$this->document->addScript($host.'components/com_monthlyarchive/assets/uikit/uikit-icons.min.js');

		// Custom css
		$this->document->addStyleSheet('modules/mod_monthlyarchive/assets/css/mod_monthlyarchive.css');

		// get month and year from URL
		$this->get_year = JFactory::getApplication()->input->get('year', '', 'STRING');
		$this->get_month = JFactory::getApplication()->input->get('month', '', 'INT');
		$this->get_month = (is_numeric($this->get_month)) ? sprintf("%02d", $this->get_month) : $this->get_month;
	}
}