suggestion:TinyMCE as new multibrowser HTML WYSIWYG editor

Use GitHub to post feature requests for phpwcms.
shiny
Posts: 56
Joined: Tue 27. Sep 2005, 20:10

A solution for you all

Post by shiny »

I've got it all working, so I thought I'd share. I'll make no claims that the following solution is tidy (it isn't) or elegant (it's not), but it does work.

I tried making a 5th $wysiwyg_editor case, but to no avail - for some reason the variable kept being reset to 0. Presumably there's some check elsewhere in the code that prevents it being larger than 2.

For this reason, my solution replaces FCKEditor (option 2) as an option completely. That means that if you're not sure that you want to swap over toTinyMCE, you should back up your wysiwyg.editor.inc first.

The solution and install instructions can be found here - I hope some of you find it helpful.

To zBurner : Your solution will probably be better than my 5-minute hack, so don't let me stop you from posting yours :)
zBurner
Posts: 5
Joined: Wed 13. Apr 2005, 22:36

Finally

Post by zBurner »

Hey everybody, once again sorry about all the delay. This time I'm actually posting how I got tinyMCE to work in phpwcms. Be warned I actually did all of this several months ago so if it doesn't work I probibly left something out, in that case let me know and I'll try and track down whatever I missed.

Now on to the good stuff:

Download the latest version of TinyMCE and unpack it to include/inc_ext/tinymce

Code additions/modifications:

config/phpwcms/conf.wysiwyg.inc.php

Code: Select all

$_wysiwyg_editor = array();

// no WYSIWYG - just text
$_wysiwyg_editor[0]['editor_name'] = $BL['be_cnt_no_wysiwyg_editor'];


// HTMLarea
$_wysiwyg_editor[1]['editor_name'] = 'HTMLarea';


// FCKeditor
$_wysiwyg_editor[2]['editor_name'] = 'FCKeditor';


// SPAW
$_wysiwyg_editor[4]['editor_name'] = 'SPAW';


/*************NEW CODE STARTS HERE********************/
// TinyMCE
$_wsiwyg_editior[5]['editor_name'] = "TinyMCE";


/*************NEW CODE ENDS HERE********************/

?>

config/phpwcms/conf.inc.php

Code: Select all

// other stuff
$phpwcms["compress_page"]     = 0; //0 = OFF, 1-9: page compression ON (1 = low level, 9 = highest level)
$phpwcms["imagick"]           = 0; //0 = GD,  1 = ImageMagick, 2 = ImageMagick 4.2.9
$phpwcms["imagick_path"]      = ""; //Path to ImageMagick (default="" - none)
$phpwcms["use_gd2"]           = 1; //0 = GD1, 1 = GD2
$phpwcms["rewrite_url"]       = 0;  //whether URL should be rewritable

/************Modify the line below this***************/
$phpwcms["wysiwyg_editor"]    = 5;  //0 = no wysiwyg editor, 1 = HTMLarea, 2 = FCKeditor, 3 = browser based


$phpwcms["phpmyadmin"]        = 0;  //enable/disable phpMyAdmin in Backend
$phpwcms["default_lang"]      = "en";  //default language
$phpwcms["charset"]           = "iso-8859-1";  //default charset 'iso-8859-1'
$phpwcms["allow_remote_URL"]  = 0;  //0 = no remote URL in {PHP:...} replacement tag allowed, 1 = allowed
$phpwcms["gt_mod"]            = 0;  //0 = Graphical Text MOD disabled, 1 = enabled
$phpwcms["jpg_quality"]       = 75; //JPG Quality Range 25-100
$phpwcms["sharpen_level"]     = 1;  //Sharpen Level - only ImageMagick: 0, 1, 2, 3, 4, 5 -- 0 = no, 5 = extra sharp
$phpwcms["allow_ext_init"]    = 1;  //allow including of custom external scripts at frontend initialization
$phpwcms["allow_ext_render"]  = 1;  //allow including of custom external scripts at frontend rendering
$phpwcms["cache_timeout"]     = 14400;  //default cache timeout setting in seconds - 0 = caching Off
$phpwcms["imgext_disabled"]   = '';  //comma seperated list of imagetypes which should not be handled "pdf,ps"
include/inc_lib/wysiwyg.editor.inc.php
This is where you put the TinyMCE options. Check out their documentation and their examples to see what to put here.

Code: Select all


/*********  Add this code after case 4  *********************/
case 5:	ob_start();
		?>
		<script language="javascript" type="text/javascript" src="include/inc_ext/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
		<script language="javascript" type="text/javascript">
		
		tinyMCE.init({


		//Put all of your TinyMCE options here
 

                });
		</script>
		<textarea name="<?=$wysiwyg_editor['field']?>" rows="<?=$wysiwyg_editor['rows']?>" class="f11" id="<?=$wysiwyg_editor['field']?>" style="width: 100%; background-color: #ffffff; display: none;">
			<?=$wysiwyg_editor['value']?>
		</textarea>
		
		
		<?php
		ob_end_flush();
	break;
login.php

Code: Select all

//WYSIWYG EDITOR:
//0 = no wysiwyg editor (default)
//1 = HTMLAREA (compatible with IE5.5+ and Mozilla 1.3+ based webbrowsers)
$_SESSION["WYSIWYG_EDITOR"] = 0;
$_SESSION["dhtml_hiding"]	= 1;
$phpwcms["wysiwyg_editor"] = intval($phpwcms["wysiwyg_editor"]);
if($phpwcms["wysiwyg_editor"]) {
	//include_once ("include/inc_ext/phpsniff/phpSniff.core.php");
	include_once ("include/inc_ext/phpsniff/phpSniff.class.php");
	$c =& new phpSniff();
	
	if($c->browser_is("mz1.3+") || $c->browser_is("ns7+") || $c->browser_is("fx")) {
		$_SESSION["dhtml_hiding"] = 0;
	}
	
	switch($phpwcms["wysiwyg_editor"]) {
		case 1:	// HTMLarea
				if(	$c->browser_is("ie5.5+")	|| 
					$c->browser_is("mz1.3+")	|| 
					$c->browser_is("ns7+")		|| 
					$c->browser_is("fx")
					) $_SESSION["WYSIWYG_EDITOR"] = 1;
				break;
		case 2:	// FCKeditor 2
				if(	$c->browser_is("ie5.5+")	|| 
					$c->browser_is("mz1.3+")	|| 
					$c->browser_is("ns7+")		|| 
					$c->browser_is("fx")
					) $_SESSION["WYSIWYG_EDITOR"] = 2;
				break;
		case 3: // Spaw
				if( $c->browser_is("ie5.5+")) {
					$_SESSION["WYSIWYG_EDITOR"] = 4;
				} elseif (
					$c->browser_is("mz1.3+")	|| 
					$c->browser_is("ns7+")		|| 
					$c->browser_is("fx") ) {
					
					$_SESSION["WYSIWYG_EDITOR"] = 1;
				}
				break;
		
		case 4:	if(	$c->browser_is("ie5.5+")) $_SESSION["WYSIWYG_EDITOR"] = 4;
				break;

/*************NEW CODE STARTS HERE********************/

		case 5: //TinyMCE
				if( $c->browser_is("ie5.5+")	|| 
					$c->browser_is("mz1.3+")	|| 
					$c->browser_is("ns7+")		|| 
					$c->browser_is("fx")
					) $_SESSION["WYSIWYG_EDITOR"] = 5;
				break;

/************NEW CODE ENDS HERE**********************/
	}
}
That should be it. Good luck and feel free to ask questions!
Buletti
Posts: 43
Joined: Tue 27. Sep 2005, 10:51
Location: Hamburg / Berlin / Germany

Post by Buletti »

I have some aditional changes to include/inc_lib/wysiwyg.editor.inc.php if you like.

Mainly i wasn't able to make it work in the way it was told before.
Anyway, maybe this is one more way to get to the solution.

First you have to make everything zBurner told before, than
you can modify:

Code: Select all

// load TinyMCE, 
	case 5:
      ?>
          <textarea style='width:<?php echo $wysiwyg_editor['width'] ?>; height: <?php echo $wysiwyg_editor['height']?> '
          name='<?php echo $wysiwyg_editor['field']?>' >
          <?php echo $wysiwyg_editor['value']; ?>
          </textarea>

          <script language="javascript" type="text/javascript" src='include/inc_ext/tinymce/jscripts/tiny_mce/tiny_mce.js'></script>
          <script language="javascript" type="text/javascript">
          tinyMCE.init
          ({

// ** Now TinyMCE options start, change if you want **

             mode : "textareas",
             theme: "advanced",
             plugins: "inlinepopups, fullscreen, zoom, table, advhr, preview, advimage, advlink, emotions, contextmenu, autosave, iespell, insertdatetime, paste, print, save, noneditable, searchreplace",
             theme_advanced_toolbar_location: "top",
             theme_advanced_buttons1: "fullscreen, bold, italic, underline, separator justifyleft, justifycenter, justifyright, justifyfull, separator, bullist, numlist, separator, outdent, indent, separator, undo, redo, print, save, search, replace, pastetext,pasteword",
             theme_advanced_buttons2: "emotions, advhr, preview, advimage, link, unlink, anchor,  context, image, separator, link, unlink, sub, sup, forecolor, backcolor, separator,hr, separator, removeformat, selectall,insertdate,inserttime, iespell, zoom, separator, cleanup, help, code hr, visualaid, charmap, separator",
             theme_advanced_buttons3: "styleselect, fontselect, fontsizeselect,tablecontrols",
			 auto_reset_designmode: "true",
             extended_valid_elements : "font[face|size|color] , hr[class|width|size|noshade], a[name|href|target|title|onclick], ",
             document_base_url: "/",
             content_css: "phpwcms_template/inc_css/tiny.css",
			 
             plugin_insertdate_dateFormat : "%d-%m-%Y",
             plugin_insertdate_timeFormat : "%H:%M:%S",
			 plugin_preview_width : "500",
	         plugin_preview_height : "600",
			 
			 table_styles : "Header 1=header1;Header 2=header2;Header 3=header3",
	         table_cell_styles : "Header 1=header1;Header 2=header2;Header 3=header3;Table Cell=tableCel1",
	         table_row_styles : "Header 1=header1;Header 2=header2;Header 3=header3;Table Row=tableRow1",
			 
			 fullscreen_settings : {
		     theme_advanced_path_location : "top"
	}

// ** Now TinyMCE options end **

          });
          </script>
      <?php
			$wysiwyg_loaded_tinyMCE = 1;
			break;
I added the plugins and buttons to make it work well, so you can copy and paste it, to make it run in a few seconds. But there are still some features i don't know exactly.


There are still two bugs left.
First Tiny starts in the Keywords (Schlüsselwörter) and Picture Subtitle Area (Bildunterzeile) as well and
Second it only works with Firefox, Internet Explorer shows some errors.
Monz@
Posts: 34
Joined: Fri 18. Feb 2005, 17:10
Location: Balzers / Liechtenstein
Contact:

Post by Monz@ »

hi @ all

Please look @ this... who can help me???

=> http://www.phpwcms.de/forum/viewtopic.php?p=53135#53135

cheers

====> SOLVED <=====

Failure in 'wysiwyg.editor.inc.php' - mea culpa - mea maxima culpa :oops:

Anyway thanx for answers

cheers
Monz@
Posts: 34
Joined: Fri 18. Feb 2005, 17:10
Location: Balzers / Liechtenstein
Contact:

Post by Monz@ »

once again...

all is functional now (incl. imanager etc.), also IE makes no problems, but now i've the same bug as already described. In the article menu at the points 'keywords', 'subtitle' & 'schlagtext' (maybe "hittingtext" :wink: ) tiny also starts. Who has an idea in which file this maybe is implemented? or is there any connection to the 'wysiwyg.editor.inc.php'?

cheers & have a nice weekend
marco
User avatar
DeXXus
Posts: 2168
Joined: Fri 28. Nov 2003, 06:20
Location: USA - Florida

Post by DeXXus »

Monz@ wrote:Who has an idea in which file this maybe is implemented? or is there any connection to the 'wysiwyg.editor.inc.php'?

cheers & have a nice weekend
marco
"article.editsummary.tmpl.php"

$BL['be_article_akeywords'] ---keywords
$BL['be_article_asubtitle'] ------subtitle
$BL['be_article_asummary'] ----schlagtext

reference:

Code: Select all

$wysiwyg_editor = array(
	'value'		=> $article["article_summary"],
	'field'		=> 'article_summary',
	'height'	=> '450px',
	'width'		=> '536px',
	'rows'		=> '15',
	'editor'	=> $_SESSION["WYSIWYG_EDITOR"],
	'lang'		=> 'en'
);
include('include/inc_lib/wysiwyg.editor.inc.php');
Buletti
Posts: 43
Joined: Tue 27. Sep 2005, 10:51
Location: Hamburg / Berlin / Germany

Post by Buletti »

Today tiny isn't working anymore, it doesn't load up.
And I don't know why ?

Maybe anyone who has a working tiny integration with the 1.2.6 DEV can
copy the case 5... thing here once again...please
Monz@
Posts: 34
Joined: Fri 18. Feb 2005, 17:10
Location: Balzers / Liechtenstein
Contact:

Post by Monz@ »

@buletti

I've taken yours - and it's working...

@dexxus

thanx & I'm working on but time is the thing i haven't really...

cheers
Monz@
Buletti
Posts: 43
Joined: Tue 27. Sep 2005, 10:51
Location: Hamburg / Berlin / Germany

Post by Buletti »

I've taken yours - and it's working...
That is not the answer i was waiting for... :oops:
User avatar
fardilha
Posts: 48
Joined: Wed 3. May 2006, 21:18
Location: Portugal
Contact:

Post by fardilha »

Hi all!

Since TinyMCE is the only editor that actually works on Safari (that I'm aware of) I would like to ask if anyone has it working with vers 1.2.6 or 1.2.8.

Thanks
Pedro Fardilha
User avatar
Oliver Georgi
Site Admin
Posts: 9889
Joined: Fri 3. Oct 2003, 22:22
Contact:

Post by Oliver Georgi »

As far I know it's horrible on Safari! It's not usable - so it makes no sense.

Oliver
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон
User avatar
fardilha
Posts: 48
Joined: Wed 3. May 2006, 21:18
Location: Portugal
Contact:

Post by fardilha »

Hi Oliver.

Thank you for your fast replay.

Indeed I only tried it on their site and although it "seemed" to work, I never tried it on real life situations.
Well, if we consider that even they assume that Safari support is "experimental" I have to agree that on a working environment that's not good enough .

It's back to Firefox to me then. :wink:

Take care!
Pedro Fardilha
Locked