diff --git a/contrib/svn_update/main.php b/contrib/svn_update/main.php new file mode 100644 index 00000000..3a829c52 --- /dev/null +++ b/contrib/svn_update/main.php @@ -0,0 +1,41 @@ + + * Link: http://trac.shishnet.org/shimmie2/ + * License: GPLv2 + * Description: Provides a button to check for updates + */ + +class SVNUpdate extends Extension { + var $theme; + + public function receive_event($event) { + if(is_null($this->theme)) $this->theme = get_theme_object("svn_update", "SVNUpdateTheme"); + + 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) == "run") { + $this->theme->display_update_log($event->page, $this->run_update()); + } + } + } + + if(is_a($event, 'AdminBuildingEvent')) { + global $page; + $this->theme->display_form($page); + } + } + + private function get_update_log() { + return shell_exec("svn log -r BASE:HEAD ."); + } + private function run_update() { + return shell_exec("svn update"); + } +} +add_event_listener(new SVNUpdate()); +?> diff --git a/contrib/svn_update/theme.php b/contrib/svn_update/theme.php new file mode 100644 index 00000000..d057e2c9 --- /dev/null +++ b/contrib/svn_update/theme.php @@ -0,0 +1,36 @@ +Check for Updates + "; + $page->add_block(new Block("Update", $html)); + } + + public function display_update_todo($page, $log) { + $h_log = html_escape($log); + $html = " + +
Install Updates + "; + + $page->set_title("Updates Available"); + $page->set_heading("Updates Available"); + $page->add_block(new NavBlock()); + $page->add_block(new Block("Updates", $html)); + } + + public function display_update_log($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)); + } +} +?>