示例#1
0
 function generate_graph_image($outputfile)
 {
     // Create Graph Dataset and set axis attributes
     $graphData = new pData();
     $graphData->setYAxisName($this->ytitle);
     $graphData->AddPoint($this->xlabels, "xaxis");
     //$graphData->SetSerieName("xaxis","xaxis");
     $graphData->SetAbsciseLabelSerie("xaxis");
     $graphData->setXAxisName($this->xtitle);
     // Add each series of plot values to dataset, but Reportico will
     // duplicate series were the same data are displayed in different forms
     // so only add each unique series once
     $seriesadded = array();
     foreach ($this->plot as $k => $v) {
         $series = $v["name"] . $k;
         $graphData->AddPoint($v["data"], $series);
         $graphData->SetSerieName($v["legend"], $series);
         $graphData->AddSerie($series);
     }
     /*
     switch ( $this->xgriddisplay )
     {
     	case "all":
     		$graph->xgrid->Show(true,true);
     		break;
     	case "major":
     		$graph->xgrid->Show(true,false);
     		break;
     	case "minor":
     		$graph->xgrid->Show(false,true);
     		break;
     	case "none":
     	default:
     		$graph->xgrid->Show(false,false);
     		break;
     }
     
     switch ( $this->ygriddisplay )
     {
     	case "all":
     		$graph->ygrid->Show(true,true);
     		break;
     	case "major":
     		$graph->ygrid->Show(true,false);
     		break;
     	case "minor":
     		$graph->ygrid->Show(false,true);
     		break;
     	case "none":
     	default:
     		$graph->ygrid->Show(false,false);
     		break;
     }
     */
     /*
     $graph->xaxis->SetFont($fontfamilies[$xaxisfont],$fontstyles[$xaxisfontstyle], $xaxisfontsize);
     $graph->xaxis->SetColor($xaxiscolor,$xaxisfontcolor);
     $graph->yaxis->SetFont($fontfamilies[$yaxisfont],$fontstyles[$yaxisfontstyle], $yaxisfontsize);
     $graph->yaxis->SetColor($yaxiscolor,$yaxisfontcolor);
     $graph->xaxis->title->SetFont($fontfamilies[$xtitlefont],$fontstyles[$xtitlefontstyle], $xtitlefontsize);
     $graph->xaxis->title->SetColor($xtitlecolor);
     $graph->yaxis->title->SetFont($fontfamilies[$ytitlefont],$fontstyles[$ytitlefontstyle], $ytitlefontsize);
     $graph->yaxis->title->SetColor($ytitlecolor);
     $graph->xaxis->SetLabelAngle(90);
     $graph->xaxis->SetLabelMargin(15); 
     $graph->yaxis->SetLabelMargin(15); 
     $graph->xaxis->SetTickLabels($this->xlabels);
     $graph->xaxis->SetTextLabelInterval($xticklabint);
     $graph->yaxis->SetTextLabelInterval($yticklabint);
     $graph->xaxis->SetTextTickInterval($xtickinterval);
     $graph->yaxis->SetTextTickInterval($ytickinterval);
     */
     /*
     if ( $gridpos == "front" )
     	$graph->SetGridDepth(DEPTH_FRONT); 
     */
     // Display the graph
     /*?$graph->Stroke();*/
     $this->apply_defaults_internal();
     //echo $this->width_pdf_actual.",".$this->height_pdf_actual."<BR>";
     $graphImage = new pChart($this->width_pdf_actual, $this->height_pdf_actual);
     /* Turn of Antialiasing */
     $graphImage->Antialias = TRUE;
     // Add gradient fill from chosen background color to white
     $startgradient = htmltorgb("#ffffff");
     //$graphImage->drawGradientArea(0,0,$width,$height,DIRECTION_VERTICAL,array(
     //"StartR"=>$startgradient[0], "StartG"=>$startgradient[1], "StartB"=>$startgradient[2],
     //"EndR"=>$color[0], "EndG"=>$color[1], "EndB"=>$color[2],"Alpha"=>100));
     /* Add a border to the picture */
     //$graphImage->drawRectangle(0,0,$width - 1,$height - 1,200,200,200);
     $graphImage->setFontProperties(PCHARTFONTS_DIR . $this->xaxisfont, $this->xaxisfontsize);
     /* Define the chart area */
     $graphImage->setGraphArea($this->marginleft_actual, $this->margintop_actual, $this->width_pdf_actual - $this->marginright_actual, $this->height_pdf_actual - $this->marginbottom_actual);
     $graphImage->drawFilledRoundedRectangle(3, 3, $this->width_pdf_actual - 3, $this->height_pdf_actual - 3, 5, 240, 240, 240);
     $graphImage->drawRoundedRectangle(1, 1, $this->width_pdf_actual - 1, $this->height_pdf_actual - 1, 5, 230, 230, 230);
     // Before plotting a series ensure they are all not drawable.
     /// Plot the chart data
     $stackeddrawn = false;
     $linedrawn = false;
     $scatterdrawn = false;
     $piedrawn = false;
     $stackedexists = false;
     $overlayexists = false;
     $barexists = false;
     foreach ($this->plot as $k => $v) {
         if ($v["type"] == "OVERLAYBAR") {
             $overlayexists = true;
         }
         if ($v["type"] == "STACKEDBAR") {
             $stackedexists = true;
         }
         if ($v["type"] == "STACKEDBAR" || $v["type"] == "BAR") {
             $barexists = true;
         }
         // Set plot colors
         if ($v["linecolor"]) {
             $graphImage->Palette[$k] = htmltorgb_pchart($v["linecolor"]);
         }
         $url .= "&plotlinecolor{$k}=" . $v["linecolor"];
     }
     $scale_drawing_mode = SCALE_NORMAL;
     $scale_drawing_mode = SCALE_START0;
     // For stacked charts fix up the Max and Min values;
     if ($stackedexists) {
         $scale_drawing_mode = SCALE_ADDALL;
         $scaleMin = "Unknown";
         $scaleMax = 0;
         $min = false;
         $max = false;
         foreach ($plot as $k => $v) {
             if ($v["type"] == "BAR" || $v["type"] == "STACKEDBAR") {
                 $series = $v["name"] . $k;
                 minmaxValueOfSeries($v["data"], $min, $max);
                 if ($scaleMin == "Unknown" || $min < $scaleMin) {
                     $scaleMin = $min;
                 }
                 $scaleMax = $scaleMax + $max;
             }
         }
         if ($scaleMin > 0) {
             $scaleMin = 0;
         }
         $range = $scaleMax - $scaleMin;
         // Make scales based on 5% of the range of values
         $scaleMax = round($range * 0.05 + $scaleMax);
         if ($scaleMin < 0) {
             $scaleMin = $scaleMin - round($range * 0.05);
         }
         $AxisBoundaries = array(0 => array("Min" => $scaleMin, "Max" => $scaleMax));
     } else {
         if ($barexists || $overlayexists) {
             $scaleMin = "Unknown";
             $scaleMax = 0;
             $min = false;
             $max = false;
             foreach ($this->plot as $k => $v) {
                 if ($v["type"] == "BAR" || $v["type"] == "STACKEDBAR") {
                     $series = $v["name"] . $k;
                     minmaxValueOfSeries($v["data"], $min, $max);
                     if ($scaleMin == "Unknown" || $min < $scaleMin) {
                         $scaleMin = $min;
                     }
                     if ($scaleMax == "Unknown" || $max > $scaleMax) {
                         $scaleMax = $max;
                     }
                 }
             }
             if ($scaleMin > 0) {
                 $scaleMin = 0;
             }
             $range = $scaleMax - $scaleMin;
             // Make scales based on 5% of the range of values
             $scaleMax = round($range * 0.05 + $scaleMax);
             if ($scaleMin < 0) {
                 $scaleMin = $scaleMin - round($range * 0.05);
             }
             $AxisBoundaries = array(0 => array("Min" => $scaleMin, "Max" => $scaleMax));
         }
     }
     //echo "<PRE>";
     //var_dump($graphData->GetDataDescription());
     //die;
     // Find out if a scale is required, will be except for pie charts
     $scalerequired = false;
     foreach ($this->plot as $k => $v) {
         switch ($v["type"]) {
             case "BAR":
             case "STACKEDBAR":
             case "OVERLAYBAR":
             case "LINE":
                 $scalerequired = "NORMAL";
                 break;
             case "SCATTER":
                 $scalerequired = "SCATTER";
                 break;
         }
     }
     $graphImage->setFontProperties(PCHARTFONTS_DIR . $this->xtitlefont, $this->xtitlefontsize);
     if ($scalerequired) {
         $graphImage->setGraphArea($this->marginleft_actual, $this->margintop_actual, $this->width_pdf_actual - $this->marginright, $this->height_pdf_actual - $this->marginbottom_actual);
         $graphImage->drawGraphAreaGradient(240, 240, 240, -20);
         // Automatic generation of x tick interval based on number of ticks
         if ($this->xticklabelinterval_actual == "AUTO") {
             $labct = count($this->plot[0]["data"]);
             $this->xticklabelinterval_actual = floor($labct / 35) + 1;
         }
         if ($scalerequired == "NORMAL") {
             $graphImage->drawScale($graphData->GetData(), $graphData->GetDataDescription(), $scale_drawing_mode, 0, 0, 0, TRUE, 40, FALSE, TRUE, $this->xticklabelinterval_actual, FALSE);
         }
         $graphImage->drawGrid(2, TRUE, 230, 230, 230, 45);
     } else {
         $this->marginright = 5;
         $this->marginbottom = 5;
         $this->marginleft = 5;
         $this->marginright_actual = 5;
         $this->marginbottom_actual = 5;
         $this->marginleft_actual = 5;
         //$this->margintop_actual = 5;
         $graphImage->setGraphArea($this->marginleft, $this->margintop_actual, $this->width_pdf_actual - $this->marginright, $this->height_pdf_actual - $this->marginbottom);
         $graphImage->drawGraphAreaGradient(240, 240, 240, -10);
     }
     // If there's a Pie chart we want to draw different legends
     $piechart = false;
     foreach ($this->plot as $k => $v) {
         disableAllSeries($this->plot, $graphData);
         $series = $v["name"] . $k;
         setSerieDrawable($this->plot, $graphData, $series, TRUE);
         switch ($v["type"]) {
             case "PIE":
                 $piedrawn = true;
                 $piechart = true;
                 $graphImage->drawFilledCircle($this->width_pdf_actual / 2 + 2, $this->margintop_actual + 2 + ($this->height_pdf_actual - $this->margintop_actual - $this->marginbottom_actual) / 2, ($this->height_pdf_actual - $this->marginbottom_actual - $this->margintop_actual - 20) * 0.45 + 1, 200, 200, 200);
                 $graphImage->drawBasicPieGraph($graphData->GetData(), $graphData->GetDataDescription(), $this->width_pdf_actual / 2, $this->margintop_actual + ($this->height_pdf_actual - $this->margintop_actual - $this->marginbottom_actual) / 2, ($this->height_pdf_actual - $this->marginbottom_actual - $this->margintop_actual - 20) * 0.45, PIE_PERCENTAGE_LABEL, 255, 255, 218);
                 break;
             case "PIE3D":
                 $piedrawn = true;
                 $piechart = true;
                 $graphImage->drawPieGraph($graphData->GetData(), $graphData->GetDataDescription(), $this->width_pdf_actual / 2, $this->margintop_actual + ($this->height_pdf_actual - $this->margintop_actual - $this->marginbottom_actual) / 2, ($this->height_pdf_actual - $this->marginbottom_actual - $this->margintop_actual - 20) * 0.5, PIE_PERCENTAGE_LABEL, true, 60, 20, 0, 0);
                 break;
             case "OVERLAYBAR":
             case "STACKEDBAR":
             case "BAR":
                 if ($stackeddrawn) {
                     break;
                 }
                 if ($barexists || $overlayexists) {
                     foreach ($this->plot as $k1 => $v1) {
                         if ($v1["type"] == "BAR" || $v1["type"] == "STACKEDBAR" || $v1["type"] == "OVERLAYBAR") {
                             setSerieDrawable($this->plot, $graphData, $v1["name"] . $k1, TRUE);
                         }
                     }
                 }
                 $stackeddrawn = true;
                 if ($stackedexists) {
                     $graphImage->drawStackedBarGraph($graphData->GetData(), $graphData->GetDataDescription(), 90);
                 } else {
                     if ($overlayexists) {
                         $graphImage->drawOverlayBarGraph($graphData->GetData(), $graphData->GetDataDescription(), 90);
                     } else {
                         $graphImage->drawBarGraph($graphData->GetData(), $graphData->GetDataDescription());
                     }
                 }
                 break;
             case "SCATTER":
                 if ($scatterdrawn) {
                     break;
                 }
                 $scatterdrawn = true;
                 $series1 = false;
                 $series2 = false;
                 $graphImage->reportWarnings("GD");
                 $ct = 0;
                 foreach ($this->plot as $k1 => $v1) {
                     if ($v1["type"] == "SCATTER") {
                         if ($ct == 0) {
                             $series1 = $v1["name"] . $k1;
                         }
                         if ($ct == 1) {
                             $series2 = $v1["name"] . $k1;
                         }
                         $ct++;
                         setSerieDrawable($this->plot, $graphData, $v1["name"] . $k1, TRUE);
                     }
                 }
                 if (count($v["data"]) == 1) {
                     $v["data"][] = 0;
                 }
                 $graphImage->drawXYScale($graphData->GetData(), $graphData->GetDataDescription(), $series1, $series2, 0, 0, 0);
                 //$graphImage->drawXYGraph($graphData->GetData(), $graphData->GetDataDescription(), $series1, $series2);
                 $graphImage->drawXYPlotGraph($graphData->GetData(), $graphData->GetDataDescription(), $series1, $series2);
                 $graphImage->writeValues($graphData->GetData(), $graphData->GetDataDescription(), $series2);
                 break;
             case "LINE":
             default:
                 if ($linedrawn) {
                     break;
                 }
                 $linedrawn = true;
                 foreach ($this->plot as $k1 => $v1) {
                     if ($v1["type"] == "LINE") {
                         setSerieDrawable($this->plot, $graphData, $v1["name"] . $k1, TRUE);
                     }
                 }
                 if (count($v["data"]) == 1) {
                     $v["data"][] = 0;
                 }
                 $graphImage->LineWidth = 1;
                 $graphImage->drawLineGraph($graphData->GetData(), $graphData->GetDataDescription());
                 $graphImage->drawPlotGraph($graphData->GetData(), $graphData->GetDataDescription());
                 $graphImage->LineWidth = 1;
                 break;
         }
     }
     foreach ($this->plot as $k1 => $v1) {
         setSerieDrawable($this->plot, $graphData, $v1["name"] . $k1, TRUE);
     }
     // Draw Legend if legend value has been set
     $drawlegend = false;
     foreach ($this->plot as $k => $v) {
         if (isset($v["legend"]) && $v["legend"]) {
             // Temporarily Dont draw legend for Pie
             //if ( $piechart )
             //$graphImage->drawPieLegend($this->width_pdf_actual - 180,30,$graphData->GetData(), $graphData->GetDataDescription(), 250, 250, 250);
             if (!$piechart) {
                 $graphImage->drawLegend($this->width_pdf_actual - 120, 30, $graphData->GetDataDescription(), 254, 254, 254, 0, 0, 0);
             }
             break;
         }
     }
     $graphImage->setFontProperties(PCHARTFONTS_DIR . $this->xtitlefont, $this->titlefontsize);
     $graphImage->drawTitle(0, 24, $this->title_actual, 50, 50, 50, $this->width_pdf_actual);
     //$graphImage->setShadow(TRUE,array("X"=>0,"Y"=>0,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10));
     //$graphImage->Render("example.png");
     //$graphImage->Stroke();
     $graphImage->render($outputfile);
     return true;
 }
$graph->xaxis->SetTextLabelInterval($xticklabint);
$graph->yaxis->SetTextLabelInterval($yticklabint);
$graph->xaxis->SetTextTickInterval($xtickinterval);
$graph->yaxis->SetTextTickInterval($ytickinterval);
*/
/*
if ( $gridpos == "front" )
	$graph->SetGridDepth(DEPTH_FRONT); 
*/
// Display the graph
/*?$graph->Stroke();*/
$graphImage = new pChart($width, $height);
/* Turn of Antialiasing */
$graphImage->Antialias = TRUE;
// Add gradient fill from chosen background color to white
$startgradient = htmltorgb("#ffffff");
//$graphImage->drawGradientArea(0,0,$width,$height,DIRECTION_VERTICAL,array(
//"StartR"=>$startgradient[0], "StartG"=>$startgradient[1], "StartB"=>$startgradient[2],
//"EndR"=>$color[0], "EndG"=>$color[1], "EndB"=>$color[2],"Alpha"=>100));
/* Add a border to the picture */
//$graphImage->drawRectangle(0,0,$width - 1,$height - 1,200,200,200);
$graphImage->setFontProperties(PCHARTFONTS_DIR . $xaxisfont, $xaxisfontsize);
/* Define the chart area */
$graphImage->setGraphArea($marginleft, $margintop, $width - $marginright, $height - $marginbottom);
$graphImage->drawFilledRoundedRectangle(3, 3, $width - 3, $height - 3, 5, 240, 240, 240);
$graphImage->drawRoundedRectangle(1, 1, $width - 1, $height - 1, 5, 230, 230, 230);
// Before plotting a series ensure they are all not drawable.
/// Plot the chart data
$stackeddrawn = false;
$linedrawn = false;
$scatterdrawn = false;
示例#3
0
 function apply_style_tags($type, $styleset, $parent_styleset = false, $grandparent_styleset = false, $apply_type = false, $applyto = false)
 {
     $styleset["type"] = $type;
     for ($ct = 1; $ct < 4; $ct++) {
         $work_styleset = false;
         if ($ct == 1) {
             $work_styleset =& $grandparent_styleset;
         }
         if ($ct == 2) {
             $work_styleset =& $parent_styleset;
         }
         if ($ct == 3) {
             $work_styleset =& $styleset;
         }
         if (!$work_styleset) {
             continue;
         }
         if ($work_styleset && is_array($work_styleset)) {
             foreach ($work_styleset as $k => $v) {
                 // Dont apply anything except the applyto specified
                 if ($applyto && $ct == 3 && $applyto != $k) {
                     continue;
                 }
                 if (isset($this->stylestack[$k])) {
                     if ($k == "margin") {
                         $tmp = array(0 => 0, 1 => 0, 2 => 0, 3 => 0);
                         //$ar = explode ( ",", preg_replace("/[^0-9]+/", ",", $v));
                         $ar = explode(" ", $v);
                         if ($ar) {
                             if (count($ar) == 1 && $ar[0] > 0) {
                                 $tmp[0] = $tmp[1] = $tmp[2] = $tmp[3] = $ar[0];
                             } else {
                                 if (count($ar) == 2) {
                                     $tmp[0] = $tmp[2] = $ar[1];
                                     $tmp[1] = $tmp[3] = $ar[2];
                                 } else {
                                     if (count($ar) == 3) {
                                         $tmp[0] = $ar[0];
                                         $tmp[1] = $ar[1];
                                         $tmp[2] = $ar[2];
                                     } else {
                                         if (count($ar) == 4) {
                                             $tmp[0] = $ar[0];
                                             $tmp[1] = $ar[1];
                                             $tmp[2] = $ar[2];
                                             $tmp[3] = $ar[3];
                                         }
                                     }
                                 }
                             }
                         }
                         $v = $tmp;
                     }
                     if ($k == "padding") {
                         $tmp = array(0 => 0, 1 => 0, 2 => 0, 3 => 0);
                         //$ar = explode ( ",", preg_replace("/[^0-9]+/", ",", $v));
                         $ar = explode(" ", $v);
                         if ($ar) {
                             if (count($ar) == 1 && $ar[0] > 0) {
                                 $tmp[0] = $tmp[1] = $tmp[2] = $tmp[3] = $ar[0];
                             } else {
                                 if (count($ar) == 2) {
                                     $tmp[0] = $tmp[2] = $ar[1];
                                     $tmp[1] = $tmp[3] = $ar[2];
                                 } else {
                                     if (count($ar) == 3) {
                                         $tmp[0] = $ar[0];
                                         $tmp[1] = $ar[1];
                                         $tmp[2] = $ar[2];
                                     } else {
                                         if (count($ar) == 4) {
                                             $tmp[0] = $ar[0];
                                             $tmp[1] = $ar[1];
                                             $tmp[2] = $ar[2];
                                             $tmp[3] = $ar[3];
                                         }
                                     }
                                 }
                             }
                         }
                         $v = $tmp;
                     }
                     if ($k == "border-width") {
                         $tmp = "";
                         $v = preg_replace("/px/", "", trim($v));
                         //$ar = explode ( ",", preg_replace("/[^0-9]+/", ",", $v));
                         $ar = explode(" ", $v);
                         $borderwidth = 0;
                         if ($ar) {
                             foreach ($ar as $vv) {
                                 if (substr($vv, 0, 1) != "0") {
                                     $borderwidth = $vv;
                                     break;
                                 }
                             }
                             if (count($ar) == 1 && $ar[0] > 0) {
                                 $tmp = "LBTR";
                             } else {
                                 if (count($ar) == 2) {
                                     if ($ar[0] > 0) {
                                         $tmp .= "TB";
                                     }
                                     if ($ar[1] > 0) {
                                         $tmp .= "LR";
                                     }
                                 } else {
                                     if (count($ar) == 3) {
                                         if ($ar[0] > 0) {
                                             $tmp .= "T";
                                         }
                                         if ($ar[1] > 0) {
                                             $tmp .= "R";
                                         }
                                         if ($ar[2] > 0) {
                                             $tmp .= "B";
                                         }
                                     } else {
                                         if (count($ar) == 4) {
                                             if ($ar[0] > 0) {
                                                 $tmp .= "T";
                                             }
                                             if ($ar[1] > 0) {
                                                 $tmp .= "R";
                                             }
                                             if ($ar[2] > 0) {
                                                 $tmp .= "B";
                                             }
                                             if ($ar[3] > 0) {
                                                 $tmp .= "L";
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                         $borderedges = $tmp;
                         $v = $borderwidth;
                         if ($apply_type == "ROW") {
                             $this->row_styles["border-width"] = $borderwidth;
                             $this->row_styles["border-edges"] = $v;
                         }
                         if ($apply_type == "ALLCELLS") {
                             $this->allcell_styles["border-width"] = $borderwidth;
                             $this->allcell_styles["border-edges"] = $v;
                         }
                         if ($apply_type == "CELLS") {
                             $this->cell_styles["border-width"] = $borderwidth;
                             $this->cell_styles["border-edges"] = $v;
                         }
                         array_push($this->stylestack["border-edges"], $borderedges);
                     }
                     if ($k == "font-family") {
                         $this->document->SetFont($v);
                     }
                     if ($k == "font-size") {
                         $sz = preg_replace("/[^0-9].*/", "", $v);
                         $this->document->SetFontSize($sz);
                         $v = $sz + $this->vspace;
                         $this->vsize = $v;
                     }
                     if ($k == "font-style") {
                         $currWeight = end($this->stylestack["font-weight"]);
                         $currFamily = end($this->stylestack["font-family"]);
                         $pdfStyle = "";
                         switch ($currWeight) {
                             case "bold":
                                 $pdfStyle .= "B";
                                 break;
                             default:
                                 $pdfStyle .= "";
                         }
                         switch ($v) {
                             case "italic":
                                 $pdfStyle .= "I";
                                 break;
                             default:
                                 $pdfStyle .= "";
                         }
                         $this->document->SetFont($currFamily, $pdfStyle);
                         //$v = $sz + $this->vspace;
                         //$this->vsize = $v;
                     }
                     if ($k == "font-weight") {
                         $currStyle = end($this->stylestack["font-style"]);
                         $currFamily = end($this->stylestack["font-family"]);
                         $pdfStyle = "";
                         switch ($v) {
                             case "bold":
                                 $pdfStyle .= "B";
                                 break;
                             default:
                                 $pdfStyle .= "";
                         }
                         switch ($currStyle) {
                             case "italic":
                                 $pdfStyle .= "I";
                                 break;
                             default:
                                 $pdfStyle .= "";
                         }
                         $this->document->SetFont($currFamily, $pdfStyle);
                         //$v = $sz + $this->vspace;
                         //$this->vsize = $v;
                     }
                     if ($k == "border-color" || $k == "color" || $k == "background-color") {
                         $v = htmltorgb($v);
                         if ($k == "border-color") {
                             $this->document->SetDrawColor($v[0], $v[1], $v[2]);
                         }
                         if ($k == "color") {
                             $this->document->SetTextColor($v[0], $v[1], $v[2]);
                         }
                         if ($k == "background-color") {
                             $this->document->SetFillColor($v[0], $v[1], $v[2]);
                             array_push($this->stylestack["isfilling"], 1);
                         }
                     }
                     array_push($this->stylestack[$k], $v);
                 }
             }
         }
     }
     //echo "APPLY: $type ";
     //echo "&nbsp;&nbsp;APPLY: $type ";
     //var_dump($this->stylestack["type"]);
     //var_dump($this->stylestack["background-color"]);
 }
 function apply_style_tags($styleset, $parent_styleset = false, $grandparent_styleset = false, $apply_type = false)
 {
     for ($ct = 1; $ct < 4; $ct++) {
         $work_styleset = false;
         if ($ct == 1) {
             $work_styleset =& $grandparent_styleset;
         }
         if ($ct == 2) {
             $work_styleset =& $parent_styleset;
         }
         if ($ct == 3) {
             $work_styleset =& $styleset;
         }
         if (!$work_styleset) {
             continue;
         }
         if ($work_styleset && is_array($work_styleset)) {
             foreach ($work_styleset as $k => $v) {
                 if (isset($this->stylestack[$k])) {
                     if ($k == "padding") {
                         $tmp = array(0 => 0, 1 => 0, 2 => 0, 3 => 0);
                         $ar = explode(",", preg_replace("/[^0-9]+/", ",", $v));
                         if ($ar) {
                             if (count($ar) == 1 && $ar[0] > 0) {
                                 $tmp[0] = $tmp[1] = $tmp[2] = $tmp[3] = $ar[0];
                             } else {
                                 if (count($ar) == 2) {
                                     $tmp[0] = $tmp[2] = $ar[1];
                                     $tmp[1] = $tmp[3] = $ar[2];
                                 } else {
                                     if (count($ar) == 3) {
                                         $tmp[0] = $ar[0];
                                         $tmp[1] = $ar[1];
                                         $tmp[2] = $ar[2];
                                     } else {
                                         if (count($ar) == 4) {
                                             $tmp[0] = $ar[0];
                                             $tmp[1] = $ar[1];
                                             $tmp[2] = $ar[2];
                                             $tmp[3] = $ar[3];
                                         }
                                     }
                                 }
                             }
                         }
                         $v = $tmp;
                     }
                     if ($k == "border-width") {
                         $tmp = "";
                         $v = preg_replace("/px/", "", $v);
                         $ar = explode(",", preg_replace("/[^0-9]+/", ",", $v));
                         if ($ar) {
                             if (count($ar) == 1 && $ar[0] > 0) {
                                 $tmp = "LBTR";
                             } else {
                                 if (count($ar) == 2) {
                                     if ($ar[0] > 0) {
                                         $tmp .= "TB";
                                     }
                                     if ($ar[1] > 0) {
                                         $tmp .= "LR";
                                     }
                                 } else {
                                     if (count($ar) == 3) {
                                         if ($ar[0] > 0) {
                                             $tmp .= "T";
                                         }
                                         if ($ar[1] > 0) {
                                             $tmp .= "R";
                                         }
                                         if ($ar[2] > 0) {
                                             $tmp .= "B";
                                         }
                                     } else {
                                         if (count($ar) == 4) {
                                             if ($ar[0] > 0) {
                                                 $tmp .= "T";
                                             }
                                             if ($ar[1] > 0) {
                                                 $tmp .= "R";
                                             }
                                             if ($ar[2] > 0) {
                                                 $tmp .= "B";
                                             }
                                             if ($ar[3] > 0) {
                                                 $tmp .= "L";
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                         $v = $tmp;
                         if ($apply_type == "ROW") {
                             $this->row_styles["border-width"] = $v;
                         }
                         if ($apply_type == "ALLCELLS") {
                             $this->allcell_styles["border-width"] = $v;
                         }
                         if ($apply_type == "CELLS") {
                             $this->cell_styles["border-width"] = $v;
                         }
                     }
                     if ($k == "font-size") {
                         $sz = preg_replace("/[^0-9].*/", "", $v);
                         $this->document->SetFontSize($sz);
                         $v = $sz + $this->vspace;
                         $this->vsize = $v;
                     }
                     if ($k == "border-color" || $k == "color" || $k == "background-color") {
                         $v = htmltorgb($v);
                         if ($k == "border-color") {
                             $this->document->SetDrawColor($v[0], $v[1], $v[2]);
                         }
                         if ($k == "color") {
                             $this->document->SetTextColor($v[0], $v[1], $v[2]);
                         }
                         if ($k == "background-color") {
                             $this->document->SetFillColor($v[0], $v[1], $v[2]);
                             array_push($this->stylestack["isfilling"], 1);
                         }
                     }
                     array_push($this->stylestack[$k], $v);
                 }
             }
         }
     }
 }