function getJforms($files) { require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'config.php'; require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'jformrender.php'; /* if (!OPCJ3) { require_once(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_onepage'.DS.'helpers'.DS.'opcparameters.php'); } else { } */ $ret = array(); foreach ($files as $file) { $path = JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'xmlexport' . DS . 'php' . DS . $file . '.xml'; if (!file_exists($path)) { continue; } //$data = new stdClass(); //$data->adwords_id = 1; $data = $this->getThemeConfig($file); $title = $description = ''; if (function_exists('simplexml_load_file')) { $fullxml = simplexml_load_file($path); $title = $fullxml->name; $description = $fullxml->description; } else { return; } $xml = file_get_contents($path); $xml = str_replace('extension', 'form', $xml); $xml = str_replace('params', 'fieldset', $xml); $xml = str_replace('<fieldset', '<fields name="' . $file . '"><fieldset name="test" label="' . $title . '" ', $xml); $xml = str_replace('param', 'field', $xml); $xml = str_replace('</fieldset>', '</fieldset></fields>', $xml); //$fullxml = simplexml_load_string($xml); // removes BOM: $bom = pack('H*', 'EFBBBF'); $text = preg_replace("/^{$bom}/", '', $xml); if (!empty($text)) { $xml = $text; } //echo $file; @ob_get_clean(); @ob_get_clean(); @ob_get_clean(); @ob_get_clean(); @ob_get_clean(); @ob_get_clean(); @ob_get_clean(); //echo $xml; $t1 = simplexml_load_string($xml); if ($t1 === false) { continue; } //die(); $test = JForm::getInstance($file, $xml, array(), true); //$test->bind($data); foreach ($data as $k => $vl) { $test->setValue($k, $file, $vl); } //debug_zval_dump($test); $fieldSets = $test->getFieldsets(); //var_dump($fieldSets); die(); //$test->load($fullxml); $test = OPCparametersJForm::render($test); //debug_zval_dump($testf); die(); //var_dump($test); die(); //$test->bind($payment); $ret[$file]['config'] = $data; $ret[$file]['xml'] = $fullxml; $ret[$file]['params'] = $test; if (empty($title)) { $ret[$file]['title'] = $file . '.php'; } else { $ret[$file]['title'] = (string) $title; } $ret[$file]['description'] = (string) $description; } return $ret; }
private function renderForm($file, $path) { require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'config.php'; require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'jformrender.php'; $ret = array(); if (!file_exists($path)) { continue; } $default = new stdClass(); //$data->adwords_id = 1; $data = OPCconfig::getValue('theme_config', $file, 0, $default, false); $title = $description = ''; if (function_exists('simplexml_load_file')) { $fullxml = simplexml_load_file($path); $title = $fullxml->name; $description = $fullxml->description; } $xml = file_get_contents($path); $xml = str_replace('extension', 'form', $xml); $xml = str_replace('params', 'fieldset', $xml); $xml = str_replace('<fieldset', '<fields name="' . $file . '"><fieldset name="test" label="' . $title . '" ', $xml); $xml = str_replace('param', 'field', $xml); $xml = str_replace('</fieldset>', '</fieldset></fields>', $xml); // removes BOM: $bom = pack('H*', 'EFBBBF'); $text = preg_replace("/^{$bom}/", '', $xml); if (!empty($text)) { $xml = $text; } $t1 = simplexml_load_string($xml); if ($t1 === false) { continue; } $test = JForm::getInstance($file, $xml, array(), true); if (!empty($data)) { foreach ($data as $k => $vl) { $test->setValue($k, $file, $vl); } } $fieldSets = $test->getFieldsets(); $test = OPCparametersJForm::render($test); $ret['params'] = $test; if (empty($title)) { $ret['title'] = $file . '.php'; } else { $ret['title'] = (string) $title; } $ret['description'] = (string) $description; return $ret; }