Example #1
0
 /**
  * Create config for adm
  *
  */
 public function createAdmConfig($servarray)
 {
     //check for the directory structure
     if (!file_exists($this->objConfig->getcontentBasePath() . 'adm/')) {
         mkdir($this->objConfig->getcontentBasePath() . 'adm/', 0777);
     }
     // write the server list file
     $cfile = $this->objConfig->getcontentBasePath() . 'adm/adm.xml';
     if (!file_exists($cfile)) {
         $conf = new Config_Container('section', 'adm');
         //$servarray['name']);
         $conf_serv =& $conf->createSection($servarray['name']);
         $conf_serv->createDirective('servername', $servarray['name']);
         $conf_serv->createDirective('serverapiurl', $servarray['url']);
         $conf_serv->createDirective('serveremail', $servarray['email']);
         $conf_serv->createDirective('regtime', date('r'));
         $config = new Config();
         $config->setRoot($conf);
         // write the container to an XML document
         $config->writeConfig($cfile, 'XML');
     } else {
         // update the xml with the new server
         $root =& $config->parseConfig($cfile, 'XML', array('name' => 'adm'));
         log_debug($root);
         $conf_serv =& $root->createSection($servarray['name']);
         $conf_serv->createDirective('servername', $servarray['name']);
         $conf_serv->createDirective('serverapiurl', $servarray['url']);
         $conf_serv->createDirective('serveremail', $servarray['email']);
         $conf_serv->createDirective('regtime', date('r'));
         $config = new Config();
         $config->setRoot($root);
         // write the container to an XML document
         $config->writeConfig($cfile, 'XML');
     }
 }
 /**
  * Saves the folders into a config file that can be edited by hand.
  * If you don't specify the config file, it will be determined
  *  automatically.
  * Values that are NULL won't be saved.
  *
  * @param string  $strFile          The file to save the data into
  *                                  (ini file)
  * @param boolean $bSaveAllSettings If all settings shall be saved
  *                         that can be loaded, or only that settings,
  *                         that have been retrieved by the user
  *
  * @return mixed True on success, PEAR_Error on failure
  *
  * @access public
  */
 function saveToFile($strFile = null, $bSaveAllSettings = true)
 {
     $conf =& new Config_Container('section', 'paths');
     if ($bSaveAllSettings) {
         foreach ($this->arSettings as $strSetting) {
             $strFunction = 'get' . $strSetting;
             $strValue = $this->{$strFunction}();
             $conf->createDirective(strtolower($strSetting), $strValue);
         }
     } else {
         foreach ($this->arCache as $strId => $strValue) {
             $conf->createDirective($strId, $strValue);
         }
     }
     $config = new Config();
     $config->setRoot($conf);
     return $config->writeConfig($this->getDefaultConfigFile(), 'inifile');
 }