Browse Source

Allow modules to provide license file (license.<module_name>.xml) with same format as setup/licenses/community_license.xml

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@4921 a333f486-631f-4898-b8df-5754b55c2be0
eespie 7 năm trước cách đây
mục cha
commit
5dae37bdde
3 tập tin đã thay đổi với 148 bổ sung101 xóa
  1. 4 2
      pages/ajax.render.php
  2. 119 80
      setup/setuputils.class.inc.php
  3. 25 19
      setup/wizardsteps.class.inc.php

+ 4 - 2
pages/ajax.render.php

@@ -1192,7 +1192,7 @@ EOF
 		$aAvailableModules = $oRuntimeEnv->AnalyzeInstallation(MetaModel::GetConfig(), $aSearchDirs);
 
 		require_once(APPROOT.'setup/setuputils.class.inc.php');
-		$aLicenses = SetupUtils::GetLicenses();
+		$aLicenses = SetupUtils::GetLicenses($sCurrEnv);
 
 		$aItopSettings = array('cron_max_execution_time', 'timezone');
 		$aPHPSettings = array('memory_limit', 'max_execution_time', 'upload_max_filesize', 'post_max_size');
@@ -1238,11 +1238,13 @@ EOF
 		$oPage->add('<fieldset>');
 		$oPage->add('<legend>'.Dict::S('UI:About:Licenses').'</legend>');
 		$oPage->add('<ul style="margin: 0; font-size: smaller; max-height: 15em; overflow: auto;">');
-		foreach($aLicenses as $index => $oLicense)
+		$index = 0;
+		foreach($aLicenses as $oLicense)
 		{
 			$oPage->add('<li><b>'.$oLicense->product.'</b>, &copy; '.$oLicense->author.' is licensed under the <b>'.$oLicense->license_type.' license</b>. (<a id="toggle_'.$index.'" class="CollapsibleLabel" style="cursor:pointer;">Details</a>)');
 			$oPage->add('<div id="license_'.$index.'" class="license_text" style="display:none;overflow:auto;max-height:10em;font-size:small;border:1px #696969 solid;margin-bottom:1em; margin-top:0.5em;padding:0.5em;">'.$oLicense->text.'</div>');
 			$oPage->add_ready_script('$("#toggle_'.$index.'").click( function() { $("#license_'.$index.'").slideToggle("normal"); } );');
+			$index++;
 		}
 		$oPage->add('</ul>');
 		$oPage->add('</fieldset>');

+ 119 - 80
setup/setuputils.class.inc.php

@@ -58,7 +58,7 @@ class SetupUtils
 	/**
 	 * Check the version of PHP, the needed PHP extension and a number
 	 * of configuration parameters (memory_limit, max_upload_file_size, etc...)
-	 * @param SetupPage $oP The page used only for its 'log' method
+     * @internal SetupPage $oP The page used only for its 'log' method
 	 * @return array An array of CheckResults objects
 	 */
 	static function CheckPHPVersion()
@@ -159,10 +159,7 @@ class SetupUtils
 			}
 			SetupPage::log("Info - php.ini file(s): '$sPhpIniFile'");
 		}
-		else
-		{
-			$sPhpIniFile = 'php.ini';
-		}
+
 		if (!ini_get('file_uploads'))
 		{
 			$aResult[] = new CheckResult(CheckResult::ERROR, "Files upload is not allowed on this server (file_uploads = ".ini_get('file_uploads').").");
@@ -224,15 +221,14 @@ class SetupUtils
 				$aResult[] = new CheckResult(CheckResult::ERROR, "'magic_quotes_gpc' is set to On. Please turn it Off in php.ini before continuing.");
 			}
 		}
-		if (function_exists('magic_quotes_runtime'))
-		{
-			if (@magic_quotes_runtime())
+        if (function_exists('get_magic_quotes_runtime'))
+        {
+            if (@get_magic_quotes_runtime())
 			{
 				$aResult[] = new CheckResult(CheckResult::ERROR, "'magic_quotes_runtime' is set to On. Please turn it Off in php.ini before continuing.");
 			}
 		}
 
-
 		$sMemoryLimit = trim(ini_get('memory_limit'));
 		if (empty($sMemoryLimit))
 		{
@@ -337,9 +333,13 @@ class SetupUtils
 		return $aResult;
 	}
 
-	/**
-	 * Check that the selected modules meet their dependencies
-	 */	 	
+    /**
+     * Check that the selected modules meet their dependencies
+     * @param $sSourceDir
+     * @param $sExtensionDir
+     * @param $aSelectedModules
+     * @return array
+     */
 	static function CheckSelectedModules($sSourceDir, $sExtensionDir, $aSelectedModules)
 	{
 		$aResult = array();
@@ -364,11 +364,12 @@ class SetupUtils
 		return $aResult;
 	}
 
-	/**
-	 * Check that the backup could be executed
-	 * @param Page $oP The page used only for its 'log' method
-	 * @return array An array of CheckResults objects
-	 */
+    /**
+     * Check that the backup could be executed
+     * @param $sDestDir
+     * @return array An array of CheckResults objects
+     * @internal param Page $oP The page used only for its 'log' method
+     */
 	static function CheckBackupPrerequisites($sDestDir)
 	{
 		$aResult = array();
@@ -438,11 +439,12 @@ class SetupUtils
 		return $aResult;
 	}
 
-	/**
-	 * Check that graphviz can be launched
-	 * @param string $GraphvizPath The path where graphviz' dot program is installed
-	 * @return CheckResult The result of the check
-	 */
+    /**
+     * Check that graphviz can be launched
+     * @param $sGraphvizPath
+     * @return CheckResult The result of the check
+     * @internal param string $GraphvizPath The path where graphviz' dot program is installed
+     */
 	static function CheckGraphviz($sGraphvizPath)
 	{
 		$oResult = null;
@@ -489,7 +491,7 @@ class SetupUtils
 			
 	/**
 	 * Helper function to retrieve the system's temporary directory
-	 * Emulates sys_get_temp_dir if neeed (PHP < 5.2.1)
+     * Emulates sys_get_temp_dir if needed (PHP < 5.2.1)
 	 * @return string Path to the system's temp directory
 	 */
 	static function GetTmpDir()
@@ -530,9 +532,11 @@ class SetupUtils
 		return $sPath;
 	}
 
-	/**
-	 * Helper to recursively remove a directory
-	 */
+    /**
+     * Helper to recursively remove a directory
+     * @param $dir
+     * @throws Exception
+     */
 	public static function rrmdir($dir)
 	{
 		if ((strlen(trim($dir)) == 0) || ($dir == '/') || ($dir == '\\'))
@@ -543,9 +547,11 @@ class SetupUtils
 		rmdir($dir);
 	}
 
-	/**
-	 * Helper to recursively cleanup a directory
-	 */
+    /**
+     * Helper to recursively cleanup a directory
+     * @param $dir
+     * @throws Exception
+     */
 	public static function tidydir($dir)
 	{
 		if ((strlen(trim($dir)) == 0) || ($dir == '/') || ($dir == '\\'))
@@ -581,9 +587,10 @@ class SetupUtils
 		}
 	}
 
-	/**
-	 * Helper to build the full path of a new directory
-	 */
+    /**
+     * Helper to build the full path of a new directory
+     * @param $dir
+     */
 	public static function builddir($dir)
 	{
 		$parent = dirname($dir);
@@ -597,10 +604,15 @@ class SetupUtils
 		}
 	}
 
-	/**
-	 * Helper to copy a directory to a target directory, skipping .SVN files (for developer's comfort!)
-	 * Returns true if successfull
-	 */
+    /**
+     * Helper to copy a directory to a target directory, skipping .SVN files (for developer's comfort!)
+     * Returns true if successful
+     * @param $sSource
+     * @param $sDest
+     * @param bool $bUseSymbolicLinks
+     * @return bool
+     * @throws Exception
+     */
 	public static function copydir($sSource, $sDest, $bUseSymbolicLinks = false)
 	{
 		if (is_dir($sSource))
@@ -679,12 +691,15 @@ class SetupUtils
 		}
 	}
 
-	/**
-	 * Helper to move a directory when the parent directory of the target dir cannot be written
-	 * To be used as alternative to rename()	 	 
-	 * Files/Subdirs of the source directory are moved one by one
-	 * Returns void
-	 */
+    /**
+     * Helper to move a directory when the parent directory of the target dir cannot be written
+     * To be used as alternative to rename()
+     * Files/Subdirs of the source directory are moved one by one
+     * Returns void
+     * @param $sSource
+     * @param $sDest
+     * @throws Exception
+     */
 	public static function movedir($sSource, $sDest)
 	{
 		if (!is_dir($sSource))
@@ -728,9 +743,8 @@ class SetupUtils
 
 	static function GetPreviousInstance($sDir)
 	{
-		$bFound = false;
 		$sSourceDir = '';
-		$sSourceEnvironement = '';
+        $sSourceEnvironment = '';
 		$sConfigFile = '';
 		$aResult = array(
 			'found' => false,
@@ -954,11 +968,14 @@ EOF
 		
 	}
 
-	/**
-	 * Helper function check the connection to the database, verify a few conditions (minimum version, etc...) and (if connected)
-	 * enumerate the existing databases (if possible)
-	 * @return mixed false if the connection failed or array('checks' => Array of CheckResult, 'databases' => Array of database names (as strings) or null if not allowed)
-	 */
+    /**
+     * Helper function check the connection to the database, verify a few conditions (minimum version, etc...) and (if connected)
+     * enumerate the existing databases (if possible)
+     * @param $sDBServer
+     * @param $sDBUser
+     * @param $sDBPwd
+     * @return mixed false if the connection failed or array('checks' => Array of CheckResult, 'databases' => Array of database names (as strings) or null if not allowed)
+     */
 	static function CheckServerConnection($sDBServer, $sDBUser, $sDBPwd)
 	{
 		$aResult = array('checks' => array(), 'databases' => null);
@@ -1083,7 +1100,7 @@ EOF
 					{
 						$sEncodedName = htmlentities($sDatabaseName, ENT_QUOTES, 'UTF-8');
 						$sSelected = ($sDatabaseName == $sDBName) ? ' selected ' : '';
-						$sDBNameInput .= '<option value="'.$sEncodedName.'"'.$sSelected.'>'.$sEncodedName.'</option>';
+                        $sDBNameInput .= '<option value="'.$sEncodedName.'" '.$sSelected.'>'.$sEncodedName.'</option>';
 					}
 				}
 				$sDBNameInput .= '</select>';
@@ -1097,8 +1114,8 @@ EOF
 	
 	/**
 	 * Helper function to get the available languages from the given directory
-	 * @param $sDir Path to the dictionary
-	 * @return an array of language code => description
+     * @param $sDir String Path to the dictionary
+     * @return array of language code => description
 	 */    
 	static public function GetAvailableLanguages($sDir)
 	{
@@ -1120,9 +1137,9 @@ EOF
 				require_once($sFilePath);
 			}
 		}
-	
-		return Dict::GetLanguages();
-	}
+
+        return Dict::GetLanguages();
+    }
 	
 	static public function GetLanguageSelect($sSourceDir, $sInputName, $sDefaultLanguageCode)
 	{
@@ -1131,19 +1148,22 @@ EOF
 		$aLanguages = SetupUtils::GetAvailableLanguages($sSourceDir);
 		foreach($aLanguages as $sCode => $aInfo)
 		{
-			$sSelected = ($sCode == $sDefaultLanguageCode) ? ' selected ' : '';
-			$sHtml .= '<option value="'.$sCode.'"'.$sSelected.'>'.htmlentities($aInfo['description'], ENT_QUOTES, 'UTF-8').' ('.htmlentities($aInfo['localized_description'], ENT_QUOTES, 'UTF-8').')</option>';
+            $sSelected = ($sCode == $sDefaultLanguageCode) ? 'selected ' : '';
+            $sHtml .= '<option value="'.$sCode.'" '.$sSelected.'>'.htmlentities($aInfo['description'], ENT_QUOTES, 'UTF-8').' ('.htmlentities($aInfo['localized_description'], ENT_QUOTES, 'UTF-8').')</option>';
 		}
 		$sHtml .= '</select></td></tr>';
 		
 		return $sHtml;
 	}
-	
-	/**
-	 *	
-	 * @param bool  $bAbortOnMissingDependency ...
-	 * @param array $aModulesToLoad List of modules to search for, defaults to all if ommitted
-	 */	 
+
+    /**
+     *
+     * @param $oWizard
+     * @param bool $bAbortOnMissingDependency ...
+     * @param array $aModulesToLoad List of modules to search for, defaults to all if ommitted
+     * @return hash
+     * @throws Exception
+     */
 	public static function AnalyzeInstallation($oWizard, $bAbortOnMissingDependency = false, $aModulesToLoad = null)
 	{
 		require_once(APPROOT.'/setup/moduleinstaller.class.inc.php');
@@ -1222,14 +1242,17 @@ EOF
 		$oProductionEnv = new RunTimeEnvironment();
 		return $oProductionEnv->GetApplicationVersion($oConfig);
 	}
-	/**
-	 * Checks if the content of a directory matches the given manifest
-	 * @param string $sBaseDir Path to the root directory of iTop
-	 * @param string $sSourceDir Relative path to the directory to check under $sBaseDir
-	 * @param Array $aDOMManifest Array of array('path' => relative_path 'size'=> iSize, 'md5' => sHexMD5)
-	 * @param Hash $aResult Used for recursion 
-	 * @return hash Hash array ('added' => array(), 'removed' => array(), 'modified' => array()) 
-	 */
+
+    /**
+     * Checks if the content of a directory matches the given manifest
+     * @param string $sBaseDir Path to the root directory of iTop
+     * @param string $sSourceDir Relative path to the directory to check under $sBaseDir
+     * @param $aManifest
+     * @param array $aExcludeNames
+     * @param Hash $aResult Used for recursion
+     * @return hash Hash array ('added' => array(), 'removed' => array(), 'modified' => array())
+     * @internal param array $aDOMManifest Array of array('path' => relative_path 'size'=> iSize, 'md5' => sHexMD5)
+     */
 	public static function CheckDirAgainstManifest($sBaseDir, $sSourceDir, $aManifest, $aExcludeNames = array('.svn', '.git'), $aResult = null)
 	{
 //echo "CheckDirAgainstManifest($sBaseDir, $sSourceDir ...)\n"; 
@@ -1466,19 +1489,35 @@ EOF
 		return false;
 	}
 
-	/**
-	 * Returns an array of xml nodes describing the licences	
-	 */	
-	static public function GetLicenses()
+    /**
+     * Returns an array of xml nodes describing the licences.
+     * @param $sEnv string|null Execution environment. If present loads licenses only for installed modules else loads all licenses available.
+     * @return array Licenses list.
+     */
+    static public function GetLicenses($sEnv = null)
 	{
 		$aLicenses = array();
-		foreach (glob(APPROOT.'setup/licenses/*.xml') as $sFile)
+        $aLicenceFiles = glob(APPROOT.'setup/licenses/*.xml');
+        if (empty($sEnv))
+        {
+            $aLicenceFiles = array_merge($aLicenceFiles, glob(APPROOT.'datamodels/*/*/license.*.xml'));
+            $aLicenceFiles = array_merge($aLicenceFiles, glob(APPROOT.'extensions/*/license.*.xml'));
+            $aLicenceFiles = array_merge($aLicenceFiles, glob(APPROOT.'data/*-modules/*/license.*.xml'));
+        }
+        else
+        {
+            $aLicenceFiles = array_merge($aLicenceFiles, glob(APPROOT.'env-'.$sEnv.'/*/license.*.xml'));
+        }
+        foreach ($aLicenceFiles as $sFile)
 		{
     		$oXml = simplexml_load_file($sFile);
-    		foreach($oXml->license as $oLicense)
-    		{
-    			$aLicenses[] = $oLicense;
-    		}
+            if (!empty($oXml->license))
+            {
+                foreach ($oXml->license as $oLicense)
+                {
+                    $aLicenses[(string)$oLicense->product] = $oLicense;
+                }
+            }
 		}
 		return $aLicenses;
 	}

+ 25 - 19
setup/wizardsteps.class.inc.php

@@ -238,9 +238,9 @@ class WizStepInstallOrUpgrade extends WizardStep
 		}
 		$oPage->add('<h2>What do you want to do?</h2>');
 		$sChecked = ($sInstallMode == 'install') ? ' checked ' : '';
-		$oPage->p('<input id="radio_install" type="radio" name="install_mode" value="install"'.$sChecked.'/><label for="radio_install">&nbsp;Install a new '.ITOP_APPLICATION.'</label>');
+        $oPage->p('<input id="radio_install" type="radio" name="install_mode" value="install" '.$sChecked.'/><label for="radio_install">&nbsp;Install a new '.ITOP_APPLICATION.'</label>');
 		$sChecked = ($sInstallMode == 'upgrade') ? ' checked ' : '';
-		$oPage->p('<input id="radio_update" type="radio" name="install_mode" value="upgrade"'.$sChecked.'/><label for="radio_update">&nbsp;Upgrade an existing '.ITOP_APPLICATION.' instance</label>');
+        $oPage->p('<input id="radio_update" type="radio" name="install_mode" value="upgrade" '.$sChecked.'/><label for="radio_update">&nbsp;Upgrade an existing '.ITOP_APPLICATION.' instance</label>');
 		//$oPage->add('<fieldset  id="upgrade_info"'.$sUpgradeInfoStyle.'>');
 		//$oPage->add('<legend>Information about the previous instance:</legend>');
 		$oPage->add('<table id="upgrade_info"'.$sUpgradeInfoStyle.'>');
@@ -264,7 +264,7 @@ class WizStepInstallOrUpgrade extends WizardStep
 		}
 		$sChecked = ($bCanBackup && $bDBBackup) ? ' checked ' : '';
 		$sDisabled = $bCanBackup ? '' : ' disabled ';
-		$oPage->add('<tr><td colspan="2"><input id="db_backup" type="checkbox" name="db_backup"'.$sChecked.$sDisabled.' value="1"/><label for="db_backup">&nbsp;Backup the '.ITOP_APPLICATION.' database before upgrading</label></td></tr>');
+        $oPage->add('<tr><td colspan="2"><input id="db_backup" type="checkbox" name="db_backup" '.$sChecked.$sDisabled.' value="1"/><label for="db_backup">&nbsp;Backup the '.ITOP_APPLICATION.' database before upgrading</label></td></tr>');
 		$oPage->add('<tr><td colspan="2">Save the backup to: <input id="db_backup_path" type="text" name="db_backup_path" '.$sDisabled.'value="'.htmlentities($sDBBackupPath, ENT_QUOTES, 'UTF-8').'" size="25"/></td></tr>');
 		$fFreeSpace = SetupUtils::CheckDiskSpace($sDBBackupPath);
 		$sMessage = '';
@@ -527,8 +527,8 @@ EOF
 				$aErrors = SetupUtils::CheckWritableDirs($aWritableDirs);
 				$sChecked = ($this->oWizard->GetParameter('upgrade_type') == 'keep-previous') ? ' checked ' : '';
 				$sDisabled = (count($aErrors) > 0) ? ' disabled ' : '';
-				
-				$oPage->p('<input id="radio_upgrade_keep" type="radio" name="upgrade_type" value="keep-previous"'.$sChecked.$sDisabled.'/><label for="radio_upgrade_keep">&nbsp;Preserve the modifications of the installed version (the dasboards inside '.ITOP_APPLICATION.' may not be editable).</label>');
+
+                $oPage->p('<input id="radio_upgrade_keep" type="radio" name="upgrade_type" value="keep-previous" '.$sChecked.$sDisabled.'/><label for="radio_upgrade_keep">&nbsp;Preserve the modifications of the installed version (the dasboards inside '.ITOP_APPLICATION.' may not be editable).</label>');
 				$oPage->add('<input type="hidden" name="datamodel_previous_version" value="'.htmlentities($sInstalledDataModelVersion, ENT_QUOTES, 'UTF-8').'">');
 				
 				$oPage->add('<input type="hidden" name="relative_source_dir" value="'.htmlentities($sPreviousSourceDir, ENT_QUOTES, 'UTF-8').'">');
@@ -543,8 +543,8 @@ EOF
 				}
 						
 				$sChecked = ($this->oWizard->GetParameter('upgrade_type') == 'use-compatible') ? ' checked ' : '';
-				
-				$oPage->p('<input id="radio_upgrade_convert" type="radio" name="upgrade_type" value="use-compatible"'.$sChecked.'/><label for="radio_upgrade_convert">&nbsp;Discard the modifications, use a standard '.$sUpgradeDMVersion.' data model.</label>');
+
+                $oPage->p('<input id="radio_upgrade_convert" type="radio" name="upgrade_type" value="use-compatible" '.$sChecked.'/><label for="radio_upgrade_convert">&nbsp;Discard the modifications, use a standard '.$sUpgradeDMVersion.' data model.</label>');
 				
 				$oPage->add('<input type="hidden" name="datamodel_path" value="'.htmlentities($sCompatibleDMDir, ENT_QUOTES, 'UTF-8').'">');
 				$oPage->add('<input type="hidden" name="datamodel_version" value="'.htmlentities($sUpgradeDMVersion, ENT_QUOTES, 'UTF-8').'">');
@@ -675,9 +675,12 @@ class WizStepLicense extends WizardStep
 		return array('class' => 'WizStepDBParams', 'state' => '');
 	}
 
-	public function Display(WebPage $oPage)
-	{
-		$aLicenses = SetupUtils::GetLicenses();
+    /**
+     * @param WebPage $oPage
+     */
+    public function Display(WebPage $oPage)
+    {
+        $aLicenses = SetupUtils::GetLicenses();
 
 		$oPage->add('<h2>Licenses agreements for the components of '.ITOP_APPLICATION.'</h2>');
 		$oPage->add_style('div a.no-arrow { background:transparent; padding-left:0;}');
@@ -685,17 +688,19 @@ class WizStepLicense extends WizardStep
 		$oPage->add('<fieldset>');
 		$oPage->add('<legend>Components of '.ITOP_APPLICATION.'</legend>');
 		$oPage->add('<ul>');
-		foreach($aLicenses as $index => $oLicense)
+        $index = 0;
+        foreach ($aLicenses as $oLicense)
 		{
 			$oPage->add('<li><b>'.$oLicense->product.'</b>, &copy; '.$oLicense->author.' is licensed under the <b>'.$oLicense->license_type.' license</b>. (<span class="toggle" id="toggle_'.$index.'">Details</span>)');
 			$oPage->add('<div id="license_'.$index.'" class="license_text" style="display:none;overflow:auto;max-height:10em;font-size:small;border:1px #696969 solid;margin-bottom:1em; margin-top:0.5em;padding:0.5em;">'.$oLicense->text.'</div>');
 			$oPage->add_ready_script('$(".license_text a").attr("target", "_blank").addClass("no-arrow");');
 			$oPage->add_ready_script('$("#toggle_'.$index.'").click( function() { $("#license_'.$index.'").toggle(); } );');
+            $index++;
 		}
 		$oPage->add('</ul>');
 		$oPage->add('</fieldset>');
-		$sChecked = ($this->oWizard->GetParameter('accept_license', 'no') == 'yes') ? ' checked ' : ''; 
-		$oPage->p('<input type="checkbox" name="accept_license" id="accept" value="yes"'.$sChecked.'><label for="accept">&nbsp;I accept the terms of the licenses of the '.count($aLicenses).' components mentioned above.</label>');
+        $sChecked = ($this->oWizard->GetParameter('accept_license', 'no') == 'yes') ? ' checked ' : '';
+        $oPage->p('<input type="checkbox" name="accept_license" id="accept" value="yes" '.$sChecked.'><label for="accept">&nbsp;I accept the terms of the licenses of the '.count($aLicenses).' components mentioned above.</label>');
 		$oPage->add_ready_script('$("#accept").bind("click change", function() { WizardUpdateButtons(); });');
 	}
 	
@@ -707,7 +712,8 @@ class WizStepLicense extends WizardStep
 	{
 		return 'return ($("#accept").attr("checked") === "checked");';
 	}
-	
+
+
 }
 
 /**
@@ -803,7 +809,7 @@ class WizStepDBParams extends WizardStep
 	bRet = ValidateField("db_name", true) && bRet;
 	bRet = ValidateField("db_new_name", true) && bRet;
 	bRet = ValidateField("db_prefix", true) && bRet;
-	
+
 	return bRet;
 EOF
 		;
@@ -956,10 +962,10 @@ class WizStepMiscParams extends WizardStep
 		$oPage->add('</fieldset>');
 		$oPage->add('<fieldset>');
 		$oPage->add('<legend>Sample Data</legend>');
-		$sChecked = ($sSampleData == 'yes') ? ' checked ' : '';
-		$oPage->p('<input id="sample_data_yes" name="sample_data" type="radio" value="yes"'.$sChecked.'><label for="sample_data_yes">&nbsp;I am installing a <b>demo or test</b> instance, populate the database with some demo data.');
-		$sChecked = ($sSampleData == 'no') ? ' checked ' : '';
-		$oPage->p('<input id="sample_data_no" name="sample_data" type="radio" value="no"'.$sChecked.'><label for="sample_data_no">&nbsp;I am installing a <b>production</b> instance, create an empty database to start from.');
+        $sChecked = ($sSampleData == 'yes') ? 'checked ' : '';
+        $oPage->p('<input id="sample_data_yes" name="sample_data" type="radio" value="yes" '.$sChecked.'><label for="sample_data_yes">&nbsp;I am installing a <b>demo or test</b> instance, populate the database with some demo data.');
+        $sChecked = ($sSampleData == 'no') ? 'checked ' : '';
+        $oPage->p('<input id="sample_data_no" name="sample_data" type="radio" value="no" '.$sChecked.'><label for="sample_data_no">&nbsp;I am installing a <b>production</b> instance, create an empty database to start from.');
 		$oPage->add('</fieldset>');
 		$oPage->add_ready_script(
 <<<EOF