首页 \ 问答 \ ckeditor可以更新数据库内容吗?(can ckeditor update database content?)

ckeditor可以更新数据库内容吗?(can ckeditor update database content?)

你能给我一种方法将ckeditor的内容保存到数据库吗?

我有0%的想法,如何使事情工作,这将是第一次使用一个。 我在谷歌搜索但它总是显示fckeditor(他们是一样的吗?)。 另外,我已经尝试了一些带有AJAX的代码,但仍然无法使其工作,因为它需要一些插件,我实际上并不理解它。

无论如何,我使用4.0版本的ckeditor,更喜欢PHP或javascript代码,因为我真的不知道AJAX。 这是我的试用代码:

<!DOCTYPE html>
<!--
Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
-->

<?php
include('global.php');
?>

<html>
<head>

    <script>
        var type = 'Admin';

        <!-- editableContent -->
        window.onload = function (){
            if(type=='Admin'){
            document.getElementById('opener').contentEditable= true;
            document.getElementById('main').contentEditable= true;
            // We need to turn off the automatic editor creation first.
            CKEDITOR.disableAutoInline = true;
            var editor = CKEDITOR.inline( 'opener' );
            var editor = CKEDITOR.inline( 'main' );
            }
            else{
            document.getElementById('opener').contentEditable= false;
            document.getElementById('main').contentEditable= false;
            }
        }

        function showHTML () {
        document.getElementById('textpad').textContent = textEditor.document.body.innerHTML;
        return;
        }

    </script>


    <title>Inline Editing by Code &mdash; CKEditor Sample</title>
    <meta charset="utf-8">
    <script src="ckeditor/ckeditor.js"></script>
    <link href="ckeditor/samples/sample.css" rel="stylesheet">
    <style>

        #editable
        {
            padding: 10px;
            float: left;
        }

    </style>
</head>
<body>
    <div id="opener">
    <?
    $result= mysql_query ("SELECT * from text_tb WHERE categoryName='index'");
        while($row = mysql_fetch_array($result)){
        echo $row[1];
        }
    ?>
    </div>

    <div id="main">
    <?
    $result= mysql_query ("SELECT * from text_tb WHERE categoryName='about'");
        while($row = mysql_fetch_array($result)){
        echo $row[1];
        }
    ?>
    </div>
</body>
</html>

非常感谢您的时间和帮助。


can you give me a way to save the contents of the ckeditor to the database?

i have 0% idea on how to make things work for this would be the first time to be use one. i've searched on google but it always shows the fckeditor(are they the same?). also, i've tried some codes with AJAX on it but still couldn't make it work because it requires some plugin and i don't actually understand it.

anyway, i'am using the 4.0 version of ckeditor and would prefer php or javascript code because i don't really know AJAX. here's my trial code:

<!DOCTYPE html>
<!--
Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
-->

<?php
include('global.php');
?>

<html>
<head>

    <script>
        var type = 'Admin';

        <!-- editableContent -->
        window.onload = function (){
            if(type=='Admin'){
            document.getElementById('opener').contentEditable= true;
            document.getElementById('main').contentEditable= true;
            // We need to turn off the automatic editor creation first.
            CKEDITOR.disableAutoInline = true;
            var editor = CKEDITOR.inline( 'opener' );
            var editor = CKEDITOR.inline( 'main' );
            }
            else{
            document.getElementById('opener').contentEditable= false;
            document.getElementById('main').contentEditable= false;
            }
        }

        function showHTML () {
        document.getElementById('textpad').textContent = textEditor.document.body.innerHTML;
        return;
        }

    </script>


    <title>Inline Editing by Code &mdash; CKEditor Sample</title>
    <meta charset="utf-8">
    <script src="ckeditor/ckeditor.js"></script>
    <link href="ckeditor/samples/sample.css" rel="stylesheet">
    <style>

        #editable
        {
            padding: 10px;
            float: left;
        }

    </style>
</head>
<body>
    <div id="opener">
    <?
    $result= mysql_query ("SELECT * from text_tb WHERE categoryName='index'");
        while($row = mysql_fetch_array($result)){
        echo $row[1];
        }
    ?>
    </div>

    <div id="main">
    <?
    $result= mysql_query ("SELECT * from text_tb WHERE categoryName='about'");
        while($row = mysql_fetch_array($result)){
        echo $row[1];
        }
    ?>
    </div>
</body>
</html>

thank you very much for your time and help.


原文:https://stackoverflow.com/questions/14005247
更新时间:2022-04-30 18:04

最满意答案

没有

TimeStamps stamps = realm.where(TimeStamps.class).findFirst();

这会在当前线程上获得stamps

if(!timeStamps.getInfractionTimeStamps()。equalsIgnoreCase( stamps.getInfractionTimeStamps() ))

这会尝试访问不同线程上的stamps实例,因此您将收到IllegalStateException

返回null;

即使它确实起作用,这条线也会使RxJava2抛出一个NullPointerException异常

.subscribeOn(Schedulers.newThread())

这可以很容易地被Schedulers.io()代替,所以它不会创建太多的线程(尽管当然你应该确保使用try(Realm realm = ...)或者finally { realm.close() }

.subscribe(new Observer>(){

这是错误的,除非你“正确地实现了onSubscribe”,这是不应该的,这应该是new DisposableObserver<List<Infraction>>()

在这种情况下,您的Retrofit界面应该可能会公开Single<T> ,因为完成后单身会自动取消订阅。


Single<TimeStamps> callTimeStamp = apiInterface.getTimeStamp();

   callTimeStamp.flatMap((timeStamps) -> {
        try(Realm realm = Realm.getDefaultInstance()) {
            TimeStamps stamps = realm.where(TimeStamps.class).findFirst();
            if(!timeStamps.getInfractionTimeStamps().equalsIgnoreCase( stamps.getInfractionTimeStamps()))
                return apiInterface.getInfractions();
            else
                return Single.never();
       }
   }).subscribeOn(Schedulers.io())
     .observeOn(AndroidSchedulers.mainThread())
     .subscribe(new DisposableObserver<List<Infraction>>() {
       @Override
       public void onNext(List<Infraction> infractions) {

       }

       @Override
       public void onError(Throwable e) {

       }

       @Override
       public void onComplete() {

       }
   });

No

TimeStamps stamps = realm.where(TimeStamps.class).findFirst();

This obtains stamps on the current thread

if(!timeStamps.getInfractionTimeStamps().equalsIgnoreCase( stamps.getInfractionTimeStamps()))

This attempts to access that stamps instance on a different thread, so you'll get an IllegalStateException

return null;

Even if it did work, this line would make RxJava2 throw a NullPointerException

.subscribeOn(Schedulers.newThread())

This could easily be Schedulers.io() instead so that it wouldn't create too many threads (although then of course you should make sure you use try(Realm realm = ...) or finally { realm.close() })

.subscribe(new Observer>() {

This is wrong unless you "properly implement onSubscribe" which is not expected at all, this should be new DisposableObserver<List<Infraction>>().

In which case your Retrofit interface should probably expose Single<T>, as singles automatically unsubscribe when done.


Single<TimeStamps> callTimeStamp = apiInterface.getTimeStamp();

   callTimeStamp.flatMap((timeStamps) -> {
        try(Realm realm = Realm.getDefaultInstance()) {
            TimeStamps stamps = realm.where(TimeStamps.class).findFirst();
            if(!timeStamps.getInfractionTimeStamps().equalsIgnoreCase( stamps.getInfractionTimeStamps()))
                return apiInterface.getInfractions();
            else
                return Single.never();
       }
   }).subscribeOn(Schedulers.io())
     .observeOn(AndroidSchedulers.mainThread())
     .subscribe(new DisposableObserver<List<Infraction>>() {
       @Override
       public void onNext(List<Infraction> infractions) {

       }

       @Override
       public void onError(Throwable e) {

       }

       @Override
       public void onComplete() {

       }
   });

相关问答

更多
  • 由于您使用的是RxJava,因此在出现网络错误时会调用onError ,并且端点相关的错误是Response一部分。 如果出现错误,请检查throwable是否是HttpException的实例 public void onError(Throwable e) { if (e instanceof HttpException) { 如果检查结果为真,您的请求中有错误。 将throwable投射到HttpException ,并且访问是成员。 例如 ((HttpException) e).respo ...
  • 没有 TimeStamps stamps = realm.where(TimeStamps.class).findFirst(); 这会在当前线程上获得stamps if(!timeStamps.getInfractionTimeStamps()。equalsIgnoreCase( stamps.getInfractionTimeStamps() )) 这会尝试访问不同线程上的stamps实例,因此您将收到IllegalStateException 返回null; 即使它确实起作用,这条线也会使RxJava ...
  • return getauthenticationtoken.getToken().subscribeOn(Schedulers.io()); 但您也可以使用默认调度程序创建调用适配器,它可以是Schedulers.io()。 return new Retrofit.Builder() .addConverterFactory(SimpleXmlConverterFactory.create()) .baseUrl("http://thecatapi.co ...
  • 你可以使用concatMap操作符 ,它只有在完成之前才会开始处理下一个项目。 下面是一个例子,其中events$以200ms的间隔出现,然后以不同的持续时间连续处理: const { Observable } = Rx; const fakeWriteRequest = data => { console.log('started working on: ', data); return Observable.of(data).delay(Math.random() * 2000); ...
  • 在这里,这是在Rx中发出Web请求的最佳方式。 public IObservable MakeWebRequest( Uri uri, Dictionary headers = null, string content = null, int retries = 3, TimeSpan? timeout = null) { var request = Obse ...
  • 我以这种方式工作。 我仍然需要了解如何使用composit订阅。 RadioLiveInfoObservableService radioLiveInfoObservableService=ApiProvider.getInstance().getRadioObserverInfo(); radioLiveInfoObservableService.commits(Type.INTERVAL) .observeOn(AndroidSchedulers.mainThread()) ...
  • 您可以使用Transformer来创建通用状态代码验证程序: class StatusCodeVerifierTransformer implements Observable.Transformer, T> { @Override public Observable call(Observable> responseObservable) { return responseObservable.flatMap(n ...
  • NoClassDefFoundError经常发生在构建工具和/或热交换在更改依赖关系后无法更新时。 尝试Build > Clean Project ,然后再次运行。 NoClassDefFoundError often happens when the build tools and/or hot-swapping fails to update after changing dependencies. Try a Build > Clean Project and then run again.
  • getNews() .flatMap { Observable.fromIterable(it.getTopicsList()) } //or Observable.from() if you use RxJava1 .flatMap({ getNewsImage(it) }, { topic, imageUrl -> topic.imageUrl = imageUrl return@flatMap topic ...
  • 在RxJava中,您可以从常规Java执行程序创建自己的调度程序: ExecutorService exec= Executors.newFixedThreadPool(2); //2 Fixed threads Schedulers.from(exec); 因此,只需为每个资源创建一个具有有限数量线程的执行程序,并在访问资源时使用该特定调度程序。 有限数量的线程将限制并发调用的数量。 编辑: 显然我误解了这个问题。 如果调用是异步的,您可以尝试使用Rx的背压来管理它们。 以下是如何使用Rx管理此类调用的 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)