本文整理汇总了PHP中waAppSettingsModel::ping方法的典型用法代码示例。如果您正苦于以下问题:PHP waAppSettingsModel::ping方法的具体用法?PHP waAppSettingsModel::ping怎么用?PHP waAppSettingsModel::ping使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类waAppSettingsModel
的用法示例。
在下文中一共展示了waAppSettingsModel::ping方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSystemPlugins
public static function getSystemPlugins(&$messages, &$update_counter = null, $filter = array())
{
if ($update_counter !== null) {
$update_counter = is_array($update_counter) ? array_merge(array_fill_keys(array('total', 'applicable', 'payware'), 0), $update_counter) : intval($update_counter);
}
$items = self::getInstaller()->getSystemList();
$types = array();
$icons = array('sms' => 'icon16 mobile', 'payment' => 'icon16 dollar', 'shipping' => 'icon16 box');
$translate = array('sms' => _w('SMS'), 'payment' => _w('Payment'), 'shipping' => _w('Shipping'));
foreach ($items as $id => $item) {
if (!empty($item['subject']) && $item['subject'] == 'systemplugins') {
$t = $item['type_slug'];
if (empty($types[$t])) {
$types[$t] = array('name' => isset($translate[$t]) ? $translate[$t] : null, 'icon' => isset($icons[$t]) ? $icons[$t] : null, 'plugins' => array());
}
$types[$t]['plugins'][$item['id']] = $item;
}
}
$minimize = is_array($update_counter) ? true : false;
foreach ($types as &$items) {
if ($update_counter !== null) {
$update_counter = waInstallerApps::getUpdateCount($items['plugins'], $minimize, $update_counter);
self::$model->ping();
}
}
self::$model->ping();
unset($items);
return $types;
}
示例2: setCount
public function setCount($n = null)
{
wa()->getStorage()->open();
$model = new waAppSettingsModel();
$model->ping();
$app_id = $this->getApplication();
$model->set($app_id, 'update_counter', $n);
$model->set($app_id, 'update_counter_timestamp', $n === false ? 0 : time());
parent::setCount($n);
}
示例3: cleanup
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();
}
示例4: execute
public function execute()
{
$update_counter = 0;
$model = new waAppSettingsModel();
$license = $model->get('webasyst', 'license', false);
$apps = new waInstallerApps($license);
$app_list = array();
$this->view->assign('error', false);
try {
$app_list = $apps->getApplicationsList(false, array(), wa()->getDataPath('images', true));
$update_counter = waInstallerApps::getUpdateCount($app_list);
$model->ping();
} catch (Exception $ex) {
//$this->view->assign('error', $ex->getMessage());
}
$this->redirect(array('module' => $update_counter ? 'update' : 'apps'));
$this->view->assign('module', false);
}
示例5: onCount
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;
}
示例6: execute
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)));
}
}
示例7: execute
public function execute()
{
$model = new waAppSettingsModel();
$settings = array('name' => 'Webasyst', 'url' => wa()->getRootUrl(true), 'auth_form_background' => null, 'auth_form_background_stretch' => 1, 'locale' => 'ru_RU', 'email' => '', 'rememberme' => 1);
$config_settings = array('debug' => 'boolean');
$flush_settings = array('debug');
$config_path = waSystem::getInstance()->getConfigPath() . '/config.php';
$config = file_exists($config_path) ? include $config_path : array();
if (!is_array($config)) {
$config = array();
}
$changed = false;
$flush = false;
$message = array();
try {
$messages = installerMessage::getInstance()->handle(waRequest::get('msg'));
foreach ($settings as $setting => &$value) {
if (waRequest::post() && !in_array($setting, array('auth_form_background'))) {
$post_value = waRequest::post($setting, '', 'string_trim');
if (!is_null($post_value)) {
$model->set('webasyst', $setting, $post_value);
$changed = true;
} elseif (!is_null($value)) {
$model->set('webasyst', $setting, '');
}
$value = $model->get('webasyst', $setting, $value);
} else {
$value = $model->get('webasyst', $setting, $value);
}
unset($value);
}
$config_changed = false;
if (waRequest::post()) {
$config_values = waRequest::post('config');
if (!is_array($config_values)) {
$config_values = array();
}
foreach ($config_settings as $setting => $type) {
$value = isset($config_values[$setting]) ? $config_values[$setting] : false;
switch ($type) {
case 'boolean':
$value = $value ? true : false;
break;
}
if (!isset($config[$setting]) || $config[$setting] !== $value) {
$config[$setting] = $value;
$config_changed = true;
if (in_array($setting, $flush_settings)) {
$flush = true;
}
}
}
if ($config_changed) {
waUtils::varExportToFile($config, $config_path);
}
if ($flush) {
$path_cache = waConfig::get('wa_path_cache');
waFiles::delete($path_cache, true);
waFiles::protect($path_cache);
}
$model->ping();
}
if ($changed || $config_changed) {
$message[] = '[`Settings saved`]';
}
$name = preg_replace('/\\?.*$/', '', $settings['auth_form_background']);
$path = wa()->getDataPath($name, true, 'webasyst');
$file = waRequest::file('auth_form_background');
if ($file->uploaded()) {
if ($name) {
waFiles::delete(wa()->getDataPath($name, true, 'webasyst'));
$model->set('webasyst', 'auth_form_background', false);
$settings['auth_form_background'] = false;
}
$ext = 'png';
if (preg_match('/\\.(png|gif|jpg|jpeg|bmp|tif)$/i', $file->name, $matches)) {
$ext = $matches[1];
}
$name = 'auth_form_background.' . $ext;
$path = wa()->getDataPath($name, true, 'webasyst');
try {
$image = $file->waImage();
} catch (waException $ex) {
$message = $ex->getMessage();
$tmp_name = $file->tmp_name;
if (!preg_match('//u', $tmp_name)) {
$tmp_name = iconv('windows-1251', 'utf-8', $tmp_name);
}
if (strpos($message, $tmp_name) !== false) {
throw new waException(preg_replace('/:\\s*$/', '', str_replace($tmp_name, '', $message)));
}
throw $ex;
}
$file->copyTo($path);
//$image->save($path);
$name .= '?' . time();
$model->set('webasyst', 'auth_form_background', $name);
$settings['auth_form_background'] = $name;
$message[] = '[`Image uploaded`]';
$image_info = get_object_vars($image);
//.........这里部分代码省略.........
示例8: getUpdates
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;
}
示例9: execute
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}";
//.........这里部分代码省略.........
示例10: execute
public function execute()
{
$model = new waAppSettingsModel();
$settings = array('name' => 'Webasyst', 'url' => wa()->getRootUrl(true), 'auth_form_background' => 'stock:bokeh_vivid.jpg', 'auth_form_background_stretch' => 1, 'locale' => 'ru_RU', 'email' => '', 'sender' => '', 'rememberme' => 1);
$config_settings = array('debug' => 'boolean');
$flush_settings = array('debug');
$config_path = waSystem::getInstance()->getConfigPath() . '/config.php';
$images_path = wa()->getDataPath(null, true, 'webasyst');
$config = file_exists($config_path) ? include $config_path : array();
if (!is_array($config)) {
$config = array();
}
$images = array();
$changed = false;
$flush = false;
$message = array();
try {
foreach ($settings as $setting => &$value) {
if (waRequest::post() && !in_array($setting, array('auth_form_background'))) {
$post_value = waRequest::post($setting, '', waRequest::TYPE_STRING_TRIM);
if (!is_null($post_value)) {
$model->set('webasyst', $setting, $post_value);
$changed = true;
} elseif (!is_null($value)) {
$model->set('webasyst', $setting, '');
}
$value = $model->get('webasyst', $setting, $value);
} else {
$value = $model->get('webasyst', $setting, $value);
}
unset($value);
}
$config_changed = false;
if (waRequest::post()) {
$config_values = waRequest::post('config');
if (!is_array($config_values)) {
$config_values = array();
}
foreach ($config_settings as $setting => $type) {
$value = isset($config_values[$setting]) ? $config_values[$setting] : false;
switch ($type) {
case 'boolean':
$value = $value ? true : false;
break;
}
if (!isset($config[$setting]) || $config[$setting] !== $value) {
$config[$setting] = $value;
$config_changed = true;
if (in_array($setting, $flush_settings)) {
$flush = true;
}
}
}
if ($config_changed) {
waUtils::varExportToFile($config, $config_path);
}
if ($flush) {
$path_cache = waConfig::get('wa_path_cache');
waFiles::delete($path_cache, true);
waFiles::protect($path_cache);
}
$model->ping();
}
if ($changed || $config_changed) {
$message[] = '[`Settings saved`]';
}
$name = preg_replace('/\\?.*$/', '', $settings['auth_form_background']);
$path = wa()->getDataPath($name, true, 'webasyst');
$file = waRequest::file('auth_form_background');
$images = $this->getImages($images_path);
if ($file->uploaded()) {
if ($name) {
//waFiles::delete(wa()->getDataPath($name, true, 'webasyst'));
$model->set('webasyst', 'auth_form_background', false);
$settings['auth_form_background'] = false;
}
$ext = 'png';
if (preg_match('/\\.(png|gif|jpg|jpeg|bmp|tif)$/i', $file->name, $matches)) {
$ext = $matches[1];
}
$name = 'auth_form_background.' . $ext;
$path = wa()->getDataPath($name, true, 'webasyst');
try {
$image = $file->waImage();
} catch (waException $ex) {
$message = $ex->getMessage();
$tmp_name = $file->tmp_name;
if (!preg_match('//u', $tmp_name)) {
$tmp_name = iconv('windows-1251', 'utf-8', $tmp_name);
}
if (strpos($message, $tmp_name) !== false) {
throw new waException(preg_replace('/:\\s*$/', '', str_replace($tmp_name, '', $message)));
}
throw $ex;
}
foreach ($images as $i) {
waFiles::delete($images_path . '/' . $i);
}
$file->copyTo($path);
clearstatcache();
//.........这里部分代码省略.........