get('DatabaseDriver'); if($map == null) { $map = array('published' => 1, 'unpublished' => 0, 'archived' => 2, 'trashed' => -2); } // Get nr of all states of events $query = $db->getQuery(true); $query->select(array('published', 'COUNT(published) as num')); $query->from($db->quoteName($tablename)); if ($tablename == "#__jem_categories") { $query->where('alias NOT LIKE "root"'); } $query->group('published'); $db->setQuery($query); $result = $db->loadObjectList("published"); $data = new stdClass(); $data->total = 0; foreach ($map as $key => $value) { if ($result) { // Check whether we have the current state in the DB result if(array_key_exists($value, $result)) { $data->$key = $result[$value]->num; $data->total += $data->$key; } else { $data->$key = 0; } } else { $data->$key = 0; } } return $data; } /** * Returns number of events for all possible states * * @return stdClass */ public function getEventsData() { return $this->getStateData('#__jem_events'); } /** * Returns number of venues for all possible states * * @return stdClass */ public function getVenuesData() { return $this->getStateData('#__jem_venues'); } /** * Returns number of categories for all possible states * * @return stdClass */ public function getCategoriesData() { return $this->getStateData('#__jem_categories'); } } ?>