function initialize(IConfigParameter $configuration) { //----------------------------------------------------- //set global variables /*$this->logDir=$logDir; $this->logFile=$logFile; if($countFile) $this->countFile=$this->logDir . "/$countFile"; $this->headerTitle=$headerTitle; $this->logMode=$logMode;*/ $this->logDir = $configuration->get('logDir'); $this->logFile = $configuration->get('logFile'); if ($configuration->get('countFile')) { $this->countFile = Project::NS()->path($this->logDir) . DIRECTORY_SEPARATOR . $configuration->get('countFile'); } $this->headerTitle = $configuration->get('headerTitle'); $this->logMode = $configuration->get('logMode'); //generate log number //set counter file and log folder $countFile = $this->countFile; $logDir = $this->logDir; //verify log folder existence //if it doesn't I create it if (!is_dir($logDir)) { if (mkdir($logDir) === FALSE) { echo "Could not create log dir"; } } //Counter INICILIZATION if (file_exists($countFile) === FALSE) { //if log counter file does not exist, I create it touch($countFile); //inicializing file in 0 $initNumber = 0; $fp = fopen($countFile, "a"); if (fwrite($fp, $initNumber) === FALSE) { echo "Could not write Counter file"; } fclose($fp); } //------------------------------------------------------------ //INCREMENT Counter //read counter $logNumber = trim(file_get_contents($countFile)); $logNumber++; //increment counter //set log number in class var $this->logNumber = $logNumber; //write incremented counter value $fp = fopen($countFile, "w+"); if (fwrite($fp, $logNumber) === FALSE) { echo "Could not write Counter file"; } fclose($fp); //parent::init(); $this->_common_config($configuration); //----------------------------------------------------- }
protected function _common_config(IConfigParameter $configuration, $skip_pathes = false) { $this->_config = $configuration; $this->_app_cache_id = $this->_config->get('cache_id'); $this->_app_cache_key = $this->_config->get('cache_key'); $this->_registry = $this->_config->get('set_to_registry', true); $this->_initialized = true; if ($skip_pathes === false) { Project::NS()->setPathes($configuration); } }
function initialize(IConfigParameter $configuration) { $this->_templateDir = Project::NS()->path($configuration->get('template_dir')); if (!file_exists($this->_templateDir) || !is_dir($this->_templateDir)) { throw new TemplateException("Template manager: root template directory is not exists"); } $this->_js_path = $configuration->get('js_path'); $this->_css_path = $configuration->get('css_path'); $this->_image_path = $configuration->get('image_path'); $this->_cj_cache_path = $configuration->get('cj_cache_path'); Project::setTemplateManager($this); $this->_common_config($configuration); }
public function initialize(IConfigParameter $configuration) { parent::initialize($configuration); $engine = new Cache_Lite(); if (!$configuration->get('directory')) { throw new CacheException('FileCache: cache directory not specified'); } $engine->_cacheDir = Project::NS()->path($configuration->get('directory')); if ($configuration->get('file_name')) { $engine->_fileName = $configuration->get('file_name'); } else { $engine->_fileName = "file.cache"; } $this->_engine = $engine; Project::getCacheManager()->set($configuration->get('id'), $this); }
function initialize(IConfigParameter $configuration) { $dsn = $configuration->get('DSN'); if (!$dsn) { $connection_file = $configuration->get('connection_file'); if (!$connection_file) { throw new DbException("Connection file not defined"); } $p = pathinfo($connection_file); $dir = Project::NS()->path($p['dirname']); $f = $dir . $p['basename']; if (!file_exists($f) || !is_file($f)) { throw new DbException("Connection file not exists"); } $config = new ConfigParameter(file_get_contents($f)); $dsn = $config->get('DSN'); if (!$dsn) { throw new DbException("DSN not exitsts at connection file"); } } $this->_caching = $configuration->get('caching'); if ($configuration->get('cache_prefix')) { $this->_cache_prefix = $configuration->get('cache_prefix'); } if ($configuration->get('cache_module_id')) { $this->_cache_module_id = $configuration->get('cache_module_id'); } else { // No cache module defined // TODO:: write NOTICE to log $this->_caching = false; } $this->_DSN = $dsn; $this->_common_config($configuration); $this->_driver = DbSimple_Generic::connect($this->_DSN); if (!is_object($this->_driver)) { throw new DbException("No connection to database"); } $this->_driver->query("SET NAMES utf8"); $this->_driver->setLogger($configuration->get('native_logger')); //$this -> _driver -> setLogger('myLogger'); Project::setDatabase($this); }