Parcourir la source

#35 - modules pre-installation

Alex Trofimov il y a 12 ans
Parent
commit
9c252539ed

+ 4 - 2
inc/classes/BxDolLanguages.php

@@ -288,8 +288,10 @@ class BxDolLanguages extends BxDol implements iBxDolSingleton {
     }    
 }
 
-function _t() {
-    return call_user_func_array(array(BxDolLanguages::getInstance(), '_t'), func_get_args());
+if (!function_exists('_t')) {
+    function _t() {
+        return call_user_func_array(array(BxDolLanguages::getInstance(), '_t'), func_get_args());
+    }
 }
 
 function _t_err() {

+ 24 - 17
install/classes/BxDolInstallSiteConfig.php

@@ -178,7 +178,7 @@ class BxDolInstallSiteConfig
                 'func' => 'rowSectionOpen',
             ),
 
-            'language' => array(
+            BX_DOL_MODULE_TYPE_LANGUAGE => array(
                 'name' => _t('_sys_inst_conf_field_language'),
                 'desc' => _t('_sys_inst_conf_desc_language'),
                 'def' => isset($_COOKIE['lang']) ? $_COOKIE['lang'] : (isset($_GET['lang']) ? $_GET['lang'] : 'en'),
@@ -186,7 +186,7 @@ class BxDolInstallSiteConfig
                 'vals' => $this->getSelectValues(BX_DOL_MODULE_TYPE_LANGUAGE),
             ),
 
-            'template' => array(
+            BX_DOL_MODULE_TYPE_TEMPLATE => array(
                 'name' => _t('_sys_inst_conf_field_template'),
                 'desc' => _t('_sys_inst_conf_desc_template'),
                 'def' => 'uni',
@@ -318,20 +318,26 @@ EOF;
 
     public function processModules ($a) 
     {
-        $oModulesTools = new BxDolInstallModulesTools();
-        $aModules = $oModulesTools->getModules();
         require_once(BX_INSTALL_PATH_HEADER);
-        $aModules = array();
-        foreach ($aModules as $sKey) {
-            if (!isset($a[$sKey]))
-                continue;
-            $aModuleConfig = $oModulesTools->getModuleConfigByUri($a[$sKey], $aModules);
-            bx_import('BxDolStudioInstallerUtils');
-            $aResult = BxDolStudioInstallerUtils::getInstance()->perform($aModuleConfig['home_dir'], 'install');
-            if (!$aResult['result'] && !empty($aResult['message']))
-                return array(BX_INSTALL_ERR_GENERAL => $aResult['message']);
-        }
-            
+        bx_import('BxDolLanguages');
+        BxDolLanguages::getInstance();
+        $oModulesTools = new BxDolInstallModulesTools();
+
+        $aTypes = array (BX_DOL_MODULE_TYPE_LANGUAGE, BX_DOL_MODULE_TYPE_TEMPLATE);
+        foreach ($aTypes as $sModuleType) {
+            $aModules = $oModulesTools->getModules($sModuleType);
+            foreach ($aModules as $aConfig) {
+                $sUri = $aConfig['home_uri'];
+                if (empty($a[$sModuleType]) || $a[$sModuleType] != $sUri)
+                    continue;
+
+                bx_import('BxDolStudioInstallerUtils');
+                $aResult = BxDolStudioInstallerUtils::getInstance()->perform($aConfig['home_dir'], 'install');
+                if ((!isset($aResult['result']) || !$aResult['result']) && !empty($aResult['message']))
+                    return array(BX_INSTALL_ERR_GENERAL => $aResult['message']);
+            }            
+        } 
+
         return array();
     }
 
@@ -379,9 +385,10 @@ EOF;
     protected function getMarkersForPhp($a) 
     {
         $a = $this->getMarkers($a);
+        $aMarkers = array();
         foreach ($a as $sKey => $mixedVal)
-            $a['%' . strtoupper($sKey) . '%'] = bx_php_string_apos($mixedVal);
-        return $a;
+            $aMarkers['%' . strtoupper($sKey) . '%'] = bx_php_string_apos($mixedVal);
+        return $aMarkers;
     }
 
     protected function getFormFields($aErrorFields) 

+ 4 - 5
install/patterns/header.inc.php

@@ -95,14 +95,13 @@ if (defined('CHECK_DOLPHIN_REQUIREMENTS')) {
 
     $aErrors[] = (ini_get('register_globals') == 0) ? '' : '<font color="red">register_globals is On (warning, you should have this param in Off state, or your site will unsafe)</font>';
     $aErrors[] = (ini_get('safe_mode') == 0) ? '' : '<font color="red">safe_mode is On, disable it</font>';
-    //$aErrors[] = (ini_get('allow_url_fopen') == 0) ? 'Off (warning, better keep this parameter in On to able register Dolphin' : '';
-//    $aErrors[] = (version_compare(PHP_VERSION, '5.2.0', '<')) ? '<font color="red">PHP version too old, please update to PHP 5.2.0 at least</font>' : '';
+    $aErrors[] = (version_compare(PHP_VERSION, '5.2.0', '<')) ? '<font color="red">PHP version too old, please update to PHP 5.2.0 at least</font>' : '';
     $aErrors[] = (!extension_loaded( 'mbstring')) ? '<font color="red">mbstring extension not installed. <b>Warning!</b> Dolphin cannot work without <b>mbstring</b> extension.</font>' : '';
-/*
+
     if (version_compare(phpversion(), "5.2", ">") == 1) {
         $aErrors[] = (ini_get('allow_url_include') == 0) ? '' : '<font color="red">allow_url_include is On (warning, you should have this param in Off state, or your site will unsafe)</font>';
     };
-*/
+
     $aErrors = array_diff($aErrors, array('')); //delete empty
     if (count($aErrors)) {
         $sErrors = implode(" <br /> ", $aErrors);
@@ -165,8 +164,8 @@ mb_regex_encoding('UTF-8');
 
 // include files needed for basic functionality
 require_once(BX_DIRECTORY_PATH_CLASSES . "BxDol.php");
-require_once(BX_DIRECTORY_PATH_INC . "security.inc.php");
 require_once(BX_DIRECTORY_PATH_INC . "utils.inc.php");
+require_once(BX_DIRECTORY_PATH_INC . "security.inc.php");
 require_once(BX_DIRECTORY_PATH_INC . "db.inc.php");
 require_once(BX_DIRECTORY_PATH_INC . "profiles.inc.php");