MediaWiki中添加CKEditor的過程


現在FCKEditor變成CKEditor了,不能用原來的Extension了。但是也有了個新的Extension,叫WYSIWYG(WhatYouSeeIsWhatYouGet,所見即所得)。鏈接是這里:Extension:WYSIWYG

大家根據自己的Wiki版本選擇對應的就好了。下面說下我安裝過程中遇到的一些問題。

根據說明文檔,我把所有的文件都復制到了extensions目錄下。並且根據README.md文件中說明的,在LocalSittings.php中插入了加載代碼

 #13.11.13->
    require_once( "$IP/extensions/WYSIWYG/WYSIWYG.php" );

    # Examples of setting permissions using $wgGroupPermissions, for more detailed explanation see:
    #   https://www.mediawiki.org/wiki/Manual:$wgGroupPermissions#Example
    # $wgGroupPermissions['user']['wysiwyg'] = true; //Only registered users are allowed to use wysiwyg
    # $wgGroupPermissions['*']['wysiwyg'] = true;    //Everyone is allowed to use wysiwyg
    $wgGroupPermissions['*']['wysiwyg'] = true;

    $wgDefaultUserOptions['cke_show'] = 'richeditor';    //Enable CKEditor
    $wgDefaultUserOptions['riched_use_toggle'] = false;  //Editor can toggle CKEditor/WikiText
    $wgDefaultUserOptions['riched_start_disabled'] = false; //Important!!! else bug...
    $wgDefaultUserOptions['riched_toggle_remember_state'] = true; //working/bug?
    $wgDefaultUserOptions['riched_use_popup'] = false;   //Deprecated

    ##These are not compatible with WYSIWYG
    $wgFCKEditorExcludedNamespaces[] = NS_MEDIAWIKI;
    $wgFCKEditorExcludedNamespaces[] = NS_TEMPLATE;
    #13.11.13<-

    #17.01.14->
    #WikiEditor may not be compatible with WYSIWYG editor, use it with caution.
    require_once( "$IP/extensions/WikiEditor/WikiEditor.php" );

    # Enables/disables use of WikiEditor by default but still allow users to disable it in preferences
    $wgDefaultUserOptions['usebetatoolbar'] = 1;
    $wgDefaultUserOptions['usebetatoolbar-cgd'] = 1;

    # Displays the Preview and Changes tabs
    $wgDefaultUserOptions['wikieditor-preview'] = 0;

    # Displays the Publish and Cancel buttons on the top right side
    $wgDefaultUserOptions['wikieditor-publish'] = 0;
    #17.01.14<-

    #27.03.14->
    #This was required by SemanticMediaWiki extension in MW 1.22.4 to prevent startup error:
    $wgLocalisationUpdateDirectory = "$IP/cache";

    #These are for SemanticForms:
    enableSemantics( );
    include_once( "$IP/extensions/SemanticForms/SemanticForms.php" );

    #Optional excludes of wysiwyg in case SemanticForms and SemanticMediawiki are installed:
    $wgFCKEditorExcludedNamespaces[] = SF_NS_FORM;
    $wgFCKEditorExcludedNamespaces[] = SMW_NS_PROPERTY;
    #27.03.14<-

    #06.02.15->
    #Setting value of following variables eq. to 1 will cause wikitext text blocks
    #within specified tags to be displayed as image- element in wysiwyg mode.
    #Value eq. to 0 makes texts inside these tags editable directly as text in wysiwyg mode
    #using pre- parent tag + child tag.
    $wgFCKEditorSpecialElementWithPreTag   = 0; // 1= <pre> tags with attributes only => img- element
    #06.02.15<-

    #26.02.15->
    $wgFCKEditorSpecialElementWithTextTags = 0; // 1= <nowiki>, <source> and <syntaxhighlight> tags => img- element
    #26.02.15<-

 

本以為萬事大吉,可以正常使用了,然並卵。

出現錯誤:Fatal error: Call to undefined function enableSemantics() in D:\xampp\htdocs\LocalSettings.php

查了不少資料,才知道因為CKEditor引用了SemanticForms,需要SemanticMediaWiki擴展支持才能正常使用。而這個是要獨立安裝的。

安裝SemanticMediaWiki的步驟:

Step1

下載SMW

Step2

在LocalSettings.php中加入代碼:

require_once "$IP/extensions/SemanticMediaWiki/SemanticMediaWiki.php";
enableSemantics( 'example.org' );

step3

在MediaWiki的頁面: "Special:SMWAdmin"進行如下操作

點擊: "Initialise or upgrade tables" 按鈕來安裝數據庫

點擊: "Start updating data"按鈕

ok,SemanticMediaWiki安裝成功了。

解決了undefined function的問題。

 

但是又遇到了一個提示信息:

Warning:call_user_func() expects parameter 1 to be a valid callback ,class 'WikiEditorHooks' does not have a method 'onRegistration' in ExtensionRegistry.php on line 269

 

又查了一下原因,是因為之前開通了MediaWiki自帶的WikiEditor而引起的沖突錯誤。

注釋掉了加載代碼 wfLoadExtension( 'WikiEditor' ); 后終於一切正常了。

可以在MediaWiki中使用CKEditor了。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM