コード例 #1
0
 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'));
 }