%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/tjamichg/intranet.tjamich.gob.mx/intranet/sistemas/compras/
Upload File :
Create Path :
Current File : /home/tjamichg/intranet.tjamich.gob.mx/intranet/sistemas/compras/flowing_block.php

<?php
// FUNCIÓN SIN REQUIRE, CONVERTIR A STRING NÚMERO
function convertirdia($numero) {
$valor = array ('primero','segundo','tercero','cuarto', 'quinto','sexto','séptimo','octavo','noveno', 'décimo','undécimo','duodécimo','decimotercero', 'decimocuarto','decimoquinto ','decimosexto', 'decimoséptimo ','decimoctavo','decimonoveno', 'vigésimo', 'vigésimo primero','vigésimo segundo','vigésimo tercero','vigésimo cuarto', 'vigésimo quinto','vigésimo sexto','vigésimo séptimo','vigésimo octavo','vigésimo noveno', 'trigésimo', 'trigésimo primero');
return $valor[$numero - 1];
}

// FUNCIONES PARA BLOQUES FLOTANTES
// FUNCIONES PARA BLOQUES FLOTANTES
// FUNCIONES PARA BLOQUES FLOTANTES
// FUNCIONES PARA BLOQUES FLOTANTES
// FUNCIONES PARA BLOQUES FLOTANTES
// FUNCIONES PARA BLOQUES FLOTANTES
require 'fpdf/fpdf.php';

class PDF_FlowingBlock extends FPDF
{
	//FFFUNCIONES DE CELDA FLOTANTE
	//FFFUNCIONES DE CELDA FLOTANTE
	//FFFUNCIONES DE CELDA FLOTANTE
	//FFFUNCIONES DE CELDA FLOTANTE
	//FFFUNCIONES DE CELDA FLOTANTE
	// NOTA: SOLO PUEDEN ESTAR COLOCADAS A LA IZQUIERDA
	var $flowingBlockAttr;
	var $widths;
    var $aligns;
    var $resg;
    function Header()
 
{
   
 
//$this->Image('../views/membretadaI.png',0,0,-300);
    
 
}



    
    function SetWidths($w)
{
//Set the array of column widths
$this->widths=$w;
}

function SetAligns($a)
{
//Set the array of column alignments
$this->aligns=$a;
}

function Row($data)
{
//Calculate the height of the row
$nb=0;
for($i=0;$i<count($data);$i++)
$nb=max($nb,$this->NbLines($this->widths[$i],$data[$i]));
$h=5*$nb;
//Issue a page break first if needed
$this->CheckPageBreak($h);
//Draw the cells of the row
for($i=0;$i<count($data);$i++)
{
$w=$this->widths[$i];
$a=isset($this->aligns[$i]) ? $this->aligns[$i] : 'L';
//Save the current position
$x=$this->GetX();
$y=$this->GetY();
//Draw the border
$this->Rect($x,$y,$w,$h);
//Print the text
$this->MultiCell($w,5,$data[$i],0,$a);
//Put the position to the right of the cell
$this->SetXY($x+$w,$y);
}
//Go to the next line
$this->Ln($h);
}

function CheckPageBreak($h)
{
//If the height h would cause an overflow, add a new page immediately
if($this->GetY()+$h>$this->PageBreakTrigger)
$this->AddPage($this->CurOrientation);
}

function NbLines($w,$txt)
{
//Computes the number of lines a MultiCell of width w will take
$cw=&$this->CurrentFont['cw'];
if($w==0)
$w=$this->w-$this->rMargin-$this->x;
$wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
$s=str_replace("\r",'',$txt);
$nb=strlen($s);
if($nb>0 and $s[$nb-1]=="\n")
$nb--;
$sep=-1;
$i=0;
$j=0;
$l=0;
$nl=1;
while($i<$nb)
{
$c=$s[$i];
if($c=="\n")
{
$i++;
$sep=-1;
$j=$i;
$l=0;
$nl++;
continue;
}
if($c==' ')
$sep=$i;
$l+=$cw[$c];
if($l>$wmax)
{
if($sep==-1)
{
if($i==$j)
$i++;
}
else
$i=$sep+1;
$sep=-1;
$j=$i;
$l=0;
$nl++;
}
else
$i++;
}
return $nl;
}
    
    
    
    
    
    ////////////////////////////////////////////////////////////////
	function saveFont()
	{
		$saved = array();
		$saved[ 'family' ] = $this->FontFamily;
		$saved[ 'style' ] = $this->FontStyle;
		$saved[ 'sizePt' ] = $this->FontSizePt;
		$saved[ 'size' ] = $this->FontSize;
		$saved[ 'curr' ] =& $this->CurrentFont;
		return $saved;
	}

	function restoreFont( $saved )
	{
		$this->FontFamily = $saved[ 'family' ];
		$this->FontStyle = $saved[ 'style' ];
		$this->FontSizePt = $saved[ 'sizePt' ];
		$this->FontSize = $saved[ 'size' ];
		$this->CurrentFont =& $saved[ 'curr' ];
		if( $this->page > 0)
			$this->_out( sprintf( 'BT /F%d %.2F Tf ET', $this->CurrentFont[ 'i' ], $this->FontSizePt ) );
	}

	function newFlowingBlock( $w, $h, $b = 0, $a = 'J', $f = 0 )
	{
		// cell width in points
		$this->flowingBlockAttr[ 'width' ] = $w * $this->k;
		// line height in user units
		$this->flowingBlockAttr[ 'height' ] = $h;
		$this->flowingBlockAttr[ 'lineCount' ] = 0;
		$this->flowingBlockAttr[ 'border' ] = $b;
		$this->flowingBlockAttr[ 'align' ] = $a;
		$this->flowingBlockAttr[ 'fill' ] = $f;
		$this->flowingBlockAttr[ 'font' ] = array();
		$this->flowingBlockAttr[ 'content' ] = array();
		$this->flowingBlockAttr[ 'contentWidth' ] = 0;
	}

	function finishFlowingBlock()
	{
		$maxWidth =& $this->flowingBlockAttr[ 'width' ];
		$lineHeight =& $this->flowingBlockAttr[ 'height' ];
		$border =& $this->flowingBlockAttr[ 'border' ];
		$align =& $this->flowingBlockAttr[ 'align' ];
		$fill =& $this->flowingBlockAttr[ 'fill' ];
		$content =& $this->flowingBlockAttr[ 'content' ];
		$font =& $this->flowingBlockAttr[ 'font' ];
		// set normal spacing
		$this->_out( sprintf( '%.3F Tw', 0 ) );
		// print out each chunk
		// the amount of space taken up so far in user units
		$usedWidth = 0;

		foreach ( $content as $k => $chunk )
		{
			$b = '';
			if ( is_int( strpos( $border, 'B' ) ) )
				$b .= 'B';
			if ( $k == 0 && is_int( strpos( $border, 'L' ) ) )
				$b .= 'L';
			if ( $k == count( $content ) - 1 && is_int( strpos( $border, 'R' ) ) )
				$b .= 'R';
			$this->restoreFont( $font[ $k ] );

			// if it's the last chunk of this line, move to the next line after
			if ( $k == count( $content ) - 1 )
				$this->Cell( ( $maxWidth / $this->k ) - $usedWidth + 2 * $this->cMargin, $lineHeight, $chunk, $b, 1, $align, $fill );
			else
				$this->Cell( $this->GetStringWidth( $chunk ), $lineHeight, $chunk, $b, 0, $align, $fill );
			$usedWidth += $this->GetStringWidth( $chunk );
		}
	}

	function WriteFlowingBlock( $s )
	{
		// width of all the content so far in points
		$contentWidth =& $this->flowingBlockAttr[ 'contentWidth' ];
		// cell width in points
		$maxWidth =& $this->flowingBlockAttr[ 'width' ];
		$lineCount =& $this->flowingBlockAttr[ 'lineCount' ];
		// line height in user units
		$lineHeight =& $this->flowingBlockAttr[ 'height' ];
		$border =& $this->flowingBlockAttr[ 'border' ];
		$align =& $this->flowingBlockAttr[ 'align' ];
		$fill =& $this->flowingBlockAttr[ 'fill' ];
		$content =& $this->flowingBlockAttr[ 'content' ];
		$font =& $this->flowingBlockAttr[ 'font' ];
		$font[] = $this->saveFont();
		$content[] = '';
		$currContent =& $content[ count( $content ) - 1 ];
		// where the line should be cutoff if it is to be justified
		$cutoffWidth = $contentWidth;
		// for every character in the string
		for ( $i = 0; $i < strlen( $s ); $i++ )
		{
			// extract the current character
			$c = $s[ $i ];
			// get the width of the character in points
			$cw = $this->CurrentFont[ 'cw' ][ $c ] * ( $this->FontSizePt / 1000 );
			if ( $c == ' ' )
			{
				$currContent .= ' ';
				$cutoffWidth = $contentWidth;
				$contentWidth += $cw;
				continue;
			}
			// try adding another char
			if ( $contentWidth + $cw > $maxWidth )
			{
				// won't fit, output what we have
				$lineCount++;
				// contains any content that didn't make it into this print
				$savedContent = '';
				$savedFont = array();
				// first, cut off and save any partial words at the end of the string
				$words = explode( ' ', $currContent );
				// if it looks like we didn't finish any words for this chunk
				if ( count( $words ) == 1 )
				{
					// save and crop off the content currently on the stack
					$savedContent = array_pop( $content );
					$savedFont = array_pop( $font );
					// trim any trailing spaces off the last bit of content
					$currContent =& $content[ count( $content ) - 1 ];
					$currContent = rtrim( $currContent );
				}
				// otherwise, we need to find which bit to cut off
				else
				{
					$lastContent = '';
					for ( $w = 0; $w < count( $words ) - 1; $w++)
						$lastContent .= "{$words[ $w ]} ";
					$savedContent = $words[ count( $words ) - 1 ];
					$savedFont = $this->saveFont();
					// replace the current content with the cropped version
					$currContent = rtrim( $lastContent );
				}
				// update $contentWidth and $cutoffWidth since they changed with cropping
				$contentWidth = 0;
				foreach ( $content as $k => $chunk )
				{
					$this->restoreFont( $font[ $k ] );
					$contentWidth += $this->GetStringWidth( $chunk ) * $this->k;
				}
				$cutoffWidth = $contentWidth;
				// if it's justified, we need to find the char spacing
				if( $align == 'J' )
				{
					// count how many spaces there are in the entire content string
					$numSpaces = 0;
					foreach ( $content as $chunk )
						$numSpaces += substr_count( $chunk, ' ' );
					// if there's more than one space, find word spacing in points
					if ( $numSpaces > 0 )
						$this->ws = ( $maxWidth - $cutoffWidth ) / $numSpaces;
					else
						$this->ws = 0;
					$this->_out( sprintf( '%.3F Tw', $this->ws ) );
				}
				// otherwise, we want normal spacing
				else
					$this->_out( sprintf( '%.3F Tw', 0 ) );
				// print out each chunk
				$usedWidth = 0;
				foreach ( $content as $k => $chunk )
				{
					$this->restoreFont( $font[ $k ] );
					$stringWidth = $this->GetStringWidth( $chunk ) + ( $this->ws * substr_count( $chunk, ' ' ) / $this->k );
					// determine which borders should be used
					$b = '';
					if ( $lineCount == 1 && is_int( strpos( $border, 'T' ) ) )
						$b .= 'T';
					if ( $k == 0 && is_int( strpos( $border, 'L' ) ) )
						$b .= 'L';
					if ( $k == count( $content ) - 1 && is_int( strpos( $border, 'R' ) ) )
						$b .= 'R';
					// if it's the last chunk of this line, move to the next line after
					if ( $k == count( $content ) - 1 )
						$this->Cell( ( $maxWidth / $this->k ) - $usedWidth + 2 * $this->cMargin, $lineHeight, $chunk, $b, 1, $align, $fill );
					else
					{
						$this->Cell( $stringWidth + 2 * $this->cMargin, $lineHeight, $chunk, $b, 0, $align, $fill );
						$this->x -= 2 * $this->cMargin;
					}
					$usedWidth += $stringWidth;
				}
				// move on to the next line, reset variables, tack on saved content and current char
				$this->restoreFont( $savedFont );
				$font = array( $savedFont );
				$content = array( $savedContent . $s[ $i ] );
				$currContent =& $content[ 0 ];
				$contentWidth = $this->GetStringWidth( $currContent ) * $this->k;
				$cutoffWidth = $contentWidth;
			}
			// another character will fit, so add it on
			else
			{
				$contentWidth += $cw;
				$currContent .= $s[ $i ];
			}
		}
	}

	//FFFUNCIONES DE WRITE-HTML
	//FFFUNCIONES DE WRITE-HTML
	//FFFUNCIONES DE WRITE-HTML
	//FFFUNCIONES DE WRITE-HTML
	//FFFUNCIONES DE WRITE-HTML
	var $B=0;
    var $I=0;
    var $U=0;
    var $HREF='';
    var $ALIGN='';

    // Esta WirteHTML hasta justo antes de Justify permite cargar texto en html para cargar estilos de texto y otras funciones
    function WriteHTML($html)
    {
        //HTML parser
        $html=str_replace("\n",' ',$html);
        $a=preg_split('/<(.*)>/U',$html,-1,PREG_SPLIT_DELIM_CAPTURE);
        foreach($a as $i=>$e)
        {
            if($i%2==0)
            {
                //Text
                if($this->HREF)
                    $this->PutLink($this->HREF,$e);
                elseif($this->ALIGN=='center')
                    $this->Cell(0,5,$e,0,1,'C');
                else
                    $this->Write(5,$e);
            }
            else
            {
                //Tag
                if($e[0]=='/')
                    $this->CloseTag(strtoupper(substr($e,1)));
                else
                {
                    //Extract properties
                    $a2=explode(' ',$e);
                    $tag=strtoupper(array_shift($a2));
                    $prop=array();
                    foreach($a2 as $v)
                    {
                        if(preg_match('/([^=]*)=["\']?([^"\']*)/',$v,$a3))
                            $prop[strtoupper($a3[1])]=$a3[2];
                    }
                    $this->OpenTag($tag,$prop);
                }
            }
        }
    }

    function OpenTag($tag,$prop)
    {
        //Opening tag
        if($tag=='B' || $tag=='I' || $tag=='U')
            $this->SetStyle($tag,true);
        if($tag=='A')
            $this->HREF=$prop['HREF'];
        if($tag=='BR')
            $this->Ln(5);
        if($tag=='P')
            $this->ALIGN=$prop['ALIGN'];
        if($tag=='HR')
        {
            if( !empty($prop['WIDTH']) )
                $Width = $prop['WIDTH'];
            else
                $Width = $this->w - $this->lMargin-$this->rMargin;
            $this->Ln(2);
            $x = $this->GetX();
            $y = $this->GetY();
            $this->SetLineWidth(0.4);
            $this->Line($x,$y,$x+$Width,$y);
            $this->SetLineWidth(0.2);
            $this->Ln(2);
        }
    }

    function CloseTag($tag)
    {
        //Closing tag
        if($tag=='B' || $tag=='I' || $tag=='U')
            $this->SetStyle($tag,false);
        if($tag=='A')
            $this->HREF='';
        if($tag=='P')
            $this->ALIGN='';
    }

    function SetStyle($tag,$enable)
    {
        //Modify style and select corresponding font
        $this->$tag+=($enable ? 1 : -1);
        $style='';
        foreach(array('B','I','U') as $s)
            if($this->$s>0)
                $style.=$s;
        $this->SetFont('',$style);
    }

    function PutLink($URL,$txt)
    {
        //Put a hyperlink
        $this->SetTextColor(0,0,255);
        $this->SetStyle('U',true);
        $this->Write(5,$txt,$URL);
        $this->SetStyle('U',false);
        $this->SetTextColor(0);
    }

    //FFFUNCIÓN JUSTIFY SOLO SIN FORMATO HMTL NI ESTILOS
    //FFFUNCIÓN JUSTIFY SOLO SIN FORMATO HMTL NI ESTILOS
    //FFFUNCIÓN JUSTIFY SOLO SIN FORMATO HMTL NI ESTILOS
    //FFFUNCIÓN JUSTIFY SOLO SIN FORMATO HMTL NI ESTILOS
    //FFFUNCIÓN JUSTIFY SOLO SIN FORMATO HMTL NI ESTILOS
    function Justify($text, $w, $h)
    {
    $tab_paragraphe = explode("\n", $text);
    $nb_paragraphe = count($tab_paragraphe);
    $j = 0;

    while ($j<$nb_paragraphe) {

        $paragraphe = $tab_paragraphe[$j];
        $tab_mot = explode(' ', $paragraphe);
        $nb_mot = count($tab_mot);

        // Handle strings longer than paragraph width
        $k=0;
        $l=0;
        while ($k<$nb_mot) {

            $len_mot = strlen ($tab_mot[$k]);
            if ($len_mot<($w-5) )
            {
                $tab_mot2[$l] = $tab_mot[$k];
                $l++;    
            } else {
                $m=0;
                $chaine_lettre='';
                while ($m<$len_mot) {

                    $lettre = substr($tab_mot[$k], $m, 1);
                    $len_chaine_lettre = $this->GetStringWidth($chaine_lettre.$lettre);

                    if ($len_chaine_lettre>($w-7)) {
                        $tab_mot2[$l] = $chaine_lettre . '-';
                        $chaine_lettre = $lettre;
                        $l++;
                    } else {
                        $chaine_lettre .= $lettre;
                    }
                    $m++;
                }
                if ($chaine_lettre) {
                    $tab_mot2[$l] = $chaine_lettre;
                    $l++;
                }

            }
            $k++;
        }

        // Justified lines
        $nb_mot = count($tab_mot2);
        $i=0;
        $ligne = '';
        while ($i<$nb_mot) {

            $mot = $tab_mot2[$i];
            $len_ligne = $this->GetStringWidth($ligne . ' ' . $mot);

            if ($len_ligne>($w-5)) {

                $len_ligne = $this->GetStringWidth($ligne);
                $nb_carac = strlen ($ligne);
                $ecart = (($w-2) - $len_ligne) / $nb_carac;
                $this->_out(sprintf('BT %.3F Tc ET',$ecart*$this->k));
                $this->MultiCell($w,$h,$ligne);
                $ligne = $mot;

            } else {

                if ($ligne)
                {
                    $ligne .= ' ' . $mot;
                } else {
                    $ligne = $mot;
                }

            }
            $i++;
        }

        // Last line
        $this->_out('BT 0 Tc ET');
        $this->MultiCell($w,$h,$ligne);
        $tab_mot = '';
        $tab_mot2 = '';
        $j++;
    }
    }

    //FUNCION CELL FORZAR JUSTIFICACIÓN
    //FUNCION CELL FORZAR JUSTIFICACIÓN
    //FUNCION CELL FORZAR JUSTIFICACIÓN
    //FUNCION CELL FORZAR JUSTIFICACIÓN
    //FUNCION CELL FORZAR JUSTIFICACIÓN
    function Cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='')
    {
    $k=$this->k;
    if($this->y+$h>$this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak())
    {
        $x=$this->x;
        $ws=$this->ws;
        if($ws>0)
        {
            $this->ws=0;
            $this->_out('0 Tw');
        }
        $this->AddPage($this->CurOrientation);
        $this->x=$x;
        if($ws>0)
        {
            $this->ws=$ws;
            $this->_out(sprintf('%.3F Tw', $ws*$k));
        }
    }
    if($w==0)
        $w=$this->w-$this->rMargin-$this->x;
    $s='';
    if($fill || $border==1)
    {
        if($fill)
            $op=($border==1) ? 'B' : 'f';
        else
            $op='S';
        $s=sprintf('%.2F %.2F %.2F %.2F re %s ', $this->x*$k, ($this->h-$this->y)*$k, $w*$k, -$h*$k, $op);
    }
    if(is_string($border))
    {
        $x=$this->x;
        $y=$this->y;
        if(is_int(strpos($border, 'L')))
            $s.=sprintf('%.2F %.2F m %.2F %.2F l S ', $x*$k, ($this->h-$y)*$k, $x*$k, ($this->h-($y+$h))*$k);
        if(is_int(strpos($border, 'T')))
            $s.=sprintf('%.2F %.2F m %.2F %.2F l S ', $x*$k, ($this->h-$y)*$k, ($x+$w)*$k, ($this->h-$y)*$k);
        if(is_int(strpos($border, 'R')))
            $s.=sprintf('%.2F %.2F m %.2F %.2F l S ', ($x+$w)*$k, ($this->h-$y)*$k, ($x+$w)*$k, ($this->h-($y+$h))*$k);
        if(is_int(strpos($border, 'B')))
            $s.=sprintf('%.2F %.2F m %.2F %.2F l S ', $x*$k, ($this->h-($y+$h))*$k, ($x+$w)*$k, ($this->h-($y+$h))*$k);
    }
    if($txt!='')
    {
        if($align=='R')
            $dx=$w-$this->cMargin-$this->GetStringWidth($txt);
        elseif($align=='C')
            $dx=($w-$this->GetStringWidth($txt))/2;
        elseif($align=='FJ')
        {
            //Set word spacing
            $wmax=($w-2*$this->cMargin);
            $this->ws=($wmax-$this->GetStringWidth($txt))/substr_count($txt, ' ');
            $this->_out(sprintf('%.3F Tw', $this->ws*$this->k));
            $dx=$this->cMargin;
        }
        else
            $dx=$this->cMargin;
        $txt=str_replace(')', '\\)', str_replace('(', '\\(', str_replace('\\', '\\\\', $txt)));
        if($this->ColorFlag)
            $s.='q '.$this->TextColor.' ';
        $s.=sprintf('BT %.2F %.2F Td (%s) Tj ET', ($this->x+$dx)*$k, ($this->h-($this->y+.5*$h+.3*$this->FontSize))*$k, $txt);
        if($this->underline)
            $s.=' '.$this->_dounderline($this->x+$dx, $this->y+.5*$h+.3*$this->FontSize, $txt);
        if($this->ColorFlag)
            $s.=' Q';
        if($link)
        {
            if($align=='FJ')
                $wlink=$wmax;
            else
                $wlink=$this->GetStringWidth($txt);
            $this->Link($this->x+$dx, $this->y+.5*$h-.5*$this->FontSize, $wlink, $this->FontSize, $link);
        }
    }
    if($s)
        $this->_out($s);
    if($align=='FJ')
    {
        //Remove word spacing
        $this->_out('0 Tw');
        $this->ws=0;
    }
    $this->lasth=$h;
    if($ln>0)
    {
        $this->y+=$h;
        if($ln==1)
            $this->x=$this->lMargin;
    }
    else
        $this->x+=$w;
    }
}

// EXPANSIÓN PARA WRITE HTML
// EXPANSIÓN PARA WRITE HTML
// EXPANSIÓN PARA WRITE HTML
// EXPANSIÓN PARA WRITE HTML
// EXPANSIÓN PARA WRITE HTML
// function hex2dec($couleur = "#000000"){
//     $R = substr($couleur, 1, 2);
//     $rouge = hexdec($R);
//     $V = substr($couleur, 3, 2);
//     $vert = hexdec($V);
//     $B = substr($couleur, 5, 2);
//     $bleu = hexdec($B);
//     $tbl_couleur = array();
//     $tbl_couleur['R']=$rouge;
//     $tbl_couleur['G']=$vert;
//     $tbl_couleur['B']=$bleu;
//     return $tbl_couleur;
// }

// //conversion pixel -> millimeter in 72 dpi
// function px2mm($px){
//     return $px*25.4/72;
// }

// function txtentities($html){
//     $trans = get_html_translation_table(HTML_ENTITIES);
//     $trans = array_flip($trans);
//     return strtr($html, $trans);
// }
// ////////////////////////////////////

// class PDF extends FPDF
// {
// //variables of html parser
// protected $B;
// protected $I;
// protected $U;
// protected $HREF;
// protected $fontList;
// protected $issetfont;
// protected $issetcolor;

// function __construct($orientation='P', $unit='mm', $format='A4')
// {
//     //Call parent constructor
//     parent::__construct($orientation,$unit,$format);

//     //Initialization
//     $this->B=0;
//     $this->I=0;
//     $this->U=0;
//     $this->HREF='';

//     $this->tableborder=0;
//     $this->tdbegin=false;
//     $this->tdwidth=0;
//     $this->tdheight=0;
//     $this->tdalign="L";
//     $this->tdbgcolor=false;

//     $this->oldx=0;
//     $this->oldy=0;

//     $this->fontlist=array("arial","times","courier","helvetica","symbol");
//     $this->issetfont=false;
//     $this->issetcolor=false;
// }

// //////////////////////////////////////
// //html parser

// function WriteHTML($html)
// {
//     $html=strip_tags($html,"<b><u><i><a><img><p><br><strong><em><font><tr><blockquote><hr><td><tr><table><sup>"); //remove all unsupported tags
//     $html=str_replace("\n",'',$html); //replace carriage returns with spaces
//     $html=str_replace("\t",'',$html); //replace carriage returns with spaces
//     $a=preg_split('/<(.*)>/U',$html,-1,PREG_SPLIT_DELIM_CAPTURE); //explode the string
//     foreach($a as $i=>$e)
//     {
//         if($i%2==0)
//         {
//             //Text
//             if($this->HREF)
//                 $this->PutLink($this->HREF,$e);
//             elseif($this->tdbegin) {
//                 if(trim($e)!='' && $e!="&nbsp;") {
//                     $this->Cell($this->tdwidth,$this->tdheight,$e,$this->tableborder,'',$this->tdalign,$this->tdbgcolor);
//                 }
//                 elseif($e=="&nbsp;") {
//                     $this->Cell($this->tdwidth,$this->tdheight,'',$this->tableborder,'',$this->tdalign,$this->tdbgcolor);
//                 }
//             }
//             else
//                 $this->Write(5,stripslashes(txtentities($e)));
//         }
//         else
//         {
//             //Tag
//             if($e[0]=='/')
//                 $this->CloseTag(strtoupper(substr($e,1)));
//             else
//             {
//                 //Extract attributes
//                 $a2=explode(' ',$e);
//                 $tag=strtoupper(array_shift($a2));
//                 $attr=array();
//                 foreach($a2 as $v)
//                 {
//                     if(preg_match('/([^=]*)=["\']?([^"\']*)/',$v,$a3))
//                         $attr[strtoupper($a3[1])]=$a3[2];
//                 }
//                 $this->OpenTag($tag,$attr);
//             }
//         }
//     }
// }

// function OpenTag($tag, $attr)
// {
//     //Opening tag
//     switch($tag){

//         case 'SUP':
//             if( !empty($attr['SUP']) ) {    
//                 //Set current font to 6pt   
//                 $this->SetFont('','',6);
//                 //Start 125cm plus width of cell to the right of left margin        
//                 //Superscript "1" 
//                 $this->Cell(2,2,$attr['SUP'],0,0,'L');
//             }
//             break;

//         case 'TABLE': // TABLE-BEGIN
//             if( !empty($attr['BORDER']) ) $this->tableborder=$attr['BORDER'];
//             else $this->tableborder=0;
//             break;
//         case 'TR': //TR-BEGIN
//             break;
//         case 'TD': // TD-BEGIN
//             if( !empty($attr['WIDTH']) ) $this->tdwidth=($attr['WIDTH']/4);
//             else $this->tdwidth=40; // Set to your own width if you need bigger fixed cells
//             if( !empty($attr['HEIGHT']) ) $this->tdheight=($attr['HEIGHT']/6);
//             else $this->tdheight=6; // Set to your own height if you need bigger fixed cells
//             if( !empty($attr['ALIGN']) ) {
//                 $align=$attr['ALIGN'];      
//                 if($align=='LEFT') $this->tdalign='L';
//                 if($align=='CENTER') $this->tdalign='C';
//                 if($align=='RIGHT') $this->tdalign='R';
//             }
//             else $this->tdalign='L'; // Set to your own
//             if( !empty($attr['BGCOLOR']) ) {
//                 $coul=hex2dec($attr['BGCOLOR']);
//                     $this->SetFillColor($coul['R'],$coul['G'],$coul['B']);
//                     $this->tdbgcolor=true;
//                 }
//             $this->tdbegin=true;
//             break;

//         case 'HR':
//             if( !empty($attr['WIDTH']) )
//                 $Width = $attr['WIDTH'];
//             else
//                 $Width = $this->w - $this->lMargin-$this->rMargin;
//             $x = $this->GetX();
//             $y = $this->GetY();
//             $this->SetLineWidth(0.2);
//             $this->Line($x,$y,$x+$Width,$y);
//             $this->SetLineWidth(0.2);
//             $this->Ln(1);
//             break;
//         case 'STRONG':
//             $this->SetStyle('B',true);
//             break;
//         case 'EM':
//             $this->SetStyle('I',true);
//             break;
//         case 'B':
//         case 'I':
//         case 'U':
//             $this->SetStyle($tag,true);
//             break;
//         case 'A':
//             $this->HREF=$attr['HREF'];
//             break;
//         case 'IMG':
//             if(isset($attr['SRC']) && (isset($attr['WIDTH']) || isset($attr['HEIGHT']))) {
//                 if(!isset($attr['WIDTH']))
//                     $attr['WIDTH'] = 0;
//                 if(!isset($attr['HEIGHT']))
//                     $attr['HEIGHT'] = 0;
//                 $this->Image($attr['SRC'], $this->GetX(), $this->GetY(), px2mm($attr['WIDTH']), px2mm($attr['HEIGHT']));
//             }
//             break;
//         case 'BLOCKQUOTE':
//         case 'BR':
//             $this->Ln(5);
//             break;
//         case 'P':
//             $this->Ln(10);
//             break;
//         case 'FONT':
//             if (isset($attr['COLOR']) && $attr['COLOR']!='') {
//                 $coul=hex2dec($attr['COLOR']);
//                 $this->SetTextColor($coul['R'],$coul['G'],$coul['B']);
//                 $this->issetcolor=true;
//             }
//             if (isset($attr['FACE']) && in_array(strtolower($attr['FACE']), $this->fontlist)) {
//                 $this->SetFont(strtolower($attr['FACE']));
//                 $this->issetfont=true;
//             }
//             if (isset($attr['FACE']) && in_array(strtolower($attr['FACE']), $this->fontlist) && isset($attr['SIZE']) && $attr['SIZE']!='') {
//                 $this->SetFont(strtolower($attr['FACE']),'',$attr['SIZE']);
//                 $this->issetfont=true;
//             }
//             break;
//     }
// }

// function CloseTag($tag)
// {
//     //Closing tag
//     if($tag=='SUP') {
//     }

//     if($tag=='TD') { // TD-END
//         $this->tdbegin=false;
//         $this->tdwidth=0;
//         $this->tdheight=0;
//         $this->tdalign="L";
//         $this->tdbgcolor=false;
//     }
//     if($tag=='TR') { // TR-END
//         $this->Ln();
//     }
//     if($tag=='TABLE') { // TABLE-END
//         $this->tableborder=0;
//     }

//     if($tag=='STRONG')
//         $tag='B';
//     if($tag=='EM')
//         $tag='I';
//     if($tag=='B' || $tag=='I' || $tag=='U')
//         $this->SetStyle($tag,false);
//     if($tag=='A')
//         $this->HREF='';
//     if($tag=='FONT'){
//         if ($this->issetcolor==true) {
//             $this->SetTextColor(0);
//         }
//         if ($this->issetfont) {
//             $this->SetFont('arial');
//             $this->issetfont=false;
//         }
//     }
// }

// function SetStyle($tag, $enable)
// {
//     //Modify style and select corresponding font
//     $this->$tag+=($enable ? 1 : -1);
//     $style='';
//     foreach(array('B','I','U') as $s) {
//         if($this->$s>0)
//             $style.=$s;
//     }
//     $this->SetFont('',$style);
// }

// function PutLink($URL, $txt)
// {
//     //Put a hyperlink
//     $this->SetTextColor(0,0,255);
//     $this->SetStyle('U',true);
//     $this->Write(5,$txt,$URL);
//     $this->SetStyle('U',false);
//     $this->SetTextColor(0);
// }
// }
?>

Zerion Mini Shell 1.0