public function getCategoriesWithCount() { $ordering = CPS_StringOrdering('name', 'en', 'ascending'); $documents = $this->model->search('*', null, null, array('post' => 'no'), $ordering); $ad = new AdModel(); $result = array(); foreach ($documents as $id => $document) { $document->count = $ad->countAdsByCategory($document->id); $result[] = $document; } return $result; }
public function refineOrdering($ordering) { if ($ordering != null) { if ($ordering[0] == 'string') { return CPS_StringOrdering($ordering[1], 'en', $ordering[2]); } else { return CPS_NumericOrdering($ordering[1], $ordering[2]); } } else { return CPS_StringOrdering('type', 'en', 'ascending'); } }