/** * Constructor * * @param util.cmd.ParamString args */ public function __construct(ParamString $args) { $dsn = new DSN($args->value(0)); $this->adapter = self::$adapters[$dsn->getDriver()]->newInstance(DriverManager::getInstance()->getConnection($dsn->dsn)); $this->package = $args->value('package', 'p', 'db'); $this->host = $args->value('host', 'h', $dsn->getHost()); $this->naming = $args->value('nstrategy', 'n', ''); if ('' != $this->naming) { DBXMLNamingContext::setStrategy(XPClass::forName($this->naming)->newInstance()); } $this->prefix = $args->value('prefix', 'pv', ''); $this->ptargets = explode('|', $args->value('ptargets', 'pt', '')); $this->pexclude = $args->value('pexclude', 'pe', FALSE); $xsls = array(); $lang = $args->value('lang', 'l', 'xp5.php'); if ($this->getClass()->getPackage()->providesPackage(strtr($lang, '.', '_'))) { $resources = $this->getClass()->getPackage()->getPackage(strtr($lang, '.', '_'))->getResources(); foreach ($resources as $resource) { $filename = substr($resource, strrpos($resource, DIRECTORY_SEPARATOR) + 1); if (substr($filename, -8, 8) !== '.php.xsl') { continue; } $xsls[] = $resource; } } else { $packagepath = strtr($this->getClass()->getPackage()->getName(), '.', DIRECTORY_SEPARATOR); $xsls[] = $packagepath . DIRECTORY_SEPARATOR . $lang . '.xsl'; } foreach ($xsls as $resource) { $processor = new DomXSLProcessor(); $processor->setBase(__DIR__); $processor->setXSLBuf(ClassLoader::getDefault()->getResource($resource)); $processor->setParam('package', $this->package); if ($this->prefix) { $processor->setParam('prefix', $this->prefix); $processor->setParam($this->pexclude ? 'exprefix' : 'incprefix', implode(',', $this->ptargets)); } $this->processor[] = $processor; } }
/** * Constructor * * @param util.cmd.ParamString args */ public function __construct(ParamString $args) { $dsn = new DSN($args->value(0)); $this->adapter = self::$adapters[$dsn->getDriver()]->newInstance(DriverManager::getInstance()->getConnection($dsn->dsn)); $this->package = $args->value('package', 'p', 'db'); $this->host = $args->value('host', 'h', $dsn->getHost()); $this->naming = $args->value('nstrategy', 'n', ''); if ('' != $this->naming) { DBXMLNamingContext::setStrategy(XPClass::forName($this->naming)->newInstance()); } $this->prefix = $args->value('prefix', 'pv', ''); $this->ptargets = explode('|', $args->value('ptargets', 'pt', '')); $this->pexclude = $args->value('pexclude', 'pe', FALSE); // Setup generator $this->processor = new DomXSLProcessor(); $this->processor->setXSLBuf($this->getClass()->getPackage()->getResource($args->value('lang', 'l', 'xp5.php') . '.xsl')); $this->processor->setParam('package', $this->package); if ($this->prefix) { $this->processor->setParam('prefix', $this->prefix); $this->processor->setParam($this->pexclude ? 'exprefix' : 'incprefix', implode(',', $this->ptargets)); } }
/** * Queue a connection string for registering on demand. * * @param string dsn The connection's DSN * @return rdbms.DSN * @param string hostAlias default NULL * @param string userAlias default NULL */ public function queue($str, $hostAlias = NULL, $userAlias = NULL) { $dsn = new DSN($str); $host = NULL == $hostAlias ? $dsn->getHost() : $hostAlias; $user = NULL == $userAlias ? $dsn->getUser() : $userAlias; $this->pool[$user . '@' . $host] = $str; return $dsn; }