<?php

/**
 * @package		CHClient
 * @copyright	Copyright (C) CloudHotelier. All rights reserved.
 * @license		GNU GPLv2 <http://www.gnu.org/licenses/gpl.html>
 * @author		Xavier Pallicer <*****@*****.**>
 */
defined('_JEXEC') or die;
// load language files
JFactory::getLanguage()->load('com_chclient');
// load required libraries
JLoader::import('chlib', JPATH_LIBRARIES . '/chlib');
JLoader::import('chinventory', JPATH_LIBRARIES . '/chinventory');
JLoader::import('chassets', JPATH_LIBRARIES . '/chassets');
JLoader::import('chuikit', JPATH_LIBRARIES . '/chuikit');
// check libraries
foreach (['CHLib', 'CHInventory', 'CHAssets', 'CHUikit'] as $lib) {
    if (!class_exists($lib)) {
        throw new Exception('CloudHotelier libraries not found', 500);
    }
}
// load helpers
JLoader::import('chclient', JPATH_COMPONENT . '/helpers');
// determine engine view
CHClient::checkView();
// load and execute the controller
$controller = JControllerLegacy::getInstance('CHClient');
$controller->execute(CHLib::input()->get('task'));
$controller->redirect();