溫瑞烘老師的教學歷程檔案(Teaching ePortfolio) - 104-1-資料庫程式設計-進階 - 第10週-CKEditor HTML編輯器
 

資訊管理系
副教授
温瑞烘


歷程檔案 Portfolio


關於我 About Me

第10週-CKEditor HTML編輯器

CKEditor,是一個專門使用在網頁上屬於開放原始碼的所見即所得HTML文字編輯器。
它可和PHP、JavaScript、ASP、Java等不同的程式語言相結合。
CKEditor 相容於絕大部分的網頁瀏覽器,像是:IE、Chrome、Firefox、Mozilla、Netscape。

如何使用
1. 將ckeditor資料夾放置於localhost/myep/之下
2. 利用下列範例寫一程式測試

<?php
 
  $command=$_POST["command"];
  if ($command=="") {
    display_first_page();
  }elseif ($command=="儲存" ) {
    display_store_page();
    //echo "<script>  window.history.back() </script>";
  }
 
  function display_first_page() {
    echo "<html><head><title>認識CKEditor網頁編輯器</title>
          <link rel='stylesheet' type='text/css' href='style.css'>
          </head><body><center>
          <form method='post' action=''>
          <textarea name='content' id='content' rows=30 cols=80 >$content</textarea>";
    include_once "./ckeditor/ckeditor.php";
    $CKEditor = new CKEditor();
    $CKEditor->basePath = './ckeditor/';
    $CKEditor->replace("content");
    echo "<input type='submit' name='command' value='儲存'>
          </form></center></body></html>";
  }
 
  function display_store_page() { 
    $content=trim($_POST["content"]); 
    $content=htmlspecialchars($content);
    echo $content;
  }
 
?>

3. 將ckeditor/config.js加以編輯, 選擇你認為常用的功能

/*
Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
 
CKEDITOR.editorConfig = function( config ) {
 
  CKEDITOR.config.toolbar_Full =
[
{ name: 'document',items : [ 'Source','-','Save','NewPage','DocProps','Preview','Print','-','Templates' ] },
{ name: 'clipboard',items : [ 'Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo' ] },
{ name: 'editing',items : [ 'Find','Replace','-','SelectAll','-','SpellChecker', 'Scayt' ] },
{ name: 'forms',items : [ 'Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField' ] },
'/',
{ name: 'basicstyles',items : [ 'Bold','Italic','Underline','Strike','Subscript','Superscript','-','RemoveFormat' ] },
{ name: 'paragraph',items : [ 'NumberedList','BulletedList','-','Outdent','Indent','-','Blockquote','CreateDiv','-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl' ] },
{ name: 'links',items : [ 'Link','Unlink','Anchor' ] },
{ name: 'insert',items : [ 'Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak','Iframe' ] },
'/',
{ name: 'styles',items : [ 'Styles','Format','Font','FontSize' ] },
{ name: 'colors',items : [ 'TextColor','BGColor' ] },
{ name: 'tools',items : [ 'Maximize', 'ShowBlocks','-','About' ] }
];
 
 
};

4. 作業: (1). 將前述2之範例擴充, 顯示結果之後丟出一個按鈕 "更新", 可以更新內容之後儲存
                (2). 分別使用第3項所設定的功能舉例,  檢視其原始碼, 並將結果放入本學期的作業中
               






 
全部共 1則留言
12-03 09:06:留言...
登入帳號密碼代表遵守學術網路規範
 


文章分類 Labels

 


最新文章 Top10

中華科技大學數位化學習歷程 - 意見反應