Fix usages of Pager with JSON calls in mod/match and mod/dirfind
This commit is contained in:
parent
74e80f137b
commit
dde8d8976d
2 changed files with 15 additions and 15 deletions
|
@ -67,6 +67,7 @@ function dirfind_content(App $a, $prefix = "") {
|
||||||
$o = '';
|
$o = '';
|
||||||
|
|
||||||
if ($search) {
|
if ($search) {
|
||||||
|
$pager = new Pager($a->query_string);
|
||||||
|
|
||||||
if ($discover_user) {
|
if ($discover_user) {
|
||||||
$j = new stdClass();
|
$j = new stdClass();
|
||||||
|
@ -94,14 +95,13 @@ function dirfind_content(App $a, $prefix = "") {
|
||||||
Model\GContact::update($user_data);
|
Model\GContact::update($user_data);
|
||||||
}
|
}
|
||||||
} elseif ($local) {
|
} elseif ($local) {
|
||||||
|
if ($community) {
|
||||||
if ($community)
|
|
||||||
$extra_sql = " AND `community`";
|
$extra_sql = " AND `community`";
|
||||||
else
|
} else {
|
||||||
$extra_sql = "";
|
$extra_sql = "";
|
||||||
|
}
|
||||||
|
|
||||||
$perpage = 80;
|
$pager->setItemsPerPage(80);
|
||||||
$startrec = (($pager->getPage()) * $perpage) - $perpage;
|
|
||||||
|
|
||||||
if (Config::get('system','diaspora_enabled')) {
|
if (Config::get('system','diaspora_enabled')) {
|
||||||
$diaspora = Protocol::DIASPORA;
|
$diaspora = Protocol::DIASPORA;
|
||||||
|
@ -138,10 +138,10 @@ function dirfind_content(App $a, $prefix = "") {
|
||||||
DBA::escape(Protocol::DFRN), DBA::escape($ostatus), DBA::escape($diaspora),
|
DBA::escape(Protocol::DFRN), DBA::escape($ostatus), DBA::escape($diaspora),
|
||||||
DBA::escape(escape_tags($search2)), DBA::escape(escape_tags($search2)), DBA::escape(escape_tags($search2)),
|
DBA::escape(escape_tags($search2)), DBA::escape(escape_tags($search2)), DBA::escape(escape_tags($search2)),
|
||||||
DBA::escape(escape_tags($search2)), DBA::escape(escape_tags($search2)), DBA::escape(escape_tags($search2)),
|
DBA::escape(escape_tags($search2)), DBA::escape(escape_tags($search2)), DBA::escape(escape_tags($search2)),
|
||||||
intval($startrec), intval($perpage));
|
$pager->getStart(), $pager->getItemsPerPage());
|
||||||
$j = new stdClass();
|
$j = new stdClass();
|
||||||
$j->total = $count[0]["total"];
|
$j->total = $count[0]["total"];
|
||||||
$j->items_page = $perpage;
|
$j->items_page = $pager->getItemsPerPage();
|
||||||
$j->page = $pager->getPage();
|
$j->page = $pager->getPage();
|
||||||
foreach ($results AS $result) {
|
foreach ($results AS $result) {
|
||||||
if (PortableContact::alternateOStatusUrl($result["nurl"])) {
|
if (PortableContact::alternateOStatusUrl($result["nurl"])) {
|
||||||
|
@ -178,18 +178,18 @@ function dirfind_content(App $a, $prefix = "") {
|
||||||
// Add found profiles from the global directory to the local directory
|
// Add found profiles from the global directory to the local directory
|
||||||
Worker::add(PRIORITY_LOW, 'DiscoverPoCo', "dirsearch", urlencode($search));
|
Worker::add(PRIORITY_LOW, 'DiscoverPoCo', "dirsearch", urlencode($search));
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$p = (($pager->getPage() != 1) ? '&p=' . $pager->getPage() : '');
|
$p = (($pager->getPage() != 1) ? '&p=' . $pager->getPage() : '');
|
||||||
|
|
||||||
if(strlen(Config::get('system','directory')))
|
if (strlen(Config::get('system','directory'))) {
|
||||||
$x = Network::fetchUrl(get_server().'/lsearch?f=' . $p . '&search=' . urlencode($search));
|
$x = Network::fetchUrl(get_server() . '/lsearch?f=' . $p . '&search=' . urlencode($search));
|
||||||
|
}
|
||||||
|
|
||||||
$j = json_decode($x);
|
$j = json_decode($x);
|
||||||
|
|
||||||
|
$pager->setItemsPerPage($j->items_page);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($j->results)) {
|
if (!empty($j->results)) {
|
||||||
$pager = new Pager($a->query_string, $j->items_page);
|
|
||||||
|
|
||||||
$id = 0;
|
$id = 0;
|
||||||
|
|
||||||
foreach ($j->results as $jj) {
|
foreach ($j->results as $jj) {
|
||||||
|
@ -250,13 +250,11 @@ function dirfind_content(App $a, $prefix = "") {
|
||||||
}
|
}
|
||||||
|
|
||||||
$tpl = get_markup_template('viewcontact_template.tpl');
|
$tpl = get_markup_template('viewcontact_template.tpl');
|
||||||
|
|
||||||
$o .= replace_macros($tpl,[
|
$o .= replace_macros($tpl,[
|
||||||
'title' => $header,
|
'title' => $header,
|
||||||
'$contacts' => $entries,
|
'$contacts' => $entries,
|
||||||
'$paginate' => $pager->renderFull($j->total),
|
'$paginate' => $pager->renderFull($j->total),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
info(L10n::t('No matches') . EOL);
|
info(L10n::t('No matches') . EOL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ function match_content(App $a)
|
||||||
$tags = trim($r[0]['pub_keywords'] . ' ' . $r[0]['prv_keywords']);
|
$tags = trim($r[0]['pub_keywords'] . ' ' . $r[0]['prv_keywords']);
|
||||||
|
|
||||||
if ($tags) {
|
if ($tags) {
|
||||||
$pager = new Pager($a->query_string, $j->items_page);
|
$pager = new Pager($a->query_string);
|
||||||
|
|
||||||
$params['s'] = $tags;
|
$params['s'] = $tags;
|
||||||
if ($pager->getPage() != 1) {
|
if ($pager->getPage() != 1) {
|
||||||
|
@ -70,6 +70,8 @@ function match_content(App $a)
|
||||||
$j = json_decode($x);
|
$j = json_decode($x);
|
||||||
|
|
||||||
if (count($j->results)) {
|
if (count($j->results)) {
|
||||||
|
$pager->setItemsPerPage($j->items_page);
|
||||||
|
|
||||||
$id = 0;
|
$id = 0;
|
||||||
|
|
||||||
foreach ($j->results as $jj) {
|
foreach ($j->results as $jj) {
|
||||||
|
|
Loading…
Reference in a new issue