" . utf8_encode($suggestions[$i]) . "
";
}
if($editablePersonalDict)
{
$retVal .= " because we don't want the links to be clickable
//but we want the html to be rendered in the div for preview purposes.
$string = preg_replace("//i", "
", $string);
$string = preg_replace("//i", "", $string);
$string = preg_replace("//i", "
", $string);
$string = preg_replace("//i", "", $string);
$string = preg_replace("//i", "", $string);
$string = preg_replace("//i", "", $string);
$string = preg_replace("//i", "", $string);
$string = preg_replace("//i", "", $string);
$string = preg_replace("//i", "", $string);
$string = preg_replace("//i", "", $string);
$string = preg_replace("//i", "", $string);
$string = preg_replace("//i", "", $string);
$string = preg_replace("//i", "
", $string);
$string = preg_replace("//i", "", $string);
$string = preg_replace("//i", "", $string);
$string = preg_replace("//i", "", $string);
$cp->set_data($string); //return value - string containing all the markup for the misspelled words.
} // end spellCheck
/*************************************************************
* addWord($str)
*
* This function adds a word to the custom dictionary
*
* @param $str The word to be added
*************************************************************/
function addWord($str)
{
global $editablePersonalDict;
global $pspell_link; //the global link to the pspell module
global $cp; //the CPAINT object
$retVal = "";
pspell_add_to_personal($pspell_link, $str);
if($editablePersonalDict && pspell_save_wordlist($pspell_link))
{
$retVal = "Save successful!";
}
else
{
$retVal = "Save Failed!";
}
$cp->set_data($retVal);
} // end addWord
/*************************************************************
* flattenArray($array)
*
* The flattenArray function is a recursive function that takes a
* multidimensional array and flattens it to be a one-dimensional
* array. The one-dimensional flattened array is returned.
*
* $array - The array to be flattened.
*
*************************************************************/
function flattenArray($array)
{
$flatArray = array();
foreach($array as $subElement)
{
if(is_array($subElement))
{
$flatArray = array_merge($flatArray, flattenArray($subElement));
}
else
{
$flatArray[] = $subElement;
}
}
return $flatArray;
} // end flattenArray
/*************************************************************
* stripslashes_custom($string)
*
* This is a custom stripslashes function that only strips
* the slashes if magic quotes are on. This is written for
* compatibility with other servers in the event someone doesn't
* have magic quotes on.
*
* $string - The string that might need the slashes stripped.
*
*************************************************************/
function stripslashes_custom($string)
{
if(get_magic_quotes_gpc())
{
return stripslashes($string);
}
else
{
return $string;
}
} // end stripslashes_custom
/*************************************************************
* addslashes_custom($string)
*
* This is a custom addslashes function that only adds
* the slashes if magic quotes are off. This is written for
* compatibility with other servers in the event someone doesn't
* have magic quotes on.
*
* $string - The string that might need the slashes added.
*
*************************************************************/
function addslashes_custom($string)
{
if(!get_magic_quotes_gpc())
{
return addslashes($string);
}
else
{
return $string;
}
} // end addslashes_custom
/*************************************************************
* remove_word_junk($t)
*
* This function strips out all the crap that Word tries to
* add to it's text in the even someone pastes in code from
* Word.
*
* $t - The text to be cleaned
*
*************************************************************/
function remove_word_junk($t)
{
$a=array(
"\xe2\x80\x9c"=>'"',
"\xe2\x80\x9d"=>'"',
"\xe2\x80\x99"=>"'",
"\xe2\x80\xa6"=>"...",
"\xe2\x80\x98"=>"'",
"\xe2\x80\x94"=>"---",
"\xe2\x80\x93"=>"--",
"\x85"=>"...",
"\221"=>"'",
"\222"=>"'",
"\223"=>'"',
"\224"=>'"',
"\x97"=>"---",
"\x96"=>"--"
);
foreach($a as $k=>$v){
$oa[]=$k;
$ra[]=$v;
}
$t=trim(str_replace($oa,$ra,$t));
return $t;
} // end remove_word_junk
/*************************************************************
* switchText($string)
*
* This function prepares the text to be sent back to the text
* box from the div. The comments are removed and breaks are
* converted back into \n's. All the html tags that the user
* might have entered that aren't on the approved list:
*
- are stripped out.
* The user-entered returns have already been replaced with
* $u2026 so that they can be preserved. I replace all the
* \n's that might have been added by the browser (Firefox does
* this in trying to pretty up the HTML) with " " so that
* everything will look the way it did when the user typed it
* in the box the first time.
*
* $string - The string of html from the div that will be sent
* back to the text box.
*
*************************************************************/
function switchText($string)
{
global $allowed_html;
global $cp; //the CPAINT object
$string = remove_word_junk($string);
$string = preg_replace("//", "", $string);
$string = preg_replace("/\r?\n/", " ", $string);
$string = stripslashes_custom($string); //we only need to strip slashes if magic quotes are on
$string = strip_tags($string, $allowed_html);
$string = preg_replace('{</?span.*?>}i', '', $string);
$string = html_entity_decode($string);
$cp->set_data($string); //the return value
} // end switchText
?>