/**
  * Emits list of links to all songs in the directory.
  * @method buildFileList
  * @return (song array)
  */
 private function buildFileList($files)
 {
     $list = new SongListPlus_Pvm();
     foreach ($files as $fname) {
         $s = preg_replace(Config::FileNamePattern, '$1', $fname);
         $content = FileHelper::getFile(Config::$SongDirectory . $fname);
         $parsed = SongHelper::parseSong($content);
         $song = new SongLinkPlus_Pvm();
         $song->Uri = Ugs::MakeUri(Actions::Song, $s);
         $song->HasInfo = strlen($parsed->title) + strlen($parsed->artist) > 0;
         $song->Title = $this->fixLeadingArticle(strlen($parsed->title) > 0 ? $parsed->title : $this->filenameToTitle($s));
         $song->Subtitle = $parsed->subtitle;
         $song->Album = $parsed->album;
         $song->Artist = $parsed->artist;
         $list->SongList[] = $song;
     }
     return $list->Sort();
 }
Exemple #2
0
 /**
  * Parses file (using URL query param) and attempts to load View Model
  * @return Song_Vm
  */
 public function Build()
 {
     $filename = FileHelper::getFilename();
     $fileContent = FileHelper::getFile(Config::$SongDirectory . $filename);
     $song = SongHelper::parseSong($fileContent);
     $title = htmlspecialchars($song->isOK ? $song->title . (strlen($song->subtitle) > 0 ? ' | ' . $song->subtitle : '') : 'Not Found');
     $viewModel = new Song_Vm();
     $viewModel->PageTitle = $this->MakePageTitle($song, $filename);
     $viewModel->SongTitle = htmlspecialchars($song->title);
     $viewModel->Subtitle = htmlspecialchars($song->subtitle);
     $viewModel->Artist = $song->artist;
     $viewModel->Album = $song->album;
     // htmlspecialchars();
     $viewModel->Body = $song->body;
     $viewModel->UgsMeta = $song->meta;
     $viewModel->SourceUri = Ugs::MakeUri(Actions::Source, $filename);
     $viewModel->EditUri = Ugs::MakeUri(Actions::Edit, $filename);
     $viewModel->Id = $filename;
     $viewModel->IsUpdateAllowed = $this->SiteUser->MayEdit && $this->SiteUser->IsAuthenticated;
     $viewModel->EditorSettingsJson = $this->getSettings();
     return $viewModel;
 }