From 6870a0d14597f7006c110708114101a7f4b09b1d Mon Sep 17 00:00:00 2001 From: Shish Moom Date: Tue, 7 Jul 2009 07:57:52 -0700 Subject: [PATCH] these don't work either --- contrib/svn_update/main.php | 84 --------------------------- contrib/svn_update/theme.php | 52 ----------------- contrib/text_score/main.php | 109 ----------------------------------- contrib/text_score/theme.php | 33 ----------- 4 files changed, 278 deletions(-) delete mode 100644 contrib/svn_update/main.php delete mode 100644 contrib/svn_update/theme.php delete mode 100644 contrib/text_score/main.php delete mode 100644 contrib/text_score/theme.php 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/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; - } -} - -?>