<?
set_time_limit(0);
global $MESS;
$strPath2Lang = str_replace("\\", "/", __FILE__);
$strPath2Lang = substr($strPath2Lang, 0, strlen($strPath2Lang)-18);
include(GetLangFileName($strPath2Lang."/lang/", "/install/index.php")); 

Class franchise extends CModule
{
	var $MODULE_ID = "franchise";
	var $MODULE_VERSION;
	var $MODULE_VERSION_DATE;
	var $MODULE_NAME;
	var $MODULE_DESCRIPTION;
	var $MODULE_CSS;

	function franchise()
	{
		$arModuleVersion = array();

		$path = str_replace("\\", "/", __FILE__);
		$path = substr($path, 0, strlen($path) - strlen("/index.php"));
		include($path."/version.php");

		$this->MODULE_VERSION = $arModuleVersion["VERSION"];
		$this->MODULE_VERSION_DATE = $arModuleVersion["VERSION_DATE"];
		$this->MODULE_NAME = GetMessage("FRANCHISE_MODULE_NAME");
		$this->MODULE_DESCRIPTION = GetMessage("FRANCHISE_MODULE_DESC");
	}

	function InstallDB($arParams = array())
	{
		RegisterModule("franchise");
		RegisterModuleDependences('main', 'OnBeforeProlog', 'franchise', 'FranchiseEvents', 'OnCreatePanel');
		RegisterModuleDependences('main', 'OnPageStart', 'franchise', 'FranchiseEvents', 'DetectMobile');
		return true;
	}

	function UnInstallDB($arParams = array())
	{
		UnRegisterModuleDependences('main', 'OnBeforeProlog', 'franchise', 'FranchiseEvents', 'OnCreatePanel');
		UnRegisterModuleDependences('main', 'OnPageStart', 'franchise', 'FranchiseEvents', 'DetectMobile');
		UnRegisterModule("franchise");
		return true;
	}

	function InstallEvents()
	{
		return true;
	}

	function UnInstallEvents()
	{
		return true;
	}

	function InstallFiles($arParams = array())
	{
		CopyDirFiles($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/franchise/install/components/franchise", $_SERVER["DOCUMENT_ROOT"]."/bitrix/components/franchise", true, true);
		CopyDirFiles($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/franchise/install/gadgets", $_SERVER["DOCUMENT_ROOT"]."/bitrix/gadgets", true, true);
		return true;
	}

	function UnInstallFiles()
	{
		DeleteDirFilesEx("/images/coats");
		return true;
	}

	function DoInstall()
	{
		global $DOCUMENT_ROOT, $APPLICATION;
		$this->InstallDB();
		$this->InstallFiles();
		$APPLICATION->IncludeAdminFile(GetMessage("FRANCHISE_INSTALL_TITLE"), $DOCUMENT_ROOT."/bitrix/modules/franchise/install/step.php");
	}

	function DoUninstall()
	{
		global $DOCUMENT_ROOT, $APPLICATION;
		$this->UnInstallDB();
		$this->UnInstallFiles();
		$APPLICATION->IncludeAdminFile(GetMessage("FRANCHISE_UNINSTALL_TITLE"), $DOCUMENT_ROOT."/bitrix/modules/franchise/install/unstep.php");
	}
}
?>