public function redirectEditFormSubmitted(AppForm $form) { $values = $form->values; RedirectModel::replace($values); $this->template->redirects = RedirectModel::getAll(); $this->flashMessage('Přesměrování přidáno/upraveno'); $this->invalidateControl('redirecttable'); $form->setValues(array(), TRUE); if (!$this->isAjax()) { $this->redirect('this'); } }
function match(IHttpRequest $httpRequest) { $path = $httpRequest->getUrl()->getPath(); //look for redirect record $newurl = RedirectModel::getByOldUrl($path); //fix pathinfo bug - strip "/index.php/" from url if (!$newurl and preg_match('~^/index\\.php~', $path)) { $newurl = preg_replace('~^/index\\.php~', '', $path); } if ($newurl) { RedirectModel::hit($path); if ($p = RedirectModel::parseHashIdLang($newurl)) { $newurl = Environment::getLinkHelper()->pageLink($p[0], $p[1]); if ($newurl == NULL) { return NULL; } } header("Location: {$newurl}", true, 301); //TODO (ask) if comented, output twice :/ better? echo "Moved permanetly to <a href='{$newurl}'>{$newurl}</a>"; exit; } return NULL; }