1
0
mirror of https://github.com/e107inc/e107.git synced 2025-03-14 01:19:44 +01:00

SEF UURL Warning added to NewsPost

This commit is contained in:
Cameron 2017-01-16 12:09:31 -08:00
parent 17ef449420
commit c0e83fa657
2 changed files with 28 additions and 1 deletions

View File

@ -509,6 +509,9 @@ class news_admin_ui extends e_admin_ui
$new_data['news_sef'] = empty($new_data['news_sef']) ? eHelper::title2sef($new_data['news_title']) : eHelper::secureSef($new_data['news_sef']);
$this->checkSEFSimilarity($new_data);
$tmp = explode(chr(35), $new_data['news_author']);
$new_data['news_author'] = intval($tmp[0]);
@ -566,6 +569,9 @@ class news_admin_ui extends e_admin_ui
$new_data['news_sef'] = eHelper::title2sef($new_data['news_title']);
}
$this->checkSEFSimilarity($new_data);
if(!empty($new_data['news_author']))
{
$tmp = explode(chr(35), $new_data['news_author']);
@ -581,6 +587,24 @@ class news_admin_ui extends e_admin_ui
}
/**
* Display a warning if there is a mismatch with the SEF Url.
* @param $new_data
*/
private function checkSEFSimilarity($new_data)
{
$expectedSEF = eHelper::title2sef($new_data['news_title']);
similar_text($expectedSEF,$new_data['news_sef'],$percSimilar);
if($percSimilar < 60)
{
e107::getMessage()->addWarning(LAN_NEWS_108); // The SEF URL is unlike the title of your news item.
}
}
public function afterCreate($new_data, $old_data, $id)
{

View File

@ -232,4 +232,7 @@ define("LAN_NEWS_105", "Email notification triggered!");
define("LAN_NEWS_106", "News item visibility must include 'everyone' for email notifications to work.");
define("LAN_NEWS_107", "Checking for Ping Status");
?>
//v2.1.4
define("LAN_NEWS_108", "The SEF URL is unlike the title of your news item.");
?>