Exemple #1
0
 public function install($input)
 {
     $patch_id = $input['params'][0];
     if (!$patch_id) {
         return;
     }
     $patch = fx::data('patch', $patch_id);
     if (!$patch) {
         return;
     }
     $this->response->addField(array('type' => 'label', 'value' => '<p>' . sprintf(fx::alang('Installing patch %s...', 'system'), $patch['to']) . '</p>'));
     $res = false;
     try {
         $res = $patch->install();
     } catch (Exception $e) {
         $this->response->addField(array('type' => 'label', 'value' => '<p style="color:#F00;">' . $e->getMessage() . '</p>'));
     }
     if (!$res) {
         $this->response->addField(array('type' => 'label', 'value' => '<p style="color:#F00;">Install failed!</p>'));
     } else {
         // retrieve changes
         $changes = '<ul>';
         $logs = fx::changelog($patch['to']);
         foreach ($logs as $log) {
             $changes .= "<li>{$log['message']}</li>";
         }
         $changes .= '</ul>';
         $this->response->addField(array('type' => 'label', 'value' => '<p>Patch installed sucessfully!</p>' . $changes));
     }
     $this->response->addField(array('type' => 'button', 'url' => 'patch.all', 'label' => 'Back'));
     $this->setLayout($patch);
 }