public function editAction() { $data = $this->getRequest()->getPost('data'); $submit = $this->getRequest()->getPost('submit'); $id = $this->_getParam('id'); $data['lang'] = $this->_getParam('langFilter'); /* get all modules */ $criteria['application_id'] = $this->_applicationId; //check if cancel button is pressed if ($this->_formHelper->isCancel()) { //cancel form return $this->_formHelper->returnCancel($this->view->url(array('action' => 'index')), $this->translate('Action canceled')); } //create form object $form = new Cms_Form_RouteRedirect($data); //postback - save? if ($this->_formHelper->isSave()) { //check if valid if ($form->isValid()) { $values = $form->getValues(); //create entity object from submitted values, and save $route = new Cms_Model_Route($values); $route->set_application_id($this->_applicationId); $route->set_path("cms/redirect/index"); $route->set_params("url/" . urlencode($route->get_params())); Cms_Model_RouteMapper::getInstance()->save($route); //save done, return success return $this->_formHelper->returnSuccess($this->view->url(array('action' => 'index')), $this->translate('Route saved.')); } else { //we have errors - return json or continue $this->_formHelper->returnError($form->getMessages()); } } elseif (!$this->_formHelper->getRequest()->isPost()) { //edit action if (isset($id) && $id > 0) { $route = new Cms_Model_Route(); if (!Cms_Model_RouteMapper::getInstance()->find($id, $route)) { throw new Exception("Route not found"); } $data = $route->toArray(); $data["params"] = urldecode(substr($data["params"], 4)); //populate form with data $form->setData($data); } } $this->view->languages = Application_Model_TranslateMapper::getInstance()->getLanguages(); $page = new Cms_Model_Page(); if (isset($data['page_id'])) { Cms_Model_PageMapper::getInstance()->find($data['page_id'], $page); } $this->view->page_title = $page->get_title(); $this->view->langFilter = $data['lang']; $data["path"] = "cms/redirect/index"; $this->view->data = $data; }
public function contactDeleteAction() { $id = $this->_getParam('contact_id'); $contact = new Contact_Model_Contact(); if (!Contact_Model_ContactMapper::getInstance()->find($id, $contact)) { return $this->_formHelper->returnError($this->translate('Contact not found.')); } Contact_Model_ContactMapper::getInstance()->delete($contact); return $this->_formHelper->returnSuccess($this->view->url(array('action' => 'contact-list')), $this->translate('Contact deleted.')); }
public function roleEditAction() { $data = $this->getRequest()->getPost('data'); $id = $this->_getParam('id'); //check if cancel button is pressed if ($this->_formHelper->isCancel()) { //cancel form return $this->_formHelper->returnCancel($this->view->url(array('action' => 'role')), $this->translate('Action canceled')); } //create form object $form = new Auth_Form_Role($data); //postback - save? if ($this->_formHelper->isSave()) { //check if valid if ($form->isValid()) { $values = $form->getValues(); //create entity object from submitted values, and save $role = new Auth_Model_Role($values); Auth_Model_RoleMapper::getInstance()->save($role); //save done, return success return $this->_formHelper->returnSuccess($this->view->url(array('action' => 'role')), $this->translate('Role saved.')); } else { //we have errors - return json or continue $this->_formHelper->returnError($form->getMessages()); } } elseif (!$this->_formHelper->getRequest()->isPost()) { //edit action if (isset($id) && $id > 0) { $role = new Auth_Model_Role(); if (!Auth_Model_RoleMapper::getInstance()->find($id, $role)) { throw new Exception("Role not found"); } //fetch data $data = $role->toArray(); //populate form with data $form->setData($data); } } $criteria = array(); $roles = Auth_Model_RoleMapper::getInstance()->fetchAll($criteria); $this->view->roles = $roles; $this->view->data = $data; }
public function editAction() { $data = $this->getRequest()->getPost('data'); $submit = $this->getRequest()->getPost('submit'); $id = $this->_getParam('id'); $langFilter = $this->_getParam('langFilter'); //check if cancel button is pressed if ($this->_formHelper->isCancel()) { //cancel form return $this->_formHelper->returnCancel($this->view->url(array('action' => 'index')), $this->translate('Action canceled')); } //create form object $form = new Translation_Form_Menu($data); //postback - save? if ($this->_formHelper->isSave()) { //check if valid if ($form->isValid()) { $values = $form->getValues(); //create entity object from submitted values, and save $menu = new Translation_Model_Menu($values); Translation_Model_MenuMapper::getInstance()->save($menu); //save done, return success return $this->_formHelper->returnSuccess($this->view->url(array('action' => 'index')), $this->translate('Menu saved.')); } else { //we have errors - return json or continue $this->_formHelper->returnError($form->getMessages()); } } elseif (!$this->_formHelper->getRequest()->isPost()) { //edit action if (isset($id) && $id > 0) { $menu = new Translation_Model_Menu(); if (!Translation_Model_MenuMapper::getInstance()->find($id, $menu)) { throw new Exception("Menu not found"); } //fetch data $data = $menu->toArray(); //populate form with data $form->setData($data); } } $this->view->data = $data; }
public function userDeleteAction() { $id = $this->_getParam('id'); $user = new Auth_Model_User(); if (!Auth_Model_UserMapper::getInstance()->find($id, $user)) { return $this->_formHelper->returnError($this->translate('User not found.')); } Auth_Model_UserMapper::getInstance()->softDelete($user); //save done, return success return $this->_formHelper->returnSuccess($this->view->url(array('action' => 'userDelete')), $this->translate('User deleted.')); }
public function contactDeleteAction() { $id = $this->_getParam('contact_id'); $entityClassName = $this->getEntityClassName(); $contact = new $entityClassName(); $mapper = $this->getMapper(); if (!$mapper->find($id, $contact)) { return $this->_formHelper->returnError($this->translate('Contact not found.')); } $mapper->delete($contact); return $this->_formHelper->returnSuccess($this->view->url(array('action' => 'index')), $this->translate('Contact deleted.')); }
public function editAction() { $data = $this->getRequest()->getPost('data'); $submit = $this->getRequest()->getPost('submit'); $formTab = $this->getRequest()->getUserParam('tab', "Ga"); $id = $this->_applicationId; //check if cancel button is pressed if ($this->_formHelper->isCancel()) { //cancel form return $this->_formHelper->returnCancel($this->view->url(array('action' => 'index')), $this->translate('Action canceled')); } $application = new Application_Model_Application(); if (!Application_Model_ApplicationMapper::getInstance()->find($id, $application)) { throw new Exception("Configuration not found"); } $this->view->data = $application->toArray(); $bootstrap = $this->getInvokeArg('bootstrap'); $config = $bootstrap->getOptions(); $this->view->clientId = isset($config['googleapi']['analitycs']['clientId']) && $config['googleapi']['analitycs']['clientId'] != '' ? $config['googleapi']['analitycs']['clientId'] : ''; $formClassName = "Admin_Form_Config" . $formTab; if (!class_exists($formClassName)) { $this->_formHelper->returnError("ne postoji"); // Mare Srbine } //create form object $form = new $formClassName($data); $errors = array(); //postback - save? if ($this->_formHelper->isSave()) { //check if valid if ($form->isValid()) { $values['settings'] = $application->get_settings(); $formValues = $form->getValues(); switch ($formTab) { case "Ga": $values['settings']['tags']['ga']['tracking_id'] = $formValues['tracking_id']; $values['settings']['tags']['ga']['active'] = $formValues['ga_active'] == "true" ? true : false; break; case "GaView": $values['settings']['tags']['ga']['view_id'] = $formValues['view_id']; break; } //create entity object from submitted values, and save $application = new Application_Model_Application($values); $application->set_id($this->_applicationId); //new entity Application_Model_ApplicationMapper::getInstance()->save($application); //save done, return success return $this->_formHelper->returnSuccess($this->view->url(array('action' => 'index')), $this->translate('Configuration saved.')); } else { //we have errors - return json or continue $this->_formHelper->returnError($form->getMessages()); } } }
public function editMainMenuAction() { $data = $this->getRequest()->getPost('data'); $submit = $this->getRequest()->getPost('submit'); $id = $this->_getParam('id'); //create form object $form = new Cms_Form_Menu($data); if ($form->isValid()) { $values = $form->getValues(); $menu = new Cms_Model_Menu($values); Cms_Model_MenuMapper::getInstance()->save($menu); } else { //we have errors - return json or continue $this->_formHelper->returnError($form->getMessages()); } $data = array('menu' => Cms_Model_MenuMapper::getInstance()->getMenus(), 'success' => true, 'message' => $this->translate("New Menu added"), 'selected' => $menu->get_code()); $this->_helper->json->sendJson($data); }
public function pageDeleteAction() { $id = $this->_getParam('page_id'); $page = new Cms_Model_Page(); if (!Cms_Model_PageMapper::getInstance()->find($id, $page)) { return $this->_formHelper->returnError($this->translate('Page not found.')); } if ((int) $page->get_application_id() != $this->_applicationId) { return $this->_formHelper->returnError($this->translate('Cannot delete this Page.')); } //check if page is in use if (Cms_Model_PageMapper::getInstance()->isInUse($page)) { return $this->_formHelper->returnError($this->translate('This page is in use in menus or routes.')); } Cms_Model_PageMapper::getInstance()->delete($page); //save done, return success return $this->_formHelper->returnSuccess($this->view->url(array('action' => 'page')), $this->translate('Page deleted.')); }
public function configAction() { $data = $this->getRequest()->getPost('data'); $submit = $this->getRequest()->getPost('submit'); $formTab = $this->getRequest()->getUserParam('tab', "Sitemap"); $id = $this->_applicationId; //check if cancel button is pressed if ($this->_formHelper->isCancel()) { //cancel form return $this->_formHelper->returnCancel($this->view->url(array('action' => 'index')), $this->translate('Action canceled')); } $module = new Application_Model_Module(); //read contact module if (!Application_Model_ModuleMapper::getInstance()->findByCode("cms", $module)) { throw new Exception("CMS module not found"); } $this->view->menus = Cms_Model_MenuMapper::getInstance()->getMenus(); $this->view->data = $module->toArray(); $formClassName = "Cms_Form_Config" . $formTab; if (!class_exists($formClassName)) { $this->_formHelper->returnError("ne postoji"); } //create form object $form = new $formClassName($data); //postback - save? if ($this->_formHelper->isSave()) { //check if valid if ($form->isValid()) { $setings = $module->get_settings(); $setings['sitemap'] = $form->getValues(); //create module entity object $module->set_settings(json_encode($setings)); $module->set_data(json_encode($module->get_data())); //new entity Application_Model_ModuleMapper::getInstance()->save($module); //save done, return success return $this->_formHelper->returnSuccess($this->view->url(array('action' => 'config')), $this->translate('Configuration saved.')); } else { //we have errors - return json or continue $this->_formHelper->returnError($form->getMessages()); } } // print_r($data);die; }
public function exportToExcelAction() { $data = $this->getRequest()->getPost('data'); $data['grid_params'] = json_decode($data["grid_params"], true); $submit = $this->getRequest()->getPost('submit'); if ($this->_formHelper->isCancel()) { //cancel form return $this->_formHelper->returnCancel($this->view->url(array('action' => 'index')), $this->translate('Action cancelled.')); } if ($this->getRequest()->isPost()) { if (isset($data["language_id"]) && count($data["language_id"]) > 0) { return $this->_formHelper->returnSuccess($this->view->url(array('action' => 'save-excel', 'data' => json_encode($data))), $this->translate('Translation successfully exported. Save the file.'), $data); // } else { $this->_formHelper->returnError(array("language_id" => array("isEmpty" => $this->translate("Select the column you want to export.")))); } } else { $data = $this->getRequest()->getParams(); $translateLanguages = Translation_Model_TranslationMapper::getInstance()->getTranslateLanguage(); $this->view->translateLanguages = $translateLanguages; $grid_params = array('_search' => $data['_search'], 'rows' => $data['rows'], 'page' => $data['page'], 'sidx' => $data['sidx'], 'sord' => $data['sord']); $this->view->grid_params = json_encode($grid_params); } }
public function setEditAction() { $data = $this->getRequest()->getPost('data'); if ($this->_formHelper->isCancel()) { //cancel form return $this->_formHelper->returnCancel($this->view->url(array('action' => 'category')), $this->translate('Action canceled')); } //create form object $form = new Cms_Form_CategorySet($data); if ($this->_formHelper->isSave()) { if ($form->isValid()) { $values = $form->getValues(); $categorySet = new Cms_Model_CategorySet($values); Cms_Model_CategorySetMapper::getInstance()->save($categorySet); $data = array('success' => true, 'set' => Cms_Model_CategorySetMapper::getInstance()->getCategorySets(), 'message' => $this->translate("New Category added"), 'selected' => $categorySet->get_id()); $this->_helper->json->sendJson($data); } else { //we have errors - return json or continue $this->_formHelper->returnError($form->getMessages()); } } $modules = Application_Model_ModuleMapper::getInstance()->fetchAll(array('application_id' => $this->_applicationId)); $this->view->modules = $modules; }
public function redirectLanding($message = 'Thank you') { return $this->_formHelper->returnSuccess($this->view->url(array('module' => 'contact', 'controller' => $this->_request->getControllerName(), 'action' => 'landing')), $this->translate($message)); }
public function editAction() { //load params $this->_globalSettings = HCMS_Utils::loadThemeConfig('config.php', 'contact'); $fieldTypes = HCMS_Utils::loadThemeConfig('types.php', 'contact'); if ($this->_request->getParam('form_id')) { $this->_formId = $this->_request->getParam('form_id'); } if (!isset($this->_globalSettings['forms'][$this->_formId])) { throw new Exception("Form not found"); } $this->_formParams = $this->_globalSettings['forms'][$this->_formId]; $this->_fields = Contact_Form_Generic::getFieldsArr($fieldTypes, $this->_formParams['fields']); $data = $this->getRequest()->getPost('data'); $id = $this->_getParam('id'); //check if cancel button is pressed if ($this->_formHelper->isCancel()) { //cancel form return $this->_formHelper->returnCancel($this->view->url(array('action' => 'index')), $this->translate('Action canceled')); } //create form object $form = new Contact_Form_AdminSubscribe($data); //postback - save? if ($this->_formHelper->isSave()) { //check if valid if ($form->isValid()) { $values = $form->getValues(); $subscription = new Contact_Model_Subscription($values); if (isset($data['id'])) { $oldSubscription = new Contact_Model_Subscription(); if (Contact_Model_SubscriptionMapper::getInstance()->find($data['id'], $oldSubscription) && $oldSubscription->get_status() != $subscription->get_status()) { $dt = date("Y-m-d H:i:s"); switch ($subscription->get_status()) { case 'subscribed': $subscription->set_subscribed_dt($dt); break; case 'unsubscribed': $subscription->set_unsubscribed_dt($dt); break; default: break; } } } Contact_Model_SubscriptionMapper::getInstance()->save($subscription); //sending done, return success return $this->_formHelper->returnSuccess($this->view->url(array('action' => 'index')), $this->translate('Saved')); } else { $this->_formHelper->returnError($form->getMessages()); } } elseif (!$this->_formHelper->getRequest()->isPost()) { //edit action if (isset($id) && $id > 0) { $subscription = new Contact_Model_Subscription(); if (!Contact_Model_SubscriptionMapper::getInstance()->find($id, $subscription)) { throw new Exception("Record not found"); } //fetch data $data = $subscription->toArray(); //populate form with data $form->setData($data); } } $this->view->data = $data; $this->view->fields = $this->_fields; $this->view->formParams = $this->_formParams; $this->view->formId = $this->_formId; }
public function editAction() { $data = $this->getRequest()->getPost('data'); $submit = $this->getRequest()->getPost('submit'); $formTab = $this->getRequest()->getUserParam('tab', "General"); $id = $this->_applicationId; //check if cancel button is pressed if ($this->_formHelper->isCancel()) { //cancel form return $this->_formHelper->returnCancel($this->view->url(array('action' => 'index')), $this->translate('Action canceled')); } $application = new Application_Model_Application(); if (!Application_Model_ApplicationMapper::getInstance()->find($id, $application)) { throw new Exception("Configuration not found"); } $this->view->emailTransportTypeOptions = Application_Model_Application::getEmailTransportTypeOptions(); $this->view->data = $application->toArray(); $formClassName = "Admin_Form_Config" . $formTab; if (!class_exists($formClassName)) { $this->_formHelper->returnError("ne postoji"); // Mare Srbine } $formConfigParams = ""; $formConfigToEmails = ""; switch ($formTab) { case "Email": $formConfigParams = new Admin_Form_ConfigParameters($data['parameters']); foreach ($data['to_emails'] as $to_emails) { $formConfigToEmails[] = new Admin_Form_ConfigToEmails($to_emails); } break; case "Upload": if (isset($data['upload'])) { foreach ($data['upload'] as $upload) { $formConfigUploads[] = new Admin_Form_ConfigUploads($upload); } } if (isset($data['default_upload'])) { foreach ($data['default_upload'] as $defaultUpload) { $formConfigDefaultUploads[] = new Admin_Form_ConfigUploads($defaultUpload); } } break; default: break; } //create form object $form = new $formClassName($data); $errors = array(); //postback - save? if ($this->_formHelper->isSave()) { //check if valid if ($form->isValid()) { switch ($formTab) { case "Email": $email_settings = $application->get_email_settings(); unset($email_settings['to_emails']); unset($email_settings['parameters']); $values['email_settings'] = $form->getValues(); // print_r(array_diff_assoc($application->get_email_settings(), $form->getValues()));die; if ($formConfigParams->isValid()) { $values['email_settings']['parameters'] = $formConfigParams->getValues(); } else { $errors[] = $formConfigParams->getMessages(); } foreach ($formConfigToEmails as $formConfigToEmail) { if ($formConfigToEmail->isValid()) { $values['email_settings']['to_emails'][] = $formConfigToEmail->getValues(); } else { $errors[] = $formConfigToEmail->getMessages(); } } if (count($errors) > 0) { $this->_formHelper->returnError($errors[0]); } $values['email_settings'] = $this->_mergeArrays($email_settings, $values['email_settings']); break; case "Fb": $values['fb_settings'] = $form->getValues(); $values['fb_settings']['login_params']['scope'] = $data['login_params']['scope']; $values['fb_settings']['login_params']['redirect_uri'] = $data['login_params']['redirect_uri']; break; case "Twitter": $values['twitter_settings'] = $form->getValues(); break; case "Og": $values['og_settings'] = $form->getValues(); break; case "Notes": $notes = $form->getValues(); $values['settings'] = $application->get_settings(); $values['settings']['notes'] = $notes['notes']; break; case "Upload": $values['settings'] = $application->get_settings(); unset($values['settings']['upload']); unset($values['settings']['default_upload']); if (isset($formConfigUploads)) { foreach ($formConfigUploads as $formConfigUpload) { if ($formConfigUpload->isValid()) { $value = $formConfigUpload->getValues(); isset($value['extensions']) ? $values['settings']['upload']['extensions'][] = $value['extensions'] : ''; isset($value['mimetypes']) ? $values['settings']['upload']['mimetypes'][] = $value['mimetypes'] : ''; } else { $errors[] = $formConfigUpload->getMessages(); } } } if (isset($formConfigDefaultUploads)) { foreach ($formConfigDefaultUploads as $formConfigDefaultUpload) { if ($formConfigDefaultUpload->isValid()) { $value = $formConfigDefaultUpload->getValues(); isset($value['default_extensions']) ? $values['settings']['default_upload']['default_extensions'][] = $value['default_extensions'] : ''; isset($value['default_mimetypes']) ? $values['settings']['default_upload']['default_mimetypes'][] = $value['default_mimetypes'] : ''; } else { $errors[] = $formConfigDefaultUpload->getMessages(); } } } if (count($errors) > 0) { $this->_formHelper->returnError($errors[0]); } break; default: $values = $form->getValues(); $values['settings'] = $application->get_settings(); break; } //create entity object from submitted values, and save $application = new Application_Model_Application($values); $application->set_id($this->_applicationId); //new entity Application_Model_ApplicationMapper::getInstance()->save($application); //save done, return success return $this->_formHelper->returnSuccess($this->view->url(array('action' => 'index')), $this->translate('Configuration saved.')); } else { //we have errors - return json or continue $this->_formHelper->returnError($form->getMessages()); } } $this->view->notice = $this->translate('Currently using the default file extensions and mime types! Here you can add more file extensions and mime types.'); }
public function editAction() { $data = $this->getRequest()->getPost('data'); $submit = $this->getRequest()->getPost('submit'); $formTab = $this->getRequest()->getUserParam('tab', "Gsc"); $id = $this->_applicationId; //check if cancel button is pressed if ($this->_formHelper->isCancel()) { //cancel form return $this->_formHelper->returnCancel($this->view->url(array('action' => 'index')), $this->translate('Action canceled')); } $application = new Application_Model_Application(); if (!Application_Model_ApplicationMapper::getInstance()->find($id, $application)) { throw new Exception("Configuration not found"); } $this->view->data = $application->toArray(); $formClassName = "Admin_Form_Config" . $formTab; if (!class_exists($formClassName)) { $this->_formHelper->returnError("ne postoji"); // Mare Srbine } //create form object $form = new $formClassName($data); $errors = array(); //postback - save? if ($this->_formHelper->isSave()) { //check if valid if ($form->isValid()) { $values['settings'] = $application->get_settings(); $formValues = $form->getValues(); switch ($formTab) { case "Gsc": $values['settings']['gsc']['name'] = $formValues['name']; $values['settings']['gsc']['cx'] = $formValues['cx']; $values['settings']['gsc']['active'] = $formValues['active'] == "true" ? true : false; $values['settings']['gsc']['css']['.gs-title']['color'] = $formValues['title-color']; $values['settings']['gsc']['css']['.gs-title']['font-size'] = $formValues['title-font-size']; $values['settings']['gsc']['css']['.gs-bidi-start-align']['color'] = $formValues['snippet-color']; $values['settings']['gsc']['css']['.gs-bidi-start-align']['font-size'] = $formValues['snippet-font-size']; $values['settings']['gsc']['css']['.gs-visibleUrl']['color'] = $formValues['visible-url-color']; $values['settings']['gsc']['css']['.gs-visibleUrl']['font-size'] = $formValues['visible-url-font-size']; break; case "Ga": $values['settings']['tags']['ga']['tracking_id'] = $formValues['tracking_id']; $values['settings']['tags']['ga']['active'] = $formValues['ga_active'] == "true" ? true : false; break; case "WMT": $values['settings']['tags']['wmt']['meta'] = $formValues['wmt_meta']; $values['settings']['tags']['wmt']['active'] = $formValues['wmt_active'] == "true" ? true : false; break; case "GTM": $values['settings']['tags']['gtm']['container_id'] = $formValues['container_id']; $values['settings']['tags']['gtm']['active'] = $formValues['gtm_active'] == "true" ? true : false; break; case "Robots": $values['settings']['tags']['robots']['active'] = $formValues['robots_active'] == "true" ? true : false; break; } //create entity object from submitted values, and save $application = new Application_Model_Application($values); $application->set_id($this->_applicationId); //new entity Application_Model_ApplicationMapper::getInstance()->save($application); //save done, return success return $this->_formHelper->returnSuccess($this->view->url(array('action' => 'index')), $this->translate('Configuration saved.')); } else { //we have errors - return json or continue $this->_formHelper->returnError($form->getMessages()); } } }
public function editAction() { $data = $this->getRequest()->getPost('data'); $submit = $this->getRequest()->getPost('submit'); $id = $this->_getParam('id'); $data['lang'] = $this->_getParam('langFilter'); /* get all modules */ $criteria['application_id'] = $this->_applicationId; $modules = Application_Model_ModuleMapper::getInstance()->fetchAll($criteria); //check if cancel button is pressed if ($this->_formHelper->isCancel()) { //cancel form return $this->_formHelper->returnCancel($this->view->url(array('action' => 'index')), $this->translate('Action canceled')); } if (isset($data['path']) && $data['path'] != '') { foreach ($modules as $module) { $moduleData = $module->get_data(); if (isset($moduleData['menus'])) { foreach ($moduleData['menus'] as $path => $menu) { if ($module->get_code() . "/" . $path == $data['path']) { $data['dialog_url'] = $menu['dialog_url']; } } } } } // print_r($data);die; //create form object $form = new Cms_Form_Route($data); //postback - save? if ($this->_formHelper->isSave()) { //check if valid if ($form->isValid()) { $values = $form->getValues(); //create entity object from submitted values, and save $route = new Cms_Model_Route($values); //new entity if (!isset($data['id']) || $data['id'] <= 0) { $route->set_application_id($this->_applicationId); $existingRoute = clone $route; if (Cms_Model_RouteMapper::getInstance()->checkRouteExist($existingRoute, $this->_applicationId)) { $route->set_id($existingRoute->get_id()); } } else { $existingRoute = new Cms_Model_Route(); if (!Cms_Model_RouteMapper::getInstance()->find($data['id'], $existingRoute)) { throw new Exception("Menu not found"); } if ((int) $existingRoute->get_application_id() != $this->_applicationId) { throw new Exception("Cannot edit this Route."); } } $route->set_application_id($this->_applicationId); Cms_Model_RouteMapper::getInstance()->save($route); //save done, return success return $this->_formHelper->returnSuccess($this->view->url(array('action' => 'index')), $this->translate('Route saved.')); } else { //we have errors - return json or continue $this->_formHelper->returnError($form->getMessages()); } } elseif (!$this->_formHelper->getRequest()->isPost()) { //edit action if (isset($id) && $id > 0) { $route = new Cms_Model_Route(); if (!Cms_Model_RouteMapper::getInstance()->find($id, $route)) { throw new Exception("Route not found"); } $data = $route->toArray(); //populate form with data $form->setData($data); } } $this->view->languages = Application_Model_TranslateMapper::getInstance()->getLanguages(); $this->view->modules = $modules; $page = new Cms_Model_Page(); if (isset($data['page_id'])) { Cms_Model_PageMapper::getInstance()->find($data['page_id'], $page); } $this->view->page_title = $page->get_title(); $this->view->langFilter = $data['lang']; $this->view->data = $data; }