Exemple #1
0
 /**
  * HTML line renderer
  *
  * @param WT_Report_HTML $html
  *
  * @return void
  */
 function render($html)
 {
     if ($this->x1 == ".") {
         $this->x1 = $html->GetX();
     }
     if ($this->y1 == ".") {
         $this->y1 = $html->GetY();
     }
     if ($this->x2 == ".") {
         $this->x2 = $html->getRemainingWidth();
     }
     if ($this->y2 == ".") {
         $this->y2 = $html->GetY();
     }
     // TODO Non verticle or horizontal lines can use a series of divs absolutely positioned
     // Vertical line
     if ($this->x1 == $this->x2) {
         echo "<div style=\"position:absolute;overflow:hidden;border-", $html->alignRTL, ":solid black 1pt;", $html->alignRTL, ":", $this->x1, "pt;top:", $this->y1 + 1, "pt;width:1pt;height:", $this->y2 - $this->y1, "pt;\"> </div>\n";
     }
     // Horizontal line
     if ($this->y1 == $this->y2) {
         echo "<div style=\"position:absolute;overflow:hidden;border-top:solid black 1pt;", $html->alignRTL, ":", $this->x1, "pt;top:", $this->y1 + 1, "pt;width:", $this->x2 - $this->x1, "pt;height:1pt;\"> </div>\n";
     }
     // Keep max Y updated
     // One or the other will be higher... lasy mans way...
     $html->addMaxY($this->y1);
     $html->addMaxY($this->y2);
 }
Exemple #2
0
 /**
  * Get the width of text
  *
  * Breaks up a text into lines if needed
  *
  * @param WT_Report_HTML $html
  *
  * @return array
  */
 function getWidth($html)
 {
     // Setup the style name
     $html->setCurrentStyle("footnotenum");
     // Check for the largest font size in the box
     $fsize = $html->getCurrentStyleHeight();
     if ($fsize > $html->largestFontHeight) {
         $html->largestFontHeight = $fsize;
     }
     // Returns the Object if already numbered else false
     if (empty($this->num)) {
         $html->checkFootnote($this);
     }
     // Get the line width for the text in points + a little margin
     $lw = $html->GetStringWidth($this->numText);
     // Line Feed counter - Number of lines in the text
     $lfct = $html->countLines($this->numText);
     // If there is still remaining wrap width...
     if ($this->wrapWidthRemaining > 0) {
         // Check with line counter too!
         if ($lw >= $this->wrapWidthRemaining or $lfct > 1) {
             $newtext = "";
             $wrapWidthRemaining = $this->wrapWidthRemaining;
             $lines = explode("\n", $this->numText);
             // Go throught the text line by line
             foreach ($lines as $line) {
                 // Line width in points + a little margin
                 $lw = $html->GetStringWidth($line);
                 // If the line has to be wraped
                 if ($lw > $wrapWidthRemaining) {
                     $words = explode(" ", $line);
                     $addspace = count($words);
                     $lw = 0;
                     foreach ($words as $word) {
                         $addspace--;
                         $lw += $html->GetStringWidth($word . " ");
                         if ($lw <= $wrapWidthRemaining) {
                             $newtext .= $word;
                             if ($addspace != 0) {
                                 $newtext .= " ";
                             }
                         } else {
                             $lw = $html->GetStringWidth($word . " ");
                             $newtext .= "\n{$word}";
                             if ($addspace != 0) {
                                 $newtext .= " ";
                             }
                             // Reset the wrap width to the cell width
                             $wrapWidthRemaining = $this->wrapWidthCell;
                         }
                     }
                 } else {
                     $newtext .= $line;
                 }
                 // Check the Line Feed counter
                 if ($lfct > 1) {
                     // Add a new line feed as long as it’s not the last line
                     $newtext .= "\n";
                     // Reset the line width
                     $lw = 0;
                     // Reset the wrap width to the cell width
                     $wrapWidthRemaining = $this->wrapWidthCell;
                 }
                 $lfct--;
             }
             $this->numText = $newtext;
             $lfct = substr_count($this->numText, "\n");
             return array($lw, 1, $lfct);
         }
     }
     $l = 0;
     $lfct = substr_count($this->numText, "\n");
     if ($lfct > 0) {
         $l = 2;
     }
     return array($lw, $l, $lfct);
 }
Exemple #3
0
 /**
  * HTML Cell renderer
  *
  * @param WT_Report_HTML $html
  *
  * @return void
  */
 function render($html)
 {
     if (strpos($this->text, "{{:ptp:}}") !== false) {
         return;
     }
     $temptext = str_replace("#PAGENUM#", $html->PageNo(), $this->text);
     // underline «title» part of Source item
     $temptext = str_replace(array('«', '»'), array('<u>', '</u>'), $temptext);
     // Setup the style name
     if ($html->getCurrentStyle() != $this->styleName) {
         $html->setCurrentStyle($this->styleName);
     }
     // If (Future-feature-enable/disable cell padding)
     $cP = $html->cPadding;
     // Adjust the positions
     if ($this->left == ".") {
         $this->left = $html->GetX();
     } else {
         $html->SetX($this->left);
     }
     if ($this->top == ".") {
         $this->top = $html->GetY();
     } else {
         $html->SetY($this->top);
     }
     // Start collecting the HTML code
     echo "<div class=\"", $this->styleName, "\" style=\"position:absolute;top:", $this->top, "pt;";
     // Use Cell around padding to support RTL also
     echo "padding:", $cP, "pt;";
     // LTR (left) or RTL (right)
     echo $html->alignRTL, ":", $this->left, "pt;";
     // Background color
     if (!empty($this->bgcolor)) {
         echo "background-color:", $this->bgcolor, ";";
     }
     // Border setup
     $bpixX = 0;
     $bpixY = 0;
     if (!empty($this->border)) {
         // Border all around
         if ($this->border == 1) {
             echo " border:solid ";
             if (!empty($this->bocolor)) {
                 echo $this->bocolor;
             } else {
                 echo "black";
             }
             echo " 1pt;";
             $bpixX = 1;
             $bpixY = 1;
         } else {
             if (stripos($this->border, "T") !== false) {
                 echo " border-top:solid ";
                 if (!empty($this->bocolor)) {
                     echo $this->bocolor;
                 } else {
                     echo "black";
                 }
                 echo " 1pt;";
                 $bpixY = 1;
             }
             if (stripos($this->border, "B") !== false) {
                 echo " border-bottom:solid ";
                 if (!empty($this->bocolor)) {
                     echo $this->bocolor;
                 } else {
                     echo "black";
                 }
                 echo " 1pt;";
                 $bpixY = 1;
             }
             if (stripos($this->border, "R") !== false) {
                 echo " border-right:solid ";
                 if (!empty($this->bocolor)) {
                     echo $this->bocolor;
                 } else {
                     echo "black";
                 }
                 echo " 1pt;";
                 $bpixX = 1;
             }
             if (stripos($this->border, "L") !== false) {
                 echo " border-left:solid ";
                 if (!empty($this->bocolor)) {
                     echo $this->bocolor;
                 } else {
                     echo "black";
                 }
                 echo " 1pt;";
                 $bpixX = 1;
             }
         }
     }
     // Check the width if set to page wide OR set by xml to larger then page wide
     if ($this->width == 0 || $this->width > $html->getRemainingWidth()) {
         $this->width = $html->getRemainingWidth();
     }
     // We have to calculate a different width for the padding, counting on both side
     $cW = $this->width - $cP * 2;
     // If there is any text
     if (!empty($temptext)) {
         // Wrap the text
         $temptext = $html->textWrap($temptext, $cW);
         $tmph = $html->getTextCellHeight($temptext);
         // Add some cell padding
         $this->height += $cP;
         if ($tmph > $this->height) {
             $this->height = $tmph;
         }
     }
     // Check the last cell height and ajust with the current cell height
     if ($html->lastCellHeight > $this->height) {
         $this->height = $html->lastCellHeight;
     }
     echo " width:", $cW - $bpixX, "pt;height:", $this->height - $bpixY, "pt;";
     // Text alignment
     switch ($this->align) {
         case "C":
             echo " text-align:center;";
             break;
         case "L":
             echo " text-align:left;";
             break;
         case "R":
             echo " text-align:right;";
             break;
     }
     // Print the collected HTML code
     echo "\">";
     // Print URL
     if (!empty($this->url)) {
         echo "<a href=\"", $this->url, "\">";
     }
     // Print any text if exists
     if (!empty($temptext)) {
         $html->write($temptext, $this->tcolor, false);
     }
     if (!empty($this->url)) {
         echo "</a>";
     }
     // Finish the cell printing and start to clean up
     echo "</div>\n";
     // Where to place the next position
     // -> Next to this cell in the same line
     if ($this->newline == 0) {
         $html->SetXY($this->left + $this->width, $this->top);
         $html->lastCellHeight = $this->height;
     } elseif ($this->newline == 1) {
         $html->SetXY(0, $html->GetY() + $this->height + $cP * 2);
         // Reset the last cell height for the next line
         $html->lastCellHeight = 0;
     } elseif ($this->newline == 2) {
         $html->SetXY($html->GetX() + $this->width, $html->GetY() + $this->height + $cP * 2);
         // Reset the last cell height for the next line
         $html->lastCellHeight = 0;
     }
 }
Exemple #4
0
 /**
  * Image renderer
  *
  * @param WT_Report_HTML $html
  *
  * @return void
  */
 function render($html)
 {
     global $lastpicbottom, $lastpicpage, $lastpicleft, $lastpicright;
     // Get the current positions
     if ($this->x == ".") {
         $this->x = $html->GetX();
     }
     if ($this->y == ".") {
         //-- first check for a collision with the last picture
         if (isset($lastpicbottom)) {
             if ($html->PageNo() == $lastpicpage && $lastpicbottom >= $html->GetY() && $this->x >= $lastpicleft && $this->x <= $lastpicright) {
                 $html->SetY($lastpicbottom + $html->cPadding * 2);
             }
         }
         $this->y = $html->GetY();
     }
     // Image alignment
     switch ($this->align) {
         case "L":
             echo "<div style=\"position:absolute;top:", $this->y, "pt;left:0pt;width:", $html->getRemainingWidth(), "pt;text-align:left;\">\n";
             echo "<img src=\"", $this->file, "\" style=\"width:", $this->width, "pt;height:", $this->height, "pt;\" alt=\"\">\n</div>\n";
             break;
         case "C":
             echo "<div style=\"position:absolute;top:", $this->y, "pt;left:0pt;width:", $html->getRemainingWidth(), "pt;text-align:center;\">\n";
             echo "<img src=\"", $this->file, "\" style=\"width:", $this->width, "pt;height:", $this->height, "pt;\" alt=\"\">\n</div>\n";
             break;
         case "R":
             echo "<div style=\"position:absolute;top:", $this->y, "pt;left:0pt;width:", $html->getRemainingWidth(), "pt;text-align:right;\">\n";
             echo "<img src=\"", $this->file, "\" style=\"width:", $this->width, "pt;height:", $this->height, "pt;\" alt=\"\">\n</div>\n";
             break;
         default:
             echo "<img src=\"", $this->file, "\" style=\"position:absolute;", $html->alignRTL, ":", $this->x, "pt;top:", $this->y, "pt;width:", $this->width, "pt;height:", $this->height, "pt;\" alt=\"\">\n";
     }
     $lastpicpage = $html->PageNo();
     $lastpicleft = $this->x;
     $lastpicright = $this->x + $this->width;
     $lastpicbottom = $this->y + $this->height;
     // Setup for the next line
     if ($this->line == "N") {
         $html->SetY($lastpicbottom);
     }
     // Keep max Y updated
     $html->addMaxY($lastpicbottom);
 }