function generateAtomInterfaces($interface, $atom, $isTopLevelInterface = false) { /* if $interface is a top-level interface, we only generate for $interface itself * otherwise, we generate for its subinterfaces * * <Atom atom='atom name'> * <AtomName>atom name</AtomName> * <InterfaceList> * .. * for each subInterface in $interface: generateInterface($interface, $atom) (or $interface, if $isTopLevelInterface) * .. * </InterfaceList> * </Atom> * * if $atom is null, we are presenting a template. Because ""==null and "" denotes an empty atom, we check with === (since "" !== null) */ global $selectedRoleNr; global $allInterfaceObjects; $html = ""; $subInterfaceIsRef = false; if ($isTopLevelInterface) { $subInterfaces = array($interface); } else { if (isset($interface['boxSubInterfaces'])) { $subInterfaces = $interface['boxSubInterfaces']; } else { if (isset($interface['refSubInterface'])) { $subInterfaces = array($allInterfaceObjects[$interface['refSubInterface']]); $subInterfaceIsRef = true; } else { $subInterfaces = array(); } } } // note that the assignments below are about interfaces for the atom, not about the subinterfaces $nrOfInterfaces = count(getTopLevelInterfacesForConcept($interface['tgtConcept'], $selectedRoleNr)); $hasInterfaces = $nrOfInterfaces == 0 ? '' : ' hasInterface=' . ($nrOfInterfaces == 1 ? 'single' : 'multiple'); emit($html, '<div class=Atom atom=' . showHtmlAttrStr($atom) . $hasInterfaces . ' status=' . ($atom !== null ? 'unchanged' : 'new') . ' atomic=' . showHtmlAttrBool(count($subInterfaces) == 0) . '>'); $atomName = showViewAtom($atom, $interface['tgtConcept']); // TODO: can be done more efficiently if we query the concept atoms once for each concept emit($html, "<div class=AtomName>" . $atomName . '</div>'); if (count($subInterfaces) > 0) { emit($html, '<div class=InterfaceList>'); foreach ($subInterfaces as $interface) { emit($html, generateInterface($interface, $atom, $subInterfaceIsRef)); } emit($html, '</div>'); // div class=InterfaceList } emit($html, '</div>'); // div class=Atom return $html; }
function getNrOfInterfaces($concept, $roleNr) { return count(getTopLevelInterfacesForConcept($concept, $roleNr)); }