public function asArray()
 {
     $res = parent::asArray();
     $data = $res['data'];
     unset($res['data']);
     $res = array_merge($res, $data);
     return $res;
 }
 public function __construct($filename, $root_node, db_update_page $db_upd)
 {
     parent::__construct($filename, $root_node);
     $this->updates = new DOMDocument();
     $this->updates->formatOutput = true;
     $this->updates->preserveWhiteSpace = false;
     $this->updates->load(XML_UPDATES_FILE);
     $this->db_update_obj = $db_upd;
 }
 private function loadSettingsFromXml($xml_string)
 {
     $store = new XmlConfig();
     $res = @$store->loadXML($xml_string);
     if (!$res) {
         throw new Exception("Invalid XML configuration file.");
     }
     $vars_arr = $store->asArray();
     $this->settings = $this->parseSettingsData($vars_arr, $this->var_names);
     $this->loaded = true;
 }
 public function testGetSecretCode()
 {
     $this->assertEquals("secret-code-1", $this->config1->getSecretCode());
     $this->assertEquals("secret-code-2", $this->config2->getSecretCode());
 }
function get_xml_data($xml_path, $xml_fields, $xml_items_node, $xml_items_info_node, $xml_filters)
{
    try {
        $xml = new XmlConfig($xml_path);
        $result = $xml->getItemsList($xml_fields, $xml_items_node, $xml_items_info_node, $xml_filters);
        unset($xml);
        return $result;
    } catch (Exception $e) {
        die($e->__toString());
    }
}
 /**
  * Load internationalization string files
  *
  *
  */
 public function loadLanguageFiles()
 {
     $culture_file = getShadowedPath(PA::$config_path . '/i18n.xml');
     $culture_data = new XmlConfig($culture_file);
     if ($culture_data->docLoaded) {
         PA::$culture_data = $culture_data->asArray();
     } else {
         throw new BootStrapException("Error - Can't load \"{$culture_file}\" culture file.", BootStrapException::UNRECOVERABLE_BOOT_EXCEPTION);
     }
     $this->installed_languages = $this->getLanguagesList();
     session_start();
     if (!empty($this->request_data['lang'])) {
         if (array_key_exists($this->request_data['lang'], $this->installed_languages)) {
             $this->current_lang = $this->request_data['lang'];
             $_SESSION['user_lang'] = $this->current_lang;
         }
     } else {
         if (isset($_SESSION['user_lang'])) {
             $this->current_lang = $_SESSION['user_lang'];
         } else {
             if (PA::$config->pa_installed) {
                 $net_info = get_network_info();
                 $net_settings = unserialize($net_info->extra);
                 $this->current_lang = isset($net_settings['default_language']) ? $net_settings['default_language'] : 'english';
             }
         }
     }
     session_commit();
     if ($this->current_lang) {
         PA::$language = $this->current_lang;
     }
     ob_start();
     global $TRANSLATED_STRINGS;
     $strings_file = getShadowedPath("web/languages/" . PA::$language . "/strings.php");
     try {
         if (file_exists($strings_file)) {
             eval('?>' . (require_once $strings_file));
         }
         $msg_handler = getShadowedPath("web/languages/" . PA::$language . "/MessagesHandler.php");
         if (file_exists($msg_handler)) {
             eval('?>' . (require_once $msg_handler));
         } else {
             eval('?>' . (require_once getShadowedPath("web/languages/english/MessagesHandler.php")));
         }
     } catch (Exception $e) {
         // Either an invalid language was selected, or one (e.g. English) without a strings.php file.
         $TRANSLATED_STRINGS = array();
         throw new BootStrapException($e->message, 1);
     }
     return ob_get_clean();
 }
 public function exportMessages($file_name)
 {
     $obj = new XmlConfig($file_name, "email_messages");
     $obj->loadFromArray($this->messages, $obj->root_node);
     $obj->saveToFile();
 }
 /** !!
  * saves the setting selected by the user
  * @param array $request_data information to be saved
  */
 private function handlePOST_saveConfSection($request_data)
 {
     global $app, $error_msg;
     $msg = __("Configuration data sucessfully stored.");
     $this->section = $request_data['section'];
     $form_data = $request_data['form_data'];
     $this->recursive_update_data_object($form_data[$this->section], "{$this->section}']['value");
     try {
         unlink(PA::$project_dir . APPLICATION_CONFIG_FILE);
         $conf = new XmlConfig(PA::$project_dir . APPLICATION_CONFIG_FILE, 'application');
         $conf->loadFromArray($app->configData, $conf->root_node);
         $conf->saveToFile();
         $app->configData = $conf->asArray();
         $app->configObj = $conf;
     } catch (Exception $e) {
         $msg = $e->getMessage();
     }
     $form = $this->getConfigSection($this->config_sect, $this->manage_mode);
     $this->set_inner_template('show_config_section.tpl.php');
     $this->inner_HTML = $this->generate_inner_html(array('data' => $form, 'mode_tag' => $this->mode_tag, 'sect_tag' => $this->sect_tag, 'message' => null));
     $error_msg = $msg;
 }
 private function updateSettings()
 {
     global $app;
     // We don't need to store the MySQL root un/pw, so un-set it from the config array.
     unset($this->config['database']['mysql_root_password'], $this->config['database']['mysql_root_username']);
     foreach ($this->config['database'] as $key => $value) {
         $app->configData['configuration']['database']['value'][$key]['value'] = $value;
     }
     $app->configData['configuration']['database']['value']['peepagg_dsn']['value'] = $this->config['peepagg_dsn'];
     $app->configData['configuration']['basic_network_settings']['value']['domain_prefix']['value'] = $this->subdomain;
     $app->configData['configuration']['basic_network_settings']['value']['enable_networks']['value'] = $this->allow_network_spawning;
     $app->configData['configuration']['basic_network_settings']['value']['enable_network_spawning']['value'] = $this->allow_network_spawning;
     $app->configData['configuration']['site_related']['value']['pa_installed']['value'] = 1;
     $app->configData['configuration']['api_keys']['value']['facebook_api_key']['value'] = $this->keys['key'];
     $app->configData['configuration']['api_keys']['value']['facebook_api_secret']['value'] = $this->keys['secret'];
     $app->configData['configuration']['api_keys']['value']['amazon_aws_key']['value'] = $this->keys['amazon_key'];
     $app->configData['configuration']['api_keys']['value']['amazon_aws_secret']['value'] = $this->keys['amazon_secret'];
     $app->configData['configuration']['api_keys']['value']['amazon_s3_bucket']['value'] = $this->keys['amazon_bucket'];
     $app->configData['configuration']['api_keys']['value']['hoptoad_key']['value'] = $this->keys['hoptoad_key'];
     $app->configData['configuration']['api_keys']['value']['hoptoad_environment']['value'] = $this->keys['hoptoad_env'];
     $app->configData['configuration']['civic_commons_settings']['value']['CC_APPLICATION_URL']['value'] = $this->keys['cc_application_url'];
     $app->configData['configuration']['site_related']['value']['PASSWORD_PEPPER']['value'] = $this->keys['pw_pepper'];
     unlink(PA::$project_dir . APPLICATION_CONFIG_FILE);
     $confObj = new XmlConfig(null, 'application');
     $confObj->loadFromArray($app->configData, $confObj->root_node);
     $confObj->saveToFile(PA::$project_dir . APPLICATION_CONFIG_FILE);
 }