| Current Path : /home/juvelize/www/modules/mod_ic_event_list/ |
| Current File : /home/juvelize/www/modules/mod_ic_event_list/helper.php |
<?php
/**
*----------------------------------------------------------------------------
* iCagenda Events Management Extension for Joomla!
* PRO Module iC Event List
*----------------------------------------------------------------------------
* @version 3.2.2 2022-07-30
*
* @package iCagendaPro.Site
* @subpackage mod_ic_event_list
* @link https://www.icagenda.com
*
* @author Cyril Rezé
* @copyright (c) 2012-2024 Cyril Rezé / iCagenda. All rights reserved.
* @license GNU General Public License version 3 or later; see LICENSE.txt
*
* @since 1.0
*----------------------------------------------------------------------------
*/
defined('_JEXEC') or die;
use iCutilities\Thumb\Thumb as icagendaThumb;
use WebiC\Component\iCagenda\Site\Model\EventsModel;
use Joomla\CMS\Language\Multilanguage;
use Joomla\CMS\Log\Log as JLog;
use Joomla\CMS\HTML\HTMLHelper;
if (version_compare(JVERSION, '4.0', 'lt'))
{
JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_icagenda/models', 'iCagendaModel');
}
/**
* Helper for mod_ic_event_list
*
* @package iCagenda
* @subpackage mod_ic_event_list
*/
abstract class modiCEventListHelper
{
/**
* Retrieves the list of events
*
* @param array $params An object containing the module parameters
* @access public
*/
public static function getList(&$params)
{
$iCparams = JComponentHelper::getParams('com_icagenda');
// Get the dbo
$db = JFactory::getDbo();
// Get an instance of the generic events model
if (version_compare(JVERSION, '4.0', 'lt'))
{
$model = JModelLegacy::getInstance('Events', 'iCagendaModel', array('ignore_request' => true));
}
else
{
$model = new EventsModel;
}
// Set application parameters in model
$app = JFactory::getApplication();
$appParams = $app->getParams();
$model->setState('params', $appParams);
// Set the filters based on the module params
$model->setState('filter.state', 1);
// $model->setState('list.select', 'e.*');
// DateTime (Upcoming) filter
$filter_by_date = $params->get('filter_by_date');
if (isset($filter_by_date))
{
$upcoming = $params->get('filter_by_date', '1');
}
else
{
$upcoming = $params->get('time', '1'); // old setting (removed since 3.4.0-rc)
if ($upcoming == '4') $upcoming = '5'; // convert old 'All' setting
if ($upcoming == '3') $upcoming = '4'; // convert old 'today' setting
if ($upcoming == '2') $upcoming = '3'; // convert old 'future' setting
if ($upcoming == '0') $upcoming = '2'; // convert old 'past' setting
}
$model->setState('filter.upcoming', (int) $upcoming);
// Set state for module params (Filter by features...)
$model->setState('filter.mod_params', $params);
// Display all dates filter
$datesDisplay = $params->get('datesDisplay', $iCparams->get('datesDisplay', 1));
$model->setState('filter.all_dates', $datesDisplay);
// Category filter
$model->setState('filter.category_id', $params->get('mcatid', 'all'));
// Access filter
$model->setState('filter.access', 'e.access');
//$access = !JComponentHelper::getParams('com_icagenda')->get('show_noauth');
//$authorised = JAccess::getAuthorisedViewLevels(JFactory::getUser()->get('id'));
//$model->setState('filter.access', $access);
// Filter by language
if (version_compare(JVERSION, '4.0', 'lt'))
{
$model->setState('filter.language', JLanguageMultilang::isEnabled());
}
else
{
$model->setState('filter.language', Multilanguage::isEnabled());
}
// $model->setState('filter.language',$app->getLanguageFilter());
// Set number of events (processed in mod_ic_event_list.php)
// $model->setState('list.start', 0);
// $model->setState('list.limit', (int) $params->get('count', 5));
// Set ordering
$model->setState('list.ordering', 'e.next');
// Set direction
$orderby = $params->get('orderby', '2');
if ($orderby == '2')
{
$model->setState('list.direction', 'ASC');
}
else
{
$model->setState('list.direction', 'DESC');
}
// Retrieve Content
$items = $model->getItems();
return $items;
}
// Function to convert font color, depending on category color
/**
* Function to convert font color, depending on category color
*
* @deprecated 3.8
*/
public static function getfontColor($cat_color)
{
JLog::add('getfontColor is deprecated, use iCColor::getBrightness($color) instead.', JLog::WARNING, 'deprecated');
if (iCColor::getBrightness($cat_color) == 'bright')
{
$fcolor = '#111111';
}
else
{
$fcolor = 'white';
}
return $fcolor;
}
/**
* Get Thumbnail
*
* @since 3.0
*/
public static function getThumbnail($image, $thumb_generator)
{
// START iCthumb
if (version_compare(JVERSION, '4.0', 'ge'))
{
$img = HTMLHelper::cleanImageURL($image);
$image = $img->url;
}
// Set if run iCthumb
if ($image && ($thumb_generator == 1))
{
// Generate xsmall thumb if not exist
$thumb_img = icagendaThumb::sizeXSmall($image);
}
elseif ($image && ($thumb_generator == 0))
{
$thumb_img = icagendaThumb::sizeOriginal($image);
}
else
{
return false;
}
$baseURL = JURI::base();
$thumb_img = ltrim($thumb_img, '/');
return $baseURL . $thumb_img;
}
}