IHMConfigClass.php 5.33 KB
<?php

/**
 * @class IHMConfigClass
 * @brief Class that's contain all specific configuration of the IHM client
 * @details
 */
class IHMConfigClass
{
	private static $genericDataDir = "generic_data/";

	private static $functionsDir   = "Functions/";
	
	private static $constantsFile  = "constants.xml";

	private static $functionsFile  = "functions.xml";
	
	private static $paramTemplateDir = "ParamTemplate/";

	private static $paramTemplateFile = "ParamTemplateList.xml";
	
	private static $paramTemplateGenerateDir = "generateTemplateParams";
	
	private static $dataDir        = "data/";

	private static $compilationDir = "compilation/";

	private static $requestDir     = "RES/";

	private static $sharedDir      = "shared_data/";
	
	private static $sharedTreeFile = "SharedObjectTree.xml";

	private static $ttDir          = "TT/";

	private static $wsDir          = "WS/";
	
	private static $downloadTmp    = "DOWNLOAD.TEMP/";

	private static $jobsDir        = "JOBS/";
	
	private static $localBaseDir   = "DATA/";

	private static $aliasesFile    = "Alias.xml";

	private static $processMgrFile = "processManager.xml";

	private static $jobsMgrFile = "jobs.xml";
	
	private static $userParamMgrFile = "WsParams.xml";

	private static $userName;
	
	private static $userHost;
	
	public static $remoteDataDir = "RemoteData/";
				
	public static function setUserName($userName)
	{
		self::$userName = $userName;
	}

	public static function getUserName()
	{
		return self::$userName;
	}
	
	public static function setUserHost($userHost)
	{
		self::$userHost = $userHost;
	}

	public static function getUserHost()
	{
		return self::$userHost;
	}
	
	public static function getRelativeResultPath()
	{
		$userPath = self::$dataDir.self::$userName.'/'.self::$requestDir;
 
		return $userPath;
	}
	
	public static function getUserPath()
	{
		$userPath = IHM_SRC_DIR.self::$dataDir.self::$userName.'/';

		if (!is_dir($userPath))
			mkdir($userPath);
			
		return $userPath;
	}

	public static function getProcessManagerFilePath()
	{
		return IHM_SRC_DIR.self::$dataDir.self::$processMgrFile;
	}

	public static function getConstantsFilePath()
	{
		return IHM_SRC_DIR.self::$genericDataDir.self::$functionsDir.self::$constantsFile;
	}

	public static function getFunctionsFilePath()
	{
		return IHM_SRC_DIR.self::$genericDataDir.self::$functionsDir.self::$functionsFile;
	}
	
	public static function getParamTemplateFilePath($fileName)
	{
		return IHM_SRC_DIR.self::$genericDataDir.self::$paramTemplateDir.$fileName.".xml";
	}
	
	public static function getTemplateParamGeneratePath()
	{
		return self::getUserPath().self::$paramTemplateGenerateDir;
	}
	
	public static function getDownloadTmpPath()
	{
		return self::getUserPath().self::$downloadTmp;
	}
	
	public static function getParamTemplateListFilePath()
	{
		return IHM_SRC_DIR.self::$genericDataDir.self::$paramTemplateDir.self::$paramTemplateFile;
	}
	
	public static function getUserParamManagerFilePath()
	{
		return self::getUserWSPath().self::$userParamMgrFile;
	}
	
	public static function getUserDerivedParamFilePath($paramId)
	{
		return self::getUserWSPath().$paramId.".xml";
	}
	
	public static function getUserUploadedParamFilePath($paramId)
	{
		return self::getUserWSPath().$paramId.".xml";
	}

	public static function getLocalParamDBPath()
	{
		return PARAMS_LOCALDB_DIR;
	}
	
	public static function getLocalParamInfoPath()
	{
		return PARAMS_LOCALINFO_DIR;
	}

	public static function getSharedPath()
	{
		return IHM_SRC_DIR.self::$sharedDir;
	}
	
	public static function getSharedTreeFilePath()
	{
		return self::getSharedPath().self::$sharedTreeFile;
	}

	public static function getUserTTPath()
	{
		return self::getUserPath().self::$ttDir;
	}

	public static function getUserWSPath()
	{
		return self::getUserPath().self::$wsDir;
	}

	public static function getUserJobsPath()
	{
		$jobsPath = self::getUserPath().self::$jobsDir;

		if (!is_dir($jobsPath))
			mkdir($jobsPath,0755);

		return $jobsPath;
	}

	public static function getUserJobsFile()
	{
		return self::getUserJobsPath().self::$jobsMgrFile;
	}


	public static function getUserAliasesFilePath()
	{
		return self::getUserWSPath().self::$aliasesFile;
	}

	public static function getCompilationPath()
	{
		$compilationPath = self::getUserPath().self::$compilationDir;

		if (!is_dir($compilationPath))
		{
			if (mkdir($compilationPath))
			{
				mkdir($compilationPath."src/");
				mkdir($compilationPath."lib/");
			}
		}
			
		return $compilationPath;
	}

	public static function getLocalBasePath()
	{
		$localBasePath = self::getUserPath().self::$localBaseDir;
		
		if (!is_dir($localBasePath))
			mkdir($localBasePath);
			
		return $localBasePath;
	}
	
	public static function getRemoteParamsFile()
	{
		$remoteBasePath = self::getUserPath().self::$wsDir;
				 			
		return $remoteBasePath.'RemoteParams.xml';
	}
			
	public static function getRequestPath()
	{
		$requestPath = self::getUserPath().self::$requestDir;

		if (!is_dir($requestPath))
			mkdir($requestPath);
			
		return $requestPath;
	}
	
	public static function getRemoteDataPath()
	{
		$remoteDataPath = IHM_SRC_DIR.self::$genericDataDir.self::$remoteDataDir;
		
		return $remoteDataPath;
	}
	
}

?>