/** * Format the nodeset / userset output as locations * This is just for Google Maps view * * @param Object $object - the data to format * @return string */ function format($object) { global $CFG; if (!$object instanceof NodeSet && !$object instanceof UserSet) { $doc = '{"error":[{"message":"' . $object->message . '","code":"' . $object->code . '"}]}'; return $doc; } $locs = array(); $doc = '{"locations":['; if ($object instanceof NodeSet) { $nodes = $object->nodes; foreach ($nodes as $node) { // can only display if the node if it has a long and lat if (isset($node->locationlat) && isset($node->locationlng)) { $country = ""; if (isset($node->country)) { $country = $node->country; } $tmp = '{"country":"' . parseToJSON(addslashes($country)) . '","desc":"' . parseToJSON($node->description) . '", "city":"' . $node->location . '","lat":"' . $node->locationlat . '","lng":"' . $node->locationlng . '","title":"' . parseToJSON($node->name) . '","thumb":"' . parseToJSON($node->role->image) . '","id":"' . $node->nodeid . '"}'; array_push($locs, $tmp); } else { // else use the user's location to locate the node if (isset($node->users[0]->locationlat) && isset($node->users[0]->locationlng)) { $desc = $node->description; //if (isProbablyHTML($desc)) { $desc = ""; //} $tmp = '{"country":"' . parseToJSON(addslashes($node->users[0]->country)) . '","desc":"' . parseToJSON($desc) . '", "city":"' . $node->users[0]->location . '","lat":"' . $node->users[0]->locationlat . '","lng":"' . $node->users[0]->locationlng . '","title":"' . parseToJSON($node->name) . '","thumb":"' . parseToJSON($node->role->image) . '","id":"' . $node->nodeid . '","user":"******",}'; array_push($locs, $tmp); } } } } else { if ($object instanceof UserSet) { $users = $object->users; $i = 0; foreach ($users as $user) { // can only display if the user has if it has a long and lat if (isset($user->locationlat) && isset($user->locationlng)) { $tmp = '{"country":"' . parseToJSON(addslashes($user->country)) . '","city":"' . $user->location . '","lat":"' . $user->locationlat . '","lng":"' . $user->locationlng . '","title":"' . parseToJSON($user->name) . '","id":"' . $user->userid . '","thumb":"' . parseToJSON($user->thumb) . '", "desc":"' . parseToJSON($user->description) . '"}'; array_push($locs, $tmp); } $i++; } } } $doc .= implode(",", $locs); $doc .= "]}"; return $doc; }
function addFullUserProfile($user) { global $CFG; $pseudo_id = $this->getPseudonym($user->userid); $this->dataGraphStr .= '{'; $this->dataGraphStr .= '"@type": "Agent",'; $this->dataGraphStr .= '"@id": "' . $this->site . ':agents/' . $pseudo_id . '",'; if (isset($user->description) && $user->description != "") { $desc = character_convert_to($user->description, 'UTF-8'); $this->dataGraphStr .= '"description": "' . parseToJSON($desc) . '",'; } if (isset($user->photo) && $user->photo != "") { $this->dataGraphStr .= '"img": "' . $user->photo . '",'; } if (isset($user->userid) && $user->userid != 'anonymous') { $this->dataGraphStr .= '"homepage": "' . $CFG->homeAddress . 'user.php?userid=' . $user->userid . '",'; } $name = character_convert_to($user->name, 'UTF-8'); $this->dataGraphStr .= '"fname": "' . parseToJSON($name) . '"'; $this->dataGraphStr .= '},'; }
/** * Helper function for the Circle Packing function. Recurses the data tree */ function addNextCirclePackingDepth($json, $node, $depth, $treeArray, $checkArray) { $json .= '{'; $json .= '"name": "' . parseToJSON($node->name) . '",'; $json .= '"nodetype": "' . parseToJSON($node->role->name) . '",'; $json .= '"nodetypename": "' . getNodeTypeText(parseToJSON($node->role->name), false) . '"'; $treeitem = $treeArray[$node->nodeid]; if (isset($treeitem["children"]) && count($treeitem["children"]) > 0 && !array_key_exists($node->nodeid, $checkArray)) { // make sure you don't recurse the same set of children more than once. $checkArray[$node->nodeid] = $node->nodeid; $children = $treeitem["children"]; $countkids = count($children); $json .= ',"children": ['; for ($i = 0; $i < $countkids; $i++) { $child = $children[$i]; $json = addNextCirclePackingDepth($json, $child, $depth + 1, $treeArray, $checkArray); if ($i < $countkids - 1) { $json .= ','; } } $json .= "]"; } else { $json .= ',"size": ' . (2000 - 20 * $depth); } $json .= "}"; return $json; }
* * * This software is provided by the copyright holders and contributors "as is" * * and any express or implied warranties, including, but not limited to, the * * implied warranties of merchantability and fitness for a particular purpose * * are disclaimed. In no event shall the copyright owner or contributors be * * liable for any direct, indirect, incidental, special, exemplary, or * * consequential damages (including, but not limited to, procurement of * * substitute goods or services; loss of use, data, or profits; or business * * interruption) however caused and on any theory of liability, whether in * * contract, strict liability, or tort (including negligence or otherwise) * * arising in any way out of the use of this software, even if advised of the * * possibility of such damage. * * * ********************************************************************************/ /** Author: Michelle Bachler, KMi, The Open University **/ $query = stripslashes(parseToJSON(optional_param("q", "", PARAM_TEXT))); // need to do parseToJSON to convert any '+' symbols as they are now used in searches. $scope = optional_param("scope", "all", PARAM_ALPHA); $tagsonly = optional_param("tagsonly", false, PARAM_BOOL); if (isset($_POST["loginsubmit"])) { $url = "http" . (!empty($_SERVER["HTTPS"]) ? "s" : "") . "://" . $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]; header('Location: ' . $CFG->homeAddress . 'ui/pages/login.php?ref=' . urlencode($url)); } ?> <!DOCTYPE html> <html lang="<?php echo $CFG->language; ?> "> <head> <meta charset="UTF-8"/>
$nodeid = required_param('nodeid', PARAM_ALPHANUMEXT); $response = getConnectionsByNode($nodeid, $start, $max, $o, $s, $filterlinkgroup, $filterlinktypes, $filternodetypes, $style, $status); break; case "getconnectionsbyurl": $url = required_param('url', PARAM_URL); $response = getConnectionsByURL($url, $start, $max, $o, $s, $filterlinkgroup, $filterlinktypes, $filternodetypes, $style, $status); break; case "getconnectionsbysocial": $linklabels = required_param('linklabels', PARAM_TEXT); $filternodetypes = required_param('filternodetypes', PARAM_TEXT); $scope = optional_param('scope', 'all', PARAM_ALPHANUM); $userid = optional_param('userid', '', PARAM_ALPHANUMEXT); $response = getConnectionsBySocial($scope, $start, $max, $o, $s, $linklabels, $filternodetypes, $userid, $style, $status); break; case "getmulticonnections": $connectionids = parseToJSON(required_param('connectionids', PARAM_TEXT)); // needs this parsing to convert single speech marks back. $response = getMultiConnections($connectionids, $start, $max, $o, $s, $style); break; case "getconnectionsbypath": $nodeid = required_param('nodeid', PARAM_ALPHANUMEXT); $linklabels = required_param('linklabels', PARAM_TEXT); $scope = optional_param('scope', 'all', PARAM_TEXT); $userid = ""; //optional_param('userid','',PARAM_ALPHANUMEXT); $linkgroup = optional_param('linkgroup', '', PARAM_TEXT); $depth = optional_param('depth', '7', PARAM_INT); $direction = optional_param('direction', 'both', PARAM_TEXT); $labelmatch = optional_param('labelmatch', 'false', PARAM_TEXT); $nodetypes = optional_param('nodetypes', null, PARAM_TEXT); $response = getConnectionsByPath($nodeid, $linklabels, $userid, $scope, $linkgroup, $depth, $direction, $labelmatch, $nodetypes, $style, $status);
include_once "../../config.php"; $me = substr($_SERVER["PHP_SELF"], 1); // remove initial '/' if ($HUB_FLM->hasCustomVersion($me)) { $path = $HUB_FLM->getCodeDirPath($me); include_once $path; die; } checkLogin(); include_once $HUB_FLM->getCodeDirPath("ui/headerdialog.php"); $errors = array(); $nodeid = required_param("nodeid", PARAM_ALPHANUMEXT); $groupid = optional_param("groupid", "", PARAM_ALPHANUMEXT); $handler = optional_param("handler", "", PARAM_TEXT); //convert any possible brackets $handler = parseToJSON($handler); $issue = optional_param("issue", "", PARAM_TEXT); $desc = optional_param("desc", "", PARAM_HTML); $resourcetypesarray = optional_param("resourcetypesarray", "", PARAM_TEXT); $resourcetitlearray = optional_param("resourcetitlearray", "", PARAM_TEXT); $resourceurlarray = optional_param("resourceurlarray", "", PARAM_URL); $identifierarray = optional_param("identifierarray", "", PARAM_TEXT); $resourcenodeidsarray = optional_param("resourcenodeidsarray", "", PARAM_TEXT); $resourcecliparray = optional_param("resourcecliparray", "", PARAM_TEXT); $resourceclippatharray = optional_param("resourceclippatharray", "", PARAM_TEXT); if (isset($_POST["editissue"])) { if ($issue == "") { array_push($errors, $LNG->FORM_ISSUE_ENTER_SUMMARY_ERROR); } if (empty($errors)) { $private = optional_param("private", "Y", PARAM_ALPHA);
* * ********************************************************************************/ include_once "../../config.php"; $me = substr($_SERVER["PHP_SELF"], 1); // remove initial '/' if ($HUB_FLM->hasCustomVersion($me)) { $path = $HUB_FLM->getCodeDirPath($me); include_once $path; die; } array_push($HEADER, "<link rel='stylesheet' href='" . $HUB_FLM->getStylePath("style.css") . "' type='text/css' media='screen' />"); array_push($HEADER, "<link rel='stylesheet' href='" . $HUB_FLM->getStylePath("stylecustom.css") . "' type='text/css' media='screen' />"); array_push($HEADER, "<script src='" . $HUB_FLM->getCodeWebPath("ui/users.js.php") . "' type='text/javascript'></script>"); include_once $HUB_FLM->getCodeDirPath("ui/headerdialog.php"); $connectionids = optional_param("connectionids", "", PARAM_TEXT); $connectionids = parseToJSON($connectionids); ?> <script type="text/javascript"> //<![CDATA[ var LINKTYPELABEL_CUTOFF = 18; var connectionids = "<?php echo $connectionids; ?> "; var connections = ""; /** * Display a list of connections with no numbers and checkboxes */ function displayMultipleConnections(objDiv,conns, start, direction, includemenu, type){
$nodeids = array(''); // This only works because nodes are not transcluded in Debate Hub $argumentConnections = getConnectionsByPathByDepth($logictype, $scope, $labelmatch, $fromNode->nodeid, $depth, $linklabels, $linkgroups, $directions, $nodetypes, $nodeids, $uniquepath, $style, $status); $args = $argumentConnections->connections; $countargs = count($args); if ($countargs > 0) { $json .= ',"children": ['; for ($k = 0; $k < $countargs; $k++) { $conarg = $args[$k]; $fromNodeArg = $conarg->from; $json .= "{"; $json .= '"name": "' . parseToJSON($fromNodeArg->name) . '",'; $size = $fromNodeArg->positivevotes; $json .= '"size": "50",'; $json .= '"nodetype": "' . parseToJSON($fromNodeArg->role->name) . '",'; $json .= '"nodetypename": "' . getNodeTypeText(parseToJSON($fromNodeArg->role->name), false) . '"'; $json .= '}'; if ($k < $countargs - 1) { $json .= ','; } } $json .= ']'; } else { $json .= ',"size": "50"'; } $json .= '}'; if ($j < $countcons - 1) { $json .= ','; } } $json .= ']';
/** * Helper function for the Circle Packing Attention function. Recurses the data tree */ function addNextCirclePackingAttentionDepth($json, $node, $depth, $treeArray, $checkArray, $circlesizearray, $circlecolorarray) { $json .= '{'; $json .= '"name": "' . parseToJSON($node->name) . '",'; $json .= '"nodetype": "' . parseToJSON($node->rolename) . '",'; $json .= '"nodetypename": "' . getNodeTypeText(parseToJSON($node->rolename), false) . '"'; if (array_key_exists($node->nodeid, $circlecolorarray)) { $json .= ',"colornumber": "' . round($circlecolorarray[$node->nodeid], 1) . '"'; } else { $json .= ',"colornumber": "0"'; //error_log("Color not found for:".$node->nodeid); } $treeitem = $treeArray[$node->nodeid]; if (isset($treeitem["children"]) && count($treeitem["children"]) > 0 && !array_key_exists($node->nodeid, $checkArray)) { // make sure you don't recurse the same set of children more than once. $checkArray[$node->nodeid] = $node->nodeid; $children = $treeitem["children"]; $countkids = count($children); $json .= ',"children": ['; for ($i = 0; $i < $countkids; $i++) { $child = $children[$i]; $json = addNextCirclePackingAttentionDepth($json, $child, $depth + 1, $treeArray, $checkArray, $circlesizearray, $circlecolorarray); if ($i < $countkids - 1) { $json .= ','; } } $json .= "]"; } $circlesize = 0; //(2000-(20*$depth)); if (array_key_exists($node->nodeid, $circlesizearray)) { $circlesize = $circlesizearray[$node->nodeid]; } $json .= ',"size": ' . $circlesize; $json .= "}"; return $json; }
/** * Helper function for formatting the output to JSON * * @param string $node name of the node * @param Object $objects data to format * @return string */ function phpToJSONInner($node, $objects) { $str = '"' . $node . '":'; $str .= "["; $count = count($objects); if (is_array($objects) && $count > 0) { $str .= "{"; $i = 0; // Dealing with an associative array in a class (like properties in Node) //for ($i=0; $i<$count; $i++){ //$obj = $objects[$i]; foreach ($objects as $key => $value) { $obj = $objects[$key]; // Dealing with an associative array in a class (like properties in Node) if (is_object($obj)) { $attr = get_object_vars($obj); $keys = array_keys($attr); $str .= '"' . strtolower(get_class($obj)) . '":'; $str .= '{'; $countj = count($keys); for ($j = 0; $j < $countj; $j++) { $next = $attr[$keys[$j]]; $isArray = false; if (is_array($next)) { $isArray = true; } else { if (is_object($next)) { $attr2 = get_object_vars($next); if (is_array($attr2)) { $isArray = true; } } } if ($isArray) { $str .= $this->phpToJSONInner($keys[$j], $next); } else { $str .= '"' . $keys[$j] . '":"' . parseToJSON($next) . '"'; } if ($j != $countj - 1) { $str .= ','; } } $str .= '}'; if ($i != $count - 1) { $str .= '},{'; } } else { if (is_array($value)) { $str .= $this->phpToJSONInner($key, $value); } else { $str .= '"' . parseToJSON($key) . '":"' . parseToJSON($value) . '"'; } if ($i != $count - 1) { $str .= ','; } } $i++; } $str .= "}"; } else { if (!is_array($objects)) { $str .= '{'; $obj = $objects; $attr = get_object_vars($obj); $keys = array_keys($attr); $str .= '"' . strtolower(get_class($obj)) . '":'; $str .= '{'; $countj = count($keys); for ($j = 0; $j < $countj; $j++) { $next = $attr[$keys[$j]]; $isArray = false; if (is_array($next)) { $isArray = true; } else { if (is_object($next)) { $attr2 = get_object_vars($next); if (is_array($attr2)) { $isArray = true; } } } if ($isArray) { $str .= $this->phpToJSONInner($keys[$j], $next); } else { $str .= '"' . $keys[$j] . '":"' . parseToJSON($next) . '"'; } if ($j != sizeof($keys) - 1) { $str .= ','; } } $str .= '}}'; } } $str .= "]"; return $str; }