首页 > 编程技术 > php

phpweb更换百度编辑器的配置教程

发布时间:2016-11-25 17:20

phpweb是一个企业建站系统了可以快速的实现企业群站创建了,但这款使用的编辑器并不是百度编辑器对于小编来讲是非常喜欢百度编辑器了,下面一起来看看phpweb更换百度编辑器的配置。

准备工作:

1.从UEditor 官网上面下载 最新版本的UEditor,现在最新版本为ueditor1_4_3-utf8-php,请下载php版本。

2.我们更换的是 news 模块下的编辑器,也就是新闻模块,请确保news/admin/下面,news_conadd.php,news_conmod.php,已经破解出源码,如果没有,请自行百度!

开始动手:

1.解压下载的压缩包直接到phpweb根目录

2.打开news_conadd.php文件夹

找到以下代码:

 代码如下 复制代码

<input type="hidden" name="body" value="<?php echo $body; ?>" />
<script type="text/javascript"" width=100% src="../../kedit/KindEditor.js"></script>
<script type="text/javascript">

var editor = new KindEditor("editor");
 editor.hiddenName = "body";
 editor.editorWidth = "680px";
 editor.editorHeight = "300px";
 editor.skinPath = "../../kedit/skins/default/";
 editor.uploadPath = "../../kedit/upload_cgi/upload.php";
 editor.imageAttachPath="news/pics/";
 editor.iconPath = "../../kedit/icons/";
 editor.show();
   function KindSubmit() {
editor.data();
 }

 </script>

然后直接注释掉,或者删除。

加入

 代码如下 复制代码
<script id="container" name="body" type="text/plain"></script>

然后在下面插入

 代码如下 复制代码
<!-- 配置文件 -->
<script type="text/javascript"" width=100% src="../../ueditor/ueditor.config.js"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript"" width=100% src="../../ueditor/ueditor.all.js"></script>
<!-- 实例化编辑器 -->
<script type="text/javascript">
var ue = UE.getEditor('container',{
   initialFrameWidth:"800",
   initialFrameHeight:"200"
  });
  
</script>

这样,新闻的添加就好了。

下面就是新闻的修改;

步骤和添加一样只是在实例化编辑器后面加入

 代码如下 复制代码

 <script type="text/javascript">
var ue = UE.getEditor('container',{
   initialFrameWidth:"800",
   initialFrameHeight:"200",
   
  });
  
  ue.ready(function() {
   //设置编辑器的内容
   ue.setContent('<?php echo htmlspecialchars_decode($body);?>');
   
   
  });
  
</script>

这样 修改就可以了。

注意:更换完成编辑器后,原来phpweb自带的分页就不能使用了

phpweb更换百度编辑器的配置教程

phpweb更换百度编辑器的配置教程

下面是修改新闻的时候:

phpweb更换百度编辑器的配置教程

写在最后:
百度UEditor 的上传图片路径是统一默认的,如果要修改,请打开 ueditor/php/config.json 下面进行修改。
KindEditor 是一套开源的在线HTML编辑器,主要用于让用户在网站上获得所见即所得编辑效果,开发人员可以用 KindEditor 把传统的多行文本输入框(textarea)替换为可视化了,下面我们就一起来看看phpweb更换kindeditor编辑器的过程,希望文章可帮助到各位。

都知道phpweb自带的编辑器很不好用,有的时候提交会出现很多问题! 今天开始动工把phpweb的编辑器给换了 首先更换news 模块下的编辑器

1.到kindeditor 官方网站上面下载最新的kindeditor包。
2.删除不用的文件夹,asp,jsp等
3.把kindeditor 的文件夹放入phpweb 根目录下
4.打开news/admin/news_conadd.php 大概108行处

 代码如下 复制代码

<input type=”hidden” name=”body” value=”<?php echo $body; ?>” />
<script type=”text/javascript”" width=100% src=”../../kedit/KindEditor.js”></script>
<script type=”text/javascript”>
var editor = new KindEditor(“editor”);
editor.hiddenName = “body”;
editor.editorWidth = “680px”;
editor.editorHeight = “300px”;
editor.skinPath = “../../kedit/skins/default/”;
editor.uploadPath = “../../kedit/upload_cgi/upload.php”;
editor.imageAttachPath=”news/pics/”;
editor.iconPath = “../../kedit/icons/”;
editor.show();
function KindSubmit() { editor.data(); }
</script>

更换为

 代码如下 复制代码

<script charset=”utf-8″" width=100% src=”../../kindeditor/kindeditor.js”></script>
<script charset=”utf-8″" width=100% src=”../../kindeditor/lang/zh_CN.js”></script>
<script>
var editor;
KindEditor.ready(function(K) {
editor = K.create(‘#editor_id’,{
width:’680px’,
height:’300px’,
uploadJson:’upload_json.php’,
fileManagerJson : ‘file_manager_json.php’,
allowFileManager : true,
syncType:”form”, afterCreate : function() { var self = this; self.sync(); }, afterChange : function() { var self = this; self.sync(); }, afterBlur : function() { var self = this; self.sync(); } }); }); </script>
<textarea  name=”body” id=”editor_id” style=”width:680px;height:300px;”/><?php echo $body;?></textarea>

注意:红色标注处,按照官方提供的demo.php文件中写的方法,得不到textarea 里面的内容! 5.复制kindeditorphp文件夹下面upload_json.php和file_manager_json.php (新版中存在 JSON.php也一起复制)文件到newsadmin下 修改2个文件

//文件保存目录路径 $save_path = $php_path . ‘../attached/'; //文件保存目录URL $save_url = $php_url . ‘../attached/';

//文件保存目录路径 $save_path = $php_path . ‘../pics/'; //文件保存目录URL $save_url = $php_url . ‘../pics/';

碰到问题

kindeditor 用ajax提交会出现如下问题: 提交第二次才能获取到真实的值。用如下方法解决:

加一个,afterChange: function (e) { this.sync() }  同步下数据即可

替换就ok:

现在这种多选择功能在很多网站都有,如现在很多电商网站都有N个条件选择了,下面小编为各位介绍一个简单的多级分类筛选实现方法。

主要注意这边有一个 $$这是变量的变量。 以后估计会常用这个做开发。

 代码如下 复制代码

<?php
 
$conditions = array('price','color','metal');//要进行筛选的字段放在这里
 
$price = $color = $metal='';//先给需要筛选的字段赋空值,这些值将输出到页面的hidden fileds 中
 
//以下循环给已经进行的筛选赋值,以便能够在下一次筛选中保留
 
foreach($conditions as $value){
 
    if(isset($_GET[$value])){
        $$value = $_GET[$value];
    }
 
}

 
//以下是演示输出$_GET数据
 
echo '<pre>';
 
print_r($_GET);
 
echo '</pre>';
 
?>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
 
<head>
 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 
<title>分类筛选演示</title>
 
<style type="text/css">
 
body{font-size:14px;font-family:Tahoma,"宋体"}
 
</style>
 
<script type="text/javascript">
 
function Filter(a,b){
 
    var $ = function(e){return document.getElementById(e);}
 
    var ipts = $('filterForm').getElementsByTagName('input'),result=[];
 
    for(var i=0,l=ipts.length;i<l;i++){
 
        if(ipts[i].getAttribute('to')=='filter'){
 
           result.push(ipts[i]);
 
       }
 
    }
 
   if($(a)){
 
        $(a).value = b;
 
        for(var j=0,len=result.length;j<len;j++){
 
           if(result[j].value==''){
 
               result[j].parentNode.removeChild(result[j]);
 
           }
 
       }
 
        document.forms['filterForm'].submit();
 
    }
 
    return false;
 
}
 
</script>
 
</head>
 
<body>
 
<form id="filterForm" action="test.php" method="get">
 
<!--
 
form的id 要和程序里统一
 
为避免与其他使用的隐藏域冲突,添加了to属性
 
以下是筛选字段隐藏域
 
需要筛选的隐藏域需要加 to 属性
 
-->
 
<input to="filter" type="hidden" id="price" name="price" value="<?=$price?>" />
 
<input to="filter" type="hidden" id="color" name="color" value="<?=$color?>" />
 
<input to="filter" type="hidden" id="metal" name="metal" value="<?=$metal?>" />
 
</form>
 
<!--
 
要筛选的属性可以由程序生成,注意规律!
 
-->
 
价格:<a href="javascript:Filter('price','');">不限</a>

<a href="javascript:Filter('price','100-1000');">100-1000</a>
 
      <a href="javascript:Filter('price','1001-2000');">1001-2000</a>
 
     <a href="javascript:Filter('price','2001-3000');">2001-3000</a><br/>
 
颜色:<a href="javascript:Filter('color','红色');">红色</a>
 
      <a href="javascript:Filter('color','蓝色');">蓝色</a><br />
 
材质:<a href="javascript:Filter('metal','纯金');">纯金</a>
 
      <a href="javascript:Filter('metal','纯银');">纯银</a><br />
 
</body>
 
</html>

以下是最近工作中总结的几个Drupal小问题,Drupal性能模块之简明分析对比,实现view动态输出的步骤方法,为Drupal主题添加主题内自带图片的正确方法。其中第一个是在网上找到的翻译国外内容,这此感谢这些默默翻译的高手。

Drupal性能模块的简明分析对比

原文:

Varnish

We explored various caching solutions available for Drupal. We shortlisted Varnish, Boost and Authcache modules. We performed a number of tests using these modules. We tested over 1000 pages from different locations. The average page load time without any caching was above 4.0 seconds. The average page load time with Drupal's default caching was 2.5 seconds. The average page load time with the Authcache module was reduced to 1.8 seconds. The average page load time with the Boost module was 1.7 seconds. The average page load time with Varnish module was 1.5 seconds. Therefore we preferred using the Varnish module. These stats are for this site only, the results may vary for other sites.

我简单翻译下:

用1000个不同的页面作的测试,

1.不用任何缓存模块:平均加载时间4秒以上;
2.使用drupal自带缓存:平均加载时间2.5秒;
3.使用Authcache模块,平均加载时间1.8秒;
4.使用Boost模块,平均加载时间1.7秒;
5.使用Varnish模块,平均加载时间1.5秒;

-----------------------------------------------

实现view动态输出的步骤方法

1、在 view 的属性页,选择 header
2、选择 Global: Text area
3、在弹出框里,覆写 输出
4、只有Replacement patterns 显示出来的字段,才能被调用
5、注意勾选 *Use replacement tokens from the first row

-----------------------------------------------

为Drupal主题添加主题内自带图片的正确方法

在为drupal的主题添加主题自带的一些图片的时候,会碰到一些路径问题,使用下面这些方法添加的图片,才能正确显示在页面上:

<img" width=100% src="<?php print $base_path . drupal_get_path('theme', 'yourtheme');?>/image/act-title.jpg">

在php标签里面输出url的时候要使用 $base_path 与 主题路径拼接出来的url 然后再加上主题目录里面的静态图片的路径,才能正确的显示.

验证URL有两种一种是利用正则表达式来验证URL是不是合适url规则了,另一个是利用函数来访问指定url看看是否可正常访问了,如果能正常访问自然就是合法的url地址了。

例子1

 代码如下 复制代码

<?php
function isValidUrl($url) {
 
    $patern = '/^http[s]?:\/\/'.
        '(([0-9]{1,3}\.){3}[0-9]{1,3}'.             // IP形式的URL- 199.194.52.184
        '|'.                                        // 允许IP和DOMAIN(域名)
        '([0-9a-z_!~*\'()-]+\.)*'.                  // 三级域验证- www.
        '([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\.'.     // 二级域验证
        '[a-z]{2,6})'.                              // 顶级域验证.com or .museum
        '(:[0-9]{1,4})?'.                           // 端口- :80
        '((\/\?)|'.                                 // 如果含有文件对文件部分进行校验
        '(\/[0-9a-zA-Z_!~\*\'\(\)\.;\?:@&=\+\$,%#-\/]*)?)$/';
 
    if(!preg_match($patern, $url)) {
        die( '您输入的URL格式有问题,请检查!');
    }
}

例子2

上面的例子只是验证url是不是正常的不代表是否可以访问了,我们可以使用如curl函数进行方法

 代码如下 复制代码

$url = "http://www.111cn.net ";
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_NOBODY, true);
$result = curl_exec($curl);
if ($result !== false)
{
  $statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); 
  if ($statusCode == 404)
  {
    echo "URL Not Exists"
  }
  else
  {
     echo "URL Exists";
  }
}
else
{
  echo "URL not Exists";
}

除了这个函数还可以使用php的很多函数如 file、file_get_contents()、fopen函数来进行检测了。

标签:[!--infotagslink--]

您可能感兴趣的文章: