示例#1
0
文件: Ldap.php 项目: las93/venus3
 /**
  * constructor of class
  * 
  * @access public
  * @return \Venus\lib\Ldap
  */
 public function __construct()
 {
     $oDbConf = Config::get('Ldap')->configuration;
     $this->_sBase = $oDbConf->base;
     $this->_rConnect = ldap_connect($oDbConf->host, $oDbConf->port);
     $this->set_option(LDAP_OPT_REFERRALS, 0);
 }
示例#2
0
文件: Entity.php 项目: las93/venus3
 /**
  * run the batch to create entity
  * @tutorial bin/console scaffolding
  *
  * @access public
  * @param  array $aOptions options of script
  * @return void
  */
 public function createDb(array $aOptions = array())
 {
     if (!isset($aOptions['p'])) {
         $aOptions['p'] = 'Batch';
     }
     if (!isset($aOptions['b'])) {
         $aOptions['b'] = json_encode(Config::get('Db', $aOptions['p']));
     }
     $oBatch = new Operation();
     $oBatch->createDb($aOptions);
 }
示例#3
0
 /**
  * Constructor
  *
  * @access public
  * @return object
  */
 public function __construct()
 {
     parent::__construct();
     $this->installDb = function () {
         $oDb = Config::get('Db');
         $oTables = json_decode(file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . preg_replace('/^.*\\\\([a-zA-Z0-9]+)$/', '$1', get_called_class()) . DIRECTORY_SEPARATOR . 'conf' . DIRECTORY_SEPARATOR . 'Db.conf'));
         $oDb->configuration->tables = $oTables;
         $aOptions = ["p" => CREATE_PORTAL, "c" => true, "e" => true, "b" => json_encode($oDb)];
         $oEntity = new Entity();
         $oEntity->runScaffolding($aOptions);
     };
 }
示例#4
0
文件: Help.php 项目: las93/venus3
 /**
  * new method to launch a web server
  * @param array $options
  * @tutorial php bin/console server:run
  *           php bin/console server:run -a 192.168.0.1:8000
  */
 public function load(array $options = array())
 {
     $BatchConf = Config::get('Route')->batch->script;
     foreach ($BatchConf as $key => $batchContent) {
         echo '-----------------------------------------------------------------------------------------------------' . "\n";
         echo '|' . $key . ' => ' . $batchContent->description . "\n|\n";
         foreach ($batchContent->options as $keyOption => $optionContent) {
             echo '|   ' . $keyOption . ' : ' . $optionContent->description . "\n";
         }
         echo '-----------------------------------------------------------------------------------------------------' . "\n";
     }
 }
示例#5
0
文件: I18n.php 项目: las93/venus3
 /**
  * constructor
  * 
  * @access public
  * @return \Venus\lib\I18n
  */
 public function __construct()
 {
     $this->setI18nDirectory(__DIR__ . DIRECTORY_SEPARATOR . I18N_DIRECTORY)->setI18nDomain(I18N_DOMAIN)->setIntermediaiteDirectory(DIRECTORY_SEPARATOR . 'LC_MESSAGES' . DIRECTORY_SEPARATOR);
     foreach (Config::get('Plugins')->list as $iKey => $sPlugin) {
         if (file_exists(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $sPlugin . DIRECTORY_SEPARATOR . 'i18n' . DIRECTORY_SEPARATOR . $this->getLanguage() . $this->getIntermediaiteDirectory() . $sPlugin . '.json')) {
             $oJson = json_decode(file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $sPlugin . DIRECTORY_SEPARATOR . 'i18n' . DIRECTORY_SEPARATOR . $this->getLanguage() . $this->getIntermediaiteDirectory() . $sPlugin . '.json'));
             $fCallBack = function ($sValue) use($oJson) {
                 if (isset($oJson->{$sValue})) {
                     return $oJson->{$sValue};
                 } else {
                     return '';
                 }
             };
         }
         CoreI18n::addCallback($sPlugin, $fCallBack);
     }
 }
示例#6
0
文件: Vendor.php 项目: las93/venus3
 /**
  * constructor - factory
  * To call a specific vendor, you have to call this class like this :
  * new \Venus\lib\Vendor('Apollina\Template');
  * new \Venus\lib\Vendor('Attila\Orm');
  * new \Venus\lib\Vendor('Mobile_Detect');
  *
  * @access public
  * @param  string $sVendorName
  * @param  mixed $mParam
  * @param  mixed $mParam2
  * @return bool|object
  */
 public static function getVendor(string $sVendorName, $mParam = null, $mParam2 = null)
 {
     if ($sVendorName === 'Apollina\\Template') {
         $oApollina = new $sVendorName($mParam, str_replace('lib', '', __DIR__), str_replace('bundles' . DIRECTORY_SEPARATOR . 'lib', CACHE_DIR, __DIR__), $mParam2);
         return $oApollina->addFunctionPath(__DIR__ . DIRECTORY_SEPARATOR . 'Functions', '\\Venus\\lib\\Functions\\');
     } else {
         if ($sVendorName === 'Attila\\Orm') {
             $oDbConfig = Config::get('Db')->configuration;
             return new $sVendorName($oDbConfig->db, $oDbConfig->type, $oDbConfig->host, $oDbConfig->user, $oDbConfig->password, $oDbConfig->db);
         } else {
             if (isset($mParam) && isset($mParam2)) {
                 return new $sVendorName($mParam, $mParam2);
             } else {
                 if (isset($mParam)) {
                     return new $sVendorName($mParam);
                 } else {
                     return new $sVendorName();
                 }
             }
         }
     }
 }
示例#7
0
文件: Cache.php 项目: las93/venus3
 /**
  * initialize the cache class and get the good object
  *
  * @access private
  * @return object
  */
 private static function _getCacheObject()
 {
     if (self::$_sTypeOfCache === 'file') {
         if (!isset(self::$_aCache['file'])) {
             self::$_aCache['file'] = new CacheFile();
         }
         return self::$_aCache['file'];
     } else {
         if (self::$_sTypeOfCache === 'memcache') {
             if (!isset(self::$_aCache['memcache'])) {
                 $oDbConf = Config::get('Memcache')->configuration;
                 if (isset($oDbConf->port)) {
                     $sPort = $oDbConf->port;
                 } else {
                     $sPort = null;
                 }
                 if (isset($oDbConf->timeout)) {
                     $iTimeout = $oDbConf->timeout;
                 } else {
                     $iTimeout = null;
                 }
                 self::$_aCache['memcache'] = new CacheMemcache($oDbConf->host, $sPort, $iTimeout);
             }
             return self::$_aCache['memcache'];
         } else {
             if (self::$_sTypeOfCache === 'apc') {
                 if (!isset(self::$_aCache['apc'])) {
                     self::$_aCache['apc'] = new Apc();
                 }
                 return self::$_aCache['apc'];
             } else {
                 if (self::$_sTypeOfCache === 'redis') {
                     if (!isset(self::$_aCache['redis'])) {
                         $oDbConf = Config::get('Redis')->configuration;
                         self::$_aCache['memcache'] = new Redis($oDbConf);
                     }
                     return self::$_aCache['redis'];
                 } else {
                     if (self::$_sTypeOfCache === 'mock') {
                         if (!isset(self::$_aCache['mock'])) {
                             self::$_aCache['mock'] = new Mock();
                         }
                         return self::$_aCache['mock'];
                     }
                 }
             }
         }
     }
 }
示例#8
0
文件: Router.php 项目: las93/venus3
 /**
  * create the constants
  *
  * @access private
  * @return void
  */
 private function _create_constant()
 {
     foreach (Config::get('Const') as $sKey => $mValue) {
         if (is_string($mValue) || is_int($mValue) || is_float($mValue) || is_bool($mValue)) {
             define(strtoupper($sKey), $mValue);
         }
     }
 }
示例#9
0
文件: Model.php 项目: las93/venus3
 /**
  * Constructor
  *
  * @access public
  * @param  Config $oDbConfig
  */
 public function __construct(Config $oDbConfig = null)
 {
     $oDbConfig = Config::get('Db')->configuration;
     parent::__construct($oDbConfig);
 }
示例#10
0
文件: AutoLoad.php 项目: las93/venus3
        $sFileClassName = preg_replace('/(src\\\\[^\\\\]+\\\\)/', '$1app\\', $sFileClassName);
        $sFileClassName = str_replace('\\\\', '\\', $sFileClassName);
        $sFileClassName = preg_replace('#bundles//tests/([^/]+)#', 'bundles/tests/$1/app', $sFileClassName);
        $sFileClassName = preg_replace('#bundles//src/([^/]+)#', 'bundles/src/$1/app', $sFileClassName);
        $sFileClassName = str_replace('app\\app', 'app', $sFileClassName);
        $sFileClassName = str_replace('app/app', 'app', $sFileClassName);
        if (strstr($sFileName, 'Venus\\') && file_exists($sFileClassName)) {
            require $sFileClassName;
        }
    } else {
        if (strstr($sFileName, 'Venus\\') && file_exists(preg_replace('#^(src/[a-zA-Z0-9_]+/)#', '$1app/', str_replace(['\\', '/'], '/', str_replace('conf', '', __DIR__) . str_replace('Venus\\', '', $sFileName))))) {
            require preg_replace('#^(src/[a-zA-Z0-9_]+/)#', '$1app/', str_replace(['\\', '/'], '/', str_replace('conf', '', __DIR__) . str_replace('Venus\\', '', $sFileName)));
        }
    }
});
/**
 * Load the composer autoload
 */
if (file_exists(preg_replace('#bundles[/\\\\]conf#', '', __DIR__) . 'vendor/autoload.php')) {
    include preg_replace('#bundles[/\\\\]conf#', '', __DIR__) . 'vendor/autoload.php';
}
/**
 * Load the autoload file (or simple files) defined in the Const.conf
 */
$oConfig = \Venus\core\Config::get('Const');
if (isset($oConfig) && isset($oConfig->autoload)) {
    $oAutoloadConf = $oConfig->autoload;
    foreach ($oAutoloadConf as $sFile) {
        require __DIR__ . '/../' . $sFile;
    }
}
示例#11
0
文件: Security.php 项目: las93/venus3
 /**
  * get the user roles
  *
  * @access public
  * @return string
  */
 public function getUserRole() : string
 {
     if (self::$_sLogin) {
         $sLogin = self::$_sLogin;
         return Config::get('Security')->users->{$sLogin}->roles;
     } else {
         return '';
     }
 }