HTMLPurifier_HTMLDefinition::parseTinyMCEAllowedList PHP Méthode

parseTinyMCEAllowedList() public méthode

..
public parseTinyMCEAllowedList ( array $list ) : array
$list array String list to parse
Résultat array
    public function parseTinyMCEAllowedList($list)
    {
        $list = str_replace(array(' ', "\t"), '', $list);
        $elements = array();
        $attributes = array();
        $chunks = preg_split('/(,|[\\n\\r]+)/', $list);
        foreach ($chunks as $chunk) {
            if (empty($chunk)) {
                continue;
            }
            // remove TinyMCE element control characters
            if (!strpos($chunk, '[')) {
                $element = $chunk;
                $attr = false;
            } else {
                list($element, $attr) = explode('[', $chunk);
            }
            if ($element !== '*') {
                $elements[$element] = true;
            }
            if (!$attr) {
                continue;
            }
            $attr = substr($attr, 0, strlen($attr) - 1);
            // remove trailing ]
            $attr = explode('|', $attr);
            foreach ($attr as $key) {
                $attributes["{$element}.{$key}"] = true;
            }
        }
        return array($elements, $attributes);
    }

Usage Example

Exemple #1
0
 /**
  * Get info message about allowed html tags
  * 
  * @return string
  **/
 public function allowed_html()
 {
     require_once APPPATH . 'libraries/htmlpurifier/HTMLPurifier.auto.php';
     $def = new HTMLPurifier_HTMLDefinition();
     list($el, $attr) = $def->parseTinyMCEAllowedList(Kohana::config('config.allowed_html', FALSE, TRUE));
     $iframes = explode('|', str_replace(array('%^http://(', ')%'), '', Kohana::config('config.safe_iframe_regexp', FALSE, TRUE)));
     $output = "";
     $output .= Kohana::lang('ui_main.allowed_tags', implode(', ', array_keys($el)));
     $output .= "<br/> ";
     $output .= Kohana::lang('ui_main.allowed_iframes', implode(', ', $iframes));
     return $output;
 }
All Usage Examples Of HTMLPurifier_HTMLDefinition::parseTinyMCEAllowedList