git.gnu.io has moved to IP address 209.51.188.249 -- please double check where you are logging in.

Commit 0c25579a authored by Mike Sheldon's avatar Mike Sheldon

Merge commit 'refs/merge-requests/12' of gitorious.org:foocorp/gnu-fm into merge12

parents 6b4974f7 23dac5ab
......@@ -39,7 +39,7 @@ class Graph {
public $user, $type, $renderer, $label_renderer;
public $max_x_axis, $max_y_axis;
public $tick_interval = 20;
public $x_axis_label = "X axis", $y_axis_label = "Y Axis";
public $x_axis_label = 'X axis', $y_axis_label = 'Y Axis';
/* Multidimensional array to allow for multiple series of data. */
protected $graph_types = array(array());
......@@ -131,11 +131,11 @@ class Graph {
**/
protected function buildJsDataArray($inverse = FALSE) {
$temp = "[";
$temp = '[';
foreach ($this->data as $i => $series)
{
$temp .= "[";
$temp .= '[';
if ($inverse) $i = 0;
foreach ($series as $j => $set)
......@@ -143,32 +143,35 @@ class Graph {
foreach ($set as $k => $node)
{
/* Determine if the node is numeric, if not, escape. */
$temp .= "[".((! is_numeric($node)) ? "'".(addslashes($node))."'" : $node);
$temp .= '['.((! is_numeric($node))
? '\''.addslashes($node).'\''
: $node);
/* @TODO: check $node for len > 1, if so tokenise string */
if ($inverse) $temp .= "," . ++$i;
$temp .= "],";
if ($inverse) $temp .= ',' . ++$i;
$temp .= '],';
}
$temp = rtrim($temp, ',');
$temp = rtrim($temp, ',');
}
$temp .= "],";
$temp .= '],';
}
$temp = rtrim($temp, ',');
$temp .= "]";
$temp .= ']';
return $temp;
}
protected function buildJsSingleArray($source) {
$temp = "[";
$temp = '[';
foreach ($source as $i => $node)
{
$temp .= ((! is_numeric($node)) ? "'".$node."'" : $node) . ",";
$temp .= ((! is_numeric($node)) ? '\''.$node.'\'' : $node) . ',';
}
$temp = rtrim($temp, ',') . "]";
$temp = rtrim($temp, ',') . ']';
return $temp;
}
}
\ No newline at end of file
......@@ -39,7 +39,7 @@ class GraphTopArtists extends Graph {
**/
function __construct($user, $num = 20)
{
parent::__construct($user, "bar_horiz");
parent::__construct($user, 'bar_horiz');
$this->number_of_tracks = $num;
$this->buildGraphData();
}
......@@ -53,12 +53,14 @@ class GraphTopArtists extends Graph {
**/
private function buildGraphData()
{
$tmp = Statistic::GeneratePlayStats('Scrobbles', 'artist',
$tmp = Statistic::generatePlayStats('Scrobbles', 'artist',
$this->number_of_tracks, $this->user->uniqueid, 300);
foreach ($tmp as $root => $node)
{
$artists[] = '<a href="'.$node['artisturl'].'">'.addslashes($node['artist']).'</a>';
$tmp = '<a href="'.$node['pageurl'].'">';
$tmp .= addslashes(htmlentities($node['artist'])).'</a>';
$artists[] = $tmp;
$artists_data[] = $node['count'];
}
......@@ -86,7 +88,7 @@ class GraphTopTracks extends Graph {
**/
function __construct($user, $num = 20)
{
parent::__construct($user, "bar_horiz");
parent::__construct($user, 'bar_horiz');
$this->number_of_tracks = $num;
$this->buildGraphData();
}
......@@ -106,8 +108,10 @@ class GraphTopTracks extends Graph {
foreach($this->data_buffer as $key => $entry)
{
$tmp_line = '<a href="'.$entry['artisturl'].'">'.$entry['artist'].'</a>';
$tmp_line .= ' - <a href="'.$entry['trackurl'].'">'.addslashes($entry['track']).'</a>';
$tmp_line = '<a href="'.$entry['artisturl'].'">';
$tmp_line .= addslashes(htmlentities($entry['artist'])).'</a>';
$tmp_line .= ' - <a href="'.$entry['trackurl'].'">';
$tmp_line .= addslashes(htmlentities($entry['track'])).'</a>';
$listings[] = $entry['freq'];
$tracks[] = $tmp_line;
}
......@@ -136,7 +140,7 @@ class GraphPlaysByDays extends Graph {
**/
function __construct($user, $num = 20)
{
parent::__construct($user, "line");
parent::__construct($user, 'line');
$this->number_of_days = $num;
$this->buildGraphData();
}
......@@ -155,15 +159,15 @@ class GraphPlaysByDays extends Graph {
$this->data_buffer = Statistic::generatePlayByDays('Scrobbles',
$this->number_of_days, $this->user->uniqueid, 300);
$date_line = "[";
$date_line = '[';
foreach ($this->data_buffer as $key => $entry)
{
$date_line .= "['" . $entry['date'] . "', " . $entry['count'] . "],";
$date_line .= '[\'' . $entry['date'] . '\', ' . $entry['count'] . '],';
}
$this->plays_by_days = rtrim($date_line, ',');
$this->plays_by_days .= "]";
$this->plays_by_days .= ']';
}
}
......
......@@ -7,7 +7,7 @@ $(document).ready(function() {
color: '#ff0000',
rendererOptions: {
barDirection: 'horizontal',
barWidth: 15
barWidth: def_bar_width
}
},
axes: {
......@@ -32,7 +32,7 @@ $(document).ready(function() {
color: '#ff0000',
rendererOptions: {
barDirection: 'horizontal',
barWidth: 15
barWidth: def_bar_width
}
},
axes: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment