protected function getPages() { $domain = siteHelper::getDomain(); $routing = wa()->getRouting(); $routes = $routing->getRoutes($domain); $page_model = new sitePageModel(); $pages = $page_model->select('id,name,url,status')->where('domain_id = ' . $this->domain_id)->order('sort')->fetchAll('id'); $pages_urls = array(); foreach ($pages as $page_id => $p) { $pages_urls[$page_id] = $p['url']; $pages[$page_id]['url'] = null; } foreach ($routes as $r_id => $r) { if (isset($r['app']) && $r['app'] == 'site' && strpos($r['url'], '<url') === false) { $u = $routing->getUrlByRoute($r); if (!isset($r['_exclude']) || !$r['_exclude']) { foreach ($pages_urls as $p_id => $p_url) { $pages[$p_id]['url'] = $u . $p_url; unset($pages_urls[$p_id]); } } else { foreach ($pages_urls as $p_id => $p_url) { if (!in_array($p_id, $r['_exclude'])) { $pages[$p_id]['url'] = $u . $p_url; unset($pages_urls[$p_id]); } } } } } return $pages; }
public function execute() { $app_id = waRequest::get('app_id'); $app = wa()->getAppInfo($app_id); $this->view->assign('items', $this->getItems($app_id)); $this->view->assign('app', $app); $domain = siteHelper::getDomain(); $routes = wa()->getRouting()->getByApp($app_id, $domain); if ($routes) { $event_params = array('app_id' => $app_id, 'routes' => $routes); $result = wa($app_id)->event(array($app_id, 'personal.settings'), $event_params); if (!empty($result[$app_id])) { $this->view->assign('personal_settings', $result[$app_id]); } $domain = siteHelper::getDomain(); $domain_config_path = $this->getConfig()->getConfigPath('domains/' . $domain . '.php'); if (file_exists($domain_config_path)) { $domain_config = (include $domain_config_path); } else { $domain_config = array(); } } $this->view->assign('domain_url', 'http://' . $domain); $this->view->assign('settled', $routes ? true : false); $this->view->assign('enabled', !isset($domain_config['personal'][$app_id]) || $domain_config['personal'][$app_id]); $this->template = wa()->getAppPath($this->getTemplate(), 'site'); }
public static function getDomainId() { if (!self::$domain_id) { $domain_id = waRequest::get('domain_id'); $domains = self::getDomains(true); if (is_numeric($domain_id)) { self::$domain_id = (int) $domain_id; } else { foreach ($domains as $d_id => $d) { if ($d['name'] == $domain_id) { self::$domain_id = $d_id; break; } } } if (!self::$domain_id) { self::$domain_id = wa()->getUser()->getSettings('site', 'last_domain_id'); if (!isset($domains[self::$domain_id])) { self::$domain_id = null; } } if (!self::$domain_id) { self::$domain_id = current(array_keys($domains)); } if (self::$domain_id && !isset($domains[self::$domain_id])) { throw new waException('Domain not found', 404); } } return self::$domain_id; }
public function execute() { $enabled = waRequest::post('enabled'); $app_id = waRequest::post('app_id'); $domain = siteHelper::getDomain(); $config = wa()->getConfig()->getAuth(); if (!isset($config[$domain])) { if (!$enabled) { return; } $config[$domain] = array(); } if ($enabled && $app_id) { $config[$domain]['auth'] = true; $config[$domain]['app'] = $app_id; } else { if (isset($config[$domain]['auth'])) { unset($config[$domain]['auth']); } if (isset($config[$domain]['app'])) { unset($config[$domain]['app']); } } if (!$this->getConfig()->setAuth($config)) { $this->errors = sprintf(_w('File could not be saved due to the insufficient file write permissions for the "%s" folder.'), 'wa-config/'); } }
protected function sortThemes($themes, $themes_routes) { $domain = 'http://' . siteHelper::getDomain(); $n = strlen($domain); // sort themes $result = array(); foreach ($themes_routes as $theme_id => $r) { $add = false; foreach ($r as $r_url => $r_title) { if (!strncasecmp($r_url, $domain, $n)) { $add = true; break; } } if ($add) { $result[$theme_id] = $themes[$theme_id]; } } foreach ($themes_routes as $theme_id => $r) { if (!isset($result[$theme_id])) { $result[$theme_id] = $themes[$theme_id]; } } foreach ($themes as $theme_id => $theme) { if (!isset($temp_themes[$theme_id])) { $result[$theme_id] = $theme; } } return $result; }
public function execute() { $path = $this->getConfig()->getPath('config', 'routing'); $all_routes = file_exists($path) ? include $path : array(); $domain = siteHelper::getDomain(); $route = waRequest::post('route'); $pos = waRequest::post('pos'); $result = array(); $i = 0; $routes = wa()->getRouting()->getRoutes($domain); $apps = wa()->getApps(); foreach ($routes as $k => $v) { if ($pos == $i) { $result[$route] = $routes[$route]; } if ($route != $k) { if (isset($v['app']) && isset($apps[$v['app']]) || isset($v['redirect'])) { $i++; } $result[$k] = $v; } } if ($pos == $i) { $result[$route] = $routes[$route]; } $all_routes[$domain] = $result; waUtils::varExportToFile($all_routes, $path); }
public function execute() { $path = wa()->getDataPath(null, true); $dirs = $this->getDirs($path); $this->view->assign('dirs', $dirs); $this->view->assign('domain', siteHelper::getDomain()); }
public function execute() { $route_id = waRequest::get('route'); $routes = wa()->getRouting()->getRoutes(siteHelper::getDomain()); if (!isset($routes[$route_id])) { throw new waException('Route not found', 404); } $route = $routes[$route_id]; $app_id = $routes[$route_id]['app']; $path = $this->getConfig()->getAppsPath($app_id, 'lib/config/site.php'); $app = wa()->getAppInfo($app_id); if (file_exists($path)) { // load locale of the app if ($app_id != 'site') { waSystem::getInstance($app_id)->setActive($app_id); } $app['site'] = (include $path); // return old locale of the site if ($app_id != 'site') { waSystem::setActive('site'); } } if (isset($app['site']['params'])) { $params = $this->getParams($route_id, $app['site']['params'], $route); } else { $params = array(); } $themes = siteHelper::getThemes($app_id); if (!isset($route['theme']) && $themes) { $route['theme'] = 'default'; } if (!isset($route['theme_mobile']) && $themes) { $route['theme_mobile'] = $route['theme']; } if (!isset($route['locale'])) { $route['locale'] = ''; } if (!isset($route['_name'])) { if ($app_id == 'site') { if ($title = siteHelper::getDomain('title')) { $route['_name'] = $title; } else { $app_settings_model = new waAppSettingsModel(); $route['_name'] = $app_settings_model->get('webasyst', 'name', 'Webasyst'); } } else { $route['_name'] = $app['name']; } } $this->view->assign('route_id', $route_id); $this->view->assign('route', $route); $this->view->assign('params', $params); $this->view->assign('app_id', $app_id); $this->view->assign('app', $app); $this->view->assign('domain_id', siteHelper::getDomainId()); $this->view->assign('domain', siteHelper::getDomain()); $this->view->assign('locales', array('' => _w('Auto')) + waLocale::getAll('name')); }
public function execute() { $domain = siteHelper::getDomain(); $config = wa()->getConfig()->getAuth(); if (!isset($config[$domain])) { $config[$domain] = array(); } if (waRequest::post('auth_captcha') !== null) { if (waRequest::post('auth_captcha')) { $config[$domain]['signup_captcha'] = true; } elseif (isset($config[$domain]['signup_captcha'])) { unset($config[$domain]['signup_captcha']); } } if (waRequest::post('auth_rememberme')) { $config[$domain]['rememberme'] = true; } elseif (isset($config[$domain]['rememberme'])) { unset($config[$domain]['rememberme']); } // save auth adapters if (waRequest::post('auth_adapters') && waRequest::post('adapter_ids')) { $config[$domain]['adapters'] = array(); $adapters = waRequest::post('adapters', array()); foreach (waRequest::post('adapter_ids') as $adapter_id) { $config[$domain]['adapters'][$adapter_id] = $adapters[$adapter_id]; } } else { if (isset($config[$domain]['adapters'])) { unset($config[$domain]['adapters']); } } // signup $fields = waRequest::post('fields'); $params = waRequest::post('params'); $must_have_fields = array('email', 'password'); $default_fields = array_merge(array('firstname', 'lastname', ''), $must_have_fields); $config[$domain]['params'] = $params; if (!$config[$domain]) { $config[$domain]['fields'] = $default_fields; } else { $config[$domain]['fields'] = array(); } foreach ($fields as $field_id => $field) { $config[$domain]['fields'][$field_id] = $field; } foreach ($must_have_fields as $field) { if (!in_array($field, array_keys($fields))) { $tmp = waContactFields::get($field); $config[$domain]['fields'][$field] = array('required' => true, 'caption' => $tmp->getName()); } else { $config[$domain]['fields'][$field]['required'] = true; } } // save to file if (!$this->getConfig()->setAuth($config)) { $this->errors = sprintf(_w('File could not be saved due to the insufficient file write permissions for the "%s" folder.'), 'wa-config/'); } }
public function execute() { $apps = wa()->getApps(); $auth_apps = array(); $routes = wa()->getRouting()->getRoutes(siteHelper::getDomain()); foreach ($routes as $route) { if (isset($route['app']) && isset($apps[$route['app']])) { $auth_apps[$route['app']] = true; } } $temp = array(); foreach ($apps as $app_id => $app) { if (isset($app['frontend'])) { $temp[$app_id] = array('id' => $app_id, 'icon' => $app['icon'], 'name' => $app['name']); if (isset($auth_apps[$app_id])) { if (empty($app['auth'])) { unset($auth_apps[$app_id]); } else { $auth_apps[$app_id] = $temp[$app_id]; } } } } $this->view->assign('auth_apps', $auth_apps); $auth_config = wa()->getAuthConfig(siteHelper::getDomain()); $this->view->assign('auth_config', array('auth' => isset($auth_config['auth']) ? $auth_config['auth'] : false, 'app' => isset($auth_config['app']) ? $auth_config['app'] : false, 'signup_captcha' => isset($auth_config['signup_captcha']) ? $auth_config['signup_captcha'] : false, 'adapters' => isset($auth_config['adapters']) ? $auth_config['adapters'] : array())); $this->view->assign('auth_adapters', $this->getAuthAdapters()); $this->view->assign('apps', $temp); $this->view->assign('domain_id', siteHelper::getDomainId()); $this->view->assign('domain', siteHelper::getDomain()); $s = siteHelper::getDomain('style'); $this->view->assign('style', $s ? $s : 'white'); $domain = siteHelper::getDomain(); $domain_config_path = $this->getConfig()->getConfigPath('domains/' . $domain . '.php'); if (file_exists($domain_config_path)) { $domain_config = (include $domain_config_path); } else { $domain_config = array(); } $u = parse_url('http://' . $domain); //$path = isset($u['path']) ? $u['path'] : ''; if (!isset($domain_config['apps']) || !$domain_config['apps']) { $this->view->assign('domain_apps_type', 0); $domain_name = !empty($domain_config['name']) ? $domain_config['name'] : null; $domain_config['apps'] = wa()->getFrontendApps($domain, $domain_name); } else { $this->view->assign('domain_apps_type', 1); } $this->view->assign('domain_apps', $domain_config['apps']); foreach (array('head_js', 'google_analytics') as $key) { $this->view->assign($key, isset($domain_config[$key]) ? $domain_config[$key] : ''); } $this->getStaticFiles($domain); $this->view->assign('url', $this->getDomainUrl($domain)); $this->view->assign('title', siteHelper::getDomain('title')); }
public function __construct($domain) { $this->domain = $domain; $this->path = wa()->getDataPath('data/' . siteHelper::getDomain() . '/', true, 'site') . 'robots.txt'; if (file_exists($this->path)) { $this->robots = file($this->path); } else { $this->robots = array(); } }
public function execute() { $plugin_id = 'convead'; $plugin = waSystem::getInstance()->getPlugin($plugin_id); $settings = $plugin->getSettings(); wa('site'); $domains = siteHelper::getDomains(true); $this->view->assign('domains', $domains); $this->view->assign('exist_curl', function_exists('curl_exec')); $this->view->assign('settings', $settings); }
protected function getRoutes() { $routes = wa()->getRouting()->getByApp($this->getAppId()); $result = array(); $d = siteHelper::getDomain(); if (isset($routes[$d])) { foreach ($routes[$d] as $route) { $result[$d . '/' . $route['url']] = array('route' => $route['url'], 'domain' => $d); } } return $result; }
public function execute() { $id = waRequest::get('id'); $model = new siteBlockModel(); $blocks = $model->order('sort')->fetchAll('id'); $apps = wa()->getApps(); foreach ($apps as $app_id => $app) { $path = $this->getConfig()->getAppsPath($app_id, 'lib/config/site.php'); if (file_exists($path)) { $site_config = (include $path); if (!empty($site_config['blocks'])) { foreach ($site_config['blocks'] as $block_id => $block) { if (!is_array($block)) { $block = array('content' => $block, 'description' => ''); } $block_id = $app_id . '.' . $block_id; if (!isset($blocks[$block_id])) { $block['id'] = $block_id; $block['app'] = $app; $blocks[$block_id] = $block; } else { if ($block_id == $id) { $blocks[$block_id]['original'] = $block['content']; } } } } } } foreach ($blocks as $block_id => $block) { if (empty($block['app'])) { if (($pos = strpos($block_id, '.')) !== false) { $app_id = substr($block_id, 0, $pos); if (isset($apps[$app_id])) { $blocks[$block_id]['app_icon'] = $apps[$app_id]['icon']; } } } } if ($id === false) { $id = key($blocks); } $this->view->assign('blocks', $blocks); if ($id && isset($blocks[$id])) { $block = $blocks[$id]; } else { $block = null; } $this->view->assign('block', $block); $this->view->assign('editor', true); $this->view->assign('domain_id', siteHelper::getDomainId()); }
public function execute() { $domain = siteHelper::getDomain(); $routes = wa()->getRouting()->getRoutes($domain); $apps = wa()->getApps(); foreach ($routes as $route_id => &$route) { if (isset($route['app']) && isset($apps[$route['app']])) { $auth_apps[$route['app']] = true; $route['app'] = $apps[$route['app']]; } } $this->view->assign(array('routes' => $routes, 'apps' => $apps, 'url' => $this->getDomainUrl($domain), 'domain_id' => siteHelper::getDomainId())); }
public function execute() { $path = $this->getConfig()->getPath('config', 'routing'); if (file_exists($path)) { $routes = (include $path); } else { $routes = array(); } $domain = siteHelper::getDomain(); $route_id = waRequest::get('route'); $other_params = waRequest::post('other_params', ''); $other_params = explode("\n", $other_params); $app_id = $routes[$domain][$route_id]['app']; if ($app_id == 'site') { if ($title = siteHelper::getDomain('title')) { $name = $title; } else { $app_settings_model = new waAppSettingsModel(); $name = $app_settings_model->get('webasyst', 'name', 'Webasyst'); } } else { $app = wa()->getAppInfo($app_id); $name = $app['name']; } $t = array('url' => $routes[$domain][$route_id]['url'], 'app' => $routes[$domain][$route_id]['app']); foreach ($routes[$domain][$route_id] as $k => $v) { if (substr($k, 0, 1) == '_') { $t[$k] = $routes[$domain][$route_id][$k]; } } $routes[$domain][$route_id] = $t; foreach ($other_params as $string) { $string = trim($string); if ($string && strpos($string, '=') !== false) { $string = explode('=', $string, 2); if ($string[0]) { $routes[$domain][$route_id][$string[0]] = $string[1]; } } } $params = waRequest::post('params', array()); foreach ($params as $key => $value) { if ($key != '_name' || $value != $name || isset($routes[$domain][$route_id]['_name']) && $value != $routes[$domain][$route_id]['_name']) { $routes[$domain][$route_id][$key] = $value; } } if (!$routes[$domain][$route_id]['locale']) { unset($routes[$domain][$route_id]['locale']); } waUtils::varExportToFile($routes, $path); }
public function execute() { $app_id = waRequest::post('app_id'); $enable = waRequest::post('enable'); $domain = siteHelper::getDomain(); $domain_config_path = wa('site')->getConfig()->getConfigPath('domains/' . $domain . '.php'); if (file_exists($domain_config_path)) { $domain_config = (include $domain_config_path); } else { $domain_config = array(); } $domain_config['personal'][$app_id] = $enable ? true : false; waUtils::varExportToFile($domain_config, $domain_config_path); }
public function execute() { $domain = siteHelper::getDomain(); $routes = wa()->getRouting()->getRoutes($domain); $route_id = waRequest::post('route'); if (isset($routes[$route_id])) { unset($routes[$route_id]); // save $path = $this->getConfig()->getPath('config', 'routing'); $all_routes = file_exists($path) ? include $path : array(); $all_routes[$domain] = $routes; waUtils::varExportToFile($all_routes, $path); $this->log('route_delete'); } }
protected function updatePagesRoute($route, $url) { $app = wa()->getAppInfo($route['app']); if (empty($app['pages'])) { return; } // init app wa($app['id']); $class = $app['id'] . 'PageModel'; /** * @var waPageModel $model */ $model = new $class(); $model->updateRoute(siteHelper::getDomain(), $route['url'], $url); }
protected function getRoutes() { $routes = wa()->getRouting()->getByApp($this->getAppId()); $result = array(); $domain = siteHelper::getDomain(); if (isset($routes[$domain])) { foreach (array_reverse($routes[$domain], true) as $route_id => $route) { $route['_id'] = $route_id; $route['_domain'] = $domain; $route['_url'] = waRouting::getUrlByRoute($route, $domain); $route['_url_title'] = $domain . '/' . waRouting::clearUrl($route['url']); $result[] = $route; } } return $result; }
public function execute() { $domain = siteHelper::getDomain(); $fields = array(); $default_fields = array('firstname' => true, 'lastname' => true, 'middlename' => true, 'email' => true, 'phone' => true, 'password' => true); $auth_config = wa()->getAuthConfig($domain); if (!empty($auth_config['app']) && $auth_config['app'] == 'shop') { $settings = wa('shop')->getConfig()->getCheckoutSettings(); if (!isset($settings['contactinfo'])) { $settings = wa('shop')->getConfig()->getCheckoutSettings(true); } if (!empty($settings['contactinfo']['fields'])) { $default_fields = array(); foreach ($settings['contactinfo']['fields'] as $field_id => $f) { $default_fields[$field_id] = true; } } } $domain_config_path = wa('site')->getConfig()->getConfigPath('domains/' . $domain . '.php'); if (file_exists($domain_config_path)) { $domain_config = (include $domain_config_path); } else { $domain_config = array(); } if (!isset($domain_config['personal_fields'])) { $domain_config['personal_fields'] = $default_fields; } if (!empty($auth_config['app']) && isset($domain_config['personal'][$auth_config['app']]) && !$domain_config['personal'][$auth_config['app']]) { $this->view->assign('profile_disabled', true); $this->view->assign('auth_app', wa()->getAppInfo($auth_config['app'])); } $contacts_fields = array('photo' => new waContactHiddenField('photo', _ws('Photo'))) + waContactFields::getAll('person', true) + array('password' => new waContactPasswordField('password', _ws('Password'))); foreach ($contacts_fields as $fiels_name => $field) { $name = $field->getName(); if ($name && $fiels_name !== 'name') { $fields[] = array('id' => $fiels_name, 'name' => $name, 'checked' => isset($domain_config['personal_fields'][$fiels_name]) && $domain_config['personal_fields'][$fiels_name] === true ? true : false); } } $this->view->assign('domain', $domain); $this->view->assign('fields', $fields); }
public function execute() { $domain = siteHelper::getDomain(); $routes = wa()->getRouting()->getRoutes($domain); $route_id = waRequest::post('route'); if (isset($routes[$route_id])) { if (isset($routes[$route_id]['app'])) { $robots = new siteRobots($domain); $robots->delete($routes[$route_id]['app'], $routes[$route_id]['url']); } unset($routes[$route_id]); // save $path = $this->getConfig()->getPath('config', 'routing'); $all_routes = file_exists($path) ? include $path : array(); $all_routes[$domain] = $routes; if (!waUtils::varExportToFile($all_routes, $path)) { $this->errors = sprintf(_w('Settings could not be saved due to the insufficient file write permissions for the file "%s".'), 'wa-config/routing.php'); } else { $this->logAction('route_delete'); } } }
public static function _get_app_key() { $plugin = wa('shop')->getPlugin('convead'); $settings = $plugin->getSettings(); wa('site'); foreach (siteHelper::getDomains(true) as $domain_id => $domain) { if (waRequest::server('SERVER_NAME') == $domain['name']) { break; } } if (isset($settings['options']) and isset($settings['options']['domains']) and !empty($settings['options']['domains'][$domain_id]) and !empty($settings['options']['domains'][$domain_id]['api_key'])) { return $settings['options']['domains'][$domain_id]['api_key']; } else { if (!empty($settings['options']['api_key'])) { return $settings['options']['api_key']; } else { return false; } } }
protected function saveRobots() { $path = wa()->getDataPath('data/' . siteHelper::getDomain() . '/', true); if ($robots = waRequest::post('robots')) { if (!file_exists($path) || !is_writable($path)) { $this->errors = sprintf(_w('File could not be saved due to the insufficient file write permissions for the "%s" folder.'), 'wa-data/public/site/data/' . siteHelper::getDomain()); } else { file_put_contents($path . 'robots.txt', $robots); } } elseif (file_exists($path . 'robots.txt')) { waFiles::delete($path . 'robots.txt'); } }
public function execute() { $apps = wa()->getApps(); $auth_apps = array(); $domain = siteHelper::getDomain(); $routes = wa()->getRouting()->getRoutes($domain); $auth_app_id = false; foreach ($routes as $route) { if (isset($route['app']) && isset($apps[$route['app']])) { $auth_apps[$route['app']] = true; $auth_app_id = $route['app']; } } $temp = array(); foreach ($apps as $app_id => $app) { if (isset($app['frontend']) || isset($auth_apps[$app_id])) { $temp[$app_id] = array('id' => $app_id, 'icon' => $app['icon'], 'name' => $app['name']); if (isset($auth_apps[$app_id])) { if (empty($app['auth'])) { unset($auth_apps[$app_id]); } else { $auth_apps[$app_id] = $temp[$app_id]; } } } } foreach ($auth_apps as $app_id => &$a) { $a['login_url'] = wa()->getRouteUrl($app_id . '/login', array('domain' => $domain), true); } unset($a); $this->view->assign('auth_apps', $auth_apps); $auth_config = wa()->getAuthConfig(siteHelper::getDomain()); $this->view->assign('auth_config', array('auth' => isset($auth_config['auth']) ? $auth_config['auth'] : false, 'app' => isset($auth_config['app']) ? $auth_config['app'] : $auth_app_id, 'signup_captcha' => isset($auth_config['signup_captcha']) ? $auth_config['signup_captcha'] : false, 'adapters' => isset($auth_config['adapters']) ? $auth_config['adapters'] : array())); $this->view->assign('auth_adapters', $this->getAuthAdapters()); $this->view->assign('apps', $temp); $this->view->assign('domain_id', siteHelper::getDomainId()); $domain = siteHelper::getDomain(); $personal_sidebar = wa('site')->event('backend_personal'); foreach ($personal_sidebar as &$items) { foreach ($items as &$item) { $item['url'] .= '&domain=' . urlencode($domain); } } $this->view->assign('domain', siteHelper::getDomain()); $this->view->assign('domain_id', siteHelper::getDomainId()); $this->view->assign('personal_sidebar', $personal_sidebar); // signup $fields = $enable_fields = array(); $must_have_fields = array('email', 'password'); $default_fields = array_merge(array('firstname', 'lastname', ''), $must_have_fields); $unset_fields = array('name'); // include auth.php $domain_config_path = wa('site')->getConfig()->getPath('config', 'auth'); if (file_exists($domain_config_path)) { $domain_config = (include $domain_config_path); } else { $domain_config = array(); } // fields for this form (or default fields) $config_fields = isset($domain_config[$domain]['fields']) ? $domain_config[$domain]['fields'] : $default_fields; $separators = 0; foreach ($config_fields as $field_name => $field) { $fld_name = is_array($field) ? $field_name : $field; $fld_name = strlen($fld_name) ? $fld_name : $separators++; if (!$fld_name) { // todo: don't skip separator continue; } $enable_fields[$fld_name] = $field; } $available_fields = waContactFields::getAll('person', true) + array('password' => new waContactPasswordField('password', 'Password')); foreach ($available_fields as $field_name => $field) { $name = $field->getName(); if ($name && !in_array($field_name, $unset_fields)) { $checked = array_key_exists($field_name, $enable_fields); $available_fields[$field_name] = array('id' => $field_name, 'name' => $name, 'checked' => $checked, 'disabled' => false); // only for 'must have' fields if (in_array($field_name, $must_have_fields)) { $available_fields[$field_name]['disabled'] = true; $available_fields[$field_name]['checked'] = true; // if we don't have 'must have' fields - let's add'em if (!array_key_exists($field_name, $enable_fields)) { $enable_fields[$field_name] = $available_fields[$field_name]; } } } else { unset($available_fields[$field_name]); } } $enable_fields = array_merge_recursive($enable_fields, $available_fields); $this->view->assign('domain', $domain); $this->view->assign('enable_fields', $enable_fields); $this->view->assign('available_fields', $available_fields); $this->view->assign('fields', $fields); $this->view->assign('params', isset($domain_config[$domain]['params']) ? $domain_config[$domain]['params'] : array()); }
protected function updatePagesRoute($route, $url) { $app = wa()->getAppInfo($route['app']); if (empty($app['pages'])) { return; } // init app wa($app['id']); $class = $app['id'] . 'PageModel'; /** * @var waPageModel $model */ $model = new $class(); $model->updateRoute(siteHelper::getDomain(), $route['url'], $url); $params = array('old' => siteHelper::getDomain() . '/' . $route['url'], 'new' => siteHelper::getDomain() . '/' . $url); wa()->event('update.route', $params); }
protected function getRoute($old = array()) { $params = waRequest::post('params', array()); if (!isset($params['redirect'])) { $app_id = $old ? $old['app'] : $params['app']; if ($app_id == 'site') { if ($title = siteHelper::getDomain('title')) { $name = $title; } else { $app_settings_model = new waAppSettingsModel(); $name = $app_settings_model->get('webasyst', 'name', 'Webasyst'); } } else { $app = wa()->getAppInfo($app_id); $name = $app['name']; } if ($old) { $r = array('url' => $old['url'], 'app' => $old['app']); } else { $r = array(); } foreach ($old as $k => $v) { if (substr($k, 0, 1) == '_') { $r[$k] = $old[$k]; } } $other_params = waRequest::post('other_params', ''); $other_params = explode("\n", $other_params); foreach ($other_params as $string) { $string = trim($string); if ($string && strpos($string, '=') !== false) { $string = explode('=', $string, 2); if ($string[0]) { $r[$string[0]] = $string[1]; } } } } else { if (isset($params['app'])) { unset($params['app']); } } foreach ($params as $key => $value) { if ($key != '_name' || isset($name) && $value != $name || isset($r['_name']) && $value != $r['_name']) { $r[$key] = $value; } } if (empty($r['locale'])) { unset($r['locale']); } return $r; }
public function execute() { $domain = siteHelper::getDomain(); $domain_config_path = $this->getConfig()->getConfigPath('domains/' . $domain . '.php'); if (file_exists($domain_config_path)) { $domain_config = (include $domain_config_path); } else { $domain_config = array(); } $apps_enabled = array(); $apps_disabled = array(); $apps_other = array(); $apps = wa()->getApps(); $routes = wa()->getRouting()->getRoutes($domain); $apps_routed = array(); foreach ($routes as $r) { if (!empty($r['app'])) { $apps_routed[$r['app']] = true; wa()->getRouting()->setRoute($r); $link = ''; $apps[$r['app']]['items'] = $this->getItems($r['app'], $link); $link = 'http://' . $domain . '/' . substr($link, strlen(wa()->getRootUrl())); $apps[$r['app']]['link'] = $link; if (!$apps[$r['app']]['items']) { unset($apps[$r['app']]); } } } foreach ($apps as $app_id => $app) { if (empty($app['my_account'])) { unset($apps[$app_id]); } else { $apps[$app_id]['items'] = $this->getItems($app_id); if (!$apps[$app_id]['items']) { unset($apps[$app_id]); } } } if (!empty($domain_config['personal'])) { foreach ($domain_config['personal'] as $app_id => $enabled) { if (isset($apps[$app_id]) && isset($apps_routed[$app_id])) { if ($enabled) { $apps_enabled[$app_id] = $apps[$app_id]; } else { $apps_disabled[$app_id] = $apps[$app_id]; } } } } foreach ($apps as $app_id => $app) { if (!isset($apps_disabled[$app_id])) { if (isset($apps_routed[$app_id])) { $apps_enabled[$app_id] = $app; } else { $apps_other[$app_id] = $app; } } } $auth_config = wa()->getAuthConfig($domain); if (isset($auth_config['app']) && !empty($apps_disabled[$auth_config['app']])) { $this->view->assign('profile_disabled', true); } $this->view->assign('apps', array('enabled' => $apps_enabled, 'disabled' => $apps_disabled, 'other' => $apps_other)); $this->view->assign('domain_id', siteHelper::getDomainId()); $this->view->assign('auth_enabled', !empty($auth_config['auth'])); $this->view->assign('auth_app', ifset($auth_config['app'])); $this->template = wa()->getAppPath($this->getTemplate(), 'site'); }
public function execute() { $apps = wa()->getApps(); $auth_apps = array(); $routes = wa()->getRouting()->getRoutes(siteHelper::getDomain()); foreach ($routes as $route) { if (isset($route['app']) && isset($apps[$route['app']])) { $auth_apps[$route['app']] = true; } } $temp = array(); foreach ($apps as $app_id => $app) { if (isset($app['frontend']) || isset($auth_apps[$app_id])) { $temp[$app_id] = array('id' => $app_id, 'icon' => $app['icon'], 'name' => $app['name']); if (isset($auth_apps[$app_id])) { if (empty($app['auth'])) { unset($auth_apps[$app_id]); } else { $auth_apps[$app_id] = $temp[$app_id]; } } } } $this->view->assign('auth_apps', $auth_apps); $auth_config = wa()->getAuthConfig(siteHelper::getDomain()); $this->view->assign('auth_config', array('auth' => isset($auth_config['auth']) ? $auth_config['auth'] : false, 'app' => isset($auth_config['app']) ? $auth_config['app'] : false, 'signup_captcha' => isset($auth_config['signup_captcha']) ? $auth_config['signup_captcha'] : false, 'adapters' => isset($auth_config['adapters']) ? $auth_config['adapters'] : array())); $this->view->assign('auth_adapters', $this->getAuthAdapters()); $this->view->assign('apps', $temp); $this->view->assign('domain_id', siteHelper::getDomainId()); $this->view->assign('domain', siteHelper::getDomain()); $this->view->assign('title', siteHelper::getDomain('title')); if ($domain_alias = wa()->getRouting()->isAlias(siteHelper::getDomain())) { $this->view->assign('domain_alias', $domain_alias); return; } $s = siteHelper::getDomain('style'); $this->view->assign('style', $s ? $s : 'white'); $domain = siteHelper::getDomain(); $domain_config_path = $this->getConfig()->getConfigPath('domains/' . $domain . '.php'); if (file_exists($domain_config_path)) { $domain_config = (include $domain_config_path); } else { $domain_config = array(); } $u = parse_url('http://' . $domain); //$path = isset($u['path']) ? $u['path'] : ''; if (!isset($domain_config['apps']) || !$domain_config['apps']) { $this->view->assign('domain_apps_type', 0); $domain_name = !empty($domain_config['name']) ? $domain_config['name'] : null; $domain_config['apps'] = wa()->getFrontendApps($domain, $domain_name); } else { $this->view->assign('domain_apps_type', 1); } $this->view->assign('domain_apps', $domain_config['apps']); $this->view->assign('cdn', ifset($domain_config['cdn'], '')); foreach (array('head_js') as $key) { $this->view->assign($key, isset($domain_config[$key]) ? $domain_config[$key] : ''); } if (isset($domain_config['google_analytics'])) { if (!is_array($domain_config['google_analytics'])) { $domain_config['google_analytics'] = array('code' => $domain_config['google_analytics']); } } else { $domain_config['google_analytics'] = array('code' => ''); } $this->view->assign('google_analytics', $domain_config['google_analytics']); $this->getStaticFiles($domain); $this->view->assign('url', $this->getDomainUrl($domain)); /** * Backend settings page * UI hook allow extends backend settings page * @event backend_settings * @param array $domain * @return array[string][string]string $return[%plugin_id%]['action_button_li'] html output * @return array[string][string]string $return[%plugin_id%]['section'] html output */ $domain_info = siteHelper::getDomainInfo(); $this->view->assign('backend_settings', wa()->event('backend_settings', $domain_info, array('action_button_li', 'section'))); }