Selaa lähdekoodia

Feature #272 - Adapting the library mPDF 4.2 to the system: Moving some directories for temporary files in the directory ".../chamilo/arcive/" where access for writting is guaranteed.

Ivan Tcholakov 15 vuotta sitten
vanhempi
commit
3380cb994f
4 muutettua tiedostoa jossa 352 lisäystä ja 294 poistoa
  1. 122 102
      main/inc/lib/mpdf/graph.php
  2. 155 139
      main/inc/lib/mpdf/mpdf.php
  3. 42 42
      main/inc/lib/mpdf/mpdfi/mpdfi.php
  4. 33 11
      main/inc/lib/mpdf/progress/out.php

+ 122 - 102
main/inc/lib/mpdf/graph.php

@@ -9,26 +9,36 @@ if (!defined('_TTF_FONT_BOLDITALIC')) { define("_TTF_FONT_BOLDITALIC", 'arialbi.
 // DELETE OLD GRAPH FILES FIRST - Housekeeping
 // First clear any files in directory that are >1 hrs old
 	$interval = 3600;
-	if ($handle = opendir(_MPDF_PATH.'graph_cache')) {
-	   while (false !== ($file = readdir($handle))) { 
-		if (((filemtime(_MPDF_PATH.'graph_cache/'.$file)+$interval) < time()) && ($file != "..") && ($file != ".")) { 
-			unlink(_MPDF_PATH.'graph_cache/'.$file); 
+	// Modified by Ivan Tcholakov, 28-JAN-2010.
+	//if ($handle = opendir(_MPDF_PATH.'graph_cache')) {
+	//   while (false !== ($file = readdir($handle))) {
+	//	if (((filemtime(_MPDF_PATH.'graph_cache/'.$file)+$interval) < time()) && ($file != "..") && ($file != ".")) {
+	//		unlink(_MPDF_PATH.'graph_cache/'.$file);
+	//	}
+	//   }
+	//   closedir($handle);
+	//}
+	if ($handle = opendir(_MPDF_GRAPH_CHACHE_PATH)) {
+	   while (false !== ($file = readdir($handle))) {
+		if (((filemtime(_MPDF_GRAPH_CHACHE_PATH.$file)+$interval) < time()) && ($file != "..") && ($file != ".")) {
+			unlink(_MPDF_GRAPH_CHACHE_PATH.$file);
 		}
 	   }
-	   closedir($handle); 
+	   closedir($handle);
 	}
+	//
 //==============================================================================================================
 // LOAD GRAPHS
 
-	include_once(_JPGRAPH_PATH.'jpgraph.php'); 
-	include_once(_JPGRAPH_PATH.'jpgraph_line.php' ); 
-	include_once(_JPGRAPH_PATH.'jpgraph_log.php' ); 
-	include_once(_JPGRAPH_PATH.'jpgraph_scatter.php' ); 
-	include_once(_JPGRAPH_PATH.'jpgraph_regstat.php' ); 
-	include_once(_JPGRAPH_PATH.'jpgraph_pie.php'); 
-	include_once(_JPGRAPH_PATH.'jpgraph_pie3d.php'); 
-	include_once(_JPGRAPH_PATH.'jpgraph_bar.php'); 
-	include_once(_JPGRAPH_PATH.'jpgraph_radar.php'); 
+	include_once(_JPGRAPH_PATH.'jpgraph.php');
+	include_once(_JPGRAPH_PATH.'jpgraph_line.php' );
+	include_once(_JPGRAPH_PATH.'jpgraph_log.php' );
+	include_once(_JPGRAPH_PATH.'jpgraph_scatter.php' );
+	include_once(_JPGRAPH_PATH.'jpgraph_regstat.php' );
+	include_once(_JPGRAPH_PATH.'jpgraph_pie.php');
+	include_once(_JPGRAPH_PATH.'jpgraph_pie3d.php');
+	include_once(_JPGRAPH_PATH.'jpgraph_bar.php');
+	include_once(_JPGRAPH_PATH.'jpgraph_radar.php');
 
 
 //======================================================================================================
@@ -69,7 +79,7 @@ function print_graph($g,$pgwidth) {
 	if (isset($g['attr']['HIDE-Y-AXIS']) && $g['attr']['HIDE-Y-AXIS']) { $hide_y_axis = true; }	// Hide the y-axis
 
 
-	// Antialias: If true - better quality curves, but graph line will only be 1px even in PDF 300dpi 
+	// Antialias: If true - better quality curves, but graph line will only be 1px even in PDF 300dpi
 	// default=true for most except line and radar
 	if (isset($g['attr']['ANTIALIAS']) && ($g['attr']['ANTIALIAS']=='' || $g['attr']['ANTIALIAS']==0)) { $antialias = false; }
 	else if (isset($g['attr']['ANTIALIAS']) && $g['attr']['ANTIALIAS'] > 0) { $antialias = true; }
@@ -78,7 +88,7 @@ function print_graph($g,$pgwidth) {
 
 	if ($g['attr']['DPI']) { $dpi = intval($g['attr']['DPI']); }
 	if (!$dpi || $dpi < 50 || $dpi > 2400) { $dpi = 150; } 	// Default dpi 150
-	$k = (0.2645/25.4 * $dpi); 
+	$k = (0.2645/25.4 * $dpi);
 
 	$img_type = 'png'; 	// Can use jpeg or gif (gif is very slow)
 
@@ -110,7 +120,7 @@ function print_graph($g,$pgwidth) {
 	// Defaults - define data
 	$rowbegin = 2;
 	$colbegin = 2;
-	if($type=='scatter' || $type=='xy') { 
+	if($type=='scatter' || $type=='xy') {
 		if ($dataseries == 'rows') { $rowbegin = 1; }
 		else { $colbegin = 1; }
 	}
@@ -149,12 +159,12 @@ function print_graph($g,$pgwidth) {
 		for ($c=($colbegin-1);$c<$colend;$c++) {
 		    if (isset($g['data'][$r][$c])) { $g['data'][$r][$c] = floatval($g['data'][$r][$c] ); }
 		    else { $g['data'][$r][$c] = 0; }
-		    if ($dataseries=='rows') { 
-			$data[($r+1-$rowbegin)][($c+1-$colbegin)] = $g['data'][$r][$c] ; 
-			$totals[($r+1-$rowbegin)] += $g['data'][$r][$c] ; 
+		    if ($dataseries=='rows') {
+			$data[($r+1-$rowbegin)][($c+1-$colbegin)] = $g['data'][$r][$c] ;
+			$totals[($r+1-$rowbegin)] += $g['data'][$r][$c] ;
 		    }
-		    else { 
-			$data[($c+1-$colbegin)][($r+1-$rowbegin)] = $g['data'][$r][$c] ; 
+		    else {
+			$data[($c+1-$colbegin)][($r+1-$rowbegin)] = $g['data'][$r][$c] ;
 			if (isset($totals[($c+1-$colbegin)])) { $totals[($c+1-$colbegin)] += $g['data'][$r][$c] ; }
 			else { $totals[($c+1-$colbegin)] = $g['data'][$r][$c] ; }
 		    }
@@ -173,30 +183,30 @@ function print_graph($g,$pgwidth) {
 	$labels = array();
 	$longestlegend = 0;
 	$longestlabel = 0;
-	if ($dataseries=='cols') { 
+	if ($dataseries=='cols') {
 		if ($colbegin>1) {
-			for ($r=($rowbegin-1);$r<$rowend;$r++) { 
+			for ($r=($rowbegin-1);$r<$rowend;$r++) {
 				$legends[($r+1-$rowbegin)] = $g['data'][$r][0] ;
 				$longestlegend = max($longestlegend, strlen( $g['data'][$r][0] ));
 			}
 		}
 		if ($rowbegin>1) {
-			for ($c=($colbegin-1);$c<$colend;$c++) { 
-				$labels[($c+1-$colbegin)] = $g['data'][0][$c] ; 
+			for ($c=($colbegin-1);$c<$colend;$c++) {
+				$labels[($c+1-$colbegin)] = $g['data'][0][$c] ;
 				$longestlabel = max($longestlabel , strlen( $g['data'][0][$c] ));
 			}
 		}
 	}
-	else if ($dataseries=='rows') { 
+	else if ($dataseries=='rows') {
 		if ($colbegin>1) {
-			for ($r=($rowbegin-1);$r<$rowend;$r++) { 
-				$labels[($r+1-$rowbegin)] = $g['data'][$r][0] ; 
+			for ($r=($rowbegin-1);$r<$rowend;$r++) {
+				$labels[($r+1-$rowbegin)] = $g['data'][$r][0] ;
 				$longestlabel = max($longestlabel , strlen( $g['data'][$r][0] ));
 			}
 		}
 		if ($rowbegin>1) {
-			for ($c=($colbegin-1);$c<$colend;$c++) { 
-				$legends[($c+1-$colbegin)] = $g['data'][0][$c] ; 
+			for ($c=($colbegin-1);$c<$colend;$c++) {
+				$legends[($c+1-$colbegin)] = $g['data'][0][$c] ;
 				$longestlegend = max($longestlegend, strlen( $g['data'][0][$c] ));
 			}
 		}
@@ -220,7 +230,10 @@ function print_graph($g,$pgwidth) {
 
 
    if (count($data)>0 && $type) {
-	$figure_file = "graph_cache/".rand(11111,999999999).".".$img_type;
+   	// Modified by Ivan Tcholakov, 28-JAN-2010.
+	//$figure_file = "graph_cache/".rand(11111,999999999).".".$img_type;
+	$figure_file = _MPDF_GRAPH_CHACHE_PATH.rand(11111,999999999).".".$img_type;
+	//
 	if ($bandw) { $colours = array('snow1','black','snow4','snow3','snow2','cadetblue4','cadetblue3','cadetblue1','bisque4','bisque2','beige'); }
 	else { $colours = array('cyan','darkorchid4','cadetblue3','khaki1','darkolivegreen2','cadetblue4','coral','cyan4','rosybrown3','wheat1'); }
 	$fills = array('navy','orange','red','yellow','purple','navy','orange','red','yellow','purple');
@@ -228,10 +241,10 @@ function print_graph($g,$pgwidth) {
 	$markers = array(MARK_DIAMOND, MARK_SQUARE, MARK_CIRCLE, MARK_UTRIANGLE, MARK_DTRIANGLE, MARK_FILLEDCIRCLE, MARK_CROSS, MARK_STAR, MARK_X);
 
 	// LEGENDS
-	if ($type == 'pie' || $type == 'pie3d') { 
-		$graph = new PieGraph (($w*$k),($h*$k));  
+	if ($type == 'pie' || $type == 'pie3d') {
+		$graph = new PieGraph (($w*$k),($h*$k));
 	}
-	else if ($type == 'radar') { 
+	else if ($type == 'radar') {
 		$graph = new RadarGraph(($w*$k),($h*$k));
 	}
 	else {
@@ -243,19 +256,19 @@ function print_graph($g,$pgwidth) {
 	$graph->img->SetImgFormat($img_type) ;
 	if (strtoupper($img_type)=='JPEG') { $graph->img->SetQuality(90); }
 	if ($antialias) { $graph->img->SetAntiAliasing(); }
-	$graph->SetShadow(true, 2*$k); 
+	$graph->SetShadow(true, 2*$k);
 	$graph->SetMarginColor("white");
 	// TITLE
-	$graph->title->Set($title); 
-	$graph->title->SetMargin(10*$k);	
+	$graph->title->Set($title);
+	$graph->title->SetMargin(10*$k);
 	$graph->title->SetFont(FF_USERFONT,FS_BOLD,11*$k);
 	$graph->title->SetColor("black");
-	$graph->legend->SetLineSpacing(3*$k); 
-	$graph->legend->SetMarkAbsSize(6*$k); 
+	$graph->legend->SetLineSpacing(3*$k);
+	$graph->legend->SetMarkAbsSize(6*$k);
 	$graph->legend->SetFont(FF_USERFONT,FS_NORMAL,8*$k);
 
 	// Set GRAPH IMAGE MARGINS
-	if ($type == 'pie' || $type == 'pie3d') { 
+	if ($type == 'pie' || $type == 'pie3d') {
 		$psize = 0.3;
 		$pposxabs = ($w/2);
 		$pposy = 0.55;
@@ -263,9 +276,9 @@ function print_graph($g,$pgwidth) {
 			$pposxabs -= ((($longestlegend * 5) + 20) / 2);
 		}
 		$pposx = ($pposxabs / $w);
-		$graph->legend->Pos(0.02,0.5,'right','center'); 
+		$graph->legend->Pos(0.02,0.5,'right','center');
 	}
-	else if ($type == 'radar') { 
+	else if ($type == 'radar') {
 		$psize = 0.5;
 		$pposxabs = ($w/2);
 		$pposy = 0.55;
@@ -273,7 +286,7 @@ function print_graph($g,$pgwidth) {
 			$pposxabs -= ((($longestlabel * 5) + 20) / 2);
 		}
 		$pposx = ($pposxabs / $w);
-		$graph->legend->Pos(0.02,0.5,'right','center'); 
+		$graph->legend->Pos(0.02,0.5,'right','center');
 	}
 	else if ($type == 'xy' || $type == 'scatter') {
 		$pml = 50;
@@ -282,7 +295,7 @@ function print_graph($g,$pgwidth) {
 		$pmb = 50;
 		$xaxislblmargin = $pmb - 30;
 		$yaxislblmargin = $pml - 15;
-		$graph->legend->Pos(0.02,0.1,'right','top'); 
+		$graph->legend->Pos(0.02,0.1,'right','top');
 	}
 	else if ($type == 'line' || $type == 'bar') {
 		$pml = 50;
@@ -300,7 +313,7 @@ function print_graph($g,$pgwidth) {
 		if ($longestlabel && !$overlap) {	// if legend showing
 			$pmr = ((($longestlabel * 5) + 40));
 		}
-		$graph->legend->Pos(0.02,0.1,'right','top'); 
+		$graph->legend->Pos(0.02,0.1,'right','top');
 	}
 	else if ($type == 'horiz_bar') {
 		$pml = 50;
@@ -314,14 +327,14 @@ function print_graph($g,$pgwidth) {
 		if ($longestlabel && !$overlap) {	// if legend showing
 			$pmr = ((($longestlabel * 5) + 40));
 		}
-		$graph->legend->Pos(0.02,0.1,'right','top'); 
+		$graph->legend->Pos(0.02,0.1,'right','top');
 	}
 
 
 	// DRAW THE GRAPHS
-	if ($type == 'pie') { 
-			$p1 = new PiePlot($data[0]); 
-			$p1->SetSliceColors($colours); 
+	if ($type == 'pie') {
+			$p1 = new PiePlot($data[0]);
+			$p1->SetSliceColors($colours);
 
 			if ($show_values) {
 				$p1->value->SetFont(FF_USERFONT,FS_NORMAL,8*$k);
@@ -337,17 +350,17 @@ function print_graph($g,$pgwidth) {
 			$p1->SetLegends($legends);
 			$p1->SetSize($psize);
 			$p1->SetCenter($pposx, $pposy);
-			if ($labels[0]) { 
-				$graph->subtitle->Set($labels[0]); 
-				$graph->subtitle->SetMargin(10*$k);	
+			if ($labels[0]) {
+				$graph->subtitle->Set($labels[0]);
+				$graph->subtitle->SetMargin(10*$k);
 				$graph->subtitle->SetFont(FF_USERFONT,FS_BOLD,11*$k);
 				$graph->subtitle->SetColor("black");
 			}
 			$graph->Add($p1);
 	}
-	else if ($type == 'pie3d') { 
-			$p1 = new PiePlot3d($data[0]); 
-			$p1->SetSliceColors($colours); 
+	else if ($type == 'pie3d') {
+			$p1 = new PiePlot3d($data[0]);
+			$p1->SetSliceColors($colours);
 			if ($show_values) {
 				$p1->value->SetFont(FF_USERFONT,FS_NORMAL,8*$k);
 				if ($percent) { $p1->SetLabelType(PIE_VALUE_PERADJ); }   //PIE_VAL_PER = default
@@ -361,17 +374,17 @@ function print_graph($g,$pgwidth) {
 			$p1->SetSize($psize);
 			$p1->SetCenter($pposx, $pposy);
 
-			if ($labels[0]) { 
-				$graph->subtitle->Set($labels[0]); 
-				$graph->subtitle->SetMargin(10*$k);	
+			if ($labels[0]) {
+				$graph->subtitle->Set($labels[0]);
+				$graph->subtitle->SetMargin(10*$k);
 				$graph->subtitle->SetFont(FF_USERFONT,FS_BOLD,11*$k);
 				$graph->subtitle->SetColor("black");
 			}
 
-			$graph->Add( $p1); 
+			$graph->Add( $p1);
 	}
 	// RADAR
-	else if ($type == 'radar') { 
+	else if ($type == 'radar') {
 			$graph->SetSize($psize);
 			$graph->SetPos($pposx, $pposy);
 
@@ -382,10 +395,10 @@ function print_graph($g,$pgwidth) {
 			$graph->axis->SetWeight(1*$k);
 			$graph->axis->HideLabels();
 			$graph->axis->SetFont(FF_USERFONT,FS_NORMAL,6*$k);
-			$graph->HideTickMarks(); 
+			$graph->HideTickMarks();
 
 			$group = array();
-			foreach($data AS $series => $dat) { 
+			foreach($data AS $series => $dat) {
 				$rdata = array();
 				foreach($data[$series] AS $row) { $rdata[] = $row;  }
 				if (count($rdata)<3) { die("ERROR::Graph::Cannot create a Radar Plot with less than 3 data points."); }
@@ -405,7 +418,7 @@ function print_graph($g,$pgwidth) {
 	}
 	// LINE
 	else if ($type == 'line') {
-			// Setup the graph. 
+			// Setup the graph.
 			$graph->img->SetMargin($pml*$k,$pmr*$k,$pmt*$k,$pmb*$k);	// LRTB
 			$graph->SetScale($axes);
 			$graph->yaxis->SetFont(FF_USERFONT,FS_NORMAL,8*$k);
@@ -413,10 +426,10 @@ function print_graph($g,$pgwidth) {
 			if ($ylabel) {
 				$graph->yaxis->title->SetFont(FF_USERFONT,FS_NORMAL,8*$k);
 				$graph->yaxis->SetTitle($ylabel,'middle');
-				$graph->yaxis->SetTitleMargin($yaxislblmargin*$k); 
+				$graph->yaxis->SetTitleMargin($yaxislblmargin*$k);
 			}
 
-			$graph->yaxis->SetLabelMargin(4*$k); 
+			$graph->yaxis->SetLabelMargin(4*$k);
 			if ($percent || $show_percent) { $graph->yaxis->SetLabelFormat('%d%%'); }	// Percent
 
 			// Show 0 label on Y-axis (default is not to show)
@@ -428,21 +441,21 @@ function print_graph($g,$pgwidth) {
 			$graph->xaxis->SetFont(FF_USERFONT,FS_NORMAL,8*$k);
 			$graph->xaxis->SetTickLabels($legends);
 			$graph->xaxis->SetLabelAngle($xlangle);
-			$graph->xaxis->SetLabelMargin(4*$k); 
+			$graph->xaxis->SetLabelMargin(4*$k);
 			// X-axis title
 			if ($xlabel) {
 				$graph->xaxis->title->SetFont(FF_USERFONT,FS_NORMAL,8*$k);
 				$graph->xaxis->SetTitle($xlabel,'middle');
-				$graph->xaxis->SetTitleMargin($xaxislblmargin*$k); 
+				$graph->xaxis->SetTitleMargin($xaxislblmargin*$k);
 			}
-			foreach($data AS $series => $rdata) { 
+			foreach($data AS $series => $rdata) {
 				$bplot = new LinePlot($rdata);
 				$bplot->mark->SetType($markers[$series]);
 				$bplot->mark->SetFillColor($colours[$series]);
 				$bplot->mark->SetWidth(4*$k);
 				if ($show_values) {
 					$bplot->value-> Show();	// Not if scatter
-					$bplot->value->SetMargin(6*$k); 
+					$bplot->value->SetMargin(6*$k);
 					$bplot->value->SetColor("darkred");
 					$bplot->value->SetFont( FF_USERFONT, FS_NORMAL, 8*$k);
 					if ($percent || $show_percent) { $bplot->value->SetFormat( '%d%%'); }
@@ -461,7 +474,7 @@ function print_graph($g,$pgwidth) {
 	}
 	// XY or SCATTER
 	else if ($type == 'xy' || $type == 'scatter') {
-			// Setup the graph. 
+			// Setup the graph.
 			$graph->img->SetMargin($pml*$k,$pmr*$k,$pmt*$k,$pmb*$k);	// LRTB
 			$graph->SetScale($axes);
 			// Setup font for axis
@@ -469,18 +482,18 @@ function print_graph($g,$pgwidth) {
 			// Y-axis title
 			if ($labels[1]) {
 				$graph->yaxis->title->SetFont(FF_USERFONT,FS_NORMAL,8*$k);
-				$graph->yaxis->SetTitleMargin($yaxislblmargin*$k); 
+				$graph->yaxis->SetTitleMargin($yaxislblmargin*$k);
 				$graph->yaxis->SetTitle($labels[1],'middle');
 			}
 
 
-			$graph->yaxis->SetLabelMargin(4*$k); 
+			$graph->yaxis->SetLabelMargin(4*$k);
 			if ($percent || $show_percent) { $graph->yaxis->SetLabelFormat('%d%%'); }	// Percent
 
 			// Show 0 label on Y-axis (default is not to show)
 			$graph->yscale->ticks->SupressZeroLabel(true);
 			// Just let the maximum be autoscaled
-			$graph->yaxis->scale->SetAutoMin(0); 
+			$graph->yaxis->scale->SetAutoMin(0);
 			if ($hide_y_axis) { $graph->yaxis->Hide(); }
 			if ($hide_grid) { $graph->ygrid->Show(false); }
 
@@ -489,11 +502,11 @@ function print_graph($g,$pgwidth) {
 // mPDF 2.5 Corrects labelling of x-axis
 //			$graph->xaxis->SetTickLabels($legends);
 			$graph->xaxis->SetLabelAngle(50);
-			$graph->xaxis->SetLabelMargin(4*$k); 
+			$graph->xaxis->SetLabelMargin(4*$k);
 			// X-axis title
 			if ($labels[0]) {
 				$graph->xaxis->title->SetFont(FF_USERFONT,FS_NORMAL,8*$k);
-				$graph->xaxis->SetTitleMargin($xaxislblmargin*$k); 
+				$graph->xaxis->SetTitleMargin($xaxislblmargin*$k);
 				$graph->xaxis->SetTitle($labels[0],'middle');
 			}
 
@@ -525,9 +538,9 @@ function print_graph($g,$pgwidth) {
 			$cplot->mark->SetFillColor($fills[0]);
 			$cplot->mark->SetWidth(8*$k);
 			if ($show_values) {
-// mPDF 2.5 
+// mPDF 2.5
 				if ($type=='xy') { $cplot->value->Show(); }	// Not if scatter
-				$cplot->value->SetMargin(8*$k); 
+				$cplot->value->SetMargin(8*$k);
 				$cplot->value->SetColor("darkred");
 				$cplot->value->SetFont( FF_USERFONT, FS_NORMAL, 6*$k);
 
@@ -544,18 +557,18 @@ function print_graph($g,$pgwidth) {
 	}
 	// BAR
 	else if ($type == 'bar') {
-			// Setup the graph. 
+			// Setup the graph.
 			$graph->img->SetMargin($pml*$k,$pmr*$k,$pmt*$k,$pmb*$k);	// LRTB
 			$graph->SetScale($axes);
 			// Setup y-axis
 			$graph->yaxis->SetFont(FF_USERFONT,FS_NORMAL,8*$k);
 			if ($hide_y_axis) { $graph->yaxis->Hide(); }
 			if ($hide_grid) { $graph->ygrid->Show(false); }
-			$graph->yaxis->SetLabelMargin(4*$k); 
+			$graph->yaxis->SetLabelMargin(4*$k);
 			if ($ylabel) {
 				$graph->yaxis->title->SetFont(FF_USERFONT,FS_NORMAL,8*$k);
 				$graph->yaxis->SetTitle($ylabel,'middle');
-				$graph->yaxis->SetTitleMargin($yaxislblmargin*$k); 
+				$graph->yaxis->SetTitleMargin($yaxislblmargin*$k);
 			}
 			// Show 0 label on Y-axis (default is not to show)
 			$graph->yscale->ticks->SupressZeroLabel(false);
@@ -563,23 +576,23 @@ function print_graph($g,$pgwidth) {
 			$graph->xaxis->SetFont(FF_USERFONT,FS_NORMAL,8*$k);
 			$graph->xaxis->SetTickLabels($legends);
 			$graph->xaxis->SetLabelAngle($xlangle);
-			$graph->xaxis->SetLabelMargin(4*$k); 
+			$graph->xaxis->SetLabelMargin(4*$k);
 			// X-axis title
 			if ($xlabel) {
 				$graph->xaxis->title->SetFont(FF_USERFONT,FS_NORMAL,8*$k);
 				$graph->xaxis->SetTitle($xlabel,'middle');
-				$graph->xaxis->SetTitleMargin($xaxislblmargin*$k); 
+				$graph->xaxis->SetTitleMargin($xaxislblmargin*$k);
 			}
 
 			$group = array();
-			foreach($data AS $series => $dat) { 
+			foreach($data AS $series => $dat) {
 				$rdata = array();
 				foreach($data[$series] AS $row) { $rdata[] = $row;  }
 
 				// Create the bar plot
 				$bplot = new BarPlot($rdata);
 				$bplot->SetWidth(0.6);	// for SINGLE??
-				// Setup color for gradient fill style 
+				// Setup color for gradient fill style
 				if ($bandw) { $bplot->SetPattern( $patterns[$series]); }
 				else { $bplot->SetFillGradient($fills[$series],"#EEEEEE",GRAD_LEFT_REFLECTION); }
 
@@ -589,7 +602,7 @@ function print_graph($g,$pgwidth) {
 				if ($bandw) { $bplot->SetShadow("gray5"); }
 				if ($show_values) {
 					$bplot->value->Show();
-					$bplot->value->SetMargin(6*$k); 
+					$bplot->value->SetMargin(6*$k);
 					$bplot->value->SetColor("darkred");
 					$bplot->value->SetFont( FF_USERFONT, FS_NORMAL, 8*$k);
 					if ($percent || $show_percent) { $bplot->value->SetFormat( '%d%%'); }
@@ -602,12 +615,12 @@ function print_graph($g,$pgwidth) {
 				$graph->Add($group[0]);
 			}
 			else {
-				// Create the grouped bar plot 
+				// Create the grouped bar plot
 				if ($stacked) {
-					$gbplot = new AccBarPlot ($group); 
+					$gbplot = new AccBarPlot ($group);
 				}
 				else {
-					$gbplot = new GroupBarPlot ($group); 
+					$gbplot = new GroupBarPlot ($group);
 				}
 				$graph->Add($gbplot);
 			}
@@ -618,7 +631,7 @@ function print_graph($g,$pgwidth) {
 
 			// Setup y-axis
 			$graph->yaxis->SetFont(FF_USERFONT,FS_NORMAL,8*$k);
-			$graph->yaxis->SetLabelMargin(4*$k); 
+			$graph->yaxis->SetLabelMargin(4*$k);
 
 			$graph->yaxis->SetPos('max');	// Intersect at top of x-axis i.e. y axis is at bottom
 			// First make the labels look right
@@ -634,7 +647,7 @@ function print_graph($g,$pgwidth) {
 			if ($ylabel) {
 				$graph->yaxis->title->SetFont(FF_USERFONT,FS_NORMAL,8*$k);
 				$graph->yaxis->SetTitle($ylabel,'middle');
-				$graph->yaxis->SetTitleMargin($yaxislblmargin*$k); 
+				$graph->yaxis->SetTitleMargin($yaxislblmargin*$k);
 				// Finally setup the title
 				$graph->yaxis->SetTitleSide(SIDE_RIGHT);
 				// To align the title to the right use :
@@ -649,21 +662,21 @@ function print_graph($g,$pgwidth) {
 			$graph->xaxis->SetFont(FF_USERFONT,FS_NORMAL,8*$k);
 			$graph->xaxis->title->SetAngle(90);
 			$graph->xaxis->SetTickLabels($legends);
-			$graph->xaxis->SetLabelMargin(4*$k); 
+			$graph->xaxis->SetLabelMargin(4*$k);
 			// X-axis title
 			if ($xlabel) {
 				$graph->xaxis->title->SetFont(FF_USERFONT,FS_NORMAL,8*$k);
-				$graph->xaxis->SetTitleMargin($xaxislblmargin*$k); 
+				$graph->xaxis->SetTitleMargin($xaxislblmargin*$k);
 				$graph->xaxis->SetTitle($xlabel,'middle');
 			}
 			$group = array();
-			foreach($data AS $series => $dat) { 
+			foreach($data AS $series => $dat) {
 				$rdata = array();
 				foreach($data[$series] AS $row) { $rdata[] = $row;  }
 				// Create the bar pot
 				$bplot = new BarPlot($rdata);
 				$bplot->SetWidth(0.6);	// for SINGLE??
-				// Setup color for gradient fill style 
+				// Setup color for gradient fill style
 				if ($bandw) { $bplot->SetPattern( $patterns[$series]); }
 				else { $bplot->SetFillGradient($fills[$series],"#EEEEEE",GRAD_LEFT_REFLECTION); }
 
@@ -673,7 +686,7 @@ function print_graph($g,$pgwidth) {
 				if ($bandw) { $bplot->SetShadow("gray5"); }
 				if ($show_values) {
 					$bplot->value-> Show();
-					$bplot->value->SetMargin(6*$k); 
+					$bplot->value->SetMargin(6*$k);
 					$bplot->value->SetColor("darkred");
 					$bplot->value->SetFont( FF_USERFONT, FS_NORMAL, 8*$k);
 					if ($percent || $show_percent) { $bplot->value->SetFormat( '%d%%'); }
@@ -686,22 +699,29 @@ function print_graph($g,$pgwidth) {
 				$graph->Add($group[0]);
 			}
 			else {
-				// Create the grouped bar plot 
+				// Create the grouped bar plot
 				if ($stacked) {
-					$gbplot = new AccBarPlot ($group); 
+					$gbplot = new AccBarPlot ($group);
 				}
 				else {
-					$gbplot = new GroupBarPlot ($group); 
+					$gbplot = new GroupBarPlot ($group);
 				}
 				$graph->Add($gbplot);
 			}
 	}
+	// Modified by Ivan Tcholakov, 28-JAN-2010.
+	//if ($graph) {
+	//	$graph->Stroke( _MPDF_PATH.$figure_file);
+	//	$srcpath = str_replace("\\","/",dirname(__FILE__)) . "/";
+	//	$srcpath .= $figure_file;
+	//	return array('file'=>$srcpath, 'w'=>$w, 'h'=>$h);
+	//}
 	if ($graph) {
-		$graph->Stroke( _MPDF_PATH.$figure_file);
-		$srcpath = str_replace("\\","/",dirname(__FILE__)) . "/";
-		$srcpath .= $figure_file;
+		$graph->Stroke($figure_file);
+		$srcpath = $figure_file;
 		return array('file'=>$srcpath, 'w'=>$w, 'h'=>$h);
 	}
+	//
    }
    return false;
 }

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 155 - 139
main/inc/lib/mpdf/mpdf.php


+ 42 - 42
main/inc/lib/mpdf/mpdfi/mpdfi.php

@@ -67,7 +67,7 @@ class mPDFI extends mPDF {
 
 	// Thumbnails
 	// mPDF 2.3 Templates
-	function Thumbnail($file, $npr=3, $spacing=10) {	//$npr = number per row	
+	function Thumbnail($file, $npr=3, $spacing=10) {	//$npr = number per row
 		$w = (($this->pgwidth + $spacing)/$npr) - $spacing;
 		$oldlinewidth = $this->LineWidth;
 		$this->SetLineWidth(0.02); $this->SetDrawColor(0);
@@ -85,9 +85,9 @@ class mPDFI extends mPDF {
 			$maxh = max($h, $maxh);
 			if ($n % $npr == 0) {
 			   if (($y + $h + $spacing + $maxh)>$this->PageBreakTrigger && $n != $pagecount) {
-				$this->AddPage();  
+				$this->AddPage();
 				$x = $_x;
-				$y = $_y;        
+				$y = $_y;
 			   }
 			   else {
 				$y += $h+$spacing ;
@@ -114,10 +114,10 @@ class mPDFI extends mPDF {
 		$this->current_parser =& $this->parsers[$fn];
 		return $this->parsers[$fn]->getPageCount();
 	}
-	
+
 	function ImportPage($pageno=1, $crop_x=null, $crop_y=null, $crop_w=0, $crop_h=0, $boxName='/CropBox') {
 		$fn =& $this->current_filename;
-		
+
 		$parser =& $this->parsers[$fn];
 		$parser->setPageno($pageno);
 
@@ -127,11 +127,11 @@ class mPDFI extends mPDF {
 		$tpl['parser'] =& $parser;
 		$tpl['resources'] = $parser->getPageResources();
 		$tpl['buffer'] = $parser->getContent();
-		
+
 		if (!in_array($boxName, $parser->availableBoxes))
 			return $this->Error(sprintf("Unknown box: %s", $boxName));
 		$pageboxes = $parser->getPageBoxes($pageno);
-		
+
 		/**
 		 * MediaBox
 		 * CropBox: Default -> MediaBox
@@ -143,10 +143,10 @@ class mPDFI extends mPDF {
 			$boxName = "/CropBox";
 		if (!isset($pageboxes[$boxName]) && $boxName == "/CropBox")
 			$boxName = "/MediaBox";
-		
+
 		if (!isset($pageboxes[$boxName]))
 			return false;
-		
+
 		$box = $pageboxes[$boxName];
 
 		$tpl['box'] = $box;
@@ -155,7 +155,7 @@ class mPDFI extends mPDF {
 		// An imported page will start at 0,0 everytime. Translation will be set in _putformxobjects()
 		$tpl['x'] = 0;
 		$tpl['y'] = 0;
-		
+
 		$tpl['w'] = $tpl['box']['w'] ;
 		$tpl['h'] = $tpl['box']['h'] ;
 		if ($crop_w) { $tpl['box']['w'] = $crop_w; }
@@ -164,7 +164,7 @@ class mPDFI extends mPDF {
 		if (isset($crop_y)) {$tpl['box']['y'] = $tpl['h'] - $crop_y  - $crop_h ; }
 
 		$page =& $parser->pages[$parser->pageno];
-		
+
 		// fix for rotated pages
 		$rotation = $parser->getPageRotation($pageno);
 
@@ -175,37 +175,37 @@ class mPDFI extends mPDF {
 			$_h = $tpl['h'];
 			$tpl['w'] = $steps % 2 == 0 ? $_w : $_h;
 			$tpl['h'] = $steps % 2 == 0 ? $_h : $_w;
-			
+
 			if ($steps % 2 != 0) {
 				$x = $y = ($steps == 1 || $steps == -3) ? $tpl['h'] : $tpl['w'];
 			} else {
 				$x = $tpl['w'];
 				$y = $tpl['h'];
 			}
-			
+
 			$cx=($x/2+$tpl['box']['x'])*$this->k;
 			$cy=($y/2+$tpl['box']['y'])*$this->k;
-			
-			$angle*=-1; 
-			
+
+			$angle*=-1;
+
 			$angle*=M_PI/180;
 			$c=cos($angle);
 			$s=sin($angle);
 			$tpl['box']['w'] = $tpl['w'] ;
 			$tpl['box']['h'] = $tpl['h'] ;
-			
+
 			$tpl['buffer'] = sprintf('q %.5f %.5f %.5f %.5f %.2f %.2f cm 1 0 0 1 %.2f %.2f cm %s Q',$c,$s,-$s,$c,$cx,$cy,-$cx,-$cy, $tpl['buffer']);
 		}
-		
+
 		return $this->tpl;
 	}
-	
+
 	function UseTemplate($tplidx, $_x=null, $_y=null, $_w=0, $_h=0) {
 		if (!isset($this->tpls[$tplidx]))
 			$this->Error("Template does not exist!");
 		if($this->state==0) { $this->AddPage(); }
 		$this->_out('q 0 J 1 w 0 j 0 G'); // reset standard values
-			
+
 		$x = $this->tpls[$tplidx]['x'];
 		$y = $this->tpls[$tplidx]['y'];
 		$w = $this->tpls[$tplidx]['w'];
@@ -219,15 +219,15 @@ class mPDFI extends mPDF {
 		$wh = $this->getTemplateSize($tplidx,$_w,$_h);
 		$_w = $wh['w'];
 		$_h = $wh['h'];
-	
-		$this->_out(sprintf("q %.4f 0 0 %.4f %.2f %.2f cm", ($_w/$this->tpls[$tplidx]['box']['w']), ($_h/$this->tpls[$tplidx]['box']['h']), $_x*$this->k, ($this->h-($_y+$_h))*$this->k)); 
+
+		$this->_out(sprintf("q %.4f 0 0 %.4f %.2f %.2f cm", ($_w/$this->tpls[$tplidx]['box']['w']), ($_h/$this->tpls[$tplidx]['box']['h']), $_x*$this->k, ($this->h-($_y+$_h))*$this->k));
 		$this->_out($this->tplprefix.$tplidx." Do Q");
 
 		$s = array("w" => $_w, "h" => $_h);
 		$this->_out('Q');
 		return $s;
 	}
-	
+
 	function SetPageTemplate($tplidx='') {
 		if (!isset($this->tpls[$tplidx])) {
 			$this->pageTemplate = '';
@@ -235,12 +235,12 @@ class mPDFI extends mPDF {
 		}
 		$this->pageTemplate = $tplidx;
 	}
-	
+
 	function SetDocTemplate($file='', $continue=0) {
 		$this->docTemplate = $file;
 		$this->docTemplateContinue = $continue;
 	}
-	
+
 
 //=========================================================================
 // Overwrite mPDF functions
@@ -281,7 +281,7 @@ function _putresources() {
 			$this->_out('/I'.$image['i'].' '.$image['n'].' 0 R');
 		foreach($this->formobjects as $formobject)
 			$this->_out('/FO'.$formobject['i'].' '.$formobject['n'].' 0 R');
-		// from FPDF_TPL function _putxobjectdict() 
+		// from FPDF_TPL function _putxobjectdict()
 	   	if (count($this->tpls)) {
 			foreach($this->tpls as $tplidx => $tpl) {
 				$this->_out($this->tplprefix.$tplidx.' '.$tpl['n'].' 0 R');
@@ -370,7 +370,7 @@ function _putstream($s) {
 						$this->_newobj($this->_obj_stack[$filename][$n][0]);
 						if ($nObj[0] == PDF_TYPE_STREAM) {
 							$this->pdf_write_value($nObj);
-						} 
+						}
 						else {
 							$this->pdf_write_value($nObj[1]);
 						}
@@ -383,7 +383,7 @@ function _putstream($s) {
 			}
 		}
 	}
-	
+
 
 
 	function _putformxobjects() {
@@ -396,7 +396,7 @@ function _putstream($s) {
 			$this->_out('<<'.$filter.'/Type /XObject');
 			$this->_out('/Subtype /Form');
 			$this->_out('/FormType 1');
-			
+
 			// Left/Bottom/Right/Top
 			$this->_out(sprintf('/BBox [%.2f %.2f %.2f %.2f]',
 				$tpl['box']['x']*$this->k,
@@ -408,7 +408,7 @@ function _putstream($s) {
 
 			if (isset($tpl['box']))
 				$this->_out(sprintf('/Matrix [1 0 0 1 %.5f %.5f]',-$tpl['box']['x']*$this->k, -$tpl['box']['y']*$this->k));
-			
+
 			$this->_out('/Resources ');
 
 			if (isset($tpl['resources'])) {
@@ -422,7 +422,7 @@ function _putstream($s) {
 							$this->_out('/F'.$font['i'].' '.$font['n'].' 0 R');
 						$this->_out('>>');
 				}
-					if(isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images']) || 
+					if(isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images']) ||
 					   isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls']))
 					{
 						$this->_out('/XObject <<');
@@ -449,14 +449,14 @@ function _putstream($s) {
 	function hex2str($hex) {
 		return pack("H*", str_replace(array("\r","\n"," "),"", $hex));
 	}
-    
+
 	function str2hex($str) {
 		return current(unpack("H*",$str));
 	}
 
 
-    
-    
+
+
 	function pdf_write_value(&$value) {
 		switch ($value[0]) {
 			case PDF_TYPE_NUMERIC :
@@ -504,7 +504,7 @@ function _putstream($s) {
 				if ($this->encrypted) {
 					$value[1] = $this->_RC4($this->_objectkey($this->_current_obj_id), $value[1]);
 					$value[1] = $this->_escape($value[1]);
-				} 
+				}
 				// A string.
 				$this->_out('('.$value[1].')');
 				break;
@@ -555,15 +555,15 @@ function _putstream($s) {
 	if ($this->isunicode && !$this->isCJK) {
 	  foreach($search AS $k=>$val) {
 		$search[$k] = $this->UTF8ToUTF16BE($search[$k] , false);
-		$search[$k] = $this->_escape($search[$k]); 
+		$search[$k] = $this->_escape($search[$k]);
 		$replacement[$k] = $this->UTF8ToUTF16BE($replacement[$k], false);
-		$replacement[$k] = $this->_escape($replacement[$k]); 
+		$replacement[$k] = $this->_escape($replacement[$k]);
 	  }
 	}
 	else {
 	  foreach($replacement AS $k=>$val) {
-		$replacement[$k] = mb_convert_encoding($replacement[$k],$this->mb_encoding,'utf-8'); 
-		$replacement[$k] = $this->_escape($replacement[$k]); 
+		$replacement[$k] = mb_convert_encoding($replacement[$k],$this->mb_encoding,'utf-8');
+		$replacement[$k] = $this->_escape($replacement[$k]);
 	  }
 	}
 
@@ -618,7 +618,7 @@ function _putstream($s) {
 	// Update xref in PDF
 	krsort($changes);
 	$newxref = "xref\n0 ".$xref_objid."\n";
-	foreach($xref AS $v) { 
+	foreach($xref AS $v) {
 		foreach($changes AS $ck => $cv) {
 			if ($v[0] > $ck) { $v[0] += $cv; }
 		}
@@ -696,10 +696,10 @@ function _strcspn($str1, $str2, $start=null, $length=null) {
 	$numargs = func_num_args();
 	if ($numargs == 2) {
 		return strcspn($str1, $str2);
-	} 
+	}
 	else if ($numargs == 3) {
 		return strcspn($str1, $str2, $start);
-	} 
+	}
 	else {
 		return strcspn($str1, $str2, $start, $length);
 	}

+ 33 - 11
main/inc/lib/mpdf/progress/out.php

@@ -3,7 +3,10 @@
 $tempfilename = $_REQUEST['filename'].'.pdf';
 $opname = $_REQUEST['opname'];
 $dest = $_REQUEST['dest'];
-	if ($tempfilename && file_exists('../tmp/'.$tempfilename)) {
+	// Modified by Ivan Tcholakov, 28-JAN-2010.
+	//if ($tempfilename && file_exists('../tmp/'.$tempfilename)) {
+	if ($tempfilename && file_exists(_MPDF_TMP_PATH.$tempfilename)) {
+	//
 		header("Pragma: ");
 		header("Cache-Control: private");
 		header("Content-transfer-encoding: binary\n");
@@ -19,35 +22,54 @@ $dest = $_REQUEST['dest'];
 					header('Status: 200 OK');
 					header('Pragma: anytextexeptno-cache', true);
 					header("Cache-Control: public, must-revalidate");
-				} 
+				}
 				else {
 					header('Cache-Control: public, must-revalidate');
 					header('Pragma: public');
 				}
 				header('Content-Type: application/force-download');
-			} 
+			}
 			else {
 				header('Content-Type: application/octet-stream');
 			}
 			header('Content-disposition: attachment; filename='.$opname);
 		}
-		$filesize = filesize('../tmp/'.$tempfilename);
+		// Modified by Ivan Tcholakov, 28-JAN-2010.
+		//$filesize = filesize('../tmp/'.$tempfilename);
+		$filesize = filesize(_MPDF_TMP_PATH.$tempfilename);
+		//
 		header("Content-length:".$filesize);
-		$fd=fopen('../tmp/'.$tempfilename,'r');
+		// Modified by Ivan Tcholakov, 28-JAN-2010.
+		//$fd=fopen('../tmp/'.$tempfilename,'r');
+		$fd=fopen(_MPDF_TMP_PATH.$tempfilename,'r');
+		//
 		fpassthru($fd);
 		fclose($fd);
-		unlink('../tmp/'.$tempfilename);
+		// Modified by Ivan Tcholakov, 28-JAN-2010.
+		//unlink('../tmp/'.$tempfilename);
+		unlink(_MPDF_TMP_PATH.$tempfilename);
+		//
 		// ====================== DELETE OLD FILES FIRST - Housekeeping =========================================
 		// Clear any files in directory that are >24 hrs old
 		$interval = 86400;
-		if ($handle = opendir('../tmp')) {
-		   while (false !== ($file = readdir($handle))) { 
-			if (((filemtime('../tmp/'.$file)+$interval) < time()) && ($file != "..") && ($file != ".")) { 
-				unlink('../tmp/'.$file); 
+		// Modified by Ivan Tcholakov, 28-JAN-2010.
+		//if ($handle = opendir('../tmp')) {
+		//   while (false !== ($file = readdir($handle))) {
+		//	if (((filemtime('../tmp/'.$file)+$interval) < time()) && ($file != "..") && ($file != ".")) {
+		//		unlink('../tmp/'.$file);
+		//	}
+		//   }
+		//   closedir($handle);
+		//}
+		if ($handle = opendir(_MPDF_TMP_PATH)) {
+		   while (false !== ($file = readdir($handle))) {
+			if (((filemtime(_MPDF_TMP_PATH.$file)+$interval) < time()) && ($file != "..") && ($file != ".")) {
+				unlink(_MPDF_TMP_PATH.$file);
 			}
 		   }
-		   closedir($handle); 
+		   closedir($handle);
 		}
+		//
 		exit;
 	}
 ?>

Kaikkia tiedostoja ei voida näyttää, sillä liian monta tiedostoa muuttui tässä diffissä