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'));
 }
Ejemplo n.º 2
0
 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'));
 }
Ejemplo n.º 3
0
 protected function getPages()
 {
     $domain_id = siteHelper::getDomainId();
     $pages = $this->getPageModel()->select('id,name,url,full_url,status,route,parent_id')->where('domain_id = ' . $domain_id)->order('parent_id,sort')->fetchAll('id');
     $domain = siteHelper::getDomain();
     foreach ($pages as &$p) {
         $p['domain'] = $domain;
     }
     unset($p);
     return $pages;
 }
Ejemplo n.º 4
0
 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());
 }
Ejemplo n.º 5
0
 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()
 {
     $this->domain_id = siteHelper::getDomainId();
     $this->view->assign('apps', siteHelper::getApps());
     $this->view->assign('domain_id', $this->domain_id);
     $this->view->assign('domain_url', siteHelper::getDomain());
     $this->view->assign('domain_alias', wa()->getRouting()->isAlias(siteHelper::getDomain()));
     $this->view->assign('domains', siteHelper::getDomains(true));
     $this->view->assign('pages', $this->getPages());
     $this->view->assign('domain_root_url', siteHelper::getDomainUrl());
     $this->view->assign('rights', array('admin' => $this->getUser()->isAdmin('site'), 'files' => $this->getRights('files'), 'themes' => $this->getRights('themes'), 'blocks' => $this->getRights('blocks')));
     /**
      * Extend backend sidebar
      * Add extra sidebar items (menu items, system output)
      * @event backend_sidebar
      * @example #event handler example
      * public function sidebarAction()
      * {
      *     $output = array();
      *
      *     #add external link into sidebar menu
      *     $output['menu_li']='<li>
      *         <a href="http://www.webasyst.com">
      *             http://www.webasyst.com
      *         </a>
      *     </li>';
      *
      *     #add system link into sidebar menu
      *     $output['system_li']='<li>
      *         <a href="http://www.webasyst.com">
      *             http://www.webasyst.com
      *         </a>
      *     </li>';
      *
      *     return $output;
      * }
      * @return array[string][string]string $return[%plugin_id%]['menu_li'] Single menu items
      * @return array[string][string]string $return[%plugin_id%]['system_li'] Extra menu items
      */
     $this->view->assign('backend_sidebar', wa()->event('backend_sidebar'));
 }
 protected function saveBackground()
 {
     $background = waRequest::file('background_file');
     if ($background && $background->uploaded()) {
         $allowed = array('jpg', 'jpeg', 'png', 'gif');
         if (!in_array($background->extension, $allowed)) {
             $this->errors = sprintf(_ws("Files with extensions %s are allowed only."), '*.' . implode(', *.', $allowed));
         } else {
             $path = wa()->getDataPath('background/', true);
             $ext = $background->extension;
             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());
             } elseif (!$background->moveTo($path, siteHelper::getDomainId() . '.' . $ext)) {
                 $this->errors = _w('Failed to upload file.');
             } else {
                 return $ext;
             }
         }
     }
     return false;
 }
 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')));
 }
Ejemplo n.º 10
0
 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());
 }