public function validateAction() { $this->_helper->viewRenderer->setNoRender(); $this->_helper->getHelper('layout')->disableLayout(); $form = new Admin_Form_Template(); $form->isValid($this->_getAllParams()); $json = $form->getMessages(); header('Content-type: application/json'); echo Zend_Json::encode($json); }
public function editTemplateAction() { $key = $this->getKey(); $translator = \Zend_Registry::get('container')->getService('translator'); $form = new Admin_Form_Template(); $form->setMethod('post'); $metadata = $this->service->fetchMetadata($key); $form->setDefaults(array('content' => $this->service->fetchItem($key), 'cache_lifetime' => $metadata->type == 'tpl' ? $metadata->ttl : 0)); $request = $this->getRequest(); if ($request->isPost() && $form->isValid($request->getPost())) { $values = $form->getValues(); $this->service->storeItem($key, $values['content']); if ($metadata->type == 'tpl') { $this->service->storeMetadata($key, $values); $this->_helper->entity->flushManager(); } $cacheService = \Zend_Registry::get('container')->getService('newscoop.cache'); $cacheService->clearNamespace('template'); $this->_helper->flashMessenger($translator->trans("Template \$1 \$2.", array('$1' => basename($key), '$2' => $translator->trans('updated', array(), 'themes')), 'themes')); $this->_redirect(urldecode($this->_getParam('next')), array('prependBase' => false)); } $this->view->form = $form; }
public function editTemplateAction() { $key = $this->getKey(); $form = new Admin_Form_Template(); $form->setMethod('post'); $metadata = $this->service->fetchMetadata($key); $form->setDefaults(array('content' => $this->service->fetchItem($key), 'cache_lifetime' => $metadata->type == 'tpl' ? $metadata->ttl : 0)); $request = $this->getRequest(); if ($request->isPost() && $form->isValid($request->getPost())) { $values = $form->getValues(); $this->service->storeItem($key, $values['content']); if ($metadata->type == 'tpl') { $this->service->storeMetadata($key, $values); $this->_helper->entity->flushManager(); } $this->_helper->flashMessenger(getGS("Template '\$1' \$2.", basename($key), getGS('updated'))); $this->_redirect(urldecode($this->_getParam('next')), array('prependBase' => false)); } $this->view->form = $form; }