/**
  * Search for records matching given arguments
  *
  * @param string                              $_filter json encoded
  * @param string                              $_paging json encoded
  * @param Tinebase_Controller_SearchInterface $_controller the record controller
  * @param string                              $_filterModel the class name of the filter model to use
  * @param bool                                $_getRelations
  * @param string                              $_totalCountMethod
  * @return array
  *
  * @todo It should be on Tinebase_Frontend_Json_Abstract
  */
 protected function _search($_filter, $_paging, Tinebase_Controller_SearchInterface $_controller, $_filterModel, $_getRelations = FALSE, $_totalCountMethod = self::TOTALCOUNT_CONTROLLER)
 {
     $decodedPagination = is_array($_paging) ? $_paging : Zend_Json::decode($_paging);
     $pagination = new Tinebase_Model_Pagination($decodedPagination);
     $filter = $this->_decodeFilter($_filter, $_filterModel);
     $records = $_controller->search($filter, $pagination, $_getRelations);
     $result = $this->_multipleRecordsToJson($records, $filter);
     return array('results' => array_values($result), 'totalcount' => $records instanceof Expressomail_Record_SearchTotalCountInterface ? $records->getSearchTotalCount() : ($_totalCountMethod == self::TOTALCOUNT_CONTROLLER ? $_controller->searchCount($filter) : count($result)), 'filter' => $filter->toArray(TRUE));
 }
 /**
  * Search for records matching given arguments
  *
  * @param string|array                        $_filter json encoded / array
  * @param string|array                        $_paging json encoded / array
  * @param Tinebase_Controller_SearchInterface $_controller the record controller
  * @param string                              $_filterModel the class name of the filter model to use
  * @param bool|array                          $_getRelations
  * @param string                              $_totalCountMethod
  * @return array
  */
 protected function _search($_filter, $_paging, Tinebase_Controller_SearchInterface $_controller, $_filterModel, $_getRelations = FALSE, $_totalCountMethod = self::TOTALCOUNT_CONTROLLER)
 {
     $decodedPagination = $this->_prepareParameter($_paging);
     $pagination = new Tinebase_Model_Pagination($decodedPagination);
     $filter = $this->_decodeFilter($_filter, $_filterModel);
     $records = $_controller->search($filter, $pagination, $_getRelations);
     $result = $this->_multipleRecordsToJson($records, $filter);
     return array('results' => array_values($result), 'totalcount' => $_totalCountMethod == self::TOTALCOUNT_CONTROLLER ? $_controller->searchCount($filter) : count($result), 'filter' => $filter->toArray(TRUE));
 }