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 static function saveDomainsSettings($domains_settings) { $app_settings_model = new waAppSettingsModel(); $routing = wa()->getRouting(); $domains_routes = $routing->getByApp('shop'); $app_settings_model->set(shopPricePlugin::$plugin_id, 'domains_settings', json_encode($domains_settings)); $cache = new waSerializeCache('shopPricePlugin'); if ($cache && $cache->isCached()) { $cache->delete(); } }
public static function saveDomainsSettings($domains_settings) { $app_settings_model = new waAppSettingsModel(); $routing = wa()->getRouting(); $domains_routes = $routing->getByApp('shop'); foreach ($domains_routes as $domain => $routes) { foreach ($routes as $route) { $domain_route = md5($domain . '/' . $route['url']); foreach (shopOnestepPlugin::$default_settings['templates'] as $id => $template) { $tpl_full_path = $template['tpl_path'] . $domain_route . '_' . $template['tpl_name'] . '.' . $template['tpl_ext']; $template_path = wa()->getDataPath($tpl_full_path, $template['public'], 'shop', true); @unlink($template_path); if (empty($domains_settings[$domain_route]['templates'][$id]['reset_tpl'])) { $source_path = wa()->getAppPath($template['tpl_path'] . $template['tpl_name'] . '.' . $template['tpl_ext'], 'shop'); $source_content = file_get_contents($source_path); if (!isset($domains_settings[$domain_route]['templates'][$id]['template'])) { continue; } $post_template = $domains_settings[$domain_route]['templates'][$id]['template']; if (preg_replace('/\\s/', '', $source_content) != preg_replace('/\\s/', '', $post_template)) { $f = fopen($template_path, 'w'); if (!$f) { throw new waException('Не удаётся сохранить шаблон. Проверьте права на запись ' . $template_path); } fwrite($f, $post_template); fclose($f); } } } unset($domains_settings[$domain_route]['templates']); } } $app_settings_model->set(shopOnestepPlugin::$plugin_id, 'domains_settings', json_encode($domains_settings)); $cache = new waSerializeCache('shopOnestepPlugin'); if ($cache && $cache->isCached()) { $cache->delete(); } }
<?php $sqls = array(); $sqls[] = <<<SQL UPDATE `wa_app_settings` SET app_id = CONCAT('blog.', SUBSTR(name, 8, POSITION('.' IN SUBSTR(name, 8)) - 1)), name = SUBSTR(name, 8 + POSITION('.' IN SUBSTR(name, 8))) WHERE `app_id`= 'blog' AND `name` LIKE 'plugin.%' SQL; $model = new waModel(); foreach ($sqls as $sql) { try { $model->exec($sql); } catch (Exception $ex) { if (class_exists('waLog')) { waLog::log(basename(__FILE__) . ': ' . $ex->getMessage(), 'blog-update.log'); } } } $cache = new waSerializeCache('app_settings/blog', SystemConfig::isDebug() ? 600 : 86400, 'webasyst'); $cache->delete();
public function delete() { return $this->cache->delete(); }