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() { $extended = false; $this->view->assign('action', 'update'); $update_counter = 0; $messages = installerMessage::getInstance()->handle(waRequest::get('msg')); $this->view->assign('error', false); $app = null; try { $app_list = installerHelper::getApps($messages, $update_counter); $slug = waRequest::get('slug'); $vendor = waRequest::get('vendor'); $edition = waRequest::get('edition'); foreach ($app_list as $info) { if ($info['slug'] == $slug && $info['vendor'] == $vendor && $info['edition'] == $edition) { $app = $info; break; } } if (!$app) { throw new waException(_w('Application not found')); } } catch (Exception $ex) { $msg = installerMessage::getInstance()->raiseMessage($ex->getMessage(), installerMessage::R_FAIL); $this->redirect(array('module' => 'apps', 'msg' => $msg)); } $this->view->assign('identity_hash', installerHelper::getHash()); $this->view->assign('messages', $messages); $this->view->assign('update_counter', $update_counter); $this->view->assign('app', $app); $this->view->assign('title', sprintf(_w('Application "%s"'), $app['name'])); }
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() { $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() { $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() { $filter = array(); $filter['enabled'] = true; $filter['extras'] = 'themes'; $options = array('installed' => true); $applications = installerHelper::getInstaller()->getApps($options, $filter); $search = array(); $search['slug'] = waRequest::get('slug'); $search['vendor'] = waRequest::get('vendor', 'webasyst'); $search['vendor'] = waRequest::get('theme_vendor', 'webasyst'); if (!empty($search['slug'])) { $options = array('action' => true, 'requirements' => true, 'inherited' => array_keys($applications)); if ($theme = installerHelper::getInstaller()->getItemInfo('*/themes/' . $search['slug'], $options)) { $theme['app'] = preg_replace('@/.+$@', '', $theme['slug']); } $this->view->assign('identity_hash', installerHelper::getHash()); $this->view->assign('promo_id', installerHelper::getPromoId()); $this->view->assign('domain', installerHelper::getDomain()); $this->view->assign('theme', $theme); $this->view->assign('query', waRequest::get('query', '', waRequest::TYPE_STRING_TRIM) . '/'); } else { throw new waException(_w('Theme not found'), 404); } }
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() { parent::execute(); $this->view->assign('systemplugins', installerHelper::getSystemPlugins($messages, $this->update_counter)); if (waRequest::get('subject') == 'systemplugins') { $this->view->assign('selected_type', waRequest::get('slug')); } $this->getConfig()->setCount($this->update_counter ? $this->update_counter : null); $this->view->assign('update_counter', $this->update_counter); }
/** * * @return waInstallerApps */ public static function &getInstaller() { if (!self::$model) { self::$model = new waAppSettingsModel(); } if (!self::$installer) { self::$installer = new waInstallerApps(self::$model->get('webasyst', 'license', false), wa()->getLocale(), 600, waRequest::get('refresh') ? true : false); } return self::$installer; }
public function execute() { try { $errors = installerHelper::flushCache(); $this->response['message'] = _w('Cache cleared'); if ($errors) { $this->response['message'] .= "<br>" . _w('But with errors:') . "<br>" . implode("<br>", $errors); } } catch (Exception $ex) { $this->setError($ex->getMessage()); } }
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() { //TODO use POST $app_ids = waRequest::request('app_id'); try { if (installerHelper::isDeveloper()) { throw new waException(_w('Unable to delete application (developer version is on)')); } if (!$app_ids || !is_array($app_ids)) { throw new waException(_w('Application not found')); } foreach ($app_ids as &$info) { if (!is_array($info)) { $info = array('vendor' => $info); } } unset($info); $this->apps = new waInstallerApps(); $app_list = $this->apps->getApps(array('installed' => true)); $deleted_apps = array(); foreach ($app_list as $info) { $app_id = $info['slug']; if (isset($app_ids[$app_id]) && $app_ids[$app_id]['vendor'] == $info['vendor']) { if (!empty($info['installed']['system'])) { throw new waException(sprintf(_w('Can not delete system application "%s"'), $info['name'])); } $deleted_apps[] = $this->deleteApp($app_id); } } wa()->setActive('installer'); if (!$deleted_apps) { throw new waException(_w('Application not found')); } $message = _w('Application %s has been deleted', 'Applications %s have been deleted', min(2, count($deleted_apps)), false); $message = sprintf($message, implode(', ', $deleted_apps)); $msg = installerMessage::getInstance()->raiseMessage($message); } catch (Exception $ex) { wa()->setActive('installer'); $msg = installerMessage::getInstance()->raiseMessage($ex->getMessage(), installerMessage::R_FAIL); } //'module' => installerHelper::getModule(), $this->redirect(array('msg' => $msg)); }
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('_')) { $this->setLayout(new installerBackendLayout()); } $this->view->assign('action', 'update'); $this->view->assign('error', false); try { $slug = waRequest::get('slug'); $options = array('vendor' => waRequest::get('vendor', '', waRequest::TYPE_STRING_TRIM), 'edition' => waRequest::get('edition', '', waRequest::TYPE_STRING_TRIM), 'action' => true, 'requirements' => true); $this->view->assign('app', $app = installerHelper::getInstaller()->getItemInfo($slug, $options)); $this->view->assign('title', sprintf(_w('Application "%s"'), $app['name'])); } catch (Exception $ex) { $this->view->assign('error', $ex->getMessage()); } $this->view->assign('identity_hash', installerHelper::getHash()); $this->view->assign('promo_id', installerHelper::getPromoId()); $this->view->assign('domain', installerHelper::getDomain()); if (!empty($app['is_premium']) && $app['theme'] == 'premium') { $this->setTemplate(preg_replace('@(\\.html)$@', 'Premium$1', $this->getTemplate())); } }
public function onCount() { $args = func_get_args(); $force = array_shift($args); $model = new waAppSettingsModel(); $app_id = $this->getApplication(); $update_counter = null; if ($force || time() - $model->get($app_id, 'update_counter_timestamp', 0) > 600 || is_null($update_counter = $model->get($app_id, 'update_counter', null))) { $license = $model->get('webasyst', 'license', false); $apps = new waInstallerApps($license, null, 600, $force); $app_list = $apps->getApplicationsList(false); $update_counter = waInstallerApps::getUpdateCount($app_list); $messages = ''; installerHelper::getSystemPlugins($messages, $update_counter); $model->ping(); $model->set($app_id, 'update_counter', $update_counter); $model->set($app_id, 'update_counter_timestamp', time()); } elseif (is_null($update_counter)) { $update_counter = $model->get($app_id, 'update_counter'); } return $update_counter ? $update_counter : null; }
public function onCount() { $args = func_get_args(); $force = array_shift($args); $model = new waAppSettingsModel(); $app_id = $this->getApplication(); $count = null; //check cache expiration time if ($force || time() - $model->get($app_id, 'update_counter_timestamp', 0) > 600 || is_null($count = $model->get($app_id, 'update_counter', null))) { $count = installerHelper::getUpdatesCounter('total'); //check available versions for installed items //download if required changelog & requirements for updated items //count applicable updates (optional) $model->ping(); } elseif (is_null($count)) { $count = $model->get($app_id, 'update_counter'); } if ($count) { $count = array('count' => $count, 'url' => $url = $this->getBackendUrl(true) . $this->application . '/?module=update'); } return $count; }
public function execute() { if (!waRequest::get('_')) { $this->setLayout(new installerBackendLayout()); } $options = array('local' => false, 'filter' => (array) waRequest::get('filter')); try { $messages = installerMessage::getInstance()->handle(waRequest::get('msg')); $this->view->assign('apps', $apps = installerHelper::getInstaller()->getApps($options)); $vendor_name = null; if (!empty($options['filter']['vendor']) && empty($vendor_name)) { foreach ($apps as $app) { if (!empty($app['vendor_name'])) { $vendor_name = $app['vendor_name']; break; } } } $this->view->assign('vendor_name', $vendor_name); } catch (Exception $ex) { $messages[] = array('text' => $ex->getMessage(), 'result' => 'fail'); $this->view->assign('messages', $messages); } }
function execute() { $update_ids = waRequest::get('app_id'); if ($update_ids && is_array($update_ids)) { ob_start(); $app_ids = array(); $plugins_ids = array(); $vendors = array(); foreach ($update_ids as $app_id => &$info) { if (!is_array($info)) { if (strpos($info, ':') === false) { $vendor = $info; $edition = ''; } else { list($vendor, $edition) = explode(':', $info, 2); } $app_ids[$app_id] = array('vendor' => $info, 'slug' => $app_id); } else { if (isset($info['slug'])) { $app_id = $info['slug']; } $app_ids[$app_id] = $info; } $vendors[] = $info['vendor']; unset($info); } $vendors = array_unique($vendors); $model = new waAppSettingsModel(); $license = $model->get('webasyst', 'license', false); $locale = wa()->getLocale(); try { $log_level = waSystemConfig::isDebug() ? waInstaller::LOG_DEBUG : waInstaller::LOG_WARNING; $thread_id = $this->getRequest()->request('thread_id', false); $updater = new waInstaller($log_level, $thread_id); $this->getStorage()->close(); $updater->init(); $apps = new waInstallerApps($license, $locale, false); $app = $this->getApp(); if (isset($app_ids[$app]) || true) { $system_list = $apps->getSystemList(); } if (isset($app_ids[$app])) { #update system items foreach ($system_list as $target => $item) { if (empty($item['subject'])) { $this->add(!empty($item['target']) ? $item['target'] : $item['slug'], $item); } } } foreach ($system_list as $target => $item) { if (!empty($item['subject']) && $item['subject'] == 'systemplugins' && isset($app_ids[$item['slug']])) { $this->add(!empty($item['target']) ? $item['target'] : $item['slug'], $item, $item['slug']); unset($app_ids[$item['slug']]); } } $app_list = $apps->getApplicationsList(false, $vendors, wa()->getDataPath('images', true)); $model->ping(); $this->pass = count($this->urls) || count($app_ids) > 1 ? true : false; $added = true; $execute_actions = array(waInstallerApps::ACTION_INSTALL, waInstallerApps::ACTION_CRITICAL_UPDATE, waInstallerApps::ACTION_UPDATE); while ($app_ids && $added) { $added = false; foreach ($app_list as &$info) { $app_id = $info['slug']; if ($app_id == 'installer') { $info['name'] = _w('Webasyst Framework'); } if (isset($app_ids[$app_id]) && installerHelper::equals($app_ids[$app_id], $info)) { $target = 'wa-apps/' . $app_id; $info['subject'] = 'app'; $this->add($target, $info, $app_id); unset($app_ids[$app_id]); } if (isset($info['extras']) && is_array($info['extras'])) { foreach ($info['extras'] as $subject => $extras) { foreach ($extras as $extras_id => $extras_info) { $extras_id = $app_id . '/' . $subject . '/' . $extras_id; if (isset($app_ids[$extras_id]) && installerHelper::equals($app_ids[$extras_id], $extras_info)) { if (!empty($app_ids[$extras_id]['dependent']) && (empty($extras_info['action']) || !in_array($extras_info['action'], $execute_actions))) { continue; } $target = 'wa-apps/' . $extras_id; $extras_info['subject'] = 'app_' . $subject; $this->add($target, $extras_info, $extras_info['slug']); if ($extras_info['dependency']) { foreach ($extras_info['dependency'] as $dependency) { $app_ids[$dependency] = $app_ids[$extras_id]; $app_ids[$dependency]['slug'] = $dependency; $app_ids[$dependency]['dependent'] = $target; $added = true; } } if ($subject == 'themes') { if (!empty($extras_info['current']['parent_theme_id'])) { $parent_id = $extras_info['current']['parent_theme_id']; $parent_app_id = $app_id; if (strpos($parent_id, ':')) { list($parent_app_id, $parent_id) = explode(':', $parent_id); } $dependency = "{$parent_app_id}/{$subject}/{$parent_id}"; $app_ids[$dependency] = $app_ids[$extras_id]; $app_ids[$dependency]['slug'] = $dependency; $app_ids[$dependency]['dependent'] = $target; $added = true; } } unset($app_ids[$extras_id]); } } } } } unset($info); } $storage = wa()->getStorage(); $storage->close(); $result_urls = $updater->update($this->urls); if (waRequest::get('install')) { $model->ping(); $user = $this->getUser(); $set_rights = false; if (!$user->isAdmin()) { $set_rights = true; } foreach ($this->urls as $target => $url) { //TODO workaround exceptions if ((!isset($url['skipped']) || !$url['skipped']) && preg_match('@^wa-apps@', $target)) { $apps->installWebAsystItem($url['slug'], null, isset($url['edition']) ? $url['edition'] : true); if ($set_rights) { $user->setRight($url['slug'], 'backend', 2); } } } } $secure_properties = array('archive', 'source', 'backup', 'md5', 'extract_path'); foreach ($result_urls as &$result_url) { foreach ($secure_properties as $property) { if (isset($result_url[$property])) { unset($result_url[$property]); } } unset($result_url); } $this->response['sources'] = $result_urls; $this->response['current_state'] = $updater->getState(); $this->response['state'] = $updater->getFullState(waRequest::get('mode', 'apps')); //cleanup cache //waFiles::delete(wa()->getAppCachePath(null, false), true); $path_cache = waConfig::get('wa_path_cache'); waFiles::delete($path_cache, true); waFiles::protect($path_cache); $root_path = waConfig::get('wa_path_root'); foreach ($this->urls as $url) { if (!isset($url['skipped']) || !$url['skipped']) { $path_cache = $root_path . '/' . $url['target'] . '/js/compiled'; waFiles::delete($path_cache, true); } } $model->ping(); $this->getConfig()->setCount(false); $response = $this->getResponse(); $response->addHeader('Content-Type', 'application/json; charset=utf-8'); $response->sendHeaders(); } catch (Exception $ex) { $this->setError($ex->getMessage()); } if ($ob = ob_get_clean()) { $this->response['warning'] = $ob; waLog::log('Output at ' . __METHOD__ . ': ' . $ob); } } else { throw new Exception('nothing to update'); } }
function execute() { if (!$this->extras_type && preg_match('/^installer(\\w+)RemoveAction$/', get_class($this), $matches)) { $this->extras_type = strtolower($matches[1]); } $module = $this->extras_type; $url = parse_url(waRequest::server('HTTP_REFERER'), PHP_URL_QUERY); if (preg_match("/(^|&)module=(update|apps| {\n {$this->extras_type}})(\$|&)/", $url, $matches)) { $module = $matches[2]; } $extras_ids = waRequest::get('extras_id'); try { /* _w('Application themes not found'); _w('Application plugins not found'); */ //$message = sprintf('Application %s not found', $this->extras_type); //throw new waException(_w($message)); if (installerHelper::isDeveloper()) { /* _w("Unable to delete application's themes (developer version is on)"); _w("Unable to delete application's plugins (developer version is on)"); */ $message = "Unable to delete application's {$this->extras_type} (developer version is on)"; throw new waException(_w($message)); } $vendors = array(); foreach ($extras_ids as $extras_id => &$info) { if (!is_array($info)) { $info = array('vendor' => $info); } $vendors[] = $info['vendor']; unset($info); } $vendors = array_unique($vendors); $locale = wa()->getLocale(); $this->installer = new waInstallerApps(null, $locale); $app_list = $this->installer->getApplicationsList(true); $deleted_extras = array(); foreach ($app_list as $app) { if (isset($app['extras']) && $app['extras'] && isset($app['extras'][$this->extras_type]) && $app['extras'][$this->extras_type]) { foreach ($app['extras'][$this->extras_type] as $extras_id => $info) { $slug = $info['slug']; if (isset($extras_ids[$slug]) && $extras_ids[$slug]['vendor'] == $info['current']['vendor']) { if (isset($info['system']) && $info['system']) { /* _w("Can not delete system application's themes \"%s\""); _w("Can not delete system application's plugins \"%s\""); */ $message = "Can not delete system application's {$this->extras_type} \"%s\""; throw new waException(sprintf(_w($message), $info['name'])); } if ($this->removeExtras($app['slug'], $extras_id, $info)) { $deleted_extras[] = "{$info['name']} ({$app['name']})"; } unset($extras_ids[$slug]); } } } } foreach ($extras_ids as $slug => $data) { if (preg_match('@^wa-plugins/([^/]+/[^/]+)$@', $slug, $matches)) { $path = wa()->getConfig()->getPath('plugins') . '/' . $matches[1]; $info_path = $path . '/lib/config/plugin.php'; if (file_exists($info_path) && ($info = (include $info_path))) { waFiles::delete($path, true); $deleted_extras[] = empty($info['name']) ? $matches[1] : $info['name']; } } } if (!$deleted_extras) { $message = sprintf('Application %s not found', $this->extras_type); throw new waException(_w($message)); } /* _w('Application plugin %s has been deleted', 'Applications plugins %s have been deleted'); _w('Application theme %s has been deleted', 'Applications themes %s have been deleted'); */ $message_singular = sprintf('Application %s %%s has been deleted', preg_replace('/s$/', '', $this->extras_type)); $message_plural = sprintf('Applications %a %%s have been deleted', $this->extras_type); $message = sprintf(_w($message_singular, $message_plural, count($deleted_extras), false), implode(', ', $deleted_extras)); $msg = installerMessage::getInstance()->raiseMessage($message); $this->redirect(array('module' => $module, 'msg' => $msg)); } catch (Exception $ex) { $msg = installerMessage::getInstance()->raiseMessage($ex->getMessage(), installerMessage::R_FAIL); $this->redirect(array('module' => $module, 'msg' => $msg)); } }
public function execute() { $filter = array(); $filter['enabled'] = true; $filter['extras'] = 'themes'; $options = array('installed' => true); $applications = installerHelper::getInstaller()->getApps($options, $filter); $search = array(); $search['slug'] = array($app_id = waRequest::get('slug')); $search['slug'] = array_unique($search['slug']); $search['vendor'] = waRequest::get('vendor', 'webasyst'); $installer = installerHelper::getInstaller(); $options = array('local' => true, 'apps' => true, 'filter' => (array) waRequest::get('filter'), 'inherited' => array_keys($applications)); $list = $installer->getExtras($search['slug'], 'themes', $options); /** * @var $themes waTheme[] */ $themes = array(); $inherited = array(); foreach ($list as $id => $item_list) { if (!empty($item_list['themes'])) { foreach ($item_list['themes'] as $theme_id => $theme) { if ($id == $app_id || !empty($theme['inherited'][$app_id])) { $themes[$theme_id] = new waTheme($theme_id, $app_id, true, true); $themes[$theme_id]['name'] = empty($theme['name']) ? $theme_id : $theme['name']; $themes[$theme_id]['description'] = empty($theme['description']) ? '' : $theme['description']; if (!empty($theme['price'])) { $themes[$theme_id]['price'] = $theme['price']; } if (!empty($theme['compare_price'])) { $themes[$theme_id]['compare_price'] = $theme['compare_price']; } if (isset($theme['commercial'])) { $themes[$theme_id]['commercial'] = $theme['commercial']; } if (!empty($theme['icon'])) { $themes[$theme_id]['cover'] = $theme['icon']; } if (!isset($inherited[$theme_id])) { $inherited[$theme_id] = array(); } if (!empty($theme['inherited'])) { $inherited[$theme_id] = array_merge($inherited[$theme_id], $theme['inherited']); } if (!isset($inherited[$theme_id][$id])) { $inherited[$theme_id][$id] = array('slug' => $id . '/themes/' . $theme_id); } } else { if (!isset($inherited[$theme_id])) { $inherited[$theme_id] = array(); } if (!empty($theme['inherited'])) { $inherited[$theme_id] = array_merge($inherited[$theme_id], $theme['inherited']); } } } } } foreach ($themes as $theme_id => &$theme) { $theme['inherited'] = $inherited[$theme_id]; unset($theme); } $app = $installer->getItemInfo($app_id); $this->view->assign('themes', $themes); $this->view->assign('app_id', $app_id); $this->view->assign('app', $app); $this->view->assign('slug', $search['slug']); $this->view->assign('vendor', $search['vendor']); $return_url = waRequest::get('return_url', waRequest::server('HTTP_REFERER')); if ($return_hash = waRequest::get('return_hash')) { if ($return_hash = preg_replace('@^#@', '', $return_hash)) { $return_url .= '#' . $return_hash; } } $this->view->assign('return_url', $return_url); }
public function execute() { $module = 'update'; $url = parse_url(waRequest::server('HTTP_REFERER'), PHP_URL_QUERY); if (preg_match('/(^|&)module=(update|apps|plugins)($|&)/', $url, $matches)) { $module = $matches[2]; } try { $updater = new waInstaller(waInstaller::LOG_TRACE); $state = $updater->getState(); if (!isset($state['stage_status']) || $state['stage_name'] != waInstaller::STAGE_NONE && $state['heartbeat'] > waInstaller::TIMEOUT_RESUME + 5 || $state['stage_name'] == waInstaller::STAGE_UPDATE && $state['heartbeat'] || $state['stage_status'] == waInstaller::STATE_ERROR && $state['heartbeat'] || $state['stage_name'] == waInstaller::STAGE_NONE && $state['heartbeat'] === false) { $updater->setState(); $this->view->assign('action', 'update'); $app_ids = waRequest::request('app_id'); $default_info = array('vendor' => waInstallerApps::VENDOR_SELF, 'edition' => ''); $vendors = array(); if ($app_ids && is_array($app_ids)) { foreach ($app_ids as $app_id => &$info) { if (!is_array($info)) { if (strpos($info, ':') === false) { $vendor = $info; $edition = ''; } else { list($vendor, $edition) = explode(':', $info, 2); } $info = array('vendor' => $vendor, 'edition' => $edition); } else { $info = array_merge($info, $default_info); } $vendors[] = $info['vendor']; unset($info); } } else { $app_ids = array(); } $vendors = array_unique($vendors); if (!$vendors) { $vendors = array(); } $model = new waAppSettingsModel(); $license = $model->get('webasyst', 'license', false); $locale = wa()->getLocale(); $apps = new waInstallerApps($license, $locale); $app_list = $vendors ? $apps->getApplicationsList(false, $vendors) : array(); $model->ping(); $queue_apps = array(); foreach ($app_list as &$info) { $app_id = $info['slug']; if ($app_id == 'installer') { $info['name'] = _w('Webasyst Framework'); } if (isset($app_ids[$app_id])) { if (installerHelper::equals($app_ids[$app_id], $info)) { $queue_apps[] = $info; } } if (!empty($info['extras'])) { foreach ($info['extras'] as $type => &$extras) { foreach ($extras as $extra_id => &$extras_info) { $extras_id = $extras_info['slug']; $extras_info['name'] .= " ({$info['name']})"; if (isset($app_ids[$extras_id]) && installerHelper::equals($app_ids[$extras_id], $extras_info)) { $queue_apps[] = $extras_info; } } unset($extras_info); } unset($extras); } unset($info); } $system_list = $apps->getSystemList(); foreach ($system_list as $item) { if (!empty($item['subject']) && $item['subject'] == 'systemplugins' && isset($app_ids[$item['slug']])) { $queue_apps[] = $item; } } if (!$queue_apps) { throw new waException(_w('Please select items for update')); } $this->view->assign('queue_apps', $queue_apps); $this->view->assign('apps', $app_list); $this->view->assign('install', waRequest::request('install')); $this->view->assign('title', _w('Updates')); } else { $this->redirect(array('module' => $module, 'msg' => installerMessage::getInstance()->raiseMessage(_w('Update is already in progress. Please wait while previous update session is finished before starting update session again.'), 'fail'))); } } catch (Exception $ex) { $this->redirect(array('module' => $module, 'msg' => installerMessage::getInstance()->raiseMessage($ex->getMessage(), installerMessage::R_FAIL))); } }
public static function getUpdates($vendor = null) { static $items = null; $config = wa('installer')->getConfig(); if ($items === null) { self::$counter = array('total' => 0, 'applicable' => 0, 'payware' => 0); $app_settings_model = new waAppSettingsModel(); $errors = (array) json_decode($app_settings_model->get('installer', 'errors', '[]')); $items = self::getInstaller()->getUpdates($vendor); $changed = false; foreach ($items as $id => $item) { if (isset($item['version'])) { ++self::$counter['total']; if (!empty($item['applicable'])) { ++self::$counter['applicable']; } } if (!empty($item['error'])) { if (!$errors) { $model = new waAnnouncementModel(); $data = array('app_id' => 'installer', 'text' => $item['error'], 'datetime' => date('Y-m-d H:i:s', time() - 86400)); if (!$model->select('COUNT(1) `cnt`')->where('app_id=s:app_id AND datetime > s:datetime', $data)->fetchField('cnt')) { $data['datetime'] = date('Y-m-d H:i:s'); $model->insert($data); } } $errors[$id] = true; $changed = true; } elseif (!empty($errors[$id])) { unset($errors[$id]); $changed = true; } foreach (array('themes', 'plugins') as $extras) { if (isset($item[$extras])) { self::$counter['total'] += count($item[$extras]); foreach ($item[$extras] as $extras_item) { if (!empty($extras_item['applicable'])) { ++self::$counter['applicable']; } } } } } if ($changed) { $app_settings_model->ping(); $app_settings_model->set('installer', 'errors', json_encode($errors)); } if ($errors) { $count = '!'; } elseif (self::$counter['total']) { $count = self::$counter['total']; } else { $count = null; } $config->setCount($count); } return $items; }
public function execute() { $this->init(); try { $updater = new waInstaller(waInstaller::LOG_TRACE); $state = $updater->getState(); if (!isset($state['stage_status']) || $state['stage_name'] != waInstaller::STAGE_NONE && $state['heartbeat'] > waInstaller::TIMEOUT_RESUME + 5 || $state['stage_name'] == waInstaller::STAGE_UPDATE && $state['heartbeat'] || $state['stage_status'] == waInstaller::STATE_ERROR && $state['heartbeat'] || $state['stage_name'] == waInstaller::STAGE_NONE && $state['heartbeat'] === false) { $updater->setState(); $state = $updater->getState(); $apps = installerHelper::getInstaller(); $items = $apps->getUpdates(null, $this->getItemsList()); $queue_apps = array(); $execute_actions = array(waInstallerApps::ACTION_INSTALL, waInstallerApps::ACTION_CRITICAL_UPDATE, waInstallerApps::ACTION_UPDATE); foreach ($items as $app_id => $info) { if (!empty($info['download_url']) && in_array($info['action'], $execute_actions)) { $info['subject'] = 'app'; if ($app_id == 'installer') { foreach ($info['download_url'] as $target => $url) { $_info = $info; $_info['download_url'] = $url; $_info['name'] = _w('Webasyst Framework') . ' (' . $target . ')'; $this->add($target, $_info); $queue_apps[$target] = $_info; unset($_info); } } else { $target = 'wa-apps/' . $app_id; $this->add($target, $info, $app_id); $queue_apps[$target] = $info; } } foreach (array('themes', 'plugins') as $type) { if (!empty($info[$type]) && is_array($info[$type])) { foreach ($info[$type] as $extra_id => $extras_info) { if (!empty($extras_info['download_url']) && in_array($extras_info['action'], $execute_actions)) { $extras_info['subject'] = 'app_' . $type; if ($type == 'themes' && is_array($extras_info['download_url'])) { foreach ($extras_info['download_url'] as $target => $url) { $__info = $extras_info; $__info['download_url'] = $url; $__info['slug'] = preg_replace('@^wa-apps/@', '', $target); $__info['app'] = preg_replace('@^wa-apps/([^/]+)/.+$@', '$1', $target); if (!isset($queue_apps[$target])) { if ($__info['app'] == $app_id || empty($items[$__info['app']][$type][$extra_id])) { if (!empty($items[$__info['app']][$type][$extra_id]['name'])) { $__info['name'] .= " ({$info['name']})"; } elseif ($app_info = wa()->getAppInfo($__info['app'])) { $__info['name'] .= " ({$app_info['name']})"; } else { $__info['name'] .= " ({$__info['app']})"; } $this->add($target, $__info); $queue_apps[$target] = $__info; } } } } else { if (!empty($info['name'])) { $extras_info['name'] .= " ({$info['name']})"; } if (strpos($app_id, '/')) { //system plugins $target = $app_id . '/' . $extra_id; } else { $target = 'wa-apps/' . $app_id . '/' . $type . '/' . $extra_id; } $this->add($target, $extras_info, $target); $queue_apps[$target] = $extras_info; } } } } } unset($info); } if (!$queue_apps) { throw new waException(_w('Please select items for update')); } if (!waRequest::get('_')) { $this->setLayout(new installerBackendLayout()); $this->getLayout()->assign('no_ajax', true); } $this->view->assign('action', 'update'); $this->view->assign('queue_apps', $queue_apps); $install = waRequest::request('install'); $this->view->assign('install', !empty($install) ? 'install' : ''); $this->view->assign('title', _w('Updates')); $this->view->assign('thread_id', $state['thread_id']); $this->view->assign('return_url', waRequest::post('return_url')); $cache = new waSerializeCache($this->getApp() . '.' . $state['thread_id']); $cache->set($this->urls); } else { $msg = _w('Update is already in progress. Please wait while previous update session is finished before starting update session again.'); $this->redirect(array('module' => $this->module, 'msg' => installerMessage::getInstance()->raiseMessage($msg, installerMessage::R_FAIL))); } } catch (Exception $ex) { $this->redirect(array('module' => $this->module, 'msg' => installerMessage::getInstance()->raiseMessage($ex->getMessage(), installerMessage::R_FAIL))); } }
private function cleanup() { $apps = array(); foreach ($this->urls as $url) { if (!isset($url['skipped']) || !$url['skipped']) { if (preg_match('@^wa-apps/[^/]+$@', $url['target'])) { $apps[] = array('installed' => true, 'slug' => $url['target']); } } } installerHelper::flushCache($apps); $this->model->ping(); }
function execute() { $module = 'apps'; $url = parse_url(waRequest::server('HTTP_REFERER'), PHP_URL_QUERY); if (preg_match('/(^|&)module=(update|apps|plugins)($|&)/', $url, $matches)) { $module = $matches[2]; } $app_ids = waRequest::get('app_id'); try { if (!$app_ids || !is_array($app_ids)) { throw new waException(_w('Application not found')); } $vendors = array(); foreach ($app_ids as $app_id => &$info) { if (!is_array($info)) { $info = array('vendor' => $info); } $vendors[] = $info['vendor']; unset($info); } $vendors = array_unique($vendors); $apps = new waInstallerApps(); $app_list = $apps->getApplicationsList(true, $vendors); $deleted_apps = array(); if (installerHelper::isDeveloper()) { throw new waException(_w('Unable to delete application (developer version is on)')); } foreach ($app_list as $info) { $app_id = $info['slug']; if (isset($app_ids[$app_id]) && $app_ids[$app_id]['vendor'] == $info['vendor']) { if (isset($info['system']) && $info['system']) { throw new waException(sprintf(_w('Can not delete system application "%s"'), $info['name'])); } $apps->updateRoutingConfig($app_id, false); $apps->updateAppConfig($app_id, null); //remove db tables and etc $paths = array(); $app_instance = waSystem::getInstance($app_id); $plugins = $app_instance->getConfig()->getPlugins(); foreach ($plugins as $plugin_id => $plugin) { if ($plugin && ($plugin_instance = $app_instance->getPlugin($plugin_id))) { $plugin_instance->uninstall(); } $apps->updateAppPluginsConfig($app_id, $plugin_id, null); //wa-apps/$app_id/plugins/$slug $paths[] = wa()->getAppPath("plugins/{$plugin_id}", $app_id); foreach ($paths as $path) { waFiles::delete($path, true); } $paths = array(); } $app_instance->getConfig()->uninstall(); //XXX called at uninstall //$paths[] = wa()->getAppCachePath(null, $app_id);//wa-cache/apps/$app_id/ $paths[] = wa()->getTempPath(null, $app_id); //wa-cache/temp/$app_id/ $paths[] = wa()->getAppCachePath(null, $app_id); //wa-cache/apps/$app_id/ $paths[] = wa()->getDataPath(null, true, $app_id); //wa-data/public/$app_id/ $paths[] = wa()->getDataPath(null, false, $app_id); //wa-data/protected/$app_id/ //XXX uncomplete code //$paths[] = wa()-> null, false, $app_id);//wa-log/$app_id/ //XXX uncomplete code //$paths[] = wa()->getAppPath(null, $app_id);//wa-config/$app_id/ $paths[] = wa()->getAppPath(null, $app_id); //wa-apps/$app_id/ foreach ($paths as $path) { waFiles::delete($path, true); } $deleted_apps[] = $info['name']; } } if (!$deleted_apps) { throw new waException(_w('Application not found')); } $message = _w('Application %s has been deleted', 'Applications %s have been deleted', min(2, count($deleted_apps)), false); $message = sprintf($message, implode(', ', $deleted_apps)); $msg = installerMessage::getInstance()->raiseMessage($message); $this->redirect(array('module' => $module, 'msg' => $msg)); } catch (Exception $ex) { $msg = installerMessage::getInstance()->raiseMessage($ex->getMessage(), installerMessage::R_FAIL); $this->redirect(array('module' => $module, 'msg' => $msg)); } }
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')); }
public function execute() { $this->init(); $extras_ids = waRequest::post('extras_id'); try { /* _w('Application themes not found'); _w('Application plugins not found'); */ foreach ($extras_ids as &$info) { if (!is_array($info)) { $info = array('vendor' => $info); } unset($info); } $options = array('installed' => true, 'local' => true); if ($this->extras_type == 'plugins') { $options['system'] = true; } $this->installer = installerHelper::getInstaller(); $app_list = $this->installer->getItems($options); $queue = array(); foreach ($extras_ids as $slug => $info) { $slug_chunks = explode('/', $slug); if ($slug_chunks[0] == 'wa-plugins') { $app_id = $slug_chunks[0] . '/' . $slug_chunks[1]; } else { $app_id = reset($slug_chunks); } if (isset($app_list[$app_id]) || $slug_chunks == 'wa-plugins') { $app = $app_list[$app_id]; if (($installed = $this->installer->getItemInfo($slug, $options)) && $info['vendor'] == $installed['vendor']) { if (!empty($installed['installed']['system'])) { /* _w("Can not delete system application's themes \"%s\""); _w("Can not delete system application's plugins \"%s\""); */ $message = "Can not delete system application's {$this->extras_type} \"%s\""; throw new waException(sprintf(_w($message), _wd($slug, isset($info['name']) ? $info['name'] : '???'))); } $queue[] = array('app_slug' => $app_id, 'ext_id' => $installed['id'], 'name' => sprintf("%s (%s)", _wd($slug, $installed['installed']['name']), _wd($app_id, $app['name']))); unset($extras_ids[$slug]); } } } $deleted_extras = array(); foreach ($queue as $q) { if ($this->removeExtras($q['app_slug'], $q['ext_id'])) { $deleted_extras[] = $q['name']; } } if (!$deleted_extras) { $message = sprintf('Application %s not found', $this->extras_type); throw new waException(_w($message)); } /* _w('Application plugin %s has been deleted', 'Applications plugins %s have been deleted'); _w('Application theme %s has been deleted', 'Applications themes %s have been deleted'); */ $message_singular = sprintf('Application %s %%s has been deleted', preg_replace('/s$/', '', $this->extras_type)); $message_plural = sprintf('Applications %a %%s have been deleted', $this->extras_type); $message = sprintf(_w($message_singular, $message_plural, count($deleted_extras), false), implode(', ', $deleted_extras)); $msg = installerMessage::getInstance()->raiseMessage($message); $this->redirect('?msg=' . $msg . '#/' . $this->extras_type . '/'); } catch (Exception $ex) { $msg = installerMessage::getInstance()->raiseMessage($ex->getMessage(), installerMessage::R_FAIL); $this->redirect('?msg=' . $msg . '#/' . $this->extras_type . '/'); } }