/** * Request gadget metadata from shindig * * Takes $gadget as a parameter and adds height and name for it */ function set_gadget_metadata($gadget_url, $gadget) { global $CFG; require_once $CFG->dirroot . '/mod/widgetspace/lib/container.php'; $gadget_container = new GadgetContainer(null); $shindig_url = $gadget_container->get_shindig_url(); $request = $shindig_url . '/gadgets/metadata?st=0:0:0:0:0:0:0'; $c = new curl(); $c->setopt(array('CURLOPT_TIMEOUT' => 3, 'CURLOPT_CONNECTTIMEOUT' => 3, 'CURLOPT_HTTPHEADER' => array("Content-Type: application/json", "Accept: application/json"))); // , "Content-length: ".strlen($data) $data = '{"context":{"view":"canvas","container":"default"},"gadgets":[{"url":"' . $gadget_url . '", "moduleId":0}]}'; $response = $c->post($request, $data); $json = json_decode($response); // var_dump($json); $gadgets = $json->gadgets; //set height of gadget $gadget->height = $gadgets[0]->height == 0 ? 200 : $gadgets[0]->height; $gadget->name = $gadgets[0]->title; //set name of gadget $gadget->thumbnail = $gadgets[0]->thumbnail; $gadget->screenshot = $gadgets[0]->screenshot; $gadget->description = $gadgets[0]->description; }
$PAGE->set_heading(''); } echo $OUTPUT->header(); } else { $PAGE->set_title($course->shortname . ': ' . $widgetspace->name); $PAGE->set_heading($course->fullname); $PAGE->set_activity_record($widgetspace); echo $OUTPUT->header(); if (!empty($options['printheading'])) { echo $OUTPUT->heading(format_string($widgetspace->name), 2, 'main', 'widgetspaceheading'); } } if (!empty($options['printintro'])) { if (trim(strip_tags($widgetspace->intro))) { echo $OUTPUT->box_start('mod_introbox', 'widgetspaceintro'); echo format_module_intro('widgetspace', $widgetspace, $cm->id); echo $OUTPUT->box_end(); } } $content = file_rewrite_pluginfile_urls($widgetspace->content, 'pluginfile.php', $context->id, 'mod_widgetspace', 'content', $widgetspace->revision); $formatoptions = array('noclean' => true, 'overflowdiv' => true); $content = format_text($content, $widgetspace->contentformat, $formatoptions, $course->id); echo $OUTPUT->box($content, "generalbox center clearfix"); // add widgets container // build container with 1-2-3 columns and add gadgets to it require_once $CFG->dirroot . '/mod/widgetspace/lib/container.php'; $gadget_container = new GadgetContainer($widgetspace->id); $gadget_container->build(); $strlastmodified = get_string("lastmodified"); echo "<div class=\"modified\">{$strlastmodified}: " . userdate($widgetspace->timemodified) . "</div>"; echo $OUTPUT->footer();