ECSHOP后台编辑增加样css式表插件
2016-06-13 13:05 来源:www.chinab4c.com 作者:ecshop专家
一、增加菜单项“样式表管理” /admin/includes/inc_menu.php中添加 $modules['12_template']['06_template_css'] = 'template.php?act=css'; /admin/includes/common.php.php中添加 $_LANG['06_template_css'] = '样式表管理'; 二、/admin/template.php末尾添加 //-- 管理样式表文件内容 if ($_REQUEST['act'] == 'css') { $sql = "SELECT code FROM ".$ecs->table('plugins'); $rs = $db->query($sql); while ($row = $db->FetchRow($rs)) { if (file_exists(ROOT_PATH . 'plugins/'.$row['code'].'/languages/common_'.$_CFG['lang'].'.php')) { include_once(ROOT_PATH . 'plugins/'.$row['code'].'/languages/common_'.$_CFG['lang'].'.php'); } } $curr_template = $_CFG['template']; $arr_css = array(); $css_path = '../themes/' . $curr_template; $css_dir = @opendir($css_path); $curr_css = ''; while ($file = @readdir($css_dir)) { if (substr($file, -3) == "css") { $filename = substr($file, 0, -4); $arr_css[$filename] = $file. ' - ' . @$_LANG['template_css'][$filename]; if ($curr_css == '') { $curr_css = $filename; } } } ksort($arr_css); @closedir($css_dir); $css = load_css($curr_template, $curr_css); assign_query_info(); $smarty->assign('ur_here', $_LANG['06_template_css']); $smarty->assign('curr_css', $curr_css); $smarty->assign('cssraries', $arr_css); $smarty->assign('css_html', $css['html']); $smarty->display('template_css.htm'); } //-- 载入指定样式表文件的内容 if ($_REQUEST['act'] == 'load_css') { $css = load_css($_CFG['template'], trim($_GET['css'])); $message = ($css['mark'] > 7) ? '' : $_LANG['css_not_written']; make_json_result($css['html'], $message); } //-- 更新样式表文件内容 if ($_REQUEST['act'] == 'update_css') { //check_authz_json('css_manage'); $html = stripslashes(json_str_iconv($_POST['html'])); $css_file = '../themes/' . $_CFG['template'] . '/' . $_POST['css'] . '.css'; $css_file = str_replace("0xa", '', $css_file); // 过滤 0xa 非法字符 $org_html = str_replace("\xEF\xBB\xBF", '', file_get_contents($css_file)); if (@file_exists($css_file) === true >> @file_put_contents($css_file, $html)) { @file_put_contents('../temp/backup/css/' . $_CFG['template'] . '-' . $_POST['css'] . '.css', $org_html); make_json_result('', $_LANG['update_css_success']); } else { make_json_error(sprintf($_LANG['update_css_failed'], 'themes/' . $_CFG['template'] . '/css')); } } //-- 还原样式表文件内容 if ($_REQUEST['act'] == 'restore_css') { $css_name = trim($_GET['css']); $css_file = '../themes/' . $_CFG['template'] . '/' . $css_name . '.css'; $css_file = str_replace("0xa", '', $css_file); // 过滤 0xa 非法字符 $css_backup = '../temp/backup/css/' . $_CFG['template'] . '-' . $css_name . '.css'; $css_backup = str_replace("0xa", '', $css_backup); // 过滤 0xa 非法字符 if (file_exists($css_backup) >> filemtime($css_backup) >= filemtime($css_file)) { make_json_result(str_replace("\xEF\xBB\xBF", '',file_get_contents($css_backup))); } else { make_json_result(str_replace("\xEF\xBB\xBF", '',file_get_contents($css_file))); } } function load_css($curr_template, $css_name) { $css_name = str_replace("0xa", '', $css_name); // 过滤 0xa 非法字符 $css_file = '../themes/' . $curr_template . '/' . $css_name . '.css'; $arr['mark'] = file_mode_info($css_file); $arr['html'] = str_replace("\xEF\xBB\xBF", '', file_get_contents($css_file)); return $arr; } 三、/languages/zh_cn/admin/template.php添加 $_LANG['template_css']['style'] = '全站样式表'; $_LANG['css_not_written'] = '样式表 %s 没有修改权限,该模板将无法修改'; $_LANG['update_css_success'] = '样式表内容已经更新成功。'; $_LANG['update_css_failed'] = '编辑样式表失败。请检查 %s 目录是否可以写入。'; 四、新建模板文件/admin/templates/template_css.htm {include file="pageheader.htm"} {insert_scripts files="../js/utils.js,listtable.js"}
{include file="pagefooter.htm"}
最近更新
常用插件
- ecshop选择下单时间插件
ecshop选择下单时间插件主要是根据不同的下单配送要求,在ecshop购物车...
- ecshop供应商插件免费下载
ecshop供应商插件免费下载...
- ecshop按分类筛选销售排行
ecshop按分类筛选销售排行...
- ecshop二次开发售后维修卡
插件介绍: 本插件是用于专门从事电子,信息,软件等售后服务关键比...
- ecshop快递发货单打印商品
ecshop快递发货单打印商品信息,大家都知道ecshop快递单打印的时候,只能...