[Fusionforge-commits] FusionForge branch master updated. 1791c451e1fc1bed16ac05394a4eaba937396d9b

Franck Villaume nerville at fusionforge.org
Wed Dec 24 12:23:50 CET 2014


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "FusionForge".

The branch, master has been updated
       via  1791c451e1fc1bed16ac05394a4eaba937396d9b (commit)
      from  a805e1d8ac8f7a75b9f87ff0b4f473d3efe0036f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 1791c451e1fc1bed16ac05394a4eaba937396d9b
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date:   Wed Dec 24 12:16:06 2014 +0100

    report chart html: move html generate code to Layout.class. Make it themable.

diff --git a/src/common/docman/views/reporting.php b/src/common/docman/views/reporting.php
index f3201b6..99e0033 100644
--- a/src/common/docman/views/reporting.php
+++ b/src/common/docman/views/reporting.php
@@ -160,7 +160,7 @@ if (count($data) == 0) {
 		});'."\n";
 	echo '//]]>';
 	echo html_ac(html_ap() -1);
-	echo html_e('div', array('id' => 'chart1'), '', false);
+	echo $HTML->html_chartid('chart1');
 	$tabletop = array(_('Folder'), _('Document'), _('User'), _('Date'));
 	$classth = array('', '', '', '');
 	echo $HTML->listTableTop($tabletop, false, 'sortable_docman_listfile', 'sortable', $classth);
diff --git a/src/common/frs/views/reporting.php b/src/common/frs/views/reporting.php
index 69441a8..a69724a 100644
--- a/src/common/frs/views/reporting.php
+++ b/src/common/frs/views/reporting.php
@@ -165,7 +165,7 @@ if ($report->isError()) {
 				plot1.replot( { resetAxes: true } );
 			});'."\n";
 		echo '//]]></script>';
-		echo html_e('div', array('id' => 'chart1'), '', false);
+		echo $HTML->html_chartid('chart1');
 		echo $HTML->listTableTop(array(_('Package'), _('Release'), _('File'), _('User'), _('Date')),
 				false, true, 'Download');
 		for ($i=0; $i<count($data); $i++) {
diff --git a/src/common/reporting/report_utils.php b/src/common/reporting/report_utils.php
index 6be7d5d..88e1b99 100644
--- a/src/common/reporting/report_utils.php
+++ b/src/common/reporting/report_utils.php
@@ -5,7 +5,7 @@
  * Copyright 2003-2004, Tim Perdue/GForge, LLC
  * Copyright 2009, Roland Mas
  * Copyright (C) 2010 Alain Peyrat - Alcatel-Lucent
- * Copyright 2013, Franck Villaume - TrivialDev
+ * Copyright 2013,2014 Franck Villaume - TrivialDev
  *
  * This file is part of FusionForge. FusionForge is free software;
  * you can redistribute it and/or modify it under the terms of the
@@ -228,7 +228,6 @@ function report_pie_arr($labels, $vals, $format=1) {
 		$pie_labels[]=_('Other')." (". number_format($rem,$format) .") ";
 		$pie_vals[]=$rem;
 	}
-
 }
 
 function report_package_box($group_id, $name='dev_id', $selected='') {
@@ -308,7 +307,6 @@ function trackeract_graph($group_id, $area, $SPAN, $start, $end, $atid) {
 	}
 	echo 'jQuery(document).ready(function(){
 		plot'.$chartid.' = jQuery.jqplot (\'chart'.$chartid.'\', series, {
-			title : \''._('Tracker Activity').' ('.strftime('%x',$start).' - '.strftime('%x',$end).') \',
 			axesDefaults: {
 				tickOptions: {
 					angle: -90,
@@ -358,10 +356,7 @@ function trackeract_graph($group_id, $area, $SPAN, $start, $end, $atid) {
 		plot'.$chartid.'.replot();
 		});'."\n";
 	echo '//]]></script>';
-	echo "<figure>\n";
-	echo "<figcaption>"._('Tracker Activity').' ('.date(_('Y-m-d'), $start).' - '.date(_('Y-m-d'), $end).')'."</figcaption>\n";
-	echo '<div id="chart'.$chartid.'"></div>';
-	echo "</figure>\n";
+	echo $HTML->html_chartid($chartid, _('Tracker Activity').' ('.date(_('Y-m-d'), $start).' - '.date(_('Y-m-d'), $end).')');
 	return true;
 }
 
@@ -387,40 +382,41 @@ function trackerpie_graph($group_id, $area, $SPAN, $start, $end, $atid) {
 			break;
 		}
 	}
-	$chartid = 'projecttrackerpie_'.$group_id;
-	echo '<script type="text/javascript">//<![CDATA['."\n";
-	echo 'var plot'.$chartid.';';
-	echo 'var data = new Array();';
-	while ($row = db_fetch_array($dbres)) {
-		echo 'data.push([\''.htmlentities($row[0]).'\',\''.$row[1].'\']);';
+	if (db_numrows($dbres)) {
+		$chartid = 'projecttrackerpie_'.$group_id;
+		echo '<script type="text/javascript">//<![CDATA['."\n";
+		echo 'var plot'.$chartid.';';
+		echo 'var data = new Array();';
+		while ($row = db_fetch_array($dbres)) {
+			echo 'data.push([\''.htmlentities($row[0]).'\',\''.$row[1].'\']);';
+		}
+		echo 'jQuery(document).ready(function(){
+			plot'.$chartid.' = jQuery.jqplot (\'chart'.$chartid.'\', [data],
+				{
+					seriesDefaults: {
+						// Make this a pie chart.
+						renderer: jQuery.jqplot.PieRenderer,
+						rendererOptions: {
+							// Put data labels on the pie slices.
+							// By default, labels show the percentage of the slice.
+							showDataLabels: true,
+							dataLabels: \'percent\',
+						}
+					},
+					legend: {
+						show:true, location: \'e\',
+					},
+				}
+				);
+			});';
+		echo 'jQuery(window).resize(function() {
+				plot'.$chartid.'.replot( { resetAxes: true } );
+			});'."\n";
+		echo '//]]></script>';
+		echo $HTML->html_chartid($chartid, $areaname.' ('.date(_('Y-m-d'), $start).' - '.date(_('Y-m-d'), $end).')');
+	} else {
+		echo $HTML->information(_('No data to display'));
 	}
-	echo 'jQuery(document).ready(function(){
-		plot'.$chartid.' = jQuery.jqplot (\'chart'.$chartid.'\', [data],
-			{
-				seriesDefaults: {
-					// Make this a pie chart.
-					renderer: jQuery.jqplot.PieRenderer,
-					rendererOptions: {
-						// Put data labels on the pie slices.
-						// By default, labels show the percentage of the slice.
-						showDataLabels: true,
-						dataLabels: \'percent\',
-					}
-				},
-				legend: {
-					show:true, location: \'e\',
-				},
-			}
-			);
-		});';
-	echo 'jQuery(window).resize(function() {
-			plot'.$chartid.'.replot( { resetAxes: true } );
-		});'."\n";
-	echo '//]]></script>';
-	echo "<figure>\n";
-	echo "<figcaption>".$areaname.' ('.date(_('Y-m-d'), $start).' - '.date(_('Y-m-d'), $end).')'."</figcaption>\n";
-	echo '<div id="chart'.$chartid.'"></div>';
-	echo "</figure>\n";
 	return true;
 }
 
@@ -590,10 +586,7 @@ function report_graph($type, $SPAN, $start, $end) {
 			plot'.$chartid.'.replot( { resetAxes: true } );
 		});'."\n";
 	echo '//]]></script>';
-	echo "<figure>\n";
-	echo "<figcaption>".$label[0].' ('.date(_('Y-m-d'), $start).' - '.date(_('Y-m-d'), $end).')'."</figcaption>\n";
-	echo '<div id="chart'.$chartid.'"></div>';
-	echo "</figure>\n";
+	echo $HTML->html_chartid($chartid, $label[0].' ('.date(_('Y-m-d'), $start).' - '.date(_('Y-m-d'), $end).')');
 	return true;
 }
 
@@ -881,10 +874,7 @@ function report_actgraph($type, $SPAN, $start, $end, $id, $area) {
 		plot'.$chartid.'.replot();
 	});'."\n";
 	echo '//]]></script>';
-	echo "<figure>\n";
-	echo "<figcaption>".$areaname.' ('.date(_('Y-m-d'), $start).' - '.date(_('Y-m-d'), $end).')'."</figcaption>\n";
-	echo '<div id="chart'.$chartid.'"></div>';
-	echo "</figure>\n";
+	echo $HTML->html_chartid($chartid, $areaname.' ('.date(_('Y-m-d'), $start).' - '.date(_('Y-m-d'), $end).')');
 	return true;
 }
 
@@ -986,10 +976,7 @@ function report_toolspiegraph($datatype = 0, $start, $end) {
 				plot'.$chartid.'.replot( { resetAxes: true } );
 			});'."\n";
 		echo '//]]></script>';
-		echo "<figure>\n";
-		echo "<figcaption>".$arr[$datatype].' ('.date(_('Y-m-d'), $start).' - '.date(_('Y-m-d'), $end).')'."</figcaption>\n";
-		echo '<div id="chart'.$chartid.'"></div>';
-		echo "</figure>\n";
+		echo $HTML->html_chartid($chartid, $arr[$datatype].' ('.date(_('Y-m-d'), $start).' - '.date(_('Y-m-d'), $end).')');
 	} else {
 		echo $HTML->information(_('No data to display.'));
 	}
@@ -1053,10 +1040,7 @@ function report_timegraph($type = 'site', $area = 'tasks', $start, $end, $id = 0
 				plot'.$chartid.'.replot( { resetAxes: true } );
 			});'."\n";
 		echo '//]]></script>';
-		echo "<figure>\n";
-		echo "<figcaption>".$arr[$area].' ('.date(_('Y-m-d'), $start).' - '.date(_('Y-m-d'), $end).')'."</figcaption>\n";
-		echo '<div id="chart'.$chartid.'"></div>';
-		echo "</figure>\n";
+		echo $HTML->html_chartid($chartid, $arr[$area].' ('.date(_('Y-m-d'), $start).' - '.date(_('Y-m-d'), $end).')');
 	} else {
 		echo $HTML->information(_('No data to display.'));
 	}
@@ -1159,10 +1143,7 @@ function report_sitetimebargraph($start, $end) {
 			plot'.$chartid.'.replot();
 		});'."\n";
 		echo '//]]></script>';
-		echo "<figure>\n";
-		echo "<figcaption>".$areaname.' ('.date(_('Y-m-d'), $start).' - '.date(_('Y-m-d'), $end).')'."</figcaption>\n";
-		echo '<div id="chart'.$chartid.'"></div>';
-		echo "</figure>\n";
+		echo $HTML->html_chartid($chartid, $areaname.' ('.date(_('Y-m-d'), $start).' - '.date(_('Y-m-d'), $end).')');
 	} else {
 		echo $HTML->information(_('No data to display.'));
 	}
@@ -1254,7 +1235,7 @@ function report_pm_hbar($id, $values, $ticks, $labels, $stackSeries = false) {
 		plot'.$id.'.replot();
 	});'."\n";
 	echo '//]]></script>';
-	echo '<div id="chart'.$id.'"></div>';
+	echo $HTML->html_chartid($chartid);
 }
 
 // Local Variables:
diff --git a/src/www/include/Layout.class.php b/src/www/include/Layout.class.php
index 5565412..8ccee7e 100644
--- a/src/www/include/Layout.class.php
+++ b/src/www/include/Layout.class.php
@@ -1483,7 +1483,7 @@ if (isset($params['group']) && $params['group']) {
 	 *						['attrs'] = array of html attrs applied to the li element
 	 * @param	array	$attrs		array of attributes of the ol element. Default empty array.
 	 * @param	string	$type		type of list : ol or ul. Default is ul.
-	 * @return string
+	 * @return	string
 	 */
 	function html_list($elements, $attrs = array() , $type = 'ul') {
 		$htmlcode = html_ao($type, $attrs);
@@ -1496,6 +1496,21 @@ if (isset($params['group']) && $params['group']) {
 		$htmlcode .= html_ac(html_ap() -1);
 		return $htmlcode;
 	}
+
+	/**
+	 * html_chartid - create the div code to be used with jqplot script
+	 *
+	 * @param	string	$chart_id		id to identify the div.
+	 * @param	string	$figcaption_title	title of the chart
+	 * @return	string
+	 */
+	function html_chartid($chart_id = 0, $figcaption_title = '') {
+		$htmlcode = html_ao('figure');
+		$htmlcode .= html_e('figcaption', array(), $figcaption_title);
+		$htmlcode .= html_ao('div', array('id' => 'chart'.$chart_id));
+		$htmlcode .= html_ac(html_ap() -2);
+		return $htmlcode;
+	}
 }
 
 // Local Variables:
diff --git a/src/www/scm/include/scm_utils.php b/src/www/scm/include/scm_utils.php
index 1e66c59..31353ad 100644
--- a/src/www/scm/include/scm_utils.php
+++ b/src/www/scm/include/scm_utils.php
@@ -193,7 +193,7 @@ function commitstime_graph($group_id, $chartid) {
 			plot'.$chartid.'.replot();
 		});'."\n";
 	echo '//]]></script>';
-	echo html_e('div', array('id' => 'chart'.$chartid), '', false);
+	echo $HTML->html_chartid($chartid);
 }
 
 function commits_graph($group_id, $days, $chartid) {
@@ -257,7 +257,7 @@ function commits_graph($group_id, $days, $chartid) {
 				plot'.$chartid.'.replot( { resetAxes: true } );
 			});'."\n";
 		echo '//]]></script>';
-		echo html_e('div', array('id' => 'chart'.$chartid), '', false);
+		echo $HTML->html_chartid($chartid);
 	} else {
 		echo $HTML->information(_('No commits during this period.'));
 	}
diff --git a/src/www/scm/reporting/index.php b/src/www/scm/reporting/index.php
index 49c9ef8..7f012ee 100644
--- a/src/www/scm/reporting/index.php
+++ b/src/www/scm/reporting/index.php
@@ -37,7 +37,6 @@ scm_header(array('title'=>_('SCM Repository Reporting'), 'group'=>$group_id));
 echo html_e('h2', array(), _('Commits Over Time'));
 commitstime_graph($group_id, 1);
 
-
 echo html_e('h2', array(), _('Commits Last 30 Days'));
 commits_graph($group_id, 30, 2);
 

-----------------------------------------------------------------------

Summary of changes:
 src/common/docman/views/reporting.php |    2 +-
 src/common/frs/views/reporting.php    |    2 +-
 src/common/reporting/report_utils.php |  103 ++++++++++++++-------------------
 src/www/include/Layout.class.php      |   17 +++++-
 src/www/scm/include/scm_utils.php     |    4 +-
 src/www/scm/reporting/index.php       |    1 -
 6 files changed, 62 insertions(+), 67 deletions(-)


hooks/post-receive
-- 
FusionForge



More information about the Fusionforge-commits mailing list