Title1

Title2

Title3

MarkDown

``` 六、網頁編輯器 CKEDITOR 1. 官網:http://ckeditor.com 2. 下載Standard Package:http://ckeditor.com/download 3. 將下載檔案解壓縮至 class/ 4. 引入js 5. 調用插件 6. 程式碼 templates/admin/tpl/admin\_icon.html ```
          
``` 七、將elFinder整合至CKEDITOR 1. 官網: 2. 將下載檔案解壓縮至 class/elFinder 3. 引入elFinder ```
            
  ```
4. 修改 class/elFinder/elfinder.html ```
  
  
  
  	
  		
  		elFinder 2.1.x source version with PHP connector
  		
  
  		
  		
  		
  		
  
  		
  		
  		
  
  		
  		
  
  		
  		
  
          
          
  
          
          
  	
  	
  
  		
  		
``` 5. 修改 class/elFinder/php/connector.minimal.php ```
   true,
  	'roots' => array(
  		array(
  			'driver' => 'LocalFileSystem', // driver for accessing file system (REQUIRED)
  			'path' => WEB_PATH . "/uploads/", // path to files (REQUIRED)
  			'URL' => WEB_URL . "/uploads/", // URL to files (REQUIRED)
  			'uploadDeny' => array('all'), // All Mimetypes not allowed to upload
  			'uploadAllow' => array('image', 'text/plain'), // Mimetype `image` and `text/plain` allowed to upload
  			'uploadOrder' => array('deny', 'allow'), // allowed Mimetype `image` and `text/plain` only
  			'accessControl' => 'access', // disable and hide dot starting files (OPTIONAL)
  		),
  	),
  );
  
  // run elFinder
  $connector = new elFinderConnector(new elFinder($opts));
  $connector->run();
  ```
 
八、op\_insert

參考:

 ```
#################################
# 新增資料
#
#################################
function op_insert() {
	global $mysqli;
	//print_r($_POST);die();

	#資料過濾
	#http://php.net/manual/en/mysqli.real-escape-string.php
	$_POST['title'] = $mysqli->real_escape_string($_POST['title']);
	$_POST['target'] = intval($_POST['target']);
	$_POST['enable'] = intval($_POST['enable']);
	$_POST['sort'] = intval($_POST['sort']);
	$_POST['url'] = $mysqli->real_escape_string($_POST['url']);
	$_POST['kind'] = $mysqli->real_escape_string($_POST['kind']);

	#圖示、摘要與內容存成json
	$content['icon'] = $mysqli->real_escape_string($_POST['icon']);
	$content['summary'] = $mysqli->real_escape_string($_POST['summary']);
	$content['content'] = $mysqli->real_escape_string($_POST['content']);
	$_POST['content'] = json_encode($content, JSON_NUMERIC_CHECK | JSON_UNESCAPED_UNICODE);

	$sql = "insert into `creative_nav`
          (`title`, `target`, `enable`, `sort`,`url`,`kind`,`content`)
          VALUES
          ('{$_POST['title']}', '{$_POST['target']}', '{$_POST['enable']}', '{$_POST['sort']}', '{$_POST['url']}', '{$_POST['kind']}', '{$_POST['content']}')"; //die($sql);

	$mysqli->query($sql) or die(printf("Error: %s 
" . $sql, $mysqli->sqlstate)); $sn = $mysqli->insert_id; //傳回insert 指令所產生之流水號 return $sn; } ``` 九、op\_update ```
#################################
# 更新資料
#
#################################
function op_update($sn = "") {
	global $mysqli;
	if (!$sn) {
		redirect_header("index.php", 3000, "更新記錄錯誤!!");
	}

	#資料過濾
	$_POST['sn'] = intval($_POST['sn']);
	$_POST['title'] = $mysqli->real_escape_string($_POST['title']);
	$_POST['target'] = intval($_POST['target']);
	$_POST['enable'] = intval($_POST['enable']);
	$_POST['sort'] = intval($_POST['sort']);
	$_POST['url'] = $mysqli->real_escape_string($_POST['url']);

	#圖示、摘要與內容存成json
	$content['icon'] = $mysqli->real_escape_string($_POST['icon']);
	$content['summary'] = $mysqli->real_escape_string($_POST['summary']);
	$content['content'] = $mysqli->real_escape_string($_POST['content']);
	$_POST['content'] = json_encode($content, JSON_NUMERIC_CHECK | JSON_UNESCAPED_UNICODE);

	$sql = "update `creative_nav` set
          `title`  = '{$_POST['title']}' ,
          `target` = '{$_POST['target']}',
          `enable` = '{$_POST['enable']}',
          `url` = '{$_POST['url']}',
          `sort` = '{$_POST['sort']}',
          `content` = '{$_POST['content']}'
          where sn='{$_POST['sn']}'";

	$mysqli->query($sql) or die(printf("Error: %s 
" . $sql, $mysqli->sqlstate)); return $sn; } ``` 十、撈出單筆資料 1. get\_creative\_nav ```
  ########################################
  #取得單筆記錄
  ########################################
  function get_creative_nav($sn = "") {
    global $mysqli;
    if (!$sn) {
      redirect_header("index.php", 3000, "查詢選單資料錯誤!!");
    }
   
    $sql = "select *
            from `creative_nav`
            where `sn`='{$sn}' and `kind`= 'icon_home'";
    $result = $mysqli->query($sql) or die(printf("Error: %s 
" . $sql, $mysqli->sqlstate)); $row = $result->fetch_assoc(); #過濾撈出資料 $row['sn'] = intval($row['sn']); //http://www.w3school.com.cn/php/func_string_htmlspecialchars.asp $row['title'] = htmlspecialchars($row['title'], ENT_QUOTES); // 轉換雙引號和單引號 $row['url'] = htmlspecialchars($row['url'], ENT_QUOTES); // 轉換雙引號和單引號 $row['sort'] = intval($row['sort']); $row['enable'] = intval($row['enable']); $row['target'] = intval($row['target']); $content = json_decode($row['content'], true); //(PHP 5 >= 5.2.0 true=>array $row['icon'] = htmlspecialchars($content['icon'], ENT_QUOTES); // 轉換雙引號和單引號 $row['summary'] = htmlspecialchars($content['summary'], ENT_QUOTES); // 轉換雙引號和單引號 $row['content'] = htmlspecialchars($content['content'], ENT_QUOTES); // 轉換雙引號和單引號 return $row; } ``` 十一、op\_form 參考: ```
#################################
# 表單
# 選單關鍵字 icon_home
#################################
function op_form($sn = "") {
  global $mysqli, $smarty;
 
  #取得預設值
  if ($sn) {
    #編輯
    $row = get_creative_nav($sn); //取得單筆記錄
    $row['op'] = "op_update";
    $row['form_title'] = "編輯選單";
  } else {
    #新增
    $row = array();
    $row['op'] = "op_insert";
    $row['form_title'] = "新增選單";
  }
 
  #預設值設定
  $row['sn'] = (isset($row['sn'])) ? $row['sn'] : "";
  $row['title'] = (isset($row['title'])) ? $row['title'] : "";
  $row['enable'] = (isset($row['enable'])) ? $row['enable'] : 1;
  $row['target'] = (isset($row['target'])) ? $row['target'] : 0;
  $row['url'] = (isset($row['url'])) ? $row['url'] : "";
  $row['sort'] = (isset($row['sort'])) ? $row['sort'] : 0;
  $row['kind'] = (isset($row['kind'])) ? $row['kind'] : "icon_home";

  $row['icon'] = (isset($row['icon'])) ? $row['icon'] : "fa-android";
  $row['content'] = (isset($row['content'])) ? $row['content'] : "";
  $row['summary'] = (isset($row['summary'])) ? $row['summary'] : "";

 
  #把變數送至樣板
  $smarty->assign("row", $row);
}
```

十二、修改樣板

1. 用「新聞」取代「選單」在 icon.php 與 templates/admin/tpl/admin\_icon.html
2. 「textarea」預設值 ```
  
  
            
```