Texy\HtmlElement::getText PHP Method

getText() final public method

Gets element's textual content.
final public getText ( ) : string
return string
    public final function getText()
    {
        $s = '';
        foreach ($this->children as $child) {
            if (is_object($child)) {
                return FALSE;
            }
            $s .= $child;
        }
        return $s;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Finish invocation.
  * @return Texy\HtmlElement|FALSE
  */
 public function solve(Texy\HandlerInvocation $invocation, $content, Texy\Modifier $mod = NULL)
 {
     $texy = $this->texy;
     // find hard linebreaks
     if ($texy->mergeLines) {
         // ....
         // ... => \r means break line
         $content = Regexp::replace($content, '#\\n +(?=\\S)#', "\r");
     } else {
         $content = Regexp::replace($content, '#\\n#', "\r");
     }
     $el = new Texy\HtmlElement('p');
     $el->parseLine($texy, $content);
     $content = $el->getText();
     // string
     // check content type
     // block contains block tag
     if (strpos($content, $texy::CONTENT_BLOCK) !== FALSE) {
         $el->setName(NULL);
         // ignores modifier!
         // block contains text (protected)
     } elseif (strpos($content, $texy::CONTENT_TEXTUAL) !== FALSE) {
         // leave element p
         // block contains text
     } elseif (preg_match('#[^\\s' . Texy\Patterns::MARK . ']#u', $content)) {
         // leave element p
         // block contains only replaced element
     } elseif (strpos($content, $texy::CONTENT_REPLACED) !== FALSE) {
         $el->setName($texy->nontextParagraph);
         // block contains only markup tags or spaces or nothing
     } else {
         // if {ignoreEmptyStuff} return FALSE;
         if (!$mod) {
             $el->setName(NULL);
         }
     }
     if ($el->getName()) {
         // apply modifier
         if ($mod) {
             $mod->decorate($texy, $el);
         }
         // add <br />
         if (strpos($content, "\r") !== FALSE) {
             $key = $texy->protect('<br />', $texy::CONTENT_REPLACED);
             $content = str_replace("\r", $key, $content);
         }
     }
     $content = strtr($content, "\r\n", '  ');
     $el->setText($content);
     return $el;
 }
All Usage Examples Of Texy\HtmlElement::getText