/** * Get the entity type by it's ID * * @param integer $id * @return string */ public static function getEntityTypeByEntityId($id) { $id = (int) $id; $item = Kingboard_EveItem::getByItemId($id); if ($item) { if ((int) $item->Group['groupID'] === self::$groupIdDeployable) { return self::ENTITY_DEPLOYABLE; } switch ((int) $item->Category['categoryID']) { case self::$categoryIdStructure: return self::ENTITY_STRUCTURE; case self::$categoryIdNpc: return self::ENTITY_NPC; } } try { $api = new Pheal(); $apiResult = $api->eveScope->CharacterName(array('ids' => $id))->characters->toArray(); if (is_array($apiResult) && !empty($apiResult)) { $name = $apiResult[0]['name']; $item = Kingboard_EveItem::getInstanceByCriteria(array('typeName' => $name)); if ($item) { if ((int) $item->typeID === $id) { return self::ENTITY_NPC; } } return self::ENTITY_CHARACTER; } } catch (PhealException $e) { } return self::ENTITY_UNKNOWN; }
private function ParseItem($row) { // Build the standard item $item = array("typeID" => $row->typeID, "typeName" => @Kingboard_EveItem::getByItemId($row->typeID)->typeName, "flag" => $row->flag, "qtyDropped" => $row->qtyDropped, "qtyDestroyed" => $row->qtyDestroyed); // Check for nested items (container) if (isset($row['items'])) { $item['items'] = array(); foreach ($row['items'] as $innerRow) { $item['items'][] = $this->ParseItem($innerRow); } } return $item; }