Jump to content

Extension talk:TinyMCE MW

Add topic
From mediawiki.org
Latest comment: 12 years ago by Jwestyp in topic Comments

MW-Tables not correct

[edit]

moved from mainpage

Hi! Thanks for this extension! I installed in on my wiki but now all old tables in wiki syntax are shown in plaintext code. What do i have to change for enabling the standard mw parser as well? -- 195.127.44.186 15:12, 4 July 2007 (UTC)Reply

  • Hi, I don't recommend installing TinyMCE for already existing Mediawiki Installations. I have not had time to test Wikitext tables, in great detail, but I could see how it would not parse correctly. Have you tried using the Disable Advanced Editor link the saving the wikitext table? Some other ways could be implemented to handle this problem. 1) Detect the wikitext table tags and disable TinyMCE_MW (see function wfCheckBeforeEdit). 2)Add a wikitext handler in function wfTinymceParserPaste so it will get formatted properly. 3) Just reedit the tables using the advanced editor. --JoeSox 15:56, 4 July 2007 (UTC)Reply

Hi! I've a related Problem with this extension. It seems to be impossible to include specialpages, when $wgUseTinyMCE is on. But I've no opinion what the reason is. If I include a special page e.g. {{special:recentchanges}} , then I get some suspecious text-dump like this:

 �UNIQ5a6b14b632c8782d-item49d3e5cb5347be63

Other Pages can be included without Problems. I've taken a look on TinyMCE_MW.php and found out, that there are some tags replaced with md5(tagopen)_number which looks similar. But I can't solve this Problem alone. Have you perhaps an idea what is causing this bug?

Sorry, my english may be bad.

regards

-Stefan- 79.211.199.52 15:19, 19 September 2007 (UTC)Reply


Its me again! Line breaks do not work as well. In a standard mw installation, a blank line is interpreted as a line break. If it is possible i would like to use tinymce only for creating and editing tables. Is there a possibility? -- 195.127.44.186 15:17, 4 July 2007 (UTC)Reply

  • I have had challenges with line breaks, which you may see in the extension code. Most of this is caused by TinyMCE's built-in reformating. Some of it is customizable. Just dig into the TinyMCE documentation and things may become clearer to you on how to customize TinyMCE_MW. Let me know if you have more questions or have some useful additions for the extension. --JoeSox 15:56, 4 July 2007 (UTC)Reply


Code TinyMCE_MW.php

[edit]

Click edit THEN copy and paste. If you don't, special characters will convert and the extension will not work.

<pre>
<?php
/*
TinyMCE_MW.php - MediaWiki extension - version 0.5.4
        by Joseph P. Socoloski III
        If you already have pages written in Mediawiki wikitext, this extension enables
        Moxiecode's TinyMCE and does not break Mediawiki wikitext. Also, TinyMCE_MW 
        has a new 'msword' configuration theme.  msword follows the MS Office 2003
        toolbar layout. Call TinyMCE's simple, advanced and a built-in msword theme from 
        LocalSettings.php.  TinyMCE_MW was built and tested on Mediawiki-1.10.0.  
        Successfully tested CategoryTree extension for compatibility with new tags.
		-Improved custom tag parsing for repeat and categorytree; added sql2wiki

        References:     http://meta.wikimedia.org/wiki/Image:Wiki-refcard.png
                                http://meta.wikimedia.org/wiki/Cheatsheet
                                http://meta.wikimedia.org/wiki/Help:HTML_in_wikitext
                                http://wiki.moxiecode.com/index.php/TinyMCE:Index
                                http://www.mediawiki.org/wiki/Extension:CategoryTree
                                http://www.mediawiki.org/wiki/Manual:Parameters_to_index.php
                                
        NOTE:To change the default font and size for TinyMCE, add these two lines to your
        theme's editor_content.css body{} section:
        font-family: Arial;
        font-size: 14px;
        NOTE:To decrease the space between lines after a carriage return place this line 
        to your theme's editor_content.css:
        p {margin: 0; padding: 0;}           
BUGS:   - Does not support Wikitext Bullet list
                - Does not support Wikitext Numbered list
                - Does not support Wikitext Redirect to another article
                - Does not support Wikitext Tables
TODO:   - Enable Ajax usage
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
*/


if( !defined( 'MEDIAWIKI' ) ) {
  die();
}

$wgExtensionCredits['other'][] = array(

        "name" => "TinyMCE MW extension",
        "author" => "Joseph P. Socoloski III",
        "version" => "0.5.4",
        "url" => "http://www.mediawiki.org/wiki/Extension:TinyMCE_MW",
        "description" => "Easily implement Moxiecode's TinyMCE into MediaWiki"
 );

# REGISTER HOOKS
$wgHooks['ParserBeforeStrip'][]                 = 'wfTinymceParserCut';
$wgHooks['ParserAfterTidy'][]                   = 'wfTinymceParserPaste';
$wgHooks['ArticleAfterFetchContent'][] 			= 'wfCheckBeforeEdit';
$wgHooks['EditPage::showEditForm:initial'][]    = 'wfTinymceAddScript';

##Process the raw wikidb code before any internal processing is applied
function wfTinymceParserCut ($q, $text) {

        global $wgTitle;
        global $wgTempText, $wgUseTinymce;
        
        $ns_allowed = true;
        $ns = $wgTitle->getNamespace();
        
        #if (in_array($ns, $wgexcludedNamespaces)) $ns_allowed = false;
        $wgTempText = $text;#get text
        #$text = "";
        
        return true;
}

##Process the wgTempText code (wikitext and html) and reformat it into html friendly $text
function wfTinymceParserPaste ($q, $text) {

        global $wgOut, $wgTitle, $wgParser;
        global $wgTempText, $wgTinymceToken, $wgUseTinymce;
        
        $List = array();
        
        $ns_allowed = true;
        $ns = $wgTitle->getNamespace();

        // @HACK this enables the upload script and other special pages
	if ($ns == -1) {
		return true;
	}
        
        # TinyMCE can NOT be enabled for any pages that have data tags
        if ($ns_allowed and $wgUseTinymce) {
        
                $tinymcetext = $wgTempText; 
                
                ## EXTENSION TAGS | ADD HERE ##
				#Custom tags may ONLY be entered in the regular editor NOT the HTML Source editor
				#Allow_inputbox_tags
				while (preg_match("|&lt;inputbox&gt;(.*?)&lt;/inputbox&gt;|is", $tinymcetext, $a)) {
				 	$r = preg_replace("| |i", "", $a[0]);#erase all the whitespace
				 	$r = preg_replace("|</p><p>|i", "<br/>", $a[0]);#sometimes </p><p> instead of br
					$r = preg_replace("|<br.*?\>|i", "\n", $r);
					$tinymcetext = str_replace($a[0], html_entity_decode($r), $tinymcetext);#htmlentities()
				}
				#Allow_repeat_tags
				while (preg_match("|&lt;repeat.*?&gt;(.*?)&lt;/repeat&gt;|is", $tinymcetext, $a)) {
				 	$r = preg_replace("| |i", "", $a[0]);#erase all the whitespace
				 	$r = preg_replace("|</p><p>|i", "<br/>", $a[0]);#sometimes </p><p> instead of br
					 #<repeat table="Service_Center_Table" sort="sc_num"></repeat>
					$r = preg_replace("|<br.*?\>|i", "\n", $r);
					$tinymcetext = str_replace($a[0], html_entity_decode($r), $tinymcetext);#htmlentities()
				}
				#Allow_categorytree_tags
				while (preg_match("|&lt;categorytree.*?&gt;(.*?)&lt;/categorytree&gt;|is", $tinymcetext, $a)) {
				 	$r = preg_replace("| |i", "", $a[0]);#erase all the whitespace
				 	$r = preg_replace("|</p><p>|i", "<br/>", $a[0]);#sometimes </p><p> instead of br
					$r = preg_replace("|<br.*?\>|i", "\n", $r);
					$tinymcetext = str_replace($a[0], html_entity_decode($r), $tinymcetext);#htmlentities()
				}
				#Allow_includeonlyx_tags
				while (preg_match("|&lt;includeonly&gt;(.*?)&lt;/includeonly&gt;|is", $tinymcetext, $a)) {
				 	$r = preg_replace("| |i", "", $a[0]);#erase all the whitespace
				 	$r = preg_replace("|</p><p>|i", "<br/>", $a[0]);#sometimes </p><p> instead of br
					$r = preg_replace("|<br.*?\>|i", "\n", $r);
					$tinymcetext = str_replace($a[0], html_entity_decode($r), $tinymcetext);#htmlentities()
				}
				#Allow_repeat_tags
				while (preg_match("|&lt;sql2wiki.*?&gt;(.*?)&lt;/sql2wiki&gt;|is", $tinymcetext, $a)) {
				 	$r = preg_replace("| |i", "", $a[0]);#erase all the whitespace
				 	$r = preg_replace("|</p><p>|i", "<br/>", $a[0]);#sometimes </p><p> instead of br
					 #<repeat table="Service_Center_Table" sort="sc_num"></repeat>
					$r = preg_replace("|<br.*?\>|i", "\n", $r);
					$tinymcetext = str_replace($a[0], html_entity_decode($r), $tinymcetext);#htmlentities()
				}
                ## EXTENSION TAGS END ##
                
                #Allow_a_tags
                        $i = 0;
                        $ta = md5("aopen");
                        while (preg_match("|(<a.*?\>)|i", $tinymcetext, $a)) {
                                $j = $ta."_".md5($i);
                                $List[$j]["content"] = $a[0];
                                $List[$j]["index"] = $j;
                                $tinymcetext = str_replace($a[0], $j, $tinymcetext);
                                $i++;
                        }
                        $i = 0;
                        $ta = md5("aclose");
                        while (preg_match("|(</a>)|i", $tinymcetext, $a)) {
                                $j = $ta."_".md5($i);
                                $List[$j]["content"] = $a[0];
                                $List[$j]["index"] = $j;
                                $tinymcetext = str_replace($a[0], $j, $tinymcetext);
                                $i++;
                        }
        
                #Allow_img_tags
                        $i = 0;
                        $timg = md5("img");
                        while (preg_match("|(<img[^>]*?/>)|i", $tinymcetext, $a)) {
                                $j = $timg."_".md5($i);
                                $List[$j]["content"] = $a[0];
                                $List[$j]["index"] = $j;
                                $tinymcetext = str_replace($a[0], $j, $tinymcetext);
                                $i++;
                        }

                ## MEDIAWIKI WIKITEXT HANDLING ##
                #'''''bold and italic'''''
                        while (preg_match("|'''''.*?'''''|is", $tinymcetext, $a)) {
                                $value = implode(",", $a);
                                $value = str_replace("'''''", "", $value);
                                $r = preg_replace("|'''''.*?'''''|is", "<i><strong>".$value."</strong></i>", $a[0]);
                                $tinymcetext = str_replace($a[0], html_entity_decode($r), $tinymcetext);
                        }
                #'''bold'''
                        while (preg_match("|'''.*?'''|is", $tinymcetext, $a)) {
                                $value = implode(",", $a);
                                $value = str_replace("'''", "", $value);
                                $r = preg_replace("|'''.*?'''|is", "<strong>".$value."</strong>", $a[0]);
                                $tinymcetext = str_replace($a[0], html_entity_decode($r), $tinymcetext);
                        }
                #''italic''
                        while (preg_match("|''.*?''|is", $tinymcetext, $a)) {
                                $value = implode(",", $a);
                                $value = str_replace("''", "", $value);
                                $r = preg_replace("|''.*?''|is", "<i>".$value."</i>", $a[0]);
                                $tinymcetext = str_replace($a[0], html_entity_decode($r), $tinymcetext);
                        }
                        
                #=====level 4=====
                        while (preg_match("|=====.*?=====|is", $tinymcetext, $a)) {
                                $value = implode(",", $a);
                                $value = str_replace("=====", "", $value);
                                $r = preg_replace("|=====.*?=====|is", "<h5>".$value."</h5>", $a[0]);
                                $tinymcetext = str_replace($a[0], html_entity_decode($r), $tinymcetext);
                        }
                #====level 3====
                        while (preg_match("|====.*?====|is", $tinymcetext, $a)) {
                                $value = implode(",", $a);
                                $value = str_replace("====", "", $value);
                                $r = preg_replace("|====.*?====|is", "<h4>".$value."</h4>", $a[0]);
                                $tinymcetext = str_replace($a[0], html_entity_decode($r), $tinymcetext);
                        }
                #===level 2===
                        while (preg_match("|===.*?===|is", $tinymcetext, $a)) {
                                $value = implode(",", $a);
                                $value = str_replace("===", "", $value);
                                $r = preg_replace("|===.*?===|is", "<h3>".$value."</h3>", $a[0]);
                                $tinymcetext = str_replace($a[0], html_entity_decode($r), $tinymcetext);
                        }
                #==heading==
                        while (preg_match("|==.*?==|is", $tinymcetext, $a)) {
                                $value = implode(",", $a);
                                $value = str_replace("==", "", $value);
                                $r = preg_replace("|==.*?==|is", "<h2>".$value."</h2>", $a[0]);
                                $tinymcetext = str_replace($a[0], html_entity_decode($r), $tinymcetext);
                        }
                #==heading 1==
                ## Does not support <h1> tags because "|=.*?=|is" grabs too much
                #---- horizontal line
                        while (preg_match("|----|is", $tinymcetext, $a)) {
                                $r = preg_replace("|----|is", "<hr>", $a[0]);
                                $tinymcetext = str_replace($a[0], html_entity_decode($r), $tinymcetext);
                        }
                ## MEDIAWIKI WIKITEXT HANDLING END ##
                
		$tagList = array("pre", "math", "gallery", "nowiki", "html");
		foreach($tagList as $tag) {
			while (preg_match("|&lt;($tag.*?)&gt;(.*?)&lt;/$tag&gt;|is", $tinymcetext, $a)) {	
				$r = preg_replace("|<br.*?\>|i", "", $a[0]);
				$r = preg_replace("|&nbsp;|i", " ", $r);
				$tinymcetext = str_replace($a[0], html_entity_decode($r), $tinymcetext);
			}
		}

		foreach($q->mTagHooks as $tag => $func) {
			while (preg_match("|&lt;($tag.*?)&gt;(.*?)&lt;/$tag&gt;|is", $tinymcetext, $a)) {	
				$r = preg_replace("|<br.*?\>|i", "", $a[0]);
				$r = preg_replace("|&nbsp;|i", " ", $r);
				$tinymcetext = str_replace($a[0], html_entity_decode($r), $tinymcetext);
			}
		}
                $state = new StripState;
                $x =& $state;
                $tinymcetext = $q->strip($tinymcetext, $x);
                # optional remove <p></p> 
                #$tinymcetext = preg_replace('/<p[^>]*>/','',$tinymcetext);//Remove the start <p> or <p attr="">
#                $tinymcetext = preg_replace('/<\/p>/', '<br />', $tinymcetext); // Replace the end
				#$tinymcetext = preg_replace('/<\/p>/', '\n', $tinymcetext); // Replace the end
				#$tinymcetext = preg_replace("|<br/>|i", "\n", $tinymcetext);
                $tinymcetext = preg_replace("/<\/?tbody>/i","", $tinymcetext);
                $tinymcetext = preg_replace("/$wgTinymceToken/i","", $tinymcetext); 
                $tinymcetext = Sanitizer::removeHTMLtags( $tinymcetext, array( &$q, 'attributeStripCallback' ) );
                $tinymcetext = $q->replaceVariables($tinymcetext);
         //$fcktext = $q->doDoubleUnderscore( $fcktext ); //var $fcktext is not set
           $tinymcetext = $q->doDoubleUnderscore( $tinymcetext ); // should be this
                $tinymcetext = $q->replaceInternalLinks( $tinymcetext );
                $tinymcetext = $q->replaceExternalLinks( $tinymcetext );
                $tinymcetext = str_replace($q->mUniqPrefix."NOPARSE", "", $tinymcetext);
                $tinymcetext = $q->doMagicLinks( $tinymcetext );
                $tinymcetext = $q->formatHeadings( $tinymcetext, true );
                $q->replaceLinkHolders( $tinymcetext );
                $tinymcetext = $q->unstripNoWiki( $tinymcetext, $state );
                $tinymcetext = $q->unstrip($tinymcetext, $state);
        
                foreach($List as $item) {
                        $tinymcetext = str_replace($item["index"], $item["content"], $tinymcetext);
                        $i++;
                }
                
                $text = $tinymcetext;
        }
        return true;
}


function wfTinymceAddScript ($q) { 

        global $wgOut, $wgTitle, $wgScriptPath, $wgMyWikiURL; 
        global $wgTempText, $wgTinymceDir, $wgTinymceTheme, $wgExt_valid_elements, $wgUseTinymce;

        $wgTinymceDir = "tinymce";
        $ns_allowed = true;
        $ns = $wgTitle->getNamespace();

        if ($ns_allowed && $wgUseTinymce)
        {
         	# following from http://rorlach.de/mediawiki/index.php/Toggle_TinyMCE
			$wgOut->addScript("<script language=\"javascript\" type=\"text/javascript\">
var tinyMCEmode = true;
function toggleEditorMode(wpTextbox1,eleToggleLink) {
    try {
        if(tinyMCEmode) {
            tinyMCE.execCommand(\"mceRemoveControl\", false, wpTextbox1);
            tinyMCEmode = false;
            if(eleToggleLink)
                eleToggleLink.innerHTML    =    \"Enable Advanced Editor\";
        } else {
            tinyMCE.execCommand(\"mceAddControl\", false, wpTextbox1);
            tinyMCEmode = true;
            if(eleToggleLink)
                eleToggleLink.innerHTML    =    \"Disable Advanced Editor\";
        }
    } catch(e) {
        //error handling
    }
}
</script>");

        if (($wgTinymceTheme == "simple")){
                $wgOut->addScript( "<script language=\"javascript\" type=\"text/javascript\" src=\"$wgScriptPath/extensions/$wgTinymceDir/jscripts/tiny_mce/tiny_mce.js\"></script><script language=\"javascript\" type=\"text/javascript\">tinyMCE.init({
        mode : \"textareas\",
        theme : \"simple\",
        convert_newlines_to_brs : false,
        apply_source_formatting : true,
        relative_urls : false,
        remove_script_host : true,
		document_base_url : \"$wgMyWikiURL\",
        extended_valid_elements : \"$wgExt_valid_elements\"
});</script>" );
} elseif(($wgTinymceTheme == "advanced")) {
        $wgOut->addScript( "<script language=\"javascript\" type=\"text/javascript\" src=\"$wgScriptPath/extensions/$wgTinymceDir/jscripts/tiny_mce/tiny_mce.js\"></script><script language=\"javascript\" type=\"text/javascript\">tinyMCE.init({
        mode : \"textareas\",
        theme : \"advanced\",
        convert_newlines_to_brs : false,
        apply_source_formatting : true,
        relative_urls : false,
        remove_script_host : true,
		document_base_url : \"$wgMyWikiURL\",
        extended_valid_elements : \"$wgExt_valid_elements\"
});</script>" );
}elseif(($wgTinymceTheme == "msword")) {
        $wgOut->addScript("<script language=\"javascript\" type=\"text/javascript\" src=\"$wgScriptPath/extensions/$wgTinymceDir/jscripts/tiny_mce/tiny_mce.js\"></script><script language=\"javascript\" type=\"text/javascript\">tinyMCE.init({
        mode : \"textareas\",
        theme : \"advanced\",
        extended_valid_elements : \"$wgExt_valid_elements\",
        convert_newlines_to_brs : false,
        apply_source_formatting : true,
        relative_urls : false,
        remove_script_host : true,
		document_base_url : \"$wgMyWikiURL\",
        plugins : \"style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,zoom,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras\",
        theme_advanced_buttons1 : \"newdocument,save,|,print,|,iespell,|cut,copy,paste,pastetext,pasteword,|,undo,redo,|,link,unlink,image,hr,anchor,code,|,search,replace,|,tablecontrols,|,help\",
        theme_advanced_buttons2 : \"styleselect,formatselect,fontselect,fontsizeselect,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,|,outdent,indent,cleanup,backcolor,forecolor,removeformat\",
        theme_advanced_buttons3 : \"insertdate,inserttime,|,sub,sup,|,charmap,emotions,media,|,ltr,rtl,|,fullscreen\",
        theme_advanced_toolbar_location : \"top\",
        theme_advanced_toolbar_align : \"left\"
});</script>");
}else{$wgOut->addScript("**TINYMCE NOT ENABLED: FIX wgTinymceTheme**<script language=\"javascript\" type=\"text/javascript\"></script>" );}
		#Since editing add the button
		$wgOut->addHTML("<p style=\"text-align:right\"><a id=\"toggleLink\" href=\"#\" title=\"toggle TinyMCE\" onclick=\"toggleEditorMode('wpTextbox1',this);\">Hide Editor</a></p>");
}
else{$wgOut->addScript("<script language=\"javascript\" type=\"text/javascript\"></script>" ); $wgUseTinymce = true; }
        return true;
}

# Check existing article for any tags we don't want TinyMCE parsing...
function wfCheckBeforeEdit ($q, $text) { 
	global $wgUseTinymce;
	
	if (preg_match("|&lt;(data.*?)&gt;(.*?)&lt;/data&gt;|is", $text, $a)) {
		$wgUseTinymce = false;
	}
	elseif(preg_match("|<(data.*?)>(.*?)</data>|is", $text, $a)) {
		$wgUseTinymce = false;}
	else{$wgUseTinymce = true;}
	return true;
}

?>

</pre>

Upgrade Log

[edit]

6/24/07 v0.2.1

[edit]
  • Misc. fixes

6/25/07 v0.3.0

[edit]
  • Fixed TinyMCE_MW to work with inputbox extension.
  • Section now for custom extension tags.

6/26/07 v0.4.0

[edit]
  • Updated inputbox handler to fix 'p /p' tags
  • Does not support wikitext h1 tags because "|=.*?=|is" grabs too much.
  • Support toggling. Enable and Disable TinyMCE toolbar by a link in upper right corner of editpage.

6/27/07 v0.4.1

[edit]
  • Set 'convert_newlines_to_brs : false' ; it was inserting new br tags on each re-edit

6/28/07 v0.4.3

[edit]
  • WikiDB tag support. Disables TinyMCE before editing any articles with WikiDB tags.

7/1/07 v0.5.3

[edit]
  • Added better link support. Added relative_url, remove_script_host, document_base_url

9/20/07 v0.5.4

[edit]
  • Modified #Allow_repeat_tagsm and #Allow_categorytree_tags replacements

Conclusion

[edit]

moved from main page Igottheconch (talk) 17:35, 21 February 2012 (UTC)Reply

Moxiecode's TinyMCE is a very impressive WYSIWYG editor.
I looked all over for a MediaWiki extention or any information.
Hopefully, this works for you and is helpfull.
--JoeSox 03:41, 24 June 2007 (UTC)Reply

Error: Failed to derive URL prefix for Timeline

[edit]

moved from main page Igottheconch (talk) 17:35, 21 February 2012 (UTC)Reply

Error: MediaWiki 1.10.1 + TinyMCE 2_1_1_1 + MSServer 200

[edit]

moved from main page Igottheconch (talk) 17:35, 21 February 2012 (UTC)Reply

Aftre integrating TinyMCE 2_1_1_1 in my project (MediaWiki 1.10.1 + WAMP + MSServer 2003), MediaWik correctly work with easy, small article only. And TinyMCE don't work.

"Hide Editor" is represented in an edit window. After click on this, it changes on "Enable Advanced Editor"

If article no easy then I take Errors
Fatal error: Maximum execution time of 30 seconds exceeded in C:\wamp\www\mediawiki\extensions\TinyMCE_MW.php on line 223
or
Fatal error: Maximum execution time of 30 seconds exceeded in C:\wamp\www\mediawiki\extensions\TinyMCE_MW.php on line 226 BunakovM 13:38, 9 August 2007 (UTC)Reply

Another Error!

[edit]

moved from main page Igottheconch (talk) 17:35, 21 February 2012 (UTC)Reply

Fatal error: Cannot instantiate non-existent class: stripstate in /home/atuaesco/public_html/extensions/TinyMCE_MW.php on line 237 What can I do?


Error: MediaWiki 1.12 + TinyMCE

[edit]

moved from main page Igottheconch (talk) 17:35, 21 February 2012 (UTC)Reply


How can I fix it? Whats the new format?

Interner Fehler

Parser::replaceVariables called using the old argument format

Backtrace:

#0 /data/apache/users/.../.../www/Wiki/includes/Parser.php(4526): Parser->replaceVariables('', Array)
#1 [internal function]: Parser->attributeStripCallback('', Array)
#2 /data/apache/users/.../.../www/Wiki/includes/Sanitizer.php(479): call_user_func_array(Array, Array)
#3 /data/apache/users/.../.../www/Wiki/extensions/TinyMCE_MW.php(253): Sanitizer::removeHTMLtags('MediaWiki wurde...', Array)
#4 [internal function]: wfTinymceParserPaste(Object(Parser), '<p>MediaWiki wu...')
#5 /data/apache/users/.../.../www/Wiki/includes/Hooks.php(113): call_user_func_array('wfTinymceParser...', Array)
#6 /data/apache/users/.../.../www/Wiki/includes/Parser.php(432): wfRunHooks('ParserAfterTidy', Array)
#7 /data/apache/users/.../.../www/Wiki/includes/Article.php(3174): Parser->parse('MediaWiki wurde...', Object(Title), Object(ParserOptions), true, true, 21)
#8 /data/apache/users/.../.../www/Wiki/includes/Article.php(821): Article->outputWikiText('MediaWiki wurde...')
#9 /data/apache/users/.../.../www/Wiki/includes/Wiki.php(390): Article->view()
#10 /data/apache/users/.../.../www/Wiki/includes/Wiki.php(48): MediaWiki->performAction(Object(OutputPage), Object(Article), Object(Title), Object(User), Object(WebRequest))
#11 /data/apache/users/.../.../www/Wiki/index.php(90): MediaWiki->initialize(Object(Title), Object(OutputPage), Object(User), Object(WebRequest))
#12 {main}

With TinyMCE version 3.1.1, I have the same problem.
To solve this problem, I have only replaced the line 4526 (is the same line number)

$text = $this->replaceVariables( $text, $frame );

with

$text = $this->replaceVariables( $text, false);

But, I have another problem.
The old articles are displayed without carriage return !
So an old document with 3 lines is now displayed on one single line !
Have somebody a solution to this new problem ?

Error.

[edit]

Fatal error: Cannot instantiate non-existent class: stripstate in /home/atuaesco/public_html/extensions/TinyMCE_MW.php on line 237 I have this error when i try to edit a page

Try version 0.5.4 --JoeSox 18:33, 20 September 2007 (UTC)Reply

Stilling having this problem. Fatal error: Cannot instantiate non-existent class: stripstate in mysite\extensions\TinyMCE_MW.php on line 245 -2009.6.21

ERROR : on file upload

[edit]

Php fatal error: maximum execution time of 30 seconds exceeded in TinyMCE_MW.php on line 231 and line 234 when file upload is selected. Results in blank page and hence cannot upload files.


(Please keep in mind that TinyMCE does handle these features)

there is a bypass to the problem by adding another flag

In LocalSettings.php (root wiki dir) add the following line before require_once("$IP/extensions/TinyMCE_MW.php");

$wgRunTinyMce = true;

In SpecialUpload.php (include dir) change the function wfSpecialUpload to look like this

function wfSpecialUpload() 
{	
    global $wgRunTinyMce;
    global $wgRequest;
    $wgRunTinyMce = false;
    $form = new UploadForm( $wgRequest );
    $form->execute();
    $wgRunTinyMce = true;
}

and the last file you need to edit is TinyMCE_MW.php (extension dir) in function wfTinymceParserPaste

add global definition for wgRunTinyMce at the beginning of the function change the following line:

if ($ns_allowed and $wgUseTinymce ) {

to

if ($ns_allowed and $wgUseTinymce and $wgRunTinyMce) {

sorry for my bad English feel free to rewrite the instruction

Slight fix

[edit]

I use a wiki with quite a lot of rewriting happening. In my case I need to be able to set $wgTinymceDir from my LocalSettings.php. This small modification makes this possible. Line:283

        if(!isset($wgTinymceDir)) $wgTinymceDir = "tinymce";

--Rob 02:39, 4 October 2007 (UTC)Reply

The new bugfix 0.5.4 has trouble with Extension:CategoryTree

[edit]

If I turn TinyMCE_MW on, end save an article with the <categorytree>-tag into the Editorbox (makes no difference if "hide editor" is used), then I get this error:

Fatal error: Maximum execution time of 30 seconds exceeded in /srv/www/htdocs/wiki/extensions/TinyMCE_MW.php on line 119

This is on line 119 of TinyMCE_MW.php:

 $tinymcetext = str_replace($a[0], html_entity_decode($r), $tinymcetext);#htmlentities()

With your earlier version 0.5.3 this doesn't appear, so it seams to cause a bug and not fix. By comparation of these version there are big differences between the lines around 119, especialy this looks a little bit supecious: New in 0.5.4:

  #Allow_categorytree_tags
  while (preg_match("|<categorytree.*?>(.*?)</categorytree>|is", $tinymcetext, $a)) {
       ...  

Old code in 0.5.3:

  #Allow_categorytree_tags
  while (preg_match("|&lt;categorytree&gt;(.*?)&lt;/categorytree&gt;|is", $tinymcetext, $a)) { 
       ...

We now rollback to 0.5.3 but I'll be greatefull if this plugin will improved in future.

Regards -Stefan

79.211.199.93 12:02, 4 October 2007 (UTC)Reply

mediawiki 1.12.0

[edit]

Does anyone have this installed on mediawiki version 1.12.0? I tried following the directions over here: TinyMCE_MW.

Setup: MW 1.12 | Windows 2003 w/ IIS. | MYSQL 5.x | PHP 5.25

But i had no luck, i got the following error:

Internal error

Parser::replaceVariables called using the old argument format

Backtrace:

#0 W:\Wiki\mediawiki-1.12.0\includes\Parser.php(4526): Parser->replaceVariables('', Array)
#1 [internal function]: Parser->attributeStripCallback('', Array)
#2 W:\Wiki\mediawiki-1.12.0\includes\Sanitizer.php(479): call_user_func_array(Array, Array)
#3 W:\Wiki\mediawiki-1.12.0\extensions\TinyMCE_MW.php(255): Sanitizer::removeHTMLtags('<big><strong>Me...', Array)
#4 [internal function]: wfTinymceParserPaste(Object(Parser), '<p><big><b>Medi...')
#5 W:\Wiki\mediawiki-1.12.0\includes\Hooks.php(113): call_user_func_array('wfTinymceParser...', Array)
#6 W:\Wiki\mediawiki-1.12.0\includes\Parser.php(432): wfRunHooks('ParserAfterTidy', Array)
#7 W:\Wiki\mediawiki-1.12.0\includes\Article.php(3174): Parser->parse('<big>'''MediaWi...', Object(Title), Object(ParserOptions), true, true, 8)
#8 W:\Wiki\mediawiki-1.12.0\includes\Article.php(821): Article->outputWikiText('<big>'''MediaWi...')
#9 W:\Wiki\mediawiki-1.12.0\includes\Wiki.php(390): Article->view()
#10 W:\Wiki\mediawiki-1.12.0\includes\Wiki.php(48): MediaWiki->performAction(Object(OutputPage), Object(Article), Object(Title), Object(User), Object(WebRequest))
#11 W:\Wiki\mediawiki-1.12.0\index.php(90): MediaWiki->initialize(Object(Title), Object(OutputPage), Object(User), Object(WebRequest))
#12 {main}

Mlong212 05:29, 20 April 2008 (CEST)

You need to change the following line in TinyMCE_MW.php (~line 255)

$tinymcetext = Sanitizer::removeHTMLtags( $tinymcetext, array( &$q, 'attributeStripCallback' ) );

to the following

$tinymcetext = Sanitizer::removeHTMLtags( $tinymcetext, 'attributeStripCallback', array( &$q ) );

Very close to working! The above change allowed me in to the main page without halting on error, however:

  1. Additional html code is shown on everything & the page layout is not as it was (without even editing yet)
  2. When trying to edit a page it displays the error: PHP Fatal Error: Maximum execution time of 30 seconds exceeded in (filepath)\extensions\TinyMCE_MW.php on line XXX
    1. XXX because it is different each time though it does seem to hit on a line containing: $tinymcetext = str_replace($a[0], html_entity_decode($r), $tinymcetext);#htmlentities()

Cannot modify header information

[edit]

I got several warnings like
"Warning: Cannot modify header information - headers already sent by [...]"

my solution:
"eliminate additional whitespace before and after the <php> and </php> tags in the TinyMCE_MW.php file" (http://tinymce.moxiecode.com/punbb/viewtopic.php?id=8233) which was for me to delete the tags:

<code>  and
<pre>

by Magnus Rode


All's well in 1.12 except...

[edit]

Have TinyMCE_MW.php working in 1.12 but <pre> tags are displaying as:

UNIQ229ef7f677e8689b-pre-00000004-QINU?

If I remove the following line from TinyMCE_MW.php:

$tinymcetext = $q->replaceVariables($tinymcetext);

..the <pre> tags then work

...but {{templates}} are not parsed.

So there's something in 1.12 that doesn't appreciate replaceVariables when parsing <pre> tags.

In Eric Hartwell's Technotes he has a similar problem caused by recursively calling the parse function in parser.php.

It seems TinyMCE_MW.php may be flawed following changes to MediaWiki's parsing since 1.10.

Anyone have any suggestions as to how to fix the extension for 1.12?

--Nigelm 20:39, 26 May 2008 (UTC)Reply

Any news? ...

[edit]

Has anyone got any further on that issue and solved the parser incompatibility? Still using 1.11 and cannot upgrade to the newest version due to this extension!

--GeorgeHol 11:09, 13 August 2009 (UTC)Reply

Announcement: New TinyMCE Plugin

[edit]

I am currently working on a new TinyMCE plugin that takes a slightly different approach to WikiText.

Instead of trying to use the MediaWiki plugin to make MediaWiki understand HTML, the plugin that I have written (and will be posting in the next week or so) simply uses the MediaWiki plugin to embed TinyMCE into MediaWiki, and uses a separate TinyMCE plugin (also written by me and that will be included in the package) that handles Translation of WikiText into HTML so that TinyMCE can work with it, and HTML into WikiText so that what is saved into the Wiki is as compatible with the rest of the wiki as possible.

This approach ensures that only limited HTML markup is saved in the articles, and also has the advantage of being able to view the source of the page (in TinyMCE) as WikiText instead of HTML. Also, since we are not tampering with the Wiki's guts, the <PRE> tags work. I also have tested this with many of the advanced TinyMCE plugins such as "inlinepopups", and the add-on plugins such as "TinyMCE SpellChecker" and "TinyMCE Compressor". (As well as several other custom plugins I have written).

The new plugin works with version 3.2.2.3 of TinyMCE (the most recent version of TinyMCE as of this writing.)

I am currently testing with MediaWiki 1.12.0, but will be upgrading to 1.14.0 in the next week, and will release the code shortly afterwards.

This plugin is being used by a project that I am actively involved with, and will be actively developed for use in that project. Currently, the plugin supports only basic WikiText markup, but I have plans to try to add buttons for the <NOWIKI> tags, as well as advanced features such as templates, categories, and other features to the plugin.

One question I DO have is this: should I post the plugin here, or create a new project for this plugin?

--Draxxon 03:55, 17 April 2009 (UTC)Reply

Post here

[edit]

I'd post it here, as the current plugin isn't fully functional it is of little use to anyone. I'd rather see a working plugin available. Please let us know when you do release it.

--Craigbruce 11:33, 19 May 2009 (UTC)Reply

Still Debugging

[edit]

I'm still working on the new extension. It's working, and you can see it over on http://www.wikihorseworld.com/wiki/ but it still has several issues that I'm resolving. I have a prototype Template parser working (but not yet turned on), and several other thing in the works for it as well.

At the moment, only basic editing features are working, and I'm having some issues with images in wikitext. (I also am using a custom-written image FileStorage plugin there that won't be released with it.) I will be working more heavily with in the coming weeks though.

--Draxxon 15:58, 28 July 2009 (UTC)Reply

I'd love to assist you with this and get a good final product - how do I get in touch with you? - wysiwyg is a huge thing missing in mediawiki --Aaron Axelsen 18:35, 2 March 2010 (UTC)Reply


The plugin is working, and has been live on the WikiHorseWorld.com site for several months. No problems so far. As soon as I can work out under what license it will be released under, I will post the plugin. (Actually, it's 2 plugins, one for MediaWiki, and one for TinyMCE.) I am pleased to announce that the plugin is capable of editing/handling MediaWiki pages such as the ones at Wikipedia that make heavy use of templates and parser functions without disturbing the template, or showing the wikitext of the template. (I just need to write a small plugin that allows you to edit the templates visually.) --Draxxon 19:39, 13 May 2010 (UTC)Reply

Is there a link to this new plugin yet? -- 21 Feb 2011

TinyMCE_MW crashes Mediawiki 1.18

[edit]

Hi. I have followed the installation instructions for TinyMCE_MW 3.3.9.4 in Mediawiki 1.18 and it crashes down my wiki =(. Is there some incompatibilities with that Mediawiki version?

Thanks.

Comments

[edit]

moved from mainpage

  • Perhaps a mailinglist / forum would be helpfull? - I`ve run into a couple of problems, especially with special tags coming from other extensions.
  • I have a suggestion! How about responding the the above edits with errors. Your extension DOES NOT WORK with MW 1.12
  • It does work with MW 1.12! see discussion
  • I don't know what "discussion" you're referring to, but there's a big section above titled "Error: MediaWiki 1.12 + TinyMCE" listing a huge number of errors that I also experience when I try to install this. I don't see any responses to this section. Have you verified that this actually works with 1.12? You now have two users verifying that it does not work with 1.12. If you have some sort of fix or response please post it, otherwise this extension should be delisted as it's broken.
  • How could one integrate Semantic MediaWiki with TinyMCE? The factbox doesn't show. Is this a parser fault?
  • Getting an Error with MW 1.18: Fatal error: Call to undefined method Parser::strip() in /home/mediawiki/public_html/extensions/TinyMCE_MW.php on line 252

Moved from Extension:TinyMCE_MW Main Page Jwestyp (talk) 14:03, 22 June 2012 (UTC)Reply

I think this will work for the heading 1 stuff.  Anyone care to poke some holes it it for us all?
 #==heading 1==
			while (preg_match("|=[A-z0-9\s'.-]+=|is", $tinymcetext, $a)) {
                                $value = implode(",", $a);
                                $value = str_replace("=", "", $value);
                                $r = preg_replace("|=[A-z0-9\s'.-]+=|is", "<h1 class='firstHeading'>".$value."</h1>", $a[0]);
                                $tinymcetext = str_replace($a[0], html_entity_decode($r), $tinymcetext);
                        }

Thanks -Ryan rahst12 3:08am March 15, 2009

Editor fixed with MW1.18, download from this page : http://blog.turutosiya.com/en/2012/02/02/45.html

TinyMCE_MW has a new 'msword' configuration theme. msword follows the MS Office 2003 toolbar layout. Call TinyMCE's simple, advanced and a built-in msword theme from LocalSettings.php. TinyMCE_MW was built and tested on Mediawiki-1.10.0, IE 6. Successfully tested CategoryTree extension for compatibility with new tags.


Several users have reported errors installing this extension in MW 1.12 (see section below); at best it is unstable. Until patches or other fixes are posted, it is not recommended for use with MW 1.12 or later.

Requested Features

[edit]
  • Enable Ajax usage.
  • Enable Embedded of Youtube Vids like in FramedVideo (FramedVideo dosn´t work with the editor)

Changing TinyMCE Font and Font Size

[edit]

After hours of trial and error and googling, I am deciding to share some very helpful information. NOTE:To change the default font and size for TinyMCE, add these two lines to your theme's editor_content.css body{} section:

	font-family: Arial;
	font-size: 14px;

NOTE:To decrease the space between lines after a carriage return place this line to your theme's editor_content.css:

	p {margin: 0; padding: 0;}

NOTE: Delete all of your cache (temporary internet files), then close your browser. Then re-open your browser.

Mediawiki 1.18

[edit]

Unfortunately this plugin has a big problem with rendering templates. I've just started to testing it - and bam! after 15 second I found already a bug:( I will continue my testing but at least at this moment I'm rather dissapointed.

TinyMCE and php 5.5

[edit]

there is a problem with php 5.5 and the TinyMCE_MW Plugin. The "===" from the wikisyntax doesn't convert to a HTML - Tag. Can someone give me a Bugfix or can someone say, where the Wikisyntax is convert to the HTML-code?

  • Change in the includes/parser/parser.php the methode doHeadings (line ~1339) in:
function doHeadings( $text ) {
wfProfileIn( __METHOD__ );
# - Just go down to 2: h1 grabs a lot
for ( $i = 6; $i >= 2; --$i ) {
$h = str_repeat( '=', $i );
######################################################
# Workaround by Kitty 
# Zuvor:      Pattern can be found everywhere. Removed ^ and $, added non greedy  
# 22-04-2014: Originalversion wiederhergestellt.
# 29-04-2014: Änderung zurückgenommen.
$text = preg_replace( "/$h(.+?)$h/m", "<h$i>\\1</h$i>", $text);
}
#  Resolve text
$text = htmlspecialchars_decode($text);
wfProfileOut( __METHOD__ );
return $text;
}

and in extensions/TinyMCE_MW/TinyMCE_MW.php

 #=====level 4=====
                 #       while (preg_match("|=====.*?=====|is", $tinymcetext, $a)) {
                 #       
                 #       #        wfDebugLog( 'tinymc', $a[0]);
                 #               $value = implode(",", $a);
                 #               $value = str_replace("=====", "", $value);
                 #               $r = preg_replace("|=====.*?=====|is", "<h5>".$value."</h5>", $a[0]);
                 #               $tinymcetext = str_replace($a[0], html_entity_decode($r), $tinymcetext);
                 #       }
                #====level 3====
                 #       while (preg_match("|====.*?====|is", $tinymcetext, $a)) {
                 #       
                 #       #        wfDebugLog( 'tinymc', $a[0]);
                 #               $value = implode(",", $a);
                 #               $value = str_replace("====", "", $value);
                 #               $r = preg_replace("|====.*?====|is", "<h4>".$value."</h4>", $a[0]);
                 #               $tinymcetext = str_replace($a[0], html_entity_decode($r), $tinymcetext);
                 #       }
                #===level 2===
                 #       while (preg_match("|===.*?===|is", $tinymcetext, $a)) {
                 #       
                 #            #   wfDebugLog( 'tinymc', $a[0]);
                 #               $value = implode(",", $a);
                 #               $value = str_replace("===", "", $value);
                 #               $r = preg_replace("|===.*?===|is", "<h3>".$value."</h3>", $a[0]);
                 #               $tinymcetext = str_replace($a[0], html_entity_decode($r), $tinymcetext);
                 #       }
                        
                #==heading==
                 #       while (preg_match("|==.*?==|is", $tinymcetext, $a)) {
                 #      
                 #          #      wfDebugLog( 'tinymc', $a[0]);
                 #               $value = implode(",", $a);
                 #               $value = str_replace("==", "", $value);
                 #               $r = preg_replace("|==.*?==|is", "<h2>".$value."</h2>", $a[0]);
                 #               $tinymcetext = str_replace($a[0], html_entity_decode($r), $tinymcetext);
                 #        }