Merge remote branch 'upstream/master'

This commit is contained in:
Michael Vogel 2012-07-15 17:26:00 +02:00
commit 7aa10d1935
9 changed files with 338 additions and 255 deletions

View File

@ -10,7 +10,7 @@ require_once('include/nav.php');
require_once('include/cache.php'); require_once('include/cache.php');
define ( 'FRIENDICA_PLATFORM', 'Friendica'); define ( 'FRIENDICA_PLATFORM', 'Friendica');
define ( 'FRIENDICA_VERSION', '3.0.1402' ); define ( 'FRIENDICA_VERSION', '3.0.1404' );
define ( 'DFRN_PROTOCOL_VERSION', '2.23' ); define ( 'DFRN_PROTOCOL_VERSION', '2.23' );
define ( 'DB_UPDATE_VERSION', 1153 ); define ( 'DB_UPDATE_VERSION', 1153 );

View File

@ -875,12 +875,14 @@ function item_store($arr,$force_parent = false) {
if((strpos($arr['body'],'<') !== false) || (strpos($arr['body'],'>') !== false)) if((strpos($arr['body'],'<') !== false) || (strpos($arr['body'],'>') !== false))
$arr['body'] = strip_tags($arr['body']); $arr['body'] = strip_tags($arr['body']);
require_once('Text/LanguageDetect.php');
$naked_body = preg_replace('/\[(.+?)\]/','',$arr['body']);
$l = new Text_LanguageDetect;
$lng = $l->detectConfidence($naked_body);
$arr['postopts'] = (($lng['language']) ? 'lang=' . $lng['language'] . ';' . $lng['confidence'] : '');
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
require_once('Text/LanguageDetect.php');
$naked_body = preg_replace('/\[(.+?)\]/','',$arr['body']);
$l = new Text_LanguageDetect;
$lng = $l->detectConfidence($naked_body);
$arr['postopts'] = (($lng['language']) ? 'lang=' . $lng['language'] . ';' . $lng['confidence'] : '');
}
$arr['wall'] = ((x($arr,'wall')) ? intval($arr['wall']) : 0); $arr['wall'] = ((x($arr,'wall')) ? intval($arr['wall']) : 0);
$arr['uri'] = ((x($arr,'uri')) ? notags(trim($arr['uri'])) : random_string()); $arr['uri'] = ((x($arr,'uri')) ? notags(trim($arr['uri'])) : random_string());

View File

@ -280,6 +280,31 @@ function paginate(&$a) {
return $o; return $o;
}} }}
if(! function_exists('alt_pager')) {
function alt_pager(&$a, $i) {
$o = '';
$stripped = preg_replace('/(&page=[0-9]*)/','',$a->query_string);
$stripped = str_replace('q=','',$stripped);
$stripped = trim($stripped,'/');
$pagenum = $a->pager['page'];
$url = $a->get_baseurl() . '/' . $stripped;
$o .= '<div class="pager">';
if($a->pager['page']>1)
$o .= "<a href=\"$url"."&page=".($a->pager['page'] - 1).'">' . t('newer') . '</a>';
if($i>0) {
if($a->pager['page']>1)
$o .= "&nbsp;-&nbsp;";
$o .= "<a href=\"$url"."&page=".($a->pager['page'] + 1).'">' . t('older') . '</a>';
}
$o .= '</div>'."\r\n";
return $o;
}}
// Turn user/group ACLs stored as angle bracketed text into arrays // Turn user/group ACLs stored as angle bracketed text into arrays
if(! function_exists('expand_acl')) { if(! function_exists('expand_acl')) {

View File

@ -44,22 +44,24 @@ function community_content(&$a, $update = 0) {
// Only public posts can be shown // Only public posts can be shown
// OR your own posts if you are a logged in member // OR your own posts if you are a logged in member
if(! get_pconfig(local_user(),'system','alt_pager')) {
$r = q("SELECT COUNT(distinct(`item`.`uri`)) AS `total`
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` LEFT JOIN `user` ON `user`.`uid` = `item`.`uid`
WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0
AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''
AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''
AND `item`.`private` = 0 AND `item`.`wall` = 1 AND `user`.`hidewall` = 0
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0"
);
$r = q("SELECT distinct(`item`.`uri`) AS `total` if(count($r))
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` LEFT JOIN `user` ON `user`.`uid` = `item`.`uid` $a->set_pager_total($r[0]['total']);
WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0
AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''
AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''
AND `item`.`private` = 0 AND `item`.`wall` = 1 AND `user`.`hidewall` = 0
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 group by `item`.`uri` "
);
if(count($r)) if(! $r[0]['total']) {
$a->set_pager_total($r[0]['total']); info( t('No results.') . EOL);
return $o;
}
if(! $r[0]['total']) {
info( t('No results.') . EOL);
return $o;
} }
$r = q("SELECT distinct(`item`.`uri`), `item`.*, `item`.`id` AS `item_id`, $r = q("SELECT distinct(`item`.`uri`), `item`.*, `item`.`id` AS `item_id`,
@ -70,9 +72,9 @@ function community_content(&$a, $update = 0) {
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
LEFT JOIN `user` ON `user`.`uid` = `item`.`uid` LEFT JOIN `user` ON `user`.`uid` = `item`.`uid`
WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0 WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0
AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''
AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''
AND `item`.`private` = 0 AND `item`.`wall` = 1 AND `user`.`hidewall` = 0 AND `item`.`private` = 0 AND `item`.`wall` = 1 AND `user`.`hidewall` = 0
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 group by `item`.`uri` AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 group by `item`.`uri`
ORDER BY `received` DESC LIMIT %d, %d ", ORDER BY `received` DESC LIMIT %d, %d ",
intval($a->pager['start']), intval($a->pager['start']),
@ -80,11 +82,21 @@ function community_content(&$a, $update = 0) {
); );
if(! count($r)) {
info( t('No results.') . EOL);
return $o;
}
// we behave the same in message lists as the search module // we behave the same in message lists as the search module
$o .= conversation($a,$r,'community',$update); $o .= conversation($a,$r,'community',$update);
$o .= paginate($a); if(! get_pconfig(local_user(),'system','alt_pager')) {
$o .= paginate($a);
}
else {
$o .= alt_pager($a,count($r));
}
return $o; return $o;
} }

View File

@ -219,12 +219,18 @@ function item_post(&$a) {
$naked_body = preg_replace('/\[(.+?)\]/','',$body); $naked_body = preg_replace('/\[(.+?)\]/','',$body);
$l = new Text_LanguageDetect;
$lng = $l->detectConfidence($naked_body);
$postopts = (($lng['language']) ? 'lang=' . $lng['language'] . ';' . $lng['confidence'] : ''); if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
$l = new Text_LanguageDetect;
$lng = $l->detectConfidence($naked_body);
$postopts = (($lng['language']) ? 'lang=' . $lng['language'] . ';' . $lng['confidence'] : '');
logger('mod_item: detect language' . print_r($lng,true) . $naked_body, LOGGER_DATA);
}
else
$postopts = '';
logger('mod_item: detect language' . print_r($lng,true) . $naked_body, LOGGER_DATA);
$private = ((strlen($str_group_allow) || strlen($str_contact_allow) || strlen($str_group_deny) || strlen($str_contact_deny)) ? 1 : 0); $private = ((strlen($str_group_allow) || strlen($str_contact_allow) || strlen($str_group_deny) || strlen($str_contact_deny)) ? 1 : 0);

View File

@ -563,21 +563,23 @@ function network_content(&$a, $update = 0) {
} }
else { else {
$r = q("SELECT COUNT(*) AS `total` if(! get_pconfig(local_user(),'system','alt_pager')) {
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` $r = q("SELECT COUNT(*) AS `total`
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
$sql_extra2 $sql_extra3 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
$sql_extra $sql_nets ", $sql_extra2 $sql_extra3
intval($_SESSION['uid']) $sql_extra $sql_nets ",
); intval($_SESSION['uid'])
);
if(count($r)) { if(count($r)) {
$a->set_pager_total($r[0]['total']); $a->set_pager_total($r[0]['total']);
$itemspage_network = get_pconfig(local_user(),'system','itemspage_network'); }
$a->set_pager_itemspage(((intval($itemspage_network)) ? $itemspage_network : 40)); }
} $itemspage_network = get_pconfig(local_user(),'system','itemspage_network');
$pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage'])); $a->set_pager_itemspage(((intval($itemspage_network)) ? $itemspage_network : 40));
$pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage']));
} }
$simple_update = (($update) ? " and `item`.`unseen` = 1 " : ''); $simple_update = (($update) ? " and `item`.`unseen` = 1 " : '');
@ -688,7 +690,12 @@ function network_content(&$a, $update = 0) {
$o .= conversation($a,$items,$mode,$update); $o .= conversation($a,$items,$mode,$update);
if(! $update) { if(! $update) {
$o .= paginate($a); if(! get_pconfig(local_user(),'system','alt_pager')) {
$o .= paginate($a);
}
else {
$o .= alt_pager($a,count($items));
}
} }
return $o; return $o;

View File

@ -206,7 +206,6 @@ function profile_content(&$a, $update = 0) {
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND
(`item`.`deleted` = 0 OR item.verb = '" . ACTIVITY_LIKE ."' OR item.verb = '" . ACTIVITY_DISLIKE . "') (`item`.`deleted` = 0 OR item.verb = '" . ACTIVITY_LIKE ."' OR item.verb = '" . ACTIVITY_DISLIKE . "')
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
and `item`.`moderated` = 0 and `item`.`unseen` = 1 and `item`.`moderated` = 0 and `item`.`unseen` = 1
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
AND `item`.`wall` = 1 AND `item`.`wall` = 1
@ -229,20 +228,21 @@ function profile_content(&$a, $update = 0) {
$sql_extra2 .= protect_sprintf(sprintf(" AND item.created >= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery2)))); $sql_extra2 .= protect_sprintf(sprintf(" AND item.created >= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery2))));
} }
if(! get_pconfig($a->profile['profile_uid'],'system','alt_pager')) {
$r = q("SELECT COUNT(*) AS `total`
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
and `item`.`moderated` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
AND `item`.`id` = `item`.`parent` AND `item`.`wall` = 1
$sql_extra $sql_extra2 ",
intval($a->profile['profile_uid'])
);
$r = q("SELECT COUNT(*) AS `total` if(count($r)) {
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` $a->set_pager_total($r[0]['total']);
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
and `item`.`moderated` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
AND `item`.`id` = `item`.`parent` AND `item`.`wall` = 1
$sql_extra $sql_extra2 ",
intval($a->profile['profile_uid'])
);
if(count($r)) {
$a->set_pager_total($r[0]['total']);
$a->set_pager_itemspage(40);
} }
}
$a->set_pager_itemspage(40);
$pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage'])); $pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage']));
@ -313,7 +313,12 @@ function profile_content(&$a, $update = 0) {
$o .= conversation($a,$items,'profile',$update); $o .= conversation($a,$items,'profile',$update);
if(! $update) { if(! $update) {
$o .= paginate($a); if(! get_pconfig($a->profile['profile_uid'],'system','alt_pager')) {
$o .= paginate($a);
}
else {
$o .= alt_pager($a,count($items));
}
} }
return $o; return $o;

View File

@ -128,21 +128,24 @@ function search_content(&$a) {
// OR your own posts if you are a logged in member // OR your own posts if you are a logged in member
// No items will be shown if the member has a blocked profile wall. // No items will be shown if the member has a blocked profile wall.
$r = q("SELECT distinct(`item`.`uri`) as `total` if(! get_pconfig(local_user(),'system','alt_pager')) {
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` LEFT JOIN `user` ON `user`.`uid` = `item`.`uid` $r = q("SELECT distinct(`item`.`uri`) as `total`
WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` LEFT JOIN `user` ON `user`.`uid` = `item`.`uid`
AND (( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `item`.`private` = 0 AND `user`.`hidewall` = 0) WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0
OR `item`.`uid` = %d ) AND (( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `item`.`private` = 0 AND `user`.`hidewall` = 0)
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 OR `item`.`uid` = %d )
$sql_extra group by `item`.`uri` ", AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
intval(local_user()) $sql_extra group by `item`.`uri` ",
); intval(local_user())
);
if(count($r)) if(count($r))
$a->set_pager_total(count($r)); $a->set_pager_total(count($r));
if(! count($r)) {
info( t('No results.') . EOL); if(! count($r)) {
return $o; info( t('No results.') . EOL);
return $o;
}
} }
$r = q("SELECT distinct(`item`.`uri`), `item`.*, `item`.`id` AS `item_id`, $r = q("SELECT distinct(`item`.`uri`), `item`.*, `item`.`id` AS `item_id`,
@ -165,6 +168,12 @@ function search_content(&$a) {
); );
if(! count($r)) {
info( t('No results.') . EOL);
return $o;
}
if($tag) if($tag)
$o .= '<h2>Items tagged with: ' . $search . '</h2>'; $o .= '<h2>Items tagged with: ' . $search . '</h2>';
else else
@ -172,7 +181,12 @@ function search_content(&$a) {
$o .= conversation($a,$r,'search',false); $o .= conversation($a,$r,'search',false);
$o .= paginate($a); if(! get_pconfig(local_user(),'system','alt_pager')) {
$o .= paginate($a);
}
else {
$o .= alt_pager($a,count($r));
}
return $o; return $o;
} }

File diff suppressed because it is too large Load Diff