/** * Populates Source View Model * @return Source_Vm */ public function Build() { $fname = FileHelper::getFilename(); $data = FileHelper::getFile(Config::$SongDirectory . $fname); $viewModel = new Source_Vm(); $viewModel->PageTitle = 'Song Source for "' . $fname . '" ChordPro (CPM)/UkeGeeks File Format'; $viewModel->Body = htmlspecialchars($data); return $viewModel; }
/** * 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; }