diff --git a/configs/AppConfig.inc b/configs/AppConfig.inc index 5f0e0485..3e8d92da 100644 --- a/configs/AppConfig.inc +++ b/configs/AppConfig.inc @@ -59,7 +59,8 @@ * @var array */ public static $dirs = array( - 'locale' => 'locale' + 'locale' => 'locale', + 'media' => 'media' ); diff --git a/controllers/MediaController.inc b/controllers/MediaController.inc index 60ad460d..7d80a897 100644 --- a/controllers/MediaController.inc +++ b/controllers/MediaController.inc @@ -46,7 +46,13 @@ /** - * TODO Action: index. + * Action: index. + * + * Display a medium without processing. + * + * @throws IdNotFoundException + * @param string $seminaryUrl URL-title of the Seminary + * @param string $mediaUrl URL-name of the medium */ public function index($seminaryUrl, $mediaUrl) { @@ -60,7 +66,10 @@ $this->response->addHeader("Content-type: ".$media['mimetype'].""); // Set filename - $media['filename'] = ROOT.DS.'media'.DS.$media['id']; + $media['filename'] = ROOT.DS.\nre\configs\AppConfig::$dirs['media'].DS.$media['id']; + if(!file_exists($media['filename'])) { + throw new \nre\exceptions\IdNotFoundException($mediaUrl); + } // Pass data to view