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 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 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'); $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 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 dialogAction() { $page_id = $this->getRequest()->getParam('page_id', ''); $langFilter = $this->getRequest()->getParam('langFilter', ''); $data = $this->getRequest()->getPost('data'); $this->view->languages = Application_Model_TranslateMapper::getInstance()->getLanguages(); $this->view->types = Cms_Model_PageTypeMapper::getInstance()->fetchAll(); $this->view->page_id = $page_id; $this->view->langFilter = $langFilter; if ($this->_formHelper->isSave()) { return $this->_formHelper->returnSuccess($this->view->url(array('action' => 'menu')), $this->translate('Page Selected.'), $data); } }
public function indexAction() { $data = $this->getRequest()->getPost('data'); //print_r($this->_fields); //create form object $form = new Contact_Form_Generic($data, null, $this->_fields, $this->getRequest()); $entityClassName = $this->getEntityClassName(); $mapperClassName = $this->getMapperClassName(); //postback - save? if ($this->_formHelper->isSave()) { //check if valid if ($form->isValid()) { $values = $form->getValues(); if ($this->hasFileUpload()) { $this->relocateUploadedFiles($values); $this->_genericFileHelper->pmcCleaner(); } //persist data if (isset($this->_formParams['db']['save']) && $this->_formParams['db']['save']) { $contact = new $entityClassName($values); $contact->set_application_id($this->_applicationId)->set_language(CURR_LANG)->set_form_id($this->_formId)->set_posted(HCMS_Utils_Time::timeTs2Mysql(time())); $mapperClassName::getInstance()->save($contact); } //send email $this->sendContactEmail($values, $this->_fields, CURR_LANG); //sending done, return success return $this->redirectLanding(); } else { $this->_formHelper->returnError($form->getMessages()); } } else { //set default values Contact_Form_Generic::setDefaultValues($this->_fields, $data); } $this->view->data = $data; $this->view->fields = $this->_fields; $this->view->formParams = $this->_formParams; $this->view->formId = $this->_formId; if (isset($this->_formParams['template'])) { $this->renderScript($this->_formParams['template']); } }
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 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 userEditAction() { $data = $this->getRequest()->getPost('data'); $id = $this->_getParam('id'); $aclLoader = HCMS_Acl_Loader::getInstance(); //check permission if ($aclLoader->getAcl()->isAllowed($aclLoader->getCurrentRoleCode(), "admin", "master")) { $this->view->isAdminLogged = true; $data["isAdminLogged"] = true; } else { $this->view->isAdminLogged = false; $data["isAdminLogged"] = false; } //check if cancel button is pressed if ($this->_formHelper->isCancel()) { //cancel form return $this->_formHelper->returnCancel($this->view->url(array('action' => 'user-edit')), $this->translate('Action canceled')); } //create form object $form = new Auth_Form_User($data); //postback - save? if ($this->_formHelper->isSave()) { //check if valid if ($form->isValid()) { $values = $form->getValues(); //create entity object from submitted values, and save $user = new Auth_Model_User($values); $date = new Zend_Date(); $user->set_changed_password_dt($date->toString('yyyy-MM-dd HH:mm:ss')); if (isset($id) && $id > 0) { if (isset($values['new_password']) && $values['new_password'] != '') { $user->set_password($values['new_password']); } $this->savePassHistory($id); } Auth_Model_UserMapper::getInstance()->save($user); //save done, return success return $this->_formHelper->returnSuccess($this->view->url(array('action' => 'user-edit')), $this->translate('User 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) { $user = new Auth_Model_User(); if (!Auth_Model_UserMapper::getInstance()->find($id, $user)) { throw new Exception("User not found"); } //fetch data $data = $user->toArray(); } } $criteria = array(); $roles = Auth_Model_RoleMapper::getInstance()->fetchAll($criteria); $languages = Application_Model_TranslateMapper::getInstance()->getLanguages(); $this->view->roles = $roles; $this->view->languages = $languages; $this->view->data = $data; //die(print_R($data)); }
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; }
/** * Configuration action */ public function configAction() { //read data from request $data = $this->getRequest()->getPost('data'); $inputHashChangePost = $this->_request->getParam('inputHashChangePost'); $inputHashChangeGet = $this->_request->getParam('inputHashChangeGet'); //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 ($this->getRequest()->getParam("type") == 'contact') { $module_name = "contact"; } else { if ($this->getRequest()->getParam("type") == 'newsletter') { $module_name = "newsletter"; } else { if ($this->getRequest()->getParam("type") == 'blog') { $module_name = "blog"; } else { throw new Exception("Contact module not found"); } } } //read contact module $module = new Application_Model_Module(); if (!Application_Model_ModuleMapper::getInstance()->findByCode($module_name, $module)) { throw new Exception("Contact module not found"); } $this->view->data = array('email' => $module->get_settings('email')); $this->view->data['type'] = $module_name; $this->view->emailTransportTypeOptions = Application_Model_Application::getEmailTransportTypeOptions(); //postback - save? if ($this->_formHelper->isSave()) { $formToEmails = new Contact_Form_ConfigToEmailsWrapper($data['email']['to_emails']); $formParameters = new Contact_Form_ConfigParameters($data['email']['parameters'], null, $data['email']['transport']); if ($module_name == 'contact') { $formEmail = new Contact_Form_ConfigEmail($data['email']); } elseif ($module_name == 'newsletter') { $formEmail = new Contact_Form_ConfigEmailNewsletter($data['email']); } elseif ($module_name == 'blog') { $formEmail = new Blog_Form_ConfigEmail($data['email']); } //check if valid if ($formEmail->isValid() && $formParameters->isValid() && $formToEmails->isValid()) { $data['email'] = $formEmail->getValues(); $data['email']['parameters'] = $formParameters->getValues(); $data['email']['to_emails'] = $formToEmails->getValues(); $lang = new Translation_Model_Lang(); if (!Translation_Model_LangMapper::getInstance()->findByCode(CURR_LANG, $lang)) { throw new Exception('No language for this code.'); } Translation_Model_TranslationMapper::getInstance()->save('mailtextRespondContactTranslationkey', $lang->get_id(), $data['email']['mailtext_respond_contact'], 'global'); $data['email']['mailtext_respond_contact'] = 'mailtextRespondContactTranslationkey'; Translation_Model_TranslationMapper::getInstance()->save('landingPageText', $lang->get_id(), $data['email']['landing_page_text'], 'global'); $data['email']['landing_page_text'] = 'landingPageText'; Translation_Model_TranslationMapper::getInstance()->save('subjectContactTranslationkey', $lang->get_id(), $data['email']['subject_contact'], 'global'); $data['email']['subject_contact'] = 'subjectContactTranslationkey'; //create module entity object $settings = $module->get_settings(); $settings['email'] = $data['email']; $module->set_settings(json_encode($settings)); $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', 'inputHashChangeGet' => $inputHashChangePost)), $this->translate('Configuration saved.')); } else { //we have errors - return json or continue $messages = $formEmail->getMessages(); $messages['parameters'] = $formParameters->getMessages(); $messages['to_emails'] = $formToEmails->getMessages(); $this->view->data = $data; $this->_formHelper->returnError($messages); } } if (isset($inputHashChangeGet) && $inputHashChangeGet != '') { $this->view->inputHashChange = $inputHashChangeGet; } else { $this->view->inputHashChange = "email-config"; } //country assign $countries = new Application_Model_Country(); $countries = Application_Model_CountryMapper::getInstance()->getAllCountries(CURR_LANG); $this->view->countries = $countries; $this->view->languages = Application_Model_TranslateMapper::getInstance()->getLanguages(); $this->view->fields = Contact_Form_Contact::getFields(); }
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 menuEditAction() { $data = $this->getRequest()->getPost('data'); $submit = $this->getRequest()->getPost('submit'); $id = $this->_getParam('id'); $langFilter = $this->_getParam('langFilter'); $menuFilter = $this->_getParam('menuFilter'); /* get routes from application.ini */ $bootstrap = $this->getInvokeArg('bootstrap'); $routes = array_keys($bootstrap->getResource('router')->getRoutes()); /* 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' => 'menu')), $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']; } } } } } //create form object $form = new Cms_Form_MenuItem($data); $route = new Cms_Model_Route(); //postback - save? if ($this->_formHelper->isSave()) { //check if valid if ($form->isValid()) { $values = $form->getValues(); //create entity object from submitted values, and save $item = new Cms_Model_MenuItem($values); if ($data['route'] == '') { $item->set_path(''); $item->set_page_id(''); $item->set_page_id_new(''); $item->set_params(''); } else { $item->set_uri(''); } //new entity if (!isset($data['id']) || $data['id'] <= 0) { $item->set_application_id($this->_applicationId); } else { $existingMenu = new Cms_Model_MenuItem(); if (!Cms_Model_MenuItemMapper::getInstance()->find($data['id'], $existingMenu)) { throw new Exception("Menu not found"); } if ((int) $existingMenu->get_application_id() != $this->_applicationId) { throw new Exception("Cannot edit this Menu Item."); } } $item->set_application_id($this->_applicationId); Cms_Model_MenuItemMapper::getInstance()->save($item, $langFilter); //save done, return success return $this->_formHelper->returnSuccess($this->view->url(array('action' => 'menu')), $this->translate('Menu Item 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) { $item = new Cms_Model_MenuItem(); if (!Cms_Model_MenuItemMapper::getInstance()->find($id, $item, $langFilter)) { throw new Exception("Menu not found"); } Cms_Model_RouteMapper::getInstance()->findByPath($item->get_path(), $this->_applicationId, $route, $item->get_params(), $langFilter != '' ? $langFilter : null); $item->set_route_uri($route->get_uri()); $params = $item->get_params(); $item->set_params(Cms_Model_MenuItemMapper::getInstance()->unsetParamsPageId($params)); //fetch data $data = $item->toArray(); //populate form with data $form->setData($data); } } $this->view->menus = Cms_Model_MenuMapper::getInstance()->getMenus(); $this->view->menuFilter = $menuFilter; $this->view->langFilter = $langFilter; $this->view->routes = $routes; $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->data = $data; }