Esempio n. 1
0
if (!(isset($_POST['A']) && $_POST['A'] !== '')) {
    return;
}
if (!(isset($_POST['XMLNODE_NAME']) && $_POST['XMLNODE_NAME'] !== '')) {
    return;
}
if (!(isset($_POST['NEW_POS']) && $_POST['NEW_POS'] !== '')) {
    return;
}
$file = PATH_DYNAFORM . G::decrypt($_POST['A'], URL_KEY) . '.xml';
$fieldName = $_POST['XMLNODE_NAME'];
$newPos = intval($_POST['NEW_POS']);
if (!file_exists($file)) {
    return;
}
$xmldoc = new Xml_Document();
$xmldoc->parseXmlFile($file);
$node =& $xmldoc->findNode('/dynaForm/' . $fieldName);
if (!isset($node)) {
    return;
}
$numFields = 0;
foreach ($xmldoc->children[0]->children as $child) {
    $numFields += $child->name !== '' ? 1 : 0;
}
$newPos = $newPos < 1 ? 1 : $newPos;
$newPos = $newPos > $numFields ? $numFields : $newPos;
$rowCounter = (int) 0;
$newOrder = array();
foreach ($xmldoc->children[0]->children as $index => $child) {
    if ($child->name !== '') {
 /**
  * Prints the DynaformEditor
  *
  * @return void
  */
 public function _render()
 {
     global $G_PUBLISH;
     $script = '';
     /* Start Block: Load (Create if doesn't exist) the xmlform */
     $Parameters = array('SYS_LANG' => SYS_LANG, 'URL' => G::encrypt($this->file, URL_KEY), 'DYN_UID' => $this->dyn_uid, 'PRO_UID' => $this->pro_uid, 'DYNAFORM_NAME' => $this->dyn_title, 'FILE' => $this->file, 'DYN_EDITOR' => $this->dyn_editor);
     $_SESSION['Current_Dynafom']['Parameters'] = $Parameters;
     $XmlEditor = array('URL' => G::encrypt($this->file, URL_KEY), 'XML' => '');
     $JSEditor = array('URL' => G::encrypt($this->file, URL_KEY));
     $A = G::encrypt($this->file, URL_KEY);
     try {
         $openDoc = new Xml_Document();
         $fileName = $this->home . $this->file . '.xml';
         if (file_exists($fileName)) {
             $openDoc->parseXmlFile($fileName);
         } else {
             $this->_createDefaultXmlForm($fileName);
             $openDoc->parseXmlFile($fileName);
         }
         //$form = new Form( $this->file , $this->home, SYS_LANG, true );
         $Properties = dynaformEditorAjax::get_properties($A, $this->dyn_uid);
         /* Start Block: Prepare the XMLDB connection */
         define('DB_XMLDB_HOST', PATH_DYNAFORM . $this->file . '.xml');
         define('DB_XMLDB_USER', '');
         define('DB_XMLDB_PASS', '');
         define('DB_XMLDB_NAME', '');
         define('DB_XMLDB_TYPE', 'myxml');
         /* Start Block: Prepare the dynaformEditor */
         $G_PUBLISH = new Publisher();
         $sName = 'dynaformEditor';
         $G_PUBLISH->publisherId = $sName;
         $oHeadPublisher =& headPublisher::getSingleton();
         $oHeadPublisher->setTitle(G::LoadTranslation('ID_DYNAFORM_EDITOR') . ' - ' . $Properties['DYN_TITLE']);
         $G_PUBLISH->AddContent('blank');
         $this->panelConf['title'] = '';
         $G_PUBLISH->AddContent('panel-init', 'mainPanel', $this->panelConf);
         if ($Properties['DYN_TYPE'] == 'xmlform') {
             $G_PUBLISH->AddContent('xmlform', 'toolbar', 'dynaforms/fields_Toolbar', 'display:none', $Parameters, '', '');
         } else {
             $G_PUBLISH->AddContent('xmlform', 'toolbar', 'dynaforms/fields_ToolbarGrid', 'display:none', $Parameters, '', '');
         }
         $G_PUBLISH->AddContent('xmlform', 'xmlform', 'dynaforms/dynaforms_Editor', 'display:none', $Parameters, '', '');
         $G_PUBLISH->AddContent('xmlform', 'xmlform', 'dynaforms/dynaforms_XmlEditor', 'display:none', $XmlEditor, '', '');
         $G_PUBLISH->AddContent('blank');
         $i = 0;
         $aFields = array();
         $aFields[] = array('XMLNODE_NAME' => 'char', 'TYPE' => 'char', 'UP' => 'char', 'DOWN' => 'char');
         $oSession = new DBSession(new DBConnection(PATH_DYNAFORM . $this->file . '.xml', '', '', '', 'myxml'));
         $oDataset = $oSession->Execute('SELECT * FROM dynaForm WHERE NOT( XMLNODE_NAME = "" ) AND TYPE <> "pmconnection"');
         $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++;
             break;
         }
         global $_DBArray;
         $_DBArray['fields'] = $aFields;
         $_SESSION['_DBArray'] = $_DBArray;
         G::LoadClass('ArrayPeer');
         $oCriteria = new Criteria('dbarray');
         $oCriteria->setDBArrayTable('fields');
         /**
          * *@Erik-> this is deprecated,.
          * (unuseful) $G_PUBLISH->AddContent('propeltable', 'paged-table', 'dynaforms/fields_List', $oCriteria, $Parameters, '', SYS_URI.'dynaforms/dynaforms_PagedTableAjax');**
          */
         $G_PUBLISH->AddContent('blank');
         $G_PUBLISH->AddContent('xmlform', 'xmlform', 'dynaforms/dynaforms_JSEditor', 'display:none', $JSEditor, '', '');
     } catch (Exception $e) {
     }
     $G_PUBLISH->AddContent('xmlform', 'xmlform', 'dynaforms/dynaforms_Properties', 'display:none', $Properties, '', '');
     //for showHide tab option @Neyek
     $G_PUBLISH->AddContent('blank');
     $G_PUBLISH->AddContent('panel-tab', G::LoadTranslation("ID_PREVIEW"), $sName . '[3]', 'dynaformEditor.changeToPreview', 'dynaformEditor.saveCurrentView');
     $G_PUBLISH->AddContent('panel-tab', G::LoadTranslation("ID_XML"), $sName . '[4]', 'dynaformEditor.changeToXmlCode', 'dynaformEditor.saveCurrentView');
     if ($Properties['DYN_TYPE'] != 'grid') {
         $G_PUBLISH->AddContent('panel-tab', G::LoadTranslation("ID_HTML"), $sName . '[5]', 'dynaformEditor.changeToHtmlCode', 'dynaformEditor.saveCurrentView');
     }
     $G_PUBLISH->AddContent('panel-tab', G::LoadTranslation("ID_FIELDS_LIST"), $sName . '[6]', 'dynaformEditor.changeToFieldsList', 'dynaformEditor.saveCurrentView');
     if ($Properties["DYN_TYPE"] != "grid") {
         $G_PUBLISH->AddContent('panel-tab', G::LoadTranslation("ID_JAVASCRIPTS"), $sName . '[7]', 'dynaformEditor.changeToJavascripts', 'dynaformEditor.saveCurrentView');
     }
     $G_PUBLISH->AddContent('panel-tab', G::LoadTranslation("ID_PROPERTIES"), $sName . '[8]', 'dynaformEditor.changeToProperties', 'dynaformEditor.saveCurrentView');
     //for showHide tab option @Neyek
     if ($Properties["DYN_TYPE"] != "grid") {
         $G_PUBLISH->AddContent("panel-tab", G::LoadTranslation("ID_CONDITIONS_EDITOR"), $sName . "[9]", "dynaformEditor.changeToShowHide", "dynaformEditor.saveShowHide");
     }
     $G_PUBLISH->AddContent('panel-close');
     $oHeadPublisher->addScriptFile("/js/maborak/core/maborak.loader.js", 2);
     $oHeadPublisher->addScriptFile('/jscore/dynaformEditor/core/dynaformEditor.js');
     //$oHeadPublisher->addScriptFile('/js/dveditor/core/dveditor.js');
     //$oHeadPublisher->addScriptFile('/codepress/codepress.js',1);
     $oHeadPublisher->addScriptFile('/js/codemirrorOld/js/codemirror.js', 1);
     $oHeadPublisher->addScriptFile('/js/grid/core/grid.js');
     $oHeadPublisher->addScriptCode('
     var DYNAFORM_URL="' . $Parameters['URL'] . '";
     leimnud.event.add(window,"load",function(){ loadEditor(); });
     ');
     $oHeadPublisher->addScriptCode(' var jsMeta;var __usernameLogged__ = "' . (isset($_SESSION['USR_USERNAME']) ? $_SESSION['USR_USERNAME'] : '') . '";var SYS_LANG = "' . SYS_LANG . '";var __DYN_UID__ = "' . $this->dyn_uid . '";');
     $oHeadPublisher->addScriptCode('var dynaformEditorParams = \'' . serialize($Parameters) . '\';');
     G::RenderPage("publish", 'blank');
 }
$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', '');
define('DB_XMLDB_PASS', '');
define('DB_XMLDB_NAME', '');
define('DB_XMLDB_TYPE', 'myxml');
$title = $process->Fields['PRO_TITLE'] . ' : ' . $dynaform->Fields['DYN_TITLE'];
$Parameters = array('SYS_LANG' => SYS_LANG, 'URL' => G::encrypt($file, URL_KEY), 'DYN_UID' => $dynaform->Fields['DYN_UID'], 'DYNAFORM_NAME' => $title);
$openDoc = new Xml_Document();
$openDoc->parseXmlFile(PATH_DYNAFORM . $file . '.xml');
$XmlEditor = array('URL' => G::encrypt($file, URL_KEY), 'XML' => $openDoc->getXml());
$form = new Form($file, PATH_DYNAFORM, SYS_LANG, true);
$HtmlEditor = array('URL' => G::encrypt($file, URL_KEY), 'HTML' => $form->printTemplate($form->template, $script));
$JSEditor = array('URL' => G::encrypt($file, URL_KEY), 'HTML' => $form->printTemplate($form->template, $script));
/* Block : Loads the Editor configuration */
$defaultConfig = array('Editor' => array('left' => '0', 'top' => '0', 'width' => 'document.body.clientWidth-4', 'height' => 'document.body.clientHeight-2'), 'Toolbar' => array('left' => 'document.body.clientWidth-2-toolbar.clientWidth-24-3+7', 'top' => '52'), 'FieldsList' => array('left' => '4+toolbar.clientWidth+24', 'top' => 'getAbsoluteTop(document.getElementById("dynaformEditor[0]"))', 'width' => 268 - 24, 'height' => 400));
/*$configuration = new Configuration($dbc);
  $configuration->load( array('CFG_UID'=>'DynaformEditor') );
  if ($configuration->is_new) {
    $config = $defaultConfig;
    $configuration->Fields['CFG_UID']='DynaformEditor';
    $configuration->Fields['CFG_VALUE']=serialize( $config );
    //$configuration->Save();
  } else {