コード例 #1
0
ファイル: metagen.php プロジェクト: redmexico/XoopsCore
 /**
  * @param string  $text
  * @param boolean $keyword
  *
  * @return string
  */
 public function purifyText($text, $keyword = false)
 {
     $text = str_replace(' ', ' ', $text);
     $text = str_replace('<br />', ' ', $text);
     $text = strip_tags($text);
     $text = html_entity_decode($text);
     $text = $this->_myts->undoHtmlSpecialChars($text);
     $text = str_replace(')', ' ', $text);
     $text = str_replace('(', ' ', $text);
     $text = str_replace(':', ' ', $text);
     $text = str_replace('&euro', ' euro ', $text);
     $text = str_replace('&hellip', '...', $text);
     $text = str_replace('&rsquo', ' ', $text);
     $text = str_replace('!', ' ', $text);
     $text = str_replace('?', ' ', $text);
     $text = str_replace('"', ' ', $text);
     $text = str_replace('-', ' ', $text);
     $text = str_replace('\\n', ' ', $text);
     if ($keyword) {
         $text = str_replace('.', ' ', $text);
         $text = str_replace(',', ' ', $text);
         $text = str_replace('\'', ' ', $text);
     }
     $text = str_replace(';', ' ', $text);
     return $text;
 }
コード例 #2
0
ファイル: metagen.php プロジェクト: trabisdementia/publisher
 /**
  * @param      $text
  * @param bool $keyword
  *
  * @return mixed
  */
 public function purifyText($text, $keyword = false)
 {
     //        $text = str_replace(['&nbsp;', ' '], ['<br />', ' '], $text); //for php 5.4
     $text = str_replace('&nbsp;', ' ', $text);
     $text = str_replace('<br />', ' ', $text);
     $text = strip_tags($text);
     $text = html_entity_decode($text);
     $text = $this->myts->undoHtmlSpecialChars($text);
     $text = str_replace(')', ' ', $text);
     $text = str_replace('(', ' ', $text);
     $text = str_replace(':', ' ', $text);
     $text = str_replace('&euro', ' euro ', $text);
     $text = str_replace('&hellip', '...', $text);
     $text = str_replace('&rsquo', ' ', $text);
     $text = str_replace('!', ' ', $text);
     $text = str_replace('?', ' ', $text);
     $text = str_replace('"', ' ', $text);
     $text = str_replace('-', ' ', $text);
     $text = str_replace('\\n', ' ', $text);
     //        $text = str_replace([')','(',':','&euro','&hellip','&rsquo','!','?','"','-','\n'], [' ' , ' ',  ' ',  ' euro ',  '...',  ' ', ' ', ' ',  ' ', ' ',  ' '], $text); //for PHP 5.4
     if ($keyword) {
         $text = str_replace('.', ' ', $text);
         $text = str_replace(',', ' ', $text);
         $text = str_replace('\'', ' ', $text);
         //            $text = str_replace(['.', ' '], [',', ' '], ['\'', ' '], $text); //for PHP 5.4
     }
     $text = str_replace(';', ' ', $text);
     return $text;
 }
コード例 #3
0
 /**
  * @param MyTextSanitizer $ts
  * @param string $source
  * @param string $language
  * @return bool|mixed|string
  */
 public function load(MyTextSanitizer &$ts, $source, $language)
 {
     $config = parent::loadConfig(__DIR__);
     if (empty($config['highlight'])) {
         return "<pre>{$source}</pre>";
     }
     $source = $ts->undoHtmlSpecialChars($source);
     $source = stripslashes($source);
     if ($config['highlight'] == 'geshi') {
         $language = str_replace('=', '', $language);
         $language = $language ? $language : $config['language'];
         $language = strtolower($language);
         if ($source2 = MytsSyntaxhighlight::geshi($source, $language)) {
             return $source2;
         }
     }
     $source = MytsSyntaxhighlight::php($source);
     return $source;
 }