<?php require_once __DIR__ . '/php-emont/Model.class.php'; require_once __DIR__ . '/Uri.class.php'; if ($_GET['echo'] == TRUE) { $visualisatie = new Visualisatie($_GET['model_uri']); echo '<html><head></head><body>'; echo '<script type="text/javascript" src="/mediawiki/resources/lib/jquery/jquery.js"></script>'; echo $visualisatie->geefInhoud(); echo '</body></html>'; } class Visualisatie { private $inhoud = ''; public function __construct($model_uri) { //TODO NA: als ResourceLoader-modules toevoegen $this->inhoud .= '<script type="text/javascript" src="/mediawiki/extensions/EMontVisualisator/includes/js/d3.v3.js"></script>'; $this->inhoud .= '<script type="text/javascript" src="/mediawiki/extensions/EMontVisualisator/includes/js/cola.v3.min.js"></script>'; $this->inhoud .= '<link rel="stylesheet" type="text/css" href="/mediawiki/extensions/EMontVisualisator/includes/css/visualisatie.css"></style>'; //$domeinprefix='http://195.93.238.49/wiki/deltaexpertise/wiki/index.php/'; $domeinprefix = 'http://127.0.0.1/mediawiki/index.php/'; $context_uri = Model::geefContextVanModel($model_uri); $svgheight = 2280; $nodeheight = 30; $nodewidth = 100; $visualisatie_id = 'visualisatie-' . Uri::stripSMWuriPadEnPrefixes($model_uri); $this->inhoud .= ' <svg id="' . $visualisatie_id . '" width="100%" height="' . $svgheight . '"> <defs> <marker id="standaard" viewBox="0 -5 10 10" refX="10" refY="0" markerWidth="5" markerHeight="5" orient="auto">
public function __construct($model_uri) { if (!$model_uri) { $model_uri = 'wiki:Building_with_Nature-2Dinterventies_op_het_systeem_practice'; } $this->inhoud .= '<script type="text/javascript"> function toggleL1modelframe() { var l1modelframe=document.getElementById(\'l1modelframe\'); if (l1modelframe.style.display==\'none\') { l1modelframe.style.display=\'block\'; } else { l1modelframe.style.display=\'none\'; } } </script>'; $url = explode('?', rtrim($_SERVER['REQUEST_URI'], '/')); $this->inhoud .= '<a href="' . $url[0] . '/../../">Terug naar het modellenoverzicht</a>'; $this->inhoud .= '<h2 id="visualisatiekop">Visualisatie</h2> <p><a href="' . $url[0] . '">Herladen</a></p> <p>U kunt elementen verslepen om het overzicht te verbeteren. Dubbelklik op een element om de wikipagina ervan weer te geven.</p>'; $visualisatie = new Visualisatie($model_uri); $this->inhoud .= $visualisatie->geefInhoud(); if (Model::modelIsExperience($model_uri)) { $l1model = Model::geefL1modelVanCase($model_uri); $l1hoofdcontext = Model::geefContextVanModel($l1model); $context_uri = Model::geefContextVanModel($model_uri); $contexten = Model::geefUrisVanContextEnSubcontexten($context_uri); $contextenlijst = ''; foreach ($contexten as $context) { $contextenlijst .= '<option value="' . $context . '">' . Uri::SMWuriNaarLeesbareTitel($context) . '</option>'; } $data = Model::geefElementenUitContextEnSubcontexten($context_uri); $ie_lijst = ''; $verbandenlijst = array(); $ie_contexten = array(); foreach ($data['@graph'] as $item) { if ($item['@id']) { $ie_lijst .= '<option value="' . $item['@id'] . '">' . $item['label'] . '</option>'; $elementen = Model::elementenNaarArrays(Model::geefArtikelTekst($item['@id'])); foreach ($elementen as $element) { if ($element['Element link']) { $verbandenlijst[] = array('van' => $item['label'], 'type' => $element['type'], 'naar' => $element['Element link']); } elseif ($element['type'] == 'Intentional Element links' || $element['type'] == 'Activity links') { $linksverbanden = array(); if ($element['Part of']) { $linksverbanden = explode(',', $element['Part of']); foreach ($linksverbanden as $linksverband) { if (trim($linksverband)) { $verbandenlijst[] = array('van' => $item['label'], 'type' => 'Part of', 'naar' => trim($linksverband)); } } } if ($element['Consumes']) { $linksverbanden = explode(',', $element['Consumes']); foreach ($linksverbanden as $linksverband) { if (trim($linksverband)) { $verbandenlijst[] = array('van' => $item['label'], 'type' => 'Consumes', 'naar' => trim($linksverband)); } } } if ($element['Produces']) { $linksverbanden = explode(',', $element['Produces']); foreach ($linksverbanden as $linksverband) { if (trim($linksverband)) { $verbandenlijst[] = array('van' => $item['label'], 'type' => 'Produces', 'naar' => trim($linksverband)); } } } } } if ($item['Eigenschap-3AContext']) { if (is_array($item['Eigenschap-3AContext'])) { foreach ($item['Eigenschap-3AContext'] as $ie_context) { $ie_contexten[$item['@id']][] = $ie_context; } } else { $ie_contexten[$item['@id']][] = $item['Eigenschap-3AContext']; } } } } $this->inhoud .= '<h2>L1-model: ' . Uri::SMWuriNaarLeesbareTitel($l1hoofdcontext) . '</h2>'; $this->inhoud .= '<button onclick="toggleL1modelframe();">Open/dichtklappen</button>'; $this->inhoud .= '<iframe style="display:none;" id="l1modelframe" width="100%" height="800" src="/mediawiki/extensions/EMontVisualisator/includes/php/Visualisatie.class.php?echo=true&model_uri=' . urlencode($l1model) . '"></iframe>'; //// $this->inhoud .= '<h2>Nieuw Intentional Element</h2>'; $this->inhoud .= '<form action="?actie=nieuw&type=ie" method="post"><table>'; $this->inhoud .= '<tr><td>Naam: ' . Uri::SMWuriNaarLeesbareTitel($context_uri) . '</td><td><input type="text" style="width: 300px;" name="titel"/></td></tr>'; $this->inhoud .= '<tr><td>Instance of:</td><td><select name="ie">'; $data = Model::geefElementenUitContextEnSubcontexten($l1hoofdcontext); if (isset($data['@graph'])) { foreach ($data['@graph'] as $item) { $this->inhoud .= '<option value="' . $item['@id'] . '">' . $item['label'] . '</option>'; } } $this->inhoud .= '</select></td></tr>'; $this->inhoud .= '<tr><td>Context:</td><td><select name="context">' . $contextenlijst . '</select></td></tr>'; $this->inhoud .= '</table><input type="submit" value="Aanmaken"/></form>'; //// $this->inhoud .= '<h2>Nieuw verband aanbrengen</h2>'; $this->inhoud .= '<form method="post" action="?actie=maakverband&type=ie"><table>'; $this->inhoud .= '<tr><th>Van:</th><th>Type:</th><th>Naar:</th><tr>'; $this->inhoud .= '<tr><td><select name="van">' . $ie_lijst . '</select></td>'; $this->inhoud .= '<td><select name="type"><option value="Contributes">Contributes</option><option value="Depends">Depends</option><option value="Connects">Connects</option><option value="Produces">Produces</option><option value="Consumes">Consumes</option><option value="Part of">Part of</option></select></td>'; $this->inhoud .= '<td><select name="naar">' . $ie_lijst . '</select></td></tr>'; $this->inhoud .= '<tr><td></td><td>Notitie:</td><td><input name="notitie" type="text" style="width:300px;"></td></tr>'; $this->inhoud .= '<tr><td></td><td>CV/CT:</td><td><input name="subtype" type="text" style="width:300px;"/></td></tr>'; $this->inhoud .= '</table><input type="submit" value="Aanmaken" /></form>'; //// $this->inhoud .= '<h2>Verband verwijderen</h2>'; $this->inhoud .= '<form method="post" action="?actie=verwijderverband&type=ie"><table>'; foreach ($verbandenlijst as $verband) { $this->inhoud .= '<tr><td><input type="radio" name="verwijder-verband" value="' . $verband['van'] . '|' . $verband['type'] . '|' . $verband['naar'] . '"/> </td><td>' . $verband['van'] . ' </td><td>' . $verband['type'] . ' </td><td>' . $verband['naar'] . '</td></tr>'; } $this->inhoud .= '</table><input type="submit" value="Verwijderen"></form>'; //// $this->inhoud .= '<h2>Nieuwe context</h2>'; $this->inhoud .= '<form method="post" action="?actie=nieuw&type=context">'; $this->inhoud .= 'Naam: ' . Uri::SMWuriNaarLeesbareTitel($context_uri) . '<input type="text" name="naam-nieuwe-context" /><br />'; $this->inhoud .= 'Supercontext: <select name="supercontext">' . $contextenlijst . '</select>'; $this->inhoud .= '<input type="submit" value="Aanmaken"></form>'; //// $this->inhoud .= '<h2>Context verwijderen</h2>'; //// $this->inhoud .= '<h2>Supercontext toevoegen aan context</h2>'; $this->inhoud .= '<form method="post" action="?actie=extrasupercontext&type=context">'; $this->inhoud .= 'Context: <select name="context">' . $contextenlijst . '</select><br />'; $this->inhoud .= 'Supercontext: <select name="supercontext">' . $contextenlijst . '</select><br />'; $this->inhoud .= '<input type="submit" value="Toevoegen"></form>'; //// $this->inhoud .= '<h2>Supercontext verwijderen van context</h2>'; $this->inhoud .= '<form method="post" action="?actie=supercontextverwijderen&type=context"><table><tr><th></th><th>Context</th><th>Supercontext</th></tr>'; foreach ($contexten as $context) { $supercontexten = Model::zoekSupercontexten($context); foreach ($supercontexten as $supercontext) { $this->inhoud .= '<tr><td><input type="radio" name="verwijder-supercontexten" value="' . $context . '|' . $supercontext . '"> </td><td>' . Uri::SMWuriNaarLeesbareTitel($context) . ' </td><td>' . Uri::SMWuriNaarLeesbareTitel($supercontext) . '</td></tr>'; } } $this->inhoud .= '</table><input type="submit" value="Verwijderen" /></form>'; //// $this->inhoud .= '<h2>Context aan Intentional Element toevoegen</h2>'; $this->inhoud .= '<form method="post" action="?actie=contexttoevoegen&type=ie">'; $this->inhoud .= '<table><tr><td>Intentional Element</td><td><select name="ie">'; $this->inhoud .= $ie_lijst; $this->inhoud .= '</select></td></tr><tr><td>Context</td><td><select name="context">'; $this->inhoud .= $contextenlijst; $this->inhoud .= '</select></td></tr></table><input type="submit" value="Toevoegen" /></form>'; //// $this->inhoud .= '<h2>Context van Intentional Element verwijderen</h2>'; //// $this->inhoud .= '<h2>Context van Intentional Element vervangen</h2>'; $this->inhoud .= '<table>'; $this->inhoud .= '<tr><th>IE</th><th>Context</th><th>Vervangen door</th></tr>'; foreach ($ie_contexten as $ie => $contextlijst) { foreach ($contextlijst as $context) { $this->inhoud .= '<form method="post" action="?actie=contextvervangen&type=ie&ie=' . $ie . '&context=' . $context . '">'; $this->inhoud .= '<tr><td>' . Uri::SMWuriNaarLeesbareTitel($ie) . '</td><td>' . Uri::SMWuriNaarLeesbareTitel($context) . '</td><td><select name="nieuwecontext">'; foreach ($contexten as $beschikbarecontext) { if ($beschikbarecontext != $context) { $this->inhoud .= '<option value="' . $beschikbarecontext . '">' . Uri::SMWuriNaarLeesbareTitel($beschikbarecontext) . '</option>'; } } $this->inhoud .= '</select></td><td><input type="submit" value="Vervangen"/></td></tr></form>'; } } $this->inhoud .= '</table>'; } }