線上書籍

Home

PHP SMARTY 樣板引擎

一、修改tadtools

  1. 下載
  2. 解壓縮,將「ckeditor」、「elFinder」、「jquery」、「bootstrap3」、「upload」複製到 /class 底下
  3. /class/ck.php <?php defined('WEB_URL') || die("WEB root path not defined"); class CKEditor { public $DirName; public $ColName; public $CustomConfigurationsPath; public $ToolbarSet = "my"; public $Width = '100%'; public $Height = 300; public $Value; public $ContentsCss = array(); public $demopublickey = ""; //建構函數 public function __construct($DirName = "", $ColName = "", $Value = "") { //$xoopsModuleConfig = TadToolsXoopsModuleConfig(); $this->DirName = $DirName; $this->ColName = $ColName; $this->Value = $Value; // if (!empty($xoopsModuleConfig['uploadcare_publickey'])) { // $this->set_demopublickey($xoopsModuleConfig['uploadcare_publickey']); // } } //設定自定義設定檔 public function setCustomConfigurationsPath($path = "") { $this->CustomConfigurationsPath = $path; } //設定自定義工具列 public function setToolbarSet($ToolbarSet = "") { $this->ToolbarSet = $ToolbarSet; } //設定自定義設寬度 public function setWidth($Width = "") { $this->Width = $Width; } //設定自定義設高度 public function setHeight($Height = "") { $this->Height = $Height; } //新增樣式 public function setContentCss($ContentsCss = "") { $this->ContentsCss[] = $ContentsCss; } public function set_demopublickey($demopublickey = "") { $this->demopublickey = $demopublickey; } //產生編輯器 public function render() { global $xoTheme; $_SESSION['DirName'] = $this->DirName; // before being fed to the textarea of CKEditor $content = str_replace('&', '&amp;', $this->Value); $content = str_replace('[', '&#91;', $content); $other_css = ''; if ($this->ContentsCss) { $other_css = ",'" . implode("','", $this->ContentsCss) . "'"; } $editor = " <script type='text/javascript' src='" . WEB_URL . "/class/ckeditor/ckeditor.js'></script> <textarea name='{$this->ColName}' id='editor_{$this->ColName}' class='ckeditor_css'>{$content}</textarea> <script type='text/javascript'> CKEDITOR.replace('editor_{$this->ColName}' , { skin : 'moono' , width : '{$this->Width}' , height : '{$this->Height}' , language : 'zh-TW' , toolbar : '{$this->ToolbarSet}' , contentsCss : ['" . WEB_URL . "/class/bootstrap3/css/bootstrap.css','" . WEB_URL . "/class/ckeditor/plugins/fontawesome/font-awesome/css/font-awesome.min.css'{$other_css}], extraPlugins: 'syntaxhighlight,oembed,eqneditor,imagerotate,fakeobjects,widget,lineutils,widgetbootstrap,widgettemplatemenu,pagebreak,fontawesome,codemirror,quicktable', filebrowserBrowseUrl : '" . WEB_URL . "/class/elFinder/elfinder.php?type=file&mod_dir=" . $this->DirName . "', filebrowserImageBrowseUrl : '" . WEB_URL . "/class/elFinder/elfinder.php?type=image&mod_dir=" . $this->DirName . "', filebrowserFlashBrowseUrl : '" . WEB_URL . "/class/elFinder/elfinder.php?type=flash&mod_dir=" . $this->DirName . "', filebrowserUploadUrl : '" . WEB_URL . "/class/upload.php?type=file&mod_dir=" . $this->DirName . "', filebrowserImageUploadUrl : '" . WEB_URL . "/class/upload.php?type=image&mod_dir=" . $this->DirName . "', filebrowserFlashUploadUrl : '" . WEB_URL . "/class/upload.php?type=flash&mod_dir=" . $this->DirName . "', qtRows: 10, // Count of rows qtColumns: 10, // Count of columns qtBorder: '1', // Border of inserted table qtWidth: '100%', // Width of inserted table qtStyle: { 'border-collapse' : 'collapse' }, qtClass: 'table table-bordered table-hover table-condensed', // Class of table qtCellPadding: '0', // Cell padding table qtCellSpacing: '0', // Cell spacing table qtPreviewBorder: '1px double black', // preview table border qtPreviewSize: '15px', // Preview table cell size qtPreviewBackground: '#c8def4' // preview table background (hover) } ); </script> <script>CKEDITOR.dtd.\$removeEmpty['span'] = false;</script> "; return $editor; } } /* $DirName = "prod"; mk_dir(WEB_PATH . "/uploads/{$DirName}"); mk_dir(WEB_PATH . "/uploads/{$DirName}/image"); mk_dir(WEB_PATH . "/uploads/{$DirName}/flash"); include_once WEB_PATH . "/class/ck.php"; $fck = new CKEditor($DirName, "content", $row['content']); $fck->setHeight(350); $row['content'] = $fck->render(); */

     

  4. /class/upload.php <?php //此檔案是給 ck.php 用的,勿刪 require_once dirname(dirname(__FILE__)).'/head.php'; include_once dirname(__FILE__)."/upload/class.upload.php"; $mdir = $_SESSION['DirName']; $path = WEB_PATH . "/uploads/{$mdir}/{$_GET['type']}/"; $url = WEB_URL . "/uploads/{$mdir}/{$_GET['type']}/"; $type_arr = array('image', 'file', 'flash'); //判斷是否是非法調用 if (empty($_GET['CKEditorFuncNum'])) { mkhtml(1, "", "error"); } $fn = $_GET['CKEditorFuncNum']; if (!in_array($_GET['type'], $type_arr)) { mkhtml(1, "", "error"); } $foo = new Upload($_FILES['upload']); if ($foo->uploaded) { // save uploaded image with no changes $foo->Process($path); if ($foo->processed) { $msg = $url . $_FILES['upload']['name']; mkhtml($fn, $msg); } else { $msg = 'error : ' . $foo->error; mkhtml($fn, "", $msg); } } function mkhtml($fn, $fileurl, $message) { $str = '<script type="text/javascript">window.parent.CKEDITOR.tools.callFunction(' . $fn . ', \'' . $fileurl . '\', \'' . $message . '\');</script>'; exit($str); }

     

  5. 將 /class/elFinder/  「$LANGCODE = str_replace("-", "_", _LANGCODE); 」替換成 「$LANGCODE = "zh_TW";」 
  6. 將 /class/elFinder/  「include_once $GLOBALS['xoops']->path('/modules/system/include/functions.php');」替換成 「」
  7. 將 /class/elFinder/ 「../../../mainfile.php」替換成 「../../head.php」
  8. 將 /class/elFinder/ 「$xoopsUser」替換成 「$_SESSION['isAdmin']」
  9. 將 /class/elFinder/  「$_SESSION['xoops_mod_name']」替換成 「$_SESSION['DirName']」
  10. 將 /class/elFinder/  「XOOPS_ROOT_PATH」替換成 「WEB_PATH」
  11. 將 /class/elFinder/  「XOOPS_URL」替換成 「WEB_URL」
  12. 將 /class/elFinder/  「/modules/tadtools」替換成 「/class」
  13. sqlConfig.php <?php #取得檔案所在目錄:dirname(__FILE__); #取得檔案上層目錄:dirname(dirname(__FILE__)); #取得檔案上二層目錄:dirname(dirname(dirname(__FILE__))); require_once dirname(dirname(dirname(__FILE__))).'/sqlConfig.php';

     

  14. 完成下載 :請下載至專案目錄並解壓縮覆蓋