Word Count Limits

Started by ethankcvds, September 08, 2009, 11:53:09 PM

Previous topic - Next topic

ethankcvds

Link to Mod

Original Mod Author: Arantor 

As requested in http://www.simplemachines.org/community/index.php?topic=332053.0

This allows the admin to set a minimum and/or maximum number of words to be present in a post before allowing it to be accepted, e.g. minimum of 20 words in the post.

* allows both individual minimum and maximum, and 'off' limits - 0 = no limit, up to 10000 on either limit (you can set a maximum of 10,000 words for example)
* discounts numbers entirely
* treats punctuation (except ') as word breaking, e.g. two-worded is treated as two words
* considers words as 3 characters or more
* configurable on a per board level

HTML and BBcode is not considered.


Version history:
1.4 RC - 05 June 2019
Removed 1.1 support
Added 2.1 RC 2 support
Quoted posts no longer included in word count total

1.3b - 11 June 2011
Added 2.0 support
Removed 2.0 RC5 support.

1.3a - 13 February 2011
Added 2.0 RC5 support
Removed 2.0 RC4 support.

1.3 - November 2010
Added 2.0 RC4 support
Removed 2.0 RC3 support.
Added Turkish Translations

1.2 - 9 March 2010
Added 2.0 RC3 support
Removed 2.0 RC 1.2 and 2.0 RC2 support.
Added Russian Translations

1.1 - 1 November 2009
Provided compatibility for older PHP/PCRE combinations
Added 2.0 RC2 support

1.0 - August 31, 2009
First public release

Beta - August 28, 2009
Beta release
No Pm's for support please!

cme1st2302

Very cool mod Arantor!!!  This will come in handy!!

Chris
SMF Version: 1.1.11
SimplePortal Version: 2.3.2

Admin

He who waits for perfect conditions sees nothing!!
If you need help adding a button or tab PM me!!

Blinker

Another triumph mate...well done. Keep up the great work.

digit

Yes.  This is good.  REAL good.  Is there any possibility of setting the number of  characters too?  8)  Keep up the great work.
Happily using a heavily modified 1.1.16 version of SMF!

2748011 Posts in 320998 Topics by 50986 Members


SOLD my website - thanks it was a good run - they converted to vbadvanced. (and screwed it up good!)

ოկtђ


Arantor

Well... global maximum of character count is already possible; it's a setting in Post Settings, adding a minimum character count wouldn't be impossible - but would likely be the scope of a separate mod to this.

alex30

Great mod Arantor!

What if people have many boards. Can this mod be updated with option that will allow to modify all boards at once?

Arantor

I suppose it could be but generally you wouldn't apply the same figures to all boards - at least that's not what I thought.

It's easy enough SQL though, and I'm not sure where to put it without giving it its very own page in the admin panel.

SimonSays

Quote from: Arantor on September 11, 2009, 05:04:22 PM
I suppose it could be but generally you wouldn't apply the same figures to all boards - at least that's not what I thought.

It's easy enough SQL though, and I'm not sure where to put it without giving it its very own page in the admin panel.
Allowing a word-limit to be applied to all boards would make sense, which could then be tweaked on a per-board basis. On my site, we have 50+ boards, which makes setting the limit individually tedious. I'd prefer that it could be set all at once.

The appropriate place, it seems to me, for such a setting would be in the "Manage Boards --> Settings" menu (ala, hxxp:www.foo.com/index.php?action=manageboards;sa=settings [nonactive])

Thanks for the cool mod.

Arantor

It would make sense, but at the same time which takes priority, global or board specific? How do you override at board level, given that you can set a 'no limit' option too at board level?

The only way I can see of doing that is adding a tick box in each board to override the global value.

To be honest I'm not sure I'm going to add this in; I've said elsewhere that I'm not making any more mods, massive enhancement to one mod (which, being honest, this is a fair enhancement) isn't something I personally have much time or energy for.

You can set a default however with SQL:
UPDATE smf_boards SET min_words = 1, max_words = 50

Change smf_ to suit your database prefix, set the defaults to values that suit you and you can instantly have a default set right there for all boards.

Jeep29

This is a very good mod !

It is possible to assign it to a group rather than a board


Ps : sorry for my very bad english

Arantor

Quote from: Jeep29 on October 12, 2009, 03:28:38 AM
It is possible to assign it to a group rather than a board

Not without a complete rewrite, not really.

javierjp

First at all, great job man!  :)

I installed in a clean smf 1.1.10 installation, set the minimum to 3 and the maximum to 6 (for testing proposes)  but Not worked for me :(

All i get its "there are no enought words in this post" no matter if i write 1, 10 or 30 words, i get the error always! , smf totally ignore both limits.

The only way i found for write a post its using 0 as minimum.

Any idea for solve this?
thanks in advance




Arantor

What words are you using and is there anything in the error log?

javierjp

#14
Error log:

2: Compilation failed: PCRE does not support \L, \l, \N, \P, \p, \U, \u, or \X at offset 1
File: W:\www\smf10\Sources\Post.php
Line: 2468


Im testing in local mode in my own PC, not in a live enviroment.

Arantor

What version of PHP are you using? That is the result of an older PHP build normally.

Anyway, it's clear that I need to figure out another way of doing this.

javierjp


Arantor

Yes, that will definitely cause that. I would note that even 4.4 series is now almost 2 years old, and 4.3 is much older.

javierjp

Thanks for all man  ;)
I will forget about local mode and try in my live enviroment (php5)

grettings
Javierjp

Arantor

Let me know how that goes. Meantime I'll see if I can find a better solution.

Advertisement: