/** * @param array $config */ public function config($config = []) { $settings = null; // check for an initial configuration template // used eg. by the demo installer $configTemplatePath = PIMCORE_CONFIGURATION_DIRECTORY . "/system.template.php"; if (file_exists($configTemplatePath)) { try { $configTemplate = new \Zend_Config(include $configTemplatePath); if ($configTemplate->general) { // check if the template contains a valid configuration $settings = $configTemplate->toArray(); // unset database configuration unset($settings["database"]["params"]["host"]); unset($settings["database"]["params"]["port"]); } } catch (\Exception $e) { } } // set default configuration if no template is present if (!$settings) { // write configuration file $settings = ["general" => ["timezone" => "Europe/Berlin", "language" => "en", "validLanguages" => "en", "debug" => "1", "debugloglevel" => "debug", "custom_php_logfile" => "1", "extjs6" => "1"], "database" => ["adapter" => "Mysqli", "params" => ["username" => "root", "password" => "", "dbname" => ""]], "documents" => ["versions" => ["steps" => "10"], "default_controller" => "default", "default_action" => "default", "error_pages" => ["default" => "/"], "createredirectwhenmoved" => "", "allowtrailingslash" => "no", "generatepreview" => "1"], "objects" => ["versions" => ["steps" => "10"]], "assets" => ["versions" => ["steps" => "10"]], "services" => [], "cache" => ["excludeCookie" => ""], "httpclient" => ["adapter" => "Zend_Http_Client_Adapter_Socket"]]; } $settings = array_replace_recursive($settings, $config); // create initial /website/var folder structure // @TODO: should use values out of startup.php (Constants) $varFolders = ["areas", "assets", "backup", "cache", "classes", "config", "email", "log", "plugins", "recyclebin", "search", "system", "tmp", "versions", "webdav"]; foreach ($varFolders as $folder) { \Pimcore\File::mkdir(PIMCORE_WEBSITE_VAR . "/" . $folder); } $configFile = \Pimcore\Config::locateConfigFile("system.php"); File::putPhpFile($configFile, to_php_data_file_format($settings)); }
/** * Get device features * * @return Application_Model_Device */ public function getDevice() { if ($this->device == null) { $this->device = false; $devices = Application_Model_DevicesMapper::i()->fetchAll(); /* @var Application_Model_Device $device */ foreach ($devices as $device) { // if exact do an == comparison if ($device->isExact() && $device->getPattern() == $_SERVER['HTTP_USER_AGENT'] || !$device->isExact() && preg_match($device->getPattern(), $_SERVER['HTTP_USER_AGENT']) > 0) { // valid $device found; $this->device = $device; break; } } if ($this->device == false) { // load things from default $this->device = new Application_Model_Device(); if (X_VlcShares_Plugins::broker()->isRegistered('wiimc')) { $this->device->setGuiClass($this->options->get('gui', 'X_VlcShares_Plugins_WiimcPlxRenderer')); } else { $this->device->setGuiClass($this->options->get('gui', 'X_VlcShares_Plugins_WebkitRenderer')); } $this->device->setIdProfile($this->options->get('profile', 1))->setLabel("Unknown device"); } } return $this->device; }
/** * Combine the static info found in application.ini with the * dynamic info found in the Info table. * * @return void */ protected function _initConfig() { $this->bootstrap('db'); $this->bootstrap('locale'); if (!class_exists('Model_Info')) { return; } try { $staticConfig = Zend_Registry::get('config'); $infoModel = $this->_getInfoModel(); $dynamicConfig = $infoModel->fetchAsConfig(null, APPLICATION_ENV); // Very sneakily bypass 'readOnly' if ($staticConfig->readOnly()) { $staticConfig = new Zend_Config($staticConfig->toArray(), APPLICATION_ENV, true); } $staticConfig->merge($dynamicConfig); $staticConfig->setReadOnly(); Zend_Registry::set('config', $staticConfig); } catch (Exception $e) { $msg = $e->getMessage(); if (strpos($msg, 'Unknown database') === false && strpos($msg, "doesn't exist") === false) { throw $e; } } }
/** * Setup db * */ public function setup(Zend_Config $config) { $sessionConfig = $config->get('config'); $configArray = $sessionConfig->toArray(); // save_path handler $configArray = $this->_prependSavePath($configArray); // name handler $configArray = $this->_parseName($configArray); // Setup config Zend_Session::setOptions($configArray); // Setup save handling? $saveHandlerConfig = $config->get('save_handler'); if ($className = $saveHandlerConfig->get('class_name')) { if ($args = $saveHandlerConfig->get('constructor_args')) { if ($args instanceof Zend_Config) { $args = $args->toArray(); } else { $args = (array) $args; } } else { $args = array(); } require_once 'Zend/Loader.php'; Zend_Loader::loadClass($className); $saveHandler = new ReflectionClass($className); $saveHandler = $saveHandler->newInstanceArgs($args); Zend_Session::setSaveHandler($saveHandler); } // Autostart session? if ($config->get('auto_start')) { // Start session Zend_Session::start(); } }
/** * Setup Doctrine * * @return void */ public function setup(Zend_Config $config) { if (is_array($config->path_config)) { $this->setPathConfig($config->path_config); } elseif ($config->path_config instanceof Zend_Config) { $this->setPathConfig($config->path_config->toArray()); } if ($charset = $config->get('charset')) { $listener = new Zym_App_Resource_Doctrine_ConnectionListener(); $listener->setCharset($charset); Doctrine_Manager::getInstance()->addListener($listener); } // determine if config is for a single-db or a multi-db site $connections = $config->connection instanceof Zend_Config ? $config->connection->toArray() : (array) $config->connection; // add connection(s) to doctrine foreach ($connections as $name => $connection) { if ($connection instanceof Zend_Config) { $connection = $connection->toArray(); } if (is_string($name)) { Doctrine_Manager::connection($connection, $name); } else { Doctrine_Manager::connection($connection); } } }
/** * Инициализация конфигурации */ protected function _initConfig() { $path = APPLICATION_PATH . '/../library/Zkernel/Application/configs'; $config = new Zend_Config(array(), true); $it = new DirectoryIterator($path); foreach ($it as $file) { if ($file->isFile()) { $fullpath = $path . '/' . $file; switch (substr(trim(strtolower($fullpath)), -3)) { case 'ini': $cfg = new Zend_Config_Ini($fullpath, $this->getEnvironment()); break; case 'xml': $cfg = new Zend_Config_Xml($fullpath, $this->getEnvironment()); break; default: throw new Zend_Config_Exception('Invalid format for config file'); break; } $config->merge($cfg); } } $config->merge(new Zend_Config($this->getOptions())); $this->setOptions($config->toArray()); }
/** * @param Zend_Config $testConfig * @param ReflectionParameter $arg * @throws Exception * @throws KalturaTestException * @return Ambigous */ protected function getArgConfig(Zend_Config $testConfig, ReflectionParameter $arg) { $argName = $arg->getName(); $argConfig = $testConfig->get($argName); KalturaLog::debug("Tests data [{$argName}] config [" . print_r($argConfig, true) . "]"); if (!$argConfig) { if (!$arg->allowsNull()) { throw new Exception("Argument [{$argName}] can't be null for test [" . $this->getName() . "]"); } return null; } if (is_string($argConfig)) { return $argConfig; } switch ($argConfig->objectType) { case 'dependency': throw new KalturaTestException("Argument [{$argName}] taken from dependency"); case 'array': return $this->populateArray($argConfig); case 'native': return $argConfig->value; case 'file': return $argConfig->path; default: return $this->populateObject($argConfig); } }
/** * @param $databaseConfig * @param $masterParams * @return array */ private function mapSlavesConfig(Zend_Config $databaseConfig, $masterParams) { $slaves = $databaseConfig->get('slaves'); if (!$slaves || !$slaves instanceof Zend_Config || $slaves->count() === 0) { $slaves = array(); } $slavesParams = array(); foreach ($slaves as $slaveId) { $slaveConfig = $databaseConfig->get($slaveId); if (!$slaveConfig || !$slaveConfig instanceof Zend_Config) { $this->logger->warning(sprintf("Listed slave '%s' has no configuration. Skipping candidate slave.", $slaveId)); continue; } $slaveParams = $this->getParamsFromConfig($slaveConfig); if ($slaveParams['driver'] !== $masterParams['driver']) { $this->logger->warning(sprintf("Listed slave '%s' has different driver ('%s') than master ('%s'). This is not supported. " . 'Skipping candidate slave.', $slaveId, $slaveParams['driver'], $masterParams['driver'])); continue; } $slavesParams[] = $slaveParams; } if (empty($slavesParams)) { $this->logger->warning('No (properly) configured slaves, using master as slave.'); $slavesParams[] = $masterParams; } return $slavesParams; }
/** * Get transport * * @param Zend_Config $config * @return Zend_Mail_Transport_Sendmail */ public static function getTransport(Zend_Config $config = null) { $host = isset($config->host) ? $config->get('host') : null; $otherConfig = ($config instanceof Zend_Config) ? $config->toArray() : null; return new Zend_Mail_Transport_Smtp($host, $otherConfig); }
/** * Constructor. * @param array $options */ public function __construct(Zend_Config $config = null) { $defaultConfig = new Zend_Config(array('style' => array('itemClass' => 'Item', 'titleClass' => 'Title', 'descriptionClass' => 'Description', 'tagContainerClass' => 'TagList', 'tagClass' => 'Tag', 'iconClass' => 'Icon', 'iconWidth' => 16, 'iconHeight' => 16, 'dateClass' => 'Date')), true); if (!is_null($config)) { $defaultConfig->merge($config); } $this->_config = $defaultConfig; }
/** * Pseudo-constructor (the actual constructor must be final). * @param Zend_Config $config * @return void */ protected function _init(Zend_Config $config) { $defaultConfig = new Zend_Config(array('url' => null, 'cacheLifetime' => 7200, 'cacheDir' => './cache', 'limit' => 5, 'items' => array()), true); if (!isset($config->url)) { throw new Polycast_Stalker_Provider_Exception('No feed url given'); } $this->_config = $defaultConfig->merge($config); }
public function testSetOptionsSkipsCallsToSetOptionsAndSetConfig() { $options = $this->getOptions(); $config = new Zend_Config($options); $options['config'] = $config; $options['options'] = $config->toArray(); $this->form->setOptions($options); }
/** * Setup navigation * * @return void */ public function setup(Zend_Config $config) { // determine registry key $confKey = $config->get('registry_key'); $key = is_string($confKey) && strlen($confKey) ? $confKey : self::DEFAULT_REGISTRY_KEY; $nav = new Zym_Navigation($config->get('pages')); Zend_Registry::set($key, $nav); }
/** * Sets filter options * * @param string|array|Zend_Config $options * @return void */ public function __construct($options = null) { if ($options instanceof Zend_Config) { $this->_options = $options->toArray(); } else { $this->_options = (array) $options; } }
/** * @param boolean $enableDev */ protected function setQuotaModuleEnableDev($enableDev) { $config = Registry::getConfig(); $newConfig = new \Zend_Config($config->toArray(), true); $newConfig->quota->module->enableDev = $enableDev; $newConfig->setReadOnly(); Registry::setConfig($newConfig); }
/** * * Creates a new test configuration from Zend_Config */ public static function fromZendConfig(Zend_Config $config) { $newConfig = new KalturaTestConfig(); $dataArray = $config->toArray(); foreach ($dataArray as $key => $value) { $newConfig->{$key} = $value; } return $newConfig; }
/** * Constructor. * @param Zend_Config $config */ public function __construct(Zend_Config $config = null) { $defaultConfig = new Zend_Config(array('providers' => array(), 'style' => array('id' => 'Stalker', 'class' => 'Stalker')), true); $defaultConfig->merge($config); $this->_config = $defaultConfig; foreach ($this->_config->providers as $name => $providerConfig) { $this->addProvider(Polycast_Stalker_Provider::factory($providerConfig), $name); } }
public function loadFromMultiFiles(array $files, $ns, $save = true) { $conf = new Zend_Config(array(), true); foreach ($files as $file) { $fileConf = $this->_loadConfigFromFile($file); $conf->merge($fileConf); } return $this->processConfigFile($conf, $ns, $save); }
public static function createFromConfig(Zend_Config $config) { if (!isset($config->host) || $config->host == '') { throw new EngineBlock_Exception('No Grouper Host specified! Please set "grouper.host" in your application configuration.'); } $url = $config->protocol . '://' . $config->user . ':' . $config->password . '@' . $config->host . (isset($config->port) ? ':' . $config->port : '') . $config->path . '/' . $config->version . '/'; $grouper = new self($url, $config->toArray()); return $grouper; }
/** * @return X_SopCast */ public function setOptions($options) { if (is_array($options)) { $options = new Zend_Config($options); } if ($options instanceof Zend_Config) { $this->setPath($options->get('path', null)); } return $this; }
/** * Return errorHandler * * @param Zend_Config $config * @return Zym_Controller_Plugin_ErrorHandler */ public function getPlugin(Zend_Config $config = null) { if ($config instanceof Zend_Config) { $options = $config->toArray(); } else { $options = array(); } $plugin = new Zym_Controller_Plugin_ErrorHandler($options); return $plugin; }
private function setConfig() { $frontController = Zend_Controller_Front::getInstance(); $options = new Zend_Config($frontController->getParam('bootstrap')->getOptions(), true); $rest = $options->get('rest', false); if ($rest) { $this->defaultFormat = $rest->default; $this->acceptableFormats = $rest->formats->toArray(); } }
/** * Returns a SimpleXMLElement for the given config. * * @see Zend_Build_Resource_Interface * @param Zend_Build_Resource_Interface Resource to convert to XML * @return string String in valid XML 1.0 format */ public static function getXmlForConfig(Zend_Config $config) { // First create the empty XML element $xml = self::_arrayToXml($config->toArray(), new SimpleXMLElement('<' . self::CONFIG_XML_ROOT_ELEMENT . '/>'), true); // Format output for readable XML and save to $filename $dom = new DomDocument('1.0'); $domnode = dom_import_simplexml($xml); $domnode = $dom->importNode($domnode, true); $domnode = $dom->appendChild($domnode); $dom->formatOutput = true; return $dom->saveXML(); }
/** * Return true if a next page is possible * @return boolean * @throws Exception invalid $items type */ public function hasNext($items, $page = 1, $perPage = null) { if ($perPage === null) { $perPage = $this->options->get('perpage', 25); } if (is_array($items)) { return count($items) > $page * $perPage; } elseif ($items instanceof X_Page_ItemList) { $items = $items->getItems(); return count($items) > $page * $perPage; } else { throw new Exception("Items must be an array or an X_Page_ItemList"); } }
/** * Modify config for Zend_Layout * * @param Zend_Config $config * @return array */ protected function _handleConfig(Zend_Config $config) { // Remove null items $inflectedConfig = $config->toArray(); foreach ($inflectedConfig as $index => $var) { if (null === $var) { unset($inflectedConfig[$index]); } } // Change underscore items to camelcased $inflectedConfig = array_flip($inflectedConfig); $inflectedConfig = array_flip(array_map(array($this, '_inflectConfig'), $inflectedConfig)); return $inflectedConfig; }
/** * Init observers * * @param Evil_Config $events * @param null $object * @return void */ public function init(Evil_Config $events, $object = null) { foreach ($events->observers as $name => $body) { foreach ($body as $handler) { /// соединяем настройки по умолчанию с настройками текущего handler, в т.ч. src /// т.к. Zend_Config v1.11.4 не умеет рекурсивно мержить конфиги $handler = new Zend_Config(array_merge_recursive($events->handler->toArray(), $handler->toArray())); // print_r($events->handler->toArray()); // print_r($handler->toArray()); $this->addHandler(new Evil_Event_Slot($name, $handler, $object)); } } // var_dump($this->_handlers); }
protected function _testConfig(array $config, &$error) { $outputConfig = new Zend_Config(array(), true); $outputConfig->merge(XenForo_Application::getInstance()->loadDefaultConfig())->merge(new Zend_Config($config)); try { $db = Zend_Db::factory($outputConfig->db->adapter, array('host' => $outputConfig->db->host, 'port' => $outputConfig->db->port, 'username' => $outputConfig->db->username, 'password' => $outputConfig->db->password, 'dbname' => $outputConfig->db->dbname, 'charset' => 'utf8')); $db->getConnection(); $db->listTables(); $error = ''; } catch (Zend_Db_Exception $e) { $error = new XenForo_Phrase('following_error_occurred_while_connecting_database', array('error' => $e->getMessage())); } return $db; }
/** * Setup * * @param Zend_Config $config */ public function setup(Zend_Config $config) { // Use non-default autoload function? $class = $config->get('class'); // Allow loading multiple loaders if ($class instanceof Zend_Config) { $classes = $class->toArray(); } else { $classes = (array) $class; } // Register autoload foreach (array_reverse($classes) as $loader) { Zend_Loader::registerAutoload($loader); } }
public function init(Zend_Config $options) { $language = new X_VlcShares_Plugins_Helper_Language($options->get('language', new Zend_Config(array()))); $ffmpeg = new X_VlcShares_Plugins_Helper_FFMpeg($options->get('ffmpeg', new Zend_Config(array()))); $devices = new X_VlcShares_Plugins_Helper_Devices($options->get('devices', new Zend_Config(array()))); $stream = new X_VlcShares_Plugins_Helper_Stream($options->get('stream', new Zend_Config(array()))); $paginator = new X_VlcShares_Plugins_Helper_Paginator($options->get('paginator', new Zend_Config(array()))); $hoster = new X_VlcShares_Plugins_Helper_Hoster(); $rtmpdump = new X_VlcShares_Plugins_Helper_RtmpDump($options->get('rtmpdump', new Zend_Config(array()))); $sopcast = new X_VlcShares_Plugins_Helper_SopCast($options->get('sopcast', new Zend_Config(array()))); //$vlc = new X_VlcShares_Plugins_Helper_Vlc($options->get('vlc', new Zend_Config(array()))); $streamer = new X_VlcShares_Plugins_Helper_Streamer($options->get('streamer', new Zend_Config(array()))); $acl = X_VlcShares_Plugins_Helper_Acl::instance($options->get('acl', new Zend_Config(array()))); $this->registerHelper('language', $language, true)->registerHelper('ffmpeg', $ffmpeg, true)->registerHelper('devices', $devices, true)->registerHelper('stream', $stream, true)->registerHelper('paginator', $paginator, true)->registerHelper('hoster', $hoster, true)->registerHelper('rtmpdump', $rtmpdump, true)->registerHelper('streamer', $streamer, true)->registerHelper('sopcast', $sopcast, true)->registerHelper('acl', $acl, true); }
private function setConfig() { $frontController = Zend_Controller_Front::getInstance(); $options = new Zend_Config($frontController->getParam('bootstrap')->getOptions(), true); $rest = $options->get('rest', false); if ($rest) { $this->defaultFormat = $rest->default; $this->acceptableFormats = $rest->formats->toArray(); foreach ($this->responseTypes as $mime => $format) { if (!in_array($format, $this->acceptableFormats)) { unset($this->responseTypes[$mime]); } } } }