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'; }
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'; }
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' . '&page=folder' . '&uid=' . $_SESSION['uid'] . '&action=cd' . '&folder=' . htmlspecialchars(rawurlencode($this->parentFolder)); $_['homeUrl'] = $_SERVER['PHP_SELF'] . '?cat=browse' . '&page=folder' . '&uid=' . $_SESSION['uid'] . '&action=cd' . '&folder='; $_['addAllUrl'] = $_SERVER['PHP_SELF'] . '?cat=browse' . '&page=folder' . '&uid=' . $_SESSION['uid'] . '&action=add' . '&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' . '&page=folder' . '&uid=' . $_SESSION['uid'] . '&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' . '&page=folder' . '&uid=' . $_SESSION['uid'] . '&action=add' . '&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'; }