Пример #1
0
 protected function renderEx($tplPath)
 {
     $_['cssPath'] = $tplPath . '/css';
     $_['cat'] = 'playlist';
     $status = $this->mpd->executeCommand('status');
     if (isset($status['songid'])) {
         $_['playlistAnchor'] = '#' . $status['songid'];
     } else {
         $_['playlistAnchor'] = '';
     }
     $_['imagePath'] = $tplPath . '/images';
     $_['name'] = htmlspecialchars($this->name);
     $_['result'] = $this->result;
     $_['resultColor'] = $this->resultColor;
     $_['uid'] = $_SESSION['uid'];
     // per playlist:
     // pos, name, lastModified, overwriteUrl, deleteUrl, cssClass, imageClass
     $playlists = $this->mpdHelper->getPlaylists();
     $count = 0;
     $_['playlists'] = array();
     foreach ($playlists as $item) {
         $count++;
         $playlist = array();
         $playlist['pos'] = $count;
         $playlist['name'] = htmlspecialchars($item['playlist']);
         $playlist['lastModified'] = Utils\Utils::formatDateISO8601($item['Last-Modified'], TRUE);
         $playlist['overwriteUrl'] = $_SERVER['PHP_SELF'] . '?cat=playlist' . '&page=save' . '&uid=' . $_SESSION['uid'] . '&action=overwrite' . '&name=' . htmlspecialchars(rawurlencode($item['playlist']));
         $playlist['deleteUrl'] = $_SERVER['PHP_SELF'] . '?cat=playlist' . '&page=save' . '&uid=' . $_SESSION['uid'] . '&action=delete' . '&name=' . htmlspecialchars(rawurlencode($item['playlist']));
         if ($count % 2 == 1) {
             $playlist['cssClass'] = 'dark';
             $playlist['imageClass'] = '-dark';
         } else {
             $playlist['cssClass'] = '';
             $playlist['imageClass'] = '';
         }
         $_['playlists'][] = $playlist;
     }
     include './templates/common/Header.tpl.php';
     include './templates/common/Navigation.tpl.php';
     include './templates/common/PlaylistSave.tpl.php';
     include './templates/common/Footer.tpl.php';
 }
Пример #2
0
 protected function renderEx($tplPath)
 {
     $_['cssPath'] = $tplPath . '/css';
     $_['cat'] = 'browse';
     $status = $this->mpd->executeCommand('status');
     if (isset($status['songid'])) {
         $_['playlistAnchor'] = '#' . $status['songid'];
     } else {
         $_['playlistAnchor'] = '';
     }
     $_['imagePath'] = $tplPath . '/images';
     $_['compilation'] = htmlspecialchars($this->compilation);
     $_['backUrl'] = $_SERVER['PHP_SELF'] . '?cat=browse' . '&page=compilations';
     $_['homeUrl'] = $_SERVER['PHP_SELF'] . '?cat=browse' . '&page=root';
     $_['addAllUrl'] = $_SERVER['PHP_SELF'] . '?cat=browse' . '&page=compilation' . '&uid=' . $_SESSION['uid'] . '&action=addAll' . '&compilation=' . htmlspecialchars(rawurlencode($this->compilation));
     // per song: track, artist, title, length, addUrl, cssClass, imageClass
     $songs = $this->mpdHelper->getSongsByCompilation($this->compilation);
     $count = 0;
     $_['songs'] = array();
     foreach ($songs as $item) {
         $count++;
         $song = array();
         $song['track'] = htmlspecialchars($item['Track']);
         $song['artist'] = htmlspecialchars($item['Artist']);
         $song['title'] = htmlspecialchars($item['Title']);
         $song['time'] = Utils\Utils::formatTimeShort($item['Time']);
         $song['addUrl'] = $_SERVER['PHP_SELF'] . '?cat=browse' . '&page=compilation' . '&uid=' . $_SESSION['uid'] . '&action=add' . '&file=' . htmlspecialchars(rawurlencode($item['file']));
         if ($count % 2 == 1) {
             $song['cssClass'] = 'dark';
             $song['imageClass'] = '-dark';
         } else {
             $song['cssClass'] = '';
             $song['imageClass'] = '';
         }
         $_['songs'][] = $song;
     }
     include './templates/common/Header.tpl.php';
     include './templates/common/Navigation.tpl.php';
     include './templates/common/BrowseCompilation.tpl.php';
     include './templates/common/Footer.tpl.php';
 }
Пример #3
0
 protected function renderEx($tplPath)
 {
     $_['cssPath'] = $tplPath . '/css';
     $_['cat'] = 'control';
     $status = $this->mpd->executeCommand('status');
     if (isset($status['songid'])) {
         $_['playlistAnchor'] = '#' . $status['songid'];
     } else {
         $_['playlistAnchor'] = '';
     }
     $_['imagePath'] = $tplPath . '/images';
     $actionUrl = $_SERVER['PHP_SELF'] . '?cat=control' . '&uid=' . $_SESSION['uid'] . '&action=';
     $_['skipBwUrl'] = $actionUrl . 'skipBw';
     $_['seekBwUrl'] = $actionUrl . 'seekBw';
     $_['playUrl'] = $actionUrl . 'play';
     $_['pauseUrl'] = $actionUrl . 'pause';
     $_['stopUrl'] = $actionUrl . 'stop';
     $_['seekFwUrl'] = $actionUrl . 'seekFw';
     $_['skipFwUrl'] = $actionUrl . 'skipFw';
     $_['volUpUrl'] = $actionUrl . 'volUp';
     $_['volume'] = $status['volume'];
     $_['volDownUrl'] = $actionUrl . 'volDown';
     switch ($status['state']) {
         case 'stop':
             $_['playing'] = FALSE;
             $_['stopped'] = TRUE;
             $_['state'] = '(stopped)';
             break;
         case 'play':
             $_['playing'] = TRUE;
             $_['stopped'] = FALSE;
             $_['state'] = 'now playing:';
             break;
         case 'pause':
             $_['playing'] = FALSE;
             $_['stopped'] = FALSE;
             $_['state'] = 'paused:';
             break;
     }
     $_['showVolumeControls'] = Config::SHOW_VOLUME_CONTROLS;
     if ($status['state'] != 'stop') {
         $song = $this->mpd->executeCommand('currentsong');
         $pathInfo = pathinfo($song['file']);
         if (isset($song['Title'])) {
             $_['title'] = htmlspecialchars($song['Title']);
         } else {
             $_['title'] = htmlspecialchars($pathInfo['filename']);
         }
         list($_['position'], $_['length']) = explode(':', $status['time']);
         $_['progress'] = '(<span id="elapsed">' . Utils\Utils::formatTimeShort($_['position']) . '</span>/' . Utils\Utils::formatTimeShort($_['length']) . ')';
         $_['info'] = 'by ';
         if (isset($song['Artist'])) {
             $_['info'] .= htmlspecialchars($song['Artist']);
         } else {
             $_['info'] .= 'Unknown Artist';
         }
         $_['info'] .= ' from ';
         if (isset($song['Album'])) {
             $_['info'] .= htmlspecialchars($song['Album']);
         } else {
             $_['info'] .= 'Unknown Album';
         }
         if (isset($song['Date'])) {
             $_['info'] .= ' <span>(</span>' . $song['Date'] . '<span>)</span>';
         }
         // Build path to cover image.
         //
         // $pathInfo['dirname'] is the path of the current track without the
         // filename relative to the MPD root (Config::MUSIC_ROOT). Example:
         //
         // Config::MUSIC_ROOT  : /home/user/music
         // $song['file']       : low/2011-c'mon/03-witches.flac
         // $pathInfo['dirname']: low/2011-c'mon
         // Config::COVER_NAME  : folder.jpg
         //
         // --> $tmpPath        : /home/user/music/low/2011-c'mon/folder.jpg
         $tmpPath = Config::MUSIC_ROOT . '/' . $pathInfo['dirname'] . '/' . CONFIG::COVER_NAME;
         // If cover image exists and is readable: make its thumbnail.
         if (file_exists($tmpPath) && is_readable($tmpPath)) {
             $_['coverPath'] = $this->thumbsCache->getThumbnail($tmpPath);
         } else {
             $_['coverPath'] = '';
         }
     } else {
         $_['title'] = '';
         $_['position'] = 0;
         $_['length'] = 0;
         $_['progress'] = '';
         $_['info'] = '';
         $_['coverPath'] = '';
     }
     $_['reloadUrl'] = $_SERVER['PHP_SELF'] . '?cat=control';
     $_['reloadTimeout'] = Config::RELOAD_TIMEOUT;
     include './templates/common/Header.tpl.php';
     include './templates/common/Navigation.tpl.php';
     include './templates/common/Control.tpl.php';
     include './templates/common/ControlFooter.tpl.php';
 }
Пример #4
0
 protected function renderEx($tplPath)
 {
     $_['cssPath'] = $tplPath . '/css';
     $_['cat'] = 'setup';
     $status = $this->mpd->executeCommand('status');
     if (isset($status['songid'])) {
         $_['playlistAnchor'] = '#' . $status['songid'];
     } else {
         $_['playlistAnchor'] = '';
     }
     $_['imagePath'] = $tplPath . '/images';
     $_['uid'] = $_SESSION['uid'];
     $_['browseOptions'] = array();
     $_['repeatOptions'] = array();
     $_['seekOptions'] = array();
     $_['sortOptions'] = array();
     $_['layoutOptions'] = array();
     foreach (array('folders', 'tags') as $value) {
         if ($value == $this->browseMode) {
             $_['browseOptions'][] = array('value' => $value, 'selected' => TRUE);
         } else {
             $_['browseOptions'][] = array('value' => $value, 'selected' => FALSE);
         }
     }
     foreach (array('off', 'on') as $value) {
         if ($value == $this->repeat) {
             $_['repeatOptions'][] = array('value' => $value, 'selected' => TRUE);
         } else {
             $_['repeatOptions'][] = array('value' => $value, 'selected' => FALSE);
         }
     }
     foreach (array(5, 10, 15, 30, 60) as $value) {
         if ($value == $this->seekInterval) {
             $_['seekOptions'][] = array('value' => $value, 'selected' => TRUE);
         } else {
             $_['seekOptions'][] = array('value' => $value, 'selected' => FALSE);
         }
     }
     foreach (array('date', 'name') as $value) {
         if ($value == $this->sortMode) {
             $_['sortOptions'][] = array('value' => $value, 'selected' => TRUE);
         } else {
             $_['sortOptions'][] = array('value' => $value, 'selected' => FALSE);
         }
     }
     foreach (array_keys(Config::$layouts) as $value) {
         if ($value == $this->layout) {
             $_['layoutOptions'][] = array('value' => $value, 'selected' => TRUE);
         } else {
             $_['layoutOptions'][] = array('value' => $value, 'selected' => FALSE);
         }
     }
     $_['updateUrl'] = $_SERVER['PHP_SELF'] . '?cat=setup' . '&amp;uid=' . $_SESSION['uid'] . '&amp;action=updateDatabase';
     $stats = $this->mpd->executeCommand('stats');
     $_['uptime'] = Utils\Utils::formatTimeLong($stats['uptime']);
     $_['playtime'] = Utils\Utils::formatTimeLong($stats['playtime']);
     $_['artists'] = $stats['artists'];
     $_['albums'] = $stats['albums'];
     $_['songs'] = $stats['songs'];
     $_['databasePlaytime'] = Utils\Utils::formatTimeLong($stats['db_playtime']);
     $_['databaseUpdated'] = Utils\Utils::formatDateUnix($stats['db_update'], TRUE);
     $_['version'] = Config::VERSION;
     $_['mpdProtocolVersion'] = $this->mpd->getProtocolVersion();
     include './templates/common/Header.tpl.php';
     include './templates/common/Navigation.tpl.php';
     include './templates/common/Setup.tpl.php';
     include './templates/common/Footer.tpl.php';
 }
Пример #5
0
 protected function renderEx($tplPath)
 {
     $_['cssPath'] = $tplPath . '/css';
     $_['cat'] = 'browse';
     $status = $this->mpd->executeCommand('status');
     if (isset($status['songid'])) {
         $_['playlistAnchor'] = '#' . $status['songid'];
     } else {
         $_['playlistAnchor'] = '';
     }
     $_['imagePath'] = $tplPath . '/images';
     $_['folder'] = '/' . htmlspecialchars($this->folder);
     $_['backUrl'] = $_SERVER['PHP_SELF'] . '?cat=browse' . '&amp;page=folder' . '&amp;uid=' . $_SESSION['uid'] . '&amp;action=cd' . '&amp;folder=' . htmlspecialchars(rawurlencode($this->parentFolder));
     $_['homeUrl'] = $_SERVER['PHP_SELF'] . '?cat=browse' . '&amp;page=folder' . '&amp;uid=' . $_SESSION['uid'] . '&amp;action=cd' . '&amp;folder=';
     $_['addAllUrl'] = $_SERVER['PHP_SELF'] . '?cat=browse' . '&amp;page=folder' . '&amp;uid=' . $_SESSION['uid'] . '&amp;action=add' . '&amp;uri=' . htmlspecialchars(rawurlencode($this->folder));
     // per directory: name, openUrl, cssClass, imageClass
     $dirContent = $this->mpd->executeCommand('lsinfo', $this->folder);
     $count = 0;
     $_['directories'] = array();
     $_['files'] = array();
     // Choose shortening with layout
     if ($tplPath = "Tablet") {
         $maxlen_dir = 80;
         $maxlen_file = 80;
     } else {
         $maxlen_dir = 25;
         $maxlen_file = 35;
     }
     foreach ($dirContent['directories'] as $item) {
         $count++;
         $directory = array();
         $pos = strrpos($item['directory'], '/');
         if ($pos == FALSE) {
             $directoryName = Utils\Utils::shortenStringUTF8($item['directory'], $maxlen_dir);
         } else {
             $directoryName = Utils\Utils::shortenStringUTF8(substr($item['directory'], $pos + 1), $maxlen_dir);
         }
         $directory['name'] = htmlspecialchars($directoryName);
         $directory['openUrl'] = $_SERVER['PHP_SELF'] . '?cat=browse' . '&amp;page=folder' . '&amp;uid=' . $_SESSION['uid'] . '&amp;folder=' . htmlspecialchars(rawurlencode($item['directory']));
         if ($count % 2 == 1) {
             $directory['cssClass'] = 'dark';
             $directory['imageClass'] = '-dark';
         } else {
             $directory['cssClass'] = '';
             $directory['imageClass'] = '';
         }
         $_['directories'][] = $directory;
     }
     // per file: name, time, addUrl, cssClass, imageClass
     foreach ($dirContent['files'] as $item) {
         $count++;
         $file = array();
         $pathInfo = pathinfo($item['file']);
         $file['name'] = htmlspecialchars(Utils\Utils::shortenStringUTF8($pathInfo['basename'], $maxlen_file));
         $file['time'] = Utils\Utils::formatTimeShort($item['Time']);
         $file['addUrl'] = $_SERVER['PHP_SELF'] . '?cat=browse' . '&amp;page=folder' . '&amp;uid=' . $_SESSION['uid'] . '&amp;action=add' . '&amp;uri=' . htmlspecialchars(rawurlencode($item['file']));
         if ($count % 2 == 1) {
             $file['cssClass'] = 'dark';
             $file['imageClass'] = '-dark';
         } else {
             $file['cssClass'] = '';
             $file['imageClass'] = '';
         }
         $_['files'][] = $file;
     }
     include './templates/common/Header.tpl.php';
     include './templates/common/Navigation.tpl.php';
     include './templates/common/BrowseFolder.tpl.php';
     include './templates/common/Footer.tpl.php';
 }