Skip to content
Permalink
Browse files

92: home page enhancements see ticket #99 for details (#93)

home page enhancements

see ticket #99 for details
  • Loading branch information
eric-gilbertson authored and RocketMan committed Dec 2, 2019
1 parent 1fbcd58 commit ed240bf6c04730fa7ba6580eb99fc00abaecf31e
@@ -29,6 +29,7 @@
'copyright' => '© 2002-2019 Fictitious Radio, LTD. All rights reserved.',

'logo' => 'img/example_banner.png',
'favicon' => 'img/favicon.ico',

'stylesheet' => 'css/example_style.css',

@@ -24,6 +24,7 @@
'copyright' => '&copy; 2002-2019 Stanford University. All rights reserved. Please read the Stanford University <A HREF="http://www.stanford.edu/home/atoz/terms.html">acceptable use policy</A>',

'logo' => 'img/kzsu/kzsu_aharoni.png',
'favicon' => 'img/kzsu/favicon.ico',

'stylesheet' => 'css/kzsustyle.css',

@@ -73,14 +73,24 @@ H2 {
padding-top: 0px;
margin-bottom: 10px;
}
H3, .subhead {
H3, .subhead {
color: #d83d04;
font-size: 14pt;
font-weight: bold;
padding-top: 10px;
padding-top: 8px;
margin-bottom: 5px;
text-align: left;
}
th.subhead {
padding-top: 0px;
}

div.subhead {
padding-top: 4px;
border-top: 1px solid gray;
border-bottom: 1px solid gray;
}

LI {
display: list-item;
}
@@ -136,6 +146,32 @@ TD.ind {
width: 15px;
}

/* home page */
.top-albums {
margin-top: 4px;
}

.home-datetime {
font-size: 12px;
padding-top: 4px;
padding-bottom: 4px;
}
.home-onnow > label {
font-weight: bold;
display: inline-block;
padding-bottom: 8px;
}

.home-hdr > label {
font-weight: bold;
display: inline-block;
width: 100px;
}
.top-albums td {
padding-right: 50px;
}


/* playlist editor */
.arrowCell {
vertical-align: top;
@@ -351,7 +387,7 @@ P.zktitle A {
width: 100%;
}

TH {
.home-onnow, TH {
font-family: verdana, arial, helvetica, sans-serif;
font-size: 11pt;
font-weight: bold;
@@ -539,6 +575,10 @@ A.calLink {
width:11px;
height:11px;
}
.albumNoReview {
width:11px;
height:11px;
}
.editorUp {
top: 0px;
width: 220px;
BIN +1.12 KB img/favicon.ico
Binary file not shown.
BIN +318 Bytes img/kzsu/favicon.ico
Binary file not shown.
@@ -33,15 +33,19 @@

class Home extends MenuItem {
public function processLocal($action, $subaction) {
echo " <H2>". Engine::param('station'). " Music :: " . Engine::param('application') . "</H2>\n";
if($this->session->isAuth("u"))
echo " <P>Remember to <B>logout</B> when you have finished.</P>\n";
echo "<H2>". Engine::param('station'). " Music :: " . Engine::param('application') . "</H2>\n";
$requestLine = Engine::param('contact')['request'];
if ($requestLine)
echo "<div class='home-hdr'><label>Request Line:</label> $requestLine</div>";

$musicDirEmail = Engine::param('email')['md'];
$musicDirName = Engine::param('md_name');
echo "<div class='home-hdr'><label>Music Director:</label><A HREF='mailto: $musicDirEmail'> $musicDirName</A></div>";

$this->emitWhatsOnNow();
$this->emitTopPlays();
echo " <TABLE WIDTH=\"100%\">\n";
echo " <TR><TH ALIGN=LEFT CLASS=\"subhead\">For complete album charting, see our\n";
echo " <A CLASS=\"subhead\" HREF=\"?session=".$this->session->getSessionID()."&amp;action=viewChart\"><B>Airplay Charts</B></A>.\n </TH></TR>\n </TABLE>\n";
UI::setFocus();
echo "<div style='border:0; margin-top:16px' CLASS='subhead'>For complete album charting, see our ";
echo "<A CLASS='subhead' HREF='?session=".$this->session->getSessionID()."&amp;action=viewChart'><B>Airplay Charts</B></A></div>";
}

private function emitTopPlays($numweeks=1, $limit=10) {
@@ -67,73 +71,67 @@ private function emitTopPlays($numweeks=1, $limit=10) {

Engine::api(ILibrary::class)->markAlbumsReviewed($topPlays);
if(sizeof($topPlays)) {
$nn4 = (substr($_SERVER["HTTP_USER_AGENT"], 0, 10) == "Mozilla/4.");
if($nn4)
echo "<TABLE BORDER=0 CELLPADDING=2 CELLSPACING=0 WIDTH=\"100%\">\n";
else
echo "<TABLE WIDTH=\"100%\">\n";
echo " <TR><TH ALIGN=LEFT CLASS=\"subhead\">";
echo "<TABLE WIDTH=\"100%\">\n";

echo "<TR><TH ALIGN=LEFT CLASS=\"subhead\">";
$formatEndDate = date("l, j F Y", mktime(0,0,0,$m,$d,$y));
echo Engine::param('station') . "'s Top $limit Albums\n" .
" <BR><FONT CLASS=\"subhead2\">for the ";
echo "Our Top $limit Albums\n" .
" <BR><FONT CLASS=\"subhead2\">for the ";
echo ($numweeks == 1)?"week":"$numweeks week period";
echo " ending $formatEndDate</FONT></TH><TD ALIGN=RIGHT STYLE=\"vertical-align: bottom;\">Music Director: <A HREF=\"mailto:" . Engine::param('email')['md'] . "\">" . Engine::param('md_name') . "</A></TD></TR>\n";
echo "</TABLE>\n<TABLE>\n";
echo " <TR><TH></TH><TH ALIGN=LEFT>Artist</TH><TH></TH><TH ALIGN=LEFT>Album</TH><TH ALIGN=LEFT>Label</TH></TR>\n";
echo " ending $formatEndDate</FONT></TH><TD ALIGN=RIGHT STYLE=\"vertical-align: bottom;\"></TR></TABLE>";

echo "<TABLE class='top-albums'><TR style='border-bottom:1px solid gray'><TH></TH><TH ALIGN=LEFT COLSPAN=2>Artist</TH><TH ALIGN=LEFT>Album</TH><TH ALIGN=LEFT>Label</TH></TR>\n";
for($i=0; $i < sizeof($topPlays); $i++) {
echo " <TR><TD ALIGN=RIGHT>".(string)($i + 1).".</TD><TD>";

// Setup artist correctly for collections
$artist = preg_match("/^COLL$/i", $topPlays[$i]["artist"])?"Various Artists":$topPlays[$i]["artist"];

echo UI::HTMLify($artist, 20) . "</TD><TD>";
if($topPlays[$i]["reviewed"])
echo "<A CLASS=\"albumReview\" HREF=\"".
"?s=byAlbumKey&amp;n=". UI::URLify($topPlays[$i]["tag"]).
"&amp;action=search&amp;session=".$this->session->getSessionID().
"\"><IMG SRC=\"img/blank.gif\" WIDTH=12 HEIGHT=11 ALT=\"[i]\"></A></TD><TD>";
else
echo "</TD><TD>";
$tagId = $topPlays[$i]["tag"];
$artist = $topPlays[$i]["artist"];
$haveReview = $topPlays[$i]["reviewed"];
$album = UI::HTMLify($topPlays[$i]["album"], 20);
$label = UI::HTMLify($topPlays[$i]["label"], 20);

// Setup artist correctly for collections & swap names if from library
if (preg_match("/^COLL$/i", $artist))
$artist = "Various Artists";
else if ($tagId)
$artist = UI::swapNames($artist);

$artist = UI::HTMLify($artist, 20);
echo "<TR>";
echo "<TD style='padding-right:4px' ALIGN=RIGHT>".(string)($i + 1).".</TD>";
echo "<TD>$artist</TD>";

$reviewClass = $haveReview ? "albumReview" : "albumNoReview";

echo "<td style='padding-right:4px'><div class='$reviewClass'></div></td>";
// Album
echo "<A CLASS=\"nav\" HREF=\"".
"?s=byAlbumKey&amp;n=". UI::URLify($topPlays[$i]["tag"]).
"&amp;action=search&amp;session=".$this->session->getSessionID().
"\">";
echo UI::HTMLify($topPlays[$i]["album"], 20) . "</A></TD><TD>" .
UI::HTMLify($topPlays[$i]["label"], 20) . "</TD></TR>\n";
echo "<TD>" .
"<A CLASS='nav' HREF='?s=byAlbumKey&amp;n=" . UI::URLify($tagId).
"&amp;action=search&amp;session=" . $this->session->getSessionID(). "'>".
"$album</A></TD>";

echo "<TD>$label</TD>";
echo "</TR>\n";
}
echo "</TABLE>\n";
}
}

private function emitWhatsOnNow() {
echo "<div class='subhead'>On Now:<div class='home-onnow'>\n";
$record = Engine::api(IPlaylist::class)->getWhatsOnNow();
echo "<TABLE WIDTH=\"100%\" BORDER=0 CELLPADDING=2 CELLSPACING=0 STYLE=\"border-style: solid; border-width: 1px 0px 1px 0px; border-color: #cccccc\">\n <TR><TH ALIGN=LEFT COLSPAN=3 CLASS=\"subhead\">";
echo "On ". Engine::param('station') . " now:</TH></TR>\n ";
$sessionId = $this->session->getSessionID();
if($record && ($row = $record->fetch())) {
echo "<TR><TH ALIGN=LEFT COLSPAN=3><A HREF=\"".
"?action=viewDJ&amp;seq=selUser&amp;viewuser=".$row["airid"]."&amp;session=".$this->session->getSessionID().
"\" CLASS=\"calNav\">" . htmlentities($row["airname"]) . "</A>&nbsp;&nbsp;&nbsp;";
echo "<A HREF=\"".
"?action=viewDate&amp;seq=selList&amp;playlist=".$row[0].
"&amp;session=".$this->session->getSessionID()."\" CLASS=\"nav\">" . htmlentities($row["description"]);
echo "</A></TH></TR>\n ";
echo "<TR><TH ALIGN=RIGHT VALIGN=BOTTOM CLASS=\"sub\">" . date("l, j M") . "&nbsp;&nbsp;</TH>\n <TH ALIGN=LEFT VALIGN=BOTTOM CLASS=\"sub\">" . Playlists::timeToAMPM($row["showtime"]) . " " . date("T") . "</TH>\n";
$requestLine = Engine::param('contact')['request'];
if($requestLine)
echo " <TD ALIGN=RIGHT VALIGN=BOTTOM ROWSPAN=2>Request Line:&nbsp;&nbsp;$requestLine&nbsp;&nbsp;&nbsp;".Engine::param('station_freq')."</TD></TR>\n";
else
echo " <TD></TD></TR>\n";
echo " <TR>" . Playlists::timeToZulu($row["showtime"]). "</TR>\n";
$airId = $row["airid"];
$airName = htmlentities($row["airname"]);
$description = htmlentities($row["description"]);
$showDateTime = Playlists::makeShowDateAndTime($row);
$hrefAirName = "?action=viewDJ&amp;seq=selUser&amp;viewuser=$airId&amp;session=$sessionId";
$hrefPL = "?action=viewDate&amp;seq=selList&amp;playlist=$row[0]&amp;session=$sessionId";
echo "<A HREF='$hrefPL' CLASS='nav'>$description</A>&nbsp;with&nbsp;";
echo "<A HREF='$hrefAirName' CLASS='calNav'>$airName</A>";
echo "<div class='home-datetime'>$showDateTime</div>";
} else {
echo "<TR><TH ALIGN=LEFT COLSPAN=3>[No playlist available]</TH></TR>\n ";
echo "<TR><TH COLSPAN=2>&nbsp;</TH>\n";
$requestLine = Engine::param('contact')['request'];
if($requestLine)
echo " <TD ALIGN=RIGHT VALIGN=BOTTOM>Request Line:&nbsp;&nbsp;$requestLine&nbsp;&nbsp;&nbsp;".Engine::param('station_freq')."</TD></TR>\n";
else
echo " <TD></TD></TR>\n";
echo "<div class='home-datetime'>[No playlist available]</div>";
}
echo "</TABLE><BR>\n";
echo "</div></div>\n";
}
}
@@ -88,6 +88,11 @@ protected function emitResponseHeader() {
<HEAD>
<TITLE><?php echo $banner;?></TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<?php
$favicon = Engine::param('favicon');
if($favicon)
echo "<LINK REL=\"icon\" HREF=\"$favicon\">\n";
?>
<?php UI::emitCSS('css/tablesorter/theme.default.css'); ?>
<?php UI::emitCSS('css/zoostyle.css'); ?>
<?php UI::emitCSS(Engine::param('stylesheet')); ?>
@@ -1888,31 +1888,6 @@ private function makeAlbumLink($row, $includeLabel) {
return $albumTitle;
}


// converts "last, first" to "first last" being careful to not swap
// other formats that have comas. call only for ZK library entries
// since manual entries don't need this. Test cases: The Band, CSN&Y,
// Bing Crosby & Fred Astaire, Bunett, June and Maqueque, Electro, Brad
// Feat. Marwan Kanafaneg: 694717, 418485, 911685, 914824, 880994.
private function swapNames($fullName) {
$suffixMap = [ "with" => "", "and" => "", "feat." => "" ];

$namesAr = explode(", ", $fullName);
if (count($namesAr) == 2) {
$spacesAr = explode(" ", $namesAr[1]);
$spacesCnt = count($spacesAr);
if ($spacesCnt == 1) {
$fullName = $namesAr[1] . " " . $namesAr[0];
} else if ($spacesCnt > 1) {
$key = strtolower($spacesAr[1]);
if (array_key_exists($key, $suffixMap)) {
$fullName = $spacesAr[0] . ' ' . $namesAr[0] . ' ' . substr($namesAr[1], strlen($spacesAr[0]));
}
}
}
return $fullName;
}

private function makePlaylistObserver($playlist, $editMode) {
$break = false;
return (new PlaylistObserver())->onComment(function($entry) use($playlist, $editMode, &$break) {
@@ -1955,8 +1930,8 @@ private function makePlaylistObserver($playlist, $editMode) {
$timeplayed = self::timestampToAMPM($entry->getCreated());
$reviewCell = $entry->getReviewed() ? "<div class='albumReview'></div>" : "";
$artistName = $entry->getArtist();
if (!$entry->getTag()) // don't swap manual entries
$artistName = $this->swapNames($artistName);
if ($entry->getTag()) // don't swap manual entries
$artistName = UI::swapNames($artistName);

$albumLink = $this->makeAlbumLink($entry->asArray(), true);
echo "<TR class='songRow'>" . $editCell .
@@ -1989,7 +1964,7 @@ private function emitPlaylistBody($playlist, $editMode) {
}


private function makeShowDateAndTime($row) {
public static function makeShowDateAndTime($row) {
$showStart = self::showStartTime($row[2]);
$showEnd = self::showEndTime($row[2]);
$showDate = self::timestampToDate($row[1]);
@@ -2001,7 +1976,7 @@ private function emitPlaylistBanner($playlistId, $playlist) {
$showName = $playlist['description'];
$djId = $playlist['id'];
$djName = $playlist['airname'];
$showDateTime = $this->makeShowDateAndTime($playlist);
$showDateTime = self::makeShowDateAndTime($playlist);

$dateDiv = "<DIV>".$showDateTime."&nbsp;</div>";
$djLink = "<A HREF='?action=viewDJ&amp;seq=selUser&amp;session=" .
@@ -195,6 +195,34 @@ public static function deLatin1ify($string,
return $string;
}


/**
* converts "last, first" to "first last" being careful to not swap
* other formats that have commas. call only for ZK library entries
* since manual entries don't need this. Test cases: The Band, CSN&Y,
* Bing Crosby & Fred Astaire, Bunett, June and Maqueque, Electro, Brad
* Feat. Marwan Kanafaneg, Kallick, Kathy Band: 694717, 418485, 911685,
* 914824, 880994, 1134313.
*/
public static function swapNames($fullName) {
$suffixMap = [ "band" => "", "with" => "", "and" => "", "feat." => "" ];

$namesAr = explode(", ", $fullName);
if (count($namesAr) == 2) {
$spacesAr = explode(" ", $namesAr[1]);
$spacesCnt = count($spacesAr);
if ($spacesCnt == 1) {
$fullName = $namesAr[1] . " " . $namesAr[0];
} else if ($spacesCnt > 1) {
$key = strtolower($spacesAr[1]);
if (array_key_exists($key, $suffixMap)) {
$fullName = $spacesAr[0] . ' ' . $namesAr[0] . ' ' . substr($namesAr[1], strlen($spacesAr[0]));
}
}
}
return $fullName;
}

/**
* decorate the specified asset for cache control
*

0 comments on commit ed240bf

Please sign in to comment.
You can’t perform that action at this time.