当前位置: 首页>>代码示例>>PHP>>正文


PHP Relation::count_relations方法代码示例

本文整理汇总了PHP中Relation::count_relations方法的典型用法代码示例。如果您正苦于以下问题:PHP Relation::count_relations方法的具体用法?PHP Relation::count_relations怎么用?PHP Relation::count_relations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Relation的用法示例。


在下文中一共展示了Relation::count_relations方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _render_friends

    function _render_friends($scope) {
	$section = ($scope == 'internal') ? 'friends' : 'friends_ext';
	$section_singular = $this->section_singular_names[$section];
	$page = (int)@$_REQUEST['friend_page'];
	$friend_state =& $this->state[$section];

	// paging controls
	$total_friends = Relation::count_relations($this->user->user_id, $scope);
	$total_pages = (int)ceil((float)$total_friends / $this->friends_per_page);
	if ($page > $total_pages) $page = $total_pages;
	if ($page < 1) $page = 1;
	$paging = "Show page: ";
	for ($i = 1; $i < $total_pages+1; ++$i) {
	  if ($i == $page) {
	    $paging .= "$i ";
	  } else {
	    $paging .= "<a href=\"javascript:badge.reload_section('badge_$section', '$this->url/$this->badge_tag/$section?friend_page=$i');\">$i</a> ";
	  }
	}
	$first_friend = ($page-1)*$this->friends_per_page + 1;
	$last_friend = min($first_friend + $this->friends_per_page - 1, $total_friends);
	$paging .= "(showing $first_friend-$last_friend of $total_friends friends)";

	// 'showing XXX' link
	$showing = $this->make_showing_link($friend_state, $section, "friend_page=$page");

	// facewall display
	$facewall = "";
	foreach (Relation::get_all_relations($this->user->user_id, 0, FALSE, $this->friends_per_page, $page, 'created', 'desc', $scope) as $rel) {
	    $facewall .= '<div id="'.$section_singular.'_'.($scope == 'internal' ? $rel['user_id'] : md5($rel['user_id'])).'">'.$this->render_friend_image($rel, $scope).'</div>';
	}

	// outer template
	return <<<ENS
<p>$showing</p>

<!--<p>How many items to show at once: <select id="item_count" onchange="badge.update()">
<option value="5">5</option>
<option value="10">10</option>
<option value="15" selected="selected">15</option>
<option value="20">20</option>
</select></p>-->

<div>
$facewall
<div style="clear: both"></div>
</div>

<p>$paging</p>
ENS;
    }
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:51,代码来源:badge_create.php

示例2: peopleaggregator_getUserRelations

function peopleaggregator_getUserRelations($args)
{
    $login = $args['login'];
    $page = $args['page'];
    $perpage = $args['resultsPerPage'];
    //	$detail = $args['detailLevel'];
    $imageSize = $args['profileImageSize'];
    if (preg_match("/^(\\d+)x(\\d+)\$/", $imageSize, $m)) {
        $imageWidth = (int) $m[1];
        $imageHeight = (int) $m[2];
    } else {
        $imageWidth = $imageHeight = 0;
    }
    // look up user ID
    $user = new User();
    $user->load($login);
    $total = Relation::count_relations($user->user_id);
    $total_pages = api_n_pages($total, $perpage);
    $relations_out = array();
    foreach (Relation::get_all_relations($user->user_id, 0, FALSE, $perpage, $page) as $rel) {
        $rel_out = array('id' => 'user:' . $rel['user_id'], 'login' => $rel['login_name'], 'relation' => $rel['relation_type'], 'url' => PA::$url . PA_ROUTE_USER_PUBLIC . '/' . $rel['user_id']);
        $img_info = api_resize_user_image($rel['picture'], $imageWidth, $imageHeight);
        if ($img_info) {
            $rel_out['image'] = $img_info;
        }
        $relations_out[] = $rel_out;
    }
    if (sizeof($relations_out)) {
        $first = ($page - 1) * $perpage + 1;
        $msg = "Retrieved relations {$first}-" . ($first + sizeof($relations_out)) . " of {$total} for user {$user->login_name}.";
    } else {
        $msg = "Retrieved zero relations.";
        if ($page > $total_pages) {
            $msg .= "  Try specifying a page number between 1 and {$total_pages}.";
        }
    }
    return array('success' => TRUE, 'msg' => $msg, 'login' => $user->login_name, 'totalPages' => $total_pages, 'resultsPerPage' => $perpage, 'totalResults' => $total, 'page' => $page, 'relations' => $relations_out);
}
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:38,代码来源:api_impl.php


注:本文中的Relation::count_relations方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。