ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
PHPExcel_Helper_HTML Class Reference
+ Collaboration diagram for PHPExcel_Helper_HTML:

Public Member Functions

 toRichTextObject ($html)
 

Protected Member Functions

 initialise ()
 
 buildTextRun ()
 
 rgbToColour ($rgb)
 
 colourNameLookup ($rgb)
 
 startFontTag ($tag)
 
 endFontTag ()
 
 startBoldTag ()
 
 endBoldTag ()
 
 startItalicTag ()
 
 endItalicTag ()
 
 startUnderlineTag ()
 
 endUnderlineTag ()
 
 startSubscriptTag ()
 
 endSubscriptTag ()
 
 startSuperscriptTag ()
 
 endSuperscriptTag ()
 
 startStrikethruTag ()
 
 endStrikethruTag ()
 
 breakTag ()
 
 parseTextNode (DOMText $textNode)
 
 handleCallback ($element, $callbackTag, $callbacks)
 
 parseElementNode (DOMElement $element)
 
 parseElements (DOMNode $element)
 

Protected Attributes

 $face
 
 $size
 
 $color
 
 $bold = false
 
 $italic = false
 
 $underline = false
 
 $superscript = false
 
 $subscript = false
 
 $strikethrough = false
 
 $startTagCallbacks
 
 $endTagCallbacks
 
 $stack = array()
 
 $stringData = ''
 
 $richTextObject
 

Static Protected Attributes

static $colourMap
 

Detailed Description

Definition at line 3 of file HTML.php.

Member Function Documentation

◆ breakTag()

PHPExcel_Helper_HTML::breakTag ( )
protected

Definition at line 721 of file HTML.php.

References PHP_EOL.

721  {
722  $this->stringData .= PHP_EOL;
723  }
if($is_dev) echo "Review changes write something in WHATSNEW and and then commit with log PHP_EOL

◆ buildTextRun()

PHPExcel_Helper_HTML::buildTextRun ( )
protected

Definition at line 602 of file HTML.php.

References $stringData, $text, color, size, and PHPExcel_Style_Font\UNDERLINE_SINGLE.

Referenced by parseTextNode().

602  {
604  if (trim($text) === '')
605  return;
606 
607  $richtextRun = $this->richTextObject->createTextRun($this->stringData);
608  if ($this->face) {
609  $richtextRun->getFont()->setName($this->face);
610  }
611  if ($this->size) {
612  $richtextRun->getFont()->setSize($this->size);
613  }
614  if ($this->color) {
615  $richtextRun->getFont()->setColor( new PHPExcel_Style_Color( 'ff' . $this->color ) );
616  }
617  if ($this->bold) {
618  $richtextRun->getFont()->setBold(true);
619  }
620  if ($this->italic) {
621  $richtextRun->getFont()->setItalic(true);
622  }
623  if ($this->underline) {
624  $richtextRun->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE);
625  }
626  if ($this->superscript) {
627  $richtextRun->getFont()->setSuperScript(true);
628  }
629  if ($this->subscript) {
630  $richtextRun->getFont()->setSubScript(true);
631  }
632  if ($this->strikethrough) {
633  $richtextRun->getFont()->setStrikethrough(true);
634  }
635  $this->stringData = '';
636  }
if(PHP_SAPI !='cli') color
Definition: langcheck.php:120
const UNDERLINE_SINGLE
Definition: Font.php:42
font size
Definition: langcheck.php:162
$text
+ Here is the caller graph for this function:

◆ colourNameLookup()

PHPExcel_Helper_HTML::colourNameLookup (   $rgb)
protected

Definition at line 646 of file HTML.php.

Referenced by startFontTag().

646  {
647  return self::$colourMap[$rgb];
648  }
+ Here is the caller graph for this function:

◆ endBoldTag()

PHPExcel_Helper_HTML::endBoldTag ( )
protected

Definition at line 677 of file HTML.php.

677  {
678  $this->bold = false;
679  }

◆ endFontTag()

PHPExcel_Helper_HTML::endFontTag ( )
protected

Definition at line 669 of file HTML.php.

References color, and size.

669  {
670  $this->face = $this->size = $this->color = null;
671  }
if(PHP_SAPI !='cli') color
Definition: langcheck.php:120
font size
Definition: langcheck.php:162

◆ endItalicTag()

PHPExcel_Helper_HTML::endItalicTag ( )
protected

Definition at line 685 of file HTML.php.

685  {
686  $this->italic = false;
687  }

◆ endStrikethruTag()

PHPExcel_Helper_HTML::endStrikethruTag ( )
protected

Definition at line 717 of file HTML.php.

717  {
718  $this->strikethrough = false;
719  }

◆ endSubscriptTag()

PHPExcel_Helper_HTML::endSubscriptTag ( )
protected

Definition at line 701 of file HTML.php.

701  {
702  $this->subscript = false;
703  }

◆ endSuperscriptTag()

PHPExcel_Helper_HTML::endSuperscriptTag ( )
protected

Definition at line 709 of file HTML.php.

709  {
710  $this->superscript = false;
711  }

◆ endUnderlineTag()

PHPExcel_Helper_HTML::endUnderlineTag ( )
protected

Definition at line 693 of file HTML.php.

693  {
694  $this->underline = false;
695  }

◆ handleCallback()

PHPExcel_Helper_HTML::handleCallback (   $element,
  $callbackTag,
  $callbacks 
)
protected

Definition at line 731 of file HTML.php.

References array.

Referenced by parseElementNode().

731  {
732  if (isset($callbacks[$callbackTag])) {
733  $elementHandler = $callbacks[$callbackTag];
734  if (method_exists($this, $elementHandler)) {
735  call_user_func(array($this, $elementHandler), $element);
736  }
737  }
738  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ initialise()

PHPExcel_Helper_HTML::initialise ( )
protected

Definition at line 576 of file HTML.php.

References array, color, and size.

Referenced by toRichTextObject().

576  {
577  $this->face = $this->size = $this->color = null;
578  $this->bold = $this->italic = $this->underline = $this->superscript = $this->subscript = $this->strikethrough = false;
579 
580  $this->stack = array();
581 
582  $this->stringData = '';
583  }
if(PHP_SAPI !='cli') color
Definition: langcheck.php:120
font size
Definition: langcheck.php:162
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ parseElementNode()

PHPExcel_Helper_HTML::parseElementNode ( DOMElement  $element)
protected

Definition at line 740 of file HTML.php.

References handleCallback(), and parseElements().

Referenced by parseElements().

740  {
741  $callbackTag = strtolower($element->nodeName);
742  $this->stack[] = $callbackTag;
743 
744  $this->handleCallback($element, $callbackTag, $this->startTagCallbacks);
745 
746  $this->parseElements($element);
747  $this->stringData .= ' ';
748  array_pop($this->stack);
749 
750  $this->handleCallback($element, $callbackTag, $this->endTagCallbacks);
751  }
handleCallback($element, $callbackTag, $callbacks)
Definition: HTML.php:731
parseElements(DOMNode $element)
Definition: HTML.php:753
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseElements()

PHPExcel_Helper_HTML::parseElements ( DOMNode  $element)
protected

Definition at line 753 of file HTML.php.

References parseElementNode(), and parseTextNode().

Referenced by parseElementNode(), and toRichTextObject().

753  {
754  foreach ($element->childNodes as $child) {
755  if ($child instanceof DOMText) {
756  $this->parseTextNode($child);
757  } elseif ($child instanceof DOMElement) {
758  $this->parseElementNode($child);
759  }
760  }
761  }
parseTextNode(DOMText $textNode)
Definition: HTML.php:725
parseElementNode(DOMElement $element)
Definition: HTML.php:740
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseTextNode()

PHPExcel_Helper_HTML::parseTextNode ( DOMText  $textNode)
protected

Definition at line 725 of file HTML.php.

References buildTextRun().

Referenced by parseElements().

725  {
726  $domText = preg_replace('/\s+/u', ' ', ltrim($textNode->nodeValue));
727  $this->stringData .= $domText;
728  $this->buildTextRun();
729  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rgbToColour()

PHPExcel_Helper_HTML::rgbToColour (   $rgb)
protected

Definition at line 638 of file HTML.php.

Referenced by startFontTag().

638  {
639  preg_match_all('/\d+/', $rgb, $values);
640  foreach($values[0] as &$value) {
641  $value = str_pad(dechex($value), 2, '0', STR_PAD_LEFT);
642  }
643  return implode($values[0]);
644  }
+ Here is the caller graph for this function:

◆ startBoldTag()

PHPExcel_Helper_HTML::startBoldTag ( )
protected

Definition at line 673 of file HTML.php.

673  {
674  $this->bold = true;
675  }

◆ startFontTag()

PHPExcel_Helper_HTML::startFontTag (   $tag)
protected

Definition at line 650 of file HTML.php.

References colourNameLookup(), and rgbToColour().

650  {
651  foreach ($tag->attributes as $attribute) {
652  $attributeName = strtolower($attribute->name);
653  $attributeValue = $attribute->value;
654 
655  if ($attributeName == 'color') {
656  if (preg_match('/rgb\s*\(/', $attributeValue)) {
657  $this->$attributeName = $this->rgbToColour($attributeValue);
658  } elseif(strpos(trim($attributeValue), '#') === 0) {
659  $this->$attributeName = ltrim($attributeValue, '#');
660  } else {
661  $this->$attributeName = $this->colourNameLookup($attributeValue);
662  }
663  } else {
664  $this->$attributeName = $attributeValue;
665  }
666  }
667  }
colourNameLookup($rgb)
Definition: HTML.php:646
+ Here is the call graph for this function:

◆ startItalicTag()

PHPExcel_Helper_HTML::startItalicTag ( )
protected

Definition at line 681 of file HTML.php.

681  {
682  $this->italic = true;
683  }

◆ startStrikethruTag()

PHPExcel_Helper_HTML::startStrikethruTag ( )
protected

Definition at line 713 of file HTML.php.

713  {
714  $this->strikethrough = true;
715  }

◆ startSubscriptTag()

PHPExcel_Helper_HTML::startSubscriptTag ( )
protected

Definition at line 697 of file HTML.php.

697  {
698  $this->subscript = true;
699  }

◆ startSuperscriptTag()

PHPExcel_Helper_HTML::startSuperscriptTag ( )
protected

Definition at line 705 of file HTML.php.

705  {
706  $this->superscript = true;
707  }

◆ startUnderlineTag()

PHPExcel_Helper_HTML::startUnderlineTag ( )
protected

Definition at line 689 of file HTML.php.

689  {
690  $this->underline = true;
691  }

◆ toRichTextObject()

PHPExcel_Helper_HTML::toRichTextObject (   $html)

Definition at line 585 of file HTML.php.

References $html, $richTextObject, initialise(), and parseElements().

585  {
586  $this->initialise();
587 
588  // Create a new DOM object
589  $dom = new domDocument;
590  // Load the HTML file into the DOM object
591  // Note the use of error suppression, because typically this will be an html fragment, so not fully valid markup
592  $loaded = @$dom->loadHTML($html);
593 
594  // Discard excess white space
595  $dom->preserveWhiteSpace = false;
596 
597  $this->richTextObject = new PHPExcel_RichText();;
598  $this->parseElements($dom);
599  return $this->richTextObject;
600  }
parseElements(DOMNode $element)
Definition: HTML.php:753
$html
Definition: example_001.php:87
+ Here is the call graph for this function:

Field Documentation

◆ $bold

PHPExcel_Helper_HTML::$bold = false
protected

Definition at line 529 of file HTML.php.

◆ $color

PHPExcel_Helper_HTML::$color
protected

Definition at line 527 of file HTML.php.

◆ $colourMap

PHPExcel_Helper_HTML::$colourMap
staticprotected

Definition at line 5 of file HTML.php.

◆ $endTagCallbacks

PHPExcel_Helper_HTML::$endTagCallbacks
protected
Initial value:
'font' => 'endFontTag',
'b' => 'endBoldTag',
'strong' => 'endBoldTag',
'i' => 'endItalicTag',
'em' => 'endItalicTag',
'u' => 'endUnderlineTag',
'ins' => 'endUnderlineTag',
'del' => 'endStrikethruTag',
'sup' => 'endSuperscriptTag',
'sub' => 'endSubscriptTag',
'br' => 'breakTag',
'p' => 'breakTag',
'h1' => 'breakTag',
'h2' => 'breakTag',
'h3' => 'breakTag',
'h4' => 'breakTag',
'h5' => 'breakTag',
'h6' => 'breakTag',
)

Definition at line 549 of file HTML.php.

◆ $face

PHPExcel_Helper_HTML::$face
protected

Definition at line 525 of file HTML.php.

◆ $italic

PHPExcel_Helper_HTML::$italic = false
protected

Definition at line 530 of file HTML.php.

◆ $richTextObject

PHPExcel_Helper_HTML::$richTextObject
protected

Definition at line 574 of file HTML.php.

Referenced by toRichTextObject().

◆ $size

PHPExcel_Helper_HTML::$size
protected

Definition at line 526 of file HTML.php.

◆ $stack

PHPExcel_Helper_HTML::$stack = array()
protected

Definition at line 570 of file HTML.php.

◆ $startTagCallbacks

PHPExcel_Helper_HTML::$startTagCallbacks
protected
Initial value:
'font' => 'startFontTag',
'b' => 'startBoldTag',
'strong' => 'startBoldTag',
'i' => 'startItalicTag',
'em' => 'startItalicTag',
'u' => 'startUnderlineTag',
'ins' => 'startUnderlineTag',
'del' => 'startStrikethruTag',
'sup' => 'startSuperscriptTag',
'sub' => 'startSubscriptTag',
)

Definition at line 536 of file HTML.php.

◆ $strikethrough

PHPExcel_Helper_HTML::$strikethrough = false
protected

Definition at line 534 of file HTML.php.

◆ $stringData

PHPExcel_Helper_HTML::$stringData = ''
protected

Definition at line 572 of file HTML.php.

Referenced by buildTextRun().

◆ $subscript

PHPExcel_Helper_HTML::$subscript = false
protected

Definition at line 533 of file HTML.php.

◆ $superscript

PHPExcel_Helper_HTML::$superscript = false
protected

Definition at line 532 of file HTML.php.

◆ $underline

PHPExcel_Helper_HTML::$underline = false
protected

Definition at line 531 of file HTML.php.


The documentation for this class was generated from the following file: