无法阅读财产' getEditor'未定义的

时间:2017-12-05 19:32:34

标签: javascript ckeditor

我正在使用CKEditor在网站上工作。我尝试合并Image Uploader插件(https://ckeditor.com/cke4/addon/uploadimage)。当我尝试复制图像时,出现错误:"无法读取属性' getEditor'未定义"。我相当确定我正确安装了文件,因为我可以将照片粘贴到textarea中,但无法发布。该插件的文档(https://docs.ckeditor.com/ckeditor4/docs/#!/guide/dev_file_upload)提到了该插件所需的许多不同代码,而且我很可能缺少这些文件,但文档不是很清楚且难以理解。如果问题是我错过了那些文件,如果有人能向我解释,我将非常感激。这是我正在使用的文件的代码:

<?php
    error_reporting(E_ERROR | E_WARNING | E_PARSE);
    require_once('../utils.php');


    $access = $_REQUEST['access'];
    $selectedPost = $_REQUEST['selectedPost'];
    $submit = $_REQUEST['submit'];

    $create = $_REQUEST['create'];
    $delete = $_REQUEST['delete'];
    $save = $_REQUEST['save'];
?>
<html>

    <head>
        <style>
        body
        {
            background-image: url('../imgs/background.jpg');
            text-align: left;
        }

        h2 {
            color: #880000;
        }

        #wrapper
        {
        font-family: arial;

        padding-top: 50px;
        padding-bottom: 50px;

        padding-left: 20px;
        padding-right: 20px;

        background: #FFFFFF;
        width: 800px;
        }
        </style>

        <script type="text/javascript" language="javascript" src="ckeditor/ckeditor.js"></script>
    </head>

    <body>


    <div id="wrapper">

        <?php

        // PRINTING OUT PAGE STUFF
        echo '<h2>Manage News Posts</h2>';

        // Boot you out if you lack the login stuff in the POST
        if(!$access) {
            echo '<h2>Invalid Login Credentials.</h2>';
            echo '<a href="index.php">Back</a>';

        }

        // We are authenticated
        else {

            // Something was submitted.  Do whatever we are trying to, then dump us back
            // to the main post selection UI.
            if($submit) {

                if($create) {
                    $query = "INSERT INTO blog_posts VALUES (NULL, '" . $_REQUEST['postSubject'] . "', '" . $_REQUEST['postBody']  . "', CURRENT_DATE)";

                    $insertPost = doQuery($query);
                    $query = '';


                    if($insertPost) {
                        echo '<i><h4>New Post Created!</h4></i>';
                    }
                    else {
                        echo '<i><h4>Error encountered during New Post creation!</h4></i>';
                    }

                }

                else if ($save) {
                    $query = "UPDATE blog_posts SET subject = '" . $_REQUEST['postSubject'] . "', body = '" . $_REQUEST['postBody'] . "' WHERE post_id = " . $selectedPost;

                    $updatePost = doQuery($query);
                    $query = '';

                    if($updatePost) {
                        echo '<i><h4>Post Updated Successfully!</h4></i>';
                    }
                    else {
                        echo '<i><h4>Error encountered during post update!</h4></i>';
                    }
                }

                else if ($delete) {
                    $query = "DELETE FROM blog_posts WHERE post_id = " . $selectedPost;
                    $deletePost = doQuery($query);
                    $query = '';

                    if($deletePost) {
                        echo '<i><h4>Post Deleted.</h4></i>';
                    }
                    else {
                        echo '<i><h4>Error encountered during deletion!</h4></i>';
                    }
                }

                $selectedPost = false;
                $save = false;
                $create = false;
                $delete = false;
            }

            // Nothing selected, show the selection page.
            if(!$create && !$selectedPost) {
                echo '<form method="post" action="admin_posts.php?access=1">';
                $query = "SELECT * FROM blog_posts ORDER BY post_id ASC";

                $all_posts = getResults($query);

                // Lay out selections
                foreach($all_posts as $post) {
                    echo '<input type="radio" name="selectedPost" value="' . $post['POST_ID'] . '"/>' . '&nbsp;&nbsp;' . $post['SUBJECT'] . '  - (Posted on ' . $post['POST_DATE'] . ')<br/>';
                }

                echo '<input type="submit" value="Select" />';
                echo '</form>';

                // Create post button, gets its own form.
                echo '<br/><br/>';
                echo '<form method="post" action="admin_posts.php?access=1&create=1">';
                    echo '<input type="submit" value="Write New Post">';
                echo '</form>';

                // Back button
                echo '<a href="admin_main.php?access=1">Back</a>';
            }
            // End initial "nothing selected" box


            // Something is selected, display its info for editing.
            else {
                echo '<br/>';

                $post_subject = '';
                $post_body = '';

                if(!$create) {
                    $query = "SELECT * FROM blog_posts WHERE post_id = $selectedPost";
                    $post_data = getSingleRow($query);

                    $post_subject = $post_data['SUBJECT'];
                    $post_body = $post_data['BODY'];
                }

                // Print out the dialogue for creating and editing post
                echo '<form method="post" action="admin_posts.php?access=1&submit=1">';

                    echo '<h4>Subject</h4>';
                    echo '<input name="postSubject" type="text" value="' . $post_data['SUBJECT'] . '" size=100/>';

                    echo '<br/>';

                    echo '<h4>Post Body</h4>';
                    echo '<textarea id="postBody" name="postBody" type="text" rows="25" cols="75">' . $post_data['BODY'] . '</textarea>';

                    echo '<br/><br/>';

                    if($create) {
                        echo '<input type="hidden" name="saveNewPost" value="1">';
                        echo '<input type="hidden" name="create" value="1">';
                    }

                    else {
                        echo '<input type="hidden" name="selectedPost" value="' . $selectedPost . '">';
                        echo '<input type="hidden" name="save" value="1">';
                    }

                    echo '<input type="submit" value="Save Post" />';

                echo '</form>';

                // Delete button.  Only if you are editing.
                // Gets its own submit form.
                if(!$create) {
                    echo '<form method="post" action="admin_posts.php?access=1&submit=1&delete=1" onsubmit="return confirm(\'Are you sure you want to delete this post?\');">';
                        echo '<input type="hidden" name="selectedPost" value="' . $selectedPost . '">';
                        echo '<input type="submit" value="Delete Post">';
                    echo '</form>';
                }

                echo '<br/><br/>';

                // Back button
                echo '<a href="admin_posts.php?access=1">Back</a>';
            }
        }
        ?>

    <script type="text/javascript" src="ckeditor/ckeditor.js"></script>
    <script type="text/javascript">
        bkLib.onDomLoaded(function()
        {
            CKEDITOR.replace( 'postBody' );
        });
    </script>

    </div>
    </body>
</html>

0 个答案:

没有答案