mirror of
https://github.com/processwire/processwire.git
synced 2025-08-14 10:45:54 +02:00
Add Notice::allowMarkdown flag to Notice class, similar to Notice::allowMarkup, but enables support of basic/inline markdown and bracket tags
This commit is contained in:
@@ -123,6 +123,14 @@ abstract class Notice extends WireData {
|
|||||||
*/
|
*/
|
||||||
const persist = 2097152;
|
const persist = 2097152;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allow parsing of basic/inline markdown and bracket markup per $sanitizer->entitiesMarkdown()
|
||||||
|
*
|
||||||
|
* @since 3.0.165
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
const allowMarkdown = 4194304;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flag integers to flag names
|
* Flag integers to flag names
|
||||||
*
|
*
|
||||||
@@ -136,6 +144,7 @@ abstract class Notice extends WireData {
|
|||||||
self::log => 'log',
|
self::log => 'log',
|
||||||
self::logOnly => 'logOnly',
|
self::logOnly => 'logOnly',
|
||||||
self::allowMarkup => 'allowMarkup',
|
self::allowMarkup => 'allowMarkup',
|
||||||
|
self::allowMarkdown => 'allowMarkdown',
|
||||||
self::anonymous => 'anonymous',
|
self::anonymous => 'anonymous',
|
||||||
self::noGroup => 'noGroup',
|
self::noGroup => 'noGroup',
|
||||||
self::login => 'login',
|
self::login => 'login',
|
||||||
@@ -263,12 +272,16 @@ abstract class Notice extends WireData {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
protected function flagNames($flags = null, $getString = false) {
|
protected function flagNames($flags = null, $getString = false) {
|
||||||
if($flags === null) return self::$flagNames;
|
if($flags === null) {
|
||||||
if(!is_int($flags)) return '';
|
$flagNames = self::$flagNames;
|
||||||
|
} else if(!is_int($flags)) {
|
||||||
|
$flagNames = array();
|
||||||
|
} else {
|
||||||
$flagNames = array();
|
$flagNames = array();
|
||||||
foreach(self::$flagNames as $flag => $flagName) {
|
foreach(self::$flagNames as $flag => $flagName) {
|
||||||
if($flags & $flag) $flagNames[$flag] = $flagName;
|
if($flags & $flag) $flagNames[$flag] = $flagName;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return $getString ? implode(' ', $flagNames) : $flagNames;
|
return $getString ? implode(' ', $flagNames) : $flagNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -507,11 +520,16 @@ class Notices extends WireArray {
|
|||||||
$item->text = "<pre>" . trim(print_r($this->sanitizeArray($text), true)) . "</pre>";
|
$item->text = "<pre>" . trim(print_r($this->sanitizeArray($text), true)) . "</pre>";
|
||||||
$item->flags = $item->flags | Notice::allowMarkup;
|
$item->flags = $item->flags | Notice::allowMarkup;
|
||||||
} else if(is_object($text) && $text instanceof Wire) {
|
} else if(is_object($text) && $text instanceof Wire) {
|
||||||
$item->text = "<pre>" . $this->wire('sanitizer')->entities(print_r($text, true)) . "</pre>";
|
$item->text = "<pre>" . $this->wire()->sanitizer->entities(print_r($text, true)) . "</pre>";
|
||||||
$item->flags = $item->flags | Notice::allowMarkup;
|
$item->flags = $item->flags | Notice::allowMarkup;
|
||||||
} else if(is_object($text)) {
|
} else if(is_object($text)) {
|
||||||
$item->text = (string) $text;
|
$item->text = (string) $text;
|
||||||
}
|
}
|
||||||
|
if($item->hasFlag('allowMarkdown')) {
|
||||||
|
$item->text = $this->wire()->sanitizer->entitiesMarkdown($text, array('allowBrackets' => true));
|
||||||
|
$item->addFlag('allowMarkup');
|
||||||
|
$item->removeFlag('allowMarkdown');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user