Esempio n. 1
0
function generate_realty()
{
    echo 'в функции generate_realty до include<br>';
    include_once 'modules/kXML/add_functions.php';
    echo 'в функции generate_realty после include<br>';
    $ids = explode(",", $_POST['records']);
    add2log($_REQUEST['module'], $_REQUEST['name'], "start update xml [" . count($ids) . " objects processed]");
    if (isset($_POST['custom_generate']) && $_POST['custom_generate'] == '1') {
        echo 'Зашел - ' . $_POST['custom_generate'] . '<br>';
        $path = "custom/kXML/custom_generate/{$_REQUEST['module']}/{$_REQUEST['name']}";
        echo $path . '<br>';
        //exit();
        if (file_exists($path)) {
            include_once $path;
            $name_this = str_replace('.php', '', $_POST['name']);
            $name_this = 'generate_xml_' . $name_this;
            foreach ($ids as $id) {
                $name_this($id);
            }
        }
        echo "\n Обработано объектов: " . count($ids);
        return false;
    }
    $first_line = true;
    //$bean=loadBean($_POST['module']);
    $n_ = '
';
    $encoding = 'UTF-8';
    $search = array();
    $elements = array();
    $elements_h = array();
    $path = $_POST['module'];
    if (!file_exists("custom/kXML/xml/" . $path)) {
        mkdir("custom/kXML/xml/" . $path);
    }
    $path .= "/" . $_POST['name'];
    $f = fopen("custom/kXML/templates/{$path}", "r");
    while (!feof($f)) {
        $line = fgets($f);
        if ($line && ($line[0] != '#' && $line[0] != '/' && $line[0] != '*' && $line[0] != ';')) {
            $element = explode(' ; ', $line);
            if ($first_line) {
                if (isset($element[3])) {
                    $encoding = str_replace($n_, '', $element[3]);
                    unset($element[3]);
                }
                $search = $element;
                $first_line = false;
            } else {
                if ($element[3][0] == '1') {
                    $elements_h[$element[0]][$element[1]] = trim($element[2]);
                } else {
                    $elements[$element[0]][$element[1]] = trim($element[2]);
                }
            }
        }
    }
    fclose($f);
    gen_xml($elements, $elements_h, $path, $search, $encoding);
}
Esempio n. 2
0
                $encoding = str_replace($n_, '', $element[3]);
                unset($element[3]);
            }
            $search = $element;
            $first_line = false;
        } else {
            if ($element[3][0] == '1') {
                $elements_h[$element[0]][$element[1]] = trim($element[2]);
            } else {
                $elements[$element[0]][$element[1]] = trim($element[2]);
            }
        }
    }
}
fclose($f);
gen_xml($elements, $elements_h, $path, $search, $encoding);
function gen_xml($elements, $elements_h, $path, $search, $encoding)
{
    include "custom/kXML/replacers/{$_POST['module']}/{$_POST['name']}.php";
    global $sugar_config;
    $records = explode(',', $_POST['records']);
    $bean = loadBean($_POST['module']);
    $name_this = str_replace('.php', '', $_POST['name']);
    //$name_this = str_replace('.', '', $name_this);
    $replacer_class = 'Replacer_' . $name_this;
    $r = new $replacer_class();
    if (!file_exists("custom/kXML/xml/{$path}.xml")) {
        $dom['root_'] = new DOMDocument('1.0', $encoding);
        $r->dom_root = $dom['root_'];
        if (count($elements_h) > 0) {
            foreach ($elements_h as $parent => $indexes) {