<?php
/**
* $Id: group.music.php,v 1.21 2004/12/02 05:12:18 openface Exp $
*
* _ _ _ _
* _ __ ___ __| (_)__ _ (_)_ _ __| |_____ _____ _ _
* | ' \/ -_) _` | / _` | | | ' \/ _` / -_) \ / -_) '_|
* |_|_|_\___\__,_|_\__,_| |_|_||_\__,_\___/_\_\___|_|
*
* Standalone Indexer Script for Media Files
* jason hines, <hide@address.com>
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
* General Public License for more details.
*/
/* For oblio ;) */
define("_PLAYLISTURL",_MEDIAURL);
/**
* Audio group class. Implements a playlist for files within this group.
*
* @version $Revision: 1.21 $
* @package mediaIndexer
* @subpackage groups
* @author jason hines, <hide@address.com>
*/
class musicGroup extends defaultGroup {
public $groupName = "Music";
public function printGroup($files) {
?>
<script language="JavaScript" type="text/javascript">
<!--
function _setStatus(n) {
cnt = document.playlist.elements.length;
for (i=0; i < cnt; i++) {
document.playlist.elements[i].checked=n;
}
}
-->
</script>
<?php
echo "<form method=\"POST\" name=\"playlist\" action=\"?do=playlist\">\n";
echo "<table border=\"0\" class=\"group\">\n";
echo "<tr>\n";
$cnt = 0;
$width = 100 / _NUMCOLUMNS;
$nrows = count($files);
foreach ($files as $file) {
$cnt++;
echo "<td class=\"cell\" valign=\"top\" width=\"{$width}%\" nowrap>\n";
echo "<input type=\"checkbox\" name=\"playlist[]\" value=\""._PLAYLISTURL._encodeuri($file->path)."\"> \n";
$file->handlerRef->printListing($file);
// print comment count
$sql = "SELECT count(id) FROM comments WHERE hash = '{$file->hash}'";
$comments = sqlite_single_query($GLOBALS['gDb'],$sql);
if ($comments > 0) {
echo "<br /><a class=\"comments\" href=\"?file={$file->path}\">({$comments} comments)</a>\n";
}
echo "</td>\n";
if ($cnt / _NUMCOLUMNS == floor($cnt / _NUMCOLUMNS) && $cnt < $nrows) {
echo "</tr>\n<tr>\n";
}
}
echo "</tr>\n";
echo "<tr><td colspan=\""._NUMCOLUMNS."\">";
echo "<input type=\"submit\" value=\"Play Selected\">\n";
echo "<small>[ <a href=\"javascript:_setStatus(1);\" onmouseover=\"window.status='Add all items to playlist';return true;\" onmouseout=\"window.status='';return true;\">select all</a> | ";
echo "<a href=\"javascript:_setStatus(0);\" onmouseover=\"window.status='Remove all items from playlist';return true;\" onmouseout=\"window.status='';return true;\">select none</a> ]</small>\n";
echo "</td></tr>\n";
echo "</table>\n";
echo "</form>\n";
}
function printInfo(file $file) {
$raw = $file->getRawInfo();
print "<table class=\"info\">\n";
if (isset($raw['id3v2']['comments'])) {
foreach ($raw['id3v2']['comments'] as $name=>$value) {
print "<tr><td valign=\"top\">".ucwords($name).":</td><td>".$this->_cleanString($value[0])."</td></tr>\n";
}
}
print "<tr><td>Bitrate:</td><td>{$raw['bitrate']}</td></tr>\n";
print "<tr><td>Playtime:</td><td>{$raw['playtime_string']} minutes</td></tr>\n";
print "<tr><td>MimeType:</td><td>{$raw['mime_type']}</td></tr>\n";
if (!empty($raw['audio'])) {
foreach ($raw['audio'] as $name=>$value) {
if (is_string($value)) {
print "<tr><td valign=\"top\">".ucwords($name).":</td><td>{$value}</td></tr>\n";
}
}
}
print "</table>\n";
}
/**
* Clean strings (ID3 tags tend to have illegal characters)
*/
function _cleanString($wild) {
return ereg_replace("[^[:alnum:]+ ]","",$wild);
}
}
/*
function callback_playlist() {
if (empty($_POST['playlist'])) { die("Unexpected Error."); }
header("Content-type: audio/x-mpegurl");
foreach ($_POST['playlist'] as $url) {
echo $url . "\n";
}
}
*/
?>