Location: PHPKode > projects > phpMUR Multi User Randomizer > tpl/andreas02/search.results.tpl.php
<?php
	if (!isset($_SESSION['search']['results'])) {
		search($_SESSION['search']);
	}
	global $db;
	echo $_SESSION['search']['results']['nav1'];
	if (!function_exists('ago')) {
		function ago($time) {
			if (!$time) {
				return 'never';
			}
			$diff = time() - $time;

			//if ($diff < )
			//yday

			$min = 60;
			$hr = 60 * $min;
			$day = $hr * 24;
			$week = $day * 7;
			$year = $day * 365;
			$month = ceil($year / 12); // Persudo month.

			$time_array['year'] = $year;
			$time_array['month'] = $month;
			$time_array['week'] = $week;
			$time_array['day'] = $day;
			$time_array['hr'] = $hr;
			$time_array['min'] = $min;
			$time_array['sec'] = 1;

			foreach ($time_array as $type=>$time) {
				$is = floor($diff / $time);
				$left = $diff % $time;
				if ($is > 1) {
					$type .= 's';
				}
				$return["$type"] = $is;
				$diff = $left;
			}

			foreach ($return as $type=>$measurement) {
				switch ($type) {
					case 'secs':
					case 'sec':
						if ($measurement < 10 && $ago) {
							$ago .= '0';
						}
						$ago .= $measurement;
						break;
					case 'mins':
					case 'min':
						if ($measurement < 10 && $ago) {
							$ago .= '0';
						}
						$ago .= $measurement.':';
						break;
					case 'hrs':
					case 'hr':
						$ago .= ' '.$measurement.':';
						break;
					default:
						if ($measurement) {
							$ago .= ' '.$measurement.' '.$type;
						}
						break;
				}
			}
			return $ago;
		}
	}


?>
<table>
	<tr>
		<td>Artist - Title</td><?php
			if ($_SESSION['users']) {
				foreach ($_SESSION['users'] as $uid=>$uinfo) {
					/* $uinfo = $db->get_assoc("SELECT uname, rating FROM user_song_info su, users u WHERE u.uid = '$uid' AND fid = '{$f['fid']}' AND u.uid = su.uid ");
					echo $uinfo['uname'].':';
					echo build_rating_select('search' , $f['fid'], $uid,$uinfo['rating'],true).' '; */
					?><td><?php
					eent($uinfo['uname']);
					?></td><?php
					//build_rating_select($div,$fid,$uid,$rating)
				}
			}
		?><td>Genre</td><td>Artist Last Time Played</td><td>Last Time Played</td><?php
			if (is_admin()) {
				?><td>CD</td><?php
			}
		?>
	</tr>
	<?php
		foreach ($_SESSION['search']['results']['rows'] as $k=>$f) {
			?><tr<?php
				if ($k % 2 == 0) {
					?> style="background: #EEE;"<?php
				}
			?>>
				<td><?php
				if (is_admin()) {
					?><div id="id3[<?php echo $f['fid']; ?>]" style="position:absolute; display:none; background: #FFF; z-index:3; overflow: auto;"><form method="post" id="id3_form[<?php echo $f['fid']; ?>]">
						<table border="1">
							<tr>
								<td colspan="2"><a style='float:right;' onClick="document.getElementById('id3[<?php echo $f['fid']; ?>]').style.display='none';xajax_search(xajax.getFormValues('search_form'));"><img src="widget/close.png" border="0"></a><?php eent(dirname($f['filename']).'/'); ?>&nbsp;&nbsp;<br />
								<?php eent(basename($f['filename'])); ?>
								</td>
							</tr>
							<tr>
								<td>Artist</td>
								<td><input type="text" name="artist" value="<?php eent($f['artist']); ?>"></td>
							</tr>
							<tr>
								<td>Title</td>
								<td><input type="text" name="title" value="<?php eent($f['title']); ?>"></td>
							</tr>
							<tr>
								<td>Genre</td>
								<td><input type="text" name="genre" id="genre[<?php echo $f['fid']; ?>]" value="<?php eent($f['genre']); ?>"><br />
								<div id="genre_select[<?php echo $f['fid']; ?>]"></div></td>
							</tr>
							<tr>
								<td colspan="2"><input style="float:right;" type="button" value="Save" onClick="xajax_save_id3(<?php echo $f['fid']; ?>,xajax.getFormValues('id3_form[<?php echo $f['fid']; ?>]'));"><span style="color:green;" id="id3_status[<?php echo $f['fid']; ?>]"></span></td>
							</tr>
						</table>
						</form>
					</div><?php
				}
				?><div onMouseOver="document.getElementById('links[<?php
				echo $f['fid'];
				?>]').style.display='block';" onMouseOut="document.getElementById('links[<?php
				echo $f['fid'];
				?>]').style.display='none';">
				<div id='links[<?php echo $f['fid'] ?>]' style="display: none; position: absolute; background: #EEE; z-index: 1; border: 5px solid; padding: 5px;">
					<?php
						eent($f['artist'].' - '.$f['title']);
					?><br /><?php
						if (is_admin()) {
							eent($f['filename']); ?><br /><?php
						}
					?>
					<a class="pl" onClick="xajax_cue_fid(<?php echo $f['fid']; ?>,true);">Play Now</a> ||
					<a class="pl" onClick="xajax_cue_fid(<?php echo $f['fid']; ?>);">Add To Playlist</a> ||
					<a class="pl" onClick="xajax_trash(<?php echo $f['fid']; ?>);">Trash</a>
					<?php
						if (is_admin()) {
							?> || <a onClick="document.getElementById('id3[<?php echo $f['fid']; ?>]').style.display='block'; genres.open(<?php echo $f['fid'] ?>,<?php echo $f['gid'] ?>);">Edit</a><?php
						}
					?>
				</div>
				<?php

				eent($f['artist'].' - '.$f['title']);
				if (is_admin() && $_SESSION['search']['find_dup']) {
					?><br /><span style='color: #888;'><?php
					eent(dirname($f['filename'])); ?></span><br /><span style='color: red;'><?php
					eent(basename($f['filename']));
					/*
					if (dirname($f['filename']) == '/home/erm/mp3/windows/todd') {
						if (@unlink($f['filename']) || !file_exists($f['filename'])) {

							?><b> *DELETED*</b><?php
							$db->query("DELETE FROM files WHERE fid = '{$f['fid']}'");
							$db->query("DELETE FROM user_song_info WHERE fid = '{$f['fid']}'");
						}
					} elseif (!file_exists($f['filename'])) {
						?><b> *DELETED* *missing*</b><?php
						$db->query("DELETE FROM files WHERE fid = '{$f['fid']}'");
						$db->query("DELETE FROM user_song_info WHERE fid = '{$f['fid']}'");
					} else {
						$parts = explode('.', basename($f['filename']));
						$end = array_slice ( $parts,-2, 2);
						if (is_numeric($end[0]) && $end[0] >= 1 && $end[0] <= 3) {
							?><b> *DELETED definete dup.*</b><?php
							$db->query("DELETE FROM files WHERE fid = '{$f['fid']}'");
							$db->query("DELETE FROM user_song_info WHERE fid = '{$f['fid']}'");
						} elseif ($end[0] == 'fixed') {

							?><b> *DELETED* *FIXED*</b><?php
							$db->query("DELETE FROM files WHERE fid = '{$f['fid']}'");
							$db->query("DELETE FROM user_song_info WHERE fid = '{$f['fid']}'");
						} elseif ($end[1] == 'ogg') {
							?><b> *DELETED* *OGG*</b><?php
							$db->query("DELETE FROM files WHERE fid = '{$f['fid']}'");
							$db->query("DELETE FROM user_song_info WHERE fid = '{$f['fid']}'");
						}
					} */
					?></span><?php
				}

				?></div>
				</td><?php
				if ($_SESSION['users']) {
					foreach ($_SESSION['users'] as $uid=>$uinfo) {
						?><td align="center"><?php
						$uinfo = $db->get_assoc("SELECT uname, rating FROM user_song_info su, users u WHERE u.uid = '$uid' AND fid = '{$f['fid']}' AND u.uid = su.uid ");
						echo build_rating_select('search' , $f['fid'], $uid,$uinfo['rating'],true);
						?></td><?php
						//build_rating_select($div,$fid,$uid,$rating)
					}
				}
				?><td><?php
					if (is_admin()) {
						?><a onClick="document.getElementById('id3[<?php echo $f['fid']; ?>]').style.display='block'; genres.open(<?php echo $f['fid'] ?>,<?php echo $f['gid'] ?>);"><?php
					}
					eent($f['genre']);
					if (is_admin()) {
						?></a><?php
					}
				?></td><td><?php
					echo ago($f['altp']);
				?></td><?php
				?><td><?php
					echo ago($f['ltp']);
				?></td><?php
				if (is_admin()) {
					?><td><input type="checkbox" onClick="xajax_add_to_cd(<?php echo $f['fid']; ?>,this.checked);"<?php
						if ($f['add_to_cd'] == 1) {
							?> checked<?php
						}
					?>></td><?php
				}
			?></tr><?php
		}
	?>
</table><?php
echo $_SESSION['search']['results']['nav2'];

/*
<ol>
	<?php
		if (!isset($_SESSION['search']['results']['rows'])) {
			$_SESSION['search']['results']['rows'] = array();
		}
		$lcnt = 0;
		foreach ($_SESSION['search']['results']['rows'] as $f) {
			?><li style='color:blue;<?php
				if ($lcnt % 2 == 0) {
					?>background:#EEE;<?php
				}
				$lcnt++;
			?>'><?php
			if (is_admin()) {
				?><div id="id3[<?php echo $f['fid']; ?>]" style="position:absolute; display:none; background: #FFF; z-index:3; width: 55%; overflow: auto;"><form method="post" id="id3_form[<?php echo $f['fid']; ?>]">
					<table border="1">
						<tr>
							<td colspan="2"><a style='float:right;' onClick="document.getElementById('id3[<?php echo $f['fid']; ?>]').style.display='none';xajax_search(xajax.getFormValues('search_form'));"><img src="widget/close.png" border="0"></a><?php eent(dirname($f['filename']).'/'); ?>&nbsp;&nbsp;<br />
							<?php eent(basename($f['filename'])); ?>
							</td>
						</tr>
						<tr>
							<td>Artist</td>
							<td><input type="text" name="artist" value="<?php eent($f['artist']); ?>"></td>
						</tr>
						<tr>
							<td>Title</td>
							<td><input type="text" name="title" value="<?php eent($f['title']); ?>"></td>
						</tr>
						<tr>
							<td>Genre</td>
							<td><input type="text" name="genre" value="<?php eent($f['genre']); ?>"></td>
						</tr>
						<tr>
							<td colspan="2"><input style="float:right;" type="button" value="Save" onClick="xajax_save_id3(<?php echo $f['fid']; ?>,xajax.getFormValues('id3_form[<?php echo $f['fid']; ?>]'));"><span style="color:green;" id="id3_status[<?php echo $f['fid']; ?>]"></span></td>
						</tr>
					</table>
					</form>
				</div><a onClick="xajax_cue_fid(<?php echo $f['fid']; ?>,true);"><img src="widget/play.png" border="0"></a><a onClick="document.getElementById('id3[<?php echo $f['fid']; ?>]').style.display='block';"><img src="widget/open.png" align="left" border="0"></a><?php
			}

			?><a class="pl" onClick="xajax_cue_fid(<?php echo $f['fid']; ?>,false);"><?php
			eent($f['artist'].' - '.$f['title']);
			?></a><br /><?php
			if (is_admin()) {
				?><span style="float:left;"><a onClick="document.getElementById('id3[<?php echo $f['fid']; ?>]').style.display='block';"><?php eent($f['genre']); ?></a></span><?php
			}
			?><div class='fright'><?php
				if ($_SESSION['users']) {
					foreach ($_SESSION['users'] as $uid=>$uinfo) {
						$uinfo = $db->get_assoc("SELECT uname, rating FROM user_song_info su, users u WHERE u.uid = '$uid' AND fid = '{$f['fid']}' AND u.uid = su.uid ");
						echo $uinfo['uname'].':';
						echo build_rating_select('search' , $f['fid'], $uid,$uinfo['rating'],true).' ';
						//build_rating_select($div,$fid,$uid,$rating)
					}
				}
			if ($f['ltp'] == '0000-00-00 00:00:00') {
				$f['ltp'] = 'never';
			}
			if ($f['altp'] == '0000-00-00 00:00:00') {
				$f['altp'] = 'never';
			}
			?></div><div style="color:black;">Last Time Played:<?php echo $f['ltp']; ?><br />Artist Last Time Played:<?php echo $f['altp']; ?><br /></div></li><?php
		}
	?>
</ol>
<?php
	*/


/*<style>
	a {
		cursor:pointer;
	}
	a:hover {
		text-decoration: underline;
	}
</style>
<ol>
	<?php
		foreach ($_SESSION['playlist'] as $k=>$f) {
			?><li <?php
				if ($k == $_SESSION['currentItem']) {
					?> style='color:red;'<?php
				} else {
					?> style='color:blue;'<?php
				}
				//javascript:sendEvent('playitem',1)
			?>><?php
			if (is_admin()) {
				?><div id="id3[<?php echo $f['fid']; ?>]" style="position:absolute; display:none; background: #FFF; z-index:3;"><form method="post" id="id3_form[<?php echo $f['fid']; ?>]">
					<table border="1">
						<tr>
							<td colspan="2"><a style='float:right;' onClick="document.getElementById('id3[<?php echo $f['fid']; ?>]').style.display='none';reverse_sync_playlist();"><img src="widget/close.png" border="0"></a><?php eent(dirname($f['filename']).'/'); ?>&nbsp;&nbsp;<br />
							<?php eent(basename($f['filename'])); ?>
							</td>
						</tr>
						<tr>
							<td>Artist</td>
							<td><input type="text" name="artist" value="<?php eent($f['artist']); ?>"></td>
						</tr>
						<tr>
							<td>Title</td>
							<td><input type="text" name="title" value="<?php eent($f['title']); ?>"></td>
						</tr>
						<tr>
							<td>Genre</td>
							<td><input type="text" name="genre" value="<?php eent($f['genre']); ?>"></td>
						</tr>
						<tr>
							<td colspan="2"><input style="float:right;" type="button" value="Save" onClick="xajax_save_id3(<?php echo $f['fid']; ?>,xajax.getFormValues('id3_form[<?php echo $f['fid']; ?>]'));"><span style="color:green;" id="id3_status[<?php echo $f['fid']; ?>]"></span></td>
						</tr>
					</table>
					</form>
				</div><a onClick="document.getElementById('id3[<?php echo $f['fid']; ?>]').style.display='block';"><img src="widget/open.png" align="left" border="0"></a><?php
			}

			?><a class="pl" onClick="sendEvent('playitem',<?php echo $k; ?>);"><?php
			eent($f['artist'].' - '.$f['title']);
			?></a><br /><?php
			if (is_admin()) {
				?><span style="float:left;"><a onClick="document.getElementById('id3[<?php echo $f['fid']; ?>]').style.display='block';"><?php eent($f['genre']); ?></a></span><?php
			}
			?><div class='fright'><?php
				if ($f['users']) {
					foreach ($f['users'] as $uid=>$uinfo) {
						if ($_SESSION['qued_for']["{$f['fid']}"] == $uid) {
							echo '<b>';
						}
						echo $uinfo['uname'].':';
						echo build_rating_select('playlist' , $f['fid'], $uid,$uinfo['rating'],true).' ';
						if ($_SESSION['qued_for']["{$f['fid']}"] == $uid) {
							echo '</b>';
						}
						//build_rating_select($div,$fid,$uid,$rating)
					}
				}
			?></div></li><?php
		}
	?>
</ol>*/
// print_r($_SESSION['search']);
?>
Return current item: phpMUR Multi User Randomizer