00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 class SystemupdateController extends ControllerBase {
00014
00015
00016
00017 public function get_routes() {
00018 return array(
00019 new ExactMatchRoute('https://systemupdate', $this, 'systemupdate_update', new NoCacheCacheManager()),
00020 );
00021 }
00022
00023
00024
00025
00026
00027
00028 public function action_systemupdate_update(PageData $page_data) {
00029 if (class_exists('Console') && Console::is_console_request()) {
00030 $this->do_update_console($page_data);
00031 }
00032 else if (defined('SYSTEMUPDATE_PWD')) {
00033 Load::tools('formhandler');
00034 $formhandler = new FormHandler('frmsystemupdate');
00035 if ($page_data->has_post_data()) {
00036
00037 $this->do_update_form($formhandler, $page_data);
00038 }
00039 else {
00040 $view = ViewFactory::create_view(IViewFactory::CONTENT, 'core::systemupdate/auth', $page_data);
00041 $formhandler->prepare_view($view);
00042 $view->render();
00043 }
00044 }
00045 else {
00046 return CONTROLLER_NOT_FOUND;
00047 }
00048 }
00049
00050
00051
00052
00053
00054
00055
00056 protected function do_update_form(FormHandler $formhandler, PageData $page_data) {
00057 $err = $formhandler->validate();
00058 if ($err->is_ok()) {
00059 if ($page_data->get_post()->get_item('a') == SYSTEMUPDATE_PWD) {
00060 $logs = $this->execute_updates();
00061
00062 $view = ViewFactory::create_view(IViewFactory::CONTENT, 'systemupdate/log', $page_data);
00063 $view->assign('logs', $logs);
00064 $view->render();
00065 return;
00066 }
00067 else {
00068 $err->append(tr('Sorry, try again', 'systemupdate'));
00069 }
00070 }
00071 $formhandler->finish($err);
00072 }
00073
00074
00075
00076
00077 protected function do_update_console($page_data) {
00078 $logs = $this->execute_updates();
00079 $view = ViewFactory::create_view(IViewFactory::CONTENT, 'systemupdate/log_console', $page_data);
00080 $view->assign('logs', $logs);
00081 $view->render();
00082 }
00083
00084
00085
00086
00087
00088
00089 protected function execute_updates() {
00090 Load::components('systemupdateexecutor');
00091 $executor = new SystemUpdateExecutor();
00092 return $executor->execute_updates();
00093 }
00094 }