From e47f65729dbe2b7658c5cdf8eaac37f150536e47 Mon Sep 17 00:00:00 2001 From: james Date: Mon, 7 Mar 2011 16:28:02 +0000 Subject: [PATCH] Trim the summary before splitting to count words (gets rid of leading and trailing whitespace causing extra 'words') --- register_participants.inc.php | 3 ++- register_participants_project.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/register_participants.inc.php b/register_participants.inc.php index 6f93eb9..9b7551e 100644 --- a/register_participants.inc.php +++ b/register_participants.inc.php @@ -288,7 +288,7 @@ function saveProjectData($data,$registrations_id=null){ $qstr="SELECT * FROM projects WHERE id='" . $data['project_id'] . "' AND registrations_id='" . $rid . "' AND conferences_id='" . $conference['id'] . "'"; $q = mysql_query($qstr); if(mysql_num_rows($q) == 1) { - $summarywords = preg_split("/[\s,]+/", $data['summary']); + $summarywords = preg_split("/[\s,]+/", trim($data['summary'])); $summarywordcount = count($summarywords); if($summarywordcount > $config['participant_project_summary_wordmax'] || $summarywordcount<$config['participant_project_summary_wordmin']) $summarycountok=0; @@ -576,6 +576,7 @@ function getProject($userId,$registrations_id=null){ 'projects.id AS project_id', 'registrations.num AS registration_number', 'projects.projectdivisions_id', + 'projects.projectcategories_id', 'projects.title', 'projects.language', 'projects.req_electricity', diff --git a/register_participants_project.php b/register_participants_project.php index da90ed5..a21751e 100644 --- a/register_participants_project.php +++ b/register_participants_project.php @@ -241,7 +241,7 @@ function countwords() echo "".i18n("Summary").": ".REQUIREDFIELD."
"; - $summarywords=preg_split("/[\s,]+/",$projectinfo->summary); + $summarywords=preg_split("/[\s,]+/",trim($projectinfo->summary)); $summarywordcount=count($summarywords); if($summarywordcount>$config['participant_project_summary_wordmax']) echo "
";