1
1
Fork 0

Merge pull request #570 from annando/master

Vier, caches and "share" via API
This commit is contained in:
friendica 2013-01-04 15:13:09 -08:00
commit 88cc414355
12 changed files with 227 additions and 29 deletions

View file

@ -944,7 +944,7 @@
//$include_entities = (x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:false);
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `contact`.`nick` as `reply_author`,
`contact`.`name`, `contact`.`photo`, `contact`.`url` as `reply_url`, `contact`.`rel`,
`contact`.`name`, `contact`.`photo` as `reply_photo`, `contact`.`url` as `reply_url`, `contact`.`rel`,
`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
FROM `item`, `contact`
@ -957,7 +957,18 @@
);
if ($r[0]['body'] != "") {
$_REQUEST['body'] = html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8')."[url=".$r[0]['reply_url']."]".$r[0]['reply_author']."[/url] \n".$r[0]['body'];
if (intval(get_config('system','new_share'))) {
$post = "[share author='".str_replace("'", "'", $r[0]['reply_author']).
"' profile='".$r[0]['reply_url'].
"' avatar='".$r[0]['reply_photo'].
"' link='".$r[0]['plink']."']";
$post .= $r[0]['body'];
$post .= "[/share]";
$_REQUEST['body'] = $post;
} else
$_REQUEST['body'] = html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8')."[url=".$r[0]['reply_url']."]".$r[0]['reply_author']."[/url] \n".$r[0]['body'];
$_REQUEST['profile_uid'] = api_user();
$_REQUEST['type'] = 'wall';
$_REQUEST['api_source'] = true;

View file

@ -310,6 +310,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
// remove some newlines before the general conversion
$Text = preg_replace("/\s?\[share(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism","[share$1]$2[/share]",$Text);
$Text = preg_replace("/\s?\[quote(.*?)\]\s?(.*?)\s?\[\/quote\]\s?/ism","[quote$1]$2[/quote]",$Text);
// when the content is meant exporting to other systems then remove the avatar picture since this doesn't really look good on these systems
if (!$tryoembed)
@ -324,6 +325,15 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
$Text = trim($Text);
$Text = str_replace("\r\n","\n", $Text);
// removing multiplicated newlines
$search = array("\n\n\n", "\n ", " \n", "[/quote]\n\n", "\n[/quote]");
$replace = array("\n\n", "\n", "\n", "[/quote]\n", "[/quote]");
do {
$oldtext = $Text;
$Text = str_replace($search, $replace, $Text);
} while ($oldtext != $Text);
$Text = str_replace(array("\r","\n"), array('<br />','<br />'), $Text);
if($preserve_nl)

View file

@ -99,14 +99,26 @@ function poller_run(&$argv, &$argc){
proc_run('php','include/expire.php');
}
// clear old cache
Cache::clear();
$last = get_config('system','cache_last_cleared');
// clear old item cache files
clear_cache();
if($last) {
$next = $last + (3600); // Once per hour
$clear_cache = ($next <= time());
} else
$clear_cache = true;
// clear cache for photos
clear_cache($a->get_basepath(), $a->get_basepath()."/photo");
if ($clear_cache) {
// clear old cache
Cache::clear();
// clear old item cache files
clear_cache();
// clear cache for photos
clear_cache($a->get_basepath(), $a->get_basepath()."/photo");
set_config('system','cache_last_cleared', time());
}
$manual_id = 0;
$generation = 0;