Simple Machines Community Forum

Customizing SMF => Modifications and Packages => Topic started by: Rudolf on July 18, 2007, 10:57:32 AM

Title: Disable shouting
Post by: Rudolf on July 18, 2007, 10:57:32 AM
Link to Mod (http://custom.simplemachines.org/mods/index.php?mod=869)

*****************************************************
Disable shouting - Modification for SMF
version 1.0
© 2007, Rudolf Martincsek
*****************************************************
This mod changes text written in upper case letters into lower case letters. Only in the topic disaply page!
You can enable/disable in Admin -> Posts and Topics -> "Disable shouting".
The feature is disabled by default
Title: Re: Disable shouting
Post by: shadow82x on July 18, 2007, 12:05:01 PM
Very Nice mod again Rudolf. :)
Title: Re: Disable shouting
Post by: GC on July 18, 2007, 01:27:32 PM
If the text were to be like "Hello", would it display "hello"?

Also, on my board there's a game we discuss about called SOCOM, and yes it's spelt in caps. Would this mod change it to socom or Socom?

Is there a way to stop certain words from being uncapitalized?
Title: Re: Disable shouting
Post by: Rudolf on July 19, 2007, 08:35:21 PM
I will be adding that feature soon.

Don't worry because the mod doesn't changes the content. The content stored in the database is written by the poster.
You might see it now lowercase, but once the feature included it will turn back normal.
Title: Re: Disable shouting
Post by: GC on July 20, 2007, 04:22:38 AM
Sweet :) Sounds gooooood
Title: Re: Disable shouting
Post by: sodmanccc on July 20, 2007, 09:14:56 PM
this type of mod is really needed at a forum like ours.

however when we install and enable it it does not seam to change it 100%, when posting a shouting or yelling TOPIC subject and message but only the message content is change. once i double click to change the title i add any letter or number and then allow it to change it does change it from yelling to not but then once you refresh its changed back for some reason.

Rudolf you made by far one of the best mods for SMF (the enhanced stats) so i know you are busy but i was hoping i could get a little help on this please pm me if you can assist me. thanks and great work.
Title: Re: Disable shouting
Post by: Rudolf on July 20, 2007, 10:38:17 PM
Do you have any errors in the error log related to this?
If the install went fine I see no reason why it shouldn't work.
Can you give a link to your forum?
Title: Re: Disable shouting
Post by: sodmanccc on July 24, 2007, 01:32:00 AM
hello

yea it is working partly... only in the Message it self, but when looking at the forums main you still SEE CAPS

i am kind of thinking that it pretty much has to change the topic title from caps to not other wise there is still caps and shouting.


i am going to PM you the site URL thanks.
Title: Re: Disable shouting
Post by: Rudolf on July 24, 2007, 03:26:55 AM
Removing shouting from any part of the forum is quite easy, but it requires small modifications in numerous files.
I will add this in other places in the next versions.
This was an "emergency" release to handle the topic display area.
Title: Re: Disable shouting
Post by: LeeOwen on July 31, 2007, 09:34:35 AM
Alright,

Blinding add on, anyway to make it so it alters the same for 'Recent Posts'

Cheers
Lee
MillwallOnline.co.uk
Title: Re: Disable shouting
Post by: michaelnl on August 12, 2007, 02:57:30 PM
Hi,

I think i've found a bug. With sticky topics I get this error:

Notice: Uninitialized string offset: -1 in /home/holland/public_html/smf/Sources/Subs.php on line 3611

Line 3611 is:

$pos--;


And that's part of:

//-Disable shouting MOD- START
function disableShouting($string, $echo = false)
{
global $func, $modSettings;

if (empty($modSettings['disableShouting']))
return $string;

preg_match_all('~[A-Z ]{5,}~',$string, $matches, PREG_OFFSET_CAPTURE);

foreach ($matches[0] as $match)
{
$search = $func['htmltrim']($match[0]);
$pos = $match[1];
do
{
[b]$pos--;[/b]
}while ($pos < 1 && $string[$pos] == ' ');

$replace = strtolower($search);
if ($pos <= 0 || in_array($string[$pos], array('.','!','?')))
$replace = ucfirst($replace);
$string = str_replace($search, $replace, $string);
}

if ($echo)
echo $string;
else
return $string;
}
//Disable shouting MOD- END
Title: Re: Disable shouting
Post by: sodmanccc on August 16, 2007, 07:34:39 PM
oh ok, i would be willing to donate a little to help make sure it gets done ... soon..
haha
Title: Re: Disable shouting
Post by: tsmalmbe on October 05, 2007, 01:22:02 PM
Only the message itself is unshoutified, the subject still is with CAPS.

This mod also modifies Post.php, and adds the disableShouting()-method there. If this only affects viewing, why are you modifying stuff in Post.php?

Nice mod, requires a few fixes still :).
Title: Re: Disable shouting
Post by: tsmalmbe on October 05, 2007, 04:36:19 PM
Did some mods to support finnish and swedisch characters. This does not yet cover german umlauts and french wierdnesses (just to mention a few shortcomings). I assume we are using UTF-8 as the forum locale, didnä't know how to pull that  dynamically from the forum.


//-Disable shouting MOD- START
function disableShouting($string, $echo = false)
{
global $func, $modSettings;

if (empty($modSettings['disableShouting']))
return $string;

preg_match_all('~[A-Ö ]{5,}~',$string, $matches, PREG_OFFSET_CAPTURE);

foreach ($matches[0] as $match)
{
$search = $func['htmltrim']($match[0]);
$pos = $match[1];
do
{
$pos--;
}while ($pos < 1 && $string[$pos] == ' ');

$replace = mb_strtolower($search, "UTF-8");
if ($pos <= 0 || in_array($string[$pos], array('.','!','?')))
$replace = ucfirst($replace);
$string = str_replace($search, $replace, $string);
}

if ($echo)
echo $string;
else
return $string;
}
//Disable shouting MOD- END
Title: Re: Disable shouting
Post by: kamili34 on October 05, 2007, 05:06:34 PM
Thanks for another good mod.
Title: Re: Disable shouting
Post by: tsmalmbe on October 06, 2007, 05:34:23 AM
Another big or should I say BIG issue is that it breaks links. I have not verfiied yet that it breaks internal, although that too was reported.

but: http://www.foobar.com/the_EBCDIC_keyboard_layout.pdf cannot be linked to, because this mod modifies the link.
Title: Re: Disable shouting
Post by: Gideon on October 17, 2007, 04:37:56 PM
Great mod, thanks...one problem I found is that if anyone links a photo in an [img] tag which is in caps it changes it, and the photo is not visible...
Title: Re: Disable shouting
Post by: Miyagi on October 28, 2007, 12:29:27 AM
Quote from: michaelnl on August 12, 2007, 02:57:30 PM
Hi,

I think i've found a bug. With sticky topics I get this error:

Notice: Uninitialized string offset: -1 in /home/holland/public_html/smf/Sources/Subs.php on line 3611

Line 3611 is:

$pos--;


And that's part of:

//-Disable shouting MOD- START
function disableShouting($string, $echo = false)
{
global $func, $modSettings;

if (empty($modSettings['disableShouting']))
return $string;

preg_match_all('~[A-Z ]{5,}~',$string, $matches, PREG_OFFSET_CAPTURE);

foreach ($matches[0] as $match)
{
$search = $func['htmltrim']($match[0]);
$pos = $match[1];
do
{
[b]$pos--;[/b]
}while ($pos < 1 && $string[$pos] == ' ');

$replace = strtolower($search);
if ($pos <= 0 || in_array($string[$pos], array('.','!','?')))
$replace = ucfirst($replace);
$string = str_replace($search, $replace, $string);
}

if ($echo)
echo $string;
else
return $string;
}
//Disable shouting MOD- END


I am having this error also!

Rudolf... please help! :)

Thx,
Miyagi
Title: Re: Disable shouting
Post by: pinoypetfinder on December 03, 2007, 01:07:11 AM
i need help on installing this theme on my custom made template..
i need to manually install the script on

Admin.template.php  and languages/Admin.english.php .. but what script and where should i place that?

package parser not working :(
Title: Re: Disable shouting
Post by: H3 Skillz on January 23, 2008, 06:51:55 PM
Could someone tell me how to edit the instalation files (or just the post.php document itself) to allow this just in topic titles?  I really love this mod but I don't like the fact that it does it in the actual post as well as the topic title.  I'm sure this is pretty simple to do but I'm just missing something, could someone help me out with this?
Title: Re: Disable shouting
Post by: Rudolf on January 24, 2008, 03:15:32 AM
In Display.php
Code (Find and delete) Select
$message['subject'] = disableShouting($message['subject']); //-Disable shouting MOD-

In Post.php
Code (Find and delete) Select
$context['message']['body'] = disableShouting($context['message']['body']);
Title: Re: Disable shouting
Post by: H3 Skillz on January 24, 2008, 09:50:13 AM
Thank you!

Edit: Wait are you sure?  The first one you told me to delete was the subject part, if I wanted to disable shouting in the subject but not the body, wouldn't you delete the body part instead?  I'm not that good at HTML or PHP or anything but I'm pretty sure you have to delete the body part.  Anyway, even when I tried it your way it still didn't seem to work and when I try it my way, it works inside the message (when you view the message) but not when you are viewing it in the forum (like when you see the subjects of all the posted threads in that forum).
Title: Re: Disable shouting
Post by: Rudolf on January 24, 2008, 11:24:48 AM
yes, it was supposed to be the body part. I copied the wrong line.
I don't understand the problem on the forum index.
Title: Re: Disable shouting
Post by: H3 Skillz on January 24, 2008, 11:55:57 AM
What is the file that displays the forum index?  Maybe I could just figure it out by searching that file for disableshouting and deleting that line of code.
Title: Re: Disable shouting
Post by: Rudolf on January 24, 2008, 12:15:38 PM
MessageIndex.php
Title: Re: Disable shouting
Post by: H3 Skillz on January 25, 2008, 11:13:23 AM
Hum, that's wierd cuz that page doesn't even have anything about the disable shouting.  When you instal the mod, it doesn't even do anything to that page.  You know, I'm using 1.1.4 and this mod is made for 1.1.3 and it works perfectly when I don't try to modify it so maybe my SMF version has something to do with it.
Title: Re: Disable shouting
Post by: Goad on February 06, 2008, 01:21:05 PM
bump to see this continue to be developed....i really need this mod but i'd rather live without for broken links (img or url)
Title: Re: Disable shouting
Post by: m1ss1nnocent on August 18, 2008, 05:43:16 PM
Another bump for continued Dev on this mod.

Is there any way to configure it so that it only un-capitalises when more than say 4 or 5 letters are capital? At present it allows things like MK1 (where only 2 letters are capitals) but as soon as you do 3 or more capitals (FORD for example) it sends it to lower case. Anyone know where the code is to change it from the trigger being 3 letters or more to start converting?
Title: Re: Disable shouting
Post by: Rudolf on August 20, 2008, 07:31:47 AM
Quote from: m1ss1nnocent on August 18, 2008, 05:43:16 PM
Another bump for continued Dev on this mod.

Is there any way to configure it so that it only un-capitalises when more than say 4 or 5 letters are capital? At present it allows things like MK1 (where only 2 letters are capitals) but as soon as you do 3 or more capitals (FORD for example) it sends it to lower case. Anyone know where the code is to change it from the trigger being 3 letters or more to start converting?

The minimum length of a word lowercased is 5 letters. It shouldn't lowercase FORD.

to change the length find in Subs.php
preg_match_all('~[A-Z ]{5,}~',$string, $matches, PREG_OFFSET_CAPTURE);
and replace the number 5, with the minimum length you want.
Title: Re: Disable shouting
Post by: DarkflameQ on August 25, 2010, 06:59:42 PM
A shame this hasn't been updated to v2.0 RC3
Title: Re: Disable shouting
Post by: cyberdyne on April 02, 2011, 11:46:26 PM
I have this installed with a custom theme on v.1.1.13. I had to install it manually as the auto install didn't work.
The function works, but I get 2 small errors in the forum logs:

QuoteApply Filter: Only show the errors with the same message
8: Undefined variable: context
File: /home/server/public_html/forum/Sources/Post.php
Line: 2396
Refers to line:
$context['message']['subject'] = disableShouting($context['message']['subject']);



Quote8: Uninitialized string offset: -1
File: /home/server/public_html/forum/Sources/Subs.php
Line: 3692
Refers to line:
}while ($pos < 1 && $string[$pos] == ' ');

Would appreciate any help.
Many thanks
Title: Re: Disable shouting
Post by: cyberdyne on April 05, 2011, 11:05:27 AM
Rudolf, any ideas please? These errors are filling up my logs! :)
Thanks
Title: Re: Disable shouting
Post by: kyjeeper on March 06, 2012, 11:41:46 AM
Any shot at this being updated for 2.0.2? I had and loved this mod through 1.1.16, but recently upgraded the forum to 2.0.2 and it is not available.

Thanks!