diff --git a/contrib/svn_update/main.php b/contrib/svn_update/main.php index 3a829c52..027d9627 100644 --- a/contrib/svn_update/main.php +++ b/contrib/svn_update/main.php @@ -15,12 +15,17 @@ class SVNUpdate extends Extension { if(is_a($event, 'PageRequestEvent') && ($event->page_name == "update")) { if($event->user->is_admin()) { - if($event->get_arg(0) == "log") { - $this->theme->display_update_todo($event->page, $this->get_update_log()); + 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) == "run") { + if($event->get_arg(0) == "update") { $this->theme->display_update_log($event->page, $this->run_update()); } + //if($event->get_arg(0) == "switch") { + // $this->theme->display_update_log($event->page, $this->run_update()); + //} } } @@ -31,11 +36,26 @@ class SVNUpdate extends Extension { } private function get_update_log() { - return shell_exec("svn log -r BASE:HEAD ."); + return shell_exec("svn log -r HEAD:BASE ."); } private function run_update() { return shell_exec("svn update"); } + 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 index d057e2c9..bcae1846 100644 --- a/contrib/svn_update/theme.php +++ b/contrib/svn_update/theme.php @@ -3,22 +3,38 @@ class SVNUpdateTheme extends Themelet { public function display_form($page) { $html = " - Check for Updates + Check for Updates "; $page->add_block(new Block("Update", $html)); } - public function display_update_todo($page, $log) { + public function display_update_todo($page, $log, $branches) { $h_log = html_escape($log); - $html = " + $updates = " -
Install 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", $html)); + $page->add_block(new Block("Updates For Current Branch", $updates)); + $page->add_block(new Block("Available Branches", $branches)); } public function display_update_log($page, $log) {