public function treatLinkAction() { $this->getLayout()->getAdminHmenu()->add($this->getTranslator()->trans('menuLinks'), array('action' => 'index'))->add($this->getTranslator()->trans('menuActionNewLink'), array('action' => 'treat')); $categoryMapper = new CategoryMapper(); $linkMapper = new LinkMapper(); $this->getView()->set('cats', $categoryMapper->getCategories()); if ($this->getRequest()->getParam('id')) { $this->getView()->set('link', $linkMapper->getLinkById($this->getRequest()->getParam('id'))); } if ($this->getRequest()->isPost()) { $model = new LinkModel(); if ($this->getRequest()->getParam('id')) { $model->setId($this->getRequest()->getParam('id')); } $name = $this->getRequest()->getPost('name'); $link = trim($this->getRequest()->getPost('link')); if (empty($name)) { $this->addMessage('missingName', 'danger'); } elseif (empty($link)) { $this->addMessage('missingLink', 'danger'); } else { $model->setName($this->getRequest()->getPost('name')); $model->setLink($this->getRequest()->getPost('link')); $model->setBanner($this->getRequest()->getPost('banner')); $model->setDesc($this->getRequest()->getPost('desc')); $model->setCatId($this->getRequest()->getPost('catId')); $linkMapper->save($model); $this->addMessage('saveSuccess'); $this->redirect(array('action' => 'index')); } } }
public function redirectAction() { $linkMapper = new LinkMapper(); $linkModel = $linkMapper->getLinkById($this->getRequest()->getParam('link_id')); $linkModel->setHits($linkModel->getHits() + 1); $linkMapper->save($linkModel); header("location: " . $linkModel->getLink()); exit; }