Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: Dove - huhtikuu 27, 2004, 12:32:53 IP

Otsikko: Code help -newbie adding button to template -Spell Check / phpSpell
Kirjoitti: Dove - huhtikuu 27, 2004, 12:32:53 IP
Hello,

     I am trying to use a different Spell Checker, since Pspell is
not an option for me.  I have everything set with the database
and the dictionary is loaded.  I just need to add 2 things to
the template.

This is what I need, and I'm not sure which template & where in
the template to edit.
----

You will need to modify the HTML in which ever program you use and add the following javascript & button:


   <script language='javascript' src='spelling/spellmessage.js'></script>
   <input type="button" class="" value="Spell Check" onclick="openspell();">

Any help is appreciated.
Otsikko: Re: Code help -newbie adding button to template
Kirjoitti: [Unknown] - huhtikuu 27, 2004, 12:41:54 IP
Please try replacing the single quotes (') with doubles quotes (") or escaped quotes (\').

You'll want to add it to the Post template.  Search for <input type="submit".

-[Unknown]
Otsikko: Re: Code help -newbie adding button to template
Kirjoitti: Dove - huhtikuu 28, 2004, 12:09:36 IP
Thank you for leading me in the right direction! 

This is what worked (the double quotes like you said):
<script language="Javascript" src="spelling/spellmessage.js"></script>

and this for the button:
<input type="button" class="button" name="spellcheck" value="SpellCheck" accesskey="p" tabindex="4" onclick="openspell();"/>';

I now have a working spellcheck, I am soooo happy!!

If anyone would like the link to the software (it's free),
and uses a table in your mysql database for the dictionary,
I could post the link.  Right now they only offer English, &
Russian.  It's an alternative to the great spell check offered
here.
 
In fact I would like to send this to the company so they
could support it, since they already support 4 other boards,
why not this one?  Would that be ok?

Thanks Again!


Otsikko: Re: Code help -newbie adding button to template -Spell Check
Kirjoitti: [Unknown] - huhtikuu 28, 2004, 01:43:44 IP
It would be great if you could write a package to install the spell checker ;).

I can help you do that ;).

-[Unknown]
Otsikko: Re: Code help -newbie adding button to template -Spell Check
Kirjoitti: Springer - huhtikuu 28, 2004, 07:02:34 IP
/me applauds Dove
Otsikko: Re: Code help -newbie adding button to template -Spell Check
Kirjoitti: Dove - huhtikuu 29, 2004, 04:00:23 AP
LOL ... there is newbie in the topic up there ^

There is an installer already - sort of.  What they do is
give you instructions for a specific board, and since there wasn't
one for "SMF," I had to use the general MySQL based board
(Native MySQL) instructions.

Here is the link to the software, so you could see what I mean:

http://www.master-technology.com/demos/spell/download.php

What I was going to do was send them what I changed so they
could make an instruction sheet for a SMF board, and hopefully
they would use it.   Maybe you want to look at what I changed, &
check it before I send it, if you have time.  If you want to make
an installer of some kind, I will definitely send it to them.

Where I added the javascript and button:
Open post.template.php in themes/default
Find around line 350:

<td align="center" colspan="2">', !empty($settings['additional_options_collapsable']) ? '
<script language="JavaScript" type="text/javascript"><!--

Change to:

<td align="center" colspan="2">', !empty($settings['additional_options_collapsable']) ? '
<script language="Javascript" src="spelling/spellmessage.js"></script>
<script language="JavaScript" type="text/javascript"><!--


Find around line 356:

<input type="submit" name="preview" value="' . $txt[507] . '" onclick="return submitThisOnce(this);" accesskey="p" tabindex="4" />';

Change to:

<input type="submit" name="preview" value="' . $txt[507] . '" onclick="return submitThisOnce(this);" accesskey="p" tabindex="4" />
<input type="button" class="button" name="spellcheck" value="SpellCheck" accesskey="p" tabindex="4" onclick="openspell();"/>';


Open spellmessage.js (they give you this file):
Find:

function openspell()
        {
          height = 391;
          width = 555;
          if (ie4) LinkToField = self.post.message;
          if (gecko) {
            LinkToField = parent.document.post.message;
            height = height + 6;
          }


Change to:

function openspell()
        {
          height = 391;
          width = 555;
          if (ie4) LinkToField = self.postmodify.message;
          if (gecko) {
            LinkToField = parent.document.postmodify.message;
            height = height + 6;
          }


It works great.  Thanks again for your help.


Otsikko: Re: Code help -newbie adding button to template -Spell Check
Kirjoitti: oscar2001 - lokakuu 30, 2004, 07:37:31 AP
Sorry for dragging up a old post but I became interested in this option since Pspell isnt a option for me either.

I applied this mod to a newly installed test forum (the newest RC2) and it works ok (even though the coding for the post.template.php is different to when dove first posted this) but after applying it in the same way to my working forum it wont function. The java script wont pop up and I get a error in internet explorer staing there there is a error on that page.

Here is the way I did it
Here is where I added the <script language="Javascript" src="spelling/spellmessage.js"></script>
<td align="center" colspan="2">';
if (!empty($settings['additional_options_collapsable']) && empty($context['attached']))
echo '
                                    <script language="Javascript" src="spelling/spellmessage.js"></script>
<script language="JavaScript" type="text/javascript"><!--
swapOptions();
// --></script>';


Heres where I added the <input type="button" class="button" name="spellcheck" value="SpellCheck" accesskey="p" tabindex="4" onclick="openspell();"/>';

<input type="submit" name="preview" value="', $txt[507], '" onclick="return (!document.postmodify.attachmentPreview.value || confirm(\'' . $txt['attach_lose'] . '\')) &amp;&amp; submitThisOnce(this);" accesskey="p" tabindex="4" />
                                    <input type="button" class="button" name="spellcheck" value="SpellCheck" accesskey="p" tabindex="4" onclick="openspell();"/>';


I thought possibly a "solve topic" mod by grudge might be affecting it so I uninstalled it but I still get the same.

I have dummy testing account on both forums if anyone wants to take a look and try the spell check.
username tester
pass   tester

This is the testing forum it works on
http://www.worldcichlids.com/smf2 (freshly installed forum)

this is the main working forum which I get the error

http://www.worldcichlids.com/yabbse (forum that has been from the old various versions of yabbse to various versions to the newest verion of smf)

Any help would be greatly appreciated :)

Otsikko: Re: Code help -newbie adding button to template -Spell Check
Kirjoitti: Oldiesmann - lokakuu 30, 2004, 06:05:58 IP
You forgot to put this in Post.template.php:

<script type="text/javascript" langauge="JavaScript" src="spellmessage.js"></script>

Add that somewhere inside one of the echo statements (doesn't really matter where as long as it's before that input line) and it should work fine. That "error on page" thing is IE's way of telling you there is (are) javascript error(s) on that page (in this case, the openSpell() function is undefined).
Otsikko: Re: Code help -newbie adding button to template -Spell Check
Kirjoitti: oscar2001 - lokakuu 30, 2004, 08:01:17 IP
isnt that basicly the same as <script language="Javascript" src="spelling/spellmessage.js"></script> which I  already added here


<td align="center" colspan="2">';
if (!empty($settings['additional_options_collapsable']) && empty($context['attached']))
echo '
                                    [font=Verdana]script language="Javascript" src="spelling/spellmessage.js"></script>[/font]
<script language="JavaScript" type="text/javascript"><!--
swapOptions();
// --></script


You got me thinking though with the idea of placing it elswhere, so I added it here and it now works
echo '
                                    <script language="Javascript" src="spelling/spellmessage.js"></script>   
<span class="smalltext"><br />', $txt['smf16'], '</span><br />
<input type="submit" name="post" value="', $context['submit_label'], '" onclick="return submitThisOnce(this);" accesskey="s" tabindex="3" />
<input type="submit" name="preview" value="', $txt[507], '" onclick="return (!document.postmodify.attachmentPreview.value || confirm(\'' . $txt['attach_lose'] . '\')) &amp;&amp; submitThisOnce(this);" accesskey="p" tabindex="4" />
                                    <input type="button" class="button" name="spellcheck" value="SpellCheck" accesskey="p" tabindex="4" onclick="openspell();"/>';



Thanks :)
Otsikko: Re: Code help -newbie adding button to template -Spell Check
Kirjoitti: [Unknown] - marraskuu 01, 2004, 02:16:27 AP
Hmm, interesting.  How well does this spell checking work, anyway?

Perhaps someone wants (I'm saying this again..) to create a full-fledged package to make this available to even PHP illiterate people?

-[Unknown]
Otsikko: Re: Code help -newbie adding button to template -Spell Check
Kirjoitti: oscar2001 - marraskuu 01, 2004, 03:52:48 IP
Seems to work pretty well, while I still have my test forum up anyone can try it using the tester account, http://www.worldcichlids.com/smf2

EDIT: Fixed link - Oldiesmann
Otsikko: Re: Code help -newbie adding button to template -Spell Check
Kirjoitti: Oldiesmann - marraskuu 02, 2004, 11:03:14 AP
Does seem to work pretty well. Nice little interface there too.
Otsikko: Re: Code help -newbie adding button to template -Spell Check
Kirjoitti: Jack.R.Abbit™ - marraskuu 03, 2004, 12:27:22 IP
Javascript error using Opera 7.54:
LainaaEvent thread: onclick
Error:
name: TypeError
message: Statement on line 40: Expression evaluated to null or undefined and is not convertible to Object: LinkToField
Backtrace:
  Line 40 of linked script http://www.worldcichlids.com/smf2/spelling/spellmessage.js
    if (LinkToField.value.length == 0)
  In unknown script
    openspell();
  At unknown location
    {event handler trampoline}
Otsikko: Re: Code help -newbie adding button to template -Spell Check
Kirjoitti: Oldiesmann - marraskuu 03, 2004, 02:03:15 IP
Looks like they weren't paying attention...

This is the line to determine whether or not you're using opera 7:

        var op7=(navigator.userAgent.indexOf('Opera/7') > -1) ? 1 : (navigator.userAgent.indexOf('Opera 7') > -1) ? 1:0;

I wouldn't think that could mess things up, but it might...
Otsikko: Re: Code help -newbie adding button to template -Spell Check
Kirjoitti: [Unknown] - marraskuu 03, 2004, 06:05:49 IP
Why not just use document.postmodify instead of this document.forms[0] crap?  That works in Opera too...

I just messed with it, but it seems like this would be a lot more cross browser:
// --------------------------------------------------------------------
// phpSpell Javascript (For the SMF Message Document)
//
// This is (c)Copyright 2003, Team phpSpell.
// --------------------------------------------------------------------
        var LinkToField;

        function openspell()
        {
          height = 391;
          width = 555;

          if (navigator.userAgent.indexOf('Gecko') > -1 || navigator.userAgent.indexOf('Safari') > -1)
            height = height + 6;

          if (navigator.userAgent.indexOf('Opera/6') > -1)
          {
            height = height + 10;
            width = width + 10;
          }

          if (typeof(parent.document.postmodify.message) == "undefined")
            alert("Sorry, phpSpell only supports the following browsers:\nOpera 6+, Netscape 6+, Mozilla 1+, Internet Explorer 4+, Safari");
          else
          {
            LinkToField = parent.document.postmodify.message;
            if (LinkToField.value.length == 0) return;

            directory = penspell.arguments.length == 1 ? "" : "spelling/";
            win1=window.open(directory+"phpSpell.html","spellcheckwin",'resizable=no,width='+width+',height='+height);
            if (win1.opener == null) win1.opener = self;
          }

          return false;
        }

        function Opera_Get_Link()
        {
          return LinkToField;
        }


-[Unknown]
Otsikko: Re: Code help -newbie adding button to template -Spell Check
Kirjoitti: Dove - helmikuu 23, 2005, 12:19:25 IP
This worked :) except for an itsy bitsy typo where it says:

penspell

should be

openspell

;)
Otsikko: Re: Code help -newbie adding button to template -Spell Check
Kirjoitti: Dove - helmikuu 23, 2005, 12:24:58 IP
Lainaus käyttäjältä: [Unknown] - marraskuu 01, 2004, 02:16:27 AP
Hmm, interesting.  How well does this spell checking work, anyway?

Perhaps someone wants (I'm saying this again..) to create a full-fledged package to make this available to even PHP illiterate people?

-[Unknown]

I wouldn't mind doing this, except I am not sure how to go about it.
I am concerned about copyrights (the re-distributing their files part-
if there is any...).
Should I just offer the "smf" edited code files for download, or attach
them here or something with an install for SMF specific instructions?

- DoVe



Otsikko: Re: Code help -newbie adding button to template -Spell Check
Kirjoitti: Dove - helmikuu 25, 2005, 10:43:14 AP
I am going to reply to my own post, since I have heard from the
owner of Pspell.  He is going to add SMF to his official distribution
of this as soon as I send him the edited files (or the code on how
to edit them).

Presently this script supports:

  PHPBB v2.0x
  HiveMail 1.2
  Invision 1.1x
  phpNuke 6.5
  pSpell (php module)
  phpMail 1.x
  VBulletian
  Native MySQL interface

..... and hopefully soon SMF will be on there. :)
Otsikko: Re: Code help -newbie adding button to template -Spell Check
Kirjoitti: icegator - toukokuu 03, 2005, 10:11:03 IP
Has anyone successfully intergrated this spell checker into the Personal Message template, and if so how?  :-\
Otsikko: Re: Code help -newbie adding button to template -Spell Check
Kirjoitti: Dove - toukokuu 04, 2005, 06:27:17 IP
Hello,
Open (Version 1.03) Themes/default/InstantMessage.template.php
^^ or each theme -InstantMessage.template.php

[ FIND around line 372 ]-----------------------------------------
  <input type="submit" name="preview" value="', $txt[507], '" onclick="return submitThisOnce(this);" accesskey="p" />';
if ($context['show_spellchecking'])
echo '
<input type="button" value="', $txt['spell_check'], '" onclick="spellCheck( \'postmodify\', \'message\');">';


[ Change to : so it looks like this]-------------------
<input type="submit" name="preview" value="', $txt[507], '" onclick="return submitThisOnce(this);" accesskey="p" />';
echo '
<script language="Javascript" src="spelling/spellmessage.js"></script>
<input type="button" value="', $txt['spell_check'], '" onclick="openspell();"/>';


:)


Otsikko: Re: Code help -newbie adding button to template -Spell Check
Kirjoitti: icegator - toukokuu 05, 2005, 04:30:22 IP
Thank you much Dove.  :) Worked like a charm!  :D  This spell checker has been a life saver because my hosting providers just can't seem to get the dictionary for pspell installed.   Thanks again for letting everyone know about this particular spell checker and how to install it.  ;)
Otsikko: Re: Code help -newbie adding button to template -Spell Check
Kirjoitti: Dove - toukokuu 06, 2005, 03:36:36 AP
Oh gee..  :) your welcome :)

Here is what one hosting company had to say to me when
I asked them if their php included pspell:
LainaaPHP is supported. All versions are the newest.
I'm not sure wat pspell is, but if you could explain it, I'm sure we could get it, or put it on our list of additional features.

Thanks for your interest!
;)

Take Care
Otsikko: Re: Code help -newbie adding button to template -Spell Check / phpSpell
Kirjoitti: mrandall131 - elokuu 10, 2005, 02:04:20 IP
Has anyone done this for 1.1 Beta 3 yet?  I can't seem to find the correct places to modify post.template.php.
Otsikko: Re: Code help -newbie adding button to template -Spell Check / phpSpell
Kirjoitti: Dove - elokuu 10, 2005, 03:10:12 IP
Hi,
     You can download the updated instructions with the modified
spellmessage.js HERE (http://www.smf-nuke.com/modules.php?name=Downloads&d_op=viewdownload&cid=5)

I'll have a complete package for download by the end of today. :)

Otsikko: Re: Code help -newbie adding button to template -Spell Check / phpSpell
Kirjoitti: mrandall131 - elokuu 10, 2005, 03:21:39 IP
Wow, I wasn't expecting the response so fast!  Thanks a lot!
Otsikko: Re: Code help -newbie adding button to template -Spell Check / phpSpell
Kirjoitti: mrandall131 - elokuu 12, 2005, 05:00:57 AP
Awsome it works! 

I came back here to find out how to integrate it into the instant message function and there is one problem, there is no instantmessage.template.php in 1.1 Beta 3?
Otsikko: Re: Code help -newbie adding button to template -Spell Check / phpSpell
Kirjoitti: Dove - elokuu 12, 2005, 05:21:50 AP
Hello,
  At the end of the day those instructions made it .. :)

### THE PERSONAL MESSAGE TEMPLATE (this was called InstantMessageTemplate.php in Older SMF Versions): ###

1. Open up the Themes/default/PersonalMessage.template.php (or yourthemename/PersonalMessage.template.php)
2. [ FIND around line 689]:--------------------------------------------------------
// Send, Preview, spellcheck buttons.
        echo '
                          <tr>
                                    <td align="right" colspan="2">
                                    <input type="submit" value="', $txt[148], '" tabindex="', $context['tabindex']++, '" onclick="return submitThisOnce(this);" accesskey="s" />
                                    <input type="submit" name="preview" value="', $txt[507], '" tabindex="', $context['tabindex']++, '" onclick="return submitThisOnce(this);" accesskey="p" />';


3. [CHANGE TO: ----- [SO NOW THE ENTIRE BLOCK OF CODE SHOULD LOOK LIKE THIS: ]-------

// Send, Preview, spellcheck buttons.
        echo '
                          <script language="Javascript" src="spelling/spellmessage.js"></script>
        <tr>
                                    <td align="right" colspan="2">
                                    <input type="submit" value="', $txt[148], '" tabindex="', $context['tabindex']++, '" onclick="return submitThisOnce(this);" accesskey="s" />
                                    <input type="submit" name="preview" value="', $txt[507], '" tabindex="', $context['tabindex']++, '" onclick="return submitThisOnce(this);" accesskey="p" />
<input type="button" class="" value="Spell Check" onclick="openspell();">';
                                                                               


The InstantMessageTemplate.php is now --->PersonalMessage.template.php

:)
Otsikko: Re: Code help -newbie adding button to template -Spell Check / phpSpell
Kirjoitti: mrandall131 - elokuu 12, 2005, 06:37:55 AP
Thanks, you are too kind!   ;D
Otsikko: Re: Code help -newbie adding button to template -Spell Check / phpSpell
Kirjoitti: xtremecruiser - elokuu 17, 2005, 04:23:27 IP
I just found this thread, Thank you for all the guys like me who have PHP impared hosts !
Otsikko: Re: Code help -newbie adding button to template -Spell Check / phpSpell
Kirjoitti: wally2255 - marraskuu 12, 2005, 01:57:08 IP
OK I am new to admin of forums so I hope I don't sound stupid for asking this. I have the newest version of SMF and I would like to add phpspell can some one give me step by step instruction on how to set it up. I have access to mysql and phpadmin. But I don't know how to add or set up phpspell.
Otsikko: Re: Code help -newbie adding button to template -Spell Check / phpSpell
Kirjoitti: mrandall131 - marraskuu 26, 2005, 09:49:50 AP
Just thought I'd update this, in case other are installing it again.  The following has the updated line numbers for finding the associated lines of code. I didn't have to install the database, or upload anything, just modify the 2 files.

post.template.php - around line 600
PersonalMessage.template.php - around line 884
Otsikko: Re: Code help -newbie adding button to template -Spell Check / phpSpell
Kirjoitti: mrandall131 - maaliskuu 02, 2006, 11:11:07 AP
Hate to bring this up again.  i installed it on RC2 and the checker works in the post template.  Unfortunately, I can't get it to work in the PM template.