/** * Construct a new modX instance. * * @param string $configPath An absolute filesystem path to look for the config file. * @param array $options Options that can be passed to the instance. * @return modX A new modX instance. */ public function __construct($configPath = '', array $options = array()) { global $database_type, $database_server, $dbase, $database_user, $database_password, $database_connection_charset, $table_prefix; modX::protect(); if (empty($configPath)) { $configPath = MODX_CORE_PATH . 'config/'; } if (@(include $configPath . MODX_CONFIG_KEY . '.inc.php')) { $cachePath = MODX_CORE_PATH . 'cache/'; if (MODX_CONFIG_KEY !== 'config') { $cachePath .= MODX_CONFIG_KEY . '/'; } $options = array_merge(array(xPDO::OPT_CACHE_PATH => $cachePath, xPDO::OPT_TABLE_PREFIX => $table_prefix, xPDO::OPT_HYDRATE_FIELDS => true, xPDO::OPT_HYDRATE_RELATED_OBJECTS => true, xPDO::OPT_HYDRATE_ADHOC_FIELDS => true, xPDO::OPT_LOADER_CLASSES => array('modAccessibleObject'), xPDO::OPT_VALIDATOR_CLASS => 'validation.modValidator', xPDO::OPT_VALIDATE_ON_SAVE => true, 'cache_system_settings' => true), $options); parent::__construct($database_type . ':host=' . $database_server . ';dbname=' . trim($dbase, '`') . ';charset=' . $database_connection_charset, $database_user, $database_password, $options, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_SILENT, PDO::ATTR_PERSISTENT => false, PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true)); $this->setPackage('modx', MODX_CORE_PATH . 'model/', $table_prefix); $this->setLogTarget($this->getOption('log_target', null, 'FILE')); if (!empty($site_id)) { $this->site_id = $site_id; } } else { $this->sendError($this->getOption('error_type', null, 'unavailable'), $options); } }
/** * Construct a new modX instance. * * @param string $configPath An absolute filesystem path to look for the config file. * @param array $options Options that can be passed to the instance. * @return modX A new modX instance. */ public function __construct($configPath = '', array $options = array()) { global $database_dsn, $database_user, $database_password, $config_options, $table_prefix, $site_id, $uuid; modX::protect(); if (empty($configPath)) { $configPath = MODX_CORE_PATH . 'config/'; } if (@(include $configPath . MODX_CONFIG_KEY . '.inc.php')) { $cachePath = MODX_CORE_PATH . 'cache/'; if (MODX_CONFIG_KEY !== 'config') { $cachePath .= MODX_CONFIG_KEY . '/'; } $options = array_merge(array(xPDO::OPT_CACHE_KEY => 'default', xPDO::OPT_CACHE_HANDLER => 'xPDOFileCache', xPDO::OPT_CACHE_PATH => $cachePath, xPDO::OPT_TABLE_PREFIX => $table_prefix, xPDO::OPT_HYDRATE_FIELDS => true, xPDO::OPT_HYDRATE_RELATED_OBJECTS => true, xPDO::OPT_HYDRATE_ADHOC_FIELDS => true, xPDO::OPT_LOADER_CLASSES => array('modAccessibleObject'), xPDO::OPT_VALIDATOR_CLASS => 'validation.modValidator', xPDO::OPT_VALIDATE_ON_SAVE => true, 'cache_system_settings' => true, 'cache_system_settings_key' => 'system_settings'), $config_options, $options); parent::__construct($database_dsn, $database_user, $database_password, $options, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_SILENT, PDO::ATTR_PERSISTENT => false)); $this->setPackage('modx', MODX_CORE_PATH . 'model/', $table_prefix); $this->setLogTarget($this->getOption('log_target', null, 'FILE')); if (!empty($site_id)) { $this->site_id = $site_id; } if (!empty($uuid)) { $this->uuid = $uuid; } } else { $this->sendError($this->getOption('error_type', null, 'unavailable'), $options); } }
/** * Construct a new modX instance. * * @param string $configPath An absolute filesystem path to look for the config file. * @param array $options xPDO options that can be passed to the instance. * @param array $driverOptions PDO driver options that can be passed to the instance. * @return modX A new modX instance. */ public function __construct($configPath = '', $options = null, $driverOptions = null) { try { $options = $this->loadConfig($configPath, $options, $driverOptions); parent::__construct(null, null, null, $options, null); $this->setLogLevel($this->getOption('log_level', null, xPDO::LOG_LEVEL_ERROR)); $this->setLogTarget($this->getOption('log_target', null, 'FILE')); $debug = $this->getOption('debug'); if (!is_null($debug) && $debug !== '') { $this->setDebug($debug); } $this->setPackage('modx', MODX_CORE_PATH . 'model/'); $this->loadClass('modAccess'); $this->loadClass('modAccessibleObject'); $this->loadClass('modAccessibleSimpleObject'); $this->loadClass('modResource'); $this->loadClass('modElement'); $this->loadClass('modScript'); $this->loadClass('modPrincipal'); $this->loadClass('modUser'); $this->loadClass('sources.modMediaSource'); } catch (xPDOException $xe) { $this->sendError('unavailable', array('error_message' => $xe->getMessage())); } catch (Exception $e) { $this->sendError('unavailable', array('error_message' => $e->getMessage())); } }
/** * Construct a new modX instance. * * @param string $configPath An absolute filesystem path to look for the config file. * @param array $options Options that can be passed to the instance. * @return modX A new modX instance. */ public function __construct($configPath = '', array $options = array()) { global $database_dsn, $database_user, $database_password, $config_options, $table_prefix, $site_id, $uuid; modX::protect(); if (!defined('MODX_CONFIG_KEY')) { define('MODX_CONFIG_KEY', 'config'); } if (empty($configPath)) { $configPath = MODX_CORE_PATH . 'config/'; } if (@(include $configPath . MODX_CONFIG_KEY . '.inc.php')) { $cachePath = MODX_CORE_PATH . 'cache/'; if (MODX_CONFIG_KEY !== 'config') { $cachePath .= MODX_CONFIG_KEY . '/'; } $options = array_merge(array(xPDO::OPT_CACHE_KEY => 'default', xPDO::OPT_CACHE_HANDLER => 'xPDOFileCache', xPDO::OPT_CACHE_PATH => $cachePath, xPDO::OPT_TABLE_PREFIX => $table_prefix, xPDO::OPT_HYDRATE_FIELDS => true, xPDO::OPT_HYDRATE_RELATED_OBJECTS => true, xPDO::OPT_HYDRATE_ADHOC_FIELDS => true, xPDO::OPT_VALIDATOR_CLASS => 'validation.modValidator', xPDO::OPT_VALIDATE_ON_SAVE => true, 'cache_system_settings' => true, 'cache_system_settings_key' => 'system_settings'), $config_options, $options); parent::__construct($database_dsn, $database_user, $database_password, $options, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_SILENT, PDO::ATTR_PERSISTENT => false)); $this->setLogLevel($this->getOption('log_level', null, xPDO::LOG_LEVEL_ERROR)); $this->setLogTarget($this->getOption('log_target', null, 'FILE')); $debug = $this->getOption('debug'); switch ($debug) { case null: case '': break; case true: case 1: case '1': $this->setDebug(true); break; case false: case 0: case '0': $this->setDebug(false); break; default: if ((int) $debug > 1) { $this->setDebug($debug); } break; } $this->setPackage('modx', MODX_CORE_PATH . 'model/', $table_prefix); if (!empty($site_id)) { $this->site_id = $site_id; } if (!empty($uuid)) { $this->uuid = $uuid; } } else { $this->sendError($this->getOption('error_type', null, 'unavailable'), $options); } }