remove in-development extensions
This commit is contained in:
		
							parent
							
								
									cca47a1df9
								
							
						
					
					
						commit
						275e0b3b64
					
				@ -1,31 +0,0 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * Name: Autocomplete
 | 
			
		||||
 * Author: Shish <webmaster@shishnet.org>
 | 
			
		||||
 * 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("<script>autocomplete_url='".html_escape(make_link("autocomplete"))."';</script>");
 | 
			
		||||
		}
 | 
			
		||||
		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());
 | 
			
		||||
?>
 | 
			
		||||
@ -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<words.length-1; n++) {
 | 
			
		||||
		box.value += words[n]+" ";
 | 
			
		||||
	}
 | 
			
		||||
	box.value += text+" ";
 | 
			
		||||
	box.focus();
 | 
			
		||||
	return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function fillCompletionZone(boxname, areaname, results) {
 | 
			
		||||
	byId(areaname).innerHTML = "";
 | 
			
		||||
	for(i=0; i<results.length; i++) {
 | 
			
		||||
		byId(areaname).innerHTML += "<br><a href=\"#\" onclick=\"complete('"+boxname+"', '"+results[i]+"');\">"+results[i]+"</a>";
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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);
 | 
			
		||||
		}
 | 
			
		||||
	};
 | 
			
		||||
}
 | 
			
		||||
@ -1,69 +0,0 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * Name: Bookmarks
 | 
			
		||||
 * Author: Shish <webmaster@shishnet.org>
 | 
			
		||||
 * 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());
 | 
			
		||||
?>
 | 
			
		||||
@ -1,5 +0,0 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
class BookmarksTheme extends Themelet {
 | 
			
		||||
}
 | 
			
		||||
?>
 | 
			
		||||
@ -1,121 +0,0 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * Name: EventLog
 | 
			
		||||
 * Author: Shish <webmaster@shishnet.org>
 | 
			
		||||
 * 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
 | 
			
		||||
?>
 | 
			
		||||
@ -1,83 +0,0 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
class EventLogTheme extends Themelet {
 | 
			
		||||
	public function display_page(Page $page, $events) {
 | 
			
		||||
		$page->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 = "
 | 
			
		||||
			<style>
 | 
			
		||||
			.event_log_table TD {
 | 
			
		||||
				font-size: 0.75em;
 | 
			
		||||
			}
 | 
			
		||||
			.event_log_table TD.entry {
 | 
			
		||||
				text-align: left;
 | 
			
		||||
				vertical-align: middle;
 | 
			
		||||
			}
 | 
			
		||||
			</style>
 | 
			
		||||
			<table border='1' class='event_log_table'>
 | 
			
		||||
				<tr>
 | 
			
		||||
					<th>User
 | 
			
		||||
						<a href='".make_link("event_log", "sort=name&order=ASC")."'>+</a>
 | 
			
		||||
						<a href='".make_link("event_log", "sort=name&order=DESC")."'>-</a>
 | 
			
		||||
					</th>
 | 
			
		||||
					<th style='width: 10em;'>IP
 | 
			
		||||
						<a href='".make_link("event_log", "sort=owner_ip&order=ASC")."'>+</a>
 | 
			
		||||
						<a href='".make_link("event_log", "sort=owner_ip&order=DESC")."'>-</a>
 | 
			
		||||
					</th>
 | 
			
		||||
					<th rowspan='2' class='entry'>Entry</th>
 | 
			
		||||
				</tr>
 | 
			
		||||
				<tr>
 | 
			
		||||
					<th style='width: 10em;'>Date
 | 
			
		||||
						<a href='".make_link("event_log", "sort=date&order=ASC")."'>+</a>
 | 
			
		||||
						<a href='".make_link("event_log", "sort=date&order=DESC")."'>-</a>
 | 
			
		||||
					</th>
 | 
			
		||||
					<th>Event
 | 
			
		||||
						<a href='".make_link("event_log", "sort=event&order=ASC")."'>+</a>
 | 
			
		||||
						<a href='".make_link("event_log", "sort=event&order=DESC")."'>-</a>
 | 
			
		||||
					</th>
 | 
			
		||||
				</tr>
 | 
			
		||||
		";
 | 
			
		||||
		foreach($events as $event) {
 | 
			
		||||
			$entry = html_escape($event['entry']);
 | 
			
		||||
			$table .= "
 | 
			
		||||
				<tr>
 | 
			
		||||
					<td>
 | 
			
		||||
						<a href='".make_link("event_log", "filter=name&where={$event['name']}")."'>{$event['name']}</a>
 | 
			
		||||
					</td>
 | 
			
		||||
					<td>
 | 
			
		||||
						<a href='".make_link("event_log", "filter=owner_ip&where={$event['owner_ip']}")."'>{$event['owner_ip']}</a>
 | 
			
		||||
					</td>
 | 
			
		||||
					<td rowspan='2' class='entry'>{$entry}</td>
 | 
			
		||||
				</tr>
 | 
			
		||||
				<tr>
 | 
			
		||||
					<td>
 | 
			
		||||
						{$event['date']}
 | 
			
		||||
					</td>
 | 
			
		||||
					<td>
 | 
			
		||||
						<a href='".make_link("event_log", "filter=event&where={$event['event']}")."'>{$event['event']}</a>
 | 
			
		||||
					</td>
 | 
			
		||||
				</tr>
 | 
			
		||||
			";
 | 
			
		||||
		}
 | 
			
		||||
		$table .= "</table>";
 | 
			
		||||
		$page->add_block(new Block("Log Contents", $table));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	protected function display_controls(Page $page) {
 | 
			
		||||
		$html = "
 | 
			
		||||
		<form action='".make_link("event_log")."' method='POST'>
 | 
			
		||||
			<input type='hidden' name='action' value='clear'>
 | 
			
		||||
			<input type='submit' value='Clear Log'>
 | 
			
		||||
		</form>
 | 
			
		||||
		";
 | 
			
		||||
		$page->add_block(new Block(null, $html, "main", 60));
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
?>
 | 
			
		||||
@ -1,53 +0,0 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * Name: Image Notes
 | 
			
		||||
 * Author: Shish <webmaster@shishnet.org>
 | 
			
		||||
 * 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());
 | 
			
		||||
?>
 | 
			
		||||
@ -1,13 +0,0 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
class NotesTheme extends Themelet {
 | 
			
		||||
	public function display_notes(Page $page, $notes) {
 | 
			
		||||
		$html = <<<EOD
 | 
			
		||||
<script type="text/javascript">
 | 
			
		||||
img = byId("main_image");
 | 
			
		||||
</script>
 | 
			
		||||
EOD;
 | 
			
		||||
		$page->add_block(new Block(null, $html));
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
?>
 | 
			
		||||
@ -1,84 +0,0 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * Name: Subversion Updater
 | 
			
		||||
 * Author: Shish <webmaster@shishnet.org>
 | 
			
		||||
 * 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());
 | 
			
		||||
?>
 | 
			
		||||
@ -1,52 +0,0 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
class SVNUpdateTheme extends Themelet {
 | 
			
		||||
	public function display_form(Page $page) {
 | 
			
		||||
		$html = "
 | 
			
		||||
			<a href='".make_link("update/view_changes")."'>Check for Updates</a>
 | 
			
		||||
		";
 | 
			
		||||
		$page->add_block(new Block("Update", $html));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public function display_update_todo(Page $page, $log, $branches) {
 | 
			
		||||
		$h_log = html_escape($log);
 | 
			
		||||
		$updates = "
 | 
			
		||||
			<textarea rows='20' cols='80'>$h_log</textarea>
 | 
			
		||||
			<br/>
 | 
			
		||||
			<form action='".make_link("update/update")."' method='POST'>
 | 
			
		||||
				<input type='submit' value='Install Updates'>
 | 
			
		||||
			</form>
 | 
			
		||||
		";
 | 
			
		||||
		$options = "";
 | 
			
		||||
		foreach($branches as $name => $nice) {
 | 
			
		||||
			$options .= "<option value='$name'>$nice</option>";
 | 
			
		||||
		}
 | 
			
		||||
		$branches = "
 | 
			
		||||
			<form action='".make_link("update/switch")."' method='POST'>
 | 
			
		||||
				<select name='branch'>
 | 
			
		||||
					$options
 | 
			
		||||
				</select>
 | 
			
		||||
				<input type='submit' value='Change Branch'>
 | 
			
		||||
			</form>
 | 
			
		||||
		";
 | 
			
		||||
 | 
			
		||||
		$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 = "
 | 
			
		||||
			<textarea rows='20' cols='80'>$h_log</textarea>
 | 
			
		||||
		";
 | 
			
		||||
 | 
			
		||||
		$page->set_title("Update Log");
 | 
			
		||||
		$page->set_heading("Update Log");
 | 
			
		||||
		$page->add_block(new NavBlock());
 | 
			
		||||
		$page->add_block(new Block("Update Log", $html));
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
?>
 | 
			
		||||
										
											Binary file not shown.
										
									
								
							| 
		 Before Width: | Height: | Size: 183 B  | 
										
											Binary file not shown.
										
									
								
							| 
		 Before Width: | Height: | Size: 227 B  | 
										
											Binary file not shown.
										
									
								
							| 
		 Before Width: | Height: | Size: 170 B  | 
										
											Binary file not shown.
										
									
								
							| 
		 Before Width: | Height: | Size: 198 B  | 
										
											Binary file not shown.
										
									
								
							@ -1,174 +0,0 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * Name: Tagger
 | 
			
		||||
 * Description: Advanced Tagging v2
 | 
			
		||||
 * Author: Artanis (Erik Youngren) <artanis.00@gmail.com>
 | 
			
		||||
 * 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","<br/>Delay queries by ");
 | 
			
		||||
			$sb->add_label(" milliseconds.");
 | 
			
		||||
			$sb->add_label("<br/>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 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n".
 | 
			
		||||
			"<tags>".
 | 
			
		||||
				$tags.
 | 
			
		||||
			"</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 = "<list id=\"$type\" query=\"$query\" rows=\"$r\"{$s_misc}>";
 | 
			
		||||
		foreach($tags as $tag) {
 | 
			
		||||
			$result .= $this->tag_to_xml($tag);
 | 
			
		||||
		}
 | 
			
		||||
		return $result."</list>";
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private function tag_to_xml ($tag) {
 | 
			
		||||
		return
 | 
			
		||||
			"<tag  ".
 | 
			
		||||
				"id=\"".$tag['id']."\" ".
 | 
			
		||||
				"count=\"".$tag['count']."\">".
 | 
			
		||||
				html_escape($tag['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);
 | 
			
		||||
?>
 | 
			
		||||
@ -1,218 +0,0 @@
 | 
			
		||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
 | 
			
		||||
* Tagger - Advanced Tagging v2                                                *
 | 
			
		||||
* Author: Artanis (Erik Youngren <artanis.00@gmail.com>)                      *
 | 
			
		||||
* 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<l; i++) {
 | 
			
		||||
				var s_tag = this.list.childNodes[i].firstChild.data;
 | 
			
		||||
				tags.push(s_tag);
 | 
			
		||||
			}
 | 
			
		||||
			tags = tags.join(" ");
 | 
			
		||||
			this.parent.editor.tags.value = tags;
 | 
			
		||||
			return true;
 | 
			
		||||
		},
 | 
			
		||||
		
 | 
			
		||||
		search : function(s,ms) {
 | 
			
		||||
			clearTimeout(Tagger.tag.timer);
 | 
			
		||||
			Tagger.tag.timer = setTimeout(
 | 
			
		||||
				"Tagger.tag.ajax('"+Tagger.tag.query+"?s="+s+"',Tagger.tag.receive)",
 | 
			
		||||
				ms);
 | 
			
		||||
		},
 | 
			
		||||
		
 | 
			
		||||
		receive : function (xml) {
 | 
			
		||||
			if(xml) {
 | 
			
		||||
				Tagger.tag.suggest = document.importNode(
 | 
			
		||||
					xml.responseXML.getElementsByTagName("list")[0],true);
 | 
			
		||||
				Tagger.tag.publish(Tagger.tag.suggest,byId("tagger_p-search"));
 | 
			
		||||
			}
 | 
			
		||||
			if(Tagger.tag.suggest.getAttribute("max")) {
 | 
			
		||||
				var rows = Tagger.tag.suggest.getAttribute("rows");
 | 
			
		||||
				var max = Tagger.tag.suggest.getAttribute("max");
 | 
			
		||||
				Tagger.alert("maxout","Showing "+rows+" of "+max+" tags",0);
 | 
			
		||||
			} else {
 | 
			
		||||
				Tagger.alert("maxout",false);
 | 
			
		||||
			}
 | 
			
		||||
		},
 | 
			
		||||
		
 | 
			
		||||
		image_tags : function(xml) {
 | 
			
		||||
			if (!xml) {
 | 
			
		||||
				this.ajax(this.query+"/"+this.image,this.image_tags);
 | 
			
		||||
				return true;
 | 
			
		||||
			} else {
 | 
			
		||||
				Tagger.tag.list = document.importNode(
 | 
			
		||||
					xml.responseXML.getElementsByTagName("list")[0],true);
 | 
			
		||||
				Tagger.tag.publish(Tagger.tag.list,byId("tagger_p-applied"));
 | 
			
		||||
			}
 | 
			
		||||
		},
 | 
			
		||||
		
 | 
			
		||||
		publish : function (list, page) {
 | 
			
		||||
			list.setAttribute("xmlns","http://www.w3.org/1999/xhtml");
 | 
			
		||||
			
 | 
			
		||||
			var l = list.childNodes.length;
 | 
			
		||||
			for(var i=0; i<l; i++) {
 | 
			
		||||
				var tag = list.childNodes[i];
 | 
			
		||||
				tag.onclick = function () {
 | 
			
		||||
					Tagger.tag.toggle(this);
 | 
			
		||||
					byId("tagger_filter").select();
 | 
			
		||||
				};
 | 
			
		||||
				tag.setAttribute("title",tag.getAttribute("count")+" uses");
 | 
			
		||||
			}
 | 
			
		||||
			
 | 
			
		||||
			page.innerHTML = "";
 | 
			
		||||
			page.appendChild(list);
 | 
			
		||||
		},
 | 
			
		||||
		
 | 
			
		||||
		create : function (tag_name) {
 | 
			
		||||
			if(tag_name.length > 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();
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
};
 | 
			
		||||
@ -1,104 +0,0 @@
 | 
			
		||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 | 
			
		||||
 * Tagger - Advanced Tagging v2                                              *
 | 
			
		||||
 * Author: Artanis (Erik Youngren <artanis.00@gmail.com>)                    *
 | 
			
		||||
 * 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');
 | 
			
		||||
}
 | 
			
		||||
@ -1,65 +0,0 @@
 | 
			
		||||
<?php
 | 
			
		||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 | 
			
		||||
 * Tagger - Advanced Tagging v2                                              *
 | 
			
		||||
 * Author: Artanis (Erik Youngren <artanis.00@gmail.com>)                    *
 | 
			
		||||
 * 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("<script src='$base_href/ext/tagger/webtoolkit.drag.js' type='text/javascript'></script>");
 | 
			
		||||
		$page->add_block(new Block(null,
 | 
			
		||||
			"<script type='text/javascript'>Tagger.initialize("
 | 
			
		||||
				.$event->get_image()->id.");</script>","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
 | 
			
		||||
<div id="tagger_parent" style="display:none; top:25px; right:25px;">
 | 
			
		||||
	<div id="tagger_titlebar">Tagger</div>
 | 
			
		||||
 | 
			
		||||
	<div id="tagger_toolbar">
 | 
			
		||||
		<input type="text" value="" id="tagger_filter" onkeyup="Tagger.tag.search(this.value, $delay);"></input>
 | 
			
		||||
		<input type="button" value="Add" onclick="Tagger.tag.create(byId('tagger_filter').value);"></input>
 | 
			
		||||
		<form action="$url_form" method="POST" onsubmit="Tagger.tag.submit();">
 | 
			
		||||
			<input type='hidden' name='image_id' value='$i_image_id' id="image_id"></input>
 | 
			
		||||
			<input type='hidden' name='query' value='$h_query'></input>
 | 
			
		||||
			<input type='hidden' name='source' value='$h_source'></input>
 | 
			
		||||
			<input type="hidden" name="tags" value="" id="tagger_tags"></input>
 | 
			
		||||
 | 
			
		||||
			<input type="submit" value="Set"></input>
 | 
			
		||||
		</form>
 | 
			
		||||
		<!--<ul id="tagger_p-menu"></ul>
 | 
			
		||||
		<br style="clear:both;"/>-->
 | 
			
		||||
	</div>
 | 
			
		||||
 | 
			
		||||
	<div id="tagger_body">
 | 
			
		||||
		<div id="tagger_p-search" name="Searched Tags"></div>
 | 
			
		||||
		<div id="tagger_p-applied" name="Applied Tags"></div>
 | 
			
		||||
	</div>
 | 
			
		||||
	<div id="tagger_statusbar"></div>
 | 
			
		||||
</div>
 | 
			
		||||
EOD;
 | 
			
		||||
		return $html;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
?>
 | 
			
		||||
@ -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;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -1,109 +0,0 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * Name: Image Scores (Text)
 | 
			
		||||
 * Author: Shish <webmaster@shishnet.org>
 | 
			
		||||
 * 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());
 | 
			
		||||
?>
 | 
			
		||||
@ -1,33 +0,0 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
class TextScoreTheme extends Themelet {
 | 
			
		||||
	public function get_scorer_html(Image $image) {
 | 
			
		||||
		$i_image_id = int_escape($image->id);
 | 
			
		||||
 | 
			
		||||
		$s_score = $this->score_to_name($image->text_score);
 | 
			
		||||
		$html = "
 | 
			
		||||
			Current score is \"$s_score\"
 | 
			
		||||
			<br/>
 | 
			
		||||
			<input type='hidden' name='image_id' value='$i_image_id' />
 | 
			
		||||
			<input type='radio' name='text_score__score' value='-2' id='-2'><label for='-2'>Delete</label>
 | 
			
		||||
			<input type='radio' name='text_score__score' value='-1' id='-1'><label for='-1'>Bad</label>
 | 
			
		||||
			<input type='radio' name='text_score__score' value='0'  id='0' ><label for='0' >Ok</label>
 | 
			
		||||
			<input type='radio' name='text_score__score' value='1'  id='1' ><label for='1' >Good</label>
 | 
			
		||||
			<input type='radio' name='text_score__score' value='2'  id='2' ><label for='2' >Favourite</label>
 | 
			
		||||
		";
 | 
			
		||||
		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;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user