本文整理汇总了PHP中ca_objects::getNumComments方法的典型用法代码示例。如果您正苦于以下问题:PHP ca_objects::getNumComments方法的具体用法?PHP ca_objects::getNumComments怎么用?PHP ca_objects::getNumComments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ca_objects
的用法示例。
在下文中一共展示了ca_objects::getNumComments方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAllItemInfo
protected function getAllItemInfo()
{
$va_info = parent::getAllItemInfo();
if ($this->getTableName() == 'ca_objects' && is_array($va_info) && sizeof($va_info) > 0) {
$t_object = new ca_objects($va_info['object_id']['value']);
if (!$t_object->getPrimaryKey()) {
return $va_info;
}
// include number of 'likes' (comments)
$va_info['likes'] = (int) $t_object->getNumComments(null);
// include copyright holder
$vs_copyright_holder = $t_object->get('ca_entities.preferred_labels', array('restrictToRelationshipTypes' => 'copyright'));
if ($vs_copyright_holder) {
$va_info['copyright_holder'] = $vs_copyright_holder;
}
// include urls for reference img
$va_objects = $t_object->getRelatedItems('ca_objects', array('restrictToRelationshipTypes' => 'reference'));
if (!is_array($va_objects) || sizeof($va_objects) != 1) {
return $va_info;
}
$va_object = array_shift($va_objects);
$t_rel_object = new ca_objects($va_object['object_id']);
$va_rep = $t_rel_object->getPrimaryRepresentation(array('preview170', 'medium', 'alhalqa1000', 'alhalqa2000'));
if (!is_array($va_rep) || !is_array($va_rep['urls'])) {
return $va_info;
}
$va_info['reference_image_urls'] = $va_rep['urls'];
}
return $va_info;
}
示例2: search
protected function search($pa_bundles = null)
{
$va_return = parent::search($pa_bundles);
if ($this->getTableName() == 'ca_objects' && is_array($va_return['results']) && sizeof($va_return['results']) > 0) {
$pb_only_with_likes = (bool) $this->opo_request->getParameter('likesOnly', pInteger);
foreach ($va_return['results'] as $vn_k => &$va_result) {
$t_object = new ca_objects($va_result['object_id']);
if (!$t_object->getPrimaryKey()) {
continue;
}
// include number of 'likes' (comments)
$va_result['likes'] = (int) $t_object->getNumComments(null);
if ($pb_only_with_likes && !$va_result['likes']) {
unset($va_return['results'][$vn_k]);
continue;
}
// include copyright holder
$vs_copyright_holder = $t_object->get('ca_entities.preferred_labels', array('restrictToRelationshipTypes' => 'copyright'));
if ($vs_copyright_holder) {
$va_result['copyright_holder'] = $vs_copyright_holder;
}
// include urls for reference img
$va_objects = $t_object->getRelatedItems('ca_objects', array('restrictToRelationshipTypes' => 'reference'));
if (!is_array($va_objects) || sizeof($va_objects) != 1) {
continue;
}
$va_object = array_shift($va_objects);
$t_rel_object = new ca_objects($va_object['object_id']);
$va_rep = $t_rel_object->getPrimaryRepresentation(array('preview170', 'medium', 'alhalqa1000', 'alhalqa2000'));
if (!is_array($va_rep) || !is_array($va_rep['urls'])) {
continue;
}
$va_result['reference_image_urls'] = $va_rep['urls'];
}
if ($this->opo_request->getParameter('sort', pString) == 'likes') {
if (strtolower($this->opo_request->getParameter('sortDirection', pString)) == 'asc') {
usort($va_return['results'], function ($a, $b) {
return $a['likes'] - $b['likes'];
});
} else {
// default is desc
usort($va_return['results'], function ($a, $b) {
return $b['likes'] - $a['likes'];
});
}
}
}
return $va_return;
}