IMP::filterText PHP Method

filterText() public static method

Filters a string, if requested.
public static filterText ( string $text ) : string
$text string The text to filter.
return string The filtered text (if requested).
    public static function filterText($text)
    {
        global $injector, $prefs;
        if ($prefs->getValue('filtering') && strlen($text)) {
            try {
                return $injector->getInstance('Horde_Core_Factory_TextFilter')->filter($text, 'words', $injector->getInstance('Horde_Core_Hooks')->callHook('msg_filter', 'imp'));
            } catch (Horde_Exception_HookNotSet $e) {
            }
        }
        return $text;
    }

Usage Example

示例#1
0
文件: Enriched.php 项目: horde/horde
 /**
  * Format output text with IMP additions.
  *
  * @param string $text  The HTML text.
  *
  * @return string  The text with extra IMP formatting applied.
  */
 protected function _IMPformat($text)
 {
     // Highlight quoted parts of an email.
     if ($GLOBALS['prefs']->getValue('highlight_text')) {
         $text = implode("\n", preg_replace('|^(\\s*&gt;.+)$|', '<span class="quoted1">\\1</span>', explode("\n", $text)));
         $indent = 1;
         while (preg_match('|&gt;(\\s?&gt;){' . $indent . '}|', $text)) {
             $text = implode("\n", preg_replace('|^<span class="quoted' . (($indent - 1) % 5 + 1) . '">(\\s*&gt;(\\s?&gt;){' . $indent . '}.+)$|', '<span class="quoted' . ($indent % 5 + 1) . '">\\1', explode("\n", $text)));
             ++$indent;
         }
     }
     // Dim signatures.
     if ($GLOBALS['prefs']->getValue('dim_signature')) {
         $parts = preg_split('|(\\n--\\s*\\n)|', $text, 2, PREG_SPLIT_DELIM_CAPTURE);
         $text = array_shift($parts);
         if (count($parts)) {
             $text .= '<span class="signature">' . $parts[0] . preg_replace('|class="[^"]+"|', 'class="signature-fixed"', $parts[1]) . '</span>';
         }
     }
     // Filter bad language.
     return IMP::filterText($text);
 }
All Usage Examples Of IMP::filterText