public function getApps($system = false)
 {
     if (self::$apps === null) {
         $locale = $this->getUser()->getLocale();
         $file = $this->config->getPath('cache', 'config/apps' . $locale);
         if (!file_exists($this->getConfig()->getPath('config', 'apps'))) {
             self::$apps = array();
             throw new waException('File wa-config/apps.php not found.', 600);
         }
         if (!file_exists($file) || filemtime($file) < filemtime($this->getConfig()->getPath('config', 'apps')) || waSystemConfig::isDebug()) {
             waFiles::create($this->getConfig()->getPath('cache') . '/config');
             $all_apps = (include $this->getConfig()->getPath('config', 'apps'));
             $all_apps['webasyst'] = true;
             self::$apps = array();
             foreach ($all_apps as $app => $enabled) {
                 if ($enabled) {
                     waLocale::loadByDomain($app, $locale);
                     $app_config = $this->getAppPath('lib/config/app.php', $app);
                     if (!file_exists($app_config)) {
                         if (false && SystemConfig::isDebug()) {
                             throw new waException("Config not found. Create config by path " . $app_config);
                         }
                         continue;
                     }
                     $app_info = (include $app_config);
                     $build_file = $app_config = $this->getAppPath('lib/config/build.php', $app);
                     if (file_exists($build_file)) {
                         $app_info['build'] = (include $build_file);
                     } else {
                         if (SystemConfig::isDebug()) {
                             $app_info['build'] = time();
                         } else {
                             $app_info['build'] = 0;
                         }
                     }
                     $app_info['id'] = $app;
                     $app_info['name'] = _wd($app, $app_info['name']);
                     if (isset($app_info['icon'])) {
                         if (is_array($app_info['icon'])) {
                             foreach ($app_info['icon'] as $size => $url) {
                                 $app_info['icon'][$size] = 'wa-apps/' . $app . '/' . $url;
                             }
                         } else {
                             $app_info['icon'] = array(48 => 'wa-apps/' . $app . '/' . $app_info['icon']);
                         }
                     } else {
                         $app_info['icon'] = array();
                     }
                     if (isset($app_info['img'])) {
                         $app_info['img'] = 'wa-apps/' . $app . '/' . $app_info['img'];
                     } else {
                         $app_info['img'] = isset($app_info['icon'][48]) ? $app_info['icon'][48] : 'wa-apps/' . $app . '/img/' . $app . ".png";
                     }
                     if (!isset($app_info['icon'][48])) {
                         $app_info['icon'][48] = $app_info['img'];
                     }
                     if (!isset($app_info['icon'][24])) {
                         $app_info['icon'][24] = $app_info['icon'][48];
                     }
                     if (!isset($app_info['icon'][16])) {
                         $app_info['icon'][16] = $app_info['icon'][24];
                     }
                     self::$apps[$app] = $app_info;
                 }
             }
             if (!file_exists($file) || filemtime($file) < filemtime($this->getConfig()->getPath('config', 'apps'))) {
                 waUtils::varExportToFile(self::$apps, $file);
             }
         } else {
             self::$apps = (include $file);
             waLocale::loadByDomain('webasyst', $locale);
         }
     }
     if ($system) {
         return self::$apps;
     } else {
         $apps = self::$apps;
         unset($apps['webasyst']);
         return $apps;
     }
 }