本文主要是介绍FCKeditor 2.6 在PHP+Zend Frameword 中的使用,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
具体的看FCKedit 官方文档,这里只记下了在ZF中的使用要点一、表单生成
1.这里是在控制器中的动作:
public function fckeAction(){
$oFCKeditor = new FCKeditor( ' FCKeditor1 ' );
$oFCKeditor -> BasePath = ' /fckeditor/ ' ; // must add .htaccess file in fckeditor directory, the content of this file only include 'RewriteEngine off'
$oFCKeditor -> Width = ' 600 ' ;
$oFCKeditor -> Height = ' 400 ' ;
$oFCKeditor -> Value = ' <p>This is some <strong>sample text</strong>. You are using <a href="http://www.fckeditor.net/">FCKeditor</a>.</p> ' ;
$this -> view -> fckeditor = $oFCKeditor ; // ->Create() ; //in this controller, not to call FCKeditor->Create(), call it must in view page
$this -> render();
}
$oFCKeditor = new FCKeditor( ' FCKeditor1 ' );
$oFCKeditor -> BasePath = ' /fckeditor/ ' ; // must add .htaccess file in fckeditor directory, the content of this file only include 'RewriteEngine off'
$oFCKeditor -> Width = ' 600 ' ;
$oFCKeditor -> Height = ' 400 ' ;
$oFCKeditor -> Value = ' <p>This is some <strong>sample text</strong>. You are using <a href="http://www.fckeditor.net/">FCKeditor</a>.</p> ' ;
$this -> view -> fckeditor = $oFCKeditor ; // ->Create() ; //in this controller, not to call FCKeditor->Create(), call it must in view page
$this -> render();
}
2.在 fcke.phtml 中:
< form name = " test " action = " /test/getfck " method = " POST " >
< ul >
< li > 用户 : < input type = " text " name = " userName " value = "" /></ li >
< li > 密码 : < input type = " password " name = " password " value = "" /></ li >
< li >
<? php
echo $this -> fckeditor -> Create();
?>
</ li >
</ ul >
< ul >
< li >< input type = " submit " value = " 提交 " />< input type = " reset " value = " 取消 " /></ li >
</ ul >
</ form >
二、获得表单值:
1.控制器中的动作
public function getfckAction(){
$this -> view -> userName = $sUser = $_POST [ ' userName ' ];
$this -> view -> password = $_POST [ ' password ' ];
$this -> view -> fckeValue = $_POST [ ' FCKeditor1 ' ];
$this -> render();
}
$this -> view -> userName = $sUser = $_POST [ ' userName ' ];
$this -> view -> password = $_POST [ ' password ' ];
$this -> view -> fckeValue = $_POST [ ' FCKeditor1 ' ];
$this -> render();
}
2. getfck.phtml
<? php
echo $this -> escape( $this -> userName) . ' <br/> ' ;
echo $this -> escape( $this -> password) . ' <br/> ' ;
echo $this -> fckeValue . ' <br/> ' ; // the FCKeditor already call htmlspecialchars() in fckeditor_5.php, not to use escape() on the view page;
?>
echo $this -> escape( $this -> userName) . ' <br/> ' ;
echo $this -> escape( $this -> password) . ' <br/> ' ;
echo $this -> fckeValue . ' <br/> ' ; // the FCKeditor already call htmlspecialchars() in fckeditor_5.php, not to use escape() on the view page;
?>
三、关键事项:
1.
在 fckeditor 目录、你要放上传文件的 userfiles 目录,以及其它不用解析的 public 目录( 我的这三个目录同入口文件 index.php 一起放在html 目录下)里要加上 .htaccess 文件,如下:
RewriteEngine Off
2.
图片上传:
功能开启
编辑 fckeditor/editor/filemanager/connectors/php/config.php
$Config [’Enabled’] = true ;
四、在FCKeditor 2.6中。发现在上传文件过程中,通过浏览服务器按钮打开的页面来上传,与直接点上传按钮后,这两种情况会有不同的结果---传到服务器不同的目录里,前者要传到 image 目录下,后者却直接传到
userfiles 目录下,可能是个 bug。
这篇关于FCKeditor 2.6 在PHP+Zend Frameword 中的使用的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!