Example #1
0
    /**

     * Create Field Conditions from an array of Field Conditions and Dynaforms,

     * removing those Objects with the same UID, and recreaiting the records

     * from the arrays data.

     *

     * @param $aFieldCondition array.

     * @param $aDynaform array.

     * @return void

     */

    public function createFieldCondition ($aFieldCondition, $aDynaform)

    {

        if (is_array( $aFieldCondition )) {

            foreach ($aFieldCondition as $key => $row) {

                $oFieldCondition = new FieldCondition();

                if ($oFieldCondition->fieldConditionExists( $row['FCD_UID'], $aDynaform )) {

                    $oFieldCondition->remove( $row['FCD_UID'] );

                }

                $res = $oFieldCondition->create( $row );

            }

        }

        return;

    }
 * also handles the complete copy of field-events related and
 * the html template if its required too.
 */
require_once 'classes/model/Dynaform.php';
if (!class_exists("FieldCondition")) {
    require_once "classes/model/FieldCondition.php";
}
try {
    G::LoadSystem('inputfilter');
    $filter = new InputFilter();
    $frm = $_POST['form'];
    $PRO_UID = $frm['PRO_UID'];
    $DYN_UID = $frm['DYN_UID'];
    $DYN_TYPE = $frm['DYN_TYPE'];
    // checks if there are conditions attached to the dynaform
    $oFieldCondition = new FieldCondition();
    $aConditions = $oFieldCondition->getAllByDynUid($DYN_UID);
    $dynaform = new dynaform();
    $arrayData = array();
    $arrayData["PRO_UID"] = $PRO_UID;
    $arrayData["DYN_TYPE"] = $DYN_TYPE;
    $arrayData["DYN_TITLE"] = $frm["DYN_TITLENEW"];
    if (isset($frm["DYN_DESCRIPTIONNEW"])) {
        $arrayData["DYN_DESCRIPTION"] = $frm["DYN_DESCRIPTIONNEW"];
    }
    $aFields = $dynaform->create($arrayData);
    $dynUid = $dynaform->getDynUid();
    $hd = fopen(PATH_DYNAFORM . $PRO_UID . '/' . $DYN_UID . '.xml', "r");
    $hd1 = fopen(PATH_DYNAFORM . $PRO_UID . '/' . $dynUid . '.xml', "w");
    $templateFilename = PATH_DYNAFORM . $PRO_UID . '/' . $DYN_UID . '.html';
    $templateFilename = $filter->xssFilterHard($templateFilename, 'path');
 /**
  * It Renders content according to Part['Type']
  *
  * @author Fernando Ontiveros Lira <*****@*****.**>
  *
  * @param intPos = 0
  * @return void
  *
  */
 public function RenderContent0($intPos = 0, $showXMLFormName = false)
 {
     global $G_FORM;
     global $G_TABLE;
     global $G_TMP_TARGET;
     global $G_OP_MENU;
     global $G_IMAGE_FILENAME;
     global $G_IMAGE_PARTS;
     global $_SESSION;
     //Changed from $HTTP_SESSION_VARS
     global $G_OBJGRAPH;
     //For graphLayout component
     $this->intPos = $intPos;
     $Part = $this->Parts[$intPos];
     $this->publishType = $Part['Type'];
     switch ($this->publishType) {
         case 'externalContent':
             $G_CONTENT = new Content();
             if ($Part['Content'] != "") {
                 $G_CONTENT = G::LoadContent($Part['Content']);
             }
             G::LoadTemplateExternal($Part['Template']);
             break;
         case 'image':
             $G_IMAGE_FILENAME = $Part['File'];
             $G_IMAGE_PARTS = $Part['Data'];
             break;
         case 'appform':
             global $APP_FORM;
             $G_FORM = $APP_FORM;
             break;
         case 'xmlform':
         case 'dynaform':
             global $G_FORM;
             if ($Part['AbsolutePath']) {
                 $sPath = $Part['AbsolutePath'];
             } else {
                 if ($this->publishType == 'xmlform') {
                     $sPath = PATH_XMLFORM;
                 } else {
                     $sPath = PATH_DYNAFORM;
                 }
             }
             //if the xmlform file doesn't exists, then try with the plugins folders
             if (!is_file($sPath . $Part['File'] . '.xml')) {
                 $aux = explode(PATH_SEP, $Part['File']);
                 //check if G_PLUGIN_CLASS is defined, because publisher can be called without an environment
                 if (count($aux) > 2) {
                     //Subfolders
                     $filename = array_pop($aux);
                     $aux0 = implode(PATH_SEP, $aux);
                     $aux = array();
                     $aux[0] = $aux0;
                     $aux[1] = $filename;
                 }
                 if (count($aux) == 2 && defined('G_PLUGIN_CLASS')) {
                     $oPluginRegistry =& PMPluginRegistry::getSingleton();
                     if ($response = $oPluginRegistry->isRegisteredFolder($aux[0])) {
                         if ($response !== true) {
                             $sPath = PATH_PLUGINS . $response . PATH_SEP;
                         } else {
                             $sPath = PATH_PLUGINS;
                         }
                     }
                 }
             }
             if (!class_exists($Part['Template']) || $Part['Template'] === 'xmlform') {
                 $G_FORM = new Form($Part['File'], $sPath, SYS_LANG, false);
             } else {
                 eval('$G_FORM = new ' . $Part['Template'] . ' ( $Part[\'File\'] , "' . $sPath . '");');
             }
             if ($this->publishType == 'dynaform' && ($Part['Template'] == 'xmlform' || $Part['Template'] == 'xmlform_preview')) {
                 $dynaformShow = isset($G_FORM->printdynaform) && $G_FORM->printdynaform ? 'gulliver/dynaforms_OptionsPrint' : 'gulliver/dynaforms_Options';
                 $G_FORM->fields = G::array_merges(array('__DYNAFORM_OPTIONS' => new XmlForm_Field_XmlMenu(new Xml_Node('__DYNAFORM_OPTIONS', 'complete', '', array('type' => 'xmlmenu', 'xmlfile' => $dynaformShow, 'parentFormId' => $G_FORM->id)), SYS_LANG, PATH_XMLFORM, $G_FORM)), $G_FORM->fields);
             }
             //Needed to make ajax calls
             //The action in the form tag.
             if (defined('ENABLE_ENCRYPT') && ENABLE_ENCRYPT == 'yes') {
                 $G_FORM->action = urlencode(G::encrypt($Part['Target'], URL_KEY));
             } else {
                 $G_FORM->action = $Part['Target'];
             }
             if (!(isset($Part['ajaxServer']) && $Part['ajaxServer'] !== '')) {
                 if ($this->publishType == 'dynaform') {
                     $Part['ajaxServer'] = '../gulliver/defaultAjaxDynaform';
                 } else {
                     $Part['ajaxServer'] = '../gulliver/defaultAjax';
                 }
             }
             if (defined('ENABLE_ENCRYPT') && ENABLE_ENCRYPT == 'yes') {
                 $G_FORM->ajaxServer = urlencode(G::encrypt($Part['ajaxServer'], URL_KEY));
             } else {
                 $G_FORM->ajaxServer = $Part['ajaxServer'];
             }
             $G_FORM->setValues($Part['Data']);
             $G_FORM->setValues(array('G_FORM_ID' => $G_FORM->id));
             //Asegurese de que no entre cuando $Part['Template']=="grid"
             //de hecho soo deberia usarse cuando $Part['Template']=="xmlform"
             if ($this->publishType == 'dynaform' && $Part['Template'] == "xmlform" || $Part['Template'] == "xmlform") {
                 $G_FORM->values = G::array_merges(array('__DYNAFORM_OPTIONS' => isset($Part['Data']['__DYNAFORM_OPTIONS']) ? $Part['Data']['__DYNAFORM_OPTIONS'] : ''), $G_FORM->values);
                 if (isset($G_FORM->nextstepsave)) {
                     switch ($G_FORM->nextstepsave) {
                         // this condition validates if the next step link is configured to Save and Go the next step or show a prompt
                         case 'save':
                             // Save and Next only if there are no required fields can submit the form.
                             $G_FORM->values['__DYNAFORM_OPTIONS']['NEXT_ACTION'] = 'if (document.getElementById("' . $G_FORM->id . '")&&validateForm(document.getElementById(\'DynaformRequiredFields\').value)) {document.getElementById("' . $G_FORM->id . '").submit();}return false;';
                             break;
                         case 'prompt':
                             // Show Prompt only if there are no required fields can submit the form.
                             $G_FORM->values['__DYNAFORM_OPTIONS']['NEXT_ACTION'] = 'if (document.getElementById("' . $G_FORM->id . '")&&validateForm(document.getElementById(\'DynaformRequiredFields\').value)) {if(dynaFormChanged(document.getElementsByTagName(\'form\').item(0))) {new leimnud.module.app.confirm().make({label:"@G::LoadTranslation(ID_DYNAFORM_SAVE_CHANGES)", action:function(){document.getElementById("' . $G_FORM->id . '").submit();}.extend(this), cancel:function(){window.location = getField("DYN_FORWARD").href;}.extend(this)});return false;} else {window.location = getField("DYN_FORWARD").href;return false;}}return false;';
                             break;
                     }
                 }
             }
             if (isset($_SESSION)) {
                 $_SESSION[$G_FORM->id] = $G_FORM->values;
             }
             // by default load the core template
             if ($Part['Template'] == 'xmlform_preview') {
                 $Part['Template'] = 'xmlform';
             }
             $template = PATH_CORE . 'templates/' . $Part['Template'] . '.html';
             //erik: new feature, now templates such as xmlform.html can be personalized via skins
             if (defined('SYS_SKIN') && strtolower(SYS_SKIN) != 'classic') {
                 // First, verify if the template exists on Custom skins path
                 if (is_file(PATH_CUSTOM_SKINS . SYS_SKIN . PATH_SEP . $Part['Template'] . '.html')) {
                     $template = PATH_CUSTOM_SKINS . SYS_SKIN . PATH_SEP . $Part['Template'] . '.html';
                     //Second, verify if the template exists on base skins path
                 } elseif (is_file(G::ExpandPath("skinEngine") . SYS_SKIN . PATH_SEP . $Part['Template'] . '.html')) {
                     $template = G::ExpandPath("skinEngine") . SYS_SKIN . PATH_SEP . $Part['Template'] . '.html';
                 }
             }
             //end new feature
             if ($Part['Template'] == 'grid') {
                 print '<form class="formDefault">';
             }
             $scriptCode = '';
             if ($this->localMode != '') {
                 // @# las modification by erik in 09/06/2008
                 $G_FORM->mode = $this->localMode;
             }
             print $G_FORM->render($template, $scriptCode);
             if ($Part['Template'] == 'grid') {
                 print '</form>';
             }
             $oHeadPublisher =& headPublisher::getSingleton();
             $oHeadPublisher->addScriptFile($G_FORM->scriptURL);
             $oHeadPublisher->addScriptCode($scriptCode);
             /**
              * We've implemented the conditional show hide fields..
              *
              * @author Erik A. Ortiz <*****@*****.**>
              * @date Fri Feb 19, 2009
              */
             if ($this->publishType == 'dynaform') {
                 if (isset($_SESSION['CURRENT_DYN_UID']) || isset($_SESSION['CONDITION_DYN_UID'])) {
                     require_once "classes/model/FieldCondition.php";
                     $oFieldCondition = new FieldCondition();
                     //This dynaform has show/hide field conditions
                     if (isset($_SESSION['CURRENT_DYN_UID']) && $_SESSION['CURRENT_DYN_UID'] != '') {
                         $ConditionalShowHideRoutines = $oFieldCondition->getConditionScript($_SESSION["CURRENT_DYN_UID"]);
                         //lsl
                     } else {
                         if (isset($_SESSION['CONDITION_DYN_UID']) && $_SESSION['CONDITION_DYN_UID'] != '') {
                             $ConditionalShowHideRoutines = $oFieldCondition->getConditionScript($_SESSION["CONDITION_DYN_UID"]);
                             //lsl
                         }
                     }
                 }
             }
             if (isset($ConditionalShowHideRoutines) && $ConditionalShowHideRoutines) {
                 G::evalJScript($ConditionalShowHideRoutines);
             }
             break;
         case 'pagedtable':
             global $G_FORM;
             //if the xmlform file doesn't exists, then try with the plugins folders
             $sPath = PATH_XMLFORM;
             if (!is_file($sPath . $Part['File'])) {
                 $aux = explode(PATH_SEP, $Part['File']);
                 if (count($aux) == 2) {
                     $oPluginRegistry =& PMPluginRegistry::getSingleton();
                     if ($oPluginRegistry->isRegisteredFolder($aux[0])) {
                         $sPath = PATH_PLUGINS;
                         // . $aux[0] . PATH_SEP ;
                     }
                 }
             }
             $G_FORM = new Form($Part['File'], $sPath, SYS_LANG, true);
             if (defined('ENABLE_ENCRYPT') && ENABLE_ENCRYPT == 'yes') {
                 $G_FORM->ajaxServer = urlencode(G::encrypt($Part['ajaxServer'], URL_KEY));
             } else {
                 $G_FORM->ajaxServer = $Part['ajaxServer'];
             }
             $G_FORM->setValues($Part['Data']);
             if (isset($_SESSION)) {
                 $_SESSION[$G_FORM->id] = $G_FORM->values;
             }
             G::LoadSystem('pagedTable');
             $oTable = new pagedTable();
             $oTable->template = 'templates/' . $Part['Template'] . '.html';
             $G_FORM->xmlform = '';
             $G_FORM->xmlform->fileXml = $G_FORM->fileName;
             $G_FORM->xmlform->home = $G_FORM->home;
             $G_FORM->xmlform->tree->attribute = $G_FORM->tree->attributes;
             $G_FORM->values = array_merge($G_FORM->values, $Part['Data']);
             $oTable->setupFromXmlform($G_FORM);
             if (isset($Part['ajaxServer']) && $Part['ajaxServer'] !== '') {
                 $oTable->ajaxServer = $Part['ajaxServer'];
             }
             /* Start Block: Load user configuration for the pagedTable */
             G::LoadClass('configuration');
             $objUID = $Part['File'];
             $conf = new Configurations();
             $conf->loadConfig($oTable, 'pagedTable', $objUID, '', isset($_SESSION['USER_LOGGED']) ? $_SESSION['USER_LOGGED'] : '', '');
             $oTable->__OBJ_UID = $objUID;
             /* End Block */
             /* Start Block: PagedTable Right Click */
             G::LoadClass('popupMenu');
             $pm = new popupMenu('gulliver/pagedTable_PopupMenu');
             $pm->name = $oTable->id;
             $fields = array_keys($oTable->fields);
             foreach ($fields as $f) {
                 switch (strtolower($oTable->fields[$f]['Type'])) {
                     case 'javascript':
                     case 'button':
                     case 'private':
                     case 'hidden':
                     case 'cellmark':
                         break;
                     default:
                         $label = $oTable->fields[$f]['Label'] != '' ? $oTable->fields[$f]['Label'] : $f;
                         $label = str_replace("\n", ' ', $label);
                         $pm->fields[$f] = new XmlForm_Field_popupOption(new Xml_Node($f, 'complete', '', array('label' => $label, 'type' => 'popupOption', 'launch' => $oTable->id . '.showHideField("' . $f . '")')));
                         $pm->values[$f] = '';
                 }
             }
             $sc = '';
             $pm->values['PAGED_TABLE_ID'] = $oTable->id;
             print $pm->render(PATH_CORE . 'templates/popupMenu.html', $sc);
             /* End Block */
             $oTable->renderTable();
             /* Start Block: Load PagedTable Right Click */
             print '<script type="text/javascript">';
             print $sc;
             print 'loadPopupMenu_' . $oTable->id . '();';
             print '</script>';
             /* End Block */
             break;
         case 'propeltable':
             global $G_FORM;
             //if the xmlform file doesn't exists, then try with the plugins folders
             if ($Part['AbsolutePath']) {
                 $sPath = '';
             } else {
                 $sPath = PATH_XMLFORM;
             }
             if (!is_file($sPath . $Part['File'])) {
                 $aux = explode(PATH_SEP, $Part['File']);
                 //search in PLUGINS folder, probably the file is in plugin
                 if (count($aux) == 2) {
                     $oPluginRegistry =& PMPluginRegistry::getSingleton();
                     if ($oPluginRegistry->isRegisteredFolder($aux[0])) {
                         $sPath = PATH_PLUGINS;
                         // . $aux[0] . PATH_SEP ;
                     }
                 }
                 //search in PATH_DYNAFORM folder
                 if (!is_file($sPath . PATH_SEP . $Part['File'] . '.xml')) {
                     $sPath = PATH_DYNAFORM;
                 }
             }
             //PATH_DATA_PUBLIC ???
             if (!file_exists($sPath . PATH_SEP . $Part['File'] . '.xml') && defined('PATH_DATA_PUBLIC')) {
                 $sPath = PATH_DATA_PUBLIC;
             }
             $G_FORM = new Form($Part['File'], $sPath, SYS_LANG, true);
             if (defined('ENABLE_ENCRYPT') && ENABLE_ENCRYPT == 'yes') {
                 $G_FORM->ajaxServer = urlencode(G::encrypt($Part['ajaxServer'], URL_KEY));
             } else {
                 $G_FORM->ajaxServer = $Part['ajaxServer'];
             }
             if (isset($_SESSION)) {
                 $_SESSION[$G_FORM->id] = $G_FORM->values;
             }
             G::LoadClass('propelTable');
             $oTable = new propelTable();
             $oTable->template = $Part['Template'];
             $oTable->criteria = $Part['Content'];
             if (isset($Part['ajaxServer']) && $Part['ajaxServer'] !== '') {
                 $oTable->ajaxServer = $Part['ajaxServer'];
             }
             if (!isset($G_FORM->xmlform)) {
                 $G_FORM->xmlform = new stdclass();
             }
             $G_FORM->xmlform->fileXml = $G_FORM->fileName;
             $G_FORM->xmlform->home = $G_FORM->home;
             if (!isset($G_FORM->xmlform->tree)) {
                 $G_FORM->xmlform->tree = new stdclass();
             }
             $G_FORM->xmlform->tree->attribute = $G_FORM->tree->attributes;
             if (is_array($Part['Data'])) {
                 $G_FORM->values = array_merge($G_FORM->values, $Part['Data']);
             }
             $oTable->setupFromXmlform($G_FORM);
             /* Start Block: Load user configuration for the pagedTable */
             G::LoadClass('configuration');
             $objUID = $Part['File'];
             $conf = new Configurations($oTable);
             $conf->loadConfig($oTable, 'pagedTable', $objUID, '', isset($_SESSION['USER_LOGGED']) ? $_SESSION['USER_LOGGED'] : '', '');
             $oTable->__OBJ_UID = $objUID;
             //$oTable->__OBJ_UID = '';
             /* End Block */
             /* Start Block: PagedTable Right Click */
             G::LoadClass('popupMenu');
             $pm = new popupMenu('gulliver/pagedTable_PopupMenu');
             $sc = $pm->renderPopup($oTable->id, $oTable->fields);
             /* End Block */
             //krumo ( $Part );
             if ($this->ROWS_PER_PAGE) {
                 $oTable->rowsPerPage = $this->ROWS_PER_PAGE;
             }
             try {
                 if (is_array($Part['Data'])) {
                     $oTable->renderTable('', $Part['Data']);
                 } else {
                     $oTable->renderTable();
                 }
                 print $sc;
             } catch (Exception $e) {
                 $aMessage['MESSAGE'] = $e->getMessage();
                 $this->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $aMessage);
             }
             break;
         case 'panel-init':
             global $mainPanelScript;
             global $panelName;
             global $tabCount;
             //G::LoadThirdParty( 'pear/json', 'class.json' );
             //$json = new Services_JSON();
             $tabCount = 0;
             $panelName = $Part['Template'];
             $data = $Part['File'];
             if (!is_array($data)) {
                 $data = array();
             }
             $data = G::array_merges(array('title' => '', 'style' => array(), 'left' => 'getAbsoluteLeft(mycontent)', 'top' => 'getAbsoluteTop(mycontent)', 'width' => 700, 'height' => 600, 'drag' => true, 'close' => true, 'modal' => true, 'roll' => false, 'resize' => false, 'tabWidth' => 120, 'tabStep' => 3, 'blinkToFront' => true, 'tabSpace' => 10), $data);
             $mainPanelScript = 'var ' . $panelName . '={},' . $panelName . 'Tabs=[];' . 'leimnud.event.add(window,"load",function(){' . $panelName . ' = new leimnud.module.panel();' . 'var mycontent=document.getElementById("' . $this->publisherId . '[' . $intPos . ']");' . $panelName . '.options={' . 'size:{w:' . $data['width'] . ',h:' . $data['height'] . '},' . 'position:{x:' . $data['left'] . ',y:' . $data['top'] . '},' . 'title:"' . addcslashes($data['title'], '\\"') . '",' . 'theme:"processmaker",' . 'statusBar:true,' . 'headerBar:true,' . 'control:{' . ' close:' . ($data['close'] ? 'true' : 'false') . ',' . ' roll:' . ($data['roll'] ? 'true' : 'false') . ',' . ' drag:' . ($data['drag'] ? 'true' : 'false') . ',' . ' resize:' . ($data['resize'] ? 'true' : 'false') . '},' . 'fx:{' . ' drag:' . ($data['drag'] ? 'true' : 'false') . ',' . ' modal:' . ($data['modal'] ? 'true' : 'false') . ',' . ' blinkToFront:' . ($data['blinkToFront'] ? 'true' : 'false') . '}' . '};' . $panelName . '.setStyle=' . Bootstrap::json_encode($data['style']) . ';' . $panelName . '.tab={' . 'width:' . ($data['tabWidth'] + $data['tabSpace']) . ',' . 'optWidth:' . $data['tabWidth'] . ',' . 'step :' . $data['tabStep'] . ',' . 'options:[]' . '};';
             print ' ';
             break;
         case 'panel-tab':
             global $tabCount;
             global $mainPanelScript;
             global $panelName;
             $onChange = $Part['Content'];
             $beforeChange = $Part['Data'];
             if (SYS_LANG == 'es') {
                 $mainPanelScript = str_replace("120", "150", $mainPanelScript);
             } else {
                 $mainPanelScript = str_replace("150", "120", $mainPanelScript);
             }
             $mainPanelScript .= $panelName . 'Tabs[' . $tabCount . ']=' . 'document.getElementById("' . $Part['File'] . '");' . $panelName . '.tab.options[' . $panelName . '.tab.options.length]=' . '{' . 'title  :"' . addcslashes($Part['Template'], '\\"') . '",' . 'noClear  :true,' . 'content  :function(){' . ($beforeChange != '' ? 'if (typeof(' . $beforeChange . ')!=="undefined") {' . $beforeChange . '();}' : '') . $panelName . 'Clear();' . $panelName . 'Tabs[' . $tabCount . '].style.display="";' . ($onChange != '' ? 'if (typeof(' . $onChange . ')!=="undefined") {' . $onChange . '();}' : '') . '}.extend(' . $panelName . '),' . 'selected:' . ($tabCount == 0 ? 'true' : 'false') . '};';
             $tabCount++;
             break;
         case 'panel-close':
             global $mainPanelScript;
             global $panelName;
             global $tabCount;
             $mainPanelScript .= $panelName . '.make();';
             $mainPanelScript .= 'for(var r=0;r<' . $tabCount . ';r++)' . 'if (' . $panelName . 'Tabs[r])' . $panelName . '.addContent(' . $panelName . 'Tabs[r]);';
             $mainPanelScript .= '});';
             $mainPanelScript .= 'function ' . $panelName . 'Clear(){';
             $mainPanelScript .= 'for(var r=0;r<' . $tabCount . ';r++)' . 'if (' . $panelName . 'Tabs[r])' . $panelName . 'Tabs[r].style.display="none";}';
             $oHeadPublisher =& headPublisher::getSingleton();
             $oHeadPublisher->addScriptCode($mainPanelScript);
             break;
         case 'blank':
             print ' ';
             break;
         case 'varform':
             global $G_FORM;
             $G_FORM = new Form();
             G::LoadSystem("varform");
             $xml = new varForm();
             //$xml->parseFile (  );
             $xml->renderForm($G_FORM, $Part['File']);
             $G_FORM->Values = $Part['Data'];
             $G_FORM->SetUp($Part['Target']);
             $G_FORM->width = 500;
             break;
         case 'table':
             $G_TMP_TARGET = $Part['Target'];
             $G_TABLE = G::LoadRawTable($Part['File'], $this->dbc, $Part['Data']);
             break;
         case 'menu':
             $G_TMP_TARGET = $Part['Target'];
             $G_OP_MENU = new Menu();
             $G_OP_MENU->Load($Part['File']);
             break;
         case 'smarty':
             //To do: Please check it 26/06/07
             $template = new Smarty();
             $template->compile_dir = PATH_SMARTY_C;
             $template->cache_dir = PATH_SMARTY_CACHE;
             $template->config_dir = PATH_THIRDPARTY . 'smarty/configs';
             $template->caching = false;
             $dataArray = $Part['Data'];
             // verify if there are templates folders registered, template and method folders are the same
             $folderTemplate = explode('/', $Part['Template']);
             $oPluginRegistry =& PMPluginRegistry::getSingleton();
             if ($oPluginRegistry->isRegisteredFolder($folderTemplate[0])) {
                 $template->templateFile = PATH_PLUGINS . $Part['Template'] . '.html';
             } else {
                 $template->templateFile = PATH_TPL . $Part['Template'] . '.html';
             }
             // last change to load the template, maybe absolute path was given
             if (!is_file($template->templateFile)) {
                 $template->templateFile = strpos($Part['Template'], '.html') !== false ? $Part['Template'] : $Part['Template'] . '.html';
             }
             //assign the variables and use the template $template
             $template->assign($dataArray);
             print $template->fetch($template->templateFile);
             break;
         case 'template':
             //To do: Please check it 26/06/07
             if (gettype($Part['Data']) == 'array') {
                 G::LoadSystem('template');
                 //template phpBB
                 $template = new Template();
                 $template->set_filenames(array('body' => $Part['Template'] . '.html'));
                 $dataArray = $Part['Data'];
                 if (is_array($dataArray)) {
                     foreach ($dataArray as $key => $val) {
                         if (is_array($val)) {
                             foreach ($val as $key_val => $val_array) {
                                 $template->assign_block_vars($key, $val_array);
                             }
                         } else {
                             $template->assign_vars(array($key => $val));
                         }
                     }
                 }
                 $template->pparse('body');
             }
             if (gettype($Part['Data']) == 'object' && strtolower(get_class($Part['Data'])) == 'templatepower') {
                 $Part['Data']->printToScreen();
             }
             return;
             break;
         case 'view':
         case 'content':
             //check if G_PLUGIN_CLASS is defined, because publisher can be called without an environment
             $aux = explode(PATH_SEP, $Part['Template']);
             if (count($aux) == 2 && defined('G_PLUGIN_CLASS')) {
                 //if the template doesn't exists, then try it with the plugins folders, after the normal Template
                 $userTemplate = G::ExpandPath('templates') . $Part['Template'];
                 $globalTemplate = PATH_TEMPLATE . $Part['Template'];
                 if (!is_file($userTemplate) && !is_file($globalTemplate)) {
                     $oPluginRegistry =& PMPluginRegistry::getSingleton();
                     if ($oPluginRegistry->isRegisteredFolder($aux[0])) {
                         $pluginTemplate = PATH_PLUGINS . $Part['Template'] . '.php';
                         include $pluginTemplate;
                     }
                 }
             }
             break;
         case 'graphLayout':
             //Added by JHL to render GraphLayout component
             $G_OBJGRAPH = $Part['Data'];
             $G_TMP_TARGET = $Part['Target'];
             $G_TMP_FILE = $Part['File'];
             break;
     }
     //krumo( $Part['Template'] );
     //check if this LoadTemplate is used, byOnti 12th Aug 2008
     G::LoadTemplate($Part['Template']);
     $G_TABLE = null;
 }
Example #4
0
 /**
  * Copy/Import a DynaForm
  *
  * @param string $processUid Unique id of Process
  * @param array  $arrayData  Data
  *
  * return array Return data of the new DynaForm created
  */
 public function copyImport($processUid, $arrayData)
 {
     try {
         $arrayData = \G::array_change_key_case2($arrayData, CASE_UPPER);
         unset($arrayData["DYN_UID"]);
         unset($arrayData["PMTABLE"]);
         //Verify data
         $process = new \ProcessMaker\BusinessModel\Process();
         $process->throwExceptionIfNotExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]);
         $process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, true);
         if (!isset($arrayData["COPY_IMPORT"])) {
             throw new \Exception(\G::LoadTranslation("ID_UNDEFINED_VALUE_IS_REQUIRED", array($this->getFieldNameByFormatFieldName("COPY_IMPORT"))));
         }
         if (!isset($arrayData["COPY_IMPORT"]["PRJ_UID"])) {
             throw new \Exception(\G::LoadTranslation("ID_UNDEFINED_VALUE_IS_REQUIRED", array($this->getFieldNameByFormatFieldName("COPY_IMPORT.PRJ_UID"))));
         }
         $arrayData["COPY_IMPORT"]["PRJ_UID"] = trim($arrayData["COPY_IMPORT"]["PRJ_UID"]);
         if ($arrayData["COPY_IMPORT"]["PRJ_UID"] == "") {
             throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_CAN_NOT_BE_EMPTY", array($this->getFieldNameByFormatFieldName("COPY_IMPORT.PRJ_UID"))));
         }
         if (!isset($arrayData["COPY_IMPORT"]["DYN_UID"])) {
             throw new \Exception(\G::LoadTranslation("ID_UNDEFINED_VALUE_IS_REQUIRED", array($this->getFieldNameByFormatFieldName("COPY_IMPORT.DYN_UID"))));
         }
         $arrayData["COPY_IMPORT"]["DYN_UID"] = trim($arrayData["COPY_IMPORT"]["DYN_UID"]);
         if ($arrayData["COPY_IMPORT"]["DYN_UID"] == "") {
             throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_CAN_NOT_BE_EMPTY", array($this->getFieldNameByFormatFieldName("COPY_IMPORT.DYN_UID"))));
         }
         $this->throwExceptionIfExistsTitle($processUid, $arrayData["DYN_TITLE"], $this->arrayFieldNameForException["dynaFormTitle"]);
         //Copy/Import Uids
         $processUidCopyImport = $arrayData["COPY_IMPORT"]["PRJ_UID"];
         $dynaFormUidCopyImport = $arrayData["COPY_IMPORT"]["DYN_UID"];
         //Verify data
         $process->throwExceptionIfNotExistsProcess($processUidCopyImport, $this->getFieldNameByFormatFieldName("COPY_IMPORT.PRJ_UID"));
         $this->throwExceptionIfNotExistsDynaForm($dynaFormUidCopyImport, $processUidCopyImport, $this->getFieldNameByFormatFieldName("COPY_IMPORT.DYN_UID"));
         //Copy/Import
         //Copy content if version is 2
         if ($arrayData["DYN_VERSION"] === 2) {
             $dynaFormOld = new \Dynaform();
             $arrayDynaFormData = $dynaFormOld->Load($dynaFormUidCopyImport);
             $arrayData["DYN_CONTENT"] = $arrayDynaFormData["DYN_CONTENT"];
         }
         //Create
         $arrayData = $this->create($processUid, $arrayData);
         $dynaFormUid = $arrayData[$this->getFieldNameByFormatFieldName("DYN_UID")];
         //Copy files of the DynaForm
         $umaskOld = umask(0);
         $fileXml = PATH_DYNAFORM . $processUidCopyImport . PATH_SEP . $dynaFormUidCopyImport . ".xml";
         if (file_exists($fileXml)) {
             $fileXmlCopy = PATH_DYNAFORM . $processUid . PATH_SEP . $dynaFormUid . ".xml";
             $fhXml = fopen($fileXml, "r");
             $fhXmlCopy = fopen($fileXmlCopy, "w");
             while (!feof($fhXml)) {
                 $strLine = fgets($fhXml, 4096);
                 $strLine = str_replace($processUidCopyImport . "/" . $dynaFormUidCopyImport, $processUid . "/" . $dynaFormUid, $strLine);
                 //DynaForm Grid
                 preg_match_all("/<.*type\\s*=\\s*[\"\\']grid[\"\\'].*xmlgrid\\s*=\\s*[\"\\']\\w{32}\\/(\\w{32})[\"\\'].*\\/>/", $strLine, $arrayMatch, PREG_SET_ORDER);
                 foreach ($arrayMatch as $value) {
                     $dynaFormGridUidCopyImport = $value[1];
                     //Get data
                     $criteria = new \Criteria();
                     $criteria->addSelectColumn(\ContentPeer::CON_VALUE);
                     $criteria->add(\ContentPeer::CON_ID, $dynaFormGridUidCopyImport);
                     $criteria->add(\ContentPeer::CON_CATEGORY, "DYN_TITLE");
                     $criteria->add(\ContentPeer::CON_LANG, SYS_LANG);
                     $rsCriteria = \ContentPeer::doSelectRS($criteria);
                     $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
                     $rsCriteria->next();
                     $row = $rsCriteria->getRow();
                     $dynGrdTitleCopyImport = $row["CON_VALUE"];
                     $criteria = new \Criteria();
                     $criteria->addSelectColumn(\ContentPeer::CON_VALUE);
                     $criteria->add(\ContentPeer::CON_ID, $dynaFormGridUidCopyImport);
                     $criteria->add(\ContentPeer::CON_CATEGORY, "DYN_DESCRIPTION");
                     $criteria->add(\ContentPeer::CON_LANG, SYS_LANG);
                     $rsCriteria = \ContentPeer::doSelectRS($criteria);
                     $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
                     $rsCriteria->next();
                     $row = $rsCriteria->getRow();
                     $dynGrdDescriptionCopyImport = $row["CON_VALUE"];
                     //Create Grid
                     $dynaFormGrid = new \Dynaform();
                     $arrayDataAux = array("PRO_UID" => $processUid, "DYN_TITLE" => $dynGrdTitleCopyImport . ($this->existsTitle($processUid, $dynGrdTitleCopyImport) ? " (" . $arrayData["DYN_TITLE"] . ")" : ""), "DYN_DESCRIPTION" => $dynGrdDescriptionCopyImport, "DYN_TYPE" => "grid");
                     $dynaFormGridUid = $dynaFormGrid->create($arrayDataAux);
                     //Copy files of the DynaForm Grid
                     $fileGridXml = PATH_DYNAFORM . $processUidCopyImport . PATH_SEP . $dynaFormGridUidCopyImport . ".xml";
                     if (file_exists($fileGridXml)) {
                         $fileGridXmlCopy = PATH_DYNAFORM . $processUid . PATH_SEP . $dynaFormGridUid . ".xml";
                         $fhGridXml = fopen($fileGridXml, "r");
                         $fhGridXmlCopy = fopen($fileGridXmlCopy, "w");
                         while (!feof($fhGridXml)) {
                             $strLineAux = fgets($fhGridXml, 4096);
                             $strLineAux = str_replace($processUidCopyImport . "/" . $dynaFormGridUidCopyImport, $processUid . "/" . $dynaFormGridUid, $strLineAux);
                             fwrite($fhGridXmlCopy, $strLineAux);
                         }
                         fclose($fhGridXmlCopy);
                         fclose($fhGridXml);
                         chmod($fileGridXmlCopy, 0777);
                     }
                     $fileGridHtml = PATH_DYNAFORM . $processUidCopyImport . PATH_SEP . $dynaFormGridUidCopyImport . ".html";
                     if (file_exists($fileGridHtml)) {
                         $fileGridHtmlCopy = PATH_DYNAFORM . $processUid . PATH_SEP . $dynaFormGridUid . ".html";
                         copy($fileGridHtml, $fileGridHtmlCopy);
                         chmod($fileGridHtmlCopy, 0777);
                     }
                     $strLine = str_replace($processUidCopyImport . "/" . $dynaFormGridUidCopyImport, $processUid . "/" . $dynaFormGridUid, $strLine);
                 }
                 fwrite($fhXmlCopy, $strLine);
             }
             fclose($fhXmlCopy);
             fclose($fhXml);
             chmod($fileXmlCopy, 0777);
         }
         $fileHtml = PATH_DYNAFORM . $processUidCopyImport . PATH_SEP . $dynaFormUidCopyImport . ".html";
         if (file_exists($fileHtml)) {
             $fileHtmlCopy = PATH_DYNAFORM . $processUid . PATH_SEP . $dynaFormUid . ".html";
             copy($fileHtml, $fileHtmlCopy);
             chmod($fileHtmlCopy, 0777);
         }
         //Copy if there are conditions attached to the DynaForm
         $fieldCondition = new \FieldCondition();
         $arrayCondition = $fieldCondition->getAllByDynUid($dynaFormUidCopyImport);
         foreach ($arrayCondition as $condition) {
             $condition["FCD_UID"] = "";
             $condition["FCD_DYN_UID"] = $dynaFormUid;
             $fieldCondition->quickSave($condition);
         }
         umask($umaskOld);
         //Return
         return $arrayData;
     } catch (\Exception $e) {
         throw $e;
     }
 }
            $aFields = array();
            $aFieldsTmp = $sFields == '' ? array() : explode(',', $sFields);
            $i = 1;
            foreach ($aFieldsTmp as $aField) {
                $aFields['gFields'][$i++] = array('dynaid' => $aField, 'dynafield' => $aField, 'dynavalue' => '');
            }
            if (sizeof($aFields) > 0) {
                $G_PUBLISH->AddContent('xmlform', 'xmlform', 'dynaforms/dynaforms_ConditionalShowHideTest', '', $aFields);
                G::RenderPage('publish', 'raw');
            } else {
                print 'false';
            }
            break;
        case 'save':
            require_once 'classes/model/FieldCondition.php';
            $oFieldCondition = new FieldCondition();
            $aDYN = $_SESSION['Current_Dynafom']['Parameters'];
            $_POST['FCD_UID'] = $_POST['FCD_UID'] == '0' ? '' : $_POST['FCD_UID'];
            $aData = array('FCD_UID' => isset($_POST['FCD_UID']) ? $_POST['FCD_UID'] : '', 'FCD_FUNCTION' => $_POST['function'], 'FCD_FIELDS' => $_POST['fields_selected'], 'FCD_CONDITION' => $_POST['condition'], 'FCD_EVENTS' => $_POST['events'], 'FCD_EVENT_OWNERS' => $_POST['event_owner_selected'], 'FCD_STATUS' => $_POST['enabled'], 'FCD_DYN_UID' => $aDYN['DYN_UID']);
            $oFieldCondition->quickSave($aData);
            break;
        case 'delete':
            require_once 'classes/model/FieldCondition.php';
            $oFieldCondition = FieldConditionPeer::retrieveByPk($_POST['FCD_UID']);
            if (is_object($oFieldCondition)) {
                $oFieldCondition->delete();
            }
            break;
    }
} catch (Exception $e) {
    print $e->getMessage();
Example #6
0
 public function create($aData)
 {
     $oConnection = Propel::getConnection(FieldConditionPeer::DATABASE_NAME);
     try {
         // $aData['FCD_UID'] = '';
         if (isset($aData['FCD_UID']) && $aData['FCD_UID'] == '') {
             unset($aData['FCD_UID']);
         }
         if (!isset($aData['FCD_UID'])) {
             $aData['FCD_UID'] = G::generateUniqueID();
         }
         $oFieldCondition = new FieldCondition();
         $oFieldCondition->fromArray($aData, BasePeer::TYPE_FIELDNAME);
         if ($oFieldCondition->validate()) {
             $oConnection->begin();
             $iResult = $oFieldCondition->save();
             $oConnection->commit();
             return true;
         } else {
             $sMessage = '';
             $aValidationFailures = $oFieldCondition->getValidationFailures();
             foreach ($aValidationFailures as $oValidationFailure) {
                 $sMessage .= $oValidationFailure->getMessage() . '<br />';
             }
             throw new Exception('The registry cannot be created!<br />' . $sMessage);
         }
     } catch (Exception $oError) {
         $oConnection->rollback();
         throw $oError;
     }
 }
                 $strLine = str_replace($aData["COPY_PROCESS_UID"] . "/" . $copyDynaformGridUid, $aData["PRO_UID"] . "/" . $dynaformGridUid, $strLine);
             }
             fwrite($fhXmlCopy, $strLine);
         }
         fclose($fhXmlCopy);
         fclose($fhXml);
         chmod($fileXmlCopy, 0777);
     }
     $fileHtml = PATH_DYNAFORM . $aData["COPY_PROCESS_UID"] . PATH_SEP . $aData["COPY_DYNAFORM_UID"] . ".html";
     if (file_exists($fileHtml)) {
         $fileHtmlCopy = PATH_DYNAFORM . $aData["PRO_UID"] . PATH_SEP . $dynaformUid . ".html";
         copy($fileHtml, $fileHtmlCopy);
         chmod($fileHtmlCopy, 0777);
     }
     //Copy if there are conditions attached to the dynaform
     $fieldCondition = new FieldCondition();
     $arrayCondition = $fieldCondition->getAllByDynUid($aData["COPY_DYNAFORM_UID"]);
     foreach ($arrayCondition as $condition) {
         $condition["FCD_UID"] = "";
         $condition["FCD_DYN_UID"] = $dynaformUid;
         $fieldCondition->quickSave($condition);
     }
     umask($umaskOld);
     break;
 default:
     //normal
     //pmtable
     if (!isset($aData["ADD_TABLE"]) || $aData["ADD_TABLE"] == "") {
         $aFields = $dynaform->create($aData);
     } else {
         $aFields = $dynaform->createFromPMTable($aData, $aData["ADD_TABLE"]);
 * 
 * For more information, contact Colosa Inc, 2566 Le Jeune Rd., 
 * Coral Gables, FL, 33134, USA, or email info@colosa.com.
 * 
 */
/*
 * @Author Erik Amaru Ortiz <*****@*****.**>
 * @Date Aug 26th, 2009 
 */
require_once "classes/model/FieldCondition.php";
G::LoadClass('ArrayPeer');
$G_PUBLISH = new Publisher();
$oHeadPublisher =& headPublisher::getSingleton();
$DISPLAY_MAX_SIZE = 25;
global $_DBArray;
$oFieldCondition = new FieldCondition();
$DYN_UID = $_SESSION['Current_Dynafom']['Parameters']['DYN_UID'];
$aRows = $oFieldCondition->getAllByDynUid($DYN_UID);
$aFieldNames = array('FCD_NRO', 'FCD_UID', 'FCD_FUNCTION', 'FCD_FIELDS', 'FCD_CONDITION', 'FCD_EVENTS', 'FCD_EVENT_OWNERS', 'FCD_STATUS', 'FCD_DYN_UID');
//Routines to limit the show in list max size for some fields that can have large size
$inndex = 0;
$aRowsTmp = array();
foreach ($aRows as $aRow) {
    $aRow['FCD_NRO'] = ++$inndex;
    if (strlen($aRow['FCD_FIELDS']) > $DISPLAY_MAX_SIZE) {
        $aRow['FCD_FIELDS'] = substr($aRow['FCD_FIELDS'], 0, $DISPLAY_MAX_SIZE) . '...';
    }
    if ($aRow['FCD_FUNCTION'] == 'showAll' || $aRow['FCD_FUNCTION'] == 'hideAll') {
        $aRow['FCD_FIELDS'] = 'ALL';
    }
    if (strlen($aRow['FCD_CONDITION']) > $DISPLAY_MAX_SIZE) {