return $p;
}
$lists = CollectionList::where('collection', $collection->id)->get();
- $partition = $song->getFirstMediaInField('partition');
- if ($partition) {
- $partition = $partition->getUrl();
- }
- $lyrics_doc = $song->getFirstMediaInField('lyrics_doc');
-
- if ($lyrics_doc) {
- $path = new \SplFileInfo($lyrics_doc->getPath());
- $html_path = $path->getPath() . '/html';
- $htmlFile = $html_path . '/' . $path->getBasename('.' . $path->getExtension()) . '.HTML';
- if (!file_exists($htmlFile)) {
- $cmd = "export HOME=/tmp;/usr/bin/libreoffice --convert-to HTML:HTML --outdir $html_path --headless $path";
- `$cmd`;
+ $partition=false;
+ $lyrics_html='';
+
+ if($song->chorale) {
+ try {
+ $partition = $song->getFirstMediaInField('partition');
+ if ($partition) {
+ $partition = $partition->getUrl();
+ }
+ } catch (\Exception $e) {
+
+ }
+
+
+ try {
+ $lyrics_doc = $song->getFirstMediaInField('lyrics_doc');
+
+ if ($lyrics_doc) {
+ $path = new \SplFileInfo($lyrics_doc->getPath());
+ $html_path = $path->getPath() . '/html';
+ $htmlFile = $html_path . '/' . $path->getBasename('.' . $path->getExtension()) . '.HTML';
+ if (!file_exists($htmlFile)) {
+ $cmd = "export HOME=/tmp;/usr/bin/libreoffice --convert-to HTML:HTML --outdir $html_path --headless $path";
+ `$cmd`;
+ }
+ $lyrics_html = file_get_contents($htmlFile);
+ //$lyrics_html = str_replace('<style', '<style scoped', $lyrics_html);
+ }
+ } catch (\Exception $e) {
+
}
- $lyrics_html = file_get_contents($htmlFile);
- //$lyrics_html = str_replace('<style', '<style scoped', $lyrics_html);
}
return view('song', ['menu' => true, 'lyrics_html' => $lyrics_html, 'song' => $song, 'collection' => $collection, 'partition' => $partition, 'collection_songs' => $this->_getSongsOfCollection($collection->id, $lists), 'collection_lists' => $lists]);
}
$zip->addFile($file, $f->getFilename());
}
$zip->close();
- return response()->download($tmp, $song->title . '.zip')->deleteFileAfterSend();
+ return response()->download($tmp, $song->title . '.zip', ['Content-Type' => 'application/zip'], 'attachment')->deleteFileAfterSend();
}
}