Spaces:
Sleeping
Sleeping
File size: 26,273 Bytes
07c3cdd | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 | <?php
/**
* Created on 21/12/2007
* Dynaform - Dynaform
/**
* DynaformEditorAjax - DynaformEditorAjax class
*
* @package workflow.engine.classes
*/
class DynaformEditorAjax extends DynaformEditor implements IDynaformEditorAjax
{
/**
* Constructor of the class dynaformEditorAjax
*
* @param var $post
* @return void
*/
public function __construct($post)
{
$this->_run($post);
}
/**
* Function Run
*
* @param var $post
* @return void
*/
public function _run($post)
{
WebResource::WebResource($_SERVER['REQUEST_URI'], $post);
}
/**
* Prints the DynaformEditorAjax
*
* @param object $A
* @return ob_get_clean
*/
public function render_preview($A)
{
ob_start();
$file = G::decrypt($A, URL_KEY);
global $G_PUBLISH;
$G_PUBLISH = new Publisher();
$G_PUBLISH->publisherId = 'preview';
$form = new Form($file, PATH_DYNAFORM, SYS_LANG, true, $G_PUBLISH->publisherId);
switch (basename($form->template, '.html')) {
case 'grid':
$template = 'grid';
$aAux = array_keys($form->fields);
if (count($aAux) > 0) {
$aFields = (array_combine($aAux, $aAux));
} else {
$aFields = $aAux;
}
if (is_array($aFields)) {
foreach ($aFields as $key => $val) {
$aFields[$key] = array(1 => "", 2 => "", 3 => "", 4 => "", 5 => "");
}
}
break;
default:
$template = 'xmlform_' . $G_PUBLISH->publisherId;
$aFields = array('__DYNAFORM_OPTIONS' => array('PREVIOUS_STEP' => '#', 'NEXT_STEP' => '#', 'NEXT_STEP_LABEL' => G::loadTranslation('ID_NEXT_STEP'), 'PREVIOUS_ACTION' => 'return false;', 'NEXT_ACTION' => 'return false;'
)
);
}
$G_PUBLISH->AddContent('dynaform', $template, $file, '', $aFields, '');
G::RenderPage('publish', 'raw');
return ob_get_clean();
}
/**
* Prints the Dynaform in format HTML
*
* @param object $A
* @return array
*/
public function render_htmledit($A)
{
$script = '';
$file = G::decrypt($A, URL_KEY);
ob_start();
global $G_PUBLISH;
$form = new Form($file, PATH_DYNAFORM, SYS_LANG, true);
$G_PUBLISH = new Publisher();
$G_PUBLISH->publisherId = '';
$html = $this->get_htmlcode($A);
if (!is_string($html)) {
$error = $html;
$html = '';
} else {
$error = 0;
}
$HtmlEditor = array('URL' => $A, 'HTML' => $html, 'DYN_UID' => $file );
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'dynaforms/dynaforms_HtmlEditor', '', $HtmlEditor, '', '');
G::RenderPage("publish", 'raw');
return array('error' => $error, 'html' => ob_get_clean()
);
}
/**
* Get the html code
* Loads the stored HTML or the default Template if
* it doesn't exist.
*
* @param object $A
* @return code html
*/
public function get_htmlcode($A)
{
try {
$script = null;
$fileTmp = G::decrypt($A, URL_KEY);
$form = new Form($fileTmp, PATH_DYNAFORM, SYS_LANG, true);
//Navigation Bar
$form->fields = G::array_merges(array("__DYNAFORM_OPTIONS" => new XmlFormFieldXmlMenu(new Xml_Node("__DYNAFORM_OPTIONS", "complete", "", array("type" => "xmlmenu", "xmlfile" => "gulliver/dynaforms_Options"
)), SYS_LANG, PATH_XMLFORM, $form)
), $form->fields);
//Loads the stored HTML or the default Template if
//it doesn't exist.
$filename = substr($form->fileName, 0, - 3) . ($form->type === "xmlform" ? "" : "." . $form->type) . "html";
if (!file_exists($filename)) {
$html = $form->printTemplate($form->template, $script);
} else {
$html = implode("", file($filename));
}
/*
* It adds the new fields automatically at the bottom of the form.
* TODO: �TOP OR BOTTOM?
* Improving detection algorithm of new fields.
* Current: Do not check the fields that have already been reviewed (saving)
* Already checked the temporary file dynaforms editor.
*/
$tmp = self::_getTmpData();
if (!isset($tmp['OLD_FIELDS'])) {
$tmp['OLD_FIELDS'] = array(); //var_dump($html);die;
}
$aAux = explode('</form>', $html);
foreach ($form->fields as $field) {
if ((strpos($html, '{$form.' . $field->name . '}') === false) && (strpos($html, '{$' . $field->name . '}') === false)) {
//Aparantly is new (but could be a deleted or non visible like private type fields)
switch (strtolower($field->type)) {
case 'private':
case 'phpvariable':
break;
default:
if (array_search($field->name, $tmp['OLD_FIELDS']) === false) {
//TOP
$aAux[0] .= '<br/>{$' . $field->name . '}' . '{$form.' . $field->name . '}';
//$html.='<br/>{$'.$field->name.'}'.'{$form.'.$field->name.'}';
//BOTTOM
//$html='{$'.$field->name.'}'.'{$form.'.$field->name.'}'.$html;
//$tmp['OLD_FIELDS'][]=$field->name;
}
}
}
}
self::_setTmpData($tmp);
//$html=str_replace('{$form_className}','formDefault', $html );
$html = str_replace('{$form_className}', 'formDefault', $aAux[0] . '</form>');
return $html;
} catch (Exception $e) {
return (array) $e;
}
}
/**
* Restore the html code
*
* @param object $A
* @return code html
*/
public function restore_html($A)
{
$filter = new InputFilter();
$script = null;
$fileTmp = G::decrypt($A, URL_KEY);
$form = new Form($fileTmp, PATH_DYNAFORM, SYS_LANG, true);
//Navigation Bar
$form->fields = G::array_merges(array("__DYNAFORM_OPTIONS" => new XmlFormFieldXmlMenu(new Xml_Node("__DYNAFORM_OPTIONS", "complete", "", array("type" => "xmlmenu", "xmlfile" => "gulliver/dynaforms_Options"
)), SYS_LANG, PATH_XMLFORM, $form)
), $form->fields);
$form->enableTemplate = false;
$html = $form->printTemplate($form->template, $script);
$html = str_replace('{$form_className}', 'formDefault', $html);
$pathTmp = $filter->xssFilterHard(PATH_DYNAFORM . $fileTmp . '.html', 'path');
if (file_exists($pathTmp)) {
unlink($pathTmp);
}
$fp = fopen($pathTmp, 'w');
fwrite($fp, $html);
fclose($fp);
return $html;
}
/**
* Set the html code
*
* @param object $A
* @return array
*/
public function set_htmlcode($A, $htmlcode)
{
try {
$filter = new InputFilter();
$iOcurrences = preg_match_all('/\{\$.*?\}/im', $htmlcode, $matches);
if ($iOcurrences) {
if (isset($matches[0])) {
$tagsHtml = $matches[0];
foreach ($tagsHtml as $value) {
$aTagVar = strip_tags($value);
if ($value != $aTagVar) {
$htmlcode = str_replace($value, $aTagVar, $htmlcode);
}
}
}
}
$file = G::decrypt($A, URL_KEY);
$form = new Form($file, PATH_DYNAFORM, SYS_LANG, true);
$filename = substr($form->fileName, 0, - 3) . ($form->type === 'xmlform' ? '' : '.' . $form->type) . 'html';
$filename = $filter->xssFilterHard($filename, 'path');
$fp = fopen($filename, 'w');
fwrite($fp, $htmlcode);
fclose($fp);
return 0;
} catch (Exception $e) {
return (array) $e;
}
}
/**
* Get the xml code
*
* @param object $A
* @return array
*/
public function get_xmlcode($A)
{
try {
$file = G::decrypt($A, URL_KEY);
$xmlcode = implode('', file(PATH_DYNAFORM . $file . '.xml'));
return array("xmlcode" => $xmlcode, "error" => 0
);
} catch (Exception $e) {
return array("xmlcode" => "", "error" => (array) $e
);
}
}
/**
* Set the xml code
*
* @param object $A
* @param array $xmlcode
* @return string
*/
public function set_xmlcode($A, $xmlcode)
{
$filter = new InputFilter();
$xmlcode = urldecode($xmlcode);
$file = G::decrypt($A, URL_KEY);
$xmlcode = str_replace(' ', ' ', trim($xmlcode));
$pathFile = $filter->xssFilterHard(PATH_DYNAFORM . $file . '.xml', "path");
$fp = fopen($pathFile, 'w');
fwrite($fp, $xmlcode);
fclose($fp);
return "";
}
/**
* Get the javascript code
*
* @param object $A
* @param string $fieldName
* @return array
*/
public function get_javascripts($A, $fieldName)
{
try {
$file = G::decrypt($A, URL_KEY);
$form = new Form($file, PATH_DYNAFORM, SYS_LANG, true);
$aOptions = array();
$sCode = '';
foreach ($form->fields as $name => $value) {
if (strcasecmp($value->type, "javascript") == 0) {
$aOptions[] = array('key' => $name, 'value' => $name
);
if ($name == $fieldName) {
$sCode = $value->code;
}
}
}
return array('aOptions' => $aOptions, 'sCode' => $sCode
);
} catch (Exception $e) {
return (array) $e;
}
}
/**
* Set the javascript code
*
* @param object $A
* @param string $fieldName
* @param string $sCode
* @return array
*/
public function set_javascript($A, $fieldName, $sCode, $meta = '')
{
$filter = new InputFilter();
$fieldName = $filter->xssFilterHard($fieldName, 'path');
if ($fieldName == '___pm_boot_strap___') {
return 0;
}
$sCode = urldecode($sCode);
try {
$sCode = rtrim($sCode);
$file = G::decrypt($A, URL_KEY);
/* $dbc2 = new DBConnection( PATH_DYNAFORM . $file . '.xml' ,'','','','myxml' );
$ses2 = new DBSession($dbc2);
$ses2->execute(G::replaceDataField("UPDATE dynaForm SET XMLNODE_VALUE = @@CODE WHERE XMLNODE_NAME = @@FIELDNAME ", array('FIELDNAME'=>$fieldName,'CODE'=>$sCode), "myxml" ));
*/
$pathFile = $filter->xssFilterHard(PATH_DYNAFORM . "{$file}.xml", 'path');
$dynaform = new DynaformHandler($pathFile);
$dynaform->replace($fieldName, $fieldName, Array('type' => 'javascript', 'meta' => $meta, '#cdata' => $sCode
));
return 0;
} catch (Exception $e) {
return (array) $e;
}
}
/**
* Get properties of the dynaForm
*
* @param file $A
* @param string $DYN_UID
* @return array
*/
public function get_properties($A, $DYN_UID)
{
$file = G::decrypt($A, URL_KEY);
$tmp = self::_getTmpData();
if (!(isset($tmp['Properties']) && isset($tmp['useTmpCopy']))) {
$dynaform = new Dynaform();
$dynaform->load($DYN_UID);
$form = new Form($file, PATH_DYNAFORM, SYS_LANG, true);
$Properties = array('A' => $A, 'DYN_UID' => $dynaform->getDynUid(), 'PRO_UID' => $dynaform->getProUid(), 'DYN_TITLE' => $dynaform->getDynTitle(), 'DYN_TYPE' => $dynaform->getDynType(), 'DYN_DESCRIPTION' => $dynaform->getDynDescription(), 'WIDTH' => $form->width,
//'ENABLETEMPLATE'=> $form->enableTemplate,
'MODE' => $form->mode, 'PRINTDYNAFORM' => $form->printdynaform, 'ADJUSTGRIDSWIDTH' => $form->adjustgridswidth, 'NEXTSTEPSAVE' => $form->nextstepsave
);
$tmp['Properties'] = $Properties;
self::_setTmpData($tmp);
} else {
$form = new Form($file, PATH_DYNAFORM, SYS_LANG, true);
$Properties = $tmp['Properties'];
if (!isset($Properties['ENABLETEMPLATE'])) {
$Properties['ENABLETEMPLATE'] = "0";
}
$Properties['WIDTH'] = $form->width;
$Properties['MODE'] = $form->mode;
}
return $Properties;
}
/**
* Set properties of the dynaForm
*
* @param file $A
* @param string $DYN_UID
* @param array $getFields
* @return array
*/
public function set_properties($A, $DYN_UID, $getFields)
{
try {
$filter = new InputFilter();
$post = array();
parse_str($getFields, $post);
$Fields = $post['form'];
//if (!isset($Fields['ENABLETEMPLATE'])) $Fields['ENABLETEMPLATE'] ="0";
$file = G::decrypt($A, URL_KEY);
$tmp = self::_getTmpData();
if (!isset($tmp['useTmpCopy'])) {
$dynaform = new Dynaform();
$dynaform->update($Fields);
} else {
$tmp['Properties'] = $Fields;
self::_setTmpData($tmp);
}
$pathFile = $filter->xssFilterHard(PATH_DYNAFORM . "{$file}.xml", 'path');
$dynaform = new DynaformHandler($pathFile);
$dbc2 = new DBConnection($pathFile, '', '', '', 'myxml');
$ses2 = new DBSession($dbc2);
//if (!isset($Fields['ENABLETEMPLATE'])) $Fields['ENABLETEMPLATE'] ="0";
/* if (isset($Fields['ENABLETEMPLATE'])) {
$ses2->execute(G::replaceDataField("UPDATE . SET ENABLETEMPLATE = @@ENABLETEMPLATE WHERE XMLNODE_NAME = 'dynaForm' ", $Fields));
} */
if (isset($Fields['DYN_TYPE'])) {
//$ses2->execute( G::replaceDataField( "UPDATE . SET TYPE = @@DYN_TYPE WHERE XMLNODE_NAME = 'dynaForm' ", $Fields ) );
$dynaform->modifyHeaderAttribute('type', $Fields['DYN_TYPE']);
}
if (isset($Fields['WIDTH'])) {
// $ses2->execute( G::replaceDataField( "UPDATE . SET WIDTH = @@WIDTH WHERE XMLNODE_NAME = 'dynaForm' ", $Fields ) );
$dynaform->modifyHeaderAttribute('width', $Fields['WIDTH']);
//g::pr($dynaform->getHeaderAttribute('width'));
}
if (isset($Fields['MODE'])) {
// $ses2->execute( G::replaceDataField( "UPDATE . SET MODE = @@MODE WHERE XMLNODE_NAME = 'dynaForm' ", $Fields ) );
$dynaform->modifyHeaderAttribute('mode', $Fields['MODE']);
}
if (isset($Fields['NEXTSTEPSAVE'])) {
//$ses2->execute( G::replaceDataField( "UPDATE . SET NEXTSTEPSAVE = @@NEXTSTEPSAVE WHERE XMLNODE_NAME = 'dynaForm' ", $Fields ) );
$dynaform->modifyHeaderAttribute('nextstepsave', $Fields['NEXTSTEPSAVE']);
}
if (isset($Fields['PRINTDYNAFORM'])) {
//$ses2->execute( G::replaceDataField( "UPDATE . SET PRINTDYNAFORM = @@PRINTDYNAFORM WHERE XMLNODE_NAME = 'dynaForm' ", $Fields ) );
$dynaform->modifyHeaderAttribute('printdynaform', $Fields['PRINTDYNAFORM']);
}
if (isset($Fields['ADJUSTGRIDSWIDTH'])) {
//$ses2->execute( G::replaceDataField( "UPDATE . SET ADJUSTGRIDSWIDTH = @@ADJUSTGRIDSWIDTH WHERE XMLNODE_NAME = 'dynaForm' ", $Fields ) );
$dynaform->modifyHeaderAttribute('adjustgridswidth', $Fields['ADJUSTGRIDSWIDTH']);
}
return 0;
} catch (Exception $e) {
return (array) $e;
}
}
/**
* Get enable template
*
* @param object $A
* @return string
*/
public function get_enabletemplate($A)
{
$file = G::decrypt($A, URL_KEY);
$form = new Form($file, PATH_DYNAFORM, SYS_LANG, true);
return $form->enableTemplate;
}
/**
* Set enable template
*
* @param object $A
* @param string $value
* @return string
*/
public function set_enabletemplate($A, $value)
{
$filter = new InputFilter();
$file = G::decrypt($A, URL_KEY);
$value = $value == "1" ? "1" : "0";
// $dbc2 = new DBConnection( PATH_DYNAFORM . $file . '.xml', '', '', '', 'myxml' );
// $ses2 = new DBSession( $dbc2 );
// $ses2->execute( "UPDATE . SET ENABLETEMPLATE = '$value'" );
$pathFile = $filter->xssFilterHard(PATH_DYNAFORM . "{$file}.xml", 'path');
$dynaform = new DynaformHandler($pathFile);
$dynaform->modifyHeaderAttribute('enabletemplate', $value);
return $value;
}
/**
* Save a dynaForm
*
* @param object $A
* @param string $DYN_UID
* @return array
*/
public function save($A, $DYN_UID)
{
try {
$answer = 0;
$file = G::decrypt($A, URL_KEY);
$tmp = self::_getTmpData();
if (isset($tmp['Properties'])){
$fileFirst = $tmp['Properties']['PRO_UID'].'/'.$tmp['Properties']['DYN_UID'];
}
if (isset($tmp['useTmpCopy'])) {
/* Save Register */
$dynaform = new Dynaform();
$dynaform->update($tmp['Properties']);
/* Save file */
$copyFirst = implode('', file(PATH_DYNAFORM . $fileFirst . '.xml'));
$copy = implode('', file(PATH_DYNAFORM . $file . '.xml'));
/*Check differences between XML*/
$elementFirst = new SimpleXMLElement($copyFirst);
$elementCopy = new SimpleXMLElement($copy);
$desAdd = '';
$desDel = '';
//Check the new fields
foreach ($elementCopy as $key1 => $row1){
$swAll = true;
foreach ($elementFirst as $key2 => $row2){
if ($key1 == $key2){
$swAll = false;
break;
}
}
if ($swAll){
$desAdd .= $key1." ";
}
}
//Check the delete fields
foreach ($elementFirst as $key1 => $row1){
$swAll = true;
foreach ($elementCopy as $key2 => $row2){
if ($key1 == $key2){
$swAll = false;
break;
}
}
if ($swAll){
$desDel .= $key1." ";
}
}
$mode = empty($tmp['Properties']['MODE'])? 'Determined by Fields' : $tmp['Properties']['MODE'];
$auditDescription = "Dynaform Title: ".$tmp['Properties']['DYN_TITLE'].", Type: ".$tmp['Properties']['DYN_TYPE'].", Description: ".$tmp['Properties']['DYN_DESCRIPTION'].", Mode: ".$mode;
if($desAdd != ''){
$auditDescription .= ", Field(s) Add: ".$desAdd;
}
if($desDel != ''){
$auditDescription .= ", Field(s) Delete: ".$desDel;
}
//Add Audit Log
G::auditLog("UpdateDynaform", $auditDescription);
/*
* added by krlos carlos/a/colosa.com
* in here we are validation if a xmlform has a submit action
*/
// if (!preg_match("/type=\"submit\"/",$copy) && !preg_match("/type=\"grid\"/",$copy) && !isset($_SESSION['submitAction']) ){
if (!preg_match("/type=\"submit\"/", $copy) && !preg_match("/type=\"grid\"/", $copy)) {
// $_SESSION['submitAction'] = 1;
$answer = 'noSub';
}
$copyHtml = false;
if (file_exists(PATH_DYNAFORM . $file . '.html')) {
$copyHtml = implode('', file(PATH_DYNAFORM . $file . '.html'));
}
$file = DynaformEditor::_getFilename($file);
$fcopy = fopen(PATH_DYNAFORM . $file . '.xml', "w");
fwrite($fcopy, $copy);
fclose($fcopy);
if ($copyHtml) {
$fcopy = fopen(PATH_DYNAFORM . $file . '.html', "w");
fwrite($fcopy, $copyHtml);
fclose($fcopy);
}
} else {
//throw new Exception("It should not come here unless you have disabled the temporary copy.");
}
return $answer;
} catch (Exception $e) {
return (array) $e;
}
}
/**
* Close a dynaform
*
* @param object $A
* @return array
*/
public function close($A)
{
try {
/*
* we are unseting this variable. It's our control about to save the xmlfrom
*/
// unset($_SESSION['submitAction']);
$file = G::decrypt($A, URL_KEY);
//return(array('response'=>PATH_DYNAFORM . $file . '.xml'));
/* Delete the temporal copy */
$tmp = self::_getTmpData();
$xmlFile = PATH_DYNAFORM . $file . '.xml';
$htmlFile = PATH_DYNAFORM . $file . '.html';
//return(array('response'=>$tmp['useTmpCopy']));
if (isset($tmp['useTmpCopy'])) {
//return(array('response'=>PATH_DYNAFORM . $file . '.xml'));
if ($file !== DynaformEditor::_getFilename($file)) {
// return(array('response'=>PATH_DYNAFORM . $file . '.xml'));
if (file_exists($xmlFile)) {
unlink($xmlFile);
}
if (file_exists($htmlFile)) {
unlink($htmlFile);
}
}
}
return 0;
} catch (Exception $e) {
return (array) $e;
}
}
/**
* Checks if a dynaform was changed
*
* @param file $A
* @param string $DYN_UID
* @return array
*/
public function is_modified($A, $DYN_UID)
{
$file = G::decrypt($A, URL_KEY);
try {
/* Compare Properties */
$dynaform = new Dynaform();
$dynaform->load($DYN_UID);
$form = new Form($file, PATH_DYNAFORM, SYS_LANG, true);
$sp = array('A' => $A, 'DYN_UID' => $dynaform->getDynUid(), 'PRO_UID' => $dynaform->getProUid(), 'DYN_TITLE' => $dynaform->getDynTitle(), 'DYN_TYPE' => $dynaform->getDynType(), 'DYN_DESCRIPTION' => $dynaform->getDynDescription(), 'WIDTH' => $form->width, 'ENABLETEMPLATE' => $form->enableTemplate, 'MODE' => $form->mode
);
$P = self::get_properties($A, $DYN_UID);
if (!isset($P['DYN_TITLE'])) {
$P['DYN_TITLE'] = $sp['DYN_TITLE'];
}
if (!isset($P['DYN_TYPE'])) {
$P['DYN_TYPE'] = $sp['DYN_TYPE'];
}
if (!isset($P['DYN_DESCRIPTION'])) {
$P['DYN_DESCRIPTION'] = $sp['DYN_DESCRIPTION'];
}
if (!isset($P['WIDTH'])) {
$P['WIDTH'] = $sp['WIDTH'];
}
if (!isset($P['ENABLETEMPLATE'])) {
$P['ENABLETEMPLATE'] = $sp['ENABLETEMPLATE'];
}
if (!isset($P['MODE'])) {
$P['MODE'] = $sp['MODE'];
}
$modPro = ($sp['DYN_TITLE'] != $P['DYN_TITLE']) || ($sp['DYN_TYPE'] != $P['DYN_TYPE']) || ($sp['DYN_DESCRIPTION'] != $P['DYN_DESCRIPTION']);
/* ||
($sp['WIDTH']!=$P['WIDTH']) ||
($sp['ENABLETEMPLATE']!=$P['ENABLETEMPLATE']) ||
($sp['MODE']!=$P['MODE']) */
/* Compare copies */
$fileOrigen = DynaformEditor::_getFilename($file);
$copy = implode('', file(PATH_DYNAFORM . $file . '.xml'));
$origen = implode('', file(PATH_DYNAFORM . $fileOrigen . '.xml'));
$copyHTML = file_exists(PATH_DYNAFORM . $file . '.html') ? implode('', file(PATH_DYNAFORM . $file . '.html')) : false;
$origenHTML = file_exists(PATH_DYNAFORM . $fileOrigen . '.html') ? implode('', file(PATH_DYNAFORM . $fileOrigen . '.html')) : false;
$modFile = ($copy !== $origen) || ($origenHTML && ($copyHTML !== $origenHTML));
//Return
//return array("*message"=>sprintf("%s, (%s= %s %s):", $modPro?"1":"0" , $modFile?"1":"0", ($copy!==$origen)?"1":"0" , ($origenHTML && ($copyHTML!==$origenHTML))?"1":"0" ));
//die("c'est fini");
return $modPro || $modFile;
} catch (Exception $e) {
return (array) $e;
}
}
/*
Functionality: Funcion que convierte objecto en array
Parameters : Object $object que queremos convertir
Return: Array
*/
public function convertObjectToArray($object){
if( !is_object( $object ) && !is_array( $object ) ){
return $object;
}
if( is_object( $object ) ){
$object = get_object_vars( $object );
}
return array_map( 'objectToArray', $object );
}
}
|