Html::entity_decode_deep PHP Method

entity_decode_deep() static public method

Recursivly execute html_entity_decode on an Array
static public entity_decode_deep ( $value ) : array
$value string or array
return array of value (same struct as input)
    static function entity_decode_deep($value)
    {
        return is_array($value) ? array_map(array(__CLASS__, 'entity_decode_deep'), $value) : html_entity_decode($value, ENT_QUOTES, "UTF-8");
    }

Usage Example

Example #1
0
 /**
  * Clean display value deleting html tags
  *
  * @param $value string: string value
  * @param $striptags bool: strip all html tags
  * @param $keep_bad int:
  *          1 : neutralize tag anb content,
  *          2 : remove tag and neutralize content
  * @return clean value
  **/
 static function clean($value, $striptags = true, $keep_bad = 2)
 {
     include_once GLPI_HTMLAWED;
     $value = Html::entity_decode_deep($value);
     // Clean MS office tags
     $value = str_replace(array("<![if !supportLists]>", "<![endif]>"), '', $value);
     if ($striptags) {
         $specialfilter = array('@<div[^>]*?tooltip_picture[^>]*?>.*?</div[^>]*?>@si');
         // Strip ToolTips
         $value = preg_replace($specialfilter, '', $value);
         $specialfilter = array('@<div[^>]*?tooltip_text[^>]*?>.*?</div[^>]*?>@si');
         // Strip ToolTips
         $value = preg_replace($specialfilter, '', $value);
         $specialfilter = array('@<div[^>]*?tooltip_picture_border[^>]*?>.*?</div[^>]*?>@si');
         // Strip ToolTips
         $value = preg_replace($specialfilter, '', $value);
         $specialfilter = array('@<div[^>]*?invisible[^>]*?>.*?</div[^>]*?>@si');
         // Strip ToolTips
         $value = preg_replace($specialfilter, '', $value);
         $value = preg_replace("/<(p|br|div)( [^>]*)?" . ">/i", "\n", $value);
         $value = preg_replace("/(&nbsp;| )+/", " ", $value);
         $search = array('@<script[^>]*?>.*?</script[^>]*?>@si', '@<style[^>]*?>.*?</style[^>]*?>@si', '@<!DOCTYPE[^>]*?>@si');
         $value = preg_replace($search, '', $value);
     }
     $value = htmLawed($value, array('elements' => $striptags ? 'none' : '', 'keep_bad' => $keep_bad, 'comment' => 1, 'cdata' => 1));
     $value = str_replace(array('&lt;', '&gt;'), array('&amp;lt;', '&amp;gt;'), $value);
     /*
           $specialfilter = array('@<span[^>]*?x-hidden[^>]*?>.*?</span[^>]*?>@si'); // Strip ToolTips
           $value         = preg_replace($specialfilter, ' ', $value);
     
           $search        = array('@<script[^>]*?>.*?</script[^>]*?>@si', // Strip out javascript
                                  '@<style[^>]*?>.*?</style[^>]*?>@si',   // Strip style tags properly
                                  '@<[\/\!]*?[^<>]*?>@si',                // Strip out HTML tags
                                  '@<![\s\S]*?--[ \t\n\r]*>@');           // Strip multi-line comments including CDATA
     
           $value = preg_replace($search, ' ', $value);
     
           // nettoyer l'apostrophe curly qui pose probleme a certains rss-readers, lecteurs de mail...
           $value = str_replace("&#8217;", "'", $value);
     */
     // Problem with this regex : may crash
     //   $value = preg_replace("/ +/u", " ", $value);
     // Revert back htmlawed &amp; -> &
     //$value = str_replace("&amp;", "&", $value);
     $value = str_replace(array("\r\n", "\r"), "\n", $value);
     $value = preg_replace("/(\n[ ]*){2,}/", "\n\n", $value, -1);
     return trim($value);
 }
All Usage Examples Of Html::entity_decode_deep
Html