Example #1
0
 private static function importConfig($groupName, $moduleName)
 {
     global $log;
     $siteLanguages = \Modules\standard\languages\Db::getLanguages();
     foreach ($siteLanguages as $key => $language) {
         $siteLanguages[$key]['code'] = strtolower($siteLanguages[$key]['code']);
     }
     $configFiles = ModulesInstallation::getConfigFiles(MODULE_DIR . 'standard/content_management/widgets/' . $groupName . '/' . $moduleName . '/install/', 'parameters');
     foreach ($configFiles as $key => $file) {
         $configFiles[$key] = unserialize(file_get_contents(MODULE_DIR . 'standard/content_management/widgets/' . $groupName . '/' . $moduleName . '/install/' . $key));
         $configFiles[$key]->languageCode = strtolower($configFiles[$key]->languageCode);
     }
     //install default config
     foreach ($configFiles as $key => $file) {
         if ($key == 'parameters.conf') {
             if (isset($siteLanguages[0])) {
                 $file->languageCode = $siteLanguages[0]['code'];
                 $log->log('developer/widgets', 'parameters installation', MODULE_DIR . 'standard/content_management/widgets/' . $groupName . '/' . $moduleName . '/install/parameters.conf installation (' . $siteLanguages[0]['code'] . ')');
                 $file->saveParameters($groupName, $moduleName, false);
             }
         }
     }
     //install configuration files that match site languages
     foreach ($configFiles as $configKey => $file) {
         if ($configKey !== 'parameters.conf') {
             //parameters.conf is already installed
             foreach ($siteLanguages as $languageKey => $language) {
                 if ($language['code'] == $file->languageCode) {
                     $file->languageCode = $siteLanguages[0]['code'];
                     $log->log('adeveloper/widgets', 'parameters installation', MODULE_DIR . 'standard/content_management/widgets/' . $groupName . '/' . $moduleName . '/install/' . $configKey . ' (' . $language['code'] . ')');
                     $file->saveParameters($groupName, $moduleName, false);
                     $siteLanguages[$languageKey] == null;
                     //mark language as installed
                 }
             }
         }
     }
     //install configuration files that are similar to site languages. Eg. en-gb and en
     foreach ($configFiles as $configKey => $file) {
         if ($configKey !== 'parameters.conf') {
             //parameters.conf is already installed
             $tmpLang = $file->languageCode;
             $tmpLang = substr($tmpLang, 0, strpos($tmpLang, '-'));
             foreach ($siteLanguages as $languageKey => $language) {
                 if ($language !== null && ($language['code'] = $tmpLang)) {
                     //null - already installed
                     $file->languageCode = $siteLanguages[0]['code'];
                     $log->log('bdeveloper/widgets', 'parameters installation', MODULE_DIR . 'standard/content_management/widgets/' . $groupName . '/' . $moduleName . '/install/' . $configKey . ' (' . $language['code'] . ')');
                     $file->saveParameters($groupName, $moduleName, false);
                     $siteLanguages[$languageKey] == null;
                     //mark language as installed
                 }
             }
         }
     }
 }
Example #2
0
 function manage()
 {
     global $cms;
     $answer = '';
     if (isset($_REQUEST['type']) == 'ajax' && $_REQUEST['action'] == 'install') {
         if ($_REQUEST['action'] == 'install') {
             $errors = ModulesInstallation::getErrors($_REQUEST['module_group'], $_REQUEST['module']);
             if ($errors) {
                 $tmp_answer = '';
                 foreach ($errors as $key => $error) {
                     if ($tmp_answer != '') {
                         $tmp_answer .= "\\n\\n";
                     }
                     $tmp_answer .= addslashes(str_replace("\n", "", str_replace("\r", "", $error)));
                 }
                 $answer .= 'alert(\'' . $tmp_answer . '\')';
             } else {
                 ModulesInstallation::install($_REQUEST['module_group'], $_REQUEST['module']);
                 $answer .= '
               window.location = \'' . $cms->generateUrl() . '\';
       ';
             }
         }
         echo $answer;
         \Db::disconnect();
         exit;
     } else {
         //$this->standard_module->before_content = $this->find_new_modules();  widgets installation disabled
         return $this->standard_module->manage();
     }
 }