--- /dev/null
+<?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
\r
if (is_string($string)) {\r
$ar = explode(",",$string);\r
- $ar = array_map('trim', $ar); // trim blank spaces\r
- //$ar = array_map('strtolower', $ar); // make lower case : [Marcus Povey 20090210 - Commented out since strtolower is not UTF8 safe]\r
+ $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]\r
$ar = array_filter($ar, 'is_not_null'); // Remove null values\r
return $ar;\r
}\r
* 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;
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
* 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')");
$body .= elgg_view_title($title); // elgg_view_title(sprintf(elgg_echo('searchtitle'),$tag));\r
$body .= trigger_plugin_hook('search','',$tag,"");\r
$body .= elgg_view('search/startblurb',array('tag' => $tag));\r
- $body .= list_entities_from_metadata($md_type, $tag, $objecttype, $subtype, $owner_guid_array, 10, false, false);\r
+ $body .= list_entities_from_metadata($md_type, elgg_strtolower($tag), $objecttype, $subtype, $owner_guid_array, 10, false, false);\r
$body = elgg_view_layout('two_column_left_sidebar','',$body);\r
}\r
\r
* @link http://elgg.org/\r
*/\r
- $version = 2009052801; // YYYYMMDD = Elgg Date
+ $version = 2009060501; // YYYYMMDD = Elgg Date
// XX = Interim incrementer\r
\r
$release = '1.5'; // Human-friendly version name\r