本文整理汇总了PHP中paginate函数的典型用法代码示例。如果您正苦于以下问题:PHP paginate函数的具体用法?PHP paginate怎么用?PHP paginate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了paginate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: viewcontacts_content
function viewcontacts_content(&$a)
{
if (!count($a->profile) || $a->profile['hide-friends']) {
notice(t('Permission denied.') . EOL);
return;
}
$o .= '<h3>' . t('View Contacts') . '</h3>';
$r = q("SELECT COUNT(*) as `total` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0");
if (count($r)) {
$a->set_pager_total($r[0]['total']);
}
$r = q("SELECT * FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 ORDER BY `name` ASC LIMIT %d , %d ", intval($a->pager['start']), intval($a->pager['itemspage']));
if (!count($r)) {
notice(t('No contacts.') . EOL);
return $o;
}
$tpl = file_get_contents("view/viewcontact_template.tpl");
foreach ($r as $rr) {
if ($rr['self']) {
continue;
}
$o .= replace_macros($tpl, array('$id' => $rr['id'], '$alt_text' => t('Visit ') . $rr['name'] . t('\'s profile'), '$thumb' => $rr['thumb'], '$name' => $rr['name'], '$url' => $rr['url']));
}
$o .= '<div id="view-contact-end"></div>';
$o .= paginate($a);
return $o;
}
示例2: limit
private function limit()
{
if (isLang()) {
if (segment(1) === "videos" and segment(2) > 0) {
$start = segment(2) * _maxLimitVideos - _maxLimitVideos;
} else {
$start = 0;
}
} else {
if (segment(0) === "videos" and segment(1) > 0) {
$start = segment(2) * _maxLimitVideos - _maxLimitVideos;
} else {
$start = 0;
}
}
$limit = $start . ", " . _maxLimitVideos;
$count = $this->Videos_Model->count();
$URL = path("videos/");
if ($count > _maxLimitVideos) {
$this->pagination = paginate($count, _maxLimitVideos, $start, $URL);
} else {
$this->pagination = NULL;
}
return $limit;
}
示例3: dirfind_content
function dirfind_content(&$a)
{
$search = notags(trim($_REQUEST['search']));
if (strpos($search, '@') === 0) {
$search = substr($search, 1);
}
$o = '';
$o .= '<h2>' . t('People Search') . ' - ' . $search . '</h2>';
if ($search) {
$p = $a->pager['page'] != 1 ? '&p=' . $a->pager['page'] : '';
if (strlen(get_config('system', 'directory_submit_url'))) {
$x = fetch_url('http://dir.friendica.com/lsearch?f=' . $p . '&search=' . urlencode($search));
}
//TODO fallback local search if global dir not available.
// else
// $x = post_url($a->get_baseurl() . '/lsearch', $params);
$j = json_decode($x);
if ($j->total) {
$a->set_pager_total($j->total);
$a->set_pager_itemspage($j->items_page);
}
if (count($j->results)) {
$tpl = get_markup_template('match.tpl');
foreach ($j->results as $jj) {
$o .= replace_macros($tpl, array('$url' => zrl($jj->url), '$name' => $jj->name, '$photo' => $jj->photo, '$tags' => $jj->tags));
}
} else {
info(t('No matches') . EOL);
}
}
$o .= '<div class="clear"></div>';
$o .= paginate($a);
return $o;
}
示例4: display
public function display($id = null, $name = null, $page = null, $pid = null)
{
global $lang_common, $lang_post, $lang_topic, $lang_bbeditor, $pd;
if ($this->user->g_read_board == '0') {
message($lang_common['No view'], '403');
}
// Load the viewtopic.php language file
require FEATHER_ROOT . 'lang/' . $this->user->language . '/topic.php';
// Load the post.php language file
require FEATHER_ROOT . 'lang/' . $this->user->language . '/post.php';
// Antispam feature
require FEATHER_ROOT . 'lang/' . $this->user->language . '/antispam.php';
$index_questions = rand(0, count($lang_antispam_questions) - 1);
// BBcode toolbar feature
require FEATHER_ROOT . 'lang/' . $this->user['language'] . '/bbeditor.php';
// Load the viewtopic.php model file
require_once FEATHER_ROOT . 'model/viewtopic.php';
// Fetch some informations about the topic TODO
$cur_topic = $this->model->get_info_topic($id);
// Sort out who the moderators are and if we are currently a moderator (or an admin)
$mods_array = $cur_topic['moderators'] != '' ? unserialize($cur_topic['moderators']) : array();
$is_admmod = $this->user->g_id == FEATHER_ADMIN || $this->user->g_moderator == '1' && array_key_exists($this->user->username, $mods_array) ? true : false;
if ($is_admmod) {
$admin_ids = get_admin_ids();
}
// Can we or can we not post replies?
$post_link = $this->model->get_post_link($id, $cur_topic['closed'], $cur_topic['post_replies'], $is_admmod);
// Add/update this topic in our list of tracked topics
if (!$this->user->is_guest) {
$tracked_topics = get_tracked_topics();
$tracked_topics['topics'][$id] = time();
set_tracked_topics($tracked_topics);
}
// Determine the post offset (based on $_GET['p'])
$num_pages = ceil(($cur_topic['num_replies'] + 1) / $this->user->disp_posts);
$p = !isset($page) || $page <= 1 || $page > $num_pages ? 1 : intval($page);
$start_from = $this->user->disp_posts * ($p - 1);
$url_topic = url_friendly($cur_topic['subject']);
$url_forum = url_friendly($cur_topic['forum_name']);
// Generate paging links
$paging_links = '<span class="pages-label">' . $lang_common['Pages'] . ' </span>' . paginate($num_pages, $p, 'topic/' . $id . '/' . $url_topic . '/#');
if ($this->config['o_censoring'] == '1') {
$cur_topic['subject'] = censor_words($cur_topic['subject']);
}
$quickpost = $this->model->is_quickpost($cur_topic['post_replies'], $cur_topic['closed'], $is_admmod);
$subscraction = $this->model->get_subscraction($cur_topic['is_subscribed'], $id);
// Add relationship meta tags
$page_head = $this->model->get_page_head($id, $num_pages, $p, $url_topic);
$page_title = array(feather_escape($this->config['o_board_title']), feather_escape($cur_topic['forum_name']), feather_escape($cur_topic['subject']));
define('FEATHER_ALLOW_INDEX', 1);
define('FEATHER_ACTIVE_PAGE', 'viewtopic');
$this->header->setTitle($page_title)->setPage($p)->setPagingLinks($paging_links)->setPageHead($page_head)->display();
$forum_id = $cur_topic['forum_id'];
require FEATHER_ROOT . 'include/parser.php';
$this->feather->render('viewtopic.php', array('id' => $id, 'p' => $p, 'post_data' => $this->model->print_posts($id, $start_from, $cur_topic, $is_admmod), 'lang_common' => $lang_common, 'lang_topic' => $lang_topic, 'lang_post' => $lang_post, 'lang_bbeditor' => $lang_bbeditor, 'cur_topic' => $cur_topic, 'subscraction' => $subscraction, 'is_admmod' => $is_admmod, 'feather_config' => $this->config, 'paging_links' => $paging_links, 'post_link' => $post_link, 'start_from' => $start_from, 'lang_antispam' => $lang_antispam, 'pid' => $pid, 'quickpost' => $quickpost, 'index_questions' => $index_questions, 'lang_antispam_questions' => $lang_antispam_questions, 'url_forum' => $url_forum, 'url_topic' => $url_topic, 'feather' => $this->feather));
// Increment "num_views" for topic
$this->model->increment_views($id);
$this->footer->display('viewtopic', $id, $p, $pid, $cur_topic['forum_id'], $num_pages);
}
示例5: match_content
/**
* @brief Controller for /match.
*
* It takes keywords from your profile and queries the directory server for
* matching keywords from other profiles.
*
* @param App &$a
* @return void|string
*/
function match_content(&$a)
{
$o = '';
if (!local_user()) {
return;
}
$a->page['aside'] .= findpeople_widget();
$a->page['aside'] .= follow_widget();
$_SESSION['return_url'] = $a->get_baseurl() . '/' . $a->cmd;
$r = q("SELECT `pub_keywords`, `prv_keywords` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1", intval(local_user()));
if (!count($r)) {
return;
}
if (!$r[0]['pub_keywords'] && !$r[0]['prv_keywords']) {
notice(t('No keywords to match. Please add keywords to your default profile.') . EOL);
return;
}
$params = array();
$tags = trim($r[0]['pub_keywords'] . ' ' . $r[0]['prv_keywords']);
if ($tags) {
$params['s'] = $tags;
if ($a->pager['page'] != 1) {
$params['p'] = $a->pager['page'];
}
if (strlen(get_config('system', 'directory'))) {
$x = post_url(get_server() . '/msearch', $params);
} else {
$x = post_url($a->get_baseurl() . '/msearch', $params);
}
$j = json_decode($x);
if ($j->total) {
$a->set_pager_total($j->total);
$a->set_pager_itemspage($j->items_page);
}
if (count($j->results)) {
$id = 0;
foreach ($j->results as $jj) {
$match_nurl = normalise_link($jj->url);
$match = q("SELECT `nurl` FROM `contact` WHERE `uid` = '%d' AND nurl='%s' LIMIT 1", intval(local_user()), dbesc($match_nurl));
if (!count($match)) {
$jj->photo = str_replace("http:///photo/", get_server() . "/photo/", $jj->photo);
$connlnk = $a->get_baseurl() . '/follow/?url=' . $jj->url;
$photo_menu = array(array(t("View Profile"), zrl($jj->url)));
$photo_menu[] = array(t("Connect/Follow"), $connlnk);
$contact_details = get_contact_details_by_url($jj->url, local_user());
$entry = array('url' => zrl($jj->url), 'itemurl' => $contact_details['addr'] != "" ? $contact_details['addr'] : $jj->url, 'name' => $jj->name, 'details' => $contact_details['location'], 'tags' => $contact_details['keywords'], 'about' => $contact_details['about'], 'account_type' => $contact_details['community'] ? t('Forum') : '', 'thumb' => proxy_url($jj->photo, false, PROXY_SIZE_THUMB), 'inttxt' => ' ' . t('is interested in:'), 'conntxt' => t('Connect'), 'connlnk' => $connlnk, 'img_hover' => $jj->tags, 'photo_menu' => $photo_menu, 'id' => ++$id);
$entries[] = $entry;
}
}
$tpl = get_markup_template('viewcontact_template.tpl');
$o .= replace_macros($tpl, array('$title' => t('Profile Match'), '$contacts' => $entries, '$paginate' => paginate($a)));
} else {
info(t('No matches') . EOL);
}
}
return $o;
}
示例6: generateHTMLList
/**
* Funkcija generise HTML ul listu
*
* @param array $array Niz (data)
* @return HTML lista sa vrijednostima arraya
*/
function generateHTMLList($items)
{
$paginatedItems = paginate($items, 5);
printf('<ul>');
foreach ($paginatedItems as $item) {
printf('<li> %s </li>', $item);
}
printf('</ul>');
return TRUE;
}
示例7: index
/**
* The main page of the blog, show the most recent blog psots
*/
public function index()
{
if ($this->session->userdata('confirmation')) {
$this->session->unset_userdata('confirmation');
}
$posts = $this->post_model->get_posts();
if ($posts['count'] == 0) {
// if there are no posts we don't want to load the regular posts view file or we'll get an error
$data['view_file'] = 'posts/no-posts';
} else {
$data['posts'] = $posts['list'];
// ------------------------------------------------------------------------
// Pagination
// ------------------------------------------------------------------------
// config for the pagination of the content (posts)
$data['posts_per_page'] = 3;
$offset = $this->uri->segment(3);
$data['offset'] = (bool) $offset === FALSE ? '' : $offset;
// If the offset is invalid or NULL (in which case the user goes back to the first page anyway)
// the user is sent back to the first page and a feedback message is displayed
if ((!is_valid_number($data['offset']) || !array_key_exists($data['offset'], $posts['list'])) && !empty($data['offset'])) {
$this->session->set_flashdata('notice', 'Invalid Request');
redirect('posts/index/0');
}
$this->load->library('pagination');
$config['base_url'] = site_url('/posts/index');
$config['total_rows'] = $posts['count'];
$config['per_page'] = $data['posts_per_page'];
$config['num_links'] = 10;
$config['uri_segment'] = 3;
$config['full_tag_open'] = '<div class="pagination-links">';
$config['full_tag_close'] = '</div>';
$this->pagination->initialize($config);
$data['pagination_links'] = $this->pagination->create_links();
// Dynamically generate the posts pagination everytime the user clicks on a pagination link
$data['posts'] = paginate($posts['list'], $posts['count'], $data['posts_per_page'], $data['offset']);
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
// Breadcrumbs
// ------------------------------------------------------------------------
// the page number segment of the breadcrumbs will only appear if there is at least two pages
if ($posts['count'] > $config['per_page']) {
$_seg_title = 'page ' . get_page_number($data['offset'], $data['posts_per_page']);
$_seg_url = 'posts/index/' . $data['offset'];
$breadcrumbs = $this->azbraz->new_segment($_seg_title, $_seg_url);
} else {
$breadcrumbs = '';
}
$data['breadcrumbs'] = $this->azbraz->generate($breadcrumbs);
// ------------------------------------------------------------------------
$data['view_file'] = 'posts/index';
}
$this->load->view($this->main_view, $data);
}
示例8: match_content
function match_content(&$a)
{
$o = '';
if (!local_user()) {
return;
}
$a->page['aside'] .= follow_widget();
$a->page['aside'] .= findpeople_widget();
$_SESSION['return_url'] = $a->get_baseurl() . '/' . $a->cmd;
$o .= replace_macros(get_markup_template("section_title.tpl"), array('$title' => t('Profile Match')));
$r = q("SELECT `pub_keywords`, `prv_keywords` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1", intval(local_user()));
if (!count($r)) {
return;
}
if (!$r[0]['pub_keywords'] && !$r[0]['prv_keywords']) {
notice(t('No keywords to match. Please add keywords to your default profile.') . EOL);
return;
}
$params = array();
$tags = trim($r[0]['pub_keywords'] . ' ' . $r[0]['prv_keywords']);
if ($tags) {
$params['s'] = $tags;
if ($a->pager['page'] != 1) {
$params['p'] = $a->pager['page'];
}
if (strlen(get_config('system', 'directory'))) {
$x = post_url(get_server() . '/msearch', $params);
} else {
$x = post_url($a->get_baseurl() . '/msearch', $params);
}
$j = json_decode($x);
if ($j->total) {
$a->set_pager_total($j->total);
$a->set_pager_itemspage($j->items_page);
}
if (count($j->results)) {
$tpl = get_markup_template('match.tpl');
foreach ($j->results as $jj) {
$match_nurl = normalise_link($jj->url);
$match = q("SELECT `nurl` FROM `contact` WHERE `uid` = '%d' AND nurl='%s' LIMIT 1", intval(local_user()), dbesc($match_nurl));
if (!count($match)) {
$jj->photo = str_replace("http:///photo/", get_server() . "/photo/", $jj->photo);
$connlnk = $a->get_baseurl() . '/follow/?url=' . $jj->url;
$o .= replace_macros($tpl, array('$url' => zrl($jj->url), '$name' => $jj->name, '$photo' => proxy_url($jj->photo), '$inttxt' => ' ' . t('is interested in:'), '$conntxt' => t('Connect'), '$connlnk' => $connlnk, '$tags' => $jj->tags));
}
}
} else {
info(t('No matches') . EOL);
}
}
$o .= cleardiv();
$o .= paginate($a);
return $o;
}
示例9: generateHTMLImage
function generateHTMLImage($items)
{
$paginatedItems = paginate($items, 2);
foreach ($paginatedItems as $item) {
printf('<br>');
printf('<img src=%s width="500px">', $item);
printf('<br>');
printf('<a href=%s> %s </a>', $item, $item);
printf('<br>');
}
}
示例10: showManyArticles
function showManyArticles($articles, $params, $count)
{
if (!empty($articles)) {
foreach ($articles as $article) {
$rating = Ratings_getByID($article['id_art']);
include VIEWS_ROOT . '/little_article.php';
}
paginate($params, $count);
} else {
echo "<h1>404 PAGE NOT FOUND!</h1>";
}
}
示例11: get_by_name
public function get_by_name($order = 'ASC', $page = 1, $limit = 10)
{
$limits = paginate($page, $limit);
$query = $this->db->query('SELECT ' . $this->primary_key . ' FROM ' . $this->table . ' ORDER BY name ' . $order . ' LIMIT ' . $limits[0] . ', ' . $limits[1]);
if ($query !== false) {
$ids = array();
while ($id = $query->fetch()) {
$ids[] = (int) $id[$this->primary_key];
}
return $ids;
}
}
示例12: allfriends_content
function allfriends_content(&$a)
{
$o = '';
if (!local_user()) {
notice(t('Permission denied.') . EOL);
return;
}
if ($a->argc > 1) {
$cid = intval($a->argv[1]);
}
if (!$cid) {
return;
}
$uid = $a->user[uid];
$c = q("SELECT `name`, `url`, `photo` FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($cid), intval(local_user()));
if (!count($c)) {
return;
}
$a->page['aside'] = "";
profile_load($a, "", 0, get_contact_details_by_url($c[0]["url"]));
$total = count_all_friends(local_user(), $cid);
if (count($total)) {
$a->set_pager_total($total);
}
$r = all_friends(local_user(), $cid, $a->pager['start'], $a->pager['itemspage']);
if (!count($r)) {
$o .= t('No friends to display.');
return $o;
}
$id = 0;
foreach ($r as $rr) {
//get further details of the contact
$contact_details = get_contact_details_by_url($rr['url'], $uid);
$photo_menu = '';
// $rr[cid] is only available for common contacts. So if the contact is a common one, use contact_photo_menu to generate the photo_menu
// If the contact is not common to the user, Connect/Follow' will be added to the photo menu
if ($rr[cid]) {
$rr[id] = $rr[cid];
$photo_menu = contact_photo_menu($rr);
} else {
$connlnk = $a->get_baseurl() . '/follow/?url=' . $rr['url'];
$photo_menu = array(array(t("View Profile"), zrl($rr['url'])));
$photo_menu[] = array(t("Connect/Follow"), $connlnk);
}
$entry = array('url' => $rr['url'], 'itemurl' => $contact_details['addr'] != "" ? $contact_details['addr'] : $rr['url'], 'name' => htmlentities($rr['name']), 'thumb' => proxy_url($rr['photo'], false, PROXY_SIZE_THUMB), 'img_hover' => htmlentities($rr['name']), 'details' => $contact_details['location'], 'tags' => $contact_details['keywords'], 'about' => $contact_details['about'], 'account_type' => $contact_details['community'] ? t('Forum') : '', 'network' => network_to_name($contact_details['network'], $contact_details['url']), 'photo_menu' => $photo_menu, 'conntxt' => t('Connect'), 'connlnk' => $connlnk, 'id' => ++$id);
$entries[] = $entry;
}
$tab_str = contacts_tab($a, $cid, 3);
$tpl = get_markup_template('viewcontact_template.tpl');
$o .= replace_macros($tpl, array('$tab_str' => $tab_str, '$contacts' => $entries, '$paginate' => paginate($a)));
return $o;
}
示例13: community_content
function community_content(&$a, $update = 0)
{
$o = '';
if (get_config('system', 'block_public') && !local_user() && !remote_user()) {
notice(t('Public access denied.') . EOL);
return;
}
if (get_config('system', 'no_community_page')) {
notice(t('Not available.') . EOL);
return;
}
require_once "include/bbcode.php";
require_once 'include/security.php';
require_once 'include/conversation.php';
$o .= '<h3>' . t('Community') . '</h3>';
if (!$update) {
nav_set_selected('community');
}
if (x($a->data, 'search')) {
$search = notags(trim($a->data['search']));
} else {
$search = x($_GET, 'search') ? notags(trim(rawurldecode($_GET['search']))) : '';
}
// Here is the way permissions work in this module...
// Only public posts can be shown
// OR your own posts if you are a logged in member
if (!get_config('alt_pager', 'global') && !get_pconfig(local_user(), 'system', 'alt_pager')) {
$r = q("SELECT COUNT(distinct(`item`.`uri`)) AS `total`\n\t\t\tFROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` LEFT JOIN `user` ON `user`.`uid` = `item`.`uid`\n\t\t\tWHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0\n\t\t\tAND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' \n\t\t\tAND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''\n\t\t\tAND `item`.`private` = 0 AND `item`.`wall` = 1 AND `user`.`hidewall` = 0 \n\t\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0");
if (count($r)) {
$a->set_pager_total($r[0]['total']);
}
if (!$r[0]['total']) {
info(t('No results.') . EOL);
return $o;
}
}
//$r = q("SELECT distinct(`item`.`uri`)
$r = q("SELECT `item`.`uri`, `item`.*, `item`.`id` AS `item_id`, \n\t\t`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`rel`,\n\t\t`contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, \n\t\t`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`,\n\t\t`user`.`nickname`, `user`.`hidewall`\n\t\tFROM `item` FORCE INDEX (`received`) LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`\n\t\tLEFT JOIN `user` ON `user`.`uid` = `item`.`uid`\n\t\tWHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0\n\t\tAND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''\n\t\tAND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' \n\t\tAND `item`.`private` = 0 AND `item`.`wall` = 1 AND `item`.`id` = `item`.`parent`\n\t\tAND `user`.`hidewall` = 0\n\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `contact`.`self`\n\t\tORDER BY `received` DESC LIMIT %d, %d ", intval($a->pager['start']), intval($a->pager['itemspage']));
// group by `item`.`uri`
if (!count($r)) {
info(t('No results.') . EOL);
return $o;
}
// we behave the same in message lists as the search module
$o .= conversation($a, $r, 'community', $update);
if (get_config('alt_pager', 'global') || get_pconfig(local_user(), 'system', 'alt_pager')) {
$o .= alt_pager($a, count($r));
} else {
$o .= paginate($a);
}
return $o;
}
示例14: notes_content
function notes_content(&$a, $update = false)
{
if (!local_user()) {
notice(t('Permission denied.') . EOL);
return;
}
require_once "include/bbcode.php";
require_once 'include/security.php';
require_once 'include/conversation.php';
require_once 'include/acl_selectors.php';
$groups = array();
$o = '';
$remote_contact = false;
$contact_id = $_SESSION['cid'];
$contact = $a->contact;
$is_owner = true;
$o = "";
$o .= profile_tabs($a, True);
if (!$update) {
$o .= '<h3>' . t('Personal Notes') . '</h3>';
$commpage = false;
$commvisitor = false;
$celeb = false;
$x = array('is_owner' => $is_owner, 'allow_location' => $a->user['allow_location'] ? true : false, 'default_location' => $a->user['default-location'], 'nickname' => $a->user['nickname'], 'lockstate' => 'lock', 'acl' => '', 'bang' => '', 'visitor' => 'block', 'profile_uid' => local_user(), 'button' => t('Save'), 'acl_data' => '');
$o .= status_editor($a, $x, $a->contact['id']);
}
// Construct permissions
// default permissions - anonymous user
$sql_extra = " AND `allow_cid` = '<" . $a->contact['id'] . ">' ";
$r = q("SELECT COUNT(*) AS `total`\n\t\tFROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`\n\t\tWHERE `item`.`uid` = %d AND `item`.`visible` = 1 and `item`.`moderated` = 0 \n\t\tAND `item`.`deleted` = 0 AND `item`.`type` = 'note'\n\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `contact`.`self` = 1\n\t\tAND `item`.`id` = `item`.`parent` AND `item`.`wall` = 0\n\t\t{$sql_extra} ", intval(local_user()));
if (count($r)) {
$a->set_pager_total($r[0]['total']);
$a->set_pager_itemspage(40);
}
$r = q("SELECT `item`.`id` AS `item_id`, `contact`.`uid` AS `contact-uid`\n\t\tFROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`\n\t\tWHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 \n\t\tand `item`.`moderated` = 0 AND `item`.`type` = 'note'\n\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `contact`.`self` = 1\n\t\tAND `item`.`id` = `item`.`parent` AND `item`.`wall` = 0\n\t\t{$sql_extra}\n\t\tORDER BY `item`.`created` DESC LIMIT %d ,%d ", intval(local_user()), intval($a->pager['start']), intval($a->pager['itemspage']));
$parents_arr = array();
$parents_str = '';
if (count($r)) {
foreach ($r as $rr) {
$parents_arr[] = $rr['item_id'];
}
$parents_str = implode(', ', $parents_arr);
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`, \n\t\t\t`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`network`, `contact`.`rel`, \n\t\t\t`contact`.`thumb`, `contact`.`self`, `contact`.`writable`, \n\t\t\t`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`\n\t\t\tFROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`\n\t\t\tWHERE `item`.`uid` = %d AND `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0\n\t\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0\n\t\t\tAND `item`.`parent` IN ( %s )\n\t\t\t{$sql_extra}\n\t\t\tORDER BY `parent` DESC, `gravity` ASC, `item`.`id` ASC ", intval(local_user()), dbesc($parents_str));
if (count($r)) {
$items = conv_sort($r, "`commented`");
$o .= conversation($a, $items, 'notes', $update);
}
}
$o .= paginate($a);
return $o;
}
示例15: match_content
function match_content(&$a)
{
$o = '';
if (!local_user()) {
return;
}
$_SESSION['return_url'] = $a->get_baseurl() . '/' . $a->cmd;
$o .= '<h2>' . t('Profile Match') . '</h2>';
$r = q("SELECT `pub_keywords`, `prv_keywords` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1", intval(local_user()));
if (!count($r)) {
return;
}
if (!$r[0]['pub_keywords'] && !$r[0]['prv_keywords']) {
notice(t('No keywords to match. Please add keywords to your default profile.') . EOL);
return;
}
$params = array();
$tags = trim($r[0]['pub_keywords'] . ' ' . $r[0]['prv_keywords']);
if ($tags) {
$params['s'] = $tags;
if ($a->pager['page'] != 1) {
$params['p'] = $a->pager['page'];
}
if (strlen(get_config('system', 'directory_submit_url'))) {
$x = post_url('http://dir.friendica.com/msearch', $params);
} else {
$x = post_url($a->get_baseurl() . '/msearch', $params);
}
$j = json_decode($x);
if ($j->total) {
$a->set_pager_total($j->total);
$a->set_pager_itemspage($j->items_page);
}
if (count($j->results)) {
$tpl = get_markup_template('match.tpl');
foreach ($j->results as $jj) {
$connlnk = $a->get_baseurl() . '/follow/?url=' . $jj->url;
$o .= replace_macros($tpl, array('$url' => zrl($jj->url), '$name' => $jj->name, '$photo' => $jj->photo, '$inttxt' => ' ' . t('is interested in:'), '$conntxt' => t('Connect'), '$connlnk' => $connlnk, '$tags' => $jj->tags));
}
} else {
info(t('No matches') . EOL);
}
}
$o .= cleardiv();
$o .= paginate($a);
return $o;
}