function JBXM_display_xml_doc_tree($schema_id, $element_id = 0)
{
    static $depth = 0;
    global $element_input_options;
    static $pivot_open;
    static $feed_row;
    if ($element_input_options == '') {
        $element_input_options = 'BUTTONS';
    }
    $feed_id = (int) $_REQUEST['feed_id'];
    if ($feed_row == null) {
        $sql = "SELECT * from xml_export_feeds WHERE feed_id='" . jb_escape_sql($feed_id) . "' ";
        $result = JB_mysql_query($sql);
        $feed_row = mysql_fetch_array($result, MYSQL_ASSOC);
        $feed_row['field_settings'] = unserialize($feed_row['field_settings']);
    }
    if ($depth > 100) {
        return;
    }
    $sql = "select * from xml_export_elements WHERE `parent_element_id`='" . jb_escape_sql($element_id) . "' AND `schema_id`='" . jb_escape_sql($schema_id) . "' order by has_child desc, is_pivot desc ";
    //echo $sql;
    $result = JB_mysql_query($sql) or die(mysql_error());
    if (mysql_num_rows($result) > 0) {
        echo "<br>";
        $the_end = true;
    }
    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
        $element = $row['element_name'];
        if ($feed_row['field_settings']['static_data_' . $row['element_id']] != '') {
            // over-write the default export mode
            $row['static_data'] = $feed_row['field_settings']['static_data_' . $row['element_id']];
            // hidden field to ensure that the custom static data setting is stored in field_settings
            // by the JBXM_save_xml_feed_input() function
            ?>
			 <input type="hidden" name="static_data_<?php 
            echo $row['element_id'];
            ?>
" value="<?php 
            echo jb_escape_html($row['static_data']);
            ?>
"> 
			<?php 
        }
        if ($row['attributes'] != '') {
            $row['attributes'] = " " . $row['attributes'];
        }
        //echo "<br>";
        JBXM_echo_nbsp_repeat($depth);
        if ($row['is_pivot'] == 'Y') {
            echo "<b>";
            $pivot_open = true;
        }
        if ($row['is_mandatory'] == 'Y') {
            echo '<font color="red" size="4">*</font>';
        }
        echo "<font color='purple'>&lt;{$element}</font><font color='blue'>" . JB_escape_html($row['attributes']) . "</font><font color='purple'>&gt;</font>";
        if ($row['is_pivot'] == 'Y') {
            echo "</b>";
            echo ' <font color="green">&lt;!-- This item will be iterated for each record (Pivot) --&gt; </font>';
        }
        $depth += 2;
        $ending = JBXM_display_xml_doc_tree($schema_id, $row['element_id']);
        if ($row['static_data'] == '' && $row['field_id'] == false) {
            //echo "<br>";
            //echo_nbsp_repeat($depth);
        }
        if ($row['is_pivot'] == 'Y') {
            echo "<b>";
            $pivot_open = true;
        }
        if ($ending) {
            if (($row['static_data'] == '' || $row['static_mod'] != 'F') && $element_input_options == 'FIELDS' && $pivot_open == true && $depth >= 6) {
                JBXM_echo_nbsp_repeat($depth);
                ?>
<small><input type="checkbox" name="implode_<?php 
                echo $row['element_id'];
                ?>
" value='Y' <?php 
                if ($_REQUEST['implode_' . $row['element_id']] == 'Y') {
                    echo ' checked ';
                }
                ?>
 ></small> <b>Implode</b> <small>the fields between &lt;<?php 
                echo $element;
                ?>
&gt; and &lt;/<?php 
                echo $element;
                ?>
&gt; in to one single value</small><?php 
                //JBXM_echo_field_select_field($row, $feed_row);
                echo '<br>';
            }
            JBXM_echo_nbsp_repeat($depth);
        } else {
            if ($element_input_options == 'FIELDS') {
                // display the input fields
                //for XML Feed configuration
                if ($row['static_data'] == '' || $row['static_mod'] != 'F') {
                    JBXM_echo_field_select_field($row, $feed_row);
                    if ($row['static_mod'] == 'A') {
                        // append
                        echo "<font color='maroon'><b>" . $row['static_data'] . "</b></font>";
                    }
                    if ($row['is_boolean'] == 'Y') {
                        ?>
						Export as <font color="blue"><b>true</b></font> if data = <input type='text' size='10' name="<?php 
                        echo 'boolean_p_' . $row['element_id'];
                        ?>
" value="<?php 
                        echo jb_escape_html($_REQUEST['boolean_p_' . $row['element_id']]);
                        ?>
" >
						<?php 
                    }
                    if ($row['static_mod'] != 'A') {
                        ?>
						<small>[<a style="color:black" href="#" onclick="window.open('xml_change_window.php?form_id=<?php 
                        echo $row['form_id'];
                        ?>
&schema_id=<?php 
                        echo $row['schema_id'];
                        ?>
&element_id=<?php 
                        echo $row['element_id'];
                        ?>
&feed_id=<?php 
                        echo $feed_id;
                        ?>
&to_static=1', '', 'toolbar=no,scrollbars=yes,location=no,statusbar=no,menubar=no,resizable=1,width=550,height=500,left = 50,top = 50');return false;">Change to static...</a>]</small>
						<?php 
                    }
                } else {
                    // display the tree without any input fields
                    echo "<font color='maroon'><b>" . $row['static_data'] . "</b></font>";
                    ?>
					<small>[<a style="color:black" href="#" onclick="window.open('xml_change_window.php?form_id=<?php 
                    echo $row['form_id'];
                    ?>
&schema_id=<?php 
                    echo $row['schema_id'];
                    ?>
&element_id=<?php 
                    echo $row['element_id'];
                    ?>
&feed_id=<?php 
                    echo $feed_id;
                    ?>
&to_static=1', '', 'toolbar=no,scrollbars=yes,location=no,statusbar=no,menubar=no,resizable=1,width=550,height=500,left = 50,top = 50');return false;">Edit</a>][<a style="color:black" href="#" onclick="window.open('xml_change_window.php?form_id=<?php 
                    echo $row['form_id'];
                    ?>
&schema_id=<?php 
                    echo $row['schema_id'];
                    ?>
&element_id=<?php 
                    echo $row['element_id'];
                    ?>
&feed_id=<?php 
                    echo $feed_id;
                    ?>
&to_db=1', '', 'toolbar=no,scrollbars=yes,location=no,statusbar=no,menubar=no,resizable=1,width=550,height=500,left = 50,top = 50');return false;">Change to DB value...</a>]</small>
					<?php 
                }
            } else {
                // $element_input_options is 'BUTTONS'
                // This means that the XML document tree is displayed on the
                // Admin->XML Exports, 'Configure XML Structure' screen
                echo "<font color='maroon'><b>" . $row['static_data'] . "</b></font>";
            }
        }
        echo "<font color='purple'>&lt;/{$element}&gt;</font>";
        // Show comments
        $comment = '';
        $comma = '';
        if ($row['is_boolean'] == 'Y') {
            $comment .= '  Boolean';
            $comma = ',';
        }
        if ($row['is_cdata'] == 'Y') {
            $comment .= $comma . ' CDATA';
            $comma = ',';
        }
        if ($row['strip_tags'] == 'Y') {
            $comment .= $comma . ' Strip Tags';
            $comma = ',';
        }
        if ($row['truncate'] > 0) {
            $comment .= $comma . ' Truncate to:' . $row['truncate'] . ' chars';
            $comma = ',';
        }
        if ($row['qualify_codes'] == 'Y') {
            $comment .= $comma . ' Export codes as names';
            $comma = ',';
        }
        if ($row['qualify_cats'] == 'Y') {
            $comment .= $comma . ' Export categories as names';
            $comma = ',';
        }
        if ($row['comment'] != '') {
            if ($comment) {
                $comment = $comment . ",";
            }
            $comment .= " " . $row['comment'];
        }
        if ($comment != '') {
            echo ' <font color="green">&lt;!-- ' . $comment . ' --&gt;</font> ';
        }
        if ($row['element_name'] == 'jamitKey') {
            echo ' <font color="green">&lt;!-- If this feed requires a key, this field should be set to static  --&gt;</font> ';
        }
        if ($element_input_options == 'BUTTONS' && !JBXM_is_schema_locked($_REQUEST['schema_id'])) {
            echo "&nbsp;<a  href='" . $_SERVER['PHP_SELF'] . "?delelement=yes&form_id=" . $_REQUEST['form_id'] . "&schema_id=" . $_REQUEST['schema_id'] . "&element_id=" . $row['element_id'] . "' onclick=\"if (!confirmLink(this, 'Delete, are you sure?')) return false;\" ><img border=0 src='delete.gif' ></a> <a href='" . $_SERVER['PHP_SELF'] . "?config=yes&form_id=" . $_REQUEST['form_id'] . "&schema_id=" . $_REQUEST['schema_id'] . "&element_id=" . $row['element_id'] . "'><img border=0 src='edit.gif'></a> <a href='" . $_SERVER['PHP_SELF'] . "?config=yes&form_id=" . $_REQUEST['form_id'] . "&schema_id=" . $_REQUEST['schema_id'] . "&form_id=" . $_REQUEST['form_id'] . "&parent_element_id=" . $row['element_id'] . "'><img border=0 src='add.gif'></a>";
        }
        echo "<br>";
        if ($row['is_pivot'] == 'Y') {
            echo "</b>";
            $pivot_open = false;
        }
    }
    $depth -= 2;
    return $the_end;
}
Exemple #2
0
    if ($_REQUEST['import'] != '') {
        ?>

		 <form method="POST" action="xmlschema.php?config=yes&form_id=<?php 
        echo $_REQUEST['form_id'];
        ?>
&schema_id=<?php 
        echo $_REQUEST['schema_id'];
        ?>
&import=1" enctype="multipart/form-data">
		 <b>Please paste in the CSV content, and click the 'Import' button to import the structure:</b><br>
		 <textarea name="csv_data" cols="80" rows="15"><?php 
        echo htmlentities(stripslashes($_REQUEST['csv_data']));
        ?>
</textarea><br>
		 <input type="submit" value="Import" name="do_import"><br>
		 (Please note: Existing structure will be replaced with the structure imported from the CSV file) 
		 </form>

		 <?php 
    }
    ?>
<i>The XML document tree:</i><br>
<?php 
    JBXM_display_xml_doc_tree($_REQUEST['schema_id']);
    ?>
</td>

<?php 
}
JB_admin_header('Admin -> XML Schema');