1
0
mirror of https://github.com/danbee/neompc synced 2025-03-04 08:39:10 +00:00

~ Fixed problems with apostrophes and ampersands in paths/names. Still need to sort out international characters.

+ Tracks in an album are now sorted by tracknumber.

+ Added config file.
This commit is contained in:
Dan Barber 2007-05-10 13:52:32 +00:00
parent 31167a15f4
commit b46e8f7441
7 changed files with 49 additions and 14 deletions

13
config/config.inc.php Normal file
View File

@ -0,0 +1,13 @@
<?php
/**************************************
** NeoMPC Config File
**************************************/
$_CONFIG['music_directory'] = '/var/lib/mpd/music';
$_CONFIG['template'] = 'default';
$_CONFIG['sort_by_tracknumber'] = true;
?>

View File

@ -11,6 +11,6 @@
require("lib/page.php");
/* output the template */
$smarty->display('default/index.html');
$smarty->display($_CONFIG['template'] . '/index.html');
?>
?>

View File

@ -94,4 +94,4 @@
header("Location: index.php");
break;
}
?>
?>

View File

@ -1,5 +1,7 @@
<?php
/* Smarty stuff */
/* Smarty stuff */
require('config/config.inc.php');
define('SMARTY_DIR', 'lib/smarty/libs/');
require(SMARTY_DIR . 'Smarty.class.php');
@ -15,6 +17,12 @@
if (!$mympd->connected) {
echo "<p>Problem connecting to MPD!</p>";
exit;
}
/* track number sorting function */
function track_sort($a, $b) {
return $a['Track'] - $b['Track'];
}
/* setup some global vars */
@ -43,10 +51,12 @@
/* do the same with the current browse position */
if ($_GET['browse']) {
$browse = $_GET['browse'];
setcookie('browse', $browse);
setcookie('browse', stripslashes($browse));
}
else {
$browse = $_COOKIE['browse'];
}
}
$browse = stripslashes($browse);
?>
?>

View File

@ -25,7 +25,9 @@
$browse = '';
}
$browse_list = explode('/', $browse);
$browse_list = explode('/', $browse);
//print_r($browse);
if ($browse) {
@ -40,8 +42,18 @@
if (!$browselist) {
$browselist = $mympd->GetDir($browse);
}
}
if ($_CONFIG['sort_by_tracknumber']) {
usort($browselist, "track_sort");
}
/*
echo '<pre>';
print_r($browselist);
echo '</pre>';
//*/
foreach ($browselist as $key => $browselist_item) {
@ -73,4 +85,4 @@
break;
}
?>
?>

View File

@ -3,7 +3,7 @@
<li>&bull; <a href="index.php?browse=/"><img src="images/home.gif" alt="Home" /></a></li>
{foreach from=$dir_list item=dir_list_item}
<li>&bull; <a href="index.php?browse={$dir_list_item.path|escape:'url'}">{$dir_list_item.name}</a></li>
<li>&bull; <a href="index.php?browse={$dir_list_item.path|escape:'url'}">{$dir_list_item.name|escape:'html'}</a></li>
{/foreach}
</ul>

View File

@ -1,10 +1,10 @@
{if $browselist_item.directory}
<li><a href="index.php?browse={$browselist_item.directory|escape:'url'}"><img src="images/dir.gif" class="icon" /> {$browselist_item.directory_name}</a></li>
<li><a href="index.php?browse={$browselist_item.directory|escape:'url'}"><img src="images/dir.gif" class="icon" /> {$browselist_item.directory_name|escape:'html'}</a></li>
{else}
{if $browselist_item.in_playlist}<li style="background: #555;">{else}<li>{/if}<a href="{$browselist_add_link}{$browselist_item.file}"><img src="images/add.gif" alt="Add" class="button" /></a><a href="{$browselist_play_link}{$browselist_item.file}"><img src="images/play.gif" alt="Play" class="button" /></a><img src="images/note.gif" class="icon" /> {if $browselist_item.Title}<span class="title">{$browselist_item.Title}</span><br /><span class="artist">{$browselist_item.Artist}</span> <span class="album">({$browselist_item.Album})</span>{else}{$browselist_item.file}{/if}</li>
{if $browselist_item.in_playlist}<li style="background: #555;">{else}<li>{/if}<a href="{$browselist_add_link}{$browselist_item.file|escape:'url'}"><img src="images/add.gif" alt="Add" class="button" /></a><a href="{$browselist_play_link}{$browselist_item.file|escape:'url'}"><img src="images/play.gif" alt="Play" class="button" /></a><img src="images/note.gif" class="icon" /> {if $browselist_item.Title|escape:'html'}<span class="title">{$browselist_item.Title|escape:'html'}</span><br /><span class="artist">{$browselist_item.Artist|escape:'html'}</span> <span class="album">({$browselist_item.Album|escape:'html'})</span>{else}{$browselist_item.file|escape:'html'}{/if}</li>
{/if}