public function indexAction() { $this->getLayout()->getAdminHmenu()->add($this->getTranslator()->trans('menuLinks'), array('action' => 'index')); $linkMapper = new LinkMapper(); $categoryMapper = new CategoryMapper(); if ($this->getRequest()->getPost('action') == 'delete' && $this->getRequest()->getPost('check_cats')) { foreach ($this->getRequest()->getPost('check_cats') as $catId) { $categoryMapper->delete($catId); } } if ($this->getRequest()->getPost('action') == 'delete' && $this->getRequest()->getPost('check_links')) { foreach ($this->getRequest()->getPost('check_links') as $linkId) { $linkMapper->delete($linkId); } } if ($this->getRequest()->getParam('cat_id')) { $links = $linkMapper->getLinks(array('cat_id' => $this->getRequest()->getParam('cat_id'))); $categorys = $categoryMapper->getCategories(array('parent_id' => $this->getRequest()->getParam('cat_id'))); } else { $links = $linkMapper->getLinks(array('cat_id' => 0)); $categorys = $categoryMapper->getCategories(array('parent_id' => 0)); } $this->getView()->set('links', $links); $this->getView()->set('categorys', $categorys); }
public function indexAction() { $linkMapper = new LinkMapper(); $categoryMapper = new CategoryMapper(); if ($this->getRequest()->getParam('cat_id')) { $category = $categoryMapper->getCategoryById($this->getRequest()->getParam('cat_id')); $parentCategories = $categoryMapper->getCategoriesForParent($category->getParentId()); $this->getLayout()->getHmenu()->add($this->getTranslator()->trans('menuLinks'), array('action' => 'index')); if (!empty($parentCategories)) { foreach ($parentCategories as $parent) { $this->getLayout()->getHmenu()->add($parent->getName(), array('action' => 'index', 'cat_id' => $parent->getId())); } } $this->getLayout()->getHmenu()->add($category->getName(), array('action' => 'index', 'cat_id' => $this->getRequest()->getParam('cat_id'))); $links = $linkMapper->getLinks(array('cat_id' => $this->getRequest()->getParam('cat_id'))); $categorys = $categoryMapper->getCategories(array('parent_id' => $this->getRequest()->getParam('cat_id'))); } else { $this->getLayout()->getHmenu()->add($this->getTranslator()->trans('menuLinks'), array('action' => 'index')); $links = $linkMapper->getLinks(array('cat_id' => 0)); $categorys = $categoryMapper->getCategories(array('parent_id' => 0)); } $this->getView()->set('links', $links); $this->getView()->set('categorys', $categorys); }