url_match('http://scratch.mit.edu/projects/'); } /** * * @param HttpResource $asset */ public function render($asset) { if (!$this->accept($asset)) { return; } $matches = array(); $pattern = "#http:\/\/scratch.mit.edu\/projects\/(\w+)/(\d*)\/?#ims"; preg_match($pattern, $asset->url(), $matches); $url = $matches[0]; $author = $matches[1]; $project_id = $matches[2]; $project_url = "../../static/projects/$author/$project_id.sb"; $image_url = "http://scratch.mit.edu/static/projects/$author/{$project_id}_med.png"; $thumb_url = "http://scratch.mit.edu/static/projects/$author/{$project_id}_sm.png"; $height = 387; $width = 482; if (function_exists('get_string')) { $no_java = get_string('no_java', 'artefact.extresource'); } else { $no_java = 'Java is not installed on your computer. You must install java first.'; } $embed = <<
$no_java
EOT; $result = array(); $result[self::EMBED_SNIPPET] = $embed; $result[self::THUMBNAIL] = $thumb_url; return $result; } }