Пример #1
0
 public function execute()
 {
     $template_processor = SJB_System::getTemplateProcessor();
     $module_name = isset($_REQUEST['module_name']) ? $_REQUEST['module_name'] : "";
     $template_editor = new SJB_TemplateEditor();
     $template_processor->assign('module_name', $module_name);
     $modules = $template_editor->getModuleWithTemplatesList();
     ksort($modules);
     $template_processor->assign('module_list', $modules);
     $template_processor->display('module_list.tpl');
 }
Пример #2
0
 public function execute()
 {
     $template_processor = SJB_System::getTemplateProcessor();
     $template_editor = new SJB_TemplateEditor();
     $modules = $template_editor->getModuleWithTemplatesList();
     ksort($modules);
     global $error;
     $template_processor->assign('module_name', SJB_Request::getVar('module_name', '', 'GET'));
     $template_processor->assign('template_name', SJB_Request::getVar('template_name', '', 'GET'));
     $template_processor->assign('tpl_error', $error);
     $template_processor->assign('module_list', $modules);
     $template_processor->display('add_template.tpl');
 }
Пример #3
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $template_editor = new SJB_TemplateEditor();
     $setNewTheme = SJB_Request::getVar('theme', false);
     $theme = SJB_Request::getVar('theme', SJB_Settings::getValue('TEMPLATE_USER_THEME', 'default'));
     if ($setNewTheme) {
         if (SJB_System::getSystemSettings("isDemo")) {
             $tp->assign('ERROR', 'ACCESS_DENIED');
         } else {
             SJB_Settings::setValue('TEMPLATE_USER_THEME', $theme);
             SJB_Settings::setValue('CURRENT_THEME', $theme);
         }
     }
     if (!$template_editor->doesThemeExists(SJB_Settings::getValue('TEMPLATE_USER_THEME', 'default'))) {
         SJB_Settings::setValue('CURRENT_THEME', 'default');
         SJB_Settings::setValue('TEMPLATE_USER_THEME', 'default');
         $theme = 'default';
     } else {
         if ($setNewTheme && !SJB_System::getSystemSettings("isDemo")) {
             SJB_HelperFunctions::redirect(SJB_System::getSystemSettings("SITE_URL") . '/edit-themes/');
         }
     }
     $tp->assign('theme_list', $template_editor->getThemeList());
     $tp->assign('theme', $theme);
     if (isset($_REQUEST['action'])) {
         if (SJB_System::getSystemSettings("isDemo")) {
             $tp->assign('ERROR', 'ACCESS_DENIED');
         } else {
             switch (SJB_Request::getVar("action")) {
                 case "copy_theme":
                     if (isset($_REQUEST['copy_from_theme'], $_REQUEST['new_theme']) && $template_editor->doesThemeExists($_REQUEST['copy_from_theme']) && !$template_editor->doesThemeExists($_REQUEST['new_theme']) && !empty($_REQUEST['new_theme'])) {
                         $template_editor->copyEntireTheme($_REQUEST['copy_from_theme'], $_REQUEST['new_theme']);
                         SJB_HelperFunctions::redirect("?theme=" . $_REQUEST['new_theme']);
                     } else {
                         if ($template_editor->doesThemeExists(SJB_Request::getVar('new_theme', ''))) {
                             $tp->assign('ERROR', 'ALREADY_EXISTS');
                         }
                         if (empty($_REQUEST['new_theme'])) {
                             $tp->assign('ERROR', 'EMPTY_NAME');
                         }
                     }
                     break;
                 case "delete_theme":
                     if (isset($_REQUEST['theme_name']) && $template_editor->doesThemeExists($_REQUEST['theme_name'])) {
                         $template_editor->deleteEntireTheme($_REQUEST['theme_name']);
                         SJB_HelperFunctions::redirect(SJB_System::getSystemSettings("SITE_URL") . '/edit-themes/');
                     }
                     break;
             }
         }
     }
     $tp->display('theme_editor.tpl');
 }
Пример #4
0
 public function execute()
 {
     $template_processor = SJB_System::getTemplateProcessor();
     $template_editor = new SJB_TemplateEditor();
     $template_name = isset($_REQUEST['template_name']) ? $_REQUEST['template_name'] : "";
     if (!$template_editor->doesModuleTemplateExists(SJB_System::getSystemSettings('STARTUP_MODULE'), $template_name)) {
         $template_name = '';
     }
     if (!empty($template_name)) {
         $menu_path = array(array('reference' => "?", 'name' => 'Page Templates'), array('name' => $template_name, 'reference' => ""));
         $template_processor->assign("navigation", $menu_path);
         $template_processor->assign("title", "Page Template: {$template_name}");
         $template_processor->display('navigation_menu.tpl');
         echo SJB_System::executeFunction("template_manager", "edit_template", array('module_name' => System::getSystemSettings('STARTUP_MODULE')));
     } else {
         $menu_path = array(array('reference' => "", 'name' => 'Page Templates'));
         $template_processor->assign("navigation", $menu_path);
         $template_processor->assign("title", 'Page Templates');
         $template_processor->display('navigation_menu.tpl');
         echo SJB_System::executeFunction("template_manager", "page_template_list");
     }
 }
Пример #5
0
 public function execute()
 {
     $template_processor = SJB_System::getTemplateprocessor();
     $template_name = isset($_REQUEST['template_name']) ? $_REQUEST['template_name'] : "";
     $template_editor = new SJB_TemplateEditor();
     $template_processor->assign('ERROR', '');
     $theme = SJB_Settings::getValue('TEMPLATE_USER_THEME', 'default');
     if (isset($_REQUEST['action'])) {
         if ($_REQUEST['action'] == 'create_page_template') {
             if (!isset($_REQUEST['new_template_name'])) {
                 $_REQUEST['new_template_name'] = '';
             }
             $_REQUEST['new_template_name'] = preg_replace("~.tpl\$~iu", "", $_REQUEST['new_template_name']);
             if (empty($_REQUEST['new_template_name'])) {
                 $template_processor->assign('ERROR', 'EMPTY_TEMPLATE_NAME');
             } else {
                 if (preg_match("~\\W~", $_REQUEST['new_template_name'])) {
                     $template_processor->assign('ERROR', 'WRONG_FILENAME');
                 } else {
                     if (true !== ($result = $template_editor->saveTemplate($_REQUEST['new_template_name'] . ".tpl", SJB_System::getSystemSettings('STARTUP_MODULE'), $theme, "<html>\n<head>\n<title>{\$TITLE}</title>\n</head>\n<body>\n{\$MAIN_CONTENT}\n</body>\n</html>"))) {
                         $template_processor->assign('ERROR', 'CANNOT_SAVE_FILE');
                     } else {
                         SJB_HelperFunctions::redirect("?");
                     }
                 }
             }
         }
         if ($_REQUEST['action'] == 'delete_template') {
             $template_editor->deleteTemplate($_REQUEST['del_template_name'], SJB_System::getSystemSettings('STARTUP_MODULE'), $theme);
             SJB_HelperFunctions::redirect("?");
         }
     }
     $template_processor->assign('new_template_name', isset($_REQUEST['new_template_name']) ? $_REQUEST['new_template_name'] : "");
     $template_processor->assign('template_name', $template_editor->doesModuleTemplateExists(SJB_System::getSystemSettings('STARTUP_MODULE'), $template_name) ? $template_name : "");
     $template_processor->assign('STARTUP_MODULE', SJB_System::getSystemSettings('STARTUP_MODULE'));
     $template_processor->assign('template_list', $template_editor->getTemplateList(SJB_System::getSystemSettings('STARTUP_MODULE'), $theme));
     $template_processor->display('page_template_list.tpl');
 }
Пример #6
0
 public function execute()
 {
     $template_processor = SJB_System::getTemplateProcessor();
     $template_editor = new SJB_TemplateEditor();
     $template_processor->assign('ERROR', "OK");
     $module_name = SJB_Request::getVar('module_name', '');
     $template_name = SJB_Request::getVar('template_name', '');
     $template_processor->assign('module_name', $template_editor->doesModuleExists($module_name) ? $module_name : "");
     $template_processor->assign('template_name', $template_editor->doesModuleTemplateExists($module_name, $template_name) ? $template_name : "");
     if (!$template_editor->doesModuleExists($module_name)) {
         $template_processor->assign('ERROR', "MODULE_DOES_NOT_EXIST");
     } else {
         if (!$template_editor->copyDefaultModuleThemeIfNotExists($module_name)) {
             $template_processor->assign('ERROR', "CANNOT_COPY_THEME");
         }
         $modules = $template_editor->getModuleWithTemplatesList();
         $template_processor->assign('display_name', $modules[$module_name]['display_name']);
         $template_processor->assign('module_name', $module_name);
         $template_processor->assign('template_list', $template_editor->getTemplateList($module_name, SJB_Settings::getValue('TEMPLATE_USER_THEME', 'default'), true));
     }
     $template_processor->display('template_list.tpl');
 }
Пример #7
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');
     }
 }
Пример #8
0
 public static function getDetails()
 {
     $details = array(array('id' => 'name', 'caption' => 'Name', 'type' => 'unique_string', 'length' => '20', 'table_name' => 'products', 'validators' => array('SJB_UniqueSystemValidator'), 'unique' => '1', 'is_required' => true, 'is_system' => true, 'order' => 1), array('id' => 'short_description', 'caption' => 'Short Description', 'type' => 'text', 'length' => '20', 'table_name' => 'products', 'is_required' => false, 'is_system' => true, 'order' => 2), array('id' => 'detailed_description', 'caption' => 'Detailed Description', 'type' => 'text', 'length' => '20', 'table_name' => 'products', 'is_required' => false, 'is_system' => true, 'order' => 3), array('id' => 'user_group_sid', 'caption' => 'User Group', 'type' => 'list', 'length' => '20', 'table_name' => 'products', 'list_values' => SJB_UserGroupManager::getAllUserGroupsIDsAndCaptions(true), 'is_required' => true, 'is_system' => true, 'order' => 4), array('id' => 'active', 'caption' => 'Active', 'type' => 'boolean', 'length' => '20', 'table_name' => 'products', 'is_required' => false, 'is_system' => true, 'order' => 5), array('id' => 'availability_from', 'caption' => 'Availability', 'type' => 'date', 'length' => '20', 'table_name' => 'products', 'is_required' => false, 'is_system' => true, 'order' => 6), array('id' => 'availability_to', 'caption' => 'AvailabilityTo', 'type' => 'date', 'length' => '20', 'table_name' => 'products', 'is_required' => false, 'is_system' => true, 'order' => 7), array('id' => 'trial', 'caption' => 'Trial Product', 'type' => 'boolean', 'length' => '20', 'table_name' => 'products', 'comment' => 'Trial Product will not be available for a user after the 1st purchase', 'is_required' => false, 'is_system' => true, 'order' => 8), array('id' => 'welcome_email', 'caption' => 'Welcome Email', 'type' => 'list', 'list_values' => SJB_TemplateEditor::getTemplatesByGroupForListType(SJB_NotificationGroups::GROUP_ID_PRODUCT), 'length' => '20', 'table_name' => 'products', 'comment' => 'You can create more email templates for different products from Admin Panel > Email Templates > Product Emails', 'is_required' => false, 'is_system' => true, 'order' => 9));
     return $details;
 }
Пример #9
0
 /**
  * Return template content
  *
  * @param string $tpl_name Template name
  * @return text Template content
  */
 function fetchTemplateSource($tpl_name)
 {
     $fileName = $this->getTplName($tpl_name);
     if (empty($fileName)) {
         return '';
     }
     $content = file_get_contents($fileName);
     /**
      * Check for 'highlight_templates' setting. If it ON, and that 'admin' user - mark templates on page
      */
     $highlight = SJB_Settings::getSettingByName('highlight_templates');
     if (SJB_System::getSystemSettings('SITE_URL') == SJB_System::getSystemSettings('USER_SITE_URL') && $highlight && SJB_Request::getVar('admin_mode', false, 'COOKIE')) {
         $admin_site_url = SJB_System::getSystemSettings('ADMIN_SITE_URL');
         $module = $this->getModuleName();
         $edit_url = $admin_site_url . "/edit-templates/?module_name={$module}&template_name=" . basename($fileName) . "&simple_view=1";
         $images = SJB_System::getSystemSettings('USER_SITE_URL') . "/templates/_system/main/images";
         // get list of templates availabled to user edit
         $current_user_theme = SJB_Settings::getValue('TEMPLATE_USER_THEME', 'default');
         $available_templates = SJB_TemplateEditor::getTemplateList($this->module_name, $current_user_theme);
         // get list of container templates
         $containerTemplates = array('main.tpl', 'index.tpl', 'empty.tpl', 'blank.tpl');
         if (self::$additionalContainerTemplate !== null) {
             $containerTemplates[] = self::$additionalContainerTemplate;
         }
         // do not wrap container templates in div
         $tplFileName = basename($tpl_name);
         if (in_array($tplFileName, $available_templates)) {
             if (!in_array($tplFileName, $containerTemplates)) {
                 $content = "<div class='templateHighlight' title='{$module}/{$tplFileName}'>" . $content;
                 $content = $content . "\n\t\t\t\t\t\t\t<div class=\"highlight-clr\"><br/></div><div class=\"inner_div\"><a class=\"editTemplateLink\" href=\"{$edit_url}\" title=\"{$module}/{$tplFileName}\" target=\"_blank\">[[Edit]]</a></div>\n\t\t\t\t\t\t</div>";
             } else {
                 if (!in_array($tplFileName, array('empty.tpl', 'blank.tpl'))) {
                     // for main.tpl and index.tpl  place edit marker div after html-document
                     // properly displayed in FF3.5, IE 6.0.2900.2180, Safary3.1.2(for win), Opera 9.50
                     $content = $content . "<div class=\"highlight-clr\"></div><div class=\"inner_div\"><a class=\"editTemplateLink\" href=\"{$edit_url}\" title=\"{$module}/{$tplFileName}\" target=\"_blank\">[[Edit]]</a></div>";
                 }
             }
         }
         return $content;
     }
     return $content;
 }
Пример #10
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $template_editor = new SJB_TemplateEditor();
     $module_name = SJB_Request::getVar('module_name', '', 'GET');
     // if set simple_view - not shown navigation to user
     $simple_view = SJB_Request::getVar('simple_view', false);
     if (!$template_editor->doesModuleExists($module_name)) {
         $module_name = '';
     }
     $template_name = SJB_Request::getVar('template_name', '', 'GET');
     if (!$template_editor->doesModuleTemplateExists($module_name, $template_name)) {
         $template_name = '';
     }
     $modules = $template_editor->getModuleWithTemplatesList();
     global $error;
     $error = array();
     $result = '';
     $highlight_setting = SJB_Request::getVar('highlight_templates');
     if (!is_null($highlight_setting)) {
         if (SJB_System::getSystemSettings("isDemo")) {
             $error[] = 'NOT_ALLOWED_IN_DEMO';
         } else {
             SJB_Settings::updateSetting('highlight_templates', $highlight_setting);
         }
     }
     $tp->assign('highlight_templates', SJB_Settings::getSettingByName('highlight_templates'));
     $action = SJB_Request::getVar('action', '');
     $form_submitted = SJB_Request::getVar('submit');
     //Clear Smarty Cache
     $clear_smarty_cache = SJB_Request::getVar('clear_cache_submit');
     if ($clear_smarty_cache) {
         $compiled_templates_dir = SJB_System::getSystemSettings('COMPILED_TEMPLATES_DIR');
         $admin_theme = ThemeManager::getCurrentTheme();
         $themes_list['user'] = $template_editor->getThemeList();
         $themes_list['admin'][] = $admin_theme;
         foreach ($themes_list as $access_type => $themes) {
             foreach ($themes as $theme) {
                 $destination = $compiled_templates_dir . $access_type . "/" . $theme;
                 $result = $tp->deleteCacheBySpecifiedPath($destination);
                 if (is_array($result)) {
                     $error = $result;
                 }
             }
         }
     }
     // actions
     if (!empty($action)) {
         $theme = SJB_Settings::getValue('TEMPLATE_USER_THEME', 'default');
         // TODO: !!!!если редактируется с юзерской части , то проверить есть ли тэмплэйт в теме , если нет , брать с _system
         switch ($action) {
             case 'delete':
                 $template_editor->deleteTemplate($template_name, $module_name, $theme);
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/edit-templates/?module_name=' . $module_name);
                 break;
             case 'edit':
             case 'add':
                 if (SJB_Request::getVar('templ_module') && SJB_Request::getVar('templ_name')) {
                     $newTemplName = trim(SJB_Request::getVar('templ_name'));
                     $newModuleName = SJB_Request::getVar('templ_module');
                     if (!$template_editor->isTemplateNameValid($newTemplName)) {
                         $error[] = 'NOT_VALID_FILENAME_FORMAT';
                     }
                     if (!$template_editor->doesModuleExists($newModuleName)) {
                         $error[] = 'MODULE_ERROR';
                     }
                     if (empty($error)) {
                         if ('edit' == $action) {
                             if ($template_editor->moveTemplate(SJB_Request::getVar('templ_name_or'), SJB_Request::getVar('templ_module_or'), $theme, $newModuleName, $newTemplName)) {
                                 if ($form_submitted == 'save_template') {
                                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/edit-templates/?module_name=' . $newModuleName);
                                 }
                                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/edit-templates/?module_name=' . $newModuleName . '&template_name=' . $newTemplName);
                                 exit;
                             } else {
                                 $error[] = 'CANT_MOVE_FILE';
                             }
                         } else {
                             if ($template_editor->createTemplate($theme, $newModuleName, $newTemplName, $error)) {
                                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/edit-templates/?module_name=' . $newModuleName . '&template_name=' . $newTemplName);
                             }
                             $error[] = 'CANT_CREATE_FILE';
                         }
                     }
                 }
                 break;
             default:
                 break;
         }
     }
     // не работало в юзерской
     if (empty($template_name)) {
         $template_name = SJB_Request::getVar('template_name', '');
     }
     if (empty($module_name)) {
         $module_name = SJB_Request::getVar('module_name', '');
     }
     // edittemplate
     if (!empty($template_name) && !empty($module_name)) {
         $menu_path = array(array('reference' => '?', 'name' => 'Edit Templates'), array('reference' => "?module_name={$module_name}", 'name' => $modules[$module_name]['display_name']), array('name' => $template_name, 'reference' => ''));
         $tp->assign('navigation', $menu_path);
         $tp->assign('errors', $error);
         $tp->assign('title', 'Edit Templates: ' . $modules[$module_name]['display_name'] . ' / Template: ' . $template_name);
         $tp->assign('show_clear_cache_setting', false);
         $tp->assign('show_highlight_setting', false);
         if (!$simple_view) {
             $tp->display('navigation_menu.tpl');
         }
         echo SJB_System::executeFunction('template_manager', 'edit_template');
     } else {
         if (!empty($module_name)) {
             $menu_path = array(array('reference' => '?', 'name' => 'Edit Templates'), array('reference' => '', 'name' => $modules[$module_name]['display_name']));
             $tp->assign('navigation', $menu_path);
             $tp->assign('title', 'Edit Templates');
             $tp->assign('errors', $error);
             $tp->assign('show_clear_cache_setting', false);
             $tp->assign('show_highlight_setting', false);
             if (!$simple_view) {
                 $tp->display('navigation_menu.tpl');
             }
             echo SJB_System::executeFunction('template_manager', 'template_list');
         } else {
             $menu_path = array(array('reference' => '', 'name' => 'Edit Templates'));
             $tp->assign('navigation', $menu_path);
             $tp->assign('title', 'Edit Templates');
             $tp->assign('show_clear_cache_setting', true);
             $tp->assign('show_highlight_setting', true);
             $tp->assign('result', $result);
             $tp->assign('errors', $error);
             if (!$simple_view) {
                 $tp->display('navigation_menu.tpl');
             }
             echo SJB_System::executeFunction('template_manager', 'add_template');
             echo SJB_System::executeFunction('template_manager', 'module_list');
         }
     }
 }