/** * Get all map locations * * @param int $mid * @param int $limit * @param int $page * @param string $sort * @return array */ public function getAll($mid, $limit = null, $page = null, $sort = null) { $order = $this->getSortOrder($sort, $page); if (null !== $limit) { $page = null !== $page && (int) $page > 1 ? $page * $limit - $limit : null; return Table\MapLocations::findBy(['map_id' => $mid], ['offset' => $page, 'limit' => $limit, 'order' => $order])->rows(); } else { return Table\MapLocations::findBy(['map_id' => $mid], ['order' => $order])->rows(); } }
/** * Get map with locations * * @param int $id * @return string */ public function getMap($id) { $map = Table\Maps::findById($id); if (isset($map->id)) { $mapData = $map->getColumns(); $mapData['map_id'] = 'phire-map-' . $id; $mapData['map_class'] = 'phire-map-div'; $mapData['locations'] = Table\MapLocations::findBy(['map_id' => $id])->rows(); $view = new View(__DIR__ . '/../../view/maps-public/map.phtml', $mapData); return $view->render(); } else { return ''; } }