作者:ericoautoca
项目:module-security-zf
public function editarAction()
{
//definindo variaveis
$request = $this->getRequest();
$id = $this->Params('id');
$serviceGrupo = $this->getServiceLocator()->get('security-service-grupo');
$form = new Grupo();
$dadosGrupo = $this->getEm('Security\\Entity\\Grupo')->find($id)->toArray();
$form->setData($dadosGrupo);
// definindo acao conforme method da request
if ($request->isPost()) {
$form->setInputFilter(new \Security\Filter\Grupo());
$data = $request->getPost()->toArray();
$form->setData($data);
if ($form->isValid()) {
if ($serviceGrupo->update($data, 'Security\\Entity\\Grupo', $id)) {
$this->flashMessenger()->addSuccessMessage('Dados editados com sucesso!');
return $this->redirect()->toUrl($this->getUrlFromSubfolderApplication('/security/grupo'));
} else {
$this->flashMessenger()->addErrorMessage('Ocorreu algum erro ao editar os dados!');
return $this->redirect()->toRoute(array('controller' => 'grupo', 'action' => 'editar'));
}
}
}
$view = new ViewModel(array('form' => $form));
$view->setTemplate('security/grupo/form.phtml');
return $view;
}
作者:Indigo133
项目:c4
public function updateAction()
{
$request = $this->getRequest();
$recipe = $this->readService->findById($this->params('id'));
if (false === $this->authorizationService->isGranted('recipe.manage', $recipe)) {
throw new UnauthorizedException('Insufficient Permissions');
}
$viewModel = new ViewModel();
$viewModel->setTemplate('recipe/update');
$viewModel->setVariables(['form' => $this->form]);
$this->form->bind($recipe);
if ($request->isPost()) {
$this->form->setData($request->getPost());
if ($this->form->isValid()) {
try {
$this->writeService->save($this->form->getData());
$this->flashMessenger()->addSuccessMessage('Rezept erfolgreich aktualisiert');
$this->redirect()->toRoute('recipe/read/update', ['id' => $this->params('id')]);
} catch (\Exception $e) {
var_dump($e->getMessage());
}
}
}
$this->layout('layout/backend');
return $viewModel;
}
作者:patrov
项目:omeka-
public function browseAction()
{
$serviceLocator = $this->getServiceLocator();
$settings = $serviceLocator->get('Omeka\\Settings');
$form = new SettingForm($serviceLocator);
$data = ['administrator_email' => $settings->get('administrator_email'), 'installation_title' => $settings->get('installation_title'), 'time_zone' => $settings->get('time_zone'), 'pagination_per_page' => $settings->get('pagination_per_page'), 'property_label_information' => $settings->get('property_label_information'), 'use_htmlpurifier' => $settings->get('use_htmlpurifier')];
$form->setData($data);
$request = $this->getRequest();
if ($request->isPost()) {
$form->setData($this->params()->fromPost());
if ($form->isValid()) {
$formData = $form->getData();
foreach ($formData as $key => $value) {
$settings->set($key, $value);
}
$this->messenger()->addSuccess('Settings updated');
return $this->redirect()->toRoute(null, ['action' => 'browse'], true);
} else {
$this->messenger()->addError('There was an error during validation');
}
}
$view = new ViewModel();
$view->setVariable('form', $form);
return $view;
}
作者:qlari
项目:sls-repositor
public function processAction()
{
if (!$this->request->isPost()) {
return $this->redirect()->toRoute('register');
}
$post = $this->request->getPost();
$form = $this->getServiceLocator()->get('RegisterForm');
$form->setData($post);
if (!$form->isValid()) {
$model = new ViewModel(array('error' => 'There were one or more isues with your submission. Please correct them as
indicated below.', 'form' => $form));
$model->setTemplate('user/register/register');
return $model;
}
$data = $form->getData();
if ($this->checkIfNotRegistered($data)) {
// Create user
$this->createUser($form->getData());
return $this->redirect()->toRoute('register', array('action' => 'confirm'));
} else {
$model = new ViewModel(array('error' => 'You are already registered', 'form' => $form));
$model->setTemplate('user/register/register');
return $model;
}
}
作者:lpj001
项目:easypa
protected function setChildViews(ViewModel $view_page)
{
$view_menu = new ViewModel();
$view_menu->setTemplate('setting/common/menu');
$view_page->addChild($view_menu, 'menu');
return $view_page;
}
作者:ppLuiGu
项目:director-dashboar
public function indexAction()
{
$viewModel = new ViewModel();
// Disable Layout
$viewModel->setTerminal(true);
return $viewModel;
}
作者:bitrecruite
项目:CrossApplicantManage
/**
* Processes formular data
*
* @return \Zend\View\Model\ViewModel
*/
public function formAction()
{
$services = $this->getServiceLocator();
$repository = $services->get('repositories')->get('Applications/Application');
$mode = $this->params()->fromQuery('mode', 'new');
$appId = $this->params()->fromQuery('id');
$viewModel = new ViewModel();
if ('edit' == $mode) {
//$application = $repository->findByCommentId($appId);
$comment = $repository->findComment($appId);
} else {
$comment = new Comment();
$comment->setUser($this->auth()->getUser());
}
$this->acl($application, 'read');
$form = $services->get('forms')->get('Applications/CommentForm');
$form->bind($comment);
if ($this->getRequest()->isPost()) {
$form->setData($_POST);
if ($form->isValid()) {
if ('new' == $mode) {
$application = $repository->find($appId);
$application->comments->add($comment);
}
$viewModel->setVariable('isSaved', true);
}
}
$viewModel->setVariables(array('mode' => $mode, 'identifier' => $appId, 'commentForm' => $form));
return $viewModel;
}
作者:vrkansagar
项目:ZFBlo
public static function prepareCompilerView($view, $config, $services)
{
$renderer = $services->get('BlogRenderer');
$view->addRenderingStrategy(function ($e) use($renderer) {
return $renderer;
}, 100);
self::$layout = $layout = new Model\ViewModel();
$layout->setTemplate('layout');
$view->addResponseStrategy(function ($e) use($layout, $renderer) {
$result = $e->getResult();
$layout->setVariable('content', $result);
$page = $renderer->render($layout);
$e->setResult($page);
// Cleanup
$layout->setVariable('single', false);
$headTitle = $renderer->plugin('headtitle');
$headTitle->getContainer()->exchangeArray(array());
$headTitle->append('Zend Framework');
$headLink = $renderer->plugin('headLink');
$headLink->getContainer()->exchangeArray(array());
$headLink(array('rel' => 'shortcut icon', 'type' => 'image/vnd.microsoft.icon', 'href' => '/images/Application/favicon.ico'));
$headScript = $renderer->plugin('headScript');
$headScript->getContainer()->exchangeArray(array());
$headMeta = $renderer->plugin('headMeta');
$headMeta->getContainer()->exchangeArray(array());
foreach (array('sidebar', 'scripts') as $name) {
$placeholder = $renderer->placeholder($name);
$placeholder->exchangeArray(array());
}
}, 100);
}
作者:whoopl
项目:magento2-testin
/**
* Displays web configuration form
*
* @return array|ViewModel
*/
public function indexAction()
{
$setupInfo = new SetupInfo($_SERVER);
$view = new ViewModel(['autoBaseUrl' => $setupInfo->getProjectUrl(), 'autoAdminPath' => $setupInfo->getProjectAdminPath()]);
$view->setTerminal(true);
return $view;
}
作者:eotg191
项目:shineisp
public function processAction()
{
if (!$this->request->isPost()) {
return $this->redirect()->toRoute('zfcadmin/cmspages/settings');
}
try {
$settingsEntity = new \Base\Entity\Settings();
$post = $this->request->getPost();
$form = $this->getServiceLocator()->get('FormElementManager')->get('CmsSettings\\Form\\PageForm');
$form->setData($post);
if (!$form->isValid()) {
// Get the record by its id
$viewModel = new ViewModel(array('error' => true, 'form' => $form));
$viewModel->setTemplate('cms-settings/page/index');
return $viewModel;
}
$data = $form->getData();
// Cleanup the custom settings
$this->recordService->cleanup('Cms');
foreach ($data as $parameter => $value) {
if ($parameter == "submit") {
continue;
}
$settingsEntity->setModule('Cms');
$settingsEntity->setParameter($parameter);
$settingsEntity->setValue($value);
$this->recordService->save($settingsEntity);
// Save the data in the database
}
$this->flashMessenger()->setNamespace('success')->addMessage($this->translator->translate('The information have been saved.'));
} catch (\Exception $e) {
$this->flashMessenger()->setNamespace('error')->addMessage($e->getMessage());
}
return $this->redirect()->toRoute('zfcadmin/cmspages/settings');
}
作者:kaiocesa
项目:kar
public function saveAction()
{
$form = $this->getForm();
$request = $this->getRequest();
$id = $this->params('id');
if ($request->isPost()) {
$data = $request->getPost();
$form->setData($data);
$kart = new Kart();
$form->setInputFilter($kart->getInputFilter());
if ($form->isValid()) {
try {
$kart->exchangeArray($form->getData());
$this->serviceLocator->get('karts')->save($kart->getArrayCopy());
} catch (\Exception $e) {
}
return $this->redirect()->toRoute('application/default', ['controller' => 'kart']);
}
} elseif ($id) {
$kartData = $this->serviceLocator->get('karts')->findById($id);
$form->setData($kartData);
}
$viewModel = new ViewModel();
$viewModel->setVariables(['form' => $form]);
$viewModel->setTemplate('application/kart/form.phtml');
return $viewModel;
}
作者:uthando-cm
项目:uthando-session-manage
public function viewAction()
{
$id = (string) $this->params()->fromRoute('id', 0);
$viewModel = new ViewModel(array('session' => $this->getService()->getById($id)));
$viewModel->setTerminal(true);
return $viewModel;
}
作者:andreas-serl
项目:athene
public function indexAction()
{
$entity = $this->getEntity();
if (!$entity) {
$this->getResponse()->setStatusCode(404);
return false;
}
$type = $this->moduleOptions->getType($entity->getType()->getName());
if ($type->hasComponent('redirect')) {
/* @var $redirect RedirectOptions */
$redirect = $type->getComponent('redirect');
foreach ($entity->getChildren('link', $redirect->getToType()) as $child) {
if (!$child->isTrashed() && $child->hasCurrentRevision()) {
return $this->redirect()->toRoute('uuid/get', ['uuid' => $child->getId()]);
}
}
}
$model = new ViewModel(['entity' => $entity]);
$model->setTemplate('entity/page/default');
if ($this->params('isXmlHttpRequest', false)) {
$model->setTemplate('entity/view/default');
}
$this->layout('layout/3-col');
if (!$entity->hasCurrentRevision()) {
$this->layout('layout/2-col');
$model->setTemplate('entity/page/pending');
}
return $model;
}
作者:olivella
项目:ZendFrameworkCours
public function getAjaxDataAction()
{
$view = new ViewModel();
// Function used for not load some content.
$view->setTerminal(true);
return $view;
}
作者:AlexandrKozy
项目:ver_sit
public function processAction()
{
if (!$this->request->isPost()) {
return $this->redirect()->toRoute(NULL, array('controller' => 'index', 'action' => 'index'));
}
$post = $this->request->getPost();
$form = $this->getServiceLocator()->get('LoginForm');
$form->setData($post);
if (!$form->isValid()) {
$model = new ViewModel(array('error' => true, 'form' => $form));
$model->setTemplate('customers/login/index');
return $model;
}
/**
* проверка поступивших данных
*/
$this->getAuthService()->getAdapter()->setIdentity($post['login'])->setCredential($post['pass']);
$result = $this->getAuthService()->authenticate();
if ($result->isValid()) {
$customer = $this->getCustomerData($post['login']);
$this->getAuthService()->getStorage()->write($customer);
$this->redirect()->toRoute('info');
} else {
$model = new ViewModel(array('error' => true, 'form' => $form));
$model->setTemplate('customers/login/index');
return $model;
}
}
作者:alectejad
项目:lakar
public function autenticarAction()
{
$form = $this->getLoginForm();
$form->setInputFilter(new LoginValidator());
$postParams = $this->request->getPost();
$form->setData($postParams);
if (!$form->isValid()) {
// Falla la validación; volvemos a generar el formulario
$modelView = new ViewModel(array('loginForm' => $this->loginForm));
$modelView->setTemplate('admin/login/index');
return $modelView;
}
$view = array();
$email = $this->getRequest()->getPost("loginEmail");
$password = $this->getRequest()->getPost("loginPassword");
//echo $email.' - '.$password;die;
$resultado = $this->usuarioDao->aunteticar($email, $password);
// return new ViewModel(array('listaUsuario' => $resultado,
// 'titulo' => $titulo));
if ($resultado) {
$view['login'] = true;
}
$view['titulo'] = 'Admin Autenticacion';
return new ViewModel($view);
}
作者:houzoum
项目:fm
public function serviceJsonAction()
{
// your code here ...
$ViewModel = new ViewModel(array('data' => array('firstParam' => 'Value1', 'secondParam' => 'Value2')));
$ViewModel->setTerminal(true);
return $ViewModel;
}
作者:jmlerou
项目:zfc-rbac-applicatio
public function ctrlEditAction()
{
$view = new ViewModel();
$view->setTemplate('application/permissions/simple-permission-guard');
$view->setVariables(['permission' => 'edit']);
return $view;
}
作者:blackhack12
项目:DISPO-AGRINA
public function mantenimientoAction()
{
try {
$viewModel = new ViewModel();
$EntityManagerPlugin = $this->EntityManagerPlugin();
//Controla el acceso a la informacion, solo accedera si es administrador
$SesionUsuarioPlugin = $this->SesionUsuarioPlugin();
$respuesta = $SesionUsuarioPlugin->isLoginAdmin();
if ($respuesta == false) {
return false;
}
$ClienteBO = new ClienteBO();
$ClienteBO->setEntityManager($EntityManagerPlugin->getEntityManager());
$condiciones['criterio_busqueda'] = $this->params()->fromPost('criterio_busqueda', '');
$condiciones['estado'] = $this->params()->fromPost('busqueda_estado', '');
$condiciones['sincronizado'] = $this->params()->fromPost('busqueda_sincronizado', '');
$result = $ClienteBO->listado($condiciones);
$viewModel->criterio_busqueda = $condiciones['criterio_busqueda'];
$viewModel->busqueda_estado = \Application\Classes\ComboGeneral::getComboEstado($condiciones['estado'], "<ESTADO>");
$viewModel->busqueda_sincronizado = \Application\Classes\ComboGeneral::getComboSincronizado($condiciones['sincronizado'], "<SINCRONIZADO>");
$viewModel->result = $result;
$this->layout($SesionUsuarioPlugin->getUserLayout());
$viewModel->setTemplate('dispo/cliente/mantenimiento.phtml');
return $viewModel;
} catch (\Exception $e) {
$excepcion_msg = utf8_encode($this->ExcepcionPlugin()->getMessageFormat($e));
$response = $this->getResponse();
$response->setStatusCode(500);
$response->setContent($excepcion_msg);
return $response;
}
}
作者:esas
项目:dream-cm
/**
* Index page
*/
public function indexAction()
{
$this->getResponse()->getHeaders()->addHeaders(['Content-type' => 'text/plain']);
$view = new ViewModel();
$view->setTerminal(true);
return $view;
}