Fixed tags with quotes killing the Javascript

Of course not.
This commit is contained in:
Justin Brewer 2013-09-26 10:47:37 -05:00
parent 7be1f9e637
commit 8c5987a6b2

View File

@ -93,33 +93,34 @@ class TagEditCloud extends Extension {
$counter = 1; $counter = 1;
foreach($tag_data as $row) { foreach($tag_data as $row) {
if(class_exists("TagCategories")){
$full_tag = $row['tag']; $full_tag = $row['tag'];
$tc = explode(':',$full_tag);
if(class_exists("TagCategories")){
$tc = explode(':',$row['tag']);
if(isset($tc[1]) && isset($cat_color[$tc[0]])){ if(isset($tc[1]) && isset($cat_color[$tc[0]])){
$h_tag = html_escape($tc[1]); $h_tag = html_escape($tc[1]);
$color = '; color:'.$cat_color[$tc[0]]; $color = '; color:'.$cat_color[$tc[0]];
} else { } else {
$h_tag = html_escape($full_tag); $h_tag = html_escape($row['tag']);
$color = ''; $color = '';
} }
} else { } else {
$full_tag = $row['tag']; $h_tag = html_escape($row['tag']);
$h_tag = html_escape($full_tag);
$color = ''; $color = '';
} }
$size = sprintf("%.2f", max($row['scaled'],0.5)); $size = sprintf("%.2f", max($row['scaled'],0.5));
$js = htmlspecialchars('tageditcloud_toggle_tag(this,'.json_encode($full_tag).')',ENT_QUOTES); //Ugly, but it works
if(array_search($row['tag'],$image->tag_array) !== FALSE) { if(array_search($row['tag'],$image->tag_array) !== FALSE) {
if($used_first) { if($used_first) {
$precloud .= "&nbsp;<span onclick='tageditcloud_toggle_tag(this,\"$full_tag\")' class='tag-selected' style='font-size: ${size}em$color' title='${row['count']}'>$h_tag</span>&nbsp;\n"; $precloud .= "&nbsp;<span onclick='$js' class='tag-selected' style='font-size: ${size}em$color' title='${row['count']}'>$h_tag</span>&nbsp;\n";
continue; continue;
} else { } else {
$entry = "&nbsp;<span onclick='tageditcloud_toggle_tag(this,\"$full_tag\")' class='tag-selected' style='font-size: ${size}em$color' title='${row['count']}'>$h_tag</span>&nbsp;\n"; $entry = "&nbsp;<span onclick='$js' class='tag-selected' style='font-size: ${size}em$color' title='${row['count']}'>$h_tag</span>&nbsp;\n";
} }
} else { } else {
$entry = "&nbsp;<span onclick='tageditcloud_toggle_tag(this,\"$full_tag\")' style='font-size: ${size}em$color' title='${row['count']}'>$h_tag</span>&nbsp;\n"; $entry = "&nbsp;<span onclick='$js' style='font-size: ${size}em$color' title='${row['count']}'>$h_tag</span>&nbsp;\n";
} }
if($counter++ <= $def_count) { if($counter++ <= $def_count) {