2007-09-25 21:28:09 +00:00
|
|
|
<?php
|
2007-09-28 05:10:44 +00:00
|
|
|
// Tagger - Advanced Tagging
|
|
|
|
// Author: Artanis (Erik Youngren <artanis.00@gmail.com>)
|
|
|
|
// Do not remove this notice.
|
|
|
|
|
2007-09-25 21:28:09 +00:00
|
|
|
class tagger extends Extension {
|
|
|
|
var $theme;
|
|
|
|
|
|
|
|
public function receive_event ($event) {
|
|
|
|
if(is_null($this->theme))
|
|
|
|
$this->theme = get_theme_object("tagger", "taggerTheme");
|
2007-09-28 05:10:44 +00:00
|
|
|
|
|
|
|
if(is_a($event,"InitExtEvent")) {
|
|
|
|
global $config;
|
|
|
|
if ($config->get_int("ext-tagger_tags-min") == -1)
|
|
|
|
$config->set_int("ext-tagger_tags-min",2);
|
|
|
|
|
|
|
|
if ($config->get_string("ext-tagger_clear-tagme") == -1)
|
|
|
|
$config->set_bool("ext-tagger_clear-tagme",false);
|
|
|
|
|
|
|
|
if ($config->get_string("ext-tagger_show-hidden") == -1)
|
|
|
|
$config->set_bool("ext-tagger_show-hidden",false);
|
|
|
|
}
|
2007-09-26 07:23:16 +00:00
|
|
|
|
2007-09-25 21:28:09 +00:00
|
|
|
if(is_a($event,"DisplayingImageEvent")) {
|
|
|
|
//show tagger box
|
|
|
|
global $database;
|
|
|
|
global $page;
|
2007-09-26 07:23:16 +00:00
|
|
|
global $config;
|
|
|
|
|
|
|
|
$base_href = $config->get_string('base_href');
|
2007-10-01 19:36:28 +00:00
|
|
|
$tags_min = (isset($_GET['tagger_min']) && $_GET['tagger_min']>0)?$_GET['tagger_min']:$config->get_int('ext-tagger_tags-min',2);
|
2007-09-30 08:53:47 +00:00
|
|
|
$hidden = $config->get_string(
|
|
|
|
'ext-tagger_show-hidden','N')=='N' ?
|
|
|
|
" AND substring(tag,1,1) != '.' " : null;
|
|
|
|
|
2007-09-25 21:28:09 +00:00
|
|
|
$tags = $database->Execute("
|
|
|
|
SELECT tag
|
|
|
|
FROM `tags`
|
2007-09-30 08:53:47 +00:00
|
|
|
WHERE count>=?{$hidden}
|
2007-09-28 05:10:44 +00:00
|
|
|
ORDER BY tag",array($tags_min));
|
2007-09-25 21:28:09 +00:00
|
|
|
|
2007-09-26 07:23:16 +00:00
|
|
|
$this->theme->build($page, $tags);
|
2007-10-02 22:27:09 +00:00
|
|
|
global $user;
|
|
|
|
if($tags->_numOfRows > 100 && $user->is_admin()) {
|
|
|
|
$page->add_block( new Block (
|
|
|
|
"Warning - ext/tagger",
|
|
|
|
"<h4>It is likely that Tagger will not function</h4>
|
|
|
|
Currently the javascript code chokes on large numbers of
|
|
|
|
tags. The tag list currently numbers
|
|
|
|
<b>{$tags->_numOfRows}</b>.<br/>
|
|
|
|
You can increase the minimum use requirement for the tag
|
|
|
|
list in the <a href='".make_link('setup')."'>Board Config</a>
|
|
|
|
to reduce the size of this list.<br/>
|
|
|
|
This is a limitation of the method in which Tagger operates.
|
|
|
|
I am working on a solution, I do not know when such a
|
|
|
|
solution will be ready.",
|
|
|
|
"main",0));
|
|
|
|
}
|
2007-09-26 07:23:16 +00:00
|
|
|
}
|
|
|
|
|
2007-10-02 18:44:29 +00:00
|
|
|
if(is_a($event,"PageRequestEvent")) {
|
|
|
|
if($event->page_name == "about" && $event->get_arg(0) == "tagger") {
|
|
|
|
global $page;
|
|
|
|
$this->theme->show_about($page);
|
|
|
|
}
|
|
|
|
if($event->page_name == "tagger") {
|
|
|
|
global $page;
|
|
|
|
// $this->theme->configTagger($page);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(is_a($event, 'UserBlockBuildingEvent')) {
|
|
|
|
if($event->user->is_admin()) {
|
|
|
|
// $event->add_link("Tagger Config", make_link("tagger"));
|
|
|
|
}
|
2007-09-25 21:28:09 +00:00
|
|
|
}
|
2007-09-28 05:10:44 +00:00
|
|
|
|
|
|
|
if(is_a($event, 'SetupBuildingEvent')) {
|
|
|
|
$sb = new SetupBlock("Tagger - Power Tagging");
|
|
|
|
$sb->add_bool_option("ext-tagger_show-hidden", "Show Hidden Tags");
|
2007-09-28 21:26:59 +00:00
|
|
|
$sb->add_bool_option(
|
|
|
|
"ext-tagger_clear-tagme",
|
|
|
|
"<br/>Remove '<a href='".make_link("post/list/tagme/1")."'>tagme</a>' on use");
|
|
|
|
$sb->add_int_option(
|
|
|
|
"ext-tagger_tags-min",
|
|
|
|
"<br/>Ignore tags used fewer than "); $sb->add_label("times.");
|
2007-09-28 05:10:44 +00:00
|
|
|
$event->panel->add_block($sb);
|
|
|
|
}
|
2007-09-25 21:28:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
add_event_listener( new tagger());
|
2007-09-25 10:16:26 +00:00
|
|
|
?>
|