/**
  * @param $data
  * @param $form
  * @return mixed
  */
 public function doUpload($data, $form)
 {
     $material = PresentationSlide::create();
     $material->SlideID = $data['Slide'];
     $material->write();
     $this->presentation->Materials()->filter(['ClassName' => 'PresentationSlide'])->removeAll();
     $this->presentation->Materials()->add($material);
     $token = SecurityToken::inst()->getValue();
     return $form->controller()->redirect(Controller::join_links($form->controller()->Link(), 'success', "?key={$token}&material={$material->ID}"));
 }
 /**
  * @param $data
  * @param Form $form
  * @return bool|SS_HTTPResponse
  */
 public function saveLink($data, Form $form)
 {
     $url = $data['Link'];
     // Attach a protocol if needed
     if (substr($url, 0, 7) != 'http://' && substr($url, 0, 8) != 'https://') {
         $url = 'http://' . $url;
     }
     if (!filter_var($url, FILTER_VALIDATE_URL)) {
         $form->sessionMessage('That does not appear to be a valid URL', 'bad');
         return $this->Controller()->redirectBack();
     }
     $material = PresentationSlide::create();
     $material->Link = $url;
     $material->write();
     $this->presentation->Materials()->filter(['ClassName' => 'PresentationSlide'])->removeAll();
     $this->presentation->Materials()->add($material);
     $token = SecurityToken::inst()->getValue();
     return $this->Controller()->redirect(Controller::join_links($this->Controller()->Link(), 'success', "?key={$token}&material={$material->ID}"));
 }