Esempio n. 1
0
function insertNodeAndLinks($pid, $x, $y, $isConnector, $link1, $link2, $link3)
{
    insertNode($isConnector, $pid, $x, $y);
    $nid1 = getMaxNid();
    if ($link1 != null) {
        insertLink($nid1, $link1);
    }
    if ($link2 != null) {
        insertLink($nid1, $link2);
    }
    if ($link3 != null) {
        insertLink($nid1, $link3);
    }
}
Esempio n. 2
0
<?php

include_once "../dao/getNode.php";
include_once "../dao/getLink.php";
$pName = "";
$nName = "";
$nid = getMaxNid() + 1;
$nid2 = getMaxNid() + 2;
$did = getMaxDid() + 1;
$pid = getMaxPatternID() + 1;
$domains = $_POST['domains'];
insertNode($nid, 2, -1, $pName, $nName, "yes", $did);
foreach ($domains as $key => $value) {
    insertLink($nid, $value);
}
insertNode($nid2, 1, $pid, $pName, $nName, "yes", $did);
insertLink($nid, $nid2);
echo "success";
Esempio n. 3
0
 function insertNodes($nodes, $pos, $subRel = false, $subPath = '')
 {
     $prevChild = false;
     while ($pos < $nodes->length && domNodeIsEmpty($nodes->item($pos))) {
         $pos++;
     }
     while ($pos < $nodes->length) {
         if ($prevChild === false) {
             $prevChild = insertNode($subRel, $subPath, $nodes->item($pos++));
         } else {
             $prevChild = insertNode($prevChild, '', $nodes->item($pos++));
         }
         while ($pos < $nodes->length && domNodeIsEmpty($nodes->item($pos))) {
             $pos++;
         }
     }
     return $prevChild;
 }
Esempio n. 4
0
 function insertNode($path, $node)
 {
     $children = $node->childNodes;
     $virtual = true;
     $title = '';
     $text = '';
     $pos = 0;
     while ($pos < $children->length && domNodeIsEmpty($children->item($pos))) {
         $pos++;
     }
     if ($pos < $children->length) {
         $item = $children->item($pos);
         if ($item->nodeType == XML_ELEMENT_NODE && $item->tagName == 'h') {
             $title = trim($item->firstChild->data);
             $virtual = false;
             $pos++;
         }
     }
     while ($pos < $children->length && domNodeIsEmpty($children->item($pos))) {
         $pos++;
     }
     if ($pos < $children->length) {
         $item = $children->item($pos);
         if ($item->nodeType == XML_TEXT_NODE) {
             $text = trim($item->data);
             $virtual = false;
             $pos++;
         }
     }
     if ($path != '') {
         if ($node->hasAttribute('delete')) {
             if (!$node->hasAttribute('id') || !$virtual) {
                 die('Malformed XML: delete tag has no id or is virtual');
             }
             $newPath = deleteParagraph(pathCombine($path, 1, $node->getAttribute('id')));
         } else {
             if ($node->hasAttribute('id')) {
                 if (!$virtual) {
                     $newPath = editParagraph(pathCombine($path, 1, $node->getAttribute('id')), $title, $text);
                 } else {
                     $newPath = pathCombine($path, 1, $node->getAttribute('id'));
                 }
             } else {
                 if (!$virtual) {
                     $newPath = addParagraph($path, 't', $title, $text);
                 } else {
                     $newPath = addParagraph($path, 'f');
                 }
             }
         }
     }
     $lastPath = pathCombine($newPath, 0, '0');
     while ($pos < $children->length && domNodeIsEmpty($children->item($pos))) {
         $pos++;
     }
     while ($pos < $children->length) {
         $lastPath = insertNode($lastPath, $children->item($pos++));
         while ($pos < $children->length && domNodeIsEmpty($children->item($pos))) {
             $pos++;
         }
     }
     return $newPath;
 }
<?php

include_once "../dao/getNode.php";
$pName = "";
$nName = "";
$nid = getMaxNid() + 1;
$pid = getMaxPatternID() + 1;
insertNode($nid, 1, $pid, $pName, $nName, "yes");
echo "success";