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;
 }
 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;
 }