diff options
| -rw-r--r-- | engine/lib/mb_wrapper.php | 46 | ||||
| -rw-r--r-- | engine/lib/metadata.php | 4 | ||||
| -rw-r--r-- | engine/lib/metastrings.php | 14 | ||||
| -rw-r--r-- | search/index.php | 2 | ||||
| -rw-r--r-- | version.php | 2 | 
5 files changed, 60 insertions, 8 deletions
diff --git a/engine/lib/mb_wrapper.php b/engine/lib/mb_wrapper.php new file mode 100644 index 000000000..7b3327edc --- /dev/null +++ b/engine/lib/mb_wrapper.php @@ -0,0 +1,46 @@ +<?php +	/** +	 * Elgg wrapper functions for multibyte string support. +	 *  +	 * @package Elgg +	 * @subpackage Core +	 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 +	 * @author Curverider Ltd +	 * @copyright Curverider Ltd 2008-2009 +	 * @link http://elgg.org/ +	 */ + +	/** +	 * Wrapper function: Returns the result of mb_strtolower if mb_support is present, else the +	 * result of strtolower is returned. +	 * +	 * @param string $string The string. +	 * @param string $charset The charset (if multibyte support is present) : default 'UTF8' +	 * @return string +	 */ +	function elgg_strtolower($string, $charset = 'UTF8') +	{ +		if (is_callable('mb_strtolower')) +			return mb_strtolower($string, $charset); +			 +		return strtolower($string); +	} +	 +	/** +	 * Wrapper function: Returns the result of mb_strtoupper if mb_support is present, else the +	 * result of strtoupper is returned. +	 * +	 * @param string $string The string. +	 * @param string $charset The charset (if multibyte support is present) : default 'UTF8' +	 * @return string +	 */ +	function elgg_strtoupper($string, $charset = 'UTF8') +	{ +		if (is_callable('mb_strtoupper')) +			return mb_strtoupper($string, $charset); +			 +		return strtoupper($string); +	} +	 +	// TODO: Other wrapper functions +?>
\ No newline at end of file diff --git a/engine/lib/metadata.php b/engine/lib/metadata.php index ebc425f17..79a5faacf 100644 --- a/engine/lib/metadata.php +++ b/engine/lib/metadata.php @@ -797,8 +797,8 @@  		if (is_string($string)) {
  			$ar = explode(",",$string);
 -			$ar = array_map('trim', $ar); // trim blank spaces
 -			//$ar = array_map('strtolower', $ar); // make lower case : [Marcus Povey 20090210 - Commented out since strtolower is not UTF8 safe]
 +			$ar = array_map('trim', $ar); // trim blank spaces +			$ar = array_map('elgg_strtolower', $ar); // make lower case : [Marcus Povey 20090605 - Using mb wrapper function using UTF8 safe function where available]
  			$ar = array_filter($ar, 'is_not_null'); // Remove null values
  			return $ar;
  		}
 diff --git a/engine/lib/metastrings.php b/engine/lib/metastrings.php index b37456b3a..2e308e12e 100644 --- a/engine/lib/metastrings.php +++ b/engine/lib/metastrings.php @@ -21,9 +21,10 @@  	 * Return the meta string id for a given tag, or false.  	 *   	 * @param string $string The value (whatever that is) to be stored +	 * @param bool $case_sensitive Do we want to make the query case sensitive?  	 * @return mixed Integer tag or false.  	 */ -	function get_metastring_id($string) +	function get_metastring_id($string, $case_sensitive = true)  	{  		global $CONFIG, $METASTRINGS_CACHE, $METASTRINGS_DEADNAME_CACHE; @@ -49,7 +50,11 @@  		if ($metastrings_memcache) $msfc = $metastrings_memcache->load($string);  		if ($msfc) return $msfc; -		$row = get_data_row("SELECT * from {$CONFIG->dbprefix}metastrings where string='$string' limit 1"); +		// Case sensitive +		$cs = ""; +		if ($case_sensitive) $cs = " BINARY "; +		 +		$row = get_data_row("SELECT * from {$CONFIG->dbprefix}metastrings where string=$cs'$string' limit 1");  		if ($row) {   			$METASTRINGS_CACHE[$row->id] = $row->string; // Cache it @@ -106,15 +111,16 @@  	 * It returns the id of the tag, whether by creating it or updating it.  	 *   	 * @param string $string The value (whatever that is) to be stored +	 * @param bool $case_sensitive Do we want to make the query case sensitive?  	 * @return mixed Integer tag or false.  	 */ -	function add_metastring($string) +	function add_metastring($string, $case_sensitive = true)  	{  		global $CONFIG, $METASTRINGS_CACHE, $METASTRINGS_DEADNAME_CACHE;  		$sanstring = sanitise_string($string); -		$id = get_metastring_id($string); +		$id = get_metastring_id($string, $case_sensitive);  		if ($id) return $id;  		$result = insert_data("INSERT into {$CONFIG->dbprefix}metastrings (string) values ('$sanstring')"); diff --git a/search/index.php b/search/index.php index 768224c2a..8cadcdcf6 100644 --- a/search/index.php +++ b/search/index.php @@ -76,7 +76,7 @@  			$body .= elgg_view_title($title); // elgg_view_title(sprintf(elgg_echo('searchtitle'),$tag));
  			$body .= trigger_plugin_hook('search','',$tag,"");
  			$body .= elgg_view('search/startblurb',array('tag' => $tag));
 -			$body .= list_entities_from_metadata($md_type, $tag, $objecttype, $subtype, $owner_guid_array, 10, false, false);
 +			$body .= list_entities_from_metadata($md_type, elgg_strtolower($tag), $objecttype, $subtype, $owner_guid_array, 10, false, false);
  			$body = elgg_view_layout('two_column_left_sidebar','',$body);
  		}
 diff --git a/version.php b/version.php index c9466556b..013b80650 100644 --- a/version.php +++ b/version.php @@ -13,7 +13,7 @@  	 * @link http://elgg.org/
  	 */
 -	   $version = 2009052801;  // YYYYMMDD   = Elgg Date +	   $version = 2009060501;  // YYYYMMDD   = Elgg Date  	                           //         XX = Interim incrementer
  	   $release = '1.5';    // Human-friendly version name
  | 
