Tag Category integration
This commit is contained in:
parent
e133138be2
commit
03e78bd19f
2 changed files with 33 additions and 15 deletions
|
@ -71,6 +71,14 @@ class TagEditCloud extends Extension {
|
||||||
|
|
||||||
$ignore_tags = explode(' ',$config->get_string("tageditcloud_ignoretags"));
|
$ignore_tags = explode(' ',$config->get_string("tageditcloud_ignoretags"));
|
||||||
|
|
||||||
|
if(class_exists("TagCategories")){
|
||||||
|
$categories = $database->get_all("SELECT category, color FROM image_tag_categories");
|
||||||
|
$cat_color = array();
|
||||||
|
foreach($categories as $row){
|
||||||
|
$cat_color[$row['category']] = $row['color'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch($sort_method){
|
switch($sort_method){
|
||||||
case 'a':
|
case 'a':
|
||||||
case 'p':
|
case 'p':
|
||||||
|
@ -93,19 +101,34 @@ class TagEditCloud extends Extension {
|
||||||
$cloud .= "<div id='tagcloud_extra' style='display: none;'>\n";
|
$cloud .= "<div id='tagcloud_extra' style='display: none;'>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$h_tag = html_escape($row['tag']);
|
if(class_exists("TagCategories")){
|
||||||
|
$full_tag = $row['tag'];
|
||||||
|
$tc = explode(':',$full_tag);
|
||||||
|
if(isset($tc[1]) && isset($cat_color[$tc[0]])){
|
||||||
|
$h_tag = html_escape($tc[1]);
|
||||||
|
$color = '; color:'.$cat_color[$tc[0]];
|
||||||
|
} else {
|
||||||
|
$h_tag = html_escape($full_tag);
|
||||||
|
$color = '';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$full_tag = $row['tag'];
|
||||||
|
$h_tag = html_escape($full_tag);
|
||||||
|
$color = '';
|
||||||
|
}
|
||||||
|
|
||||||
$size = sprintf("%.2f", max($row['scaled'],0.5));
|
$size = sprintf("%.2f", max($row['scaled'],0.5));
|
||||||
|
|
||||||
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 .= " <span onclick='tageditcloud_toggle_tag(this)' class='tag-selected' style='font-size: ${size}em' title='${row['count']}'>$h_tag</span> \n";
|
$precloud .= " <span onclick='tageditcloud_toggle_tag(this,\"$full_tag\")' class='tag-selected' style='font-size: ${size}em$color' title='${row['count']}'>$h_tag</span> \n";
|
||||||
} else {
|
} else {
|
||||||
$counter++;
|
$counter++;
|
||||||
$cloud .= " <span onclick='tageditcloud_toggle_tag(this)' class='tag-selected' style='font-size: ${size}em' title='${row['count']}'>$h_tag</span> \n";
|
$cloud .= " <span onclick='tageditcloud_toggle_tag(this,\"$full_tag\")' class='tag-selected' style='font-size: ${size}em$color' title='${row['count']}'>$h_tag</span> \n";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$counter++;
|
$counter++;
|
||||||
$cloud .= " <span onclick='tageditcloud_toggle_tag(this)' style='font-size: ${size}em' title='${row['count']}'>$h_tag</span> \n";
|
$cloud .= " <span onclick='tageditcloud_toggle_tag(this,\"$full_tag\")' style='font-size: ${size}em$color' title='${row['count']}'>$h_tag</span> \n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,23 +29,18 @@ function tageditcloud_toggle_extra(hide) {
|
||||||
hide.innerHTML = (el.style.display != 'none' ? 'show fewer tags' : hide_text );
|
hide.innerHTML = (el.style.display != 'none' ? 'show fewer tags' : hide_text );
|
||||||
}
|
}
|
||||||
|
|
||||||
function tageditcloud_toggle_tag(ele) {
|
function tageditcloud_toggle_tag(ele,fullTag) {
|
||||||
var thisTag = ele.innerHTML;
|
|
||||||
var taglist = document.getElementById('tag_editor');
|
var taglist = document.getElementById('tag_editor');
|
||||||
var tags = taglist.value.split(' ');
|
var tags = taglist.value.split(' ');
|
||||||
|
|
||||||
// If tag is already listed, remove it
|
if (tags.editcloud_contains(fullTag)) {
|
||||||
if (tags.editcloud_contains(thisTag)) {
|
tags = tags.editcloud_remove(fullTag);
|
||||||
tags = tags.editcloud_remove(thisTag);
|
|
||||||
ele.className = 'tag-unselected';
|
ele.className = 'tag-unselected';
|
||||||
|
|
||||||
// Otherwise add it
|
|
||||||
} else {
|
} else {
|
||||||
tags.splice(0, 0, thisTag);
|
tags.splice(0, 0, fullTag);
|
||||||
ele.className = 'tag-selected';
|
ele.className = 'tag-selected';
|
||||||
}
|
}
|
||||||
|
|
||||||
taglist.value = tags.join(' ');
|
taglist.value = tags.join(' ');
|
||||||
|
|
||||||
document.getElementById('tags').focus();
|
document.getElementById('tags').focus();
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue