本文整理汇总了PHP中modX::getCollectionGraph方法的典型用法代码示例。如果您正苦于以下问题:PHP modX::getCollectionGraph方法的具体用法?PHP modX::getCollectionGraph怎么用?PHP modX::getCollectionGraph使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类modX
的用法示例。
在下文中一共展示了modX::getCollectionGraph方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetchPosts
/**
* Fetch all posts for this thread
*
* @param mixed $post A reference to a disPost or ID of disPost to start the posts from
* @param array $options An array of options for sorting, limiting and display
* @return array
*/
public function fetchPosts($post = false, array $options = array())
{
$response = array();
$c = $this->xpdo->newQuery('disPost');
$c->innerJoin('disThread', 'Thread');
$c->where(array('thread' => $this->get('id')));
$response['total'] = $this->xpdo->discuss->controller->getPostCount('disThread', $this->get('id'));
$flat = $this->xpdo->getOption('flat', $options, true);
$limit = $this->xpdo->getOption('limit', $options, (int) $this->xpdo->getOption('discuss.post_per_page', $options, 10));
$start = $this->xpdo->getOption('start', $options, 0);
if ($flat) {
$sortBy = $this->xpdo->getOption('sortBy', $options, 'createdon');
$sortDir = $this->xpdo->getOption('sortDir', $options, 'ASC');
$c->sortby($this->xpdo->getSelectColumns('disPost', 'disPost', '', array($sortBy)), $sortDir);
if (empty($_REQUEST['print'])) {
$c->limit($limit, $start);
}
} else {
$c->sortby($this->xpdo->getSelectColumns('disPost', 'disPost', '', array('rank')), 'ASC');
}
if (!empty($post)) {
if (!is_object($post)) {
$post = $this->xpdo->getObject('disPost', $post);
}
if ($post) {
$c->where(array('disPost.createdon:>=' => $post->get('createdon')));
}
}
$c->bindGraph('{"Author":{"PrimaryDiscussGroup":{},"PrimaryGroup":{}},"EditedBy":{}}');
//$c->prepare();
//$cacheKey = 'discuss/thread/'.$thread->get('id').'/'.md5($c->toSql());
$response['results'] = $this->xpdo->getCollectionGraph('disPost', '{"Author":{"PrimaryDiscussGroup":{},"PrimaryGroup":{}},"EditedBy":{}}', $c);
return $response;
}
示例2: getUserGroupNames
/**
* Gets all the User Group names of the groups this user belongs to.
*
* @access public
* @return array An array of User Group names.
*/
public function getUserGroupNames()
{
$groupNames = array();
$id = $this->get('id') ? (string) $this->get('id') : '0';
if (isset($_SESSION["modx.user.{$id}.userGroupNames"]) && $this->xpdo->user->get('id') == $this->get('id')) {
$groupNames = $_SESSION["modx.user.{$id}.userGroupNames"];
} else {
$memberGroups = $this->xpdo->getCollectionGraph('modUserGroup', '{"UserGroupMembers":{}}', array('UserGroupMembers.member' => $this->get('id')));
if ($memberGroups) {
/** @var modUserGroup $group */
foreach ($memberGroups as $group) {
$groupNames[] = $group->get('name');
}
}
$_SESSION["modx.user.{$id}.userGroupNames"] = $groupNames;
}
return $groupNames;
}
示例3: getResourceGroupNames
/**
* Gets all the Resource Group names of the resource groups this resource is assigned to.
*
* @access public
* @return array An array of Resource Group names.
*/
public function getResourceGroupNames()
{
$resourceGroupNames = array();
$resourceGroups = $this->xpdo->getCollectionGraph('modResourceGroup', '{"ResourceGroupResources":{}}', array('ResourceGroupResources.document' => $this->get('id')));
if ($resourceGroups) {
/** @var modResourceGroup $resourceGroup */
foreach ($resourceGroups as $resourceGroup) {
$resourceGroupNames[] = $resourceGroup->get('name');
}
}
return $resourceGroupNames;
}