public function answers($id, $author = null, $tag = null, $keyword = null)
 {
     $parent = Artefact::all()->find($id);
     $parent = BmoocJsonController::search($parent, $author, $tag, $keyword);
     $tree = $parent;
     $parent->children = BmoocJsonController::buildTree($parent->children, $parent->id, $author, $tag, $keyword);
     return response()->json($tree);
 }
예제 #2
0
 public function getThumbnails(Request $request)
 {
     $user = Auth::user();
     if (!$user || $user->role != "editor") {
         App::abort(401, 'Not authenticated');
     }
     // get a list of all the local pdf's & images
     $artefacts = Artefact::where('artefact_type', '29')->orWhere('artefact_type', '33')->get();
     // check which image sizes are available
     $basepath = base_path() . '/../uploads/thumbnails';
     foreach ($artefacts as $artefact) {
         $sizes = array();
         if (file_exists($basepath . '/../' . $artefact->url)) {
             array_push($sizes, 'original');
         }
         if (file_exists($basepath . '/small/' . $artefact->url)) {
             array_push($sizes, 'small');
         }
         if (file_exists($basepath . '/large/' . $artefact->url)) {
             array_push($sizes, 'large');
         }
         $artefact->setAttribute('sizes', $sizes);
     }
     return view('admin/thumbnails', ['artefacts' => $artefacts]);
 }
예제 #3
0
 public function getImageOriginal($id)
 {
     $a = Artefact::find($id);
     $path = base_path() . '/../uploads/' . $a->url;
     if (file_exists($path)) {
         $filetype = mime_content_type($path);
         $response = Response::make(File::get($path), 200);
         $response->header('Content-Type', $filetype);
         return $response;
     } else {
         if ($a->artefact_type == 31) {
             $url = str_replace('www.youtube.com/embed', 'img.youtube.com/vi', $a->url);
             $url .= '/0.jpg';
             $response = Response::make(file_get_contents($url), 200);
             $response->header('Content-Type', 'image/jpeg');
             return $response;
         } else {
             if ($a->artefact_type == 32) {
                 $oembed_endpoint = 'http://vimeo.com/api/oembed';
                 $url = $oembed_endpoint . '.json?url=' . rawurlencode($a->url);
                 $json = file_get_contents($url);
                 $obj = json_decode($json);
                 $response = Response::make(file_get_contents($obj->thumbnail_url), 200);
                 $response->header('Content-Type', 'image/jpeg');
                 return $response;
             }
         }
     }
     abort(404, 'Image not found');
 }