public function categoryAction() { $catId = (int) $this->getRequestParam('id', 0); $categoriesTbl = new Category(); $cat = $categoriesTbl->getCategory($catId); if (!$cat) { $this->notFound(); } $componentMenu = new TopMenuComponent($this); $componentMenuResp = $componentMenu->toString(); $componentNotify = new NotifyComponent($this); $componentNotifyResp = $componentNotify->toString(); $form = new CategoryFormType($this); $form->fill($cat); if ($_POST) { if ($form->fillAndIsValid()) { if ($idNew = $form->save()) { if (is_array($idNew)) { $idNew = $catId; } $this->redirect('backend_category', array('id' => $idNew)); } } } $formR = $form->render(); $this->render(array('componentMenu' => $componentMenuResp, 'componentNotify' => $componentNotifyResp, 'form' => $formR), 'Backend/Category/category.html'); }
public function productAction() { $prodId = (int) $this->getRequestParam('id', 0); $productTbl = new Product(); $product = $productTbl->getProduct($prodId); if (!$product) { $this->notFound(); } $componentMenu = new TopMenuComponent($this); $componentMenuResp = $componentMenu->toString(); $componentNotify = new NotifyComponent($this); $componentNotifyResp = $componentNotify->toString(); $form = new ProductFormType($this); $form->fill($product); if ($_POST) { if ($form->fillAndIsValid()) { if ($idNew = $form->save()) { if (is_array($idNew)) { $idNew = $prodId; } $this->redirect('backend_product', array('id' => $idNew)); } } } $formR = $form->render(); $this->render(array('componentMenu' => $componentMenuResp, 'componentNotify' => $componentNotifyResp, 'form' => $formR), 'Backend/Product/product.html'); }
public function indexAction() { $component = new TopMenuComponent($this); $componentResp = $component->toString(); $componentNotify = new NotifyComponent($this); $componentNotifyResp = $componentNotify->toString(); $sess = App::getInstance()->getSession(); if ($this->getRequestParam('exit', false)) { $sess->set('login_id', null); $sess->set('login_name', null); $this->redirect('backend_index'); } $username = ''; if (!$sess->getByName('login_id') || !$sess->getByName('login_name')) { $formUser = new LoginFormType($this); if ($_POST) { $res = array(); $res['redirect'] = false; if ($formUser->fillAndIsValid()) { $tblUser = new Users(); $login = $tblUser->login($formUser->getData()); if (isset($login['id']) && isset($login['name'])) { $sess->set('login_id', $login['id']); $sess->set('login_name', $login['name']); $res['redirect'] = true; } else { $formUser->addFormError('Неверные данные'); } } $res['form'] = $formUser->render(); header('Content-Type: application/json'); echo json_encode($res); die; } $formLogin = $formUser->render(); } else { $formLogin = false; $username = $sess->getByName('login_name'); } $this->render(array('componentMenu' => $componentResp, 'formLogin' => $formLogin, 'username' => $username, 'componentNotify' => $componentNotifyResp), 'Backend/Default/index.html'); }