Пример #1
15
 /**
  * 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();
 }
Пример #2
0
 /**
  * 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;
 }
Пример #3
0
 /**
  * Does not validate values, but does ensure only valid JSON was provided.
  * @method getSettings
  * @return string
  */
 private function getSettings()
 {
     $settings = FileHelper::getFile(Config::$AppDirectory . 'settings.json');
     if ($settings === null) {
         return '{}';
     }
     if (!function_exists('json_decode')) {
         return $settings;
     }
     $json = preg_replace("#(/\\*([^*]|[\r\n]|(\\*+([^*/]|[\r\n])))*\\*+/)|([\\s\t]//.*)|(^//.*)#", '', $settings);
     if (json_decode($json)) {
         return $settings;
     }
     return '{"invalidJson": "There is a problem with your settings: invalid JSON. Please check for typos."}';
 }