<?php
/*
 * HTML table Joomla! module
 *
 * @package		HTML table Joomla! module.
 * @version		1.0.0
 * @author		ARI Soft
 * @copyright	Copyright (c) 2010 www.ari-soft.com. All rights reserved
 * @license		GNU/GPL (http://www.gnu.org/copyleft/gpl.html)
 * 
 */

(defined('_JEXEC') && defined('ARI_FRAMEWORK_LOADED')) or die;

AriKernel::import('Parameters.ParametersHelper');
AriKernel::import('Application.ARISmartContent.Utils.ApplicationHelper');
AriKernel::import('Application.ARISmartContent.Providers.ProvidersHelper');

$constantId = (bool)$params->get('constantId');
$id = $constantId ? 'tbl_' . $module->id : uniqid('tbl_', false);

$flatParams = AriParametersHelper::flatParametersToArray($params);
$mainParams = AriUtils::getParam($flatParams, '_default');
$tableParams = AriUtils::getParam($flatParams, 'table');
$source = AriUtils::getParam($mainParams, 'source');
$sourceData = AriSmartContentProvidersHelper::resolveSource($source);
$columnsSettings = AriUtils::getParam($sourceData, 'settings');
$data = AriSmartContentProvidersHelper::getData($sourceData, null);

$htmlTable = new AriSmartContentWidgetHtmlTable($id, $tableParams, $columnsSettings);
$htmlTable->render($data, $sourceData['columns'], $sourceData['settings']);