<?php
/*
 * @component Calc Builder 
 * @copyright Copyright (C) January 2017. 
 * @license GPL 3.0 
 * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
 * See the GNU General Public License for more details. 
 * See <http://www.gnu.org/licenses/>. 
 * More info www.moonsoft.es 
 * gestion@moonsoft.es
 */

// No direct access
defined ( '_JEXEC' ) or die ( 'Restricted access' );

jimport ( 'joomla.application.component.view' );

require_once (JPATH_COMPONENT_ADMINISTRATOR . DS . 'helper.php');

require 'main.view.php';
class wrapperMainView extends CalcbuilderMainView {
	private static $COMPNAME = 'com_calcbuilder';
	function display($tpl = null) {
		/*
		 * $format=MSHelper::__requestGetVarWrapper('format','html'); if ($format=='html'){ $document =JFactory::getDocument(); $css=$this->__getCSS(); foreach ($css as $style){ $document->addStyleSheet($style); } $js=$this->__getJS(); foreach ($js as $jscript){ echo '<script src="'.$jscript.'"></script>'; } }
		 */
		parent::display ( $tpl );
	}
	
	/**
	 * Get the actions
	 */
	public static function getActions() {
		jimport ( 'joomla.access.access' );
		$user = JFactory::getUser ();
		$result = new JObject ();
		$assetName = 'com_calcbuilder';
		$actions = JAccess::getActions ( 'com_calcbuilder', 'component' );
		foreach ( $actions as $action ) {
			$result->set ( $action->name, $user->authorise ( $action->name, $assetName ) );
		}
		return $result;
	}
	function __getCSS() {
		$version = new JVersion ();
		$ret = array ();
		if (version_compare ( $version->getShortVersion (), '3.0.0' ) < 0) {
			$ret [] = JURI::base () . 'components/com_calcbuilder/assets/css/bootstrap-responsive.min.css';
			$ret [] = JURI::base () . 'components/com_calcbuilder/assets/css/bootstrap.css';
		}
		$ret [] = JURI::base () . 'components/com_calcbuilder/assets/css/default2.css';
		$ret [] = JURI::base () . 'components/com_calcbuilder/assets/css/ms-theme/jquery-ui-1.9.2.custom.css';
		return $ret;
	}
	function __getJS() {
		$version = new JVersion ();
		$ret = array ();
		if (version_compare ( $version->getShortVersion (), '3.0.0' ) < 0) {
			//$ret [] = 'http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js';
			//$ret [] = 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js';
			$ret [] = JURI::base () . 'components/com_calcbuilder/assets/js/jquery-1.8.3.min.js';
			$ret [] = JURI::base () . 'components/com_calcbuilder/assets/js/jquery-ui-1.9.2.custom.min.js';
			$ret [] = JURI::base () . 'components/com_calcbuilder/assets/js/jquery.noConflict.js';
			$ret [] = JURI::base () . 'components/com_calcbuilder/assets/js/bootstrap.min.js';
		} else {
			$ret [] = JURI::base () . 'components/com_calcbuilder/assets/js/jquery-ui-1.9.2.custom.min.js';
		}
		return $ret;
	}
	function __getVersion() {
		$version = new JVersion ();
		$arr_version = explode ( '.', $version->getShortVersion () );
		return $arr_version [0];
	}
}
?>