),but it´s working
).Features:
1) You can use any normal language (normal = not chinese and other symbol languages).
2) Tags will be displayed with any characters correctly and searching with tags will give you results
Requirements:
-As usually, Notepad++,PHP Designer or PHPed...whatever good for editing php files
Steps to do:
3a) We need add a new column in your tags table. Column with name "tags_safe". So open your MyAdmin and run following sql:
Code:
alter table your_domain_tags add column tag_safe varchar(30)
Code:
function tags_insert_string($link, $lang, $string, $date = 0) {
global $db;
$string = tags_normalize_string($string);
if ($date == 0) $date=time();
$words = preg_split('/[,;]+/', $string);
if ($words) {
$db->query("delete from " . table_tags . " where tag_link_id = $link");
foreach ($words as $word) {
$word=trim($word);
//************************************************************
//SAFE words
$replace_what = array("á","ě","š","č","ř","ž","ý","á","í","é","ň","ť","ď","ó");
$replace_with = array("a","e","s","c","r","z","y","a","i","e","n","t","d","o");
$word_safe= str_ireplace($replace_what,$replace_with,$word);
//*******************************************************
if (!$inserted[$word] && !empty($word)) {
$db->query("insert into " . table_tags . " (tag_link_id, tag_lang, tag_words, tag_safe,tag_date) values ($link, '$lang', '$word','$word_safe', from_unixtime($date))");
$inserted[$word] = true;
}
}
return true;
}
return false;
}
3c) Open search.php in your libs folder. Watch this code and carefully edit first part of get_search_clause function like this:
Code:
function get_search_clause($option='') {
if(!empty($this->searchTerm)) {
// make sure there is a search term
//change to search
$words = $this->searchTerm;
$SearchMethod = SearchMethod; // create a temp variable so we can change the value without possibly affecting anything else
if($this->isTag == true){
// search the tags table
$this->searchTable = table_tags . " INNER JOIN " . table_links . " ON " . table_tags . ".tag_link_id = " . table_links . ".link_id";
// thanks to jalso for this code
$x = explode(",",$words);
$sq .= "(";
foreach($x as $k=>$v){
//****************************************************************
$replace_what = array("ú","ó","é","ý","š","á","í","á","ě","š","č","ř","ž","ý","á","í","é","ň","ť","ď","ó");
$replace_with = array("u","o","e","y","s","a","i","a","e","s","c","r","z","y","a","i","e","n","t","d","o");
$word_safe= str_ireplace($replace_what,$replace_with,trim($x[$k]));
$sq .= "tag_safe = '".$word_safe."'";
//*************************************************************************************
if($k != (count($x) - 1))$sq .= " OR ";
}
$sq .= ")";
$where .= " AND ".$sq." GROUP BY " . table_links . ".link_id, `link_votes` ORDER BY `link_votes` DESC";
// ---
3d). This could be end, but this works for your NEW tags. And if you have (i assume you have many tags, you could spend a little time to editing link in your pligg site or in database. There are 2 choices what is your situation:
- you have language incorrect tags but with non-accent characters - you have to edit all of them manually, there is no way how to automatize it
- you have language correct tags with no results, there is a way how to do it faster, i made this script (but i neednt it myself), so customize it to your own needs:
PHP Code:
<?php
global $db; $main_smarty;
$tagCount = $db->get_var("SELECT count(tag_link_id) FROM ".$table_tags);
for ($i=1; $i <= $tagCount; $i++) {
$tag_name = $db->get_var("SELECT tag_words FROM ".$table_tags ." WHERE tag_link_id=".$i);
$replace_what = array("á","ě","š","č","ř","ž","ý","á","í","é","ň","ť","ď","ó");
$replace_with = array("a","e","s","c","r","z","y","a","i","e","n","t","d","o");
$word_safe= str_ireplace($replace_what,$replace_with,$tag_name);
$db->query("UPDATE your_domain_tags SET tag_safe=" .$word_safe ." WHERE tag_link_id=".$i);
}
?>






Linear Mode

