Title Control

Title Control 1.7

No permission to download
I'm happy with my current ruleset except for one thing - it won't allow anyone to title a thread with all caps when it's appropriate. Setting appropriateness rules would be very difficult, so I was wondering if there was a way to allow all caps on thread titles up to a certain length?

My current rules:
Code:
<?php
// get title
$title = $this->get('title');
// see if there's any lowercase characters
$pattern[0] = '/[^a-z]/';
$replacement[0] = '';
$parsed = preg_replace($pattern, $replacement, $title); 
$lower_count = strlen($parsed);
// convert title to all lowercase if currently all uppercase
if ($lower_count == 0) {
    $title = strtolower($title);
}
// uppercase the first character of each word in a string
$title = ucwords($title);
// set title
$this->set('title', $title);
?>
 
I don't understand these new features:
  • Added Poll in Options. Allows adding a phrase if the thread contains a poll.
  • Added Multibyte check box in Options.
Could you please describe more with some example or screen shots. Thanks!
 
Is this working with 1.3.3? I installed this and set the Maximum Length to 75 however when on create-thread pages I can still enter up to 100 chars (XenForo default).

Btw it would be really useful if you could integrate a new checkbox like the current "Uppercase First" called something like "Prevent Full Uppercase" which as title says will make all chars lowercase in case everything entered in the title field is in uppercase. And if you want to further improve the functionality, you could do that not only if all chars are uppercase but if a high percentage of them is i.e. 90% because sometime people do this to bypass the restriction: "HI MY NAME IS ANDYB AND I CAME HERE TO STAY forever"
 
Is this path ok?
/library/Andy/TitleControl/rules.php

Or should I put?
/var/www/html/library/Andy/TitleControl/rules.php

Because in the options page you ask for an absolute path whereas in your post 3 you mention relative path.
 
I have uploaded the files, installed the add-on and checkmarked "Uppercase First".

Still all threads starting with lowercase remain lowercase. Have I missed something here? Do I need a custom PHP file, I thought this functionality was built in?

I'm using XenForo 1.3.5.
 
Great add-on! Just to confirm,this will only capitalize the first letter, and not force lowercase any other words correct?

Also, could you provide the script to update older threads to follow this?
 
@AndyB ,
I have a problem with Turkish Chars. For example, If I wrote title like : "KİTAP KITAP" , it is converted to "Kitap Kitap". But I want it to be "Kitap Kıtap".
Is there a solution for this situation ?
Thanks.
Andy, I have solve the problem. Code is bit long but it is working :D
I share with you below. Thanks for your helps.
PHP:
<?php


$title2 = $this->get('title');

$sonuc='';
$kelimeler=explode(" ", $title2);

foreach ($kelimeler as $kelime_duz){
$kelime_uzunluk=strlen($kelime_duz);$ilk_karakter=mb_substr($kelime_duz,0,1,'UTF-8');

if($ilk_karakter=='Ç' or $ilk_karakter=='ç'){
$ilk_karakter='Ç';

}elseif ($ilk_karakter=='Ğ' or $ilk_karakter=='ğ') {
$ilk_karakter='Ğ';

}elseif($ilk_karakter=='I' or $ilk_karakter=='ı'){
$ilk_karakter='I';

}elseif ($ilk_karakter=='İ' or $ilk_karakter=='i'){
$ilk_karakter='İ';

}elseif ($ilk_karakter=='Ö' or $ilk_karakter=='ö'){
$ilk_karakter='Ö';

}elseif ($ilk_karakter=='Ş' or $ilk_karakter=='ş'){
$ilk_karakter='Ş';

}elseif ($ilk_karakter=='Ü' or $ilk_karakter=='ü'){
$ilk_karakter='Ü';

}else{
$ilk_karakter=strtoupper($ilk_karakter);

}

$digerleri=mb_substr($kelime_duz,1,$kelime_uzunluk,'UTF-8');
$digerleri=str_replace('Ç', 'ç', $digerleri);$digerleri=str_replace('Ğ', 'ğ', $digerleri);$digerleri=str_replace('I', 'ı', $digerleri);$digerleri=str_replace('İ', 'i', $digerleri);$digerleri=str_replace('Ö', 'ö', $digerleri);$digerleri=str_replace('Ş', 'ş', $digerleri);$digerleri=str_replace('Ü', 'ü', $digerleri);$digerleri=strtolower($digerleri);


$sonuc.=$ilk_karakter.$digerleri.' ';



}
$son=trim(str_replace(' ', ' ', $sonuc));


// set title

$this->set('title', $title);
?>
 
Last edited:
Could anyone share a php file with the following rules implemented?

1) No period at the end of thread title
2) Convert multiple question/exclamation marks to a single question/exclamation mark
3) Convert all caps to Title case
 
@JackieChun

Here you go:

PHP:
<?PHP

// get title
$title = $this->get('title');

//########################################
// Remove trailing period(s).

$done = '';

while ($done != 'yes')
{
	$length = strlen($title);
	$length = $length - 1;
	$lastchar = substr($title, $length, 1);
	
	if ($lastchar != '.')
	{
		$done = 'yes';
	}
	
	if ($lastchar == '.')
	{
		$title = substr($title, 0, $length);
	}
}

//########################################
// Remove question marks if more than one
// is used.

if (substr_count($title, '?') > 1)
{
	$patterns[0] = '/\?/';
	$replacements[0] = '';
	$title = preg_replace($patterns, $replacements, $title);
}

//########################################
// If all caps over 30 characters, convert
// to sentence case.

if (strlen($title) > 30)
{
	$pattern[0] = '/[^a-z]/';
	$replacement[0] = '';
	$parsed = preg_replace($pattern, $replacement, $title);	
	$lower_count = strlen($parsed);
	
	$pattern[0] = '/[^A-Z]/';
	$replacement[0] = '';
	$parsed = preg_replace($pattern, $replacement, $title);
	$upper_count = strlen($parsed);
	
	if ($upper_count > $lower_count)
	{
		$title = strtolower($title);
		$title = ucwords($title);
	}
}

// set title
$this->set('title', $title);
 
The file doesn't seem to have any effect on thread titles. I was able to post the following threads:

TEST THREAD THREE!!!
TEST THREAD 4????

I changed the number of all caps characters to 5 to make sure the length was suspending the rule, no effect.
 
The main problem I have with people in thread titles is doing things like this:

Read this post!!!!!!

More than one exclamation point.

Open to see more.........

Many periods at the end of posts

###must read###

# or other characters that contribute nothing.

I would like to strip out but one exclamation point, all the periods, and all the # or any other character that doesn't belong in a title ($,^,*,@ and so forth)

Can this add on be configured to do the above? As far as the capital letters the default Xenforo works fine for me with the title case setting.
 
Top Bottom