示例#1
0
 /**
  * allowContentItem - Returns true if we can return LTI Link Items
  */
 public static function allowContentItem($postdata)
 {
     if (!isset($postdata['content_item_return_url'])) {
         return false;
     }
     if (isset($postdata['accept_media_types'])) {
         $web_mimetype = 'text/html';
         $m = new Mimeparse();
         $web_allowed = $m->best_match(array($web_mimetype), $postdata['accept_media_types']);
         if ($web_mimetype != $web_allowed) {
             return false;
         }
         return true;
     }
     return false;
 }
示例#2
0
 }
 if ($ltilink_allowed && $_POST['content_item_return_url']) {
     print '<p><form action="json/content_json.php" method="post">' . "\n";
     foreach ($_POST as $k => $v) {
         print '<input type="hidden" name="' . $k . '" ';
         print 'value="' . htmlentities($v) . '"/>';
     }
     print '<input type="submit" value="Test LtiLink Content Item"/>';
     print "</form></p>\n";
     $found = true;
 }
 $fileitem_allowed = false;
 if (isset($_POST['accept_media_types'])) {
     $fileitem_mimetype = 'application/vnd.ims.imsccv1p3';
     $m = new Mimeparse();
     $fileitem_allowed = $m->best_match(array($fileitem_mimetype), $_POST['accept_media_types']);
 }
 if ($fileitem_allowed && $_POST['content_item_return_url']) {
     print '<p><form action="json/fileitem_json.php" method="post">' . "\n";
     foreach ($_POST as $k => $v) {
         print '<input type="hidden" name="' . $k . '" ';
         print 'value="' . htmlentities($v) . '"/>';
     }
     print '<input type="submit" value="Test FileItem Content Item"/>';
     print "</form></p>\n";
     $found = true;
 }
 if (!$found) {
     echo "<p>No Services are available for this launch.</p>\n";
 }
 print "<pre>\n";
示例#3
0
 /**
  * Matches an array of mime types against the Accept header in a request.
  *
  * @param Zend_Controller_Request_Abstract $request            the request
  * @param array                            $supportedMimetypes The mime types to match against
  *
  * @return string
  */
 public static function matchMimetypeFromRequest(Zend_Controller_Request_Abstract $request, array $supportedMimetypes)
 {
     // get accept header
     $acceptHeader = strtolower($request->getHeader('Accept'));
     require_once 'Mimeparse.php';
     try {
         $match = @Mimeparse::best_match($supportedMimetypes, $acceptHeader);
     } catch (Exception $e) {
         $match = '';
     }
     return $match;
 }