merge of AD's updates (now with real git-merge, rather than patching by hand; apologies if the hand-patches broke anything)

This commit is contained in:
Shish 2010-12-23 01:10:07 +00:00
commit d8c88d373f

View file

@ -20,17 +20,46 @@ class TagEditCloud implements Extension {
//if(is_null($this->theme)) $this->theme = get_theme_object($this); //if(is_null($this->theme)) $this->theme = get_theme_object($this);
if($event instanceof ImageInfoBoxBuildingEvent) { if($event instanceof ImageInfoBoxBuildingEvent) {
if($this->can_tag($event->image)) { if(!$config->get_bool("tageditcloud_disable")) {
$cfgstub_sortbyname=false; // FIXME if($this->can_tag($event->image)) {
$cfgstub_showtop=40; // Derp if(!$cfg_minusage=$config->get_int("tageditcloud_minusage")) $cfg_minusage=2;
$cfgstub_minuse=2; // Derp if(!$cfg_defcount=$config->get_int("tageditcloud_defcount")) $cfg_defcount=40;
if($cfgstub_sortbyname) { if(!$cfg_maxcount=$config->get_int("tageditcloud_maxcount")) $cfg_maxcount=4096;
$event->add_part($this->build_tag_map($event->image,$cfgstub_minuse,false),40); if($config->get_string("tageditcloud_sort") != "p") {
} else { $event->add_part($this->build_tag_map($event->image,$cfg_minusage,false),40);
$event->add_part($this->build_tag_map($event->image,$cfgstub_showtop,4096),40); } else {
$event->add_part($this->build_tag_map($event->image,$cfg_defcount,$cfg_maxcount),40);
}
} }
} }
} }
if($event instanceof InitExtEvent) {
$config->set_default_bool("tageditcloud_disable",false);
$config->set_default_bool("tageditcloud_usedfirst",true);
$config->set_default_string("tageditcloud_sort",'a');
$config->set_default_int("tageditcloud_minusage",2);
$config->set_default_int("tageditcloud_defcount",40);
$config->set_default_int("tageditcloud_maxcount",4096);
}
if($event instanceof SetupBuildingEvent) {
$sort_by = array('Alphabetical'=>'a','Popularity'=>'p');
$sb = new SetupBlock("Tag Edit Cloud");
$sb->add_bool_option("tageditcloud_disable", "Disable Tag Selection Cloud: ");
$sb->add_choice_option("tageditcloud_sort", $sort_by, "<br>Sort the tags by:");
$sb->add_bool_option("tageditcloud_usedfirst","<br>Always show used tags first: ");
$sb->add_label("<br><b>Alpha sort</b>:<br>Only show tags used at least ");
$sb->add_int_option("tageditcloud_minusage");
$sb->add_label(" times.<br><b>Popularity sort</b>:<br>Show ");
$sb->add_int_option("tageditcloud_defcount");
$sb->add_label(" tags by default.<br>Show a maximum of ");
$sb->add_int_option("tageditcloud_maxcount");
$sb->add_label(" tags.");
$event->panel->add_block($sb);
}
} }
private function tag_link($tag) { private function tag_link($tag) {
@ -42,12 +71,13 @@ class TagEditCloud implements Extension {
// build_tag_map($image|false, $minusage|false) -- taglist sorted by alpha, only showing tags with usage >= $minusage // build_tag_map($image|false, $minusage|false) -- taglist sorted by alpha, only showing tags with usage >= $minusage
private function build_tag_map($image,$defcount,$maxcount) { // private function build_tag_map($image,$defcount,$maxcount) { //
global $database,$config;
global $database;
$html="";$cloud="";$precloud=""; $html="";$cloud="";$precloud="";
$itags=Array(); $itags=Array();
$tags_min=1; $tags_min=1;
$alphasort=false; $alphasort=false;
$usedfirst=$config->get_bool("tageditcloud_usedfirst");
if(!is_int($defcount)) $defcount=20; if(!is_int($defcount)) $defcount=20;
if(!is_int($maxcount)) { // Derp this is pretty cheesy. if(!is_int($maxcount)) { // Derp this is pretty cheesy.
$maxcount=4096; // Hurrrr $maxcount=4096; // Hurrrr
@ -75,9 +105,14 @@ class TagEditCloud implements Extension {
$usecount=$row['count']; $usecount=$row['count'];
$link = $this->tag_link($row['tag']); $link = $this->tag_link($row['tag']);
if($size<0.5) $size = 0.5; if($size<0.5) $size = 0.5;
if(isset($itags[$row['tag']])) { if(isset($itags[$row['tag']])) {
// if($size<0.75) $size = 0.75; if($usedfirst) {
$precloud .= "&nbsp;<span onclick=\"tageditcloud_toggle_tag(this)\" class=\"tag-selected\" style='font-size: ${size}em' title='$usecount'>$h_tag</span>&nbsp;\n"; $precloud .= "&nbsp;<span onclick=\"tageditcloud_toggle_tag(this)\" class=\"tag-selected\" style='font-size: ${size}em' title='$usecount'>$h_tag</span>&nbsp;\n";
} else {
$counter++;
$cloud .= "&nbsp;<span onclick=\"tageditcloud_toggle_tag(this)\" class=\"tag-selected\" style='font-size: ${size}em' title='$usecount'>$h_tag</span>&nbsp;\n";
}
} else { } else {
$counter++; $counter++;
$cloud .= "&nbsp;<span onclick=\"tageditcloud_toggle_tag(this)\" style='font-size: ${size}em' title='$usecount'>$h_tag</span>&nbsp;\n"; $cloud .= "&nbsp;<span onclick=\"tageditcloud_toggle_tag(this)\" style='font-size: ${size}em' title='$usecount'>$h_tag</span>&nbsp;\n";
@ -86,8 +121,6 @@ class TagEditCloud implements Extension {
if ($precloud != '') $html .= "<div id=\"tagcloud_set\">$precloud</div>"; if ($precloud != '') $html .= "<div id=\"tagcloud_set\">$precloud</div>";
$html .="<div id=\"tagcloud_unset\">$cloud</div>"; $html .="<div id=\"tagcloud_unset\">$cloud</div>";
$rem=count($tag_data)-$defcount; $rem=count($tag_data)-$defcount;
// $script = "";
// $html.=$script;
if((!$alphasort)&&($counter>=$defcount)) $html .= "</div><br>[<span onclick=\"tageditcloud_toggle_extra('tagcloud_extra',this);\" style=\"color: #0000EF; font-weight:bold;\">show $rem more tags</span>]"; if((!$alphasort)&&($counter>=$defcount)) $html .= "</div><br>[<span onclick=\"tageditcloud_toggle_extra('tagcloud_extra',this);\" style=\"color: #0000EF; font-weight:bold;\">show $rem more tags</span>]";
// $html.='<pre>'.var_export($itags,true).'</pre>'; // $html.='<pre>'.var_export($itags,true).'</pre>';
return "<div id=\"tageditcloud\" class=\"tageditcloud\">$html</div>"; // FIXME: stupidasallhell return "<div id=\"tageditcloud\" class=\"tageditcloud\">$html</div>"; // FIXME: stupidasallhell