$newOrder[] = $node; $rowCounter++; $newPos = -1; } if ($child->name !== $node->name) { $newOrder[] = $xmldoc->children[0]->children[$index]; } else { $rowCounter--; } } if ($rowCounter < $newPos) { $newOrder[] = $node; $rowCounter++; $newPos = -1; } $xmldoc->children[0]->children = $newOrder; $xmldoc->save($file); G::LoadClass('xmlDb'); $i = 0; $aFields = array(); $aFields[] = array('XMLNODE_NAME' => 'char', 'TYPE' => 'char', 'UP' => 'char', 'DOWN' => 'char', 'row__' => 'integer'); $oSession = new DBSession(new DBConnection($file, '', '', '', 'myxml')); $oDataset = $oSession->Execute('SELECT * FROM dynaForm WHERE NOT( XMLNODE_NAME = "" )'); $iMaximun = $oDataset->count(); while ($aRow = $oDataset->Read()) { $aFields[] = array('XMLNODE_NAME' => $aRow['XMLNODE_NAME'], 'TYPE' => $aRow['TYPE'], 'UP' => $i > 0 ? G::LoadTranslation('ID_UP') : '', 'DOWN' => $i < $iMaximun - 1 ? G::LoadTranslation('ID_DOWN') : '', 'row__' => $i + 1); $i++; } global $_DBArray; $_DBArray['fields'] = $aFields; $_SESSION['_DBArray'] = $_DBArray;
$dynaform = new dynaform($dbc); $dynaform->Fields['DYN_UID'] = isset($_POST['DYN_UID']) ? urldecode($_POST['DYN_UID']) : '0'; $dynaform->Load($dynaform->Fields['DYN_UID']); if (isset($_POST['DYN_UID']) && $_POST['DYN_UID'] !== '') { $file = $dynaform->Fields['DYN_FILENAME']; } else { //Hardcode: Sample of xmlform. $file = $PRO_UID . '/' . 'myInfo'; } /* Start Comment: If file doesn't exist, it is created */ if (!file_exists(PATH_DYNAFORM . $file . '.xml')) { $newDoc = new Xml_Document(); $newDoc->addChildNode(new Xml_Node('dynaForm', 'open', '', array('type' => 'xmlform', 'name' => $file))); $newDoc->children[0]->addChildNode(new Xml_Node('', 'cdata', "\n")); G::verifyPath(dirname(PATH_DYNAFORM . $file . '.xml'), true); $newDoc->save(PATH_DYNAFORM . $file . '.xml'); unset($newDoc); } /* End Comment */ /* Start Comment: Create and temporal copy. */ $pathFile = $filter->xssFilterHard(PATH_DYNAFORM . $file . '.xml', 'path'); $copy = implode('', file($pathFile)); $file .= '_tmp0'; $fcopy = fopen($pathFile, "w"); fwrite($fcopy, $copy); fclose($fcopy); /* End Comment */ //Removes any other CURRENT_DYNAFORM that could be pending because of a page refresh or a failure unset($_SESSION['CURRENT_DYNAFORM']); define('DB_XMLDB_HOST', PATH_DYNAFORM . $file . '.xml'); define('DB_XMLDB_USER', '');