function generateInterface($interface, $srcAtom, $isRef = false) { /* * <Interface label='interface label' isRef=true'/'false'> * <Label>interface label</Label> * <AtomList concept=.. [relation=.. relationIsFlipped=..]> * .. * for each $tgtAtom in codomain of relation of $interface * <AtomRow rowType=Normal> <DeleteStub/> <AtomListElt> generateAtomInterfaces($interface, $tgtAtom) </AtomListElt> </AtomRow> * .. * * <AtomRow rowType=NewAtomTemplate> <DeleteStub/> <AtomListElt> generateAtomInterfaces($interface, null) </AtomListElt> </AtomRow> * * <AtomRow rowType=InsertAtomStub> <DeleteStub/> <InsertStub>Insert new .. </InsertStub> </AtomRow> * </AtomList> * </Interface> */ $html = ""; emit($html, '<div class=Interface label=' . showHtmlAttrStr($interface['name']) . ' isRef=' . showHtmlAttrBool($isRef) . '>'); emit($html, "<div class=Label>" . htmlSpecialChars($interface['name']) . '</div>'); if ($srcAtom == null) { $codomainAtoms = array(); } else { $codomainAtoms = array_filter(getCoDomainAtoms($srcAtom, $interface['expressionSQL']), 'notNull'); } // filter, in case table contains ($srcAtom, null) if (count($codomainAtoms) == 0 && isset($interface['min']) && $interface['min'] == 'One') { // 'min' is only defined for editable relations $codomainAtoms[] = ""; } // if there should be at least one field, we add an empty field. $codomainAtoms[] = null; // the null is presented as a NewAtomTemplate (which is cloned when inserting a new atom) $nrOfAtoms = count($codomainAtoms) - 1; // disregard the null for the NewAtomTemplate $relationAttrs = $interface['relation'] == '' ? '' : ' relation=' . showHtmlAttrStr($interface['relation']) . ' relationIsFlipped=' . showHtmlAttrBool($interface['relationIsFlipped']) . ' min=' . showHtmlAttrStr($interface['min']) . ' max=' . showHtmlAttrStr($interface['max']) . ' nrOfAtoms=' . showHtmlAttrStr($nrOfAtoms); // emit($html, '<div class="AtomList" concept=' . showHtmlAttrStr($interface['tgtConcept']) . $relationAttrs . '>'); foreach ($codomainAtoms as $i => $tgtAtom) { // null is the NewAtomTemplate emit($html, '<div class=AtomRow rowType=' . ($tgtAtom === null ? 'NewAtomTemplate' : 'Normal') . '><div class=DeleteStub> </div>' . '<div class=AtomListElt>'); emit($html, generateAtomInterfaces($interface, $tgtAtom)); emit($html, '</div></div>'); } emit($html, '<div class=AtomRow rowType=InsertAtomRow><div class=DeleteStub> </div>' . '<div class=InsertStub>Insert new ' . htmlSpecialChars($interface['tgtConcept']) . '</div></div>'); emit($html, '</div></div>'); // close .AtomList and .Interface return $html; }
function execPair($srcAtom, $srcConcept, $tgtAtom, $tgtConcept, $pairView) { $pairStrs = array(); foreach ($pairView as $segment) { if ($segment['segmentType'] == 'Text') { $pairStrs[] = $segment['Text']; } else { $atom = $segment['srcOrTgt'] == 'Src' ? $srcAtom : $tgtAtom; $concept = $segment['srcOrTgt'] == 'Src' ? $srcConcept : $tgtConcept; $r = getCoDomainAtoms($atom, $segment['expSQL']); // SRC of TGT kunnen door een expressie gevolgd worden $pairStrs[] = $r[0]; // Even er van uit gaan dat we maar 1 atoom kunnen behandelen... } } return implode($pairStrs); }