コード例 #1
0
 public function getMod($slug)
 {
     $table_javascript = route('tdf_name', ['modmodpacks', '0', $slug]);
     $mod = Mod::where('slug', '=', $slug)->first();
     if (!$mod) {
         $redirect = new URLRedirect();
         $do_redirect = $redirect->getRedirect(Request::path());
         if ($do_redirect) {
             return Redirect::to($do_redirect->target, 301);
         }
         App::abort(404);
     }
     $can_edit = false;
     if (Auth::check()) {
         $maintainer = $mod->maintainers()->where('user_id', Auth::id())->first();
         if ($maintainer) {
             $can_edit = true;
         }
     }
     $authors = $mod->authors;
     $spotlights = $mod->youtubeVideos()->where('category_id', 2)->get();
     $tutorials = $mod->youtubeVideos()->where('category_id', 3)->get();
     $raw_links = ['website' => $mod->website, 'download_link' => $mod->download_link, 'donate_link' => $mod->donate_link, 'wiki_link' => $mod->wiki_link];
     $links = [];
     foreach ($raw_links as $index => $link) {
         if ($link != '') {
             $links["{$index}"] = $link;
         }
     }
     $markdown_html = Parsedown::instance()->setBreaksEnabled(true)->text(strip_tags($mod->description));
     $mod_description = str_replace('<table>', '<table class="table table-striped table-bordered">', $markdown_html);
     $title = $mod->name . ' - Mod - ' . $this->site_name;
     $meta_description = $mod->deck;
     return View::make('mods.detail', ['table_javascript' => $table_javascript, 'mod' => $mod, 'mod_description' => $mod_description, 'links' => $links, 'authors' => $authors, 'title' => $title, 'meta_description' => $meta_description, 'sticky_tabs' => true, 'spotlights' => $spotlights, 'tutorials' => $tutorials, 'can_edit' => $can_edit]);
 }
コード例 #2
0
 public function getModpack($version, $slug)
 {
     $mods_javascript = route('tdf_name', ['modpackmods', $version, $slug]);
     $friendly_version = $this->getVersion($version);
     $modpack = Modpack::where('slug', '=', $slug)->first();
     if (!$modpack) {
         $redirect = new URLRedirect();
         $do_redirect = $redirect->getRedirect(Request::path());
         if ($do_redirect) {
             return Redirect::to($do_redirect->target, 301);
         }
         App::abort(404);
     }
     $can_edit = false;
     $has_servers = false;
     if (Auth::check()) {
         $maintainer = $modpack->maintainers()->where('user_id', Auth::id())->first();
         if ($maintainer) {
             $can_edit = true;
         }
     }
     $launcher = $modpack->launcher;
     $creators = $modpack->creators;
     $creators_formatted = implode(', ', array_map(function ($creator) {
         return $creator['name'];
     }, $creators->toArray()));
     $pack_code = $modpack->code;
     $tags = $modpack->tags;
     $tags_formatted = implode(', ', array_map(function ($tag) {
         return link_to(action('SearchController@getModpackSearch') . '?tag=' . $tag['slug'], $tag['name'], ['title' => $tag['deck']]);
     }, $tags->toArray()));
     $server_count = $modpack->servers()->where('active', 1)->count();
     $twitch_streams = $modpack->twitchStreams()->orderBy('viewers', 'desc')->get();
     $lets_plays = $modpack->youtubeVideos()->where('category_id', 1)->get();
     if ($server_count > 0) {
         $has_servers = true;
     }
     $server_javascript = route('tdf', ['servers', 'all']) . '?modpack=' . $modpack->id;
     $raw_links = ['website' => $modpack->website, 'download_link' => $modpack->download_link, 'donate_link' => $modpack->donate_link, 'wiki_link' => $modpack->wiki_link];
     $links = [];
     foreach ($raw_links as $index => $link) {
         if (!empty($link)) {
             $links[] = ['type' => $index, 'link' => $link];
         }
     }
     $links_formatted = implode(' | ', array_map(function ($link) {
         if ($link['type'] == 'website') {
             return "<a href='{$link['link']}'><i class='fa fa-external-link'></i>Website</a>";
         }
         if ($link['type'] == 'download_link') {
             return "<a href='{$link['link']}'><i class='fa fa-download'></i>Download</a>";
         }
         if ($link['type'] == 'donate_link') {
             return "<a href='{$link['link']}'><i class='fa fa-dollar'></i>Donate</a>";
         }
         if ($link['type'] == 'wiki_link') {
             return "<a href='{$link['link']}'><i class='fa fa-book'></i>Wiki</a>";
         }
         return '';
     }, $links));
     $table_javascript = [$mods_javascript, $server_javascript];
     $markdown_html = Parsedown::instance()->setBreaksEnabled(true)->text(strip_tags($modpack->description));
     $modpack_description = str_replace('<table>', '<table class="table table-striped table-bordered">', $markdown_html);
     $title = $modpack->name . ' - ' . $friendly_version . ' Modpack - ' . $this->site_name;
     $meta_description = $modpack->deck;
     return View::make('modpacks.detail', ['table_javascript' => $table_javascript, 'modpack' => $modpack, 'modpack_description' => $modpack_description, 'links' => $links, 'links_formatted' => $links_formatted, 'launcher' => $launcher, 'creators' => $creators, 'creators_formatted' => $creators_formatted, 'tags' => $tags, 'tags_formatted' => $tags_formatted, 'servers' => $has_servers, 'title' => $title, 'meta_description' => $meta_description, 'pack_code' => $pack_code, 'version' => $version, 'twitch_streams' => $twitch_streams, 'lets_plays' => $lets_plays, 'has_servers' => $has_servers, 'can_edit' => $can_edit, 'sticky_tabs' => true]);
 }