public function execute() { if ($this->thread_id = waRequest::get('thread_id', false)) { $cache = new waSerializeCache($this->getApp() . '.' . $this->thread_id); $this->urls = $cache->get(); $cache->delete(); } if ($this->urls) { wa()->getStorage()->close(); ob_start(); try { $this->model = new waAppSettingsModel(); $log_level = waSystemConfig::isDebug() ? waInstaller::LOG_DEBUG : waInstaller::LOG_WARNING; $updater = new waInstaller($log_level, $this->thread_id); $this->getStorage()->close(); $updater->init(); $this->model->ping(); $storage = wa()->getStorage(); $storage->close(); $this->urls = $updater->update($this->urls); if (waRequest::request('install')) { $this->install(); } $this->response['sources'] = $this->getResult(); $this->response['current_state'] = $updater->getState(); $this->response['state'] = $updater->getFullState(waRequest::get('mode', 'apps')); //cleanup cache $this->cleanup(); //update themes foreach ($this->urls as $url) { if (preg_match('@(wa-apps/)?(.+)/themes/(.+)@', $url['slug'], $matches)) { try { $theme = new waTheme($matches[3], $matches[2]); $theme->update(); } catch (Exception $ex) { waLog::log(sprintf('Error during theme %s@%s update: %s', $matches[3], $matches[2], $ex->getMessage())); } } } //and again cleanup $this->cleanup(); $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'); } }
public function themeUpdateAction() { $theme_id = waRequest::get('theme'); $theme = new waTheme($theme_id); if (waRequest::method() == 'post') { if (!waRequest::post("parent_only")) { if (waRequest::post('reset')) { foreach (waRequest::post('reset') as $f) { $theme->revertFile($f); } } $theme->update(false); } if ($theme->parent_theme && $theme->parent_theme->type == waTheme::OVERRIDDEN) { if (waRequest::post('parent_reset')) { foreach (waRequest::post('parent_reset') as $f) { $theme->parent_theme->revertFile($f); } } $theme->parent_theme->update(false); } $this->displayJson(array()); } else { $theme_original = new waTheme($theme_id, true, 'original'); $data = array('theme' => $theme, 'theme_original_version' => $theme_original->version); if ($theme->parent_theme && $theme->version == $theme_original->version && $theme->parent_theme->type == waTheme::OVERRIDDEN) { $parent_theme_original = new waTheme($theme->parent_theme->id, $theme->parent_theme->app, 'original'); $data['theme_original_version'] = $parent_theme_original->version; $data['parent_only'] = true; } $this->display($data, $this->getConfig()->getRootPath() . '/wa-system/design/templates/ThemeUpdate.html'); } }