| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- <?php
- namespace ModulesGarden\Servers\ProxmoxCloudVps\Core;
- class ModuleConstants
- {
- protected static $mgDevConfig = null;
- protected static $mgHelperLangs = null;
- protected static $mgCoreConfig = null;
- protected static $mgModuleRootDir = null;
- protected static $mgTemplateDir = null;
- protected static $mgIsPhp7 = false;
- protected static $mgModuleNamespace = "ModulesGarden\Servers\ProxmoxCloudVps";
- protected static $prefixDataBase = "";
- public static function initialize()
- {
- self::$mgModuleRootDir = dirname(__DIR__);
- self::$mgDevConfig = self::getFullPath("app", "Config");
- self::$mgHelperLangs = self::getFullPath("langs");
- self::$mgCoreConfig = self::getFullPath("core", "Config");
- self::$mgTemplateDir = self::getFullPath("templates");
- self::$mgIsPhp7 = self::checkIfPhp7();
- self::$prefixDataBase = self::loadDataBasePrefix();
- }
- public static function loadDataBasePrefix()
- {
- $namespaceParts = explode("\\", self::$mgModuleNamespace);
- return end($namespaceParts);
- }
- public static function checkIfPhp7()
- {
- return (version_compare(PHP_VERSION, '7.0.0') >= 0);
- }
- public static function getDevConfigDir()
- {
- return self::$mgDevConfig;
- }
- public static function getCoreConfigDir()
- {
- return self::$mgCoreConfig;
- }
- public static function getLangsDir()
- {
- return self::$mgHelperLangs;
- }
- public static function getModuleRootDir()
- {
- return self::$mgModuleRootDir;
- }
- public static function getFullPath()
- {
- $fullPath = self::getModuleRootDir();
- foreach (func_get_args() as $dir)
- {
- $fullPath .= (DS . $dir);
- }
- return $fullPath;
- }
- public static function getFullNamespace()
- {
- $fullNamespace = self::getRootNamespace();
- foreach (func_get_args() as $dir)
- {
- $fullNamespace .= ("\\" . $dir);
- }
- return $fullNamespace;
- }
- public static function getFullPathWhmcs()
- {
- $fullPath = ROOTDIR;
- foreach (func_get_args() as $dir)
- {
- $fullPath .= (DS . $dir);
- }
- return $fullPath;
- }
- public static function requireFile($file, $ones = true)
- {
- if ($ones)
- {
- require_once $file;
- }
- else
- {
- require $file;
- }
- }
- public static function getTemplateDir()
- {
- return self::$mgTemplateDir;
- }
- public static function isPhp7orHigher()
- {
- return self::$mgIsPhp7;
- }
- public static function getPrefixDataBase()
- {
- return self::$prefixDataBase . "_";
- }
- public static function getRootNamespace()
- {
- return self::$mgModuleNamespace;
- }
- public static function getModuleType()
- {
- $pathParts = explode(DIRECTORY_SEPARATOR, __DIR__);
- $typeElement = array_slice($pathParts, -3, 1);
- switch ($typeElement[0])
- {
- case 'servers':
- return 'server';
- case 'registrars':
- return 'registrar';
- default:
- return 'addon';
- }
- }
- }
|