/** * Gets the number of entities a query of one type will return * @param string $status Either Live, Pending, Archived... (optional) * @param int $type type_id (or blank for default) * @return int number of results */ function get_one_count($status = 'Live', $type = '') { if (!$type) { if ($this->type[0]) { $type = $this->type[0]; } else { return 0; } } $new_e = new entity_selector($this->site_id); $sharing = ''; if ($this->owns) { $sharing .= 'owns'; } if ($this->borrows) { $sharing .= 'borrows'; } $new_e->swallow(get_entities_by_type_object($type, $this->site_id, $sharing)); $new_e->swallow($this); if ($status != 'All') { $new_e->add_relation('entity.state = "' . $status . '"'); } else { $new_e->add_relation('entity.state != "Archived"'); } if ($this->union) { $key_search = array_flip($new_e->fields); foreach ($this->diff['fields'] as $k => $union) { $new_e->fields = array_diff($new_e->fields, $this->diff['fields'][$k]); $new_e->tables = array_diff_assoc($new_e->tables, $this->diff['tables'][$k]); $new_e->relations = array_diff($new_e->relations, $this->diff['relations'][$k]); } } return $new_e->get_count(); }