/** * Parse maps navigation * * @param AbstractController $controller * @param Application $application * @return void */ public static function parse(AbstractController $controller, Application $application) { if ($controller->hasView() && ($controller instanceof \Phire\Content\Controller\IndexController || $controller instanceof \Phire\Categories\Controller\IndexController)) { $body = $controller->response()->getBody(); if (strpos($body, '[{map_') !== false) { $ids = self::parseMapIds($body); if (count($ids) > 0) { $map = new Model\Map(); foreach ($ids as $id) { $body = str_replace('[{map_' . $id . '}]', $map->getMap($id), $body); } } $controller->response()->setBody($body); } } }
/** * Remove action method * * @return void */ public function remove() { if ($this->request->isPost()) { $map = new Model\Map(); $map->remove($this->request->getPost()); } $this->sess->setRequestValue('removed', true); $this->redirect(BASE_PATH . APP_URI . '/maps'); }
/** * Edit action method * * @param int $mid * @param int $id * @return void */ public function edit($mid, $id) { $map = new Model\Map(); $map->getById($mid); $this->prepareView('maps/locations/edit.phtml'); $this->view->title = 'Maps : ' . $map->name; $this->view->mid = $mid; $location = new Model\MapLocation(); $location->getById($id); $fields = $this->application->config()['forms']['Phire\\Maps\\Form\\MapLocation']; $fields[0]['map_id']['value'] = $mid; $fields[1]['title']['attributes']['onkeyup'] = 'phire.changeTitle(this.value);'; $this->view->location_name = $location->title; $this->view->form = new Form\MapLocation($fields); $this->view->form->addFilter('htmlentities', [ENT_QUOTES, 'UTF-8'])->setFieldValues($location->toArray()); if ($this->request->isPost()) { $this->view->form->setFieldValues($this->request->getPost()); if ($this->view->form->isValid()) { $this->view->form->clearFilters()->addFilter('html_entity_decode', [ENT_QUOTES, 'UTF-8'])->filter(); $location = new Model\MapLocation(); $location->update($this->view->form->getFields()); $this->view->id = $location->id; $this->sess->setRequestValue('saved', true); $this->redirect(BASE_PATH . APP_URI . '/maps/locations/edit/' . $mid . '/' . $location->id); } } $this->send(); }