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 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'); $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.'); }
private function _checkSelectors($theme) { $mapper = Application_Model_ApplicationMapper::getInstance(); $appSettings = $mapper->fetchAll(); $settings = $appSettings[0]->get_theme_settings(); if (isset($settings[$theme])) { $editorProperties = json_decode($this->_getPropertiesJson($theme), true)['pages']['/themes/' . $theme . '/theme_edit/preview/complex.html']['def']; $dbJson = isset($settings[$theme]['json']['/themes/' . $theme . '/theme_edit/preview/complex.html']) ? $settings[$theme]['json']['/themes/' . $theme . '/theme_edit/preview/complex.html'] : ''; $dbCss = $settings[$theme]['css']; $flag = false; if (is_array($dbJson)) { foreach ($dbJson as $property => $value) { if (!array_key_exists($property, $editorProperties)) { unset($dbJson[$property]); preg_replace("/" . $property . "{(.*?)}/", " ", $dbCss); $flag = true; } } } } if ($flag) { $settings[$theme]['css'] = $dbCss; $settings[$theme]['json'] = $dbJson; $app = new Application_Model_Application(); $app->set_theme_settings($settings); $app->set_id(1); $mapper->save($app); } }