/**
  * @param unknown $text
  * @return Ambigous <string, mixed>
  */
 private function get_text($text)
 {
     // Strip links first
     $text = preg_replace("/<\\/?a(\\s+.*?>|>)/", "", $text);
     $html2Text = new \Html2Text\Html2Text($text);
     $text = $html2Text->get_text();
     // Strip multiply spaces and remove line breaks
     $text = preg_replace('/\\s+/m', ' ', $text);
     $text = \Rss\Util\Helpers\Helpers::fix_smartquotes($text);
     return $text;
 }
Beispiel #2
0
 /**
  * Replace smart quotes
  *
  * @param string $xml        	
  * @return string
  */
 private function fix_encoding($xml)
 {
     // Fix text
     $doc = new \DOMDocument('1.0');
     @$doc->loadXML($xml);
     $xpath = new \DOMXpath($doc);
     foreach ($xpath->query('//text()') as $node) {
         if (preg_match('/â€/', $node->nodeValue)) {
             $node->nodeValue = \Rss\Util\Helpers\Helpers::fix_smartquotes($node->nodeValue);
         }
     }
     return $doc->saveXML();
 }
 /**
  * Get the text from an html string
  *
  * @param string $text        	
  * @return string
  *
  */
 private function get_text($text)
 {
     if (!is_array($text)) {
         $this->logger->logWarn("Invalid text ", array(json_decode($text)));
         return null;
     }
     for ($i = 0; $i < count($text); $i++) {
         // Strip multiply spaces and remove line breaks
         $text[$i] = preg_replace('/\\s+/m', ' ', $text[$i]);
         $text[$i] = trim($text[$i]);
     }
     $text = implode(" ", $text);
     $text = htmlspecialchars_decode($text, ENT_QUOTES);
     $text = \Rss\Util\Helpers\Helpers::fix_smartquotes($text);
     return $text;
 }
Beispiel #4
0
 /**
  * Get the text from an html string
  *
  * @param string $text        	
  * @return string
  *
  */
 private function get_text($text)
 {
     // Strip links first because Html2Text puts them in the output
     $text = preg_replace("/<\\/?a(\\s+.*?>|>)/", "", $text);
     $html2Text = new \Html2Text\Html2Text($text);
     $text = $html2Text->get_text();
     $text = html_entity_decode($text, ENT_QUOTES);
     // Strip multiply spaces and remove line breaks
     $text = preg_replace('/\\s+/m', ' ', $text);
     $text = \Rss\Util\Helpers\Helpers::fix_smartquotes($text);
     $text = trim($text);
     return $text;
 }