Exemplo n.º 1
0
 public function saveAction()
 {
     $this->_helper->layout()->setLayout("nolayout");
     $modelname = $this->_request->getParam("model", 'Eau_Model_Company');
     $suffixname = "model-config.xml";
     $modelnameAr = explode("_", $modelname);
     $packet = strtolower($modelnameAr[0]);
     $configfile = $packet . "-" . $suffixname;
     $config = new Zend_Config_Xml(CONFIG_PATH . "{$configfile}", null, true);
     $allfield = array();
     $arrayKey = array();
     $i = 0;
     foreach (App_Model_Config::get($modelname)->getProperties() as $element) {
         $allfield[] = $element->name;
         $arrayKey[$element->name] = $i++;
     }
     $config->production->classes->{$modelname}->text = "2";
     $props = $config->production->classes->{$modelname}->prop->toArray();
     foreach ($_POST as $key => $value) {
         list($field, $property) = explode("_", $key);
         if (in_array($field, $allfield)) {
             $index = $arrayKey[$field];
             foreach ($props as $key => $prop) {
                 if ($prop['name'] == $field) {
                     $props[$key][$property] = $value;
                     //$config->classes->{$modelname}->props->$field->$property = $value;
                 }
                 //echo $prop->name,"<br/>";
             }
             //$config->classes->{$modelname}->prop->$property = $value;
         }
     }
     $config->production->classes->{$modelname}->prop = $props;
     $config->staging = array();
     $config->setExtend('staging', 'production');
     $config->development = array();
     $config->setExtend('development', 'production');
     $writer = new Zend_Config_Writer_Xml();
     $writer->write(CONFIG_PATH . $configfile, $config);
     $this->render('blank', null, true);
 }