Hopefully this will make item_cache the default
This commit is contained in:
parent
c186e6ed96
commit
e85593e970
@ -381,10 +381,47 @@ function bb_sanitize_style($input) {
|
|||||||
return '<span style="' . $css_string_san . '">' . $input[2] . '</span>';
|
return '<span style="' . $css_string_san . '">' . $input[2] . '</span>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function bb_observer($Text) {
|
||||||
|
|
||||||
|
$observer = $a->get_observer();
|
||||||
|
|
||||||
|
if ((strpos($Text,'[/observer]') !== false) || (strpos($Text,'[/rpost]') !== false)) {
|
||||||
|
if ($observer) {
|
||||||
|
$Text = preg_replace("/\[observer\=1\](.*?)\[\/observer\]/ism", '$1', $Text);
|
||||||
|
$Text = preg_replace("/\[observer\=0\].*?\[\/observer\]/ism", '', $Text);
|
||||||
|
$Text = preg_replace_callback("/\[rpost(=(.*?))?\](.*?)\[\/rpost\]/ism", 'rpost_callback', $Text);
|
||||||
|
} else {
|
||||||
|
$Text = preg_replace("/\[observer\=1\].*?\[\/observer\]/ism", '', $Text);
|
||||||
|
$Text = preg_replace("/\[observer\=0\](.*?)\[\/observer\]/ism", '$1', $Text);
|
||||||
|
$Text = preg_replace("/\[rpost(=.*?)?\](.*?)\[\/rpost\]/ism", '', $Text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$channel = $a->get_channel();
|
||||||
|
|
||||||
|
if (strpos($Text,'[/channel]') !== false) {
|
||||||
|
if ($channel) {
|
||||||
|
$Text = preg_replace("/\[channel\=1\](.*?)\[\/channel\]/ism", '$1', $Text);
|
||||||
|
$Text = preg_replace("/\[channel\=0\].*?\[\/channel\]/ism", '', $Text);
|
||||||
|
} else {
|
||||||
|
$Text = preg_replace("/\[channel\=1\].*?\[\/channel\]/ism", '', $Text);
|
||||||
|
$Text = preg_replace("/\[channel\=0\](.*?)\[\/channel\]/ism", '$1', $Text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $Text;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// BBcode 2 HTML was written by WAY2WEB.net
|
// BBcode 2 HTML was written by WAY2WEB.net
|
||||||
// extended to work with Mistpark/Friendica/Red - Mike Macgirvin
|
// extended to work with Mistpark/Friendica/Red - Mike Macgirvin
|
||||||
|
|
||||||
function bbcode($Text, $preserve_nl = false, $tryoembed = true) {
|
function bbcode($Text, $preserve_nl = false, $tryoembed = true, $cache = false) {
|
||||||
|
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
|
|
||||||
@ -420,7 +457,8 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true) {
|
|||||||
// process [observer] tags before we do anything else because we might
|
// process [observer] tags before we do anything else because we might
|
||||||
// be stripping away stuff that then doesn't need to be worked on anymore
|
// be stripping away stuff that then doesn't need to be worked on anymore
|
||||||
|
|
||||||
if(get_config('system','item_cache'))
|
|
||||||
|
if($cache)
|
||||||
$observer = false;
|
$observer = false;
|
||||||
else
|
else
|
||||||
$observer = $a->get_observer();
|
$observer = $a->get_observer();
|
||||||
@ -437,7 +475,7 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(get_config('system','item_cache'))
|
if($cache)
|
||||||
$channel = false;
|
$channel = false;
|
||||||
else
|
else
|
||||||
$channel = $a->get_channel();
|
$channel = $a->get_channel();
|
||||||
@ -452,6 +490,8 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
$x = bb_extract_images($Text);
|
$x = bb_extract_images($Text);
|
||||||
$Text = $x['body'];
|
$Text = $x['body'];
|
||||||
|
@ -1379,15 +1379,15 @@ function generate_named_map($location) {
|
|||||||
|
|
||||||
function prepare_body(&$item,$attach = false) {
|
function prepare_body(&$item,$attach = false) {
|
||||||
|
|
||||||
if(get_config('system','item_cache') && $item['html'])
|
if($item['html'])
|
||||||
return $item['html'];
|
return bb_observer($item['html']);
|
||||||
|
|
||||||
call_hooks('prepare_body_init', $item);
|
call_hooks('prepare_body_init', $item);
|
||||||
|
|
||||||
|
|
||||||
unobscure($item);
|
unobscure($item);
|
||||||
|
|
||||||
$s = prepare_text($item['body'],$item['mimetype']);
|
$s = prepare_text($item['body'],$item['mimetype'], true);
|
||||||
|
|
||||||
$prep_arr = array('item' => $item, 'html' => $s);
|
$prep_arr = array('item' => $item, 'html' => $s);
|
||||||
call_hooks('prepare_body', $prep_arr);
|
call_hooks('prepare_body', $prep_arr);
|
||||||
@ -1452,11 +1452,11 @@ function prepare_body(&$item,$attach = false) {
|
|||||||
$prep_arr = array('item' => $item, 'html' => $s);
|
$prep_arr = array('item' => $item, 'html' => $s);
|
||||||
call_hooks('prepare_body_final', $prep_arr);
|
call_hooks('prepare_body_final', $prep_arr);
|
||||||
|
|
||||||
if(get_config('system','item_cache'))
|
|
||||||
q("update item set html = '%s' where id = %d",
|
q("update item set html = '%s' where id = %d",
|
||||||
dbesc($prep_arr['html']),
|
dbesc($prep_arr['html']),
|
||||||
intval($item['id'])
|
intval($item['id'])
|
||||||
);
|
);
|
||||||
|
|
||||||
return $prep_arr['html'];
|
return $prep_arr['html'];
|
||||||
}
|
}
|
||||||
@ -1468,7 +1468,7 @@ function prepare_body(&$item,$attach = false) {
|
|||||||
* @param sting $content_type
|
* @param sting $content_type
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function prepare_text($text, $content_type = 'text/bbcode') {
|
function prepare_text($text, $content_type = 'text/bbcode', $cache = false) {
|
||||||
|
|
||||||
switch($content_type) {
|
switch($content_type) {
|
||||||
case 'text/plain':
|
case 'text/plain':
|
||||||
@ -1506,9 +1506,9 @@ function prepare_text($text, $content_type = 'text/bbcode') {
|
|||||||
require_once('include/bbcode.php');
|
require_once('include/bbcode.php');
|
||||||
|
|
||||||
if(stristr($text,'[nosmile]'))
|
if(stristr($text,'[nosmile]'))
|
||||||
$s = bbcode($text);
|
$s = bbcode($text,false,true,$cache);
|
||||||
else
|
else
|
||||||
$s = smilies(bbcode($text));
|
$s = smilies(bbcode($text,false,true,$cache));
|
||||||
$s = zidify_links($s);
|
$s = zidify_links($s);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user