/** * Handles requests to view a vidyard video in the cms * @param {SS_HTTPRequest} $request HTTP Request object * @return {string} Rendered view on success null on error * @throws SS_HTTPResponse_Exception */ public function viewvidyard(SS_HTTPRequest $request) { $file = null; $url = null; if ($fileUrl = $request->getVar('VidyardURL')) { // If this isn't an absolute URL, or is, but is to this site, try and get the File object // that is associated with it if (Director::is_absolute_url($fileUrl) && !Director::is_site_url($fileUrl) && Vidyard::validateVidyardURL($fileUrl)) { list($file, $url) = $this->getVideoByURL($fileUrl); } else { throw new SS_HTTPResponse_Exception('"VidyardURL" is not a valid Vidyard Video', 400); } } else { throw new SS_HTTPResponse_Exception('Need "VidyardURL" parameter to identify the file', 400); } $fileWrapper = new VidyardInsertMedia_Embed($url, $file); $fields = $this->getFieldsForVidyard($url, $fileWrapper); return $fileWrapper->customise(array('Fields' => $fields))->renderWith('HtmlEditorField_viewfile'); }