/**
  * Get modules locales
  * @return array
  */
 public function parseModules()
 {
     try {
         $modules = getModulesPaths();
         foreach ($modules as $moduleName => $modulePath) {
             $language_dir = $modulePath . 'language/';
             if (!file_exists($language_dir)) {
                 // TODO: Спитати Марка чому в shop нема language =))
                 continue;
             }
             $locales = new \DirectoryIterator($language_dir);
             foreach ($locales as $locale) {
                 if ($locale->isDir() && !$locale->isDot() && is_dir($language_dir . $locale->getBasename()) && isLocale($locale->getBasename())) {
                     $objLang = new \MY_Lang();
                     $objLang->load($moduleName);
                     $module_info = $module_dir . '/module_info.php';
                     $module_info = \get_mainsite_url($module_info);
                     include $module_info;
                     $menu_name = $com_info['menu_name'] ? $com_info['menu_name'] : $moduleName;
                     self::$MODULES_LOCALES[$locale->getBasename()][] = array('module' => $moduleName, 'menu_name' => ucfirst($menu_name));
                     unset($com_info);
                 }
             }
         }
         return self::$MODULES_LOCALES;
     } catch (Exception $exc) {
         return array();
     }
 }
 function find_components($in_menu = FALSE)
 {
     $components = array();
     if ($in_menu == TRUE) {
         $this->db->where('in_menu', 1);
     }
     $this->db->not_like('identif', 'payment_method_');
     $installed = $this->db->get('components')->result_array();
     $modulesPaths = getModulesPaths();
     foreach ($modulesPaths as $moduleName => $modulePath) {
         $info_file = $modulePath . 'module_info.php';
         $com_file_admin = $modulePath . 'admin.php';
         $lang = new MY_Lang();
         $lang->load($moduleName);
         if (file_exists($info_file)) {
             include $info_file;
             if (file_exists($com_file_admin)) {
                 $admin_file = 1;
             } else {
                 $admin_file = 0;
             }
             $ins = FALSE;
             foreach ($installed as $k) {
                 if ($k['name'] == $moduleName) {
                     $ins = TRUE;
                 }
             }
             $new_com = array('menu_name' => $com_info['menu_name'], 'com_name' => $moduleName, 'admin_file' => $admin_file, 'installed' => $ins, 'type' => $com_info['type']);
             array_push($components, $new_com);
         }
     }
     return $components;
 }
 public function getModules()
 {
     $modules = getModulesPaths();
     $data = array();
     foreach ($modules as $moduleName => $modulePath) {
         if ($moduleName != 'admin' && $moduleName != 'shop') {
             $lang = new \MY_Lang();
             $lang->load($moduleName);
             include $modulePath . 'module_info.php';
             $name = isset($com_info['menu_name']) ? $com_info['menu_name'] : $moduleName;
             $data[$moduleName] = $name;
         }
     }
     return $data;
 }
 /**
  * form XML doc
  */
 public function formXml()
 {
     $modules = getModulesPaths();
     $array = array();
     foreach ($modules as $moduleName => $modulePath) {
         $ver = read_file($modulePath . "module_info.php");
         preg_match("/'version'(\\s*)=>(\\s*)'(.*)',/", $ver, $find);
         $array[$moduleName] = end($find);
     }
     $array['core'] = IMAGECMS_NUMBER;
     header('content-type: text/xml');
     $xml = "<?xml version='1.0' encoding='UTF-8'?>" . "\n" . "<КонтейнерСписков ВерсияСхемы='0.1'  ДатаФормирования='" . date('Y-m-d') . "'>" . "\n";
     foreach ($array as $key => $arr) {
         $xml .= '<modul>';
         $xml .= "<name>{$key}</name>";
         $xml .= "<version>{$arr}</version>";
         $xml .= '</modul>';
     }
     $xml .= "</КонтейнерСписков>\n";
     echo $xml;
     exit;
 }