From 275e0b3b64cd64b389919e62cf66474ee06a0373 Mon Sep 17 00:00:00 2001 From: Shish Date: Sun, 25 Jan 2009 11:49:42 +0000 Subject: [PATCH] remove in-development extensions --- contrib/autocomplete/main.php | 31 ---- contrib/autocomplete/script.js | 98 ------------- contrib/bookmarks/main.php | 69 --------- contrib/bookmarks/theme.php | 5 - contrib/event_log/main.php | 121 ---------------- contrib/event_log/theme.php | 83 ----------- contrib/notes/main.php | 53 ------- contrib/notes/theme.php | 13 -- contrib/svn_update/main.php | 84 ----------- contrib/svn_update/theme.php | 52 ------- contrib/tagger/images/active.png | Bin 183 -> 0 bytes contrib/tagger/images/add-tag.png | Bin 227 -> 0 bytes contrib/tagger/images/inactive.png | Bin 170 -> 0 bytes contrib/tagger/images/rem-tag.png | Bin 198 -> 0 bytes contrib/tagger/images/tag-img.psd | Bin 2148 -> 0 bytes contrib/tagger/main.php | 174 ----------------------- contrib/tagger/script.js | 218 ----------------------------- contrib/tagger/style.css | 104 -------------- contrib/tagger/theme.php | 65 --------- contrib/tagger/webtoolkit.drag.js | 85 ----------- contrib/text_score/main.php | 109 --------------- contrib/text_score/theme.php | 33 ----- 22 files changed, 1397 deletions(-) delete mode 100644 contrib/autocomplete/main.php delete mode 100644 contrib/autocomplete/script.js delete mode 100644 contrib/bookmarks/main.php delete mode 100644 contrib/bookmarks/theme.php delete mode 100644 contrib/event_log/main.php delete mode 100644 contrib/event_log/theme.php delete mode 100644 contrib/notes/main.php delete mode 100644 contrib/notes/theme.php delete mode 100644 contrib/svn_update/main.php delete mode 100644 contrib/svn_update/theme.php delete mode 100644 contrib/tagger/images/active.png delete mode 100644 contrib/tagger/images/add-tag.png delete mode 100644 contrib/tagger/images/inactive.png delete mode 100644 contrib/tagger/images/rem-tag.png delete mode 100644 contrib/tagger/images/tag-img.psd delete mode 100644 contrib/tagger/main.php delete mode 100644 contrib/tagger/script.js delete mode 100644 contrib/tagger/style.css delete mode 100644 contrib/tagger/theme.php delete mode 100644 contrib/tagger/webtoolkit.drag.js delete mode 100644 contrib/text_score/main.php delete mode 100644 contrib/text_score/theme.php diff --git a/contrib/autocomplete/main.php b/contrib/autocomplete/main.php deleted file mode 100644 index cee08e4e..00000000 --- a/contrib/autocomplete/main.php +++ /dev/null @@ -1,31 +0,0 @@ - - * License: GPLv2 - * Description: Auto-complete for search and upload tags - * Documentation: - * Just enable and things should start autocompleting as if - * by magic. That is, if this extension actually worked... - */ - -class AutoComplete implements Extension { - public function receive_event(Event $event) { - if(($event instanceof PageRequestEvent) && ($event->page_matches("index") || $event->page_matches("view"))) { - $event->page->add_header(""); - } - if(($event instanceof PageRequestEvent) && $event->page_matches("autocomplete")) { - $event->page->set_mode("data"); - $event->page->set_type("text/plain"); - $event->page->set_data($this->get_completions($event->get_arg(0))); - } - } - - private function get_completions($start) { - global $database; - $tags = $database->db->GetCol("SELECT tag,count FROM tags WHERE tag LIKE ? ORDER BY count DESC", array($start.'%')); - return implode("\n", $tags); - } -} -add_event_listener(new AutoComplete()); -?> diff --git a/contrib/autocomplete/script.js b/contrib/autocomplete/script.js deleted file mode 100644 index 081d8b47..00000000 --- a/contrib/autocomplete/script.js +++ /dev/null @@ -1,98 +0,0 @@ - -// addEvent(window, "load", function() { -// initAjax("searchBox", "search_completions"); -// initAjax("tagBox", "upload_completions"); -// }); - -function endWord(sentance) { - words = sentance.split(" "); - return words[words.length-1]; -} - -var resultCache = new Array(); -resultCache[""] = new Array(); - -function complete(boxname, text) { - box = byId(boxname); - words = box.value.split(" "); - box.value = ""; - for(n=0; n"+results[i]+""; - } -} - -function initAjax(boxname, areaname) { - var box = byId(boxname); - if(!box) return; - - addEvent( - box, - "keyup", - function f() { - starter = endWord(box.value); - - if(resultCache[starter]) { - fillCompletionZone(boxname, areaname, resultCache[starter]); - } - else { - ajaxRequest( - "ajax.php?start="+starter, - function g(text) { - resultCache[starter] = text.split("\n"); - fillCompletionZone(boxname, areaname, resultCache[starter]); - } - ); - } - }, - false - ); -} - - -//completion_cache = new array(); - -input = byId("search_input"); -output = byId("search_completions"); - -function get_cached_completions(start) { -// if(completion_cache[start]) { -// return completion_cache[start]; -// } -// else { - return null; -// } -} -function get_completions(start) { - cached = get_cached_completions(start); - if(cached) { - output.innerHTML = cached; - } - else { - ajaxRequest(autocomplete_url+"/"+start, function(data) {set_completions(start, data);}); - } -} -function set_completions(start, data) { -// completion_cache[start] = data; - output.innerHTML = data; -} - -if(input) { - input.onkeyup = function() { - if(input.value.length < 3) { - output.innerHTML = ""; - } - else { - get_completions(input.value); - } - }; -} diff --git a/contrib/bookmarks/main.php b/contrib/bookmarks/main.php deleted file mode 100644 index 916fa996..00000000 --- a/contrib/bookmarks/main.php +++ /dev/null @@ -1,69 +0,0 @@ - - * License: GPLv2 - * Description: Allow users to bookmark searches - */ - -class Bookmarks implements Extension { - var $theme; - - public function receive_event(Event $event) { - if(is_null($this->theme)) $this->theme = get_theme_object($this); - - if(($event instanceof PageRequestEvent) && $event->page_matches("bookmark")) { - $user = $event->context->user; - - if($event->get_arg(0) == "add") { - if(isset($_POST['url'])) { - $event->page->set_mode("redirect"); - $event->page->set_redirect(make_link("user")); - } - } - else if($event->get_arg(0) == "remove") { - if(isset($_POST['id'])) { - $event->page->set_mode("redirect"); - $event->page->set_redirect(make_link("user")); - } - } - } - } - - protected function install() { - global $database; - global $config; - - // shortcut to latest - if($config->get_int("ext_bookmarks_version") < 1) { - $database->create_table("bookmark", " - id SCORE_AIPK, - owner_id INTEGER NOT NULL, - url TEXT NOT NULL, - title TET NOT NULL, - INDEX (owner_id), - FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE CASCADE - "); - $config->set_int("ext_bookmarks_version", 1); - } - } - - private function get_bookmarks() { - global $database; - $bms = $database->get_all(" - SELECT * - FROM bookmark - WHERE bookmark.owner_id = ? - "); - if($bms) {return $bms;} - else {return array();} - } - - private function add_bookmark($url, $title) { - global $database; - $sql = "INSERT INTO bookmark(owner_id, url, title) VALUES (?, ?, ?)"; - $database->Execute($sql, array($user->id, $url, $title)); - } -} -add_event_listener(new Bookmarks()); -?> diff --git a/contrib/bookmarks/theme.php b/contrib/bookmarks/theme.php deleted file mode 100644 index 83c43b42..00000000 --- a/contrib/bookmarks/theme.php +++ /dev/null @@ -1,5 +0,0 @@ - diff --git a/contrib/event_log/main.php b/contrib/event_log/main.php deleted file mode 100644 index 0f9e244d..00000000 --- a/contrib/event_log/main.php +++ /dev/null @@ -1,121 +0,0 @@ - - * License: GPLv2 - * Description: A log of things that happen, for abuse tracking - */ - -class EventLog implements Extension { - var $theme; - - public function receive_event(Event $event) { - if(is_null($this->theme)) $this->theme = get_theme_object($this); - - if($event instanceof InitExtEvent) { - $this->setup(); - } - - if(($event instanceof PageRequestEvent) && $event->page_matches("event_log")) { - global $database; - if($event->user->is_admin()) { - if(isset($_POST['action'])) { - switch($_POST['action']) { - case 'clear': - $database->execute("DELETE FROM event_log"); - break; - } - } - - $columns = array("name", "date", "owner_ip", "event"); - $orders = array("ASC", "DESC"); - - $sort = "date"; - if(isset($_GET['sort']) && in_array($_GET['sort'], $columns)) { - $sort = $_GET['sort']; - } - - $order = "DESC"; - if(isset($_GET['order']) && in_array($_GET['order'], $orders)) { - $order = $_GET['order']; - } - - $filter_sql = ""; - if(isset($_GET['filter']) && isset($_GET['where']) && in_array($_GET['filter'], $columns)) { - $filter = $_GET['filter']; - $where = $database->db->Quote($_GET['where']); - $filter_sql = "WHERE $filter = $where"; - } - - $events = $database->get_all(" - SELECT event_log.*,users.name FROM event_log - JOIN users ON event_log.owner_id = users.id - $filter_sql - ORDER BY $sort $order - "); - $this->theme->display_page($event->page, $events); - } - else { - $this->theme->display_permission_denied($event->page); - } - } - if($event instanceof UserBlockBuildingEvent) { - if($event->user->is_admin()) { - $event->add_link("Event Log", make_link("event_log")); - } - } - - global $user; // bad - if($event instanceof UploadingImageEvent) { - $this->add_to_log($event->user, 'Uploading Image', "Uploaded a new image"); - } - if($event instanceof CommentPostingEvent) { - $this->add_to_log($event->user, 'Comment Posting', "Posted a comment on image #{$event->image_id}"); - } - if($event instanceof WikiUpdateEvent) { - $this->add_to_log($event->user, 'Wiki Update', "Edited '{$event->wikipage->title}'"); - } - if($event instanceof ConfigSaveEvent) { - $this->add_to_log($user, 'Config Save', "Updated the board config"); - } - if($event instanceof ImageDeletionEvent) { - $this->add_to_log($user, 'Image Deletion', "Deleted image {$event->image->id} (tags: {$event->image->get_tag_list()})"); - } - if($event instanceof SourceSetEvent) { - $this->add_to_log($user, 'Source Set', "Source for image #{$event->image->id} set to '{$event->source}'"); - } - if($event instanceof TagSetEvent) { - $tags = implode($event->tags, ", "); - $this->add_to_log($user, 'Tags Set', "Tags for image #{$event->image->id} set to '$tags'"); - } - } - - private function add_to_log($user, $event, $entry) { - global $database; - - $database->execute(" - INSERT INTO event_log (owner_id, owner_ip, date, event, entry) - VALUES (?, ?, now(), ?, ?)", - array($user->id, $_SERVER['REMOTE_ADDR'], $event, $entry)); - } - - private function setup() { - global $database; - global $config; - - if($config->get_int("ext_event_log_version", 0) < 1) { - $database->create_table("event_log", " - id SCORE_AIPK, - owner_id INTEGER NOT NULL, - owner_ip SCORE_INET NOT NULL, - date DATETIME NOT NULL, - event VARCHAR(32) NOT NULL, - entry TEXT NOT NULL, - FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE CASCADE - "); - $config->set_int("ext_event_log_version", 1); - } - } -} -add_event_listener(new EventLog(), 99); // ignore vetoed events -?> diff --git a/contrib/event_log/theme.php b/contrib/event_log/theme.php deleted file mode 100644 index df94446b..00000000 --- a/contrib/event_log/theme.php +++ /dev/null @@ -1,83 +0,0 @@ -set_title("Event Log"); - $page->set_heading("Event Log"); - $page->add_block(new NavBlock()); - - $this->display_table($page, $events); - $this->display_controls($page); - } - - protected function display_table(Page $page, $events) { - $table = " - - - - - - - - - - - - "; - foreach($events as $event) { - $entry = html_escape($event['entry']); - $table .= " - - - - - - - - - - "; - } - $table .= "
User - + - - - IP - + - - - Entry
Date - + - - - Event - + - - -
- {$event['name']} - - {$event['owner_ip']} - {$entry}
- {$event['date']} - - {$event['event']} -
"; - $page->add_block(new Block("Log Contents", $table)); - } - - protected function display_controls(Page $page) { - $html = " -
- - -
- "; - $page->add_block(new Block(null, $html, "main", 60)); - } -} -?> diff --git a/contrib/notes/main.php b/contrib/notes/main.php deleted file mode 100644 index 9098699f..00000000 --- a/contrib/notes/main.php +++ /dev/null @@ -1,53 +0,0 @@ - - * License: GPLv2 - * Description: Adds notes overlaid on the images - * Documentation: - * This is quite broken :( - */ - -class Notes implements Extension { - var $theme; - - public function receive_event(Event $event) { - if(is_null($this->theme)) $this->theme = get_theme_object($this); - - if($event instanceof InitExtEvent) { - global $config; - if($config->get_int("ext_notes_version") < 1) { - $this->install(); - } - } - - if($event instanceof DisplayingImageEvent) { - global $database; - $notes = $database->get_all("SELECT * FROM image_notes WHERE image_id = ?", array($event->image->id)); - $this->theme->display_notes($event->page, $notes); - } - } - - protected function install() { - global $database; - global $config; - $database->create_table("image_notes", " - id SCORE_AIPK, - image_id INTEGER NOT NULL, - user_id INTEGER NOT NULL, - owner_ip SCORE_INET NOT NULL, - created_at DATETIME NOT NULL, - updated_at DATETIME NOT NULL, - version INTEGER DEFAULT 1 NOT NULL, - is_active SCORE_BOOL DEFAULT SCORE_BOOL_Y NOT NULL, - x INTEGER NOT NULL, - y INTEGER NOT NULL, - w INTEGER NOT NULL, - h INTEGER NOT NULL, - body TEXT NOT NULL - "); - $config->set_int("ext_notes_version", 1); - } -} -add_event_listener(new Notes()); -?> diff --git a/contrib/notes/theme.php b/contrib/notes/theme.php deleted file mode 100644 index 178b9fb9..00000000 --- a/contrib/notes/theme.php +++ /dev/null @@ -1,13 +0,0 @@ - -img = byId("main_image"); - -EOD; - $page->add_block(new Block(null, $html)); - } -} -?> diff --git a/contrib/svn_update/main.php b/contrib/svn_update/main.php deleted file mode 100644 index f4d02b51..00000000 --- a/contrib/svn_update/main.php +++ /dev/null @@ -1,84 +0,0 @@ - - * License: GPLv2 - * Description: Provides a button to check for updates - * Documentation: - * This is a very risky idea, implemented without safeguards. - * If you've done a clean SVN checkout, then updating will - * normally work fine; but if you've made changes in one way, - * and SVN has changed something in a different way, then there - * will be conflicts and the site will die :( - */ - -class SVNUpdate implements Extension { - var $theme; - - public function receive_event(Event $event) { - if(is_null($this->theme)) $this->theme = get_theme_object($this); - - if(($event instanceof PageRequestEvent) && $event->page_matches("update")) { - if($event->user->is_admin()) { - if($event->get_arg(0) == "view_changes") { - $this->theme->display_update_todo($event->page, - $this->get_update_log(), - $this->get_branches()); - } - if($event->get_arg(0) == "update") { - $this->theme->display_update_log($event->page, $this->run_update()); - } - if($event->get_arg(0) == "dump") { - $this->theme->display_update_log($event->page, $this->run_dump()); - } - //if($event->get_arg(0) == "switch") { - // $this->theme->display_update_log($event->page, $this->run_update()); - //} - } - } - - if($event instanceof AdminBuildingEvent) { - global $page; - $this->theme->display_form($page); - } - } - - private function get_update_log() { - return shell_exec("svn log -r HEAD:BASE ."); - } - private function run_update() { - return shell_exec("svn update"); - } - private function run_dump() { - global $database_dsn; - $matches = array(); - - // FIXME: MySQL specific - if(preg_match("#^mysql://([^:]+):([^@]+)@([^/]+)/([^\?]+)#", $database_dsn, $matches)) { - $date = date("Ymd"); - return - shell_exec("mysqldump -uUSER -pPASS -hHOST DATABASE | gzip > db-$date.sql.gz") . - "\n\nDatabase dump should now be sitting in db-$date.sql.gz in the shimmie folder"; - } - else { - return "Couldn't parse database connection string"; - } - } - private function get_branches() { - $data = shell_exec("svn ls http://svn.shishnet.org/shimmie2/branches/"); - $list = array(); - foreach(split("\n", $data) as $line) { - $matches = array(); - if(preg_match("/branch_(\d.\d+)/", $line, $matches)) { - $ver = $matches[1]; - $list["branch_$ver"] = "Stable ($ver.X)"; - } - } - ksort($list); - $list = array_reverse($list, true); - $list["trunk"] = "Unstable (Trunk)"; - return $list; - } -} -add_event_listener(new SVNUpdate()); -?> diff --git a/contrib/svn_update/theme.php b/contrib/svn_update/theme.php deleted file mode 100644 index 574a0691..00000000 --- a/contrib/svn_update/theme.php +++ /dev/null @@ -1,52 +0,0 @@ -Check for Updates - "; - $page->add_block(new Block("Update", $html)); - } - - public function display_update_todo(Page $page, $log, $branches) { - $h_log = html_escape($log); - $updates = " - -
-
- -
- "; - $options = ""; - foreach($branches as $name => $nice) { - $options .= ""; - } - $branches = " -
- - -
- "; - - $page->set_title("Updates Available"); - $page->set_heading("Updates Available"); - $page->add_block(new NavBlock()); - $page->add_block(new Block("Updates For Current Branch", $updates)); - $page->add_block(new Block("Available Branches", $branches)); - } - - public function display_update_log(Page $page, $log) { - $h_log = html_escape($log); - $html = " - - "; - - $page->set_title("Update Log"); - $page->set_heading("Update Log"); - $page->add_block(new NavBlock()); - $page->add_block(new Block("Update Log", $html)); - } -} -?> diff --git a/contrib/tagger/images/active.png b/contrib/tagger/images/active.png deleted file mode 100644 index 4e4942c8c5a6e8feea2cff6c10ba8eb424db9f3f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 183 zcmeAS@N?(olHy`uVBq!ia0vp^AT}2V8<6ZZI=>f4u_bxCyDDqA0IPmT(MivH9 X4OWH=yO!z$l`(j_`njxgN@xNAvJx>W diff --git a/contrib/tagger/images/add-tag.png b/contrib/tagger/images/add-tag.png deleted file mode 100644 index dccedf8ddddb993f70433fe86b774538df5bce75..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 227 zcmeAS@N?(olHy`uVBq!ia0vp^AT}2V8<6ZZI=>f4u_bxCyDKq1)@*N775{M_8syb=cIqSVBa z)D(sC%#sX+kc?CXcTeAd_bIA*K!xs}E{-7*m#0oR$jhL>!OZ`-hwtR1uS*RzIKR0s zU}x>x6rlZj`->7wz5N}wibr|3U8o9VXyawb-k(@f4u_bxCyDFVdQ I&MBb@0P46Y%m4rY diff --git a/contrib/tagger/images/rem-tag.png b/contrib/tagger/images/rem-tag.png deleted file mode 100644 index 5fb9827a0f400c615120a8c0c27d6f4c9cfc7f66..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 198 zcmeAS@N?(olHy`uVBq!ia0vp^AT}2V8<6ZZI=>f4u_bxCyD_A-%p00i_>zopr0N6t|Qvd(} diff --git a/contrib/tagger/images/tag-img.psd b/contrib/tagger/images/tag-img.psd deleted file mode 100644 index 4404dfeea31c728a139b28eba5fff6b859d508a9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2148 zcmd^=%}T>S5XUD?sUP&vg9o1>&`VF^Npey_5WMyhZIvReP+IYs_9c8GkY{%2;B zO_SCyL=bn$>}F>6x3jym$w7R6K>=wA(d^2zP2A@a9mFSR;gj?`bc{AYbuHVPVxk69 zS{a@fYN<-3@|xD-EfP&6^Fr=Sh{Aro-_& zq(dQX*efCVy-KcTqx)e6wq~#1qwULl5be=ql^0+gwVG1BV%0T2YSjHw&Y|D(v}vtk z_BQ6PJlomARa&Hr@4o$Eb_4fzwc_kDTH4G>qG!3LRay2a&bCa#S#uUF$(p5;mR^k| zm1RBqx$Ia^utI>uSbS7e;;qnsNcc(&yeB)TEzMWWW!;B>?CT@uN3^b^dgtRaoY zU2W+~?77aZnmyN#DE8|IM&x@daVbytuzZ%PQEMqWw-#Pg9!a_V_nw?FyOK35_3S^T zOKpZM&LBfF1|7oHvj+cE8}LoR$Juwht#H@T_}-ZeIi5j=xEJUU7#1utfx)c-$9KG~ caM#hPDRVd;<#0SQoa6Bw;fRen;+}Kf0P5AOVE_OC diff --git a/contrib/tagger/main.php b/contrib/tagger/main.php deleted file mode 100644 index f572889c..00000000 --- a/contrib/tagger/main.php +++ /dev/null @@ -1,174 +0,0 @@ - - * Do not remove this notice. - */ - -class Tagger implements Extension { - var $theme; - - public function receive_event(Event $event) { - if(is_null($this->theme)) - $this->theme = get_theme_object($this); - - if($event instanceof DisplayingImageEvent) { - global $page, $config, $user; - - if($config->get_bool("tag_edit_anon") - || ($user->id != $config->get_int("anon_id")) - && $config->get_bool("ext_tagger_enabled")) - { - $this->theme->build_tagger($page,$event); - } - } - - if($event instanceof SetupBuildingEvent) { - $sb = new SetupBlock("Tagger"); - $sb->add_bool_option("ext_tagger_enabled","Enable Tagger"); - $sb->add_int_option("ext_tagger_search_delay","
Delay queries by "); - $sb->add_label(" milliseconds."); - $sb->add_label("
Limit queries returning more than "); - $sb->add_int_option("ext_tagger_tag_max"); - $sb->add_label(" tags to "); - $sb->add_int_option("ext_tagger_limit"); - $event->panel->add_block($sb); - } - } -} - -add_event_listener(new Tagger()); - -// Tagger AJAX back-end -class TaggerXML implements Extension { - public function receive_event(Event $event) { - if(($event instanceof PageRequestEvent) && $event->page_matches("tagger/tags")) { - global $page; - - //$match_tags = null; - //$image_tags = null; - $tags=null; - if (isset($_GET['s'])) { // tagger/tags[/...]?s=$string - // return matching tags in XML form - $tags = $this->match_tag_list($_GET['s']); - } else if($event->get_arg(0)) { // tagger/tags/$int - // return arg[1] AS image_id's tag list in XML form - $tags = $this->image_tag_list($event->get_arg(0)); - } - - $xml = "\n". - "". - $tags. - ""; - - $page->set_mode("data"); - $page->set_type("text/xml"); - $page->set_data($xml); - } - } - - private function match_tag_list ($s) { - global $database, $config, $event; - - $max_rows = $config->get_int("ext_tagger_tag_max",30); - $limit_rows = $config->get_int("ext_tagger_limit",30); - - $values = array(); - - // Match - $p = strlen($s) == 1? " ":"\_"; - $sq = "%".$p.mysql_real_escape_string($s)."%"; - $match = "concat(?,tag) LIKE ?"; - array_push($values,$p,$sq); - // Exclude -// $exclude = $event->get_arg(1)? "AND NOT IN ".$this->image_tags($event->get_arg(1)) : null; - - // Hidden Tags - $hidden = $config->get_string('ext-tagger_show-hidden','N')=='N' ? - "AND substring(tag,1,1) != '.'" : null; - - $q_where = "WHERE {$match} {$hidden} AND count > 0"; - - // FROM based on return count - $q_from = null; - $count = $this->count($q_where,$values); - if ($count > $max_rows) { - $q_from = "FROM (SELECT * FROM `tags` {$q_where} ". - "ORDER BY count DESC LIMIT 0, {$limit_rows}) AS `c_tags`"; - $q_where = null; - $count = array("max"=>$count); - } else { - $q_from = "FROM `tags`"; - $count = null; - } - - $tags = $database->Execute(" - SELECT * - {$q_from} - {$q_where} - ORDER BY tag", - $values); - - return $this->list_to_xml($tags,"search",$s,$count); - } - - private function image_tag_list ($image_id) { - global $database; - $tags = $database->Execute(" - SELECT tags.* - FROM image_tags JOIN tags ON image_tags.tag_id = tags.id - WHERE image_id=? ORDER BY tag", array($image_id)); - return $this->list_to_xml($tags,"image",$image_id); - } - - private function list_to_xml ($tags,$type,$query,$misc=null) { - $r = $tags->_numOfRows; - - $s_misc = ""; - if(!is_null($misc)) - foreach($misc as $attr => $val) $s_misc .= " ".$attr."=\"".$val."\""; - - $result = ""; - foreach($tags as $tag) { - $result .= $this->tag_to_xml($tag); - } - return $result.""; - } - - private function tag_to_xml ($tag) { - return - "". - html_escape($tag['tag']). - ""; - } - - private function count($query,$values) { - global $database; - return $database->Execute( - "SELECT COUNT(*) FROM `tags` $query",$values)->fields['COUNT(*)']; - } - - private function image_tags ($image_id) { - global $database; - $list = "("; - $i_tags = $database->Execute( - "SELECT tag_id FROM `image_tags` WHERE image_id=?", - array($image_id)); - - $b = false; - foreach($i_tags as $tag) { - if($b) - $list .= ","; - $b = true; - $list .= $tag['tag_id']; - - } - $list .= ")"; - - return $list; - } -} add_event_listener( new taggerXML(),10); -?> diff --git a/contrib/tagger/script.js b/contrib/tagger/script.js deleted file mode 100644 index e01c8168..00000000 --- a/contrib/tagger/script.js +++ /dev/null @@ -1,218 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\ -* Tagger - Advanced Tagging v2 * -* Author: Artanis (Erik Youngren ) * -* Do not remove this notice. * -\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -var Tagger = { - initialize : function (image_id) { - // object navigation - this.tag.parent = this; - this.position.parent = this; - // components - this.editor.container = byId('tagger_parent'); - this.editor.titlebar = byId('tagger_titlebar'); - this.editor.toolbar = byId('tagger_toolbar'); - //this.editor.menu = byId('tagger_p-menu'); - this.editor.body = byId('tagger_body'); - this.editor.tags = byId('tagger_tags'); - this.editor.form = this.editor.tags.parentNode; - this.editor.statusbar = byId('tagger_statusbar'); - // initial data - this.tag.image = image_id; - this.tag.query = config.make_link("tagger/tags"); - this.tag.list = null; - this.tag.suggest = null; - this.tag.image_tags(); - - // reveal - this.editor.container.style.display = ""; - - // dragging - DragHandler.attach(this.editor.titlebar); - - // positioning - this.position.load(); - - // events - window.onunload = function () { Tagger.position.save(); }; - }, - - alert : function (type,text,timeout) { - var id = "tagger_alert-"+type - var t_alert = byId(id); - if (t_alert) { - if(text == false) { - // remove - t_alert.parentNode.removeChild(t_alert); - } else { - // update - t_alert.innerHTML = text; - } - } else if (text) { - // create - var t_alert = document.createElement("div"); - t_alert.setAttribute("id",id); - t_alert.appendChild(document.createTextNode(text)); - this.editor.statusbar.appendChild(t_alert); - if(timeout>1) { - console.log("Tagger.alert('"+type+"',false,0)"); - setTimeout("Tagger.alert('"+type+"',false,0)",timeout); - } - } - }, - - editor : {}, - - tag : { - submit : function () { - var l = this.list.childNodes.length; - var tags = Array(); - for(var i=0; i 0) { - var tag = document.createElement("tag"); - tag.setAttribute("count","0"); - tag.setAttribute("id","newTag_"+tag_name); - tag.setAttribute("title","New - 0 uses"); - tag.onclick = function() { - Tagger.tag.toggle(this); - }; - tag.appendChild(document.createTextNode(tag_name)); - Tagger.tag.list.appendChild(tag); - } - }, - - toggle : function (tag) { - if(tag.parentNode == this.list) { - this.list.removeChild(tag); - } else { - this.list.appendChild(tag); - } - }, - - ajax : function (url, callback) { - var http = (new XMLHttpRequest || new ActiveXObject("Microsoft.XMLHTTP")); - http.open("GET",url,true); - http.onreadystatechange = function () { - if(http.readyState == 4) callback(http); - }; - http.send(null); - } - }, - - position : { - set : function (x,y) { - if (!x || !y) { - with(this.parent.editor.container.style) { - top = "25px"; - left = ""; - right = "25px"; - bottom = ""; - } - var xy = this.get(); - x = xy[0]; - y = xy[1]; - } - with(this.parent.editor.container.style) { - top = y+"px"; - left = x+"px"; - right = ""; - bottom = ""; - } - }, - - get : function () { - // http://www.quirksmode.org/js/findpos.html - var left = 0; - var top = 0; - var obj = this.parent.editor.container; - if(obj.offsetParent) { - left = obj.offsetLeft; - top = obj.offsetTop; - while (obj = obj.offsetParent) { - left += obj.offsetLeft; - top += obj.offsetTop; - } - } - return [left,top]; - }, - - save : function (x,y) { - if (!x || !y) { - var xy = this.get(); - x = xy[0]; - y = xy[1]; - } - setCookie(config.title+"_tagger-position",x+" "+y,14); - }, - - load : function () { - var p = getCookie(config.title+"_tagger-position"); - if(p) { - var xy = p.split(" "); - this.set(xy[0],xy[1]); - } else { - this.set(); - } - } - } -}; diff --git a/contrib/tagger/style.css b/contrib/tagger/style.css deleted file mode 100644 index 40c79065..00000000 --- a/contrib/tagger/style.css +++ /dev/null @@ -1,104 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Tagger - Advanced Tagging v2 * - * Author: Artanis (Erik Youngren ) * - * Do not remove this notice. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#tagger_parent { - text-align:left; - position:fixed; - max-width:300px; - -} -#tagger_parent * { - background-color:#EEE; -} - -#tagger_titlebar { - background-color:#ddd; - border:2px solid; - cursor:move; - font-weight:bold; - -moz-border-radius:5px 5px 0 0; - padding:.25em; - text-align:center; -} - -#tagger_toolbar, #tagger_body { - padding:2px 2px 0 2px; - border-style:solid; - border-width: 0px 2px 0px 2px; -} -#tagger_body { - max-height:175px; - overflow:auto; - overflow-x:hidden; - overflow-y:auto; -} - -#tagger_statusbar { - background-color:#ddd; - border:2px solid; - font-weight: bold; - min-height:16px; - -moz-border-radius:0 0 5px 5px; - padding:.25em; -} #tagger_statusbar * { background-color:#ddd; } - -#tagger_body div { - padding-top:2px; - margin-top:2px; - border-top:1px solid; -} - -/* Tagger Styling - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#tagger_parent form { - display:inline; -} -#tagger_parent input { - width:auto; -} -#tagger_parent input[type=text] { - background-color:white; -} - -/* Custom Element Base Styles - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#tagger_parent list { - display: block; -} -#tagger_parent tag { - font-size:1.25em; - display:block; -} - -#tagger_parent list[id=image] tag:before { - content:url('./images/active.png'); -} - -#tagger_parent list[id=search] tag:before { - content:url('./images/inactive.png'); -} -/* Hovering */ -#tagger_parent tag:hover { - cursor:pointer; - background-color:#ddd; -} - -/*#tagger_parent list[id=image] tag:hover { - background-color:#faa; -} - -#tagger_parent list[id=search] tag:hover { - background-color:#afa; -}*/ - -#tagger_parent list[id=image] tag:hover:before { - content:url('./images/rem-tag.png'); -} - -#tagger_parent list[id=search] tag:hover:before { - content:url('./images/add-tag.png'); -} diff --git a/contrib/tagger/theme.php b/contrib/tagger/theme.php deleted file mode 100644 index f1edc566..00000000 --- a/contrib/tagger/theme.php +++ /dev/null @@ -1,65 +0,0 @@ -) * - * Do not remove this notice. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -class taggerTheme extends Themelet { - public function build_tagger (Page $page, $event) { - global $config; - // Initialization code - $base_href = $config->get_string('base_href'); - // TODO: AJAX test and fallback. - $page->add_header(""); - $page->add_block(new Block(null, - "","main",1000)); - - // Tagger block - $page->add_block( new Block( - null, - $this->html($event->get_image()), - "main")); - } - private function html(Image $image) { - global $config; - $i_image_id = int_escape($image->id); - $h_source = html_escape($image->source); - $h_query = isset($_GET['search'])? $h_query= "search=".url_escape($_GET['search']) : ""; - - $delay = $config->get_string("ext_tagger_search_delay","250"); - - $url_form = make_link("tag_edit/set"); - - // TODO: option for initial Tagger window placement. - $html = <<< EOD - -EOD; - return $html; - } -} -?> diff --git a/contrib/tagger/webtoolkit.drag.js b/contrib/tagger/webtoolkit.drag.js deleted file mode 100644 index 3ba87507..00000000 --- a/contrib/tagger/webtoolkit.drag.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* -* Crossbrowser Drag Handler -* http://www.webtoolkit.info/ -* -* Modified by Erik Youngren to move parent node -**/ - -var DragHandler = { - - - // private property. - _oElem : null, - - - // public method. Attach drag handler to an element. - attach : function(oElem) { - oElem.onmousedown = DragHandler._dragBegin; - - // callbacks - oElem.dragBegin = new Function(); - oElem.drag = new Function(); - oElem.dragEnd = new Function(); - - return oElem; - }, - - - // private method. Begin drag process. - _dragBegin : function(e) { - var oElem = DragHandler._oElem = this; - - if (isNaN(parseInt(oElem.parentNode.style.left))) { oElem.parentNode.style.left = '0px'; } - if (isNaN(parseInt(oElem.parentNode.style.top))) { oElem.parentNode.style.top = '0px'; } - - var x = parseInt(oElem.parentNode.style.left); - var y = parseInt(oElem.parentNode.style.top); - - e = e ? e : window.event; - oElem.mouseX = e.clientX; - oElem.mouseY = e.clientY; - - oElem.dragBegin(oElem, x, y); - - document.onmousemove = DragHandler._drag; - document.onmouseup = DragHandler._dragEnd; - return false; - }, - - - // private method. Drag (move) element. - _drag : function(e) { - var oElem = DragHandler._oElem; - - var x = parseInt(oElem.parentNode.style.left); - var y = parseInt(oElem.parentNode.style.top); - - e = e ? e : window.event; - oElem.parentNode.style.left = x + (e.clientX - oElem.mouseX) + 'px'; - oElem.parentNode.style.top = y + (e.clientY - oElem.mouseY) + 'px'; - - oElem.mouseX = e.clientX; - oElem.mouseY = e.clientY; - - oElem.drag(oElem, x, y); - - return false; - }, - - - // private method. Stop drag process. - _dragEnd : function() { - var oElem = DragHandler._oElem; - - var x = parseInt(oElem.parentNode.style.left); - var y = parseInt(oElem.parentNode.style.top); - - oElem.dragEnd(oElem, x, y); - - document.onmousemove = null; - document.onmouseup = null; - DragHandler._oElem = null; - } - -} diff --git a/contrib/text_score/main.php b/contrib/text_score/main.php deleted file mode 100644 index 853d45db..00000000 --- a/contrib/text_score/main.php +++ /dev/null @@ -1,109 +0,0 @@ - - * License: GPLv2 - * Description: Allow users to score images - * Documentation: - * Similar to the Image Scores (Numeric) extension, but this one - * uses an average rather than the sum of all votes, which means - * that the score will be [-2 .. +2], and each integer in that - * range has a label attached. - */ - -class TextScoreSetEvent extends Event { - var $image_id, $user, $score; - - public function TextScoreSetEvent($image_id, $user, $score) { - $this->image_id = $image_id; - $this->user = $user; - $this->score = $score; - } -} - -class TextScore implements Extension { - var $theme; - - public function receive_event(Event $event) { - if(is_null($this->theme)) $this->theme = get_theme_object($this); - - if(($event instanceof InitExtEvent)) { - global $config; - if($config->get_int("ext_text_score_version", 0) < 1) { - $this->install(); - } - $config->set_default_bool("text_score_anon", true); - } - - if(($event instanceof ImageInfoBoxBuildingEvent)) { - global $user; - global $config; - if(!$user->is_anonymous() || $config->get_bool("text_score_anon")) { - $event->add_part($this->theme->get_scorer_html($event->image)); - } - } - - if($event instanceof ImageInfoSetEvent) { - global $user; - $i_score = int_escape($_POST['text_score__score']); - - if($i_score >= -2 || $i_score <= 2) { - send_event(new TextScoreSetEvent($event->image->id, $user, $i_score)); - } - } - - if(($event instanceof TextScoreSetEvent)) { - if(!$event->user->is_anonymous() || $config->get_bool("text_score_anon")) { - $this->add_vote($event->image_id, $event->user->id, $event->score); - } - } - - if(($event instanceof ImageDeletionEvent)) { - global $database; - $database->execute("DELETE FROM text_score_votes WHERE image_id=?", array($event->image->id)); - } - - if(($event instanceof SetupBuildingEvent)) { - $sb = new SetupBlock("Text Score"); - $sb->add_bool_option("text_score_anon", "Allow anonymous votes: "); - $event->panel->add_block($sb); - } - - if(($event instanceof ParseLinkTemplateEvent)) { - $event->replace('$text_score', $this->theme->score_to_name($event->image->text_score)); - } - } - - private function install() { - global $database; - global $config; - - if($config->get_int("ext_text_score_version") < 1) { - $database->Execute("ALTER TABLE images ADD COLUMN text_score INTEGER NOT NULL DEFAULT 0"); - $database->Execute("CREATE INDEX images__text_score ON images(text_score)"); - $database->create_table("text_score_votes", " - image_id INTEGER NOT NULL, - user_id INTEGER NOT NULL, - score INTEGER NOT NULL, - UNIQUE(image_id, user_id), - INDEX(image_id), - FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE, - FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE - "); - $config->set_int("ext_text_score_version", 1); - } - } - - private function add_vote($image_id, $user_id, $score) { - global $database; - // TODO: update if already voted - $database->Execute( - "REPLACE INTO text_score_votes(image_id, user_id, score) VALUES(?, ?, ?)", - array($image_id, $user_id, $score)); - $database->Execute( - "UPDATE images SET text_score=(SELECT AVG(score) FROM text_score_votes WHERE image_id=?) WHERE id=?", - array($image_id, $image_id)); - } -} -add_event_listener(new TextScore()); -?> diff --git a/contrib/text_score/theme.php b/contrib/text_score/theme.php deleted file mode 100644 index bc0f14b4..00000000 --- a/contrib/text_score/theme.php +++ /dev/null @@ -1,33 +0,0 @@ -id); - - $s_score = $this->score_to_name($image->text_score); - $html = " - Current score is \"$s_score\" -
- - - - - - - "; - return $html; - } - - public function score_to_name($score) { - $words = array(); - $words[-2] = "Delete"; - $words[-1] = "Bad"; - $words[ 0] = "Ok"; - $words[ 1] = "Good"; - $words[ 2] = "Favourite"; - $s_score = $words[$score]; - return $s_score; - } -} - -?>