public function execute()
 {
     $messages = installerMessage::getInstance()->handle(waRequest::get('msg'));
     installerHelper::checkUpdates($messages);
     if ($m = $this->view->getVars('messages')) {
         $messages = array_merge($m, $messages);
     }
     $this->view->assign('messages', $messages);
     $plugins = 'wa-plugins/payment';
     $apps = wa()->getApps();
     if (isset($apps['shop'])) {
         $plugins = 'shop';
     } else {
         ksort($apps);
         foreach ($apps as $app => $info) {
             if (!empty($info['plugins'])) {
                 $plugins = $app;
                 break;
             }
         }
     }
     $model = new waAppSettingsModel();
     $this->view->assign('update_counter', $model->get($this->getApp(), 'update_counter'));
     $this->view->assign('module', waRequest::get('module', 'backend'));
     $this->view->assign('default_query', array('plugins' => $plugins));
 }
 public function execute()
 {
     $this->view->assign('action', 'update');
     $counter = array('total' => 0, 'applicable' => 0, 'payware' => 0);
     $app_list = array();
     $this->view->assign('error', false);
     $messages = installerMessage::getInstance()->handle(waRequest::get('msg'));
     try {
         $app_list = installerHelper::getApps($messages, $counter);
         foreach ($app_list as &$info) {
             if ($info['slug'] == 'installer') {
                 $info['name'] = _w('Webasyst Framework');
                 break;
             }
         }
         unset($info);
         $plugin_list = installerHelper::getSystemPlugins($messages, $counter);
     } catch (Exception $ex) {
         $messages[] = array('text' => $ex->getMessage(), 'result' => 'fail');
     }
     installerHelper::checkUpdates($messages);
     $this->view->assign('messages', $messages);
     //$this->view->assign('install_counter', $model->get($this->getApp(), 'install_counter'));
     $this->getConfig()->setCount($counter['total'] ? $counter['total'] : null);
     $this->view->assign('update_counter', $counter['total']);
     $this->view->assign('update_counter_applicable', $counter['applicable']);
     $this->view->assign('apps', $app_list);
     $this->view->assign('plugins', $plugin_list);
     $this->view->assign('identity_hash', installerHelper::getHash());
     $this->view->assign('title', _w('Updates'));
 }
 public function execute()
 {
     $messages = installerMessage::getInstance()->handle(waRequest::get('msg'));
     $counter = array('total' => 0, 'applicable' => 0, 'payware' => 0);
     $items = array();
     try {
         $items = installerHelper::getUpdates();
         $counter = installerHelper::getUpdatesCounter(null);
         if (isset($items['installer'])) {
             $items['installer']['name'] = _w('Webasyst Framework');
         }
     } catch (Exception $ex) {
         $messages[] = array('text' => $ex->getMessage(), 'result' => 'fail');
     }
     installerHelper::checkUpdates($messages);
     if (!waRequest::get('_')) {
         $this->setLayout(new installerBackendLayout());
         if ($messages) {
             $this->getLayout()->assign('messages', $messages);
         }
         $this->getLayout()->assign('update_counter', $counter['total']);
         $this->getLayout()->assign('no_ajax', true);
     } else {
         $this->view->assign('messages', $messages);
     }
     $this->view->assign('error', false);
     $this->view->assign('update_counter', $counter['total']);
     $this->view->assign('update_counter_applicable', $counter['applicable']);
     $this->view->assign('items', $items);
     $this->view->assign('domain', installerHelper::getDomain());
     $this->view->assign('title', _w('Updates'));
 }
 public function execute()
 {
     $extended = false;
     $this->view->assign('action', 'update');
     $this->view->assign('error', false);
     $messages = installerMessage::getInstance()->handle(waRequest::get('msg'));
     $update_counter = null;
     $this->view->assign('apps', installerHelper::getApps($messages, $update_counter));
     installerHelper::checkUpdates($messages);
     $this->view->assign('identity_hash', installerHelper::getHash());
     $this->view->assign('messages', $messages);
     $model = new waAppSettingsModel();
     $this->view->assign('update_counter', $model->get($this->getApp(), 'update_counter'));
     $this->view->assign('extended', $extended);
     $this->view->assign('title', _w('Installer'));
 }
 public function execute()
 {
     $extended = false;
     $this->view->assign('action', 'update');
     $this->view->assign('error', false);
     $messages = installerMessage::getInstance()->handle(waRequest::get('msg'));
     $filter = array();
     $filter['enabled'] = true;
     if ($this->module) {
         $filter['extras'] = $this->module;
     }
     $applications = installerHelper::getApps($messages, $this->update_counter, $filter);
     $app = false;
     try {
         $subject = waRequest::get('subject');
         if (empty($subject)) {
             $storage = wa()->getStorage();
             $search = array();
             $extras = preg_replace('/s$/', '', $this->module);
             $slug_id = "installer_select_{$extras}";
             $vendor_id = "installer_select_{$extras}_vendor";
             $search['slug'] = waRequest::get('slug', $storage->read($slug_id));
             $search['vendor'] = waRequest::get('vendor', $storage->read($vendor_id));
             if ((!$this->redirect || array_filter($search, 'strlen')) && ($app = installerHelper::search($applications, $search))) {
                 $storage->write($slug_id, $search['slug'] = $app['slug']);
                 $storage->write($vendor_id, $search['vendor'] = $app['vendor']);
             } else {
                 reset($applications);
                 if ($app = current($applications)) {
                     $this->redirect(array('module' => $this->module, 'slug' => $app['slug'], 'vendor' => $app['vendor']));
                 }
             }
             $this->view->assign('slug', $search['slug']);
             $this->view->assign('vendor', $search['vendor']);
             $this->view->assign('selected_app', $app);
         }
     } catch (Exception $ex) {
         $messages[] = array('text' => $ex->getMessage(), 'result' => 'fail');
     }
     installerHelper::checkUpdates($messages);
     $model = new waAppSettingsModel();
     $this->view->assign('update_counter', $model->get($this->getApp(), 'update_counter'));
     $this->view->assign('messages', $messages);
     $this->view->assign('apps', $applications);
     $this->view->assign('extended', $extended);
     $this->view->assign('title', _w('Installer'));
 }
 public function execute()
 {
     if (!waRequest::get('_') && false) {
         $this->setLayout(new installerBackendLayout());
     }
     $this->view->assign('action', 'update');
     $this->view->assign('error', false);
     $messages = installerMessage::getInstance()->handle(waRequest::get('msg'));
     $filter = array();
     if ($this->module) {
         $filter['extras'] = $this->module;
     }
     $app_options = $this->getAppOptions();
     try {
         $applications = installerHelper::getInstaller()->getApps($app_options, $filter);
         $this->extendApplications($applications);
         $subject = waRequest::get('subject');
         if (empty($subject)) {
             $extras = array();
             $search = array();
             $options = $this->getExtrasOptions();
             $slug = waRequest::get('slug');
             if (!empty($options['filter']['slug'])) {
                 $slug = $options['filter']['slug'];
                 unset($options['filter']['slug']);
             }
             $search['slug'] = array_filter(array_map('trim', explode(',', $slug)), 'strlen');
             if ($this->module == 'themes') {
                 if (empty($search['slug'])) {
                     $search['slug'] = array_keys($applications);
                 }
             } else {
                 foreach ($search['slug'] as $id) {
                     if (isset($applications[$id]) && !empty($applications[$id]['system_plugins'])) {
                         $search['slug'] = array_unique(array_merge($search['slug'], $applications[$id]['system_plugins']));
                     }
                 }
             }
             if ((!$this->redirect || !empty($search['slug'])) && ($keys = installerHelper::search($applications, $search, true)) !== null) {
                 $slug = array();
                 foreach ($keys as $id => $key) {
                     $slug[$id] = $applications[$key]['slug'];
                 }
                 $extras = installerHelper::getInstaller()->getExtras($slug, $this->module, $options);
                 $vendor_name = null;
                 foreach ($extras as $app_id => $app_item) {
                     if (!empty($app_item[$this->module])) {
                         foreach ($app_item[$this->module] as $extras_id => $extras_item) {
                             if (!empty($extras_item['vendor_name']) && !empty($options['filter']['vendor']) && empty($vendor_name)) {
                                 $vendor_name = $extras_item['vendor_name'];
                             }
                             if (in_array($app_id, $keys) !== false) {
                                 $app =& $applications[$app_id];
                                 if (!isset($app[$this->module])) {
                                     $app[$this->module] = array();
                                 }
                                 $app[$this->module][$extras_id] = $extras_item;
                                 unset($app);
                             } elseif (!empty($extras_item['inherited'])) {
                                 foreach (array_keys($extras_item['inherited']) as $app_id) {
                                     if (in_array($app_id, $keys) !== false) {
                                         $app =& $applications[$app_id];
                                         if (!isset($app[$this->module])) {
                                             $app[$this->module] = array();
                                         }
                                         $app[$this->module][$extras_id] = $extras_item;
                                         unset($app);
                                     }
                                 }
                             }
                         }
                     }
                 }
                 foreach ($keys as $id => $key) {
                     if (empty($applications[$key][$this->module])) {
                         unset($slug[$id]);
                     }
                 }
                 $this->view->assign('vendor_name', $vendor_name);
             } else {
                 reset($applications);
                 if ($app = current($applications)) {
                     $this->redirect(array('module' => $this->module, 'slug' => $app['slug'], 'vendor' => $app['vendor']));
                 }
             }
             $this->view->assign('slug', $search['slug']);
             //$this->view->assign('vendor', $search['vendor']);
             $this->view->assign('extras', $extras);
         }
         $this->view->assign('apps', $applications);
     } catch (Exception $ex) {
         $messages[] = array('text' => $ex->getMessage(), 'result' => 'fail');
     }
     installerHelper::checkUpdates($messages);
     $model = new waAppSettingsModel();
     $this->view->assign('update_counter', $model->get($this->getApp(), 'update_counter'));
     $this->view->assign('messages', $messages);
     $this->view->assign('title', _w('Installer'));
 }