Пример #1
0
 public function checkUpdates()
 {
     $stored = $this->all();
     $url = fx::config('fx.update_url') . '?action=find&from=' . fx::version();
     @($res = file_get_contents($url));
     if (!$res) {
         return false;
     }
     $res = @json_decode($res);
     if ($res) {
         foreach ($res as $patch) {
             if ($stored->findOne('to', $patch->to)) {
                 continue;
             }
             $new_patch = $this->create(array('to' => $patch->to, 'from' => $patch->from, 'url' => $patch->url, 'created' => $patch->created));
             if ($patch->from == fx::version()) {
                 $new_patch['status'] = 'ready';
             } else {
                 $new_patch['status'] = 'pending';
             }
             $new_patch->save();
         }
     }
     return true;
 }
Пример #2
0
 public function all($input)
 {
     if (isset($input['params'][0])) {
     }
     $bSkipCheckUpdates = isset($input['params'][0]) ? $input['params'][0] : false;
     if (!$bSkipCheckUpdates) {
         if (!fx::data('patch')->checkUpdates()) {
             $this->response->addField(array('type' => 'label', 'value' => '<p style="color:#F00;">' . fx::alang('Update check failed', 'system') . '</p>'));
         }
     }
     $this->response->addField(array('type' => 'label', 'value' => '<p>' . fx::alang('Current Floxim version:', 'system') . ' ' . fx::version() . '</p>'));
     $patches = fx::data('patch')->all();
     $list = array('type' => 'list', 'filter' => true, 'sortable' => false);
     $list['labels'] = array('name' => fx::alang('Version'), 'description' => fx::alang('Description'), 'buttons' => array('type' => 'buttons'), 'from' => fx::alang('Previous'), 'status' => fx::alang('Status'));
     $list['values'] = array();
     $have_ready = false;
     foreach ($patches as $patch) {
         $r = array('row_id' => 'patch_id_' . $patch['id'], 'name' => $patch['to'], 'description' => $patch['description'], 'from' => $patch['from'], 'status' => $patch['status'], 'buttons' => array());
         if ($patch['status'] == 'ready') {
             $have_ready = true;
             $r['buttons'][] = array('url' => 'patch.install(' . $patch['id'] . ')', 'label' => fx::alang('Install'));
         }
         $list['values'][] = $r;
     }
     $this->response->addField($list);
     if ($have_ready) {
         $this->response->addField(array('type' => 'button', 'func' => 'fx_patch.install_chain', 'label' => fx::alang('Install all')));
     }
     $this->setLayout();
 }