Permalink
Browse files

reworked IChart::getCategories + misc fixes

  • Loading branch information...
RocketMan committed Jun 9, 2018
1 parent 3572620 commit 2d15185f16d631b1c57d3a3d1aad67f0be6fe210
@@ -181,11 +181,11 @@ public function getCharts() {
echo "</getChartRs>\n";
// genre charts
$genres = array(5, 7, 6, 1, 2, 4, 3, 8);
$genres = [5, 7, 6, 1, 2, 4, 3, 8];
for($i=0; $i<sizeof($genres); $i++) {
unset($records);
Engine::api(IChart::class)->getChart2($records, 0, $date, 10, $genres[$i]);
echo "<getChartRs chart=\"".$this->catCodes[$genres[$i]-1]."\" week-ending=\"$date\"".$this->emitSuccess().">\n";
echo "<getChartRs chart=\"".$this->catCodes[$genres[$i]-1]["name"]."\" week-ending=\"$date\"".$this->emitSuccess().">\n";
$this->emitDataSetArray("albumrec", $chartfields, $records, 0);
echo "</getChartRs>\n";
}
@@ -333,11 +333,7 @@ private function emitDataSetArray($name, $fields, &$data) {
}
private function getAFileCats() {
$catCodes = array();
$result = Engine::api(IChart::class)->getCategories();
while($row = $result->fetch())
$catCodes[] = $row["name"];
return $catCodes;
return Engine::api(IChart::class)->getCategories();
}
private function emitAFileCat($cats) {
@@ -348,8 +344,8 @@ private function emitAFileCat($cats) {
if($cats) {
$cats = explode(",", $cats);
for($i=0; $i<sizeof($cats); $i++)
if(substr($this->catCodes[$cats[$i]-1], 0, 1) != "(")
echo "<chart>".$this->catCodes[$cats[$i]-1]."</chart>\n";
if(substr($this->catCodes[$cats[$i]-1]["name"], 0, 1) != "(")
echo "<chart>".$this->catCodes[$cats[$i]-1]["name"]."</chart>\n";
}
echo "</charts>\n";
}
@@ -53,11 +53,8 @@ public function processRequest($dispatcher) {
header("Content-type: application/csv");
header("Content-disposition: attachment; filename=add.csv");
// Stuff the categories into an array
// Get the chart categories
$cats = Engine::api(IChart::class)->getCategories();
$i=1;
while($cats && ($row = $cats->fetch()))
$catcode[$i++] = $row[2];
// Get the add records
$records = Engine::api(IChart::class)->getAdd2($date);
@@ -72,9 +69,10 @@ public function processRequest($dispatcher) {
$row["pulldate"] . "\t";
// Categories
$cats = explode(",", $row["afile_category"]);
while(list($index, $cat) = each($cats))
echo $catcode[$cat];
$acats = explode(",", $row["afile_category"]);
foreach($acats as $index => $cat)
if($cat)
echo $cats[$cat-1]["code"];
echo "\t";
// A-File Number
@@ -41,7 +41,8 @@ class RSS extends CommandTarget implements IController {
];
private static function xmlentities($str) {
return str_replace(array('&', '"', "'", '<', '>', '`'), array('&amp;' , '&quot;', '&apos;' , '&lt;' , '&gt;', '&apos;'), $str);
return str_replace(['&', '"', "'", '<', '>', '`'],
['&amp;' , '&quot;', '&apos;' , '&lt;' , '&gt;', '&apos;'], $str);
}
private static function htmlnumericentities($str) {
@@ -76,13 +77,8 @@ public function emitChartRSS($endDate, &$title, $limit="", $category="") {
if(sizeof($chart)) {
$title = Engine::param('station'). " ";
if($category) {
// Stuff the categories into an array
$i=1;
$categories = Engine::api(IChart::class)->getCategories();
while($categories && ($cat = $categories->fetch()))
$cats[$i++] = $cat["name"];
$title .= strtoupper($cats[$category]) . " CHART ";
$cats = Engine::api(IChart::class)->getCategories();
$title .= strtoupper($cats[$category-1]["name"]) . " CHART ";
} else {
if($limit) $title .= " TOP $limit ";
}
@@ -252,11 +248,8 @@ public function emitAddRSS($addDate, &$title) {
$output = "&lt;p&gt;Num (Charts) ARTIST &lt;I&gt;Album&lt;/I&gt; (Label)&lt;/p&gt;\n";
$output .= "&lt;p&gt;";
// Stuff the categories into an array
// Get the chart categories
$cats = Engine::api(IChart::class)->getCategories();
$i=1;
while($cats && ($cat = $cats->fetch()))
$catcode[$i++] = $cat["code"];
while($row = $results->fetch()) {
// Fixup the artist, album, and label names
@@ -284,9 +277,10 @@ public function emitAddRSS($addDate, &$title) {
// Categories
$codes = "";
$cats = explode(",", $row[5]);
while(list($index, $cat) = each($cats))
$codes .= $catcode[$cat];
$acats = explode(",", $row["afile_category"]);
foreach($acats as $index => $cat)
if($cat)
$codes .= $cats[$cat-1]["code"];
if($codes == "")
$codes = "G";
@@ -32,6 +32,8 @@
use ZK\UI\UICommon as UI;
class RunDaily implements IController {
private $catCodes;
public function processRequest($dispatcher) {
header("Content-type: text/plain");
@@ -161,22 +163,14 @@ private function buildChart($start, $end, $limit="", $category="", $cmj=0, $crd=
$chartApi->getChart($chart, $start, $end, $limit, $category);
if(sizeof($chart)) {
if($category) {
// stuff the categories into an array
$i=1;
$categories = $chartApi->getCategories();
while($categories && ($cat = $categories->fetch())) {
$directors[$i] = $cat["director"];
$cats[$i++] = $cat["name"];
}
if($crd)
$result .= sprintf("\n\n%s\n%s\n",
strtoupper($cats[$category]),
$directors[$category]);
strtoupper($this->catCodes[$category-1]["name"]),
$this->catCodes[$category-1]["director"]);
else
$result .= sprintf("\n\n%-22s %56s\n",
strtoupper($cats[$category]),
$directors[$category]);
strtoupper($this->catCodes[$category-1]["name"]),
$this->catCodes[$category-1]["director"]);
}
if($cmj)
@@ -256,14 +250,6 @@ private function sendChartGenreEMail($start, $date, $month) {
"1"=>"blues" // blues
];
// Stuff the categories into an array
$categories = Engine::api(IChart::class)->getCategories();
$i=1;
while($categories && ($cat = $categories->fetch())) {
$directors[$i] = $cat["director"];
$cats[$i++] = $cat["name"];
}
// genre director default e-mail domain same as md's
$domain = Engine::param('email')['md'];
$i = strpos($base, '@');
@@ -276,8 +262,10 @@ private function sendChartGenreEMail($start, $date, $month) {
$address .= $domain;
// skip genre e-mail if no valid address
if(!strpos($address, '@'))
if(!strpos($address, '@')) {
echo "Skipping ".$this->catCodes[$genre-1]["name"]." monthly e-mail due to invalid address: $address\n";
continue;
}
// Build the chart
$chart = $this->buildChart($start, $date, 0, $genre, 1);
@@ -288,7 +276,7 @@ private function sendChartGenreEMail($start, $date, $month) {
// Setup the headers
$subject = Engine::param('station').": ".
$cats[$genre] . " monthly totals, " .
$this->catCodes[$genre-1]["name"] . " monthly totals, " .
date("m/Y", mktime(0,0,0,$month,$d,$y));
$headers = "From: ".Engine::param('station')." ".
@@ -297,7 +285,7 @@ private function sendChartGenreEMail($start, $date, $month) {
// send the mail
$stat = mail($address, $subject, $chart, $headers);
echo "Sending ".$cats[$genre]." monthly e-mail: ".
echo "Sending ".$this->catCodes[$genre-1]["name"]." monthly e-mail: ".
($stat?"OK":"FAILED!")."\n";
}
}
@@ -317,13 +305,10 @@ private function chartWeekly($date, $address, $cmj=0) {
}
if($i != strlen($address)) {
echo " <P CLASS=\"header\">E-Mail address is invalid.</P>\n";
echo "Skipping ".($cmj?"cmj":"weekly")." e-mail due to invalid address: $address\n";
} else {
// Stuff the categories into an array
$cats = Engine::api(IChart::class)->getCategories();
$i=1;
while($cats && ($row = $cats->fetch()))
$catcode[$i++] = $row[2];
// get the chart categories
$this->catCodes = Engine::api(IChart::class)->getCategories();
// Build the charts
$charts = $this->buildChart("", $date, 100, "", $cmj);
@@ -369,7 +354,8 @@ private function chartWeekly($date, $address, $cmj=0) {
echo "Sending ".($cmj?"cmj":"weekly").
" e-mail: ".($stat?"OK":"FAILED!")."\n";
}
}
} else
echo "Skipping ".($cmj?"cmj":"weekly")." e-mail: no address configured\n";
}
private function chartMonthly($date, $address, $crd=0) {
@@ -398,13 +384,10 @@ private function chartMonthly($date, $address, $crd=0) {
}
if($i != strlen($address)) {
echo " <P CLASS=\"header\">E-Mail address is invalid.</P>\n";
echo "Skipping ".($crd?"crossroads":"monthly")." e-mail due to invalid address: $address\n";
} else {
// Stuff the categories into an array
$cats = Engine::api(IChart::class)->getCategories();
$i=1;
while($cats && ($row = $cats->fetch()))
$catcode[$i++] = $row[2];
// get the chart categories
$this->catCodes = Engine::api(IChart::class)->getCategories();
// Build the charts
$charts = "";
@@ -461,7 +444,9 @@ private function chartMonthly($date, $address, $crd=0) {
echo "Sending ".($crd?"crossroads":"monthly").
" e-mail: ".($stat?"OK":"FAILED!")."\n";
}
}
} else
echo "Skipping ".($crd?"crossroads":"monthly")." e-mail: no address configured\n";
if(!$crd)
$this->sendChartGenreEMail($start, $date, $month);
}
@@ -30,6 +30,9 @@ div.headerNavbar span {
bottom: 0;
position: absolute;
}
div.leftNav{
div.leftNav {
clear:both;
}
hr {
color: #2d3bce;
}
@@ -43,6 +43,7 @@ TABLE.afileactivity {
border-style: solid;
border-width: 1px 0px 0px 0px;
border-color: #cccccc;
vertical-align: baseline;
}
.noPlaylist, .noPlaylist TD {
background-color: #000000;
@@ -98,6 +99,9 @@ TD.ind {
.recentPlays, .recentReviews {
vertical-align: top;
}
TABLE.djzone TD:last-child {
width: 100%;
}
/* layout */
DIV.box {
@@ -28,6 +28,9 @@
* Chart operations
*/
interface IChart {
const CAT_NAME = 0;
const CAT_CODE = 1;
const CAT_FULL = 2;
function getCategories();
function updateCategory($i, $name, $code, $dir);
function getNextAID();
@@ -34,7 +34,7 @@ class ChartImpl extends BaseImpl implements IChart {
public function getCategories() {
$query = "SELECT id, name, code, director FROM categories ORDER BY id";
$stmt = $this->prepare($query);
return $this->execute($stmt, \PDO::FETCH_BOTH);
return $this->executeAndFetchAll($stmt);
}
public function updateCategory($i, $name, $code, $dir) {
BIN +48 Bytes (100%) img/9mmm_banner.png
Binary file not shown.
Oops, something went wrong.

0 comments on commit 2d15185

Please sign in to comment.