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


PHP ca_objects::getNumComments方法代码示例

本文整理汇总了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;
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:30,代码来源:AlhalqaItemService.php

示例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;
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:49,代码来源:AlhalqaSearchService.php


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