示例#1
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $errors = '';
     if (!isset($_REQUEST['name'])) {
         $_REQUEST['name'] = '';
     }
     if (!isset($_REQUEST['lang'])) {
         $_REQUEST['lang'] = '';
     }
     $action = SJB_Request::getVar('action', '');
     $form_submitted = SJB_Request::getVar('formSubmitted');
     if ($action == 'add') {
         if (($error = SJB_StaticContentAuxil::isValidNameID($_REQUEST['name'], $_REQUEST['page_id'])) == '') {
             if (!SJB_StaticContent::getStaticContentByIdAndLang($_REQUEST['page_id'], $_REQUEST['lang'])) {
                 $contentInfo = array('id' => $_REQUEST['page_id'], 'name' => $_REQUEST['name'], 'lang' => $_REQUEST['lang']);
                 if (SJB_StaticContent::addStaticContent($contentInfo)) {
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings("SITE_URL") . '/stat-pages/');
                 } else {
                     $errors = SJB_StaticContentAuxil::warning('Error', 'Cannot add new static page');
                 }
             } else {
                 $errors = SJB_StaticContentAuxil::warning('Error', 'Dublicate pare ID and Language. Please specify another ID or/and Language');
             }
         } else {
             $errors = SJB_StaticContentAuxil::warning('Error', $error);
         }
     }
     if ($action == 'change') {
         $staticContent = SJB_StaticContent::getStaticContentByIDAndLang($_REQUEST['page_id'], $_REQUEST['lang']);
         if (!$staticContent || $staticContent['sid'] == $_REQUEST['page_sid']) {
             $content = SJB_Request::getVar('content');
             if ((SJB_System::getSystemSettings('isDemo') || SJB_System::getIfTrialModeIsOn()) && SJB_HelperFunctions::findSmartyRestrictedTagsInContent($tp, $content)) {
                 $errors = SJB_StaticContentAuxil::warning('Error', 'Php tags are not allowed');
             } else {
                 $contentInfo = array('id' => $_REQUEST['page_id'], 'name' => $_REQUEST['name'], 'content' => $content, 'lang' => $_REQUEST['lang']);
                 if (SJB_StaticContent::changeStaticContent($contentInfo, $_REQUEST['page_sid'])) {
                     if ($form_submitted == 'save_content') {
                         SJB_HelperFunctions::redirect(SJB_System::getSystemSettings("SITE_URL") . '/stat-pages/');
                     }
                 } else {
                     $errors = SJB_StaticContentAuxil::warning('Error', 'Cannot update page');
                 }
             }
         } else {
             $errors = SJB_StaticContentAuxil::warning('Error', 'Dublicate pare ID and Language. Please specify another ID or/and Language');
         }
         $action = 'edit';
     }
     if ($action == 'delete') {
         if (SJB_StaticContent::deleteStaticContent($_REQUEST['page_sid'])) {
             SJB_HelperFunctions::redirect(SJB_System::getSystemSettings("SITE_URL") . '/stat-pages/');
         }
         $errors = SJB_StaticContentAuxil::warning('Error', 'Cannot delete static page');
     }
     $tp->assign('languages', SJB_I18N::getInstance()->getActiveFrontendLanguagesData());
     if ($action == 'edit') {
         $page = SJB_StaticContent::getStaticContent($_REQUEST['page_sid']);
         $tp->assign('page', array_map('htmlspecialchars', $page));
         $pageInfo = array('module' => 'static_content', 'function' => 'show_static_content', 'parameters' => array('pageid' => SJB_Request::getVar('pageid', '')));
         $tp->assign('pageInfo', $pageInfo);
         $tp->assign('page_content', $page['content']);
         $tp->assign('page_sid', $_REQUEST['page_sid']);
         $tp->assign('page', $page);
         $tp->assign('error', $errors);
         $tp->display('static_content_change.tpl');
         return;
     }
     $tp->assign('pages', SJB_StaticContent::getStaticContents());
     $tp->assign('error', $errors);
     $tp->display('static_content.tpl');
 }
示例#2
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $module_name = SJB_Request::getVar('module_name', "", 'GET');
     $template_name = SJB_Request::getVar('template_name', "", 'GET');
     // не работало с юзерской
     if (empty($template_name)) {
         $template_name = SJB_Request::getVar('template_name', '');
     }
     if (empty($module_name)) {
         $module_name = SJB_Request::getVar('module_name', '');
     }
     $theme = SJB_Settings::getValue('TEMPLATE_USER_THEME', 'default');
     $template_editor = new SJB_TemplateEditor();
     $simple_view = SJB_Request::getVar('simple_view');
     if (!$template_editor->doesModuleExists($module_name)) {
         $tp->assign('ERROR', "MODULE_DOES_NOT_EXIST");
     } else {
         if (!$template_editor->doesModuleTemplateExists($module_name, $template_name)) {
             $tp->assign('ERROR', "TEMPLATE_DOES_NOT_EXIST");
         } else {
             if (isset($_REQUEST['action'])) {
                 $content = SJB_Request::getVar('template_content');
                 if ($content) {
                     if (SJB_System::getSystemSettings("isDemo")) {
                         $tp->assign('ERROR', 'NOT_ALLOWED_IN_DEMO');
                     } elseif (SJB_System::getIfTrialModeIsOn() && SJB_HelperFunctions::findSmartyRestrictedTagsInContent($tp, $content)) {
                         $tp->assign('ERROR', 'Php tags are not allowed');
                     } else {
                         $result = $template_editor->saveTemplate($template_name, $module_name, $theme, $content);
                         // if ajax request to save
                         if ($simple_view) {
                             if ($result) {
                                 echo '<p class="message">Template saved successfully. </p>';
                             } else {
                                 echo "ERROR WHILE SAVE TEMPLATE";
                             }
                             exit;
                         }
                         if ($_REQUEST['action'] == "save_template") {
                             SJB_HelperFunctions::redirect("?module_name=" . $module_name);
                         }
                     }
                 }
             }
             echo SJB_System::executeFunction('template_manager', 'add_template');
             $modules = $template_editor->getModuleWithTemplatesList();
             $tp->assign('module_name', $module_name);
             $tp->assign('template_name', $template_name);
             $tp->assign('theme', $theme);
             $tp->assign('display_name', $modules[$module_name]['display_name']);
             $tp->assign('template_display_name', $template_name);
             $path_to_template = SJB_TemplatePathManager::getAbsoluteTemplatePath($theme, $module_name, $template_name);
             if (!file_exists($path_to_template)) {
                 $theme = SJB_System::getSystemSettings('SYSTEM_TEMPLATE_DIR');
             }
             if (false === ($template_content = $template_editor->loadTemplate($template_name, $module_name, $theme))) {
                 $tp->assign('ERROR', "CANNOT_FETCH_TEMPLATE");
             } else {
                 if (!$template_editor->isTemplateWriteable($module_name, $theme, $template_name) && !SJB_System::getSystemSettings("isDemo")) {
                     $tp->assign('ERROR', "TEMPLATE_IS_NOT_WRITEABLE");
                 } else {
                     $tp->assign('template_content', $template_content);
                 }
             }
             $list_modules = SJB_System::getModulesUserList();
             $list_functions = array();
             $list_params = array();
             foreach ($list_modules as $module) {
                 $functions = SJB_System::getFunctionsUserList($module);
                 foreach ($functions as $keyF => $func) {
                     $list_functions[$module][$keyF] = $func;
                     $params = SJB_System::getParamsList($module, $func);
                     if (isset($params[0])) {
                         foreach ($params as $keyP => $param) {
                             $list_params[$module][$func][$keyP] = $param;
                         }
                     }
                 }
             }
             $tp->assign('LIST_MODULES', $list_modules);
             $tp->assign('LIST_FUNCTIONS', $list_functions);
             $tp->assign('LIST_PARAMS', $list_params);
         }
     }
     if ($simple_view) {
         $tp->display('edit_template_simple.tpl');
     } else {
         header('X-XSS-Protection: 0');
         $tp->display('edit_template.tpl');
     }
 }
示例#3
0
 protected function editEmailTemplate($sid, &$errors = array())
 {
     $tplInfo = SJB_EmailTemplateEditor::getEmailTemplateInfoBySID($sid);
     if ($tplInfo) {
         $tplInfo = array_merge($tplInfo, $_REQUEST);
         $emailTemplate = new SJB_EmailTemplate($tplInfo);
         $emailTemplate->setSID($sid);
         $emailTemplate_edit_form = new SJB_Form($emailTemplate);
         $form_is_submitted = SJB_Request::getVar('action');
         // php tags are not allowed in trial mode
         if (SJB_System::getIfTrialModeIsOn() || SJB_System::getSystemSettings('isDemo')) {
             if (SJB_HelperFunctions::findSmartyRestrictedTagsInContent($this->tp, $emailTemplate->getPropertyValue('text'))) {
                 $errors['Text'] = 'Php tags are not allowed';
             }
         }
         if ($form_is_submitted && $emailTemplate_edit_form->isDataValid($errors)) {
             SJB_EmailTemplateEditor::saveEmailTemplate($emailTemplate);
             if ($form_is_submitted == 'save_info') {
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/edit-email-templates/' . $emailTemplate->getPropertyValue('group'));
             }
             $this->successMessage = 'You have successfully saved your changes';
         }
         $emailTemplate_edit_form->registerTags($this->tp);
         // prepare email templates variables info
         $this->prepareTemplateVarsInfo(SJB_Array::get($tplInfo, 'group'), SJB_Array::get($tplInfo, 'name'));
         $this->tp->assign('form_fields', $emailTemplate_edit_form->getFormFieldsInfo());
         $this->tp->assign('tplInfo', $tplInfo);
         $this->template = 'edit_email_template.tpl';
     } else {
         $this->error = 'INVALID_EMAIL_TEMPLATE_SID_WAS_SPECIFIED';
     }
 }