public function execute()
 {
     $filter = array();
     $filter['enabled'] = true;
     $filter['extras'] = 'themes';
     $app = false;
     $messages = array();
     $applications = installerHelper::getApps($messages, $update_counter, $filter);
     $search = array();
     $search['slug'] = $app_id = waRequest::get('slug');
     $search['vendor'] = waRequest::get('vendor', 'webasyst');
     $themes = wa()->getThemes($search['slug']);
     if (array_filter($search, 'strlen') && ($app = installerHelper::search($applications, $search))) {
         foreach ($app['extras']['themes'] as $id => $info) {
             if (!isset($themes[$id])) {
                 $themes[$id] = new waTheme($id, $search['slug'], true);
                 $themes[$id]['name'] = $info['name'];
                 $themes[$id]['description'] = $info['description'];
             }
             if (!empty($info['payware'])) {
                 $themes[$id]['payware'] = $info['payware'];
             }
             if (!empty($info['img'])) {
                 $themes[$id]['cover'] = $info['img'];
             }
         }
         $this->view->assign('themes', $themes);
         $this->view->assign('messages', $messages);
         $this->view->assign('app_id', $app_id);
         $this->view->assign('app', $app);
         $this->view->assign('slug', $search['slug']);
         $this->view->assign('vendor', $search['vendor']);
     }
 }
 public function execute()
 {
     $filter = array();
     $filter['enabled'] = true;
     $filter['extras'] = 'plugins';
     $options = array('installed' => true);
     $search = array();
     $search['slug'] = preg_replace('@^(wa-plugins/)?([^/]+)/.+$@', '$1$2', waRequest::get('slug'));
     if (strpos($search['slug'], 'wa-plugins/') === 0) {
         $options['system'] = true;
     }
     $applications = installerHelper::getInstaller()->getApps($options, $filter);
     $plugin_search = array();
     $plugin_search['id'] = preg_replace('@^.+/@', '', waRequest::get('slug'));
     if (array_filter($search, 'strlen') && ($app = installerHelper::search($applications, $search))) {
         $plugin_search['slug'] = $search['slug'] . "/plugins/" . $plugin_search['id'];
         $options = array('action' => true, 'requirements' => true);
         $plugin = installerHelper::getInstaller()->getItemInfo($plugin_search['slug'], $options);
         if (!$plugin) {
             $options['local'] = true;
             $plugin = installerHelper::getInstaller()->getItemInfo($plugin_search['slug'], $options);
         }
         if ($plugin) {
             $plugin['app'] = preg_replace('@^(wa-plugins/)?([^/]+)/.+$@', '$1$2', $plugin['slug']);
             $plugin['slug'] = preg_replace('@^wa-plugins/([^/]+)/plugins/(.+)$@', 'wa-plugins/$1/$2', $plugin['slug']);
         }
         $this->view->assign('identity_hash', installerHelper::getHash());
         $this->view->assign('promo_id', installerHelper::getPromoId());
         $this->view->assign('domain', installerHelper::getDomain());
         $this->view->assign('plugin', $plugin);
         $this->view->assign('query', waRequest::get('query', '', waRequest::TYPE_STRING_TRIM) . '/');
     } else {
         throw new waException(_w('Plugin not found'), 404);
     }
 }
 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()
 {
     $filter = array();
     $filter['enabled'] = true;
     $filter['extras'] = 'themes';
     $app = false;
     $messages = array();
     $applications = installerHelper::getApps($messages, $update_counter = null, $filter);
     $search = array();
     $search['slug'] = waRequest::get('slug');
     $search['vendor'] = waRequest::get('vendor', 'webasyst');
     $theme_search = array();
     $theme_search['slug'] = waRequest::get('theme_slug');
     $theme_search['vendor'] = waRequest::get('theme_vendor', 'webasyst');
     if (array_filter($search, 'strlen') && ($app = installerHelper::search($applications, $search))) {
         $theme = new waTheme($theme_search['slug'], $search['slug'], true);
         $theme_search['slug'] = $search['slug'] . "/themes/" . $theme_search['slug'];
         if ($info = installerHelper::search($app['extras']['themes'], $theme_search)) {
             if (!$theme['path']) {
                 $theme['name'] = $info['name'];
                 $theme['description'] = $info['description'];
                 $theme['vendor'] = $info['vendor'];
                 $theme['install_info'] = $info;
             } else {
                 $theme['updates_info'] = $info;
             }
             if (!empty($info['payware'])) {
                 $theme['payware'] = $info['payware'];
             }
             if (!empty($info['img'])) {
                 $theme['cover'] = $info['img'];
             }
         }
         $this->view->assign('identity_hash', installerHelper::getHash());
         $this->view->assign('theme', $theme);
         $this->view->assign('messages', $messages);
     } else {
         throw new waException(_w('Theme not found'), 404);
     }
 }
 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'));
 }